Bugzilla – Attachment 77223 Details for
Bug 20469
Add item status to staff article requests form
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20469: Add item status to staff article request form
Bug-20469-Add-item-status-to-staff-article-request.patch (text/plain), 5.11 KB, created by
Marcel de Rooy
on 2018-07-24 14:49:42 UTC
(
hide
)
Description:
Bug 20469: Add item status to staff article request form
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-07-24 14:49:42 UTC
Size:
5.11 KB
patch
obsolete
>From 9b88dca690d09ab6517fec9970613fbb1e48cade Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 26 Mar 2018 13:20:53 +0200 >Subject: [PATCH] Bug 20469: Add item status to staff article request form >Content-Type: text/plain; charset=utf-8 > >A method Koha::Item->has_waiting_or_transit_hold is added (with tests). >The template checks if an item is checked out, on hold (waiting or >transit), or is available. (Note: This can be extended in the future >in a general include as we have at opac side.) > >Test plan: >[1] Run t/db_dependent/Koha/Items.t >[2] Place an article request on an item on loan. Verify status on form. >[3] Place an article request on a waiting item. Check status again. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >EDIT (July 24, 2018): >Method renamed to has_waiting_or_transit_hold. Part of the logic moved to >Koha::Holds (see first patch now). Replaced storing undef to found by >deleting hold in corresponding subtest of Items.t. >Added an additional check in the template for article requests on record >level that have no itemnumber (in that case no item status). > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > 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(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 964359e..fa3507f 100644 >--- a/Koha/Item.pm >+++ b/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 >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt >index 8a2a073..610c98e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt >@@ -42,6 +42,13 @@ > </ul> > </div> > [% 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 %] > > <body id="circ_article-requests" class="circ"> > [% INCLUDE 'header.inc' %] >@@ -176,6 +183,7 @@ > [% END %] > > [% ar.item.itemcallnumber %] >+ <p>[% PROCESS 'item_status' myitem = ar.item %]</p> > </td> > <td class="ar-copynumber">[% ar.item.copynumber %]</td> > <td class="ar-enumchron">[% ar.item.enumchron %]</td> >@@ -284,6 +292,7 @@ > [% END %] > > [% ar.item.itemcallnumber %] >+ <p>[% PROCESS 'item_status' myitem = ar.item %]</p> > </td> > <td class="ar-copynumber">[% ar.item.copynumber %]</td> > <td class="ar-enumchron">[% ar.item.enumchron %]</td> >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index 87ebfb3..8b6be7b 100644 >--- a/t/db_dependent/Koha/Items.t >+++ b/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; > >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20469
:
73281
|
73282
|
73388
|
76627
|
76628
|
76630
|
76631
|
77184
|
77185
|
77186
|
77222
|
77223
|
77224
|
107235
|
107236
|
107412
|
107413
|
107417
|
107418
|
107419
|
108345
|
108346
|
108347