4 # This file is part of Koha.
6 # Koha is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # Koha is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 #use warnings; FIXME - Bug 2505
30 use Koha::BiblioFrameworks;
33 =head1 branchoverdues.pl
35 this module is a new interface, allow to the librarian to check all items on overdues (based on the acountlines type 'FU' )
36 this interface is filtered by branches (automatically), and by location (optional) ....
38 FIXME for this time, we have only four methods to notify :
39 - mail : work with a batch programm
40 - letter : for us, the letters are generated by an open-office program
41 - phone : Simple method, when the method 'phone' is selected, we consider, that the borrower as been notified, and the notify send date is implemented
42 - considered lost : for us if the document is on the third overduelevel,
44 FIXME the methods are actually hardcoded for the levels : (maybe can be improved by a new possibility in overduerule)
46 level 1 : three methods are possible : - mail, letter, phone
47 level 2 : only one method is possible : - letter
48 level 3 : only methode is possible : - Considered Lost
50 the documents displayed on this interface, are checked on three points
51 - 1) the document must be on accountlines (Type 'FU')
52 - 2) item issues is not returned
53 - 3) this item as not been already notify
55 FIXME: who is the author?
56 FIXME: No privisions (i.e. "actions") for handling notices are implemented.
57 FIXME: This is linked as "Overdue Fines" but the relationship to fines in GetOverduesForBranch is more complicated than that.
62 my $dbh = C4::Context->dbh;
64 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user({
65 template_name => "circ/branchoverdues.tt",
69 flagsrequired => { circulate => "circulate_remaining_permissions" },
73 my $default = C4::Context->userenv->{'branch'};
75 # Deal with the vars recept from the template
76 my $borrowernumber = $input->param('borrowernumber');
77 my $itemnumber = $input->param('itemnumber');
78 my $method = $input->param('method');
79 my $overduelevel = $input->param('overduelevel');
80 my $notifyId = $input->param('notifyId');
81 my $location = $input->param('location');
83 # FIXME: better check that borrowernumber is defined and valid.
84 # FIXME: same for itemnumber and other variables passed in here.
87 my @getoverdues = GetOverduesForBranch( $default, $location );
88 $debug and warn "HERE : $default / $location" . Dumper(@getoverdues);
89 # search for location authorised value
90 my ($tag,$subfield) = GetMarcFromKohaField('items.location','');
91 my $tagslib = &GetMarcStructure(1,'');
92 if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
93 my $values= GetAuthorisedValues($tagslib->{$tag}->{$subfield}->{authorised_value});
94 for (@$values) { $_->{selected} = 1 if $location eq $_->{authorised_value} }
95 $template->param(locationsloop => $values);
98 foreach my $num (@getoverdues) {
100 my $record = GetMarcBiblio({ biblionumber => $num->{biblionumber} });
102 $overdueforbranch{'subtitle'} = GetRecordValue('subtitle',$record,'')->[0]->{subfield};
104 my $dt = dt_from_string($num->{date_due}, 'sql');
105 $overdueforbranch{'date_due'} = output_pref($dt);
106 $overdueforbranch{'title'} = $num->{'title'};
107 $overdueforbranch{'description'} = $num->{'description'};
108 $overdueforbranch{'barcode'} = $num->{'barcode'};
109 $overdueforbranch{'biblionumber'} = $num->{'biblionumber'};
110 $overdueforbranch{'author'} = $num->{'author'};
111 $overdueforbranch{'borrowersurname'} = $num->{'surname'};
112 $overdueforbranch{'borrowerfirstname'} = $num->{'firstname'};
113 $overdueforbranch{'borrowerphone'} = $num->{'phone'};
114 $overdueforbranch{'borroweremail'} = $num->{'email'};
115 $overdueforbranch{'homebranch'} = $num->{'homebranch'};
116 $overdueforbranch{'itemcallnumber'} = $num->{'itemcallnumber'};
117 $overdueforbranch{'borrowernumber'} = $num->{'borrowernumber'};
118 $overdueforbranch{'itemnumber'} = $num->{'itemnumber'};
119 $overdueforbranch{'cardnumber'} = $num->{'cardnumber'};
121 # now we add on the template, the differents values of notify_level
122 # FIXME: numerical comparison, not string eq.
123 if ( $num->{'notify_level'} eq '1' ) {
124 $overdueforbranch{'overdue1'} = 1;
125 $overdueforbranch{'overdueLevel'} = 1;
127 elsif ( $num->{'notify_level'} eq '2' ) {
128 $overdueforbranch{'overdue2'} = 1;
129 $overdueforbranch{'overdueLevel'} = 2;
131 elsif ( $num->{'notify_level'} eq '3' ) {
132 $overdueforbranch{'overdue3'} = 1;
133 $overdueforbranch{'overdueLevel'} = 3;
135 $overdueforbranch{'notify_id'} = $num->{'notify_id'};
137 push( @overduesloop, \%overdueforbranch );
140 # initiate the templates for the overdueloop
142 overduesloop => \@overduesloop,
143 location => $location,
146 # Checking if there is a Fast Cataloging Framework
147 $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
149 output_html_with_http_headers $input, $cookie, $template->output;