use C4::Koha qw( getitemtypeimagelocation getitemtypeimagesrc );
use C4::Circulation qw( GetBranchItemRule GetTransfers );
use C4::Reserves qw( CanItemBeReserved CanBookBeReserved AddReserve GetReservesControlBranch ItemsAnyAvailableAndNotRestricted IsAvailableForItemLevelRequest );
-use C4::Biblio qw( GetBiblioData GetFrameworkCode GetMarcBiblio );
+use C4::Biblio qw( GetBiblioData GetFrameworkCode );
use C4::Items qw( GetHostItemsInfo GetItemsInfo );
use C4::Output qw( output_html_with_http_headers );
use C4::Context;
my @itemInfos = GetItemsInfo($biblioNumber);
- my $marcrecord= GetMarcBiblio({ biblionumber => $biblioNumber });
+ my $biblio = Koha::Biblios->find( $biblioNumber );
+ next unless $biblio;
+
+ my $marcrecord = $biblio->metadata->record;
# flag indicating existence of at least one item linked via a host record
# adding items linked via host biblios
}
# Compute the priority rank.
- my $biblio = Koha::Biblios->find( $biblioNumber );
- next unless $biblio;
-
$biblioData->{object} = $biblio;
my $holds = $biblio->holds;
my $rank = $holds->count;
my $patron_expiration_date = $query->param("expiration_date_$biblioNum");
+ my $itemtype = $query->param('itemtype') || undef;
+ $itemtype = undef if $itemNum;
+
my $rank = $biblioData->{rank};
my $patron = Koha::Patrons->find( $borrowernumber );
if ( $item ) {
$canreserve = 1 if CanItemBeReserved( $patron, $item, $branch )->{status} eq 'OK';
}
else {
- $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum, $branch )->{status} eq 'OK';
+ $canreserve = 1
+ if CanBookBeReserved( $borrowernumber, $biblioNum, $branch, { itemtype => $itemtype } )->{status} eq 'OK';
# Inserts a null into the 'itemnumber' field of 'reserves' table.
$itemNum = undef;
}
}
- my $itemtype = $query->param('itemtype') || undef;
- $itemtype = undef if $itemNum;
-
# Here we actually do the reserveration. Stage 3.
if ($canreserve) {
my $reserve_id = AddReserve(
# change the background color.
my $issue = Koha::Checkouts->find( { itemnumber => $itemNum } );
if ( $issue ) {
- $itemLoopIter->{dateDue} = output_pref({ dt => dt_from_string($issue->date_due, 'sql'), as_due_date => 1 });
+ $itemLoopIter->{dateDue} = $issue->date_due;
$itemLoopIter->{onloan} = 'onloan';
}
if ( my $first_hold = $holds->next ) {
$itemLoopIter->{backgroundcolor} = 'reserved';
- $itemLoopIter->{reservedate} = output_pref({ dt => dt_from_string($first_hold->reservedate), dateonly => 1 }); # FIXME Should be formatted in the template
+ $itemLoopIter->{reservedate} = $first_hold->reservedate;
$itemLoopIter->{ExpectedAtLibrary} = $first_hold->branchcode;
$itemLoopIter->{waitingdate} = $first_hold->waitingdate;
}
my $patron_unblessed = $patron->unblessed;
my $branch = GetReservesControlBranch( $itemInfo, $patron_unblessed );
- my $policy_holdallowed = !$itemLoopIter->{already_reserved};
# items_any_available defined outside of the current loop,
# so we avoiding loop inside IsAvailableForItemLevelRequest:
- $policy_holdallowed &&=
+ my $policy_holdallowed =
CanItemBeReserved( $patron, $item )->{status} eq 'OK' &&
IsAvailableForItemLevelRequest($item, $patron, undef, $items_any_available);
$biblioLoopIter{holdable} &&= $status eq 'OK';
$biblioLoopIter{already_patron_possession} = $status eq 'alreadypossession';
+ if ( $biblioLoopIter{holdable} and C4::Context->preference('AllowHoldItemTypeSelection') ) {
+ # build the allowed item types loop
+ my $rs = $biblio->items->search(
+ undef,
+ { select => [ { distinct => 'itype' } ],
+ as => 'item_type'
+ }
+ );
+
+ my @item_types =
+ grep { CanBookBeReserved( $borrowernumber, $biblioNum, $branch, { itemtype => $_ } )->{status} eq 'OK' }
+ $rs->get_column('item_type');
+
+ $biblioLoopIter{allowed_item_types} = \@item_types;
+ }
+
+ if ( $status eq 'recall' ) {
+ $biblioLoopIter{recall} = 1;
+ }
+
# For multiple holds per record, if a patron has previously placed a hold,
# the patron can only place more holds of the same type. That is, if the
# patron placed a record level hold, all the holds the patron places must