5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA 02111-1307 USA
29 use C4::Circulation::Circ2;
36 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
38 my ($template, $loggedinuser, $cookie)
39 = get_template_and_user({template_name => "circ/waitingreservestransfers.tmpl",
43 flagsrequired => {borrowers => 1},
48 # set the userenv branch
49 my $default = C4::Context->userenv->{'branch'};
52 my @datearr = localtime(time());
53 my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]);
55 my $item=$input->param('itemnumber');
56 my $fbr=$input->param('fbr');
57 my $tbr=$input->param('tbr');
58 # If we have a return of the form dotransfer, we launch the subroutine dotransfer
60 C4::Circulation::Circ2::dotransfer($item,$fbr,$tbr);
63 # get the all the branches for reference
64 my $branches = GetBranches();
66 foreach my $br (keys %$branches) {
69 $branchloop{'branchname'} = $branches->{$br}->{'branchname'};
70 $branchloop{'branchcode'} = $branches->{$br}->{'branchcode'};
71 my @getreserves = GetReservesToBranch($branches->{$br}->{'branchcode'},$default);
73 foreach my $num (@getreserves) {
76 my $gettitle = getiteminformation(\%env,$num->{'itemnumber'});
77 my $itemtypeinfo = getitemtypeinfo($gettitle->{'itemtype'});
78 if ($gettitle->{'holdingbranch'} eq $default){
79 my $getborrower = getpatroninformation (\%env,$num->{'borrowernumber'});
80 $getreserv{'reservedate'} = format_date($num->{'reservedate'});
81 my $calcDate=DateCalc($num->{'reservedate'},"+".C4::Context->preference('TransfersMaxDaysWarning')." days");
82 my $warning=Date_Cmp(ParseDate("today"),$calcDate);
84 $getreserv{'messcompa'} = 1;
86 $getreserv{'title'} = $gettitle->{'title'};
87 $getreserv{'biblionumber'} = $gettitle->{'biblionumber'};
88 $getreserv{'itemnumber'} = $gettitle->{'itemnumber'};
89 $getreserv{'barcode'} = $gettitle->{'barcode'};
90 $getreserv{'itemtype'} = $itemtypeinfo->{'description'};
91 $getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'};
92 $getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
93 $getreserv{'borrowernum'} = $getborrower->{'borrowernumber'};
94 $getreserv{'borrowername'} = $getborrower->{'surname'};
95 $getreserv{'borrowerfirstname'} = $getborrower->{'firstname'} ;
96 if ($getborrower->{'emailaddress'}){
97 $getreserv{'borrowermail'} = $getborrower->{'emailaddress'} ;
99 $getreserv{'borrowerphone'} = $getborrower->{'phone'};
100 push(@reservloop, \%getreserv);
103 # If we have a return of reservloop we put it in the branchloop sequence
105 $branchloop{'reserv'} = \@reservloop ;
107 # else, we unset the value of the branchcode .
109 $branchloop{'branchcode'} = 0;
113 # if we don't have a retrun from reservestobranch we unset branchname and branchcode
114 $branchloop{'branchname'} = 0;
115 $branchloop{'branchcode'} = 0;
117 push(@branchesloop, \%branchloop);
120 $template->param( branchesloop => \@branchesloop,
121 show_date => format_date($todaysdate)
124 print "Content-Type: text/html\n\n", $template->output;