View | Details | Raw Unified | Return to bug 17829
Collapse All | Expand All

(-)a/reserve/request.pl (-62 / +67 lines)
Lines 215-243 foreach my $biblionumber (@biblionumbers) { Link Here
215
215
216
    my $dat = GetBiblioData($biblionumber);
216
    my $dat = GetBiblioData($biblionumber);
217
217
218
    my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber );
218
    my $force_hold_level;
219
    $canReserve //= '';
219
    if ( $patron ) {
220
    if ( $canReserve eq 'OK' ) {
220
        { # CanBookBeReserved
221
            my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber );
222
            $canReserve //= '';
223
            if ( $canReserve eq 'OK' ) {
221
224
222
        #All is OK and we can continue
225
                #All is OK and we can continue
223
    }
226
            }
224
    elsif ( $canReserve eq 'tooManyReserves' ) {
227
            elsif ( $canReserve eq 'tooManyReserves' ) {
225
        $exceeded_maxreserves = 1;
228
                $exceeded_maxreserves = 1;
226
    }
229
            }
227
    elsif ( $canReserve eq 'tooManyHoldsForThisRecord' ) {
230
            elsif ( $canReserve eq 'tooManyHoldsForThisRecord' ) {
228
        $exceeded_holds_per_record = 1;
231
                $exceeded_holds_per_record = 1;
229
        $biblioloopiter{$canReserve} = 1;
232
                $biblioloopiter{$canReserve} = 1;
230
    }
233
            }
231
    elsif ( $canReserve eq 'ageRestricted' ) {
234
            elsif ( $canReserve eq 'ageRestricted' ) {
232
        $template->param( $canReserve => 1 );
235
                $template->param( $canReserve => 1 );
233
        $biblioloopiter{$canReserve} = 1;
236
                $biblioloopiter{$canReserve} = 1;
234
    }
237
            }
235
    else {
238
            else {
236
        $biblioloopiter{$canReserve} = 1;
239
                $biblioloopiter{$canReserve} = 1;
237
    }
240
            }
241
        }
238
242
239
    my $force_hold_level;
240
    if ( $patron->borrowernumber ) {
241
        # For multiple holds per record, if a patron has previously placed a hold,
243
        # For multiple holds per record, if a patron has previously placed a hold,
242
        # the patron can only place more holds of the same type. That is, if the
244
        # the patron can only place more holds of the same type. That is, if the
243
        # patron placed a record level hold, all the holds the patron places must
245
        # patron placed a record level hold, all the holds the patron places must
Lines 261-275 foreach my $biblionumber (@biblionumbers) { Link Here
261
        $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
263
        $biblioloopiter{remaining_holds_for_record} = $max_holds_for_record;
262
        $template->param( max_holds_for_record => $max_holds_for_record );
264
        $template->param( max_holds_for_record => $max_holds_for_record );
263
        $template->param( remaining_holds_for_record => $remaining_holds_for_record );
265
        $template->param( remaining_holds_for_record => $remaining_holds_for_record );
264
    }
265
266
266
    # Check to see if patron is allowed to place holds on records where the
267
        { # alreadypossession
267
    # patron already has an item from that record checked out
268
            # Check to see if patron is allowed to place holds on records where the
268
    my $alreadypossession;
269
            # patron already has an item from that record checked out
269
    if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
270
            my $alreadypossession;
270
        && CheckIfIssuedToPatron( $patron->borrowernumber, $biblionumber ) )
271
            if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions')
271
    {
272
                && CheckIfIssuedToPatron( $patron->borrowernumber, $biblionumber ) )
272
        $template->param( alreadypossession => $alreadypossession, );
273
            {
274
                $template->param( alreadypossession => $alreadypossession, );
275
            }
276
        }
273
    }
277
    }
