3 # Copyright 2000-2002 Katipo Communications
4 # parts copyright 2010 BibLibre
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 use C4
::Branch
; # GetBranchName
28 use C4
::Dates qw
/format_date/;
44 my $item = $input->param('itemnumber');
45 my $borrowernumber = $input->param('borrowernumber');
46 my $fbr = $input->param('fbr') || '';
47 my $tbr = $input->param('tbr') || '';
48 my $all_branches = $input->param('allbranches') || '';
52 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
54 template_name
=> "circ/waitingreserves.tmpl",
58 flagsrequired
=> { circulate
=> "circulate_remaining_permissions" },
63 my $default = C4
::Context
->userenv->{'branch'};
65 # if we have a return from the form we launch the subroutine CancelReserve
67 my ( $messages, $nextreservinfo ) = ModReserveCancelAll
( $item, $borrowernumber );
69 if ($nextreservinfo) {
70 my $borrowerinfo = GetMemberDetails
( $nextreservinfo );
71 my $iteminfo = GetBiblioFromItemNumber
($item);
72 if ( $messages->{'transfert'} ) {
74 messagetransfert
=> $messages->{'transfert'},
75 branchname
=> GetBranchName
($messages->{'transfert'}),
81 nextreservnumber
=> $nextreservinfo,
82 nextreservsurname
=> $borrowerinfo->{'surname'},
83 nextreservfirstname
=> $borrowerinfo->{'firstname'},
84 nextreservitem
=> $item,
85 nextreservtitle
=> $iteminfo->{'title'},
86 waiting
=> ($messages->{'waiting'}) ?
1 : 0,
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 ModItemTransfer
( $item, $fbr, $tbr );
95 if ( C4
::Context
->preference('IndependantBranches') ) {
98 $template->param( all_branches_link
=> $input->url . '?allbranches=1&' . $input->query_string )
102 my (@reservloop, @overloop);
103 my ($reservcount, $overcount);
104 my @getreserves = $all_branches ? GetReservesForBranch
() : GetReservesForBranch
($default);
105 # get reserves for the branch we are logged into, or for all branches
107 my $today = Date_to_Days
(&Today
);
108 foreach my $num (@getreserves) {
109 next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00');
111 my $gettitle = GetBiblioFromItemNumber
( $num->{'itemnumber'} );
112 # fix up item type for display
113 $gettitle->{'itemtype'} = C4
::Context
->preference('item-level_itypes') ?
$gettitle->{'itype'} : $gettitle->{'itemtype'};
114 my $getborrower = GetMemberDetails
( $num->{'borrowernumber'} );
115 my $itemtypeinfo = getitemtypeinfo
( $gettitle->{'itemtype'} ); # using the fixed up itype/itemtype
116 $getreserv{'waitingdate'} = format_date
( $num->{'waitingdate'} );
118 my ( $waiting_year, $waiting_month, $waiting_day ) = split (/-/, $num->{'waitingdate'});
119 ( $waiting_year, $waiting_month, $waiting_day ) =
120 Add_Delta_Days
( $waiting_year, $waiting_month, $waiting_day,
121 C4
::Context
->preference('ReservesMaxPickUpDelay'));
122 my $calcDate = Date_to_Days
( $waiting_year, $waiting_month, $waiting_day );
124 $getreserv{'itemtype'} = $itemtypeinfo->{'description'};
125 $getreserv{'title'} = $gettitle->{'title'};
126 $getreserv{'itemnumber'} = $gettitle->{'itemnumber'};
127 $getreserv{'biblionumber'} = $gettitle->{'biblionumber'};
128 $getreserv{'barcode'} = $gettitle->{'barcode'};
129 $getreserv{'homebranch'} = GetBranchName
($gettitle->{'homebranch'});
130 $getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'};
131 $getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
132 if ( $gettitle->{'homebranch'} ne $gettitle->{'holdingbranch'} ) {
133 $getreserv{'dotransfer'} = 1;
135 $getreserv{'borrowernum'} = $getborrower->{'borrowernumber'};
136 $getreserv{'borrowername'} = $getborrower->{'surname'};
137 $getreserv{'borrowerfirstname'} = $getborrower->{'firstname'};
138 $getreserv{'borrowerphone'} = $getborrower->{'phone'};
139 if ( $getborrower->{'emailaddress'} ) {
140 $getreserv{'borrowermail'} = $getborrower->{'emailaddress'};
143 if ($today > $calcDate) {
144 push @overloop, \
%getreserv;
147 push @reservloop, \
%getreserv;
154 reserveloop
=> \
@reservloop,
155 reservecount
=> $reservcount,
156 overloop
=> \
@overloop,
157 overcount
=> $overcount,
158 show_date
=> format_date
(C4
::Dates
->today('iso')),
159 dateformat
=> C4
::Context
->preference("dateformat"),
160 ReservesMaxPickUpDelay
=> C4
::Context
->preference('ReservesMaxPickUpDelay')
163 output_html_with_http_headers
$input, $cookie, $template->output;