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 396-403 is( Link Here
396
my $letter = ReserveSlip($branch_1, $requesters{$branch_1}, $bibnum);
396
my $letter = ReserveSlip($branch_1, $requesters{$branch_1}, $bibnum);
397
ok(defined($letter), 'can successfully generate hold slip (bug 10949)');
397
ok(defined($letter), 'can successfully generate hold slip (bug 10949)');
398
398
399
# Tests for bug 9788: Does Koha::Item->holds_placed_before_today return a future wait?
399
# Tests for bug 9788: Does Koha::Item->current_holds return a future wait?
400
# 9788a: holds_placed_before_today does not return future next available hold
400
# 9788a: current_holds does not return future next available hold
401
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
401
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
402
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2);
402
t::lib::Mocks::mock_preference('ConfirmFutureHolds', 2);
403
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
403
t::lib::Mocks::mock_preference('AllowHoldDateInFuture', 1);
Lines 408-428 AddReserve($branch_1, $requesters{$branch_1}, $bibnum, Link Here
408
           $bibitems,  1, $resdate, $expdate, $notes,
408
           $bibitems,  1, $resdate, $expdate, $notes,
409
           $title,      $checkitem, $found);
409
           $title,      $checkitem, $found);
410
my $item = Koha::Items->find( $itemnumber );
410
my $item = Koha::Items->find( $itemnumber );
411
$holds = $item->holds_placed_before_today;
411
$holds = $item->current_holds;
412
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
412
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
413
my $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
413
my $future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
414
is( $future_holds->count, 0, 'holds_placed_before_today does not return a future next available hold');
414
is( $future_holds->count, 0, 'current_holds does not return a future next available hold');
415
# 9788b: holds_placed_before_today does not return future item level hold
415
# 9788b: current_holds does not return future item level hold
416
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
416
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
417
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
417
AddReserve($branch_1,  $requesters{$branch_1}, $bibnum,
418
           $bibitems,  1, $resdate, $expdate, $notes,
418
           $bibitems,  1, $resdate, $expdate, $notes,
419
           $title,      $itemnumber, $found); #item level hold
419
           $title,      $itemnumber, $found); #item level hold
420
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
420
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
421
is( $future_holds->count, 0, 'holds_placed_before_today does not return a future item level hold' );
421
is( $future_holds->count, 0, 'current_holds does not return a future item level hold' );
422
# 9788c: holds_placed_before_today returns future wait (confirmed future hold)
422
# 9788c: current_holds returns future wait (confirmed future hold)
423
ModReserveAffect( $itemnumber,  $requesters{$branch_1} , 0); #confirm hold
423
ModReserveAffect( $itemnumber,  $requesters{$branch_1} , 0); #confirm hold
424
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
424
$future_holds = $holds->search({ reservedate => { '>' => $dtf->format_date( dt_from_string ) } } );
425
is( $future_holds->count, 1, 'holds_placed_before_today returns a future wait (confirmed future hold)' );
425
is( $future_holds->count, 1, 'current_holds returns a future wait (confirmed future hold)' );
426
# End of tests for bug 9788
426
# End of tests for bug 9788
427
427
428
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
428
$dbh->do("DELETE FROM reserves WHERE biblionumber=?",undef,($bibnum));
429
- 

Return to bug 17737