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 with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 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') || '';
50 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
52 template_name
=> "circ/waitingreserves.tmpl",
56 flagsrequired
=> { circulate
=> "circulate_remaining_permissions" },
61 my $default = C4
::Context
->userenv->{'branch'};
63 # if we have a return from the form we launch the subroutine CancelReserve
65 my ( $messages, $nextreservinfo ) = ModReserveCancelAll
( $item, $borrowernumber );
67 if ($nextreservinfo) {
68 my $borrowerinfo = GetMemberDetails
( $nextreservinfo );
69 my $iteminfo = GetBiblioFromItemNumber
($item);
70 if ( $messages->{'transfert'} ) {
72 messagetransfert
=> $messages->{'transfert'},
73 branchname
=> GetBranchName
($messages->{'transfert'}),
79 nextreservnumber
=> $nextreservinfo,
80 nextreservsurname
=> $borrowerinfo->{'surname'},
81 nextreservfirstname
=> $borrowerinfo->{'firstname'},
82 nextreservitem
=> $item,
83 nextreservtitle
=> $iteminfo->{'title'},
84 waiting
=> ($messages->{'waiting'}) ?
1 : 0,
88 # if the document is not in his homebranch location and there is not reservation after, we transfer it
89 if ($fbr ne $tbr and not $nextreservinfo) {
90 ModItemTransfer
( $item, $fbr, $tbr );
95 my @getreserves = C4
::Context
->preference('IndependantBranches') ? GetReservesForBranch
($default) : GetReservesForBranch
();
96 # get reserves for the branch we are logged into, or for all branches
98 my $today = Date_to_Days
(&Today
);
99 foreach my $num (@getreserves) {
100 next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00');
102 my $gettitle = GetBiblioFromItemNumber
( $num->{'itemnumber'} );
103 # fix up item type for display
104 $gettitle->{'itemtype'} = C4
::Context
->preference('item-level_itypes') ?
$gettitle->{'itype'} : $gettitle->{'itemtype'};
105 my $getborrower = GetMemberDetails
( $num->{'borrowernumber'} );
106 my $itemtypeinfo = getitemtypeinfo
( $gettitle->{'itemtype'} ); # using the fixed up itype/itemtype
107 $getreserv{'waitingdate'} = format_date
( $num->{'waitingdate'} );
109 my ( $waiting_year, $waiting_month, $waiting_day ) = split /-/, $num->{'waitingdate'};
110 ( $waiting_year, $waiting_month, $waiting_day ) =
111 Add_Delta_Days
( $waiting_year, $waiting_month, $waiting_day,
112 C4
::Context
->preference('ReservesMaxPickUpDelay'));
113 my $calcDate = Date_to_Days
( $waiting_year, $waiting_month, $waiting_day );
115 if ($today > $calcDate) {
116 $getreserv{'messcompa'} = 1;
118 $getreserv{'itemtype'} = $itemtypeinfo->{'description'};
119 $getreserv{'title'} = $gettitle->{'title'};
120 $getreserv{'itemnumber'} = $gettitle->{'itemnumber'};
121 $getreserv{'biblionumber'} = $gettitle->{'biblionumber'};
122 $getreserv{'barcode'} = $gettitle->{'barcode'};
123 $getreserv{'homebranch'} = $gettitle->{'homebranch'};
124 $getreserv{'holdingbranch'} = $gettitle->{'holdingbranch'};
125 $getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
126 if ( $gettitle->{'homebranch'} ne $gettitle->{'holdingbranch'} ) {
127 $getreserv{'dotransfer'} = 1;
129 $getreserv{'borrowernum'} = $getborrower->{'borrowernumber'};
130 $getreserv{'borrowername'} = $getborrower->{'surname'};
131 $getreserv{'borrowerfirstname'} = $getborrower->{'firstname'};
132 $getreserv{'borrowerphone'} = $getborrower->{'phone'};
133 if ( $getborrower->{'emailaddress'} ) {
134 $getreserv{'borrowermail'} = $getborrower->{'emailaddress'};
136 push @reservloop, \
%getreserv;
140 reserveloop
=> \
@reservloop,
141 show_date
=> format_date
(C4
::Dates
->today('iso')),
142 dateformat
=> C4
::Context
->preference("dateformat"),
145 output_html_with_http_headers
$input, $cookie, $template->output;