Lines 91-97
if ((! $biblionumbers) && (! $query->param('place_reserve'))) {
Link Here
|
91 |
} |
91 |
} |
92 |
|
92 |
|
93 |
# Pass the numbers to the page so they can be fed back |
93 |
# Pass the numbers to the page so they can be fed back |
94 |
# when the hold is confirmed. TODO: Not necessary? |
94 |
# when the hold is confirmed. Biblionumbers are also needed if the |
|
|
95 |
# pickup branch changes and the page needs to be reloaded. |
95 |
$template->param( biblionumbers => $biblionumbers ); |
96 |
$template->param( biblionumbers => $biblionumbers ); |
96 |
|
97 |
|
97 |
# Each biblio number is suffixed with '/', e.g. "1/2/3/" |
98 |
# Each biblio number is suffixed with '/', e.g. "1/2/3/" |
Lines 103-114
if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) {
Link Here
|
103 |
} |
104 |
} |
104 |
|
105 |
|
105 |
# pass the pickup branch along.... |
106 |
# pass the pickup branch along.... |
106 |
my $branch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ; |
107 |
my $pickupBranch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ; |
107 |
($branches->{$branch}) or $branch = ""; # Confirm branch is real |
108 |
($branches->{$pickupBranch}) or $pickupBranch = ""; # Confirm branch is real |
108 |
$template->param( branch => $branch ); |
109 |
$template->param( branch => $pickupBranch ); |
109 |
|
110 |
|
110 |
# make branch selection options... |
111 |
# make branch selection options... |
111 |
my $branchloop = GetBranchesLoop($branch); |
112 |
my $branchloop = GetBranchesLoop($pickupBranch); |
112 |
|
113 |
|
113 |
# Is the person allowed to choose their branch |
114 |
# Is the person allowed to choose their branch |
114 |
my $OPACChooseBranch = (C4::Context->preference("OPACAllowUserToChooseBranch")) ? 1 : 0; |
115 |
my $OPACChooseBranch = (C4::Context->preference("OPACAllowUserToChooseBranch")) ? 1 : 0; |
Lines 202-220
if ( $query->param('place_reserve') ) {
Link Here
|
202 |
} |
203 |
} |
203 |
|
204 |
|
204 |
while (@selectedItems) { |
205 |
while (@selectedItems) { |
205 |
my $biblioNum = shift(@selectedItems); |
206 |
my $biblioNum = shift(@selectedItems); |
206 |
my $itemNum = shift(@selectedItems); |
207 |
my $itemNum = shift(@selectedItems); |
207 |
my $branch = shift(@selectedItems); # i.e., branch code, not name |
208 |
my $pickupLocation = shift(@selectedItems); # i.e., branch code, not name, |
208 |
|
209 |
|
209 |
my $canreserve = 0; |
210 |
my $canreserve = 0; |
210 |
|
211 |
|
211 |
my $singleBranchMode = C4::Context->preference("singleBranchMode"); |
212 |
my $singleBranchMode = C4::Context->preference("singleBranchMode"); |
212 |
if ( $singleBranchMode || !$OPACChooseBranch ) |
213 |
if ( $singleBranchMode || !$OPACChooseBranch ) |
213 |
{ # single branch mode or disabled user choosing |
214 |
{ # single branch mode or disabled user choosing |
214 |
$branch = $borr->{'branchcode'}; |
215 |
$pickupLocation = $borr->{'branchcode'}; |
215 |
} |
216 |
} |
216 |
|
217 |
|
217 |
#item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber |
218 |
#item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber |
218 |
if ( $itemNum ne '' ) { |
219 |
if ( $itemNum ne '' ) { |
219 |
my $hostbiblioNum = GetBiblionumberFromItemnumber($itemNum); |
220 |
my $hostbiblioNum = GetBiblionumberFromItemnumber($itemNum); |
220 |
if ( $hostbiblioNum ne $biblioNum ) { |
221 |
if ( $hostbiblioNum ne $biblioNum ) { |
Lines 235-254
if ( $query->param('place_reserve') ) {
Link Here
|
235 |
|
236 |
|
236 |
my $expiration_date = $query->param("expiration_date_$biblioNum"); |
237 |
my $expiration_date = $query->param("expiration_date_$biblioNum"); |
237 |
|
238 |
|
238 |
# If a specific item was selected and the pickup branch is the same as the |
239 |
# If a specific item was selected and the pickup branch is the same as the |
239 |
# holdingbranch, force the value $rank and $found. |
240 |
# holdingbranch, force the value $rank and $found. |
240 |
my $rank = $biblioData->{rank}; |
241 |
my $rank = $biblioData->{rank}; |
241 |
if ( $itemNum ne '' ) { |
242 |
if ( $itemNum ne '' ) { |
|
|
243 |
my $item = GetItem($itemNum); |
242 |
$canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum ); |
244 |
$canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum ); |
243 |
$rank = '0' unless C4::Context->preference('ReservesNeedReturns'); |
245 |
$rank = '0' unless C4::Context->preference('ReservesNeedReturns'); |
244 |
my $item = GetItem($itemNum); |
246 |
if ( $item->{'holdingbranch'} eq $pickupLocation ) { |
245 |
if ( $item->{'holdingbranch'} eq $branch ) { |
|
|
246 |
$found = 'W' |
247 |
$found = 'W' |
247 |
unless C4::Context->preference('ReservesNeedReturns'); |
248 |
unless C4::Context->preference('ReservesNeedReturns'); |
248 |
} |
249 |
} |
|
|
250 |
|
251 |
# UseBranchTransferLimits checking. |
252 |
my ($transferOk, $message) = CheckBranchTransferAllowed( $pickupLocation, $item->{'holdingbranch'}, $item, undef ); |
253 |
if (! $transferOk) { |
254 |
$canreserve = 0; |
255 |
} |
249 |
} |
256 |
} |
250 |
else { |
257 |
else { |
251 |
$canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum ); |
258 |
$canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum, $pickupLocation ); |
252 |
|
259 |
|
253 |
# Inserts a null into the 'itemnumber' field of 'reserves' table. |
260 |
# Inserts a null into the 'itemnumber' field of 'reserves' table. |
254 |
$itemNum = undef; |
261 |
$itemNum = undef; |
Lines 264-270
if ( $query->param('place_reserve') ) {
Link Here
|
264 |
# Here we actually do the reserveration. Stage 3. |
271 |
# Here we actually do the reserveration. Stage 3. |
265 |
if ($canreserve) { |
272 |
if ($canreserve) { |
266 |
AddReserve( |
273 |
AddReserve( |
267 |
$branch, $borrowernumber, |
274 |
$pickupLocation, $borrowernumber, |
268 |
$biblioNum, 'a', |
275 |
$biblioNum, 'a', |
269 |
[$biblioNum], $rank, |
276 |
[$biblioNum], $rank, |
270 |
$startdate, $expiration_date, |
277 |
$startdate, $expiration_date, |
Lines 398-403
foreach my $biblioNum (@biblionumbers) {
Link Here
|
398 |
} |
405 |
} |
399 |
} |
406 |
} |
400 |
|
407 |
|
|
|
408 |
#Collect the amout of items that pass the CheckBranchTransferAllowed-check. This is needed to tell |
409 |
# the user if some or all Items cannot be transferred to the pickup location. |
410 |
my $branchTransferableItemsCount = 0; |
411 |
|
401 |
$biblioLoopIter{itemLoop} = []; |
412 |
$biblioLoopIter{itemLoop} = []; |
402 |
my $numCopiesAvailable = 0; |
413 |
my $numCopiesAvailable = 0; |
403 |
foreach my $itemInfo (@{$biblioData->{itemInfos}}) { |
414 |
foreach my $itemInfo (@{$biblioData->{itemInfos}}) { |
Lines 434-443
foreach my $biblioNum (@biblionumbers) {
Link Here
|
434 |
my ($reservedate,$reservedfor,$expectedAt) = GetReservesFromItemnumber($itemNum); |
445 |
my ($reservedate,$reservedfor,$expectedAt) = GetReservesFromItemnumber($itemNum); |
435 |
my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0); |
446 |
my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0); |
436 |
|
447 |
|
437 |
# the item could be reserved for this borrower vi a host record, flag this |
448 |
# the item could be reserved for this borrower vi a host record, flag this |
438 |
if ($reservedfor eq $borrowernumber){ |
449 |
if ($reservedfor eq $borrowernumber){ |
439 |
$itemLoopIter->{already_reserved} = 1; |
450 |
$itemLoopIter->{already_reserved} = 1; |
440 |
} |
451 |
} |
441 |
|
452 |
|
442 |
if ( defined $reservedate ) { |
453 |
if ( defined $reservedate ) { |
443 |
$itemLoopIter->{backgroundcolor} = 'reserved'; |
454 |
$itemLoopIter->{backgroundcolor} = 'reserved'; |
Lines 480-491
foreach my $biblioNum (@biblionumbers) {
Link Here
|
480 |
$itemLoopIter->{nocancel} = 1; |
491 |
$itemLoopIter->{nocancel} = 1; |
481 |
} |
492 |
} |
482 |
|
493 |
|
483 |
# if the items belongs to a host record, show link to host record |
494 |
# if the items belongs to a host record, show link to host record |
484 |
if ($itemInfo->{biblionumber} ne $biblioNum){ |
495 |
if ($itemInfo->{biblionumber} ne $biblioNum){ |
485 |
$biblioLoopIter{hostitemsflag} = 1; |
496 |
$biblioLoopIter{hostitemsflag} = 1; |
486 |
$itemLoopIter->{hostbiblionumber} = $itemInfo->{biblionumber}; |
497 |
$itemLoopIter->{hostbiblionumber} = $itemInfo->{biblionumber}; |
487 |
$itemLoopIter->{hosttitle} = GetBiblioData($itemInfo->{biblionumber})->{title}; |
498 |
$itemLoopIter->{hosttitle} = GetBiblioData($itemInfo->{biblionumber})->{title}; |
488 |
} |
499 |
} |
489 |
|
500 |
|
490 |
# If there is no loan, return and transfer, we show a checkbox. |
501 |
# If there is no loan, return and transfer, we show a checkbox. |
491 |
$itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0; |
502 |
$itemLoopIter->{notforloan} = $itemLoopIter->{notforloan} || 0; |
Lines 501-520
foreach my $biblioNum (@biblionumbers) {
Link Here
|
501 |
} |
512 |
} |
502 |
|
513 |
|
503 |
if (IsAvailableForItemLevelRequest($itemNum) and $policy_holdallowed and CanItemBeReserved($borrowernumber,$itemNum) and ($itemLoopIter->{already_reserved} ne 1)) { |
514 |
if (IsAvailableForItemLevelRequest($itemNum) and $policy_holdallowed and CanItemBeReserved($borrowernumber,$itemNum) and ($itemLoopIter->{already_reserved} ne 1)) { |
504 |
$itemLoopIter->{available} = 1; |
515 |
|
|
|
516 |
$itemLoopIter->{available} = 1; |
505 |
$numCopiesAvailable++; |
517 |
$numCopiesAvailable++; |
|
|
518 |
|
519 |
#Check for UseBranchTransferLimit. $numCopiesAvailable is incremented because this Item |
520 |
# could still be available from another pickup location |
521 |
my ($transferOk, $errorMsg) = CheckBranchTransferAllowed( $pickupBranch, undef, GetItem($itemNum), undef ); |
522 |
if (! $transferOk) { |
523 |
$itemLoopIter->{available} = 0; |
524 |
$itemLoopIter->{branchTransferBlocked} = 1; |
525 |
} |
526 |
else { |
527 |
$branchTransferableItemsCount++; |
528 |
} |
506 |
} |
529 |
} |
507 |
|
530 |
|
508 |
# FIXME: move this to a pm |
531 |
# FIXME: move this to a pm |
509 |
my $dbh = C4::Context->dbh; |
532 |
my $dbh = C4::Context->dbh; |
510 |
my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'"); |
533 |
my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'"); |
511 |
$sth2->execute($itemLoopIter->{ReservedForBorrowernumber}, $itemNum); |
534 |
$sth2->execute($itemLoopIter->{ReservedForBorrowernumber}, $itemNum); |
512 |
while (my $wait_hashref = $sth2->fetchrow_hashref) { |
535 |
while (my $wait_hashref = $sth2->fetchrow_hashref) { |
513 |
$itemLoopIter->{waitingdate} = format_date($wait_hashref->{waitingdate}); |
536 |
$itemLoopIter->{waitingdate} = format_date($wait_hashref->{waitingdate}); |
514 |
} |
537 |
} |
515 |
$itemLoopIter->{imageurl} = getitemtypeimagelocation( 'opac', $itemTypes->{ $itemInfo->{itype} }{imageurl} ); |
538 |
$itemLoopIter->{imageurl} = getitemtypeimagelocation( 'opac', $itemTypes->{ $itemInfo->{itype} }{imageurl} ); |
516 |
|
539 |
|
517 |
# Show serial enumeration when needed |
540 |
# Show serial enumeration when needed |
518 |
if ($itemLoopIter->{enumchron}) { |
541 |
if ($itemLoopIter->{enumchron}) { |
519 |
$itemdata_enumchron = 1; |
542 |
$itemdata_enumchron = 1; |
520 |
} |
543 |
} |
Lines 523-528
foreach my $biblioNum (@biblionumbers) {
Link Here
|
523 |
} |
546 |
} |
524 |
$template->param( itemdata_enumchron => $itemdata_enumchron ); |
547 |
$template->param( itemdata_enumchron => $itemdata_enumchron ); |
525 |
|
548 |
|
|
|
549 |
## Set the behaviour flags for the template |
526 |
if ($numCopiesAvailable > 0) { |
550 |
if ($numCopiesAvailable > 0) { |
527 |
$numBibsAvailable++; |
551 |
$numBibsAvailable++; |
528 |
$biblioLoopIter{bib_available} = 1; |
552 |
$biblioLoopIter{bib_available} = 1; |
Lines 538-550
foreach my $biblioNum (@biblionumbers) {
Link Here
|
538 |
$biblioLoopIter{holdable} = undef; |
562 |
$biblioLoopIter{holdable} = undef; |
539 |
$biblioLoopIter{already_patron_possession} = 1; |
563 |
$biblioLoopIter{already_patron_possession} = 1; |
540 |
} |
564 |
} |
|
|
565 |
if ($branchTransferableItemsCount == 0) { |
566 |
#We can tell our Borrowers that they can try another pickup location if they don't find what they need. |
567 |
$biblioLoopIter{suggestAnotherPickupLocation} = 1 ; |
568 |
} |
569 |
|
541 |
|
570 |
|
542 |
if( $biblioLoopIter{holdable} ){ $anyholdable++; } |
571 |
if( $biblioLoopIter{holdable} ){ $anyholdable++; } |
543 |
|
572 |
|
544 |
push @$biblioLoop, \%biblioLoopIter; |
573 |
push @$biblioLoop, \%biblioLoopIter; |
545 |
} |
574 |
} |
546 |
|
575 |
|
547 |
if ( $numBibsAvailable == 0 || $anyholdable == 0) { |
576 |
if ( $numBibsAvailable == 0 || $anyholdable == 0 ) { |
548 |
$template->param( none_available => 1 ); |
577 |
$template->param( none_available => 1 ); |
549 |
} |
578 |
} |
550 |
|
579 |
|
551 |
- |
|
|