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

(-)a/Koha/Item.pm (+21 lines)
Lines 44-49 use Koha::ItemTypes; Link Here
44
use Koha::Libraries;
44
use Koha::Libraries;
45
use Koha::Patrons;
45
use Koha::Patrons;
46
use Koha::Plugins;
46
use Koha::Plugins;
47
use Koha::Recalls;
47
use Koha::Result::Boolean;
48
use Koha::Result::Boolean;
48
use Koha::SearchEngine::Indexer;
49
use Koha::SearchEngine::Indexer;
49
use Koha::StockRotationItem;
50
use Koha::StockRotationItem;
Lines 925-930 sub has_pending_hold { Link Here
925
    return $pending_hold->count ? 1: 0;
926
    return $pending_hold->count ? 1: 0;
926
}
927
}
927
928
929
=head3 has_pending_recall {
930
931
  my $has_pending_recall
932
933
Return if whether has pending recall of not.
934
935
=cut
936
937
sub has_pending_recall {
938
    my ( $self ) = @_;
939
940
    # FIXME Must be moved to $self->recalls
941
    return Koha::Recalls->search(
942
        {
943
            item_id   => $self->itemnumber,
944
            status    => 'waiting',
945
        }
946
    )->count;
947
}
948
928
=head3 as_marc_field
949
=head3 as_marc_field
929
950
930
    my $field = $item->as_marc_field;
951
    my $field = $item->as_marc_field;
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status-schema-org.inc (-1 / +1 lines)
Lines 1-4 Link Here
1
[% IF ( item.damaged or item.datedue or item.itemlost or item.transfertwhen or item.waiting ) %]
1
[% IF ( item.damaged or item.checkout.date_due or item.itemlost or item.transfertwhen or item.waiting ) %]
2
    <link property="availability" href="http://schema.org/OutOfStock" />
2
    <link property="availability" href="http://schema.org/OutOfStock" />
3
[% ELSIF ( item.withdrawn ) %]
3
[% ELSIF ( item.withdrawn ) %]
4
    <link property="availability" href="http://schema.org/Discontinued" />
4
    <link property="availability" href="http://schema.org/Discontinued" />
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc (-4 / +5 lines)
Lines 18-25 Link Here
18
[% END %]
18
[% END %]
19
19
20
[% IF item.isa('Koha::Item') %]
20
[% IF item.isa('Koha::Item') %]
21
    [% SET datedue = issue.date_due %]
21
    [% SET datedue = item.checkout.date_due %]
22
    [% SET onsite_checkout = issue.onsite_checkout %]
22
    [% SET onsite_checkout = item.checkout.onsite_checkout %]
23
[% ELSE %]
23
[% ELSE %]
24
    [% SET datedue = item.datedue || issue.date_due %]
24
    [% SET datedue = item.datedue || issue.date_due %]
25
    [% SET onsite_checkout = item.onsite_checkout %]
25
    [% SET onsite_checkout = item.onsite_checkout %]
Lines 39-45 Link Here
39
            <span class="item-status checkedout">Checked out</span>
39
            <span class="item-status checkedout">Checked out</span>
40
        [% END %]
40
        [% END %]
41
    [% END %]
41
    [% END %]
42
    [% IF item.avail_for_recall %]<a href="/cgi-bin/koha/opac-recall.pl?biblionumber=[% item.biblionumber | uri %]" class="btn btn-default btn-xs">Recall</a>[% END %]
42
    [%# FIXME We should move avail_for_recall to a Koha::Item method %]
43
    [% IF !item.isa('Koha::Item') AND item.avail_for_recall %]<a href="/cgi-bin/koha/opac-recall.pl?biblionumber=[% item.biblionumber | uri %]" class="btn btn-default btn-xs">Recall</a>[% END %]
43
[% END %]
44
[% END %]
44
45
45
[% IF NOT ( item.isa('Koha::Item') ) AND item.transfertwhen %] [%# transfertwhen is set in C4::Search, do not have it for course reserves %]
46
[% IF NOT ( item.isa('Koha::Item') ) AND item.transfertwhen %] [%# transfertwhen is set in C4::Search, do not have it for course reserves %]
Lines 100-106 Link Here
100
    <span class="item-status pendinghold">Pending hold</span>
101
    <span class="item-status pendinghold">Pending hold</span>
101
[% END %]
102
[% END %]
102
103
103
[% IF item.has_pending_recall %]
104
[% IF Koha.Preference('UseRecalls') && item.has_pending_recall %]
104
    [% SET itemavailable = 0 %]
105
    [% SET itemavailable = 0 %]
105
    <span class="item-status pendingrecall">Pending recall</span>
106
    <span class="item-status pendingrecall">Pending recall</span>
106
[% END %]
107
[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt (-1 / +1 lines)
Lines 1342-1348 Link Here
1342
                    </td>
1342
                    </td>
1343
                [% END # /IF itemdata_uri %]
1343
                [% END # /IF itemdata_uri %]
1344
                [% IF ( itemdata_copynumber ) %]<td class="copynumber">[% ITEM_RESULT.copynumber | html %]</td>[% END %]
1344
                [% IF ( itemdata_copynumber ) %]<td class="copynumber">[% ITEM_RESULT.copynumber | html %]</td>[% END %]
1345
                <td class="status">[% INCLUDE 'item-status-schema-org.inc' item = ITEM_RESULT %][% INCLUDE 'item-status.inc' item = ITEM_RESULT %]</td>
1345
                <td class="status">[% INCLUDE 'item-status-schema-org.inc' item = ITEM_RESULT %][% INCLUDE 'item-status.inc' item = ITEM_RESULT.object %]</td>
1346
                [% IF ( itemdata_itemnotes ) %]<td class="notes" property="description">[% ITEM_RESULT.itemnotes | $raw %]</td>[% END %]
1346
                [% IF ( itemdata_itemnotes ) %]<td class="notes" property="description">[% ITEM_RESULT.itemnotes | $raw %]</td>[% END %]
1347
                [% IF ITEM_RESULT.checkout %]
1347
                [% IF ITEM_RESULT.checkout %]
1348
                    <td class="date_due" data-order="[% ITEM_RESULT.checkout.date_due | html %]">[% ITEM_RESULT.checkout.date_due | $KohaDates as_due_date => 1 %]</td>
1348
                    <td class="date_due" data-order="[% ITEM_RESULT.checkout.date_due | html %]">[% ITEM_RESULT.checkout.date_due | $KohaDates as_due_date => 1 %]</td>
(-)a/opac/opac-detail.pl (-11 / +1 lines)
Lines 79-85 use Koha::Virtualshelves; Link Here
79
use Koha::Patrons;
79
use Koha::Patrons;
80
use Koha::Plugins;
80
use Koha::Plugins;
81
use Koha::Ratings;
81
use Koha::Ratings;
82
use Koha::Recalls;
83
use Koha::Reviews;
82
use Koha::Reviews;
84
use Koha::Serial::Items;
83
use Koha::Serial::Items;
85
use Koha::SearchEngine::Search;
84
use Koha::SearchEngine::Search;
Lines 729-750 else { Link Here
729
        }
728
        }
730
729
731
        $item_info->{checkout} = $item->checkout;
730
        $item_info->{checkout} = $item->checkout;
731
        $item_info->{object} = $item;
732
732
733
        my $reserve_status =
733
        my $reserve_status =
734
          C4::Reserves::GetReserveStatus( $item->itemnumber );
734
          C4::Reserves::GetReserveStatus( $item->itemnumber );
735
        if ( $reserve_status eq "Waiting"  ) { $item_info->{'waiting'} = 1; }
735
        if ( $reserve_status eq "Waiting"  ) { $item_info->{'waiting'} = 1; }
736
        if ( $reserve_status eq "Reserved" ) { $item_info->{'onhold'}  = 1; }
736
        if ( $reserve_status eq "Reserved" ) { $item_info->{'onhold'}  = 1; }
737
737
738
        if ( C4::Context->preference('UseRecalls') ) {
739
            my $pending_recall_count = Koha::Recalls->search(
740
                {
741
                    item_id   => $item->itemnumber,
742
                    status    => 'waiting',
743
                }
744
            )->count;
745
            if ( $pending_recall_count ) { $item_info->has_pending_recall = 1; }
746
        }
747
748
        my ( $transfertwhen, $transfertfrom, $transfertto ) =
738
        my ( $transfertwhen, $transfertfrom, $transfertto ) =
749
          GetTransfers( $item->itemnumber );
739
          GetTransfers( $item->itemnumber );
750
        if ( defined($transfertwhen) && $transfertwhen ne '' ) {
740
        if ( defined($transfertwhen) && $transfertwhen ne '' ) {
(-)a/t/db_dependent/Koha/Item.t (-2 / +4 lines)
Lines 1483-1489 subtest 'store() tests' => sub { Link Here
1483
1483
1484
subtest 'Recalls tests' => sub {
1484
subtest 'Recalls tests' => sub {
1485
1485
1486
    plan tests => 20;
1486
    plan tests => 22;
1487
1487
1488
    $schema->storage->txn_begin;
1488
    $schema->storage->txn_begin;
1489
1489
Lines 1654-1659 subtest 'Recalls tests' => sub { Link Here
1654
        }
1654
        }
1655
    )->store;
1655
    )->store;
1656
    $recall2->set_waiting( { item => $item1 } );
1656
    $recall2->set_waiting( { item => $item1 } );
1657
    is( $item1->has_pending_recall, 1, 'Item has pending recall' );
1657
1658
1658
    # return a waiting recall
1659
    # return a waiting recall
1659
    my $check_recall = $item1->check_recalls;
1660
    my $check_recall = $item1->check_recalls;
Lines 1661-1666 subtest 'Recalls tests' => sub { Link Here
1661
1662
1662
    $recall2->revert_waiting;
1663
    $recall2->revert_waiting;
1663
1664
1665
    is( $item1->has_pending_recall, 0, 'Item does not have pending recall' );
1666
1664
    # return recall based on recalldate
1667
    # return recall based on recalldate
1665
    $check_recall = $item1->check_recalls;
1668
    $check_recall = $item1->check_recalls;
1666
    is( $check_recall->patron_id, $patron1->borrowernumber, "No waiting recall, so oldest recall is returned" );
1669
    is( $check_recall->patron_id, $patron1->borrowernumber, "No waiting recall, so oldest recall is returned" );
1667
- 

Return to bug 27272