@@ -, +, @@
---
Koha/Item.pm | 12 ++++++++++++
.../prog/en/modules/circ/article-requests.tt | 9 +++++++++
t/db_dependent/Koha/Items.t | 19 +++++++++++++++++--
3 files changed, 38 insertions(+), 2 deletions(-)
--- a/Koha/Item.pm
+++ a/Koha/Item.pm
@@ -282,6 +282,18 @@ sub current_holds {
return Koha::Holds->_new_from_dbic($hold_rs);
}
+=head3 has_waiting_or_transit_hold
+
+ Returns true if an item has a waiting or transit hold
+
+=cut
+
+sub has_waiting_or_transit_hold {
+ my ( $self ) = @_;
+ my $rs = $self->_result->reserves;
+ return Koha::Holds->_new_from_dbic($rs)->waiting_or_transit->count;
+}
+
=head3 type
=cut
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt
@@ -42,6 +42,13 @@
[% END %]
+[% BLOCK item_status %][%# pass Koha::Item into myitem %]
+ [% IF !myitem # Note: article request may have no item %]
+ [% ELSIF myitem.onloan %]Checked out
+ [% ELSIF myitem.has_waiting_or_transit_hold %]On hold
+ [% ELSE %]Available
+ [% END %]
+[% END %]
[% INCLUDE 'header.inc' %]
@@ -176,6 +183,7 @@
[% END %]
[% ar.item.itemcallnumber %]
+ [% PROCESS 'item_status' myitem = ar.item %]
[% ar.item.copynumber %] |
[% ar.item.enumchron %] |
@@ -284,6 +292,7 @@
[% END %]
[% ar.item.itemcallnumber %]
+ [% PROCESS 'item_status' myitem = ar.item %]
[% ar.item.copynumber %] |
[% ar.item.enumchron %] |
--- a/t/db_dependent/Koha/Items.t
+++ a/t/db_dependent/Koha/Items.t
@@ -19,7 +19,7 @@
use Modern::Perl;
-use Test::More tests => 9;
+use Test::More tests => 10;
use Test::Exception;
use C4::Circulation;
@@ -34,7 +34,7 @@ use t::lib::Mocks;
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
-my $builder = t::lib::TestBuilder->new;
+our $builder = t::lib::TestBuilder->new;
my $biblioitem = $builder->build( { source => 'Biblioitem' } );
my $library = $builder->build( { source => 'Branch' } );
my $nb_of_items = Koha::Items->search->count;
@@ -164,5 +164,20 @@ subtest 'can_be_transferred' => sub {
$retrieved_item_1->delete;
is( Koha::Items->search->count, $nb_of_items + 1, 'Delete should have deleted the item' );
+subtest 'has_waiting_or_transit_hold' => sub {
+ plan tests => 3;
+
+ my $hold = $builder->build_object({ class => 'Koha::Holds', value => { found => 'W' } });
+ my $itemnumber = $hold->itemnumber;
+ is( Koha::Items->find($itemnumber)->has_waiting_or_transit_hold, 1,
+ 'Item is waiting' );
+ $hold->found('T')->store;
+ is( Koha::Items->find($itemnumber)->has_waiting_or_transit_hold, 1,
+ 'Item has transit hold' );
+ $hold->delete;
+ is( Koha::Items->find($itemnumber)->has_waiting_or_transit_hold, 0,
+ 'Item should be available' );
+};
+
$schema->storage->txn_rollback;
--