use C4::Biblio;
use C4::Items;
use C4::Koha;
+use C4::Serials;
use C4::Circulation;
use Koha::DateUtils;
use C4::Utils::DataTables::Members;
);
my $showallitems = $input->param('showallitems');
+my $pickup = $input->param('pickup') || C4::Context->userenv->{'branch'};
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
$action ||= q{};
if ( $action eq 'move' ) {
- my $where = $input->param('where');
- my $reserve_id = $input->param('reserve_id');
- AlterPriority( $where, $reserve_id );
+ my $where = $input->param('where');
+ my $reserve_id = $input->param('reserve_id');
+ my $prev_priority = $input->param('prev_priority');
+ my $next_priority = $input->param('next_priority');
+ my $first_priority = $input->param('first_priority');
+ my $last_priority = $input->param('last_priority');
+ my $hold_itemnumber = $input->param('itemnumber');
+ if ( $prev_priority == 0 && $next_priority == 1 ){
+ C4::Reserves::RevertWaitingStatus({ itemnumber => $hold_itemnumber });
+ } else {
+ AlterPriority( $where, $reserve_id, $prev_priority, $next_priority, $first_priority, $last_priority );
+ }
} elsif ( $action eq 'cancel' ) {
my $reserve_id = $input->param('reserve_id');
my $hold = Koha::Holds->find( $reserve_id );
push @biblionumbers, $input->multi_param('biblionumber');
}
+my $multihold = scalar $input->param('multi_hold');
# FIXME multi_hold should not be a variable but depends on the number of elements in @biblionumbers
$template->param(multi_hold => scalar $input->param('multi_hold'));
my $logged_in_patron = Koha::Patrons->find( $borrowernumber );
+my $wants_check;
+if ($patron) {
+ $wants_check = $patron->wants_check_for_previous_checkout;
+}
my $itemdata_enumchron = 0;
+my $itemdata_ccode = 0;
my @biblioloop = ();
foreach my $biblionumber (@biblionumbers) {
next unless $biblionumber =~ m|^\d+$|;
my $force_hold_level;
if ( $patron ) {
{ # CanBookBeReserved
- my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber );
- $canReserve->{status} //= '';
+ my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber, $pickup );
if ( $canReserve->{status} eq 'OK' ) {
#All is OK and we can continue
foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } ) {
my $item = $iteminfos_of->{$itemnumber};
-
+ my $do_check;
+ if ( $patron ) {
+ $do_check = $patron->do_check_for_previous_checkout($item) if $wants_check;
+ if ( $do_check && $wants_check ) {
+ $item->{checked_previously} = $do_check;
+ if ( $multihold ) {
+ $biblioloopiter{checked_previously} = $do_check;
+ } else {
+ $template->param( checked_previously => $do_check );
+ }
+ }
+ }
$item->{force_hold_level} = $force_hold_level;
unless (C4::Context->preference('item-level_itypes')) {
# for branches they arent logged in to
if ( C4::Context->preference("IndependentBranches") ) {
if (! C4::Context->preference("canreservefromotherbranches")){
- # cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
+ # can't reserve items so need to check if item homebranch and userenv branch match if not we can't reserve
my $userenv = C4::Context->userenv;
unless ( C4::Context->IsSuperLibrarian ) {
$item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
$item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
- my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber );
+ my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber, $pickup );
$item->{not_holdable} = $can_item_be_reserved->{status} unless ( $can_item_be_reserved->{status} eq 'OK' );
$item->{item_level_holds} = Koha::IssuingRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } );
if (
!$item->{cantreserve}
&& !$exceeded_maxreserves
- && IsAvailableForItemLevelRequest($item, $patron_unblessed)
- && $can_item_be_reserved eq 'OK'
+ && IsAvailableForItemLevelRequest($item_object, $patron)
+ && $can_item_be_reserved->{status} eq 'OK'
)
{
$item->{available} = 1;
push( @available_itemtypes, $item->{itype} );
}
- elsif ( $can_item_be_reserved eq 'tooManyReserves' && C4::Context->preference('AllowHoldPolicyOverride') ) {
+ elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) {
# If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules
$item->{override} = 1;
$num_override++;
if ($item->{enumchron}) {
$itemdata_enumchron = 1;
}
+ # Show collection when needed
+ if ($item->{ccode}) {
+ $itemdata_ccode = 1;
+ }
}
push @{ $biblioitem->{itemloop} }, $item;
$reserve{'reserve_id'} = $res->reserve_id();
$reserve{itemtype} = $res->itemtype();
$reserve{branchcode} = $res->branchcode();
+ $reserve{object} = $res;
push( @reserveloop, \%reserve );
}
optionloop => \@optionloop,
bibitemloop => \@bibitemloop,
itemdata_enumchron => $itemdata_enumchron,
+ itemdata_ccode => $itemdata_ccode,
date => $date,
biblionumber => $biblionumber,
findborrower => $findborrower,
$template->param( biblionumbers => $biblionumbers );
$template->param( exceeded_maxreserves => $exceeded_maxreserves );
$template->param( exceeded_holds_per_record => $exceeded_holds_per_record );
+$template->param( subscriptionsnumber => CountSubscriptionFromBiblionumber($biblionumber));
+$template->param( pickup => $pickup );
if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
$template->param( reserve_in_future => 1 );