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 if ($gettitle->{'holdingbranch'} eq $default){
78 my $getborrower = getpatroninformation (\%env,$num->{'borrowernumber'});
79 $getreserv{'reservedate'} = format_date($num->{'reservedate'});
80 my $calcDate=DateCalc($num->{'reservedate'},"+".C4::Context->preference('MaxDaysRecoveryReserves')." days");
81 my $warning=Date_Cmp(ParseDate("today"),$calcDate);
83 $getreserv{'messcompa'} = 1;
85 $getreserv{'title'} = $gettitle->{'title'};
86 $getreserv{'biblionumber'} = $gettitle->{'biblionumber'};
87 $getreserv{'itemnumber'} = $gettitle->{'itemnumber'};
88 $getreserv{'barcode'} = $gettitle->{'barcode'};
89 # $getreserv{'itemtype'} = get_iteminfos_of($gettitle->{'itemtype'}->{'description'});
90 $getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'};
91 $getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
92 $getreserv{'borrowernum'} = $getborrower->{'borrowernumber'};
93 $getreserv{'borrowername'} = $getborrower->{'surname'};
94 $getreserv{'borrowerfirstname'} = $getborrower->{'firstname'} ;
95 if ($getborrower->{'emailaddress'}){
96 $getreserv{'borrowermail'} = $getborrower->{'emailaddress'} ;
98 $getreserv{'borrowerphone'} = $getborrower->{'phone'};
99 push(@reservloop, \%getreserv);
102 # If we have a return of reservloop we put it in the branchloop sequence
104 $branchloop{'reserv'} = \@reservloop ;
106 # else, we unset the value of the branchcode .
108 $branchloop{'branchcode'} = 0;
112 # if we don't have a retrun from reservestobranch we unset branchname and branchcode
113 $branchloop{'branchname'} = 0;
114 $branchloop{'branchcode'} = 0;
116 push(@branchesloop, \%branchloop);
119 $template->param( branchesloop => \@branchesloop,
120 show_date => format_date($todaysdate)
123 print "Content-Type: text/html\n\n", $template->output;