|
Lines 1-6
Link Here
|
| 1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
| 2 |
|
2 |
|
| 3 |
|
|
|
| 4 |
#writen 2/1/00 by chris@katipo.oc.nz |
3 |
#writen 2/1/00 by chris@katipo.oc.nz |
| 5 |
# Copyright 2000-2002 Katipo Communications |
4 |
# Copyright 2000-2002 Katipo Communications |
| 6 |
# Parts Copyright 2011 Catalyst IT |
5 |
# Parts Copyright 2011 Catalyst IT |
|
Lines 41-75
use C4::Koha;
Link Here
|
| 41 |
use C4::Circulation; |
40 |
use C4::Circulation; |
| 42 |
use C4::Dates qw/format_date/; |
41 |
use C4::Dates qw/format_date/; |
| 43 |
use C4::Members; |
42 |
use C4::Members; |
| 44 |
use C4::Search; # enabled_staff_search_views |
43 |
use C4::Search; # enabled_staff_search_views |
| 45 |
use Koha::DateUtils; |
44 |
use Koha::DateUtils; |
| 46 |
|
45 |
|
| 47 |
my $dbh = C4::Context->dbh; |
46 |
my $dbh = C4::Context->dbh; |
| 48 |
my $sth; |
47 |
my $sth; |
| 49 |
my $input = new CGI; |
48 |
my $input = new CGI; |
| 50 |
my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( |
49 |
my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( |
| 51 |
{ |
50 |
{ |
| 52 |
template_name => "reserve/request.tmpl", |
51 |
template_name => "reserve/request.tmpl", |
| 53 |
query => $input, |
52 |
query => $input, |
| 54 |
type => "intranet", |
53 |
type => "intranet", |
| 55 |
authnotrequired => 0, |
54 |
authnotrequired => 0, |
| 56 |
flagsrequired => { reserveforothers => 'place_holds' }, |
55 |
flagsrequired => { reserveforothers => 'place_holds' }, |
| 57 |
} |
56 |
} |
| 58 |
); |
57 |
); |
| 59 |
|
58 |
|
| 60 |
my $multihold = $input->param('multi_hold'); |
59 |
my $multihold = $input->param('multi_hold'); |
| 61 |
$template->param(multi_hold => $multihold); |
60 |
$template->param( multi_hold => $multihold ); |
| 62 |
my $showallitems = $input->param('showallitems'); |
61 |
my $showallitems = $input->param('showallitems'); |
| 63 |
|
62 |
|
| 64 |
# get Branches and Itemtypes |
63 |
# get Branches and Itemtypes |
| 65 |
my $branches = GetBranches(); |
64 |
my $branches = GetBranches(); |
| 66 |
my $itemtypes = GetItemTypes(); |
65 |
my $itemtypes = GetItemTypes(); |
| 67 |
|
66 |
|
| 68 |
my $userbranch = ''; |
67 |
my $userbranch = ''; |
| 69 |
if (C4::Context->userenv && C4::Context->userenv->{'branch'}) { |
68 |
if ( C4::Context->userenv && C4::Context->userenv->{'branch'} ) { |
| 70 |
$userbranch = C4::Context->userenv->{'branch'}; |
69 |
$userbranch = C4::Context->userenv->{'branch'}; |
| 71 |
} |
70 |
} |
| 72 |
|
71 |
my $pickupBranch = |
|
|
72 |
$input->param('pickup') ? $input->param('pickup') : $userbranch; |
| 73 |
|
73 |
|
| 74 |
# Select borrowers infos |
74 |
# Select borrowers infos |
| 75 |
my $findborrower = $input->param('findborrower'); |
75 |
my $findborrower = $input->param('findborrower'); |
|
Lines 79-168
my $borrowernumber_hold = $input->param('borrowernumber') || '';
Link Here
|
| 79 |
my $messageborrower; |
79 |
my $messageborrower; |
| 80 |
my $maxreserves; |
80 |
my $maxreserves; |
| 81 |
|
81 |
|
| 82 |
my $date = C4::Dates->today('iso'); |
82 |
my $date = C4::Dates->today('iso'); |
| 83 |
my $action = $input->param('action'); |
83 |
my $action = $input->param('action'); |
| 84 |
$action ||= q{}; |
84 |
$action ||= q{}; |
| 85 |
|
85 |
|
| 86 |
if ( $action eq 'move' ) { |
86 |
if ( $action eq 'move' ) { |
| 87 |
my $where = $input->param('where'); |
87 |
my $where = $input->param('where'); |
| 88 |
my $reserve_id = $input->param('reserve_id'); |
88 |
my $reserve_id = $input->param('reserve_id'); |
| 89 |
AlterPriority( $where, $reserve_id ); |
89 |
AlterPriority( $where, $reserve_id ); |
| 90 |
} elsif ( $action eq 'cancel' ) { |
90 |
} |
| 91 |
my $reserve_id = $input->param('reserve_id'); |
91 |
elsif ( $action eq 'cancel' ) { |
| 92 |
CancelReserve({ reserve_id => $reserve_id }); |
92 |
my $reserve_id = $input->param('reserve_id'); |
| 93 |
} elsif ( $action eq 'setLowestPriority' ) { |
93 |
CancelReserve( { reserve_id => $reserve_id } ); |
| 94 |
my $reserve_id = $input->param('reserve_id'); |
94 |
} |
| 95 |
ToggleLowestPriority( $reserve_id ); |
95 |
elsif ( $action eq 'setLowestPriority' ) { |
| 96 |
} elsif ( $action eq 'toggleSuspend' ) { |
96 |
my $reserve_id = $input->param('reserve_id'); |
| 97 |
my $reserve_id = $input->param('reserve_id'); |
97 |
ToggleLowestPriority($reserve_id); |
| 98 |
my $suspend_until = $input->param('suspend_until'); |
98 |
} |
| 99 |
ToggleSuspend( $reserve_id, $suspend_until ); |
99 |
elsif ( $action eq 'toggleSuspend' ) { |
|
|
100 |
my $reserve_id = $input->param('reserve_id'); |
| 101 |
my $suspend_until = $input->param('suspend_until'); |
| 102 |
ToggleSuspend( $reserve_id, $suspend_until ); |
| 100 |
} |
103 |
} |
| 101 |
|
104 |
|
| 102 |
if ($findborrower) { |
105 |
if ($findborrower) { |
| 103 |
my $borrowers = Search($findborrower, 'cardnumber'); |
106 |
my $borrowers = Search( $findborrower, 'cardnumber' ); |
| 104 |
|
107 |
|
| 105 |
if ($borrowers && @$borrowers) { |
108 |
if ( $borrowers && @$borrowers ) { |
| 106 |
if ( @$borrowers == 1 ) { |
109 |
if ( @$borrowers == 1 ) { |
| 107 |
$borrowernumber_hold = $borrowers->[0]->{'borrowernumber'}; |
110 |
$borrowernumber_hold = $borrowers->[0]->{'borrowernumber'}; |
| 108 |
} |
111 |
} |
| 109 |
else { |
112 |
else { |
| 110 |
$template->param( borrower_list => sort_borrowerlist($borrowers)); |
113 |
$template->param( borrower_list => sort_borrowerlist($borrowers) ); |
| 111 |
} |
114 |
} |
| 112 |
} else { |
115 |
} |
| 113 |
$messageborrower = "'$findborrower'"; |
116 |
else { |
| 114 |
} |
117 |
$messageborrower = "'$findborrower'"; |
|
|
118 |
} |
| 115 |
} |
119 |
} |
| 116 |
|
120 |
|
| 117 |
# If we have the borrowernumber because we've performed an action, then we |
121 |
# If we have the borrowernumber because we've performed an action, then we |
| 118 |
# don't want to try to place another reserve. |
122 |
# don't want to try to place another reserve. |
| 119 |
if ($borrowernumber_hold && !$action) { |
123 |
if ( $borrowernumber_hold && !$action ) { |
| 120 |
my $borrowerinfo = GetMember( borrowernumber => $borrowernumber_hold ); |
124 |
my $borrowerinfo = GetMember( borrowernumber => $borrowernumber_hold ); |
| 121 |
my $diffbranch; |
125 |
my $diffbranch; |
| 122 |
my @getreservloop; |
126 |
my @getreservloop; |
| 123 |
my $count_reserv = 0; |
127 |
my $count_reserv = 0; |
| 124 |
|
128 |
|
| 125 |
# we check the reserves of the borrower, and if he can reserv a document |
129 |
# we check the reserves of the borrower, and if he can reserv a document |
| 126 |
# FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ... |
130 |
# FIXME At this time we have a simple count of reservs, but, later, we could improve the infos "title" ... |
| 127 |
|
131 |
|
| 128 |
my $number_reserves = |
132 |
my $number_reserves = GetReserveCount( $borrowerinfo->{'borrowernumber'} ); |
| 129 |
GetReserveCount( $borrowerinfo->{'borrowernumber'} ); |
133 |
|
| 130 |
|
134 |
if ( C4::Context->preference('maxreserves') |
| 131 |
if ( C4::Context->preference('maxreserves') && ($number_reserves >= C4::Context->preference('maxreserves')) ) { |
135 |
&& ( $number_reserves >= C4::Context->preference('maxreserves') ) ) |
| 132 |
$maxreserves = 1; |
136 |
{ |
| 133 |
} |
137 |
$maxreserves = 1; |
| 134 |
|
138 |
} |
| 135 |
# we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn) |
139 |
|
| 136 |
my $expiry_date = $borrowerinfo->{dateexpiry}; |
140 |
# we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn) |
| 137 |
my $expiry = 0; # flag set if patron account has expired |
141 |
my $expiry_date = $borrowerinfo->{dateexpiry}; |
| 138 |
if ($expiry_date and $expiry_date ne '0000-00-00' and |
142 |
my $expiry = 0; # flag set if patron account has expired |
| 139 |
Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry_date)) { |
143 |
if ( $expiry_date |
| 140 |
$expiry = 1; |
144 |
and $expiry_date ne '0000-00-00' |
| 141 |
} |
145 |
and Date_to_Days( split /-/, $date ) > |
| 142 |
|
146 |
Date_to_Days( split /-/, $expiry_date ) ) |
| 143 |
# check if the borrower make the reserv in a different branch |
147 |
{ |
| 144 |
if ( $borrowerinfo->{'branchcode'} ne C4::Context->userenv->{'branch'} ) { |
148 |
$expiry = 1; |
| 145 |
$diffbranch = 1; |
149 |
} |
| 146 |
} |
150 |
|
| 147 |
|
151 |
# check if the borrower make the reserv in a different branch |
| 148 |
$template->param( |
152 |
if ( $borrowerinfo->{'branchcode'} ne C4::Context->userenv->{'branch'} ) { |
| 149 |
borrowernumber => $borrowerinfo->{'borrowernumber'}, |
153 |
$diffbranch = 1; |
| 150 |
borrowersurname => $borrowerinfo->{'surname'}, |
154 |
} |
| 151 |
borrowerfirstname => $borrowerinfo->{'firstname'}, |
155 |
|
| 152 |
borrowerstreetaddress => $borrowerinfo->{'address'}, |
156 |
$template->param( |
| 153 |
borrowercity => $borrowerinfo->{'city'}, |
157 |
borrowernumber => $borrowerinfo->{'borrowernumber'}, |
| 154 |
borrowerphone => $borrowerinfo->{'phone'}, |
158 |
borrowersurname => $borrowerinfo->{'surname'}, |
| 155 |
borrowermobile => $borrowerinfo->{'mobile'}, |
159 |
borrowerfirstname => $borrowerinfo->{'firstname'}, |
| 156 |
borrowerfax => $borrowerinfo->{'fax'}, |
160 |
borrowerstreetaddress => $borrowerinfo->{'address'}, |
| 157 |
borrowerphonepro => $borrowerinfo->{'phonepro'}, |
161 |
borrowercity => $borrowerinfo->{'city'}, |
| 158 |
borroweremail => $borrowerinfo->{'email'}, |
162 |
borrowerphone => $borrowerinfo->{'phone'}, |
| 159 |
borroweremailpro => $borrowerinfo->{'emailpro'}, |
163 |
borrowermobile => $borrowerinfo->{'mobile'}, |
| 160 |
borrowercategory => $borrowerinfo->{'category'}, |
164 |
borrowerfax => $borrowerinfo->{'fax'}, |
| 161 |
borrowerreservs => $count_reserv, |
165 |
borrowerphonepro => $borrowerinfo->{'phonepro'}, |
| 162 |
cardnumber => $borrowerinfo->{'cardnumber'}, |
166 |
borroweremail => $borrowerinfo->{'email'}, |
| 163 |
expiry => $expiry, |
167 |
borroweremailpro => $borrowerinfo->{'emailpro'}, |
| 164 |
diffbranch => $diffbranch, |
168 |
borrowercategory => $borrowerinfo->{'category'}, |
| 165 |
); |
169 |
borrowerreservs => $count_reserv, |
|
|
170 |
cardnumber => $borrowerinfo->{'cardnumber'}, |
| 171 |
expiry => $expiry, |
| 172 |
diffbranch => $diffbranch, |
| 173 |
); |
| 166 |
} |
174 |
} |
| 167 |
|
175 |
|
| 168 |
$template->param( messageborrower => $messageborrower ); |
176 |
$template->param( messageborrower => $messageborrower ); |
|
Lines 173-606
my $borrowerinfo = GetMember( borrowernumber => $borrowernumber_hold );
Link Here
|
| 173 |
my @biblionumbers = (); |
181 |
my @biblionumbers = (); |
| 174 |
my $biblionumbers = $input->param('biblionumbers'); |
182 |
my $biblionumbers = $input->param('biblionumbers'); |
| 175 |
if ($multihold) { |
183 |
if ($multihold) { |
| 176 |
@biblionumbers = split '/', $biblionumbers; |
184 |
@biblionumbers = split '/', $biblionumbers; |
| 177 |
} else { |
185 |
} |
| 178 |
push @biblionumbers, $input->param('biblionumber'); |
186 |
else { |
|
|
187 |
push @biblionumbers, $input->param('biblionumber'); |
| 179 |
} |
188 |
} |
| 180 |
|
189 |
|
| 181 |
my $itemdata_enumchron = 0; |
190 |
my $itemdata_enumchron = 0; |
| 182 |
my @biblioloop = (); |
191 |
my @biblioloop = (); |
| 183 |
foreach my $biblionumber (@biblionumbers) { |
192 |
foreach my $biblionumber (@biblionumbers) { |
| 184 |
|
193 |
|
| 185 |
my %biblioloopiter = (); |
194 |
my %biblioloopiter = (); |
| 186 |
|
195 |
|
| 187 |
my $dat = GetBiblioData($biblionumber); |
196 |
my $dat = GetBiblioData($biblionumber); |
| 188 |
|
197 |
|
| 189 |
unless ( CanBookBeReserved($borrowerinfo->{borrowernumber}, $biblionumber) ) { |
198 |
unless ( |
| 190 |
$maxreserves = 1; |
199 |
CanBookBeReserved( $borrowerinfo->{borrowernumber}, $biblionumber ) ) |
| 191 |
} |
200 |
{ |
| 192 |
|
201 |
$maxreserves = 1; |
| 193 |
my $alreadypossession; |
202 |
} |
| 194 |
if (not C4::Context->preference('AllowHoldsOnPatronsPossessions') and CheckIfIssuedToPatron($borrowerinfo->{borrowernumber},$biblionumber)) { |
203 |
|
| 195 |
$alreadypossession = 1; |
204 |
my $alreadypossession; |
| 196 |
} |
205 |
if ( not C4::Context->preference('AllowHoldsOnPatronsPossessions') |
| 197 |
|
206 |
and |
| 198 |
# get existing reserves ..... |
207 |
CheckIfIssuedToPatron( $borrowerinfo->{borrowernumber}, $biblionumber ) |
| 199 |
my ( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber,1); |
208 |
) |
| 200 |
my $totalcount = $count; |
209 |
{ |
| 201 |
my $holds_count = 0; |
210 |
$alreadypossession = 1; |
| 202 |
my $alreadyreserved = 0; |
211 |
} |
| 203 |
|
212 |
|
| 204 |
foreach my $res (@$reserves) { |
213 |
# get existing reserves ..... |
| 205 |
if ( defined $res->{found} && $res->{found} eq 'W' ) { |
214 |
my ( $count, $reserves ) = GetReservesFromBiblionumber( $biblionumber, 1 ); |
| 206 |
$count--; |
215 |
my $totalcount = $count; |
| 207 |
} |
216 |
my $holds_count = 0; |
| 208 |
|
217 |
my $alreadyreserved = 0; |
| 209 |
if ( defined $borrowerinfo && defined($borrowerinfo->{borrowernumber}) && ($borrowerinfo->{borrowernumber} eq $res->{borrowernumber}) ) { |
218 |
|
| 210 |
$holds_count++; |
219 |
foreach my $res (@$reserves) { |
| 211 |
} |
220 |
if ( defined $res->{found} && $res->{found} eq 'W' ) { |
| 212 |
} |
221 |
$count--; |
| 213 |
|
222 |
} |
| 214 |
if ( $holds_count ) { |
223 |
|
| 215 |
$alreadyreserved = 1; |
224 |
if ( defined $borrowerinfo |
| 216 |
$biblioloopiter{warn} = 1; |
225 |
&& defined( $borrowerinfo->{borrowernumber} ) |
| 217 |
$biblioloopiter{alreadyres} = 1; |
226 |
&& ( $borrowerinfo->{borrowernumber} eq $res->{borrowernumber} ) ) |
| 218 |
} |
227 |
{ |
| 219 |
|
228 |
$holds_count++; |
| 220 |
$template->param( |
229 |
} |
| 221 |
alreadyreserved => $alreadyreserved, |
230 |
} |
| 222 |
alreadypossession => $alreadypossession, |
231 |
|
| 223 |
); |
232 |
if ($holds_count) { |
| 224 |
|
233 |
$alreadyreserved = 1; |
| 225 |
# FIXME think @optionloop, is maybe obsolete, or must be switchable by a systeme preference fixed rank or not |
234 |
$biblioloopiter{warn} = 1; |
| 226 |
# make priorities options |
235 |
$biblioloopiter{alreadyres} = 1; |
| 227 |
|
236 |
} |
| 228 |
my @optionloop; |
237 |
|
| 229 |
for ( 1 .. $count + 1 ) { |
238 |
$template->param( |
| 230 |
push( |
239 |
alreadyreserved => $alreadyreserved, |
| 231 |
@optionloop, |
240 |
alreadypossession => $alreadypossession, |
| 232 |
{ |
241 |
); |
| 233 |
num => $_, |
242 |
|
| 234 |
selected => ( $_ == $count + 1 ), |
243 |
# FIXME think @optionloop, is maybe obsolete, or must be switchable by a systeme preference fixed rank or not |
| 235 |
} |
244 |
# make priorities options |
| 236 |
); |
245 |
|
| 237 |
} |
246 |
my @optionloop; |
| 238 |
# adding a fixed value for priority options |
247 |
for ( 1 .. $count + 1 ) { |
| 239 |
my $fixedRank = $count+1; |
248 |
push( |
| 240 |
|
249 |
@optionloop, |
| 241 |
my @branchcodes; |
250 |
{ |
| 242 |
my %itemnumbers_of_biblioitem; |
251 |
num => $_, |
| 243 |
my @itemnumbers; |
252 |
selected => ( $_ == $count + 1 ), |
| 244 |
|
253 |
} |
| 245 |
## $items is array of 'item' table numbers |
254 |
); |
| 246 |
if (my $items = get_itemnumbers_of($biblionumber)->{$biblionumber}){ |
255 |
} |
| 247 |
@itemnumbers = @$items; |
256 |
|
| 248 |
} |
257 |
# adding a fixed value for priority options |
| 249 |
my @hostitems = get_hostitemnumbers_of($biblionumber); |
258 |
my $fixedRank = $count + 1; |
| 250 |
if (@hostitems){ |
259 |
|
| 251 |
$template->param('hostitemsflag' => 1); |
260 |
my @branchcodes; |
| 252 |
push(@itemnumbers, @hostitems); |
261 |
my %itemnumbers_of_biblioitem; |
| 253 |
} |
262 |
my @itemnumbers; |
| 254 |
|
263 |
|
| 255 |
if (!@itemnumbers) { |
264 |
## $items is array of 'item' table numbers |
| 256 |
$template->param('noitems' => 1); |
265 |
if ( my $items = get_itemnumbers_of($biblionumber)->{$biblionumber} ) { |
| 257 |
$biblioloopiter{noitems} = 1; |
266 |
@itemnumbers = @$items; |
| 258 |
} |
|
|
| 259 |
|
| 260 |
## Hash of item number to 'item' table fields |
| 261 |
my $iteminfos_of = GetItemInfosOf(@itemnumbers); |
| 262 |
|
| 263 |
## Here we go backwards again to create hash of biblioitemnumber to itemnumbers, |
| 264 |
## when by definition all of the itemnumber have the same biblioitemnumber |
| 265 |
foreach my $itemnumber (@itemnumbers) { |
| 266 |
my $biblioitemnumber = $iteminfos_of->{$itemnumber}->{biblioitemnumber}; |
| 267 |
push( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} }, $itemnumber ); |
| 268 |
} |
| 269 |
|
| 270 |
## Should be same as biblionumber |
| 271 |
my @biblioitemnumbers = keys %itemnumbers_of_biblioitem; |
| 272 |
|
| 273 |
my $notforloan_label_of = get_notforloan_label_of(); |
| 274 |
|
| 275 |
## Hash of biblioitemnumber to 'biblioitem' table records |
| 276 |
my $biblioiteminfos_of = GetBiblioItemInfosOf(@biblioitemnumbers); |
| 277 |
|
| 278 |
my @bibitemloop; |
| 279 |
|
| 280 |
foreach my $biblioitemnumber (@biblioitemnumbers) { |
| 281 |
my $biblioitem = $biblioiteminfos_of->{$biblioitemnumber}; |
| 282 |
my $num_available = 0; |
| 283 |
my $num_override = 0; |
| 284 |
my $hiddencount = 0; |
| 285 |
|
| 286 |
$biblioitem->{description} = |
| 287 |
$itemtypes->{ $biblioitem->{itemtype} }{description}; |
| 288 |
if($biblioitem->{biblioitemnumber} ne $biblionumber){ |
| 289 |
$biblioitem->{hostitemsflag}=1; |
| 290 |
} |
267 |
} |
| 291 |
$biblioloopiter{description} = $biblioitem->{description}; |
268 |
my @hostitems = get_hostitemnumbers_of($biblionumber); |
| 292 |
$biblioloopiter{itypename} = $biblioitem->{description}; |
269 |
if (@hostitems) { |
| 293 |
$biblioloopiter{imageurl} = |
270 |
$template->param( 'hostitemsflag' => 1 ); |
| 294 |
getitemtypeimagelocation('intranet', $itemtypes->{$biblioitem->{itemtype}}{imageurl}); |
271 |
push( @itemnumbers, @hostitems ); |
| 295 |
|
272 |
} |
| 296 |
foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } ) { |
273 |
|
| 297 |
my $item = $iteminfos_of->{$itemnumber}; |
274 |
if ( !@itemnumbers ) { |
| 298 |
|
275 |
$template->param( 'noitems' => 1 ); |
| 299 |
unless (C4::Context->preference('item-level_itypes')) { |
276 |
$biblioloopiter{noitems} = 1; |
| 300 |
$item->{itype} = $biblioitem->{itemtype}; |
277 |
} |
| 301 |
} |
278 |
|
| 302 |
|
279 |
## Hash of item number to 'item' table fields |
| 303 |
$item->{itypename} = $itemtypes->{ $item->{itype} }{description}; |
280 |
my $iteminfos_of = GetItemInfosOf(@itemnumbers); |
| 304 |
$item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} ); |
281 |
|
| 305 |
$item->{homebranchname} = $branches->{ $item->{homebranch} }{branchname}; |
282 |
## Here we go backwards again to create hash of biblioitemnumber to itemnumbers, |
| 306 |
|
283 |
## when by definition all of the itemnumber have the same biblioitemnumber |
| 307 |
# if the holdingbranch is different than the homebranch, we show the |
284 |
foreach my $itemnumber (@itemnumbers) { |
| 308 |
# holdingbranch of the document too |
285 |
my $biblioitemnumber = $iteminfos_of->{$itemnumber}->{biblioitemnumber}; |
| 309 |
if ( $item->{homebranch} ne $item->{holdingbranch} ) { |
286 |
push( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} }, $itemnumber ); |
| 310 |
$item->{holdingbranchname} = |
287 |
} |
| 311 |
$branches->{ $item->{holdingbranch} }{branchname}; |
288 |
|
| 312 |
} |
289 |
## Should be same as biblionumber |
| 313 |
|
290 |
my @biblioitemnumbers = keys %itemnumbers_of_biblioitem; |
| 314 |
if($item->{biblionumber} ne $biblionumber){ |
291 |
|
| 315 |
$item->{hostitemsflag}=1; |
292 |
my $notforloan_label_of = get_notforloan_label_of(); |
| 316 |
$item->{hosttitle} = GetBiblioData($item->{biblionumber})->{title}; |
293 |
|
|
|
294 |
## Hash of biblioitemnumber to 'biblioitem' table records |
| 295 |
my $biblioiteminfos_of = GetBiblioItemInfosOf(@biblioitemnumbers); |
| 296 |
|
| 297 |
my @bibitemloop; |
| 298 |
|
| 299 |
foreach my $biblioitemnumber (@biblioitemnumbers) { |
| 300 |
my $biblioitem = $biblioiteminfos_of->{$biblioitemnumber}; |
| 301 |
my $num_available = 0; |
| 302 |
my $num_override = 0; |
| 303 |
my $hiddencount = 0; |
| 304 |
|
| 305 |
#Collect the amout of items that pass the CanItemBeTransferred-check. This is needed to tell |
| 306 |
# the user if some or all Items cannot be transferred to the pickup location. |
| 307 |
my $branchTransferableItemsCount = 0; |
| 308 |
|
| 309 |
$biblioitem->{description} = |
| 310 |
$itemtypes->{ $biblioitem->{itemtype} }{description}; |
| 311 |
if ( $biblioitem->{biblioitemnumber} ne $biblionumber ) { |
| 312 |
$biblioitem->{hostitemsflag} = 1; |
| 317 |
} |
313 |
} |
| 318 |
|
314 |
$biblioloopiter{description} = $biblioitem->{description}; |
| 319 |
# add information |
315 |
$biblioloopiter{itypename} = $biblioitem->{description}; |
| 320 |
$item->{itemcallnumber} = $item->{itemcallnumber}; |
316 |
$biblioloopiter{imageurl} = |
| 321 |
|
317 |
getitemtypeimagelocation( 'intranet', |
| 322 |
# if the item is currently on loan, we display its return date and |
318 |
$itemtypes->{ $biblioitem->{itemtype} }{imageurl} ); |
| 323 |
# change the background color |
319 |
|
| 324 |
my $issues= GetItemIssue($itemnumber); |
320 |
foreach |
| 325 |
if ( $issues->{'date_due'} ) { |
321 |
my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } ) |
| 326 |
$item->{date_due} = format_sqldatetime($issues->{date_due}); |
322 |
{ |
| 327 |
$item->{backgroundcolor} = 'onloan'; |
323 |
my $item = $iteminfos_of->{$itemnumber}; |
| 328 |
} |
324 |
|
| 329 |
|
325 |
unless ( C4::Context->preference('item-level_itypes') ) { |
| 330 |
# checking reserve |
326 |
$item->{itype} = $biblioitem->{itemtype}; |
| 331 |
my ($reservedate,$reservedfor,$expectedAt,$reserve_id) = GetReservesFromItemnumber($itemnumber); |
327 |
} |
| 332 |
my $ItemBorrowerReserveInfo = GetMember( borrowernumber => $reservedfor ); |
328 |
|
| 333 |
|
329 |
$item->{itypename} = $itemtypes->{ $item->{itype} }{description}; |
| 334 |
if ( defined $reservedate ) { |
330 |
$item->{imageurl} = getitemtypeimagelocation( 'intranet', |
| 335 |
$item->{backgroundcolor} = 'reserved'; |
331 |
$itemtypes->{ $item->{itype} }{imageurl} ); |
| 336 |
$item->{reservedate} = format_date($reservedate); |
332 |
$item->{homebranchname} = |
| 337 |
$item->{ReservedForBorrowernumber} = $reservedfor; |
333 |
$branches->{ $item->{homebranch} }{branchname}; |
| 338 |
$item->{ReservedForSurname} = $ItemBorrowerReserveInfo->{'surname'}; |
334 |
|
| 339 |
$item->{ReservedForFirstname} = $ItemBorrowerReserveInfo->{'firstname'}; |
335 |
# if the holdingbranch is different than the homebranch, we show the |
| 340 |
$item->{ExpectedAtLibrary} = $branches->{$expectedAt}{branchname}; |
336 |
# holdingbranch of the document too |
| 341 |
|
337 |
if ( $item->{homebranch} ne $item->{holdingbranch} ) { |
| 342 |
} |
338 |
$item->{holdingbranchname} = |
| 343 |
|
339 |
$branches->{ $item->{holdingbranch} }{branchname}; |
| 344 |
# Management of the notforloan document |
340 |
} |
| 345 |
if ( $item->{notforloan} ) { |
341 |
|
| 346 |
$item->{backgroundcolor} = 'other'; |
342 |
if ( $item->{biblionumber} ne $biblionumber ) { |
| 347 |
$item->{notforloanvalue} = |
343 |
$item->{hostitemsflag} = 1; |
| 348 |
$notforloan_label_of->{ $item->{notforloan} }; |
344 |
$item->{hosttitle} = |
| 349 |
} |
345 |
GetBiblioData( $item->{biblionumber} )->{title}; |
| 350 |
|
346 |
} |
| 351 |
# Management of lost or long overdue items |
347 |
|
| 352 |
if ( $item->{itemlost} ) { |
348 |
# add information |
| 353 |
|
349 |
$item->{itemcallnumber} = $item->{itemcallnumber}; |
| 354 |
# FIXME localized strings should never be in Perl code |
350 |
|
| 355 |
$item->{message} = |
351 |
# if the item is currently on loan, we display its return date and |
| 356 |
$item->{itemlost} == 1 ? "(lost)" |
352 |
# change the background color |
| 357 |
: $item->{itemlost} == 2 ? "(long overdue)" |
353 |
my $issues = GetItemIssue($itemnumber); |
| 358 |
: ""; |
354 |
if ( $issues->{'date_due'} ) { |
| 359 |
$item->{backgroundcolor} = 'other'; |
355 |
$item->{date_due} = format_sqldatetime( $issues->{date_due} ); |
| 360 |
if (GetHideLostItemsPreference($borrowernumber) && !$showallitems) { |
356 |
$item->{backgroundcolor} = 'onloan'; |
| 361 |
$item->{hide} = 1; |
357 |
} |
| 362 |
$hiddencount++; |
358 |
|
| 363 |
} |
359 |
# checking reserve |
| 364 |
} |
360 |
my ( $reservedate, $reservedfor, $expectedAt, $reserve_id ) = |
| 365 |
|
361 |
GetReservesFromItemnumber($itemnumber); |
| 366 |
# Check the transit status |
362 |
my $ItemBorrowerReserveInfo = |
| 367 |
my ( $transfertwhen, $transfertfrom, $transfertto ) = |
363 |
GetMember( borrowernumber => $reservedfor ); |
| 368 |
GetTransfers($itemnumber); |
364 |
|
| 369 |
|
365 |
if ( defined $reservedate ) { |
| 370 |
if ( defined $transfertwhen && $transfertwhen ne '' ) { |
366 |
$item->{backgroundcolor} = 'reserved'; |
| 371 |
$item->{transfertwhen} = format_date($transfertwhen); |
367 |
$item->{reservedate} = format_date($reservedate); |
| 372 |
$item->{transfertfrom} = |
368 |
$item->{ReservedForBorrowernumber} = $reservedfor; |
| 373 |
$branches->{$transfertfrom}{branchname}; |
369 |
$item->{ReservedForSurname} = |
| 374 |
$item->{transfertto} = $branches->{$transfertto}{branchname}; |
370 |
$ItemBorrowerReserveInfo->{'surname'}; |
| 375 |
$item->{nocancel} = 1; |
371 |
$item->{ReservedForFirstname} = |
| 376 |
} |
372 |
$ItemBorrowerReserveInfo->{'firstname'}; |
| 377 |
|
373 |
$item->{ExpectedAtLibrary} = |
| 378 |
# If there is no loan, return and transfer, we show a checkbox. |
374 |
$branches->{$expectedAt}{branchname}; |
| 379 |
$item->{notforloan} = $item->{notforloan} || 0; |
375 |
|
| 380 |
|
376 |
} |
| 381 |
# if independent branches is on we need to check if the person can reserve |
377 |
|
| 382 |
# for branches they arent logged in to |
378 |
# Management of the notforloan document |
| 383 |
if ( C4::Context->preference("IndependentBranches") ) { |
379 |
if ( $item->{notforloan} ) { |
| 384 |
if (! C4::Context->preference("canreservefromotherbranches")){ |
380 |
$item->{backgroundcolor} = 'other'; |
| 385 |
# cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve |
381 |
$item->{notforloanvalue} = |
| 386 |
my $userenv = C4::Context->userenv; |
382 |
$notforloan_label_of->{ $item->{notforloan} }; |
| 387 |
if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) { |
383 |
} |
| 388 |
$item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} ); |
384 |
|
| 389 |
} |
385 |
# Management of lost or long overdue items |
| 390 |
} |
386 |
if ( $item->{itemlost} ) { |
| 391 |
} |
387 |
|
| 392 |
|
388 |
# FIXME localized strings should never be in Perl code |
| 393 |
my $branch = C4::Circulation::_GetCircControlBranch($item, $borrowerinfo); |
389 |
$item->{message} = |
| 394 |
|
390 |
$item->{itemlost} == 1 ? "(lost)" |
| 395 |
my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} ); |
391 |
: $item->{itemlost} == 2 ? "(long overdue)" |
| 396 |
my $policy_holdallowed = 1; |
392 |
: ""; |
| 397 |
|
393 |
$item->{backgroundcolor} = 'other'; |
| 398 |
$item->{'holdallowed'} = $branchitemrule->{'holdallowed'}; |
394 |
if ( GetHideLostItemsPreference($borrowernumber) |
| 399 |
|
395 |
&& !$showallitems ) |
| 400 |
if ( $branchitemrule->{'holdallowed'} == 0 || |
396 |
{ |
| 401 |
( $branchitemrule->{'holdallowed'} == 1 && |
397 |
$item->{hide} = 1; |
| 402 |
$borrowerinfo->{'branchcode'} ne $item->{'homebranch'} ) ) { |
398 |
$hiddencount++; |
| 403 |
$policy_holdallowed = 0; |
399 |
} |
| 404 |
} |
400 |
} |
| 405 |
|
401 |
|
| 406 |
if ( |
402 |
# Check the transit status |
| 407 |
$policy_holdallowed |
403 |
my ( $transfertwhen, $transfertfrom, $transfertto ) = |
| 408 |
&& !$item->{cantreserve} |
404 |
GetTransfers($itemnumber); |
| 409 |
&& IsAvailableForItemLevelRequest($itemnumber) |
405 |
|
| 410 |
&& CanItemBeReserved( |
406 |
if ( defined $transfertwhen && $transfertwhen ne '' ) { |
| 411 |
$borrowerinfo->{borrowernumber}, $itemnumber |
407 |
$item->{transfertwhen} = format_date($transfertwhen); |
| 412 |
) |
408 |
$item->{transfertfrom} = |
| 413 |
) |
409 |
$branches->{$transfertfrom}{branchname}; |
| 414 |
{ |
410 |
$item->{transfertto} = $branches->{$transfertto}{branchname}; |
| 415 |
$item->{available} = 1; |
411 |
$item->{nocancel} = 1; |
| 416 |
$num_available++; |
412 |
} |
| 417 |
} |
413 |
|
| 418 |
elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) { |
414 |
# If there is no loan, return and transfer, we show a checkbox. |
|
|
415 |
$item->{notforloan} = $item->{notforloan} || 0; |
| 416 |
|
| 417 |
# if independent branches is on we need to check if the person can reserve |
| 418 |
# for branches they arent logged in to |
| 419 |
if ( C4::Context->preference("IndependentBranches") ) { |
| 420 |
if ( !C4::Context->preference("canreservefromotherbranches") ) { |
| 421 |
|
| 422 |
# cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve |
| 423 |
my $userenv = C4::Context->userenv; |
| 424 |
if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) { |
| 425 |
$item->{cantreserve} = 1 |
| 426 |
if ( $item->{homebranch} ne $userenv->{branch} ); |
| 427 |
} |
| 428 |
} |
| 429 |
} |
| 430 |
|
| 431 |
# UseBranchTransferLimits checking |
| 432 |
my ( $transferOk, $errorMessage ) = |
| 433 |
CanItemBeTransferred( $pickupBranch, $item->{holdingbranch}, |
| 434 |
$item, undef ); |
| 435 |
if ( !$transferOk ) { |
| 436 |
$item->{cantreserve} = 1; |
| 437 |
$item->{branchTransferDenied} = 1; |
| 438 |
} |
| 439 |
else { |
| 440 |
$branchTransferableItemsCount++; |
| 441 |
} |
| 442 |
|
| 443 |
my $branch = |
| 444 |
C4::Circulation::_GetCircControlBranch( $item, $borrowerinfo ); |
| 445 |
|
| 446 |
my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} ); |
| 447 |
my $policy_holdallowed = 1; |
| 448 |
|
| 449 |
$item->{'holdallowed'} = $branchitemrule->{'holdallowed'}; |
| 450 |
|
| 451 |
if ( |
| 452 |
$branchitemrule->{'holdallowed'} == 0 |
| 453 |
|| ( $branchitemrule->{'holdallowed'} == 1 |
| 454 |
&& $borrowerinfo->{'branchcode'} ne $item->{'homebranch'} ) |
| 455 |
) |
| 456 |
{ |
| 457 |
$policy_holdallowed = 0; |
| 458 |
} |
| 459 |
|
| 460 |
if ( |
| 461 |
$policy_holdallowed |
| 462 |
&& !$item->{cantreserve} |
| 463 |
&& IsAvailableForItemLevelRequest($itemnumber) |
| 464 |
&& CanItemBeReserved( |
| 465 |
$borrowerinfo->{borrowernumber}, $itemnumber |
| 466 |
) |
| 467 |
) |
| 468 |
{ |
| 469 |
$item->{available} = 1; |
| 470 |
$num_available++; |
| 471 |
} |
| 472 |
elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) { |
| 419 |
|
473 |
|
| 420 |
# If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules |
474 |
# If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules |
| 421 |
$item->{override} = 1; |
475 |
$item->{override} = 1; |
| 422 |
$num_override++; |
476 |
$num_override++; |
| 423 |
} |
477 |
} |
| 424 |
|
478 |
|
| 425 |
# If none of the conditions hold true, then neither override nor available is set and the item cannot be checked |
479 |
# If none of the conditions hold true, then neither override nor available is set and the item cannot be checked |
| 426 |
|
480 |
|
| 427 |
# FIXME: move this to a pm |
481 |
# FIXME: move this to a pm |
| 428 |
my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'"); |
482 |
my $sth2 = $dbh->prepare( |
| 429 |
$sth2->execute($item->{ReservedForBorrowernumber},$item->{itemnumber}); |
483 |
"SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'" |
| 430 |
while (my $wait_hashref = $sth2->fetchrow_hashref) { |
484 |
); |
| 431 |
$item->{waitingdate} = format_date($wait_hashref->{waitingdate}); |
485 |
$sth2->execute( $item->{ReservedForBorrowernumber}, |
| 432 |
} |
486 |
$item->{itemnumber} ); |
| 433 |
|
487 |
while ( my $wait_hashref = $sth2->fetchrow_hashref ) { |
| 434 |
# Show serial enumeration when needed |
488 |
$item->{waitingdate} = |
| 435 |
if ($item->{enumchron}) { |
489 |
format_date( $wait_hashref->{waitingdate} ); |
| 436 |
$itemdata_enumchron = 1; |
490 |
} |
| 437 |
} |
491 |
|
| 438 |
|
492 |
# Show serial enumeration when needed |
| 439 |
push @{ $biblioitem->{itemloop} }, $item; |
493 |
if ( $item->{enumchron} ) { |
| 440 |
} |
494 |
$itemdata_enumchron = 1; |
| 441 |
|
495 |
} |
| 442 |
if ( $num_override == scalar( @{ $biblioitem->{itemloop} } ) ) { # That is, if all items require an override |
496 |
|
| 443 |
$template->param( override_required => 1 ); |
497 |
push @{ $biblioitem->{itemloop} }, $item; |
| 444 |
} elsif ( $num_available == 0 ) { |
498 |
} |
| 445 |
$template->param( none_available => 1 ); |
499 |
|
| 446 |
$biblioloopiter{warn} = 1; |
500 |
if ( $num_override == scalar( @{ $biblioitem->{itemloop} } ) ) |
| 447 |
$biblioloopiter{none_avail} = 1; |
501 |
{ # That is, if all items require an override |
| 448 |
} |
502 |
$template->param( override_required => 1 ); |
| 449 |
$template->param( hiddencount => $hiddencount); |
503 |
} |
| 450 |
|
504 |
elsif ( $num_available == 0 ) { |
| 451 |
push @bibitemloop, $biblioitem; |
505 |
$template->param( none_available => 1 ); |
| 452 |
} |
506 |
$biblioloopiter{warn} = 1; |
| 453 |
|
507 |
$biblioloopiter{none_avail} = 1; |
| 454 |
# existingreserves building |
508 |
} |
| 455 |
my @reserveloop; |
509 |
if ( $branchTransferableItemsCount == 0 ) { |
| 456 |
( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber,1); |
510 |
$biblioloopiter{suggestAnotherPickupLocation} = 1; |
| 457 |
foreach my $res ( sort { |
511 |
$biblioitem->{suggestAnotherPickupLocation} = 1; |
| 458 |
my $a_found = $a->{found} || ''; |
512 |
$template->param( bookBranchTransferDenied => 1 ); |
| 459 |
my $b_found = $a->{found} || ''; |
513 |
} |
| 460 |
$a_found cmp $b_found; |
514 |
|
| 461 |
} @$reserves ) { |
515 |
$template->param( hiddencount => $hiddencount ); |
| 462 |
my %reserve; |
516 |
|
| 463 |
my @optionloop; |
517 |
push @bibitemloop, $biblioitem; |
| 464 |
for ( my $i = 1 ; $i <= $totalcount ; $i++ ) { |
518 |
} |
| 465 |
push( |
519 |
|
| 466 |
@optionloop, |
520 |
# existingreserves building |
| 467 |
{ |
521 |
my @reserveloop; |
| 468 |
num => $i, |
522 |
( $count, $reserves ) = GetReservesFromBiblionumber( $biblionumber, 1 ); |
| 469 |
selected => ( $i == $res->{priority} ), |
523 |
foreach my $res ( |
| 470 |
} |
524 |
sort { |
| 471 |
); |
525 |
my $a_found = $a->{found} || ''; |
| 472 |
} |
526 |
my $b_found = $a->{found} || ''; |
| 473 |
|
527 |
$a_found cmp $b_found; |
| 474 |
if ( defined $res->{'found'} && ($res->{'found'} eq 'W' || $res->{'found'} eq 'T' )) { |
528 |
} @$reserves |
| 475 |
my $item = $res->{'itemnumber'}; |
529 |
) |
| 476 |
$item = GetBiblioFromItemNumber($item,undef); |
530 |
{ |
| 477 |
$reserve{'wait'}= 1; |
531 |
my %reserve; |
| 478 |
$reserve{'holdingbranch'}=$item->{'holdingbranch'}; |
532 |
my @optionloop; |
| 479 |
$reserve{'biblionumber'}=$item->{'biblionumber'}; |
533 |
for ( my $i = 1 ; $i <= $totalcount ; $i++ ) { |
| 480 |
$reserve{'barcodenumber'} = $item->{'barcode'}; |
534 |
push( |
| 481 |
$reserve{'wbrcode'} = $res->{'branchcode'}; |
535 |
@optionloop, |
| 482 |
$reserve{'itemnumber'} = $res->{'itemnumber'}; |
536 |
{ |
| 483 |
$reserve{'wbrname'} = $branches->{$res->{'branchcode'}}->{'branchname'}; |
537 |
num => $i, |
| 484 |
if($reserve{'holdingbranch'} eq $reserve{'wbrcode'}){ |
538 |
selected => ( $i == $res->{priority} ), |
| 485 |
$reserve{'atdestination'} = 1; |
539 |
} |
| 486 |
} |
540 |
); |
| 487 |
# set found to 1 if reserve is waiting for patron pickup |
541 |
} |
| 488 |
$reserve{'found'} = 1 if $res->{'found'} eq 'W'; |
542 |
|
| 489 |
$reserve{'intransit'} = 1 if $res->{'found'} eq 'T'; |
543 |
if ( defined $res->{'found'} |
| 490 |
} elsif ($res->{priority} > 0) { |
544 |
&& ( $res->{'found'} eq 'W' || $res->{'found'} eq 'T' ) ) |
| 491 |
if (defined($res->{itemnumber})) { |
545 |
{ |
| 492 |
my $item = GetItem($res->{itemnumber}); |
546 |
my $item = $res->{'itemnumber'}; |
| 493 |
$reserve{'itemnumber'} = $res->{'itemnumber'}; |
547 |
$item = GetBiblioFromItemNumber( $item, undef ); |
| 494 |
$reserve{'barcodenumber'} = $item->{'barcode'}; |
548 |
$reserve{'wait'} = 1; |
| 495 |
$reserve{'item_level_hold'} = 1; |
549 |
$reserve{'holdingbranch'} = $item->{'holdingbranch'}; |
| 496 |
} |
550 |
$reserve{'biblionumber'} = $item->{'biblionumber'}; |
| 497 |
} |
551 |
$reserve{'barcodenumber'} = $item->{'barcode'}; |
| 498 |
|
552 |
$reserve{'wbrcode'} = $res->{'branchcode'}; |
| 499 |
# get borrowers reserve info |
553 |
$reserve{'itemnumber'} = $res->{'itemnumber'}; |
| 500 |
my $reserveborrowerinfo = GetMember( borrowernumber => $res->{'borrowernumber'} ); |
554 |
$reserve{'wbrname'} = |
| 501 |
if (C4::Context->preference('HidePatronName')){ |
555 |
$branches->{ $res->{'branchcode'} }->{'branchname'}; |
| 502 |
$reserve{'hidename'} = 1; |
556 |
|
| 503 |
$reserve{'cardnumber'} = $reserveborrowerinfo->{'cardnumber'}; |
557 |
if ( $reserve{'holdingbranch'} eq $reserve{'wbrcode'} ) { |
|
|
558 |
$reserve{'atdestination'} = 1; |
| 559 |
} |
| 560 |
|
| 561 |
# set found to 1 if reserve is waiting for patron pickup |
| 562 |
$reserve{'found'} = 1 if $res->{'found'} eq 'W'; |
| 563 |
$reserve{'intransit'} = 1 if $res->{'found'} eq 'T'; |
| 564 |
} |
| 565 |
elsif ( $res->{priority} > 0 ) { |
| 566 |
if ( defined( $res->{itemnumber} ) ) { |
| 567 |
my $item = GetItem( $res->{itemnumber} ); |
| 568 |
$reserve{'itemnumber'} = $res->{'itemnumber'}; |
| 569 |
$reserve{'barcodenumber'} = $item->{'barcode'}; |
| 570 |
$reserve{'item_level_hold'} = 1; |
| 571 |
} |
| 572 |
} |
| 573 |
|
| 574 |
# get borrowers reserve info |
| 575 |
my $reserveborrowerinfo = |
| 576 |
GetMember( borrowernumber => $res->{'borrowernumber'} ); |
| 577 |
if ( C4::Context->preference('HidePatronName') ) { |
| 578 |
$reserve{'hidename'} = 1; |
| 579 |
$reserve{'cardnumber'} = $reserveborrowerinfo->{'cardnumber'}; |
| 580 |
} |
| 581 |
$reserve{'expirationdate'} = format_date( $res->{'expirationdate'} ) |
| 582 |
unless ( !defined( $res->{'expirationdate'} ) |
| 583 |
|| $res->{'expirationdate'} eq '0000-00-00' ); |
| 584 |
$reserve{'date'} = format_date( $res->{'reservedate'} ); |
| 585 |
$reserve{'borrowernumber'} = $res->{'borrowernumber'}; |
| 586 |
$reserve{'biblionumber'} = $res->{'biblionumber'}; |
| 587 |
$reserve{'borrowernumber'} = $res->{'borrowernumber'}; |
| 588 |
$reserve{'firstname'} = $reserveborrowerinfo->{'firstname'}; |
| 589 |
$reserve{'surname'} = $reserveborrowerinfo->{'surname'}; |
| 590 |
$reserve{'notes'} = $res->{'reservenotes'}; |
| 591 |
$reserve{'wait'} = ( |
| 592 |
( defined $res->{'found'} and $res->{'found'} eq 'W' ) |
| 593 |
or ( $res->{'priority'} eq '0' ) |
| 594 |
); |
| 595 |
$reserve{'constrainttypea'} = ( $res->{'constrainttype'} eq 'a' ); |
| 596 |
$reserve{'constrainttypeo'} = ( $res->{'constrainttype'} eq 'o' ); |
| 597 |
$reserve{'voldesc'} = $res->{'volumeddesc'}; |
| 598 |
$reserve{'ccode'} = $res->{'ccode'}; |
| 599 |
$reserve{'barcode'} = $res->{'barcode'}; |
| 600 |
$reserve{'priority'} = $res->{'priority'}; |
| 601 |
$reserve{'lowestPriority'} = $res->{'lowestPriority'}; |
| 602 |
$reserve{'optionloop'} = \@optionloop; |
| 603 |
$reserve{'suspend'} = $res->{'suspend'}; |
| 604 |
$reserve{'suspend_until'} = $res->{'suspend_until'}; |
| 605 |
$reserve{'reserve_id'} = $res->{'reserve_id'}; |
| 606 |
|
| 607 |
if ( C4::Context->preference('IndependentBranches') |
| 608 |
&& $flags->{'superlibrarian'} != 1 ) |
| 609 |
{ |
| 610 |
$reserve{'branchloop'} = |
| 611 |
[ GetBranchDetail( $res->{'branchcode'} ) ]; |
| 612 |
} |
| 613 |
else { |
| 614 |
$reserve{'branchloop'} = GetBranchesLoop( $res->{'branchcode'} ); |
| 615 |
} |
| 616 |
|
| 617 |
push( @reserveloop, \%reserve ); |
| 618 |
} |
| 619 |
|
| 620 |
# get the time for the form name... |
| 621 |
my $time = time(); |
| 622 |
|
| 623 |
$template->param( |
| 624 |
branchloop => GetBranchesLoop($pickupBranch), |
| 625 |
time => $time, |
| 626 |
fixedRank => $fixedRank, |
| 627 |
); |
| 628 |
|
| 629 |
# display infos |
| 630 |
$template->param( |
| 631 |
optionloop => \@optionloop, |
| 632 |
bibitemloop => \@bibitemloop, |
| 633 |
itemdata_enumchron => $itemdata_enumchron, |
| 634 |
date => $date, |
| 635 |
biblionumber => $biblionumber, |
| 636 |
findborrower => $findborrower, |
| 637 |
title => $dat->{title}, |
| 638 |
author => $dat->{author}, |
| 639 |
holdsview => 1, |
| 640 |
C4::Search::enabled_staff_search_views, |
| 641 |
); |
| 642 |
if ( defined $borrowerinfo && exists $borrowerinfo->{'branchcode'} ) { |
| 643 |
$template->param( |
| 644 |
borrower_branchname => |
| 645 |
$branches->{ $borrowerinfo->{'branchcode'} }->{'branchname'}, |
| 646 |
borrower_branchcode => $borrowerinfo->{'branchcode'}, |
| 647 |
); |
| 504 |
} |
648 |
} |
| 505 |
$reserve{'expirationdate'} = format_date( $res->{'expirationdate'} ) |
649 |
|
| 506 |
unless ( !defined($res->{'expirationdate'}) || $res->{'expirationdate'} eq '0000-00-00' ); |
650 |
$biblioloopiter{biblionumber} = $biblionumber; |
| 507 |
$reserve{'date'} = format_date( $res->{'reservedate'} ); |
651 |
$biblioloopiter{title} = $dat->{title}; |
| 508 |
$reserve{'borrowernumber'} = $res->{'borrowernumber'}; |
652 |
$biblioloopiter{rank} = $fixedRank; |
| 509 |
$reserve{'biblionumber'} = $res->{'biblionumber'}; |
653 |
$biblioloopiter{reserveloop} = \@reserveloop; |
| 510 |
$reserve{'borrowernumber'} = $res->{'borrowernumber'}; |
654 |
|
| 511 |
$reserve{'firstname'} = $reserveborrowerinfo->{'firstname'}; |
655 |
if (@reserveloop) { |
| 512 |
$reserve{'surname'} = $reserveborrowerinfo->{'surname'}; |
656 |
$template->param( reserveloop => \@reserveloop ); |
| 513 |
$reserve{'notes'} = $res->{'reservenotes'}; |
657 |
} |
| 514 |
$reserve{'wait'} = |
658 |
|
| 515 |
( ( defined $res->{'found'} and $res->{'found'} eq 'W' ) or ( $res->{'priority'} eq '0' ) ); |
659 |
push @biblioloop, \%biblioloopiter; |
| 516 |
$reserve{'constrainttypea'} = ( $res->{'constrainttype'} eq 'a' ); |
|
|
| 517 |
$reserve{'constrainttypeo'} = ( $res->{'constrainttype'} eq 'o' ); |
| 518 |
$reserve{'voldesc'} = $res->{'volumeddesc'}; |
| 519 |
$reserve{'ccode'} = $res->{'ccode'}; |
| 520 |
$reserve{'barcode'} = $res->{'barcode'}; |
| 521 |
$reserve{'priority'} = $res->{'priority'}; |
| 522 |
$reserve{'lowestPriority'} = $res->{'lowestPriority'}; |
| 523 |
$reserve{'optionloop'} = \@optionloop; |
| 524 |
$reserve{'suspend'} = $res->{'suspend'}; |
| 525 |
$reserve{'suspend_until'} = $res->{'suspend_until'}; |
| 526 |
$reserve{'reserve_id'} = $res->{'reserve_id'}; |
| 527 |
|
| 528 |
if ( C4::Context->preference('IndependentBranches') && $flags->{'superlibrarian'} != 1 ) { |
| 529 |
$reserve{'branchloop'} = [ GetBranchDetail($res->{'branchcode'}) ]; |
| 530 |
} else { |
| 531 |
$reserve{'branchloop'} = GetBranchesLoop($res->{'branchcode'}); |
| 532 |
} |
| 533 |
|
| 534 |
push( @reserveloop, \%reserve ); |
| 535 |
} |
| 536 |
|
| 537 |
# get the time for the form name... |
| 538 |
my $time = time(); |
| 539 |
|
| 540 |
$template->param( |
| 541 |
branchloop => GetBranchesLoop($userbranch), |
| 542 |
time => $time, |
| 543 |
fixedRank => $fixedRank, |
| 544 |
); |
| 545 |
|
| 546 |
# display infos |
| 547 |
$template->param( |
| 548 |
optionloop => \@optionloop, |
| 549 |
bibitemloop => \@bibitemloop, |
| 550 |
itemdata_enumchron => $itemdata_enumchron, |
| 551 |
date => $date, |
| 552 |
biblionumber => $biblionumber, |
| 553 |
findborrower => $findborrower, |
| 554 |
title => $dat->{title}, |
| 555 |
author => $dat->{author}, |
| 556 |
holdsview => 1, |
| 557 |
C4::Search::enabled_staff_search_views, |
| 558 |
); |
| 559 |
if (defined $borrowerinfo && exists $borrowerinfo->{'branchcode'}) { |
| 560 |
$template->param( |
| 561 |
borrower_branchname => $branches->{$borrowerinfo->{'branchcode'}}->{'branchname'}, |
| 562 |
borrower_branchcode => $borrowerinfo->{'branchcode'}, |
| 563 |
); |
| 564 |
} |
| 565 |
|
| 566 |
$biblioloopiter{biblionumber} = $biblionumber; |
| 567 |
$biblioloopiter{title} = $dat->{title}; |
| 568 |
$biblioloopiter{rank} = $fixedRank; |
| 569 |
$biblioloopiter{reserveloop} = \@reserveloop; |
| 570 |
|
| 571 |
if (@reserveloop) { |
| 572 |
$template->param( reserveloop => \@reserveloop ); |
| 573 |
} |
| 574 |
|
| 575 |
push @biblioloop, \%biblioloopiter; |
| 576 |
} |
660 |
} |
| 577 |
|
661 |
|
| 578 |
$template->param( biblioloop => \@biblioloop ); |
662 |
$template->param( biblioloop => \@biblioloop ); |
| 579 |
$template->param( biblionumbers => $biblionumbers ); |
663 |
$template->param( biblionumbers => $biblionumbers ); |
| 580 |
$template->param( maxreserves => $maxreserves ); |
664 |
$template->param( maxreserves => $maxreserves ); |
| 581 |
|
665 |
|
| 582 |
if ($multihold) { |
666 |
if ($multihold) { |
| 583 |
$template->param( multi_hold => 1 ); |
667 |
$template->param( multi_hold => 1 ); |
| 584 |
} |
668 |
} |
| 585 |
|
669 |
|
| 586 |
if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) { |
670 |
if ( C4::Context->preference('AllowHoldDateInFuture') ) { |
| 587 |
$template->param( reserve_in_future => 1 ); |
671 |
$template->param( reserve_in_future => 1 ); |
| 588 |
} |
672 |
} |
| 589 |
|
673 |
|
| 590 |
$template->param( |
674 |
$template->param( |
| 591 |
SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'), |
675 |
SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'), |
| 592 |
AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'), |
676 |
AutoResumeSuspendedHolds => |
|
|
677 |
C4::Context->preference('AutoResumeSuspendedHolds'), |
| 593 |
); |
678 |
); |
| 594 |
|
679 |
|
| 595 |
# printout the page |
680 |
# printout the page |
| 596 |
output_html_with_http_headers $input, $cookie, $template->output; |
681 |
output_html_with_http_headers $input, $cookie, $template->output; |
| 597 |
|
682 |
|
| 598 |
sub sort_borrowerlist { |
683 |
sub sort_borrowerlist { |
| 599 |
my $borrowerslist = shift; |
684 |
my $borrowerslist = shift; |
| 600 |
my $ref = []; |
685 |
my $ref = []; |
| 601 |
push @{$ref}, sort { |
686 |
push @{$ref}, sort { |
| 602 |
uc( $a->{surname} . $a->{firstname} ) cmp |
687 |
uc( $a->{surname} . $a->{firstname} ) cmp |
| 603 |
uc( $b->{surname} . $b->{firstname} ) |
688 |
uc( $b->{surname} . $b->{firstname} ) |
| 604 |
} @{$borrowerslist}; |
689 |
} @{$borrowerslist}; |
| 605 |
return $ref; |
690 |
return $ref; |
| 606 |
} |
691 |
} |
| 607 |
- |
|
|