use C4::Items qw( get_hostitemnumbers_of );
use C4::Koha qw( getitemtypeimagelocation );
use C4::Serials qw( CountSubscriptionFromBiblionumber );
-use C4::Circulation qw( GetTransfers _GetCircControlBranch GetBranchItemRule );
-use Koha::DateUtils qw( dt_from_string output_pref );
-use C4::Utils::DataTables::Members;
+use C4::Circulation qw( _GetCircControlBranch GetBranchItemRule );
+use Koha::DateUtils qw( dt_from_string );
use C4::Search qw( enabled_staff_search_views );
use Koha::Biblios;
-use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Checkouts;
use Koha::Holds;
use Koha::CirculationRules;
use Koha::ItemTypes;
use Koha::Libraries;
use Koha::Patrons;
+use Koha::Patron::Attribute::Types;
use Koha::Clubs;
use Koha::BackgroundJob::BatchCancelHold;
my $itemtypes = {
map {
$_->itemtype =>
- { %{ $_->unblessed }, image_location => $_->image_location }
+ { %{ $_->unblessed }, image_location => $_->image_location('intranet'), notforloan => $_->notforloan }
} Koha::ItemTypes->search_with_localization->as_list
};
my $exceeded_maxreserves;
my $exceeded_holds_per_record;
-my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
my $action = $input->param('action');
$action ||= q{};
my $itemdata_ccode = 0;
my @biblioloop = ();
my $no_reserves_allowed = 0;
+ my $num_bibs_available = 0;
foreach my $biblionumber (@biblionumbers) {
next unless $biblionumber =~ m|^\d+$|;
my %biblioloopiter = ();
my $biblio = Koha::Biblios->find( $biblionumber );
+
unless ($biblio) {
$biblioloopiter{noitems} = 1;
$template->param('nobiblio' => 1);
last;
}
+ $biblioloopiter{object} = $biblio;
+
if ( $patron ) {
{ # CanBookBeReserved
my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber );
$template->param( $canReserve->{status} => 1);
$biblioloopiter{ $canReserve->{status} } = 1;
}
+ elsif ( $canReserve->{status} eq 'recall' ) {
+ $template->param( $canReserve->{status} => 1 );
+ $biblioloopiter{ $canReserve->{status} } = 1;
+ }
else {
$biblioloopiter{ $canReserve->{status} } = 1;
}
if ( $club_hold or $borrowernumber_hold ) {
my @available_itemtypes;
- my $num_available = 0;
+ my $num_items_available = 0;
my $num_override = 0;
my $hiddencount = 0;
my $num_alreadyheld = 0;
for my $item_object ( @items ) {
my $do_check;
my $item = $item_object->unblessed;
+ $item->{object} = $item_object;
if ( $patron ) {
$do_check = $patron->do_check_for_previous_checkout($item) if $wants_check;
if ( $do_check && $wants_check ) {
my $p = Koha::Patrons->find( $first_hold->borrowernumber );
$item->{backgroundcolor} = 'reserved';
- $item->{reservedate} = output_pref({ dt => dt_from_string( $first_hold->reservedate ), dateonly => 1 }); # FIXME Should be formatted in the template
+ $item->{reservedate} = $first_hold->reservedate;
$item->{ReservedFor} = $p;
$item->{ExpectedAtLibrary} = $first_hold->branchcode;
$item->{waitingdate} = $first_hold->waitingdate;
}
# Check the transit status
- my ( $transfertwhen, $transfertfrom, $transfertto ) =
- GetTransfers($item_object->itemnumber); # FIXME replace with get_transfer
-
- if ( defined $transfertwhen && $transfertwhen ne '' ) {
- $item->{transfertwhen} = output_pref({ dt => dt_from_string( $transfertwhen ), dateonly => 1 });
- $item->{transfertfrom} = $transfertfrom;
- $item->{transfertto} = $transfertto;
+ my $transfer = $item_object->get_transfer;
+ if ( $transfer && $transfer->in_transit ) {
+ $item->{transfertwhen} = $transfer->datesent;
+ $item->{transfertfrom} = $transfer->frombranch;
+ $item->{transfertto} = $transfer->tobranch;
$item->{nocancel} = 1;
}
# If there is no loan, return and transfer, we show a checkbox.
+ $item->{notforloanitype} = $item->{itemtype}->{notforloan};
$item->{notforloan} ||= 0;
# if independent branches is on we need to check if the person can reserve
my $can_item_be_reserved = CanItemBeReserved( $patron, $item_object )->{status};
$item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
+ $item->{not_holdable} ||= 'notforloan' if ( $item->{notforloanitype} || $item->{notforloan} > 0 );
+
$item->{item_level_holds} = Koha::CirculationRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
+ my $default_hold_pickup_location_pref = C4::Context->preference('DefaultHoldPickupLocation');
+ my $default_pickup_branch;
+ if( $default_hold_pickup_location_pref eq 'homebranch' ){
+ $default_pickup_branch = $item->{homebranch};
+ } elsif ( $default_hold_pickup_location_pref eq 'holdingbranch' ){
+ $default_pickup_branch = $item->{holdingbranch};
+ } else {
+ $default_pickup_branch = C4::Context->userenv->{branch};
+ }
+
if (
!$item->{cantreserve}
&& !$exceeded_maxreserves
my $pickup_locations = $item_object->pickup_locations({ patron => $patron });
$item->{pickup_locations_count} = $pickup_locations->count;
if ( $item->{pickup_locations_count} > 0 ) {
- $num_available++;
+ $num_items_available++;
$item->{available} = 1;
# pass the holding branch for use as default
- my $default_pickup_location = $pickup_locations->search({ branchcode => $item->{holdingbranch} })->next;
+ my $default_pickup_location = $pickup_locations->search({ branchcode => $default_pickup_branch })->next;
$item->{default_pickup_location} = $default_pickup_location;
}
else {
$item->{pickup_locations_count} = scalar @pickup_locations;
if ( @pickup_locations ) {
- $num_available++;
- $item->{available} = 1;
+ $num_items_available++;
+ $item->{override} = 1;
my $default_pickup_location;
- # Default to logged-in, if valid
- if ( C4::Context->userenv->{branch} ) {
- ($default_pickup_location) = grep { $_->branchcode eq C4::Context->userenv->{branch} } @pickup_locations;
- }
+ ($default_pickup_location) = grep { $_->branchcode eq $default_pickup_branch } @pickup_locations;
$item->{default_pickup_location} = $default_pickup_location;
}
} else { $num_alreadyheld++ }
push( @available_itemtypes, $item->{itype} );
+ } else {
+ # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
+ $item->{available} = 0;
}
- # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
# Show serial enumeration when needed
if ($item->{enumchron}) {
if ( $num_override > 0 && ($num_override + $num_alreadyheld) == scalar( @{ $biblioloopiter{itemloop} } ) ) {
# That is, if all items require an override
$template->param( override_required => 1 );
- } elsif ( $num_available == 0 ) {
+ } elsif ( $num_items_available == 0 ) {
$template->param( none_available => 1 );
$biblioloopiter{warn} = 1;
$biblioloopiter{none_avail} = 1;
$template->param(
itemdata_enumchron => $itemdata_enumchron,
itemdata_ccode => $itemdata_ccode,
- date => $date,
+ date => dt_from_string,
biblionumber => $biblionumber,
findborrower => $findborrower,
biblio => $biblio,
$template->param( reserveloop => \@reserveloop );
}
- if ( $patron ) {
+ if ( $patron && $multi_hold ) {
# Add the valid pickup locations
my @pickup_locations = $biblio->pickup_locations({ patron => $patron })->as_list;
$biblioloopiter{pickup_locations} = \@pickup_locations;
$biblioloopiter{pickup_locations_codes} = [ map { $_->branchcode } @pickup_locations ];
}
+ $num_bibs_available++ unless $biblioloopiter{none_avail};
push @biblioloop, \%biblioloopiter;
}
+ $template->param( no_bibs_available => 1 ) unless $num_bibs_available > 0;
+
$template->param( biblioloop => \@biblioloop );
$template->param( no_reserves_allowed => $no_reserves_allowed );
$template->param( exceeded_maxreserves => $exceeded_maxreserves );
}
$template->param( biblionumbers => \@biblionumbers );
+$template->param(
+ attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes')
+ ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
+ : []
+ ),
+);
+
+
# pass the userenv branch if no pickup location selected
$template->param( pickup => $pickup || C4::Context->userenv->{branch} );
-if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
- $template->param( reserve_in_future => 1 );
-}
-
-$template->param(
- SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
- AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
- borrowernumber => $borrowernumber_hold,
-);
+$template->param(borrowernumber => $borrowernumber_hold);
# printout the page
output_html_with_http_headers $input, $cookie, $template->output;