5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
23 use C4::Interface::CGI::Output;
26 use C4::Circulation::Circ2; # AddNotifyLine
27 use C4::Koha; # GetDepartement...
30 use Date::Calc qw/Today Today_and_Now Now/;
32 =head1 branchoverdues.pl
34 this module is a new interface, allow to the librarian to check all items on overdues (based on the acountlines type 'FU' )
35 this interface is filtered by branches (automaticly), and by department (optional) ....
36 all informations are stocked in the notifys BDD
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
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'};
74 my ( $year, $month, $day ) = &Today;
75 my $todaysdate = join "-", ( $year, $month, $day );
77 # Deal with the vars recept from the template
78 my $borrowernumber = $input->param('borrowernumber');
79 my $itemnumber = $input->param('itemnumber');
80 my $method = $input->param('method');
81 my $overduelevel = $input->param('overduelevel');
82 my $notifyId = $input->param('notifyId');
83 my $department = $input->param('department');
85 # now create the line in bdd (notifys)
86 if ( $input->param('action') eq 'add' ) {
88 AddNotifyLine( $borrowernumber, $itemnumber, $overduelevel, $method,
92 # possibility to remove notify line
93 if ( $input->param('action') eq 'remove' ) {
94 my $notify_date = $input->param('notify_date');
96 RemoveNotifyLine( $borrowernumber, $itemnumber, $notify_date );
100 my @todayoverduesloop;
103 my @getoverdues = GetOverduesForBranch( $default, $department );
105 # filter by department
107 my ( $departmentlib, $departmentValue ) = GetDepartementLib($department);
109 department => $departmentlib,
110 departmentValue => $departmentValue,
115 # initiate the selector of departments .....
116 my @getdepartments = GetDepartements();
118 foreach my $dpt (@getdepartments) {
120 $department{'authorised_value'} = $dpt->{'authorised_value'};
121 $department{'lib'} = $dpt->{'lib'};
122 push( @departmentsloop, \%department );
124 $template->param( departmentsloop => \@departmentsloop, );
128 foreach my $num (@getoverdues) {
130 my %overdueforbranch;
131 $overdueforbranch{'date_due'} = format_date( $num->{'date_due'} );
132 $overdueforbranch{'title'} = $num->{'title'};
133 $overdueforbranch{'description'} = $num->{'description'};
134 $overdueforbranch{'barcode'} = $num->{'barcode'};
135 $overdueforbranch{'biblionumber'} = $num->{'biblionumber'};
136 $overdueforbranch{'borrowersurname'} = $num->{'surname'};
137 $overdueforbranch{'borrowerfirstname'} = $num->{'firstname'};
138 $overdueforbranch{'borrowerphone'} = $num->{'phone'};
139 $overdueforbranch{'borroweremail'} = $num->{'email'};
140 $overdueforbranch{'itemcallnumber'} = $num->{'itemcallnumber'};
141 $overdueforbranch{'borrowernumber'} = $num->{'borrowernumber'};
142 $overdueforbranch{'itemnumber'} = $num->{'itemnumber'};
144 # now we add on the template, the differents values of notify_level
145 if ( $num->{'notify_level'} eq '1' ) {
146 $overdueforbranch{'overdue1'} = 1;
147 $overdueforbranch{'overdueLevel'} = 1;
150 if ( $num->{'notify_level'} eq '2' ) {
151 $overdueforbranch{'overdue2'} = 1;
152 $overdueforbranch{'overdueLevel'} = 2;
155 if ( $num->{'notify_level'} eq '3' ) {
156 $overdueforbranch{'overdue3'} = 1;
157 $overdueforbranch{'overdueLevel'} = 3;
159 $overdueforbranch{'notify_id'} = $num->{'notify_id'};
161 push( @overduesloop, \%overdueforbranch );
164 # initiate the templates for the overdueloop
166 overduesloop => \@overduesloop,
167 show_date => format_date($todaysdate),
170 output_html_with_http_headers $input, $cookie, $template->output;