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

(-)a/Koha/Item.pm (-2 / +2 lines)
Lines 171-181 sub article_request_type { Link Here
171
    return $issuing_rule->article_requests || q{}
171
    return $issuing_rule->article_requests || q{}
172
}
172
}
173
173
174
=head3 holds_placed_before_today
174
=head3 current_holds
175
175
176
=cut
176
=cut
177
177
178
sub holds_placed_before_today {
178
sub current_holds {
179
    my ( $self ) = @_;
179
    my ( $self ) = @_;
180
    my $attributes = { order_by => 'priority' };
180
    my $attributes = { order_by => 'priority' };
181
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
181
    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 101-107 while ( my $library = $libraries->next ) { Link Here
101
101
102
            # we check if we have a reserv for this transfer
102
            # we check if we have a reserv for this transfer
103
            my $item = Koha::Items->find( $num->{itemnumber} );
103
            my $item = Koha::Items->find( $num->{itemnumber} );
104
            my $holds = $item->holds_placed_before_today;
104
            my $holds = $item->current_holds;
105
            if ( my $first_hold = $holds->next ) {
105
            if ( my $first_hold = $holds->next ) {
106
                my $getborrower = C4::Members::GetMember( borrowernumber => $first_hold->borrowernumber );
106
                my $getborrower = C4::Members::GetMember( borrowernumber => $first_hold->borrowernumber );
107
                $getransf{'borrowernum'}       = $getborrower->{'borrowernumber'};
107
                $getransf{'borrowernum'}       = $getborrower->{'borrowernumber'};
(-)a/opac/opac-reserve.pl (-1 / +1 lines)
Lines 450-456 foreach my $biblioNum (@biblionumbers) { Link Here
450
450
451
        # checking reserve
451
        # checking reserve
452
        my $item = Koha::Items->find( $itemNum );
452
        my $item = Koha::Items->find( $itemNum );
453
        my $holds = $item->holds_placed_before_today;
453
        my $holds = $item->current_holds;
454
454
455
        # the item could be reserved for this borrower vi a host record, flag this
455
        # the item could be reserved for this borrower vi a host record, flag this
456
        my $reservedfor = q||;
456
        my $reservedfor = q||;
(-)a/reserve/request.pl (-1 / +1 lines)
Lines 387-393 foreach my $biblionumber (@biblionumbers) { Link Here
387
            }
387
            }
388
388
389
            # checking reserve
389
            # checking reserve
390
            my $holds = Koha::Items->find( $itemnumber )->holds_placed_before_today;
390
            my $holds = Koha::Items->find( $itemnumber )->current_holds;
391
            if ( my $first_hold = $holds->next ) {
391
            if ( my $first_hold = $holds->next ) {
392
                my $ItemBorrowerReserveInfo = GetMember( borrowernumber => $first_hold->borrowernumber );
392
                my $ItemBorrowerReserveInfo = GetMember( borrowernumber => $first_hold->borrowernumber );
393
393
(-)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