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

(-)a/C4/Items.pm (-1 / +1 lines)
Lines 944-950 sub GetItemsInfo { Link Here
944
           holding.opac_info as holding_branch_opac_info,
944
           holding.opac_info as holding_branch_opac_info,
945
           home.opac_info as home_branch_opac_info
945
           home.opac_info as home_branch_opac_info
946
    ";
946
    ";
947
    $query .= ",IF(tmp_holdsqueue.itemnumber,1,0) AS pending_hold" if !C4::Context->preference('AllowItemsOnHoldCheckout');
947
    $query .= ",IF(tmp_holdsqueue.itemnumber,1,0) AS has_pending_hold" if !C4::Context->preference('AllowItemsOnHoldCheckout');
948
    $query .= "
948
    $query .= "
949
     FROM items
949
     FROM items
950
     LEFT JOIN branches AS holding ON items.holdingbranch = holding.branchcode
950
     LEFT JOIN branches AS holding ON items.holdingbranch = holding.branchcode
(-)a/C4/XSLT.pm (-2 / +2 lines)
Lines 317-323 sub buildKohaItemsNamespace { Link Here
317
        my $reservestatus = C4::Reserves::GetReserveStatus( $item->{itemnumber} );
317
        my $reservestatus = C4::Reserves::GetReserveStatus( $item->{itemnumber} );
318
318
319
        if ( ( $item->{itype} && $itemtypes->{ $item->{itype} }->{notforloan} ) || $item->{notforloan} || $item->{onloan} || $item->{withdrawn} || $item->{itemlost} || $item->{damaged} ||
319
        if ( ( $item->{itype} && $itemtypes->{ $item->{itype} }->{notforloan} ) || $item->{notforloan} || $item->{onloan} || $item->{withdrawn} || $item->{itemlost} || $item->{damaged} ||
320
             (defined $transfertwhen && $transfertwhen ne '') || $item->{itemnotforloan} || (defined $reservestatus && $reservestatus eq "Waiting") || $item->{pending_hold} ){
320
             (defined $transfertwhen && $transfertwhen ne '') || $item->{itemnotforloan} || (defined $reservestatus && $reservestatus eq "Waiting") || $item->{has_pending_hold} ){
321
            if ( $item->{notforloan} < 0) {
321
            if ( $item->{notforloan} < 0) {
322
                $status = "On order";
322
                $status = "On order";
323
            }
323
            }
Lines 342-348 sub buildKohaItemsNamespace { Link Here
342
            if (defined $reservestatus && $reservestatus eq "Waiting") {
342
            if (defined $reservestatus && $reservestatus eq "Waiting") {
343
                $status = 'Waiting';
343
                $status = 'Waiting';
344
            }
344
            }
345
            if ($item->{pending_hold}) {
345
            if ($item->{has_pending_hold}) {
346
                $status = 'Pending hold';
346
                $status = 'Pending hold';
347
            }
347
            }
348
        } else {
348
        } else {
(-)a/Koha/Item.pm (-3 / +3 lines)
Lines 354-368 sub add_to_rota { Link Here
354
    return $self;
354
    return $self;
355
}
355
}
356
356
357
=head3 pending_hold
357
=head3 has_pending_hold
358
358
359
  my $is_pending_hold = $item->pending_hold();
359
  my $is_pending_hold = $item->has_pending_hold();
360
360
361
This method checks the tmp_holdsqueue to see if this item has been selected for a hold, but not filled yet and returns true or false
361
This method checks the tmp_holdsqueue to see if this item has been selected for a hold, but not filled yet and returns true or false
362
362
363
=cut
363
=cut
364
364
365
sub pending_hold {
365
sub has_pending_hold {
366
    my ( $self ) = @_;
366
    my ( $self ) = @_;
367
    my $pending_hold = $self->_result->tmp_holdsqueues;
367
    my $pending_hold = $self->_result->tmp_holdsqueues;
368
    return !C4::Context->preference('AllowItemsOnHoldCheckout') && $pending_hold->count ? 1: 0;
368
    return !C4::Context->preference('AllowItemsOnHoldCheckout') && $pending_hold->count ? 1: 0;
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc (-1 / +1 lines)
Lines 89-95 Link Here
89
    <span class="item-status onorder">On order</span>
89
    <span class="item-status onorder">On order</span>
90
[% END %]
90
[% END %]
91
91
92
[% IF item.pending_hold %]
92
[% IF item.has_pending_hold %]
93
    [% SET itemavailable = 0 %]
93
    [% SET itemavailable = 0 %]
94
    <span class="item-status pendinghold">Pending hold</span>
94
    <span class="item-status pendinghold">Pending hold</span>
95
[% END %]
95
[% END %]
(-)a/t/db_dependent/Items.t (-2 / +2 lines)
Lines 318-328 subtest 'GetItemsInfo tests' => sub { Link Here
318
    my $dbh = C4::Context->dbh;
318
    my $dbh = C4::Context->dbh;
319
    $dbh->do(q{INSERT INTO tmp_holdsqueue (biblionumber, itemnumber, surname, borrowernumber ) VALUES (?, ?, "Zorro", 42)}, undef, $item_bibnum, $itemnumber);
319
    $dbh->do(q{INSERT INTO tmp_holdsqueue (biblionumber, itemnumber, surname, borrowernumber ) VALUES (?, ?, "Zorro", 42)}, undef, $item_bibnum, $itemnumber);
320
    @results = GetItemsInfo( $biblio->biblionumber );
320
    @results = GetItemsInfo( $biblio->biblionumber );
321
    is( $results[0]->{ pending_hold }, "1",
321
    is( $results[0]->{ has_pending_hold }, "1",
322
        'Hold marked as pending/unavailable if not AllowItemsOnHoldCheckout' );
322
        'Hold marked as pending/unavailable if not AllowItemsOnHoldCheckout' );
323
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 1 );
323
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 1 );
324
    @results = GetItemsInfo( $biblio->biblionumber );
324
    @results = GetItemsInfo( $biblio->biblionumber );
325
    is( $results[0]->{ pending_hold }, undef,
325
    is( $results[0]->{ has_pending_hold }, undef,
326
        'Hold not marked as pending/unavailable if AllowItemsOnHoldCheckout' );
326
        'Hold not marked as pending/unavailable if AllowItemsOnHoldCheckout' );
327
327
328
328
(-)a/t/db_dependent/Koha/Item.t (-5 / +4 lines)
Lines 62-68 subtest 'hidden_in_opac() tests' => sub { Link Here
62
    $schema->storage->txn_rollback;
62
    $schema->storage->txn_rollback;
63
};
63
};
64
64
65
subtest 'pending_hold() tests' => sub {
65
subtest 'has_pending_hold() tests' => sub {
66
66
67
    plan tests => 3;
67
    plan tests => 3;
68
68
Lines 75-84 subtest 'pending_hold() tests' => sub { Link Here
75
    # disable AllowItemsOnHoldCheckout as it ignores pending holds
75
    # disable AllowItemsOnHoldCheckout as it ignores pending holds
76
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 0 );
76
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 0 );
77
    $dbh->do("INSERT INTO tmp_holdsqueue (surname,borrowernumber,itemnumber) VALUES ('Clamp',42,$itemnumber)");
77
    $dbh->do("INSERT INTO tmp_holdsqueue (surname,borrowernumber,itemnumber) VALUES ('Clamp',42,$itemnumber)");
78
    ok( $item->pending_hold, "Yes, we have a pending hold");
78
    ok( $item->has_pending_hold, "Yes, we have a pending hold");
79
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 1 );
79
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 1 );
80
    ok( !$item->pending_hold, "We don't consider a pending hold if hold items can be checked out");
80
    ok( !$item->has_pending_hold, "We don't consider a pending hold if hold items can be checked out");
81
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 0 );
81
    t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 0 );
82
    $dbh->do("DELETE FROM tmp_holdsqueue WHERE itemnumber=$itemnumber");
82
    $dbh->do("DELETE FROM tmp_holdsqueue WHERE itemnumber=$itemnumber");
83
    ok( !$item->pending_hold, "We don't have a pending hold if nothing in the tmp_holdsqueue");
83
    ok( !$item->has_pending_hold, "We don't have a pending hold if nothing in the tmp_holdsqueue");
84
};
84
};
85
- 

Return to bug 22899