4 # This file is part of Koha.
6 # Koha is free software; you can redistribute it and/or modify it under the
7 # terms of the GNU General Public License as published by the Free Software
8 # Foundation; either version 2 of the License, or (at your option) any later
11 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along with
16 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
17 # Suite 330, Boston, MA 02111-1307 USA
24 use C4::Dates qw/format_date/;
25 use C4::Overdues; # AddNotifyLine
30 =head1 branchoverdues.pl
32 this module is a new interface, allow to the librarian to check all items on overdues (based on the acountlines type 'FU' )
33 this interface is filtered by branches (automatically), and by location (optional) ....
34 all informations are stocked in the notifys BDD
36 FIXME for this time, we have only four methods to notify :
37 - mail : work with a batch programm
38 - letter : for us, the letters are generated by an open-office program
39 - phone : Simple method, when the method 'phone' is selected, we consider, that the borrower as been notified, and the notify send date is implemented
40 - considered lost : for us if the document is on the third overduelevel,
42 FIXME the methods are actually hardcoded for the levels : (maybe can be improved by a new possibility in overduerule)
44 level 1 : three methods are possible : - mail, letter, phone
45 level 2 : only one method is possible : - letter
46 level 3 : only methode is possible : - Considered Lost
48 the documents displayed on this interface, are checked on three points
49 - 1) the document must be on accountlines (Type 'FU')
50 - 2) item issues is not returned
51 - 3) this item as not been already notify
56 my $dbh = C4::Context->dbh;
58 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
60 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
62 template_name => "circ/branchoverdues.tmpl",
66 flagsrequired => { circulate => 1 },
71 my $default = C4::Context->userenv->{'branch'};
73 # Deal with the vars recept from the template
74 my $borrowernumber = $input->param('borrowernumber');
75 my $itemnumber = $input->param('itemnumber');
76 my $method = $input->param('method');
77 my $overduelevel = $input->param('overduelevel');
78 my $notifyId = $input->param('notifyId');
79 my $location = $input->param('location');
81 # now create the line in bdd (notifys)
82 if ( $input->param('action') eq 'add' ) {
84 AddNotifyLine( $borrowernumber, $itemnumber, $overduelevel, $method,
87 elsif ( $input->param('action') eq 'remove' ) {
88 my $notify_date = $input->param('notify_date');
90 RemoveNotifyLine( $borrowernumber, $itemnumber, $notify_date );
94 my @todayoverduesloop;
97 my @getoverdues = GetOverduesForBranch( $default, $location );
99 $debug and warn "HERE : $default / $location" . Dumper(@getoverdues);
100 # search for location authorised value
101 my ($tag,$subfield) = GetMarcFromKohaField('items.location','');
102 my $tagslib = &GetMarcStructure(1,'');
103 if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
104 my $values= GetAuthorisedValues($tagslib->{$tag}->{$subfield}->{authorised_value});
105 $template->param(locationsloop => $values);
108 foreach my $num (@getoverdues) {
110 my %overdueforbranch;
111 $overdueforbranch{'date_due'} = format_date( $num->{'date_due'} );
112 $overdueforbranch{'title'} = $num->{'title'};
113 $overdueforbranch{'description'} = $num->{'description'};
114 $overdueforbranch{'barcode'} = $num->{'barcode'};
115 $overdueforbranch{'biblionumber'} = $num->{'biblionumber'};
116 $overdueforbranch{'borrowersurname'} = $num->{'surname'};
117 $overdueforbranch{'borrowerfirstname'} = $num->{'firstname'};
118 $overdueforbranch{'borrowerphone'} = $num->{'phone'};
119 $overdueforbranch{'borroweremail'} = $num->{'email'};
120 $overdueforbranch{'itemcallnumber'} = $num->{'itemcallnumber'};
121 $overdueforbranch{'borrowernumber'} = $num->{'borrowernumber'};
122 $overdueforbranch{'itemnumber'} = $num->{'itemnumber'};
124 # now we add on the template, the differents values of notify_level
125 if ( $num->{'notify_level'} eq '1' ) {
126 $overdueforbranch{'overdue1'} = 1;
127 $overdueforbranch{'overdueLevel'} = 1;
130 if ( $num->{'notify_level'} eq '2' ) {
131 $overdueforbranch{'overdue2'} = 1;
132 $overdueforbranch{'overdueLevel'} = 2;
135 if ( $num->{'notify_level'} eq '3' ) {
136 $overdueforbranch{'overdue3'} = 1;
137 $overdueforbranch{'overdueLevel'} = 3;
139 $overdueforbranch{'notify_id'} = $num->{'notify_id'};
141 push( @overduesloop, \%overdueforbranch );
144 # initiate the templates for the overdueloop
146 overduesloop => \@overduesloop,
147 show_date => format_date(C4::Dates->today('iso')),
148 location => $location,
151 output_html_with_http_headers $input, $cookie, $template->output;