Bug 6536: QA Follow-up for string changes referring to Z39.50
[koha.git] / circ / branchoverdues.pl
blobc5a8743529a3b3a653a4b524c3a4726cf77fd6e3
1 #!/usr/bin/perl
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
9 # version.
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
19 use strict;
20 #use warnings; FIXME - Bug 2505
21 use C4::Context;
22 use CGI;
23 use C4::Output;
24 use C4::Auth;
25 use C4::Overdues; # AddNotifyLine
26 use C4::Biblio;
27 use C4::Koha;
28 use C4::Debug;
29 use C4::Branch;
30 use Koha::DateUtils;
31 use Data::Dumper;
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) ....
37 all informations are stocked in the notifys BDD
39 FIXME for this time, we have only four methods to notify :
40 - mail : work with a batch programm
41 - letter : for us, the letters are generated by an open-office program
42 - phone : Simple method, when the method 'phone' is selected, we consider, that the borrower as been notified, and the notify send date is implemented
43 - considered lost : for us if the document is on the third overduelevel,
45 FIXME the methods are actually hardcoded for the levels : (maybe can be improved by a new possibility in overduerule)
47 level 1 : three methods are possible : - mail, letter, phone
48 level 2 : only one method is possible : - letter
49 level 3 : only methode is possible : - Considered Lost
51 the documents displayed on this interface, are checked on three points
52 - 1) the document must be on accountlines (Type 'FU')
53 - 2) item issues is not returned
54 - 3) this item as not been already notify
56 FIXME: who is the author?
57 FIXME: No privisions (i.e. "actions") for handling notices are implemented.
58 FIXME: This is linked as "Overdue Fines" but the relationship to fines in GetOverduesForBranch is more complicated than that.
60 =cut
62 my $input = new CGI;
63 my $dbh = C4::Context->dbh;
65 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
66 template_name => "circ/branchoverdues.tt",
67 query => $input,
68 type => "intranet",
69 authnotrequired => 0,
70 flagsrequired => { circulate => "circulate_remaining_permissions" },
71 debug => 1,
72 });
74 my $default = C4::Context->userenv->{'branch'};
76 # Deal with the vars recept from the template
77 my $borrowernumber = $input->param('borrowernumber');
78 my $itemnumber = $input->param('itemnumber');
79 my $method = $input->param('method');
80 my $overduelevel = $input->param('overduelevel');
81 my $notifyId = $input->param('notifyId');
82 my $location = $input->param('location');
84 # FIXME: better check that borrowernumber is defined and valid.
85 # FIXME: same for itemnumber and other variables passed in here.
87 # now create the line in bdd (notifys)
88 if ( $input->param('action') eq 'add' ) {
89 my $addnotify =
90 AddNotifyLine( $borrowernumber, $itemnumber, $overduelevel, $method,
91 $notifyId ) # FIXME: useless variable, no TMPL code for "action" exists.;
93 elsif ( $input->param('action') eq 'remove' ) {
94 my $notify_date = $input->param('notify_date');
95 my $removenotify =
96 RemoveNotifyLine( $borrowernumber, $itemnumber, $notify_date ); # FIXME: useless variable, no TMPL code for "action" exists.
99 my @overduesloop;
100 my @getoverdues = GetOverduesForBranch( $default, $location );
101 $debug and warn "HERE : $default / $location" . Dumper(@getoverdues);
102 # search for location authorised value
103 my ($tag,$subfield) = GetMarcFromKohaField('items.location','');
104 my $tagslib = &GetMarcStructure(1,'');
105 if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
106 my $values= GetAuthorisedValues($tagslib->{$tag}->{$subfield}->{authorised_value});
107 for (@$values) { $_->{selected} = 1 if $location eq $_->{authorised_value} }
108 $template->param(locationsloop => $values);
110 # now display infos
111 foreach my $num (@getoverdues) {
112 my %overdueforbranch;
113 my $record = GetMarcBiblio($num->{biblionumber});
114 if ($record){
115 $overdueforbranch{'subtitle'} = GetRecordValue('subtitle',$record,'')->[0]->{subfield};
117 my $dt = dt_from_string($num->{date_due}, 'sql');
118 $overdueforbranch{'date_due'} = output_pref($dt);
119 $overdueforbranch{'title'} = $num->{'title'};
120 $overdueforbranch{'description'} = $num->{'description'};
121 $overdueforbranch{'barcode'} = $num->{'barcode'};
122 $overdueforbranch{'biblionumber'} = $num->{'biblionumber'};
123 $overdueforbranch{'author'} = $num->{'author'};
124 $overdueforbranch{'borrowersurname'} = $num->{'surname'};
125 $overdueforbranch{'borrowerfirstname'} = $num->{'firstname'};
126 $overdueforbranch{'borrowerphone'} = $num->{'phone'};
127 $overdueforbranch{'borroweremail'} = $num->{'email'};
128 $overdueforbranch{'homebranch'} = GetBranchName($num->{'homebranch'});
129 $overdueforbranch{'itemcallnumber'} = $num->{'itemcallnumber'};
130 $overdueforbranch{'borrowernumber'} = $num->{'borrowernumber'};
131 $overdueforbranch{'itemnumber'} = $num->{'itemnumber'};
132 $overdueforbranch{'cardnumber'} = $num->{'cardnumber'};
134 # now we add on the template, the differents values of notify_level
135 # FIXME: numerical comparison, not string eq.
136 if ( $num->{'notify_level'} eq '1' ) {
137 $overdueforbranch{'overdue1'} = 1;
138 $overdueforbranch{'overdueLevel'} = 1;
140 elsif ( $num->{'notify_level'} eq '2' ) {
141 $overdueforbranch{'overdue2'} = 1;
142 $overdueforbranch{'overdueLevel'} = 2;
144 elsif ( $num->{'notify_level'} eq '3' ) {
145 $overdueforbranch{'overdue3'} = 1;
146 $overdueforbranch{'overdueLevel'} = 3;
148 $overdueforbranch{'notify_id'} = $num->{'notify_id'};
150 push( @overduesloop, \%overdueforbranch );
153 # initiate the templates for the overdueloop
154 $template->param(
155 overduesloop => \@overduesloop,
156 location => $location,
159 output_html_with_http_headers $input, $cookie, $template->output;