Lines 212-218
if ( $query->param('place_reserve') ) {
Link Here
|
212 |
exit; |
212 |
exit; |
213 |
} |
213 |
} |
214 |
|
214 |
|
215 |
my $failed_holds = 0; |
215 |
my @failed_holds; |
216 |
while (@selectedItems) { |
216 |
while (@selectedItems) { |
217 |
my $biblioNum = shift(@selectedItems); |
217 |
my $biblioNum = shift(@selectedItems); |
218 |
my $itemNum = shift(@selectedItems); |
218 |
my $itemNum = shift(@selectedItems); |
Lines 264-274
if ( $query->param('place_reserve') ) {
Link Here
|
264 |
my $biblio = Koha::Biblios->find($biblioNum); |
264 |
my $biblio = Koha::Biblios->find($biblioNum); |
265 |
my $rank = $biblio->holds->search( { found => [ { "!=" => "W" }, undef ] } )->count + 1; |
265 |
my $rank = $biblio->holds->search( { found => [ { "!=" => "W" }, undef ] } )->count + 1; |
266 |
if ( $item ) { |
266 |
if ( $item ) { |
267 |
$canreserve = 1 if CanItemBeReserved( $patron, $item, $branch )->{status} eq 'OK'; |
267 |
my $status = CanItemBeReserved( $patron, $item, $branch )->{status}; |
|
|
268 |
if( $status eq 'OK' ){ |
269 |
$canreserve = 1; |
270 |
} else { |
271 |
push @failed_holds, $status; |
272 |
} |
273 |
|
268 |
} |
274 |
} |
269 |
else { |
275 |
else { |
270 |
$canreserve = 1 |
276 |
my $status = CanBookBeReserved( $borrowernumber, $biblioNum, $branch, { itemtype => $itemtype } )->{status}; |
271 |
if CanBookBeReserved( $borrowernumber, $biblioNum, $branch, { itemtype => $itemtype } )->{status} eq 'OK'; |
277 |
if( $status eq 'OK'){ |
|
|
278 |
$canreserve = 1; |
279 |
} else { |
280 |
push @failed_holds, $status; |
281 |
} |
272 |
|
282 |
|
273 |
# Inserts a null into the 'itemnumber' field of 'reserves' table. |
283 |
# Inserts a null into the 'itemnumber' field of 'reserves' table. |
274 |
$itemNum = undef; |
284 |
$itemNum = undef; |
Lines 279-284
if ( $query->param('place_reserve') ) {
Link Here
|
279 |
if ( $maxreserves |
289 |
if ( $maxreserves |
280 |
&& $reserve_cnt >= $maxreserves ) |
290 |
&& $reserve_cnt >= $maxreserves ) |
281 |
{ |
291 |
{ |
|
|
292 |
push @failed_holds, 'tooManyReserves'; |
282 |
$canreserve = 0; |
293 |
$canreserve = 0; |
283 |
} |
294 |
} |
284 |
|
295 |
|
Lines 287-293
if ( $query->param('place_reserve') ) {
Link Here
|
287 |
my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count; |
298 |
my $nb_of_items_issued = $items_in_this_library->search({ 'issue.itemnumber' => { not => undef }}, { join => 'issue' })->count; |
288 |
my $nb_of_items_unavailable = $items_in_this_library->search({ -or => { lost => { '!=' => 0 }, damaged => { '!=' => 0 }, } }); |
299 |
my $nb_of_items_unavailable = $items_in_this_library->search({ -or => { lost => { '!=' => 0 }, damaged => { '!=' => 0 }, } }); |
289 |
if ( $items_in_this_library->count > $nb_of_items_issued + $nb_of_items_unavailable ) { |
300 |
if ( $items_in_this_library->count > $nb_of_items_issued + $nb_of_items_unavailable ) { |
290 |
$canreserve = 0 |
301 |
$canreserve = 0; |
|
|
302 |
push @failed_holds, 'items_available'; |
291 |
} |
303 |
} |
292 |
} |
304 |
} |
293 |
|
305 |
|
Lines 309-320
if ( $query->param('place_reserve') ) {
Link Here
|
309 |
item_group_id => $item_group_id, |
321 |
item_group_id => $item_group_id, |
310 |
} |
322 |
} |
311 |
); |
323 |
); |
312 |
$failed_holds++ unless $reserve_id; |
324 |
if( $reserve_id ){ |
313 |
++$reserve_cnt; |
325 |
++$reserve_cnt; |
|
|
326 |
} else { |
327 |
push @failed_holds, 'not_placed'; |
328 |
} |
314 |
} |
329 |
} |
315 |
} |
330 |
} |
316 |
|
331 |
|
317 |
print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds"); |
332 |
print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( @failed_holds ? "failed_holds=" . join('|',@failed_holds) : q|| ) . "#opac-user-holds"); |
318 |
exit; |
333 |
exit; |
319 |
} |
334 |
} |
320 |
|
335 |
|
321 |
- |
|
|