274
278
275
279
Lines 392-404 foreach my $biblionumber (@biblionumbers) { Link Here
392
            # checking reserve
396
            # checking reserve
393
            my $holds = Koha::Items->find( $itemnumber )->current_holds;
397
            my $holds = Koha::Items->find( $itemnumber )->current_holds;
394
            if ( my $first_hold = $holds->next ) {
398
            if ( my $first_hold = $holds->next ) {
395
                my $patron = Koha::Patrons->find( $first_hold->borrowernumber );
399
                my $p = Koha::Patrons->find( $first_hold->borrowernumber );
396
400
397
                $item->{backgroundcolor} = 'reserved';
401
                $item->{backgroundcolor} = 'reserved';
398
                $item->{reservedate}     = output_pref({ dt => dt_from_string( $first_hold->reservedate ), dateonly => 1 }); # FIXME Should be formatted in the template
402
                $item->{reservedate}     = output_pref({ dt => dt_from_string( $first_hold->reservedate ), dateonly => 1 }); # FIXME Should be formatted in the template
399
                $item->{ReservedForBorrowernumber}     = $first_hold->borrowernumber;
403
                $item->{ReservedForBorrowernumber}     = $p->borrowernumber;
400
                $item->{ReservedForSurname}     = $patron->surname;
404
                $item->{ReservedForSurname}     = $p->surname;
401
                $item->{ReservedForFirstname}     = $patron->firstname;
405
                $item->{ReservedForFirstname}     = $p->firstname;
402
                $item->{ExpectedAtLibrary}     = $first_hold->branchcode;
406
                $item->{ExpectedAtLibrary}     = $first_hold->branchcode;
403
                $item->{waitingdate} = $first_hold->waitingdate;
407
                $item->{waitingdate} = $first_hold->waitingdate;
404
            }
408
            }
Lines 451-491 foreach my $biblionumber (@biblionumbers) { Link Here
451
                }
455
                }
452
            }
456
            }
453
457
454
            my $patron_unblessed = $patron->unblessed;
458
            if ( $patron ) {
455
            my $branch = C4::Circulation::_GetCircControlBranch($item, $patron_unblessed);
459
                my $patron_unblessed = $patron->unblessed;
460
                my $branch = C4::Circulation::_GetCircControlBranch($item, $patron_unblessed);
456
461
457
            my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
462
                my $branchitemrule = GetBranchItemRule( $branch, $item->{'itype'} );
458
463
459
            $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
464
                $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
460
465
461
            my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber );
466
                my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber );
462
            $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
467
                $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' );
463
468
464
            $item->{item_level_holds} = OPACItemHoldsAllowed( $item, $patron_unblessed);
469
                $item->{item_level_holds} = OPACItemHoldsAllowed( $item, $patron_unblessed);
465
470
466
            if (
471
                if (
467
                   !$item->{cantreserve}
472
                       !$item->{cantreserve}
468
                && !$exceeded_maxreserves
473
                    && !$exceeded_maxreserves
469
                && IsAvailableForItemLevelRequest($item, $patron_unblessed)
474
                    && IsAvailableForItemLevelRequest($item, $patron_unblessed)
470
                && $can_item_be_reserved eq 'OK'
475
                    && $can_item_be_reserved eq 'OK'
471
              )
476
                  )
472
            {
477
                {
473
                $item->{available} = 1;
478
                    $item->{available} = 1;
474
                $num_available++;
479
                    $num_available++;
475
480
476
                push( @available_itemtypes, $item->{itype} );
481
                    push( @available_itemtypes, $item->{itype} );
477
            }
482
                }
478
            elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) {
483
                elsif ( C4::Context->preference('AllowHoldPolicyOverride') ) {
479
                # If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules
484
                    # If AllowHoldPolicyOverride is set, it should override EVERY restriction, not just branch item rules
480
                $item->{override} = 1;
485
                    $item->{override} = 1;
481
                $num_override++;
486
                    $num_override++;
482
            }
487
                }
483
488
484
            # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
489
                # If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
485
490
486
            # Show serial enumeration when needed
491
                # Show serial enumeration when needed
487
            if ($item->{enumchron}) {
492
                if ($item->{enumchron}) {
488
                $itemdata_enumchron = 1;
493
                    $itemdata_enumchron = 1;
494
                }
489
            }
495
            }
490
496
491
            push @{ $biblioitem->{itemloop} }, $item;
497
            push @{ $biblioitem->{itemloop} }, $item;
Lines 611-617 foreach my $biblionumber (@biblionumbers) { Link Here
611
                     holdsview => 1,
617
                     holdsview => 1,
612
                     C4::Search::enabled_staff_search_views,
618
                     C4::Search::enabled_staff_search_views,
613
                    );
619
                    );
614
    if ( $patron ) { # FIXME This test seems very useless
620
    if ( $patron ) {
615
        $template->param( borrower_branchcode => $patron->branchcode );
621
        $template->param( borrower_branchcode => $patron->branchcode );
616
    }
622
    }
617
623
618
- 

Return to bug 17829