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::Search qw( enabled_staff_search_views );
use Koha::Biblios;
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, notforloan => $_->notforloan }
} Koha::ItemTypes->search_with_localization->as_list
};
}
elsif ( $action eq 'cancelBulk' ) {
my $cancellation_reason = $input->param("cancellation-reason");
- my @hold_ids = split ',', $input->param("ids");
+ my @hold_ids = split( ',', scalar $input->param("ids"));
my $params = {
reason => $cancellation_reason,
hold_ids => \@hold_ids,
if ($findborrower) {
my $patron = Koha::Patrons->find( { cardnumber => $findborrower } );
- if ( $patron ) {
- $borrowernumber_hold = $patron->borrowernumber;
- } else {
- my $dt_params = { iDisplayLength => -1 };
- my $results = C4::Utils::DataTables::Members::search(
- {
- searchmember => $findborrower,
- dt_params => $dt_params,
- }
- );
- my $borrowers = $results->{patrons};
- if ( scalar @$borrowers == 1 ) {
- $borrowernumber_hold = $borrowers->[0]->{borrowernumber};
- } elsif ( @$borrowers ) {
- $template->param( borrowers => $borrowers );
- } else {
- $messageborrower = "'$findborrower'";
- }
- }
+ $borrowernumber_hold = $patron->borrowernumber if $patron;
}
if($findclub) {
my @clubs = Koha::Clubs->search( [
{ name => { like => '%'.$findclub.'%' } },
{ description => { like => '%'.$findclub.'%' } }
- ] );
+ ] )->as_list;
if( scalar @clubs == 1 ) {
$club_hold = $clubs[0]->id;
} elsif ( @clubs ) {
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+$|;
$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;
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;
}
# 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++;
+ $num_items_available++;
$item->{available} = 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;
$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} );