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

(-)a/Koha/Item.pm (-2 / +2 lines)
Lines 185-195 sub article_request_type { Link Here
185
    return $issuing_rule->article_requests || q{}
185
    return $issuing_rule->article_requests || q{}
186
}
186
}
187
187
188
=head3 holds_placed_before_today
188
=head3 current_holds
189
189
190
=cut
190
=cut
191
191
192
sub holds_placed_before_today {
192
sub current_holds {
193
    my ( $self ) = @_;
193
    my ( $self ) = @_;
194
    my $attributes = { order_by => 'priority' };
194
    my $attributes = { order_by => 'priority' };
195
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
195
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
(-)a/catalogue/detail.pl (-1 / +1 lines)
Lines 259-265 foreach my $item (@items) { Link Here
259
259
260
    # checking for holds
260
    # checking for holds
261
    my $item_object = Koha::Items->find( $item->{itemnumber} );
261
    my $item_object = Koha::Items->find( $item->{itemnumber} );
262
    my $holds = $item_object->holds_placed_before_today;
262
    my $holds = $item_object->current_holds;
263
    if ( my $first_hold = $holds->next ) {
263
    if ( my $first_hold = $holds->next ) {
264
        my $ItemBorrowerReserveInfo = C4::Members::GetMember( borrowernumber => $first_hold->borrowernumber); # FIXME could be improved
264
        my $ItemBorrowerReserveInfo = C4::Members::GetMember( borrowernumber => $first_hold->borrowernumber); # FIXME could be improved
265
        $item->{backgroundcolor} = 'reserved';
265
        $item->{backgroundcolor} = 'reserved';
(-)a/circ/transferstoreceive.pl (-1 / +1 lines)
Lines 102-108 while ( my $library = $libraries->next ) { Link Here
102
102
103
            # we check if we have a reserv for this transfer
103
            # we check if we have a reserv for this transfer
104
            my $item = Koha::Items->find( $num->{itemnumber} );
104
            my $item = Koha::Items->find( $num->{itemnumber} );
105
            my $holds = $item->holds_placed_before_today;
105
            my $holds = $item->current_holds;
106
            if ( my $first_hold = $holds->next ) {
106
            if ( my $first_hold = $holds->next ) {
107
                my $getborrower = C4::Members::GetMember( borrowernumber => $first_hold->borrowernumber );
107
                my $getborrower = C4::Members::GetMember( borrowernumber => $first_hold->borrowernumber );
108
                $getransf{'borrowernum'}       = $getborrower->{'borrowernumber'};
108
                $getransf{'borrowernum'}       = $getborrower->{'borrowernumber'};
(-)a/opac/opac-reserve.pl (-1 / +1 lines)
Lines 472-478 foreach my $biblioNum (@biblionumbers) { Link Here
472
472
473
        # checking reserve
473
        # checking reserve
474
        my $item = Koha::Items->find( $itemNum );
474
        my $item = Koha::Items->find( $itemNum );
475
        my $holds = $item->holds_placed_before_today;
475
        my $holds = $item->current_holds;
476
476
477
        # the item could be reserved for this borrower vi a host record, flag this
477
        # the item could be reserved for this borrower vi a host record, flag this
478
        my $reservedfor = q||;
478
        my $reservedfor = q||;
(-)a/reserve/request.pl (-1 / +1 lines)
Lines 389-395 foreach my $biblionumber (@biblionumbers) { Link Here
389
            }
389
            }
390
390
391
            # checking reserve
391
            # checking reserve
392
            my $holds = Koha::Items->find( $itemnumber )->holds_placed_before_today;
392
            my $holds = Koha::Items->find( $itemnumber )->current_holds;
393
            if ( my $first_hold = $holds->next ) {
393
            if ( my $first_hold = $holds->next ) {
394
                my $ItemBorrowerReserveInfo = GetMember( borrowernumber => $first_hold->borrowernumber );
394
                my $ItemBorrowerReserveInfo = GetMember( borrowernumber => $first_hold->borrowernumber );
395
395
(-)a/t/db_dependent/Holds.t (-2 / +2 lines)
Lines 95-101 is( $holds->next->priority, 4, "Reserve 4 has a priority of 4" ); Link Here
95
is( $holds->next->priority, 5, "Reserve 5 has a priority of 5" );
95
is( $holds->next->priority, 5, "Reserve 5 has a priority of 5" );
96
96
97
my $item = Koha::Items->find( $itemnumber );
97
my $item = Koha::Items->find( $itemnumber );
98
$holds = $item->holds_placed_before_today;
98
$holds = $item->current_holds;
99
my $first_hold = $holds->next;
99
my $first_hold = $holds->next;
100
my $reservedate = $first_hold->reservedate;
100
my $reservedate = $first_hold->reservedate;
101
my $borrowernumber = $first_hold->borrowernumber;
101
my $borrowernumber = $first_hold->borrowernumber;
Lines 132-138 CancelReserve({ 'reserve_id' => $reserve_id }); Link Here
132
$holds = $biblio->holds;
132
$holds = $biblio->holds;
133
is( $holds->count, $borrowers_count - 1, "Test CancelReserve()" );
133
is( $holds->count, $borrowers_count - 1, "Test CancelReserve()" );
134
134
135
$holds = $item->holds_placed_before_today;
135
$holds = $item->current_holds;
136
$first_hold = $holds->next;
136
$first_hold = $holds->next;
137
$borrowernumber = $first_hold->borrowernumber;
137
$borrowernumber = $first_hold->borrowernumber;
138
$branch_1code = $first_hold->branchcode;
138
$branch_1code = $first_hold->branchcode;
(-)a/t/db_dependent/Reserves.t (-9 / +8 lines)
Lines 404-411 is( Link Here
404
my $letter = ReserveSlip($branch_1, $requesters{$branch_1}, $bibnum);
404
my $letter = ReserveSlip($branch_1, $requesters{$branch_1}, $bibnum);
405
ok(defined($letter), 'can successfully generate hold slip (bug 10949)');
405
ok(defined($letter), 'can successfully generate hold slip (bug 10949)');
406
406
407
# Tests for bug 9788: Does Koha::Item->holds_placed_before_today return a future wait?
407
# Tests for bug 9788: Does Koha::Item->current_holds return a future wait?
408
# 9788a: holds_placed_before_today does not return future next available hold
408
# 9788a: current_holds does not return future next available hold
409
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
409
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
410
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2);
410
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2);
411
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
411
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
Lines 416-436 AddReserve($branch_1, $requesters{$branch_1}, $bibnum, Link Here
416
           $bibitems,  1, $resdate, $expdate, $notes,
416
           $bibitems,  1, $resdate, $expdate, $notes,
417
           $title,      $checkitem, $found);
417
           $title,      $checkitem, $found);
418
my $item = Koha::Items->find( $itemnumber );
418
my $item = Koha::Items->find( $itemnumber );
419
$holds = $item->holds_placed_before_today;
419
$holds = $item->current_holds;
420
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
420
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
421
my $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
421
my $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
422
is( $future_holds->count, 0, 'holds_placed_before_today does not return a future next available hold');
422
is( $future_holds->count, 0, 'current_holds does not return a future next available hold');
423
# 9788b: holds_placed_before_today does not return future item level hold
423
# 9788b: current_holds does not return future item level hold
424
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
424
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
425
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
425
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
426
           $bibitems,  1, $resdate, $expdate, $notes,
426
           $bibitems,  1, $resdate, $expdate, $notes,
427
           $title,      $itemnumber, $found); #item level hold
427
           $title,      $itemnumber, $found); #item level hold
428
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
428
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
429
is( $future_holds->count, 0, 'holds_placed_before_today does not return a future item level hold' );
429
is( $future_holds->count, 0, 'current_holds does not return a future item level hold' );
430
# 9788c: holds_placed_before_today returns future wait (confirmed future hold)
430
# 9788c: current_holds returns future wait (confirmed future hold)
431
ModReserveAffect( $itemnumber,  $requesters{$branch_1} , 0); #confirm hold
431
ModReserveAffect( $itemnumber,  $requesters{$branch_1} , 0); #confirm hold
432
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
432
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
433
is( $future_holds->count, 1, 'holds_placed_before_today returns a future wait (confirmed future hold)' );
433
is( $future_holds->count, 1, 'current_holds returns a future wait (confirmed future hold)' );
434
# End of tests for bug 9788
434
# End of tests for bug 9788
435
435
436
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
436
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
437
- 

Return to bug 17737