3 # Copyright 2000-2002 Katipo Communications
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
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 use C4
::Branch
; # GetBranchName
27 use C4
::Dates qw
/format_date/;
43 my $item = $input->param('itemnumber');
44 my $borrowernumber = $input->param('borrowernumber');
45 my $fbr = $input->param('fbr') || '';
46 my $tbr = $input->param('tbr') || '';
47 my $all_branches = $input->param('allbranches') || '';
51 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
53 template_name
=> "circ/waitingreserves.tmpl",
57 flagsrequired
=> { circulate
=> "circulate_remaining_permissions" },
62 my $default = C4
::Context
->userenv->{'branch'};
64 # if we have a return from the form we launch the subroutine CancelReserve
66 my ( $messages, $nextreservinfo ) = ModReserveCancelAll
( $item, $borrowernumber );
68 if ($nextreservinfo) {
69 my $borrowerinfo = GetMemberDetails
( $nextreservinfo );
70 my $iteminfo = GetBiblioFromItemNumber
($item);
71 if ( $messages->{'transfert'} ) {
73 messagetransfert
=> $messages->{'transfert'},
74 branchname
=> GetBranchName
($messages->{'transfert'}),
80 nextreservnumber
=> $nextreservinfo,
81 nextreservsurname
=> $borrowerinfo->{'surname'},
82 nextreservfirstname
=> $borrowerinfo->{'firstname'},
83 nextreservitem
=> $item,
84 nextreservtitle
=> $iteminfo->{'title'},
85 waiting
=> ($messages->{'waiting'}) ?
1 : 0,
89 # if the document is not in his homebranch location and there is not reservation after, we transfer it
90 if ($fbr ne $tbr and not $nextreservinfo) {
91 ModItemTransfer
( $item, $fbr, $tbr );
94 if ( C4
::Context
->preference('IndependantBranches') ) {
97 $template->param( all_branches_link
=> $input->url . '?allbranches=1&' . $input->query_string )
101 my (@reservloop, @overloop);
102 my ($reservcount, $overcount);
103 my @getreserves = $all_branches ? GetReservesForBranch
() : GetReservesForBranch
($default);
104 # get reserves for the branch we are logged into, or for all branches
106 my $today = Date_to_Days
(&Today
);
107 foreach my $num (@getreserves) {
108 next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00');
110 my $gettitle = GetBiblioFromItemNumber
( $num->{'itemnumber'} );
111 # fix up item type for display
112 $gettitle->{'itemtype'} = C4
::Context
->preference('item-level_itypes') ?
$gettitle->{'itype'} : $gettitle->{'itemtype'};
113 my $getborrower = GetMemberDetails
( $num->{'borrowernumber'} );
114 my $itemtypeinfo = getitemtypeinfo
( $gettitle->{'itemtype'} ); # using the fixed up itype/itemtype
115 $getreserv{'waitingdate'} = format_date
( $num->{'waitingdate'} );
117 my ( $waiting_year, $waiting_month, $waiting_day ) = split (/-/, $num->{'waitingdate'});
118 ( $waiting_year, $waiting_month, $waiting_day ) =
119 Add_Delta_Days
( $waiting_year, $waiting_month, $waiting_day,
120 C4
::Context
->preference('ReservesMaxPickUpDelay'));
121 my $calcDate = Date_to_Days
( $waiting_year, $waiting_month, $waiting_day );
123 $getreserv{'itemtype'} = $itemtypeinfo->{'description'};
124 $getreserv{'title'} = $gettitle->{'title'};
125 $getreserv{'itemnumber'} = $gettitle->{'itemnumber'};
126 $getreserv{'biblionumber'} = $gettitle->{'biblionumber'};
127 $getreserv{'barcode'} = $gettitle->{'barcode'};
128 $getreserv{'homebranch'} = GetBranchName
($gettitle->{'homebranch'});
129 $getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'};
130 $getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
131 if ( $gettitle->{'homebranch'} ne $gettitle->{'holdingbranch'} ) {
132 $getreserv{'dotransfer'} = 1;
134 $getreserv{'borrowernum'} = $getborrower->{'borrowernumber'};
135 $getreserv{'borrowername'} = $getborrower->{'surname'};
136 $getreserv{'borrowerfirstname'} = $getborrower->{'firstname'};
137 $getreserv{'borrowerphone'} = $getborrower->{'phone'};
138 if ( $getborrower->{'emailaddress'} ) {
139 $getreserv{'borrowermail'} = $getborrower->{'emailaddress'};
142 if ($today > $calcDate) {
143 push @overloop, \
%getreserv;
146 push @reservloop, \
%getreserv;
153 reserveloop
=> \
@reservloop,
154 reservecount
=> $reservcount,
155 overloop
=> \
@overloop,
156 overcount
=> $overcount,
157 show_date
=> format_date
(C4
::Dates
->today('iso')),
158 dateformat
=> C4
::Context
->preference("dateformat"),
161 output_html_with_http_headers
$input, $cookie, $template->output;