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
27 use C4::Circulation::Circ2;
34 my $item=$input->param('itemnumber');
35 my $borrowernumber=$input->param('borrowernumber');
36 my $fbr=$input->param('fbr');
37 my $tbr=$input->param('tbr');
42 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
44 my ($template, $loggedinuser, $cookie)
45 = get_template_and_user({template_name => "circ/branchreserves.tmpl",
49 flagsrequired => {borrowers => 1},
53 my $default = C4::Context->userenv->{'branch'};
54 my $dbh=C4::Context->dbh;
55 my $todaysdate = get_today();
58 # if we have a return from the form we launch the subroutine CancelReserve
64 ($messages,$nextreservinfo) = GlobalCancel($item,$borrowernumber);
67 my $borrowerinfo = getpatroninformation(\%env,$nextreservinfo);
68 my $iteminfo = C4::Circulation::Circ2::getiteminformation(\%env,$item);
69 if ($messages->{'transfert'}){
70 my $branchname = getbranchname($messages->{'transfert'});
72 messagetransfert => $messages->{'transfert'},
73 branchname => $branchname,
76 if ($messages->{'waiting'}){
82 nextreservnumber => $nextreservinfo,
83 nextreservsurname => $borrowerinfo->{'surname'},
84 nextreservfirstname => $borrowerinfo->{'firstname'},
85 nextreservitem => $item,
86 nextreservtitle => $iteminfo->{'title'},
90 # if the document is not in his homebranch location and there is not reservation after, we transfer it
91 if (($fbr ne $tbr) and (not $nextreservinfo)){
92 C4::Circulation::Circ2::dotransfer($item,$fbr,$tbr);
93 C4::Circulation::Circ2::itemseen($dbh,$itm);
98 my @getreserves = GetReservesForBranch($default);
99 foreach my $num (@getreserves) {
102 my $gettitle = getiteminformation(\%env,$num->{'itemnumber'});
103 my $getborrower = getpatroninformation (\%env,$num->{'borrowernumber'});
104 my $itemtypeinfo = getitemtypeinfo($gettitle->{'itemtype'});
105 $getreserv{'waitingdate'} = format_date($num->{'waitingdate'});
106 my $calcDate=DateCalc($num->{'waitingdate'},"+".C4::Context->preference('ReservesMaxPickUpDelay')." days");
107 my $warning=Date_Cmp(ParseDate("today"),$calcDate);
109 $getreserv{'messcompa'} = 1;
111 $getreserv{'title'} = $gettitle->{'title'};
112 $getreserv{'itemnumber'} = $gettitle->{'itemnumber'};
113 $getreserv{'biblionumber'} = $gettitle->{'biblionumber'};
114 $getreserv{'barcode'} = $gettitle->{'barcode'};
115 $getreserv{'itemtype'} = $itemtypeinfo->{'description'};
116 $getreserv{'homebranch'} = $gettitle->{'homebranch'};
117 $getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'};
118 if ($gettitle->{'homebranch'} ne $gettitle->{'holdingbranch'}){
119 $getreserv{'dotransfer'} = 1;
121 $getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
122 $getreserv{'borrowernum'} = $getborrower->{'borrowernumber'};
123 $getreserv{'borrowername'} = $getborrower->{'surname'};
124 $getreserv{'borrowerfirstname'} = $getborrower->{'firstname'} ;
125 if ($getborrower->{'emailaddress'}){
126 $getreserv{'borrowermail'} = $getborrower->{'emailaddress'} ;
128 $getreserv{'borrowerphone'} = $getborrower->{'phone'};
129 push(@reservloop, \%getreserv);
132 $template->param( reserveloop => \@reservloop,
133 show_date => format_date($todaysdate),
136 output_html_with_http_headers $input, $cookie, $template->output;