m/priority/ and $show_priority = 1;
}
-sub get_out {
- output_html_with_http_headers(shift,shift,shift); # $query, $cookie, $template->output;
- exit;
-}
-
my $patron = Koha::Patrons->find( $borrowernumber );
my $can_place_hold_if_available_at_pickup = C4::Context->preference('OPACHoldsIfAvailableAtPickup');
# cannot reserve, their card has expired and the rules set mean this is not allowed
$template->param( message => 1, expired_patron => 1 );
- get_out( $query, $cookie, $template->output );
+ output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
+ exit;
}
}
# Pass through any reserve charge
my $reservefee = $patron->category->reservefee;
if ( $reservefee > 0){
- $template->param( RESERVE_CHARGE => sprintf("%.2f",$reservefee));
+ $template->param( RESERVE_CHARGE => $reservefee);
}
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
if ((! $biblionumbers) && (! $query->param('place_reserve'))) {
$template->param(message=>1, no_biblionumber=>1);
- &get_out($query, $cookie, $template->output);
+ output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
+ exit;
}
# Pass the numbers to the page so they can be fed back
if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) {
# TODO: New message?
$template->param(message=>1, no_biblionumber=>1);
- &get_out($query, $cookie, $template->output);
+ output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
+ exit;
}
# Compute the priority rank.
my $biblio = Koha::Biblios->find( $biblioNumber );
+ $biblioData->{object} = $biblio;
my $holds = $biblio->holds;
my $rank = $holds->count;
$biblioData->{reservecount} = 1; # new reserve
my $selectionCount = @selectedItems;
if (($selectionCount == 0) || (($selectionCount % 3) != 0)) {
$template->param(message=>1, bad_data=>1);
- &get_out($query, $cookie, $template->output);
+ output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
+ exit;
}
my $failed_holds = 0;
$branch = $patron->branchcode;
}
+ # When choosing a specific item, the default pickup library should be dictated by the default hold policy
+ if ( ! C4::Context->preference("OPACAllowUserToChooseBranch") && $itemNum ) {
+ my $item = Koha::Items->find( $itemNum );
+ my $type = $item->effective_itemtype;
+ my $rule = GetBranchItemRule( $patron->branchcode, $type );
+
+ if ( $rule->{hold_fulfillment_policy} eq 'any' ) {
+ $branch = $patron->branchcode;
+ } else {
+ my $policy = $rule->{hold_fulfillment_policy};
+ $branch = $item->$policy;
+ }
+ }
+
#item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
if ( $itemNum ne '' ) {
my $item = Koha::Items->find( $itemNum );
my $rank = $biblioData->{rank};
if ( $itemNum ne '' ) {
- $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum )->{status} eq 'OK';
+ $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum, $branch )->{status} eq 'OK';
}
else {
- $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum )->{status} eq 'OK';
+ $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum, $branch )->{status} eq 'OK';
# Inserts a null into the 'itemnumber' field of 'reserves' table.
$itemNum = undef;
my $itemdata_ccode = 0;
my $anyholdable = 0;
my $itemLevelTypes = C4::Context->preference('item-level_itypes');
+my $pickup_locations = Koha::Libraries->search({ pickup_location => 1 });
$template->param('item_level_itypes' => $itemLevelTypes);
foreach my $biblioNum (@biblionumbers) {
- my @not_available_at = ();
- my $record = GetMarcBiblio({ biblionumber => $biblioNum });
# Init the bib item with the choices for branch pickup
my %biblioLoopIter;
my $biblioData = $biblioDataHash{$biblioNum};
if (! $biblioData) {
$template->param(message=>1, bad_biblionumber=>$biblioNum);
- &get_out($query, $cookie, $template->output);
+ output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
+ exit;
+ }
+
+ my @not_available_at = ();
+ my $biblio = $biblioData->{object};
+ foreach my $library ( $pickup_locations->as_list ) {
+ push( @not_available_at, $library->branchcode ) unless $biblio->can_be_transferred({ to => $library });
}
my $frameworkcode = GetFrameworkCode( $biblioData->{biblionumber} );
$biblioLoopIter{biblionumber} = $biblioData->{biblionumber};
$biblioLoopIter{title} = $biblioData->{title};
- $biblioLoopIter{subtitle} = GetRecordValue('subtitle', $record, $frameworkcode);
+ $biblioLoopIter{subtitle} = $biblioData->{'subtitle'};
+ $biblioLoopIter{medium} = $biblioData->{medium};
+ $biblioLoopIter{part_number} = $biblioData->{part_number};
+ $biblioLoopIter{part_name} = $biblioData->{part_name};
$biblioLoopIter{author} = $biblioData->{author};
$biblioLoopIter{rank} = $biblioData->{rank};
$biblioLoopIter{reservecount} = $biblioData->{reservecount};
$itemInfo->{backgroundcolor} = 'other';
}
- # Check of the transfered documents
+ # Check of the transferred documents
my ( $transfertwhen, $transfertfrom, $transfertto ) =
GetTransfers($itemNum);
if ( $transfertwhen && ($transfertwhen ne '') ) {
my $policy_holdallowed = !$itemLoopIter->{already_reserved};
$policy_holdallowed &&=
- IsAvailableForItemLevelRequest($itemInfo,$patron_unblessed) &&
+ IsAvailableForItemLevelRequest($item, $patron) &&
CanItemBeReserved( $borrowernumber, $itemNum )->{status} eq 'OK';
if ($policy_holdallowed) {
$anyholdable = 1 if $biblioLoopIter{holdable};
}
+unless ($pickup_locations->count) {
+ $numBibsAvailable = 0;
+ $anyholdable = 0;
+ $template->param(
+ message => 1,
+ no_pickup_locations => 1
+ );
+}
if ( $numBibsAvailable == 0 || $anyholdable == 0) {
$template->param( none_available => 1 );