Bugzilla – Attachment 142416 Details for
Bug 24860
Add ability to place item group level holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24860: Add ability to select an item group when placing a hold
Bug-24860-Add-ability-to-select-an-item-group-when.patch (text/plain), 15.52 KB, created by
Kyle M Hall (khall)
on 2022-10-21 16:04:09 UTC
(
hide
)
Description:
Bug 24860: Add ability to select an item group when placing a hold
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2022-10-21 16:04:09 UTC
Size:
15.52 KB
patch
obsolete
>From 473a04ab5d93749aead7aa25926abbefcd85634a Mon Sep 17 00:00:00 2001 >From: Kyle Hall <kyle@bywatersolutions.com> >Date: Fri, 3 Jun 2022 06:33:25 -0400 >Subject: [PATCH] Bug 24860: Add ability to select an item group when placing a > hold > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> > >Signed-off-by: Rebecca Coert <rcoert@arlingtonva.us> >--- > C4/Reserves.pm | 1 + > Koha/Hold.pm | 14 ++++ > Koha/Holds.pm | 3 + > .../prog/en/includes/holds_table.inc | 2 + > .../prog/en/modules/reserve/request.tt | 80 ++++++++++++++++++- > reserve/placerequest.pl | 2 + > reserve/request.pl | 4 + > t/db_dependent/Koha/Holds.t | 27 +++++++ > 8 files changed, 129 insertions(+), 4 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index c70a069efe..a94d66d2a8 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -162,6 +162,7 @@ BEGIN { > itemnumber => $itemnumber, > found => $found, > itemtype => $itemtype, >+ item_gorup_id => $item_group_id > } > ); > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index 378b902638..ee98a6cc49 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -525,6 +525,20 @@ sub item { > return $self->{_item}; > } > >+=head3 item_group >+ >+Returns the related Koha::Biblio::ItemGroup object for this Hold >+ >+=cut >+ >+sub item_group { >+ my ($self) = @_; >+ >+ my $item_group_rs = $self->_result->item_group; >+ return unless $item_group_rs; >+ return Koha::Biblio::ItemGroup->_new_from_dbic($item_group_rs); >+} >+ > =head3 branch > > Returns the related Koha::Library object for this Hold >diff --git a/Koha/Holds.pm b/Koha/Holds.pm >index c5bfc55df3..a4de91c813 100644 >--- a/Koha/Holds.pm >+++ b/Koha/Holds.pm >@@ -85,6 +85,9 @@ sub forced_hold_level { > my $item_level_count = $self->search( { itemnumber => { '!=' => undef } } )->count(); > return 'item' if $item_level_count > 0; > >+ my $item_group_level_count = $self->search( { item_group_id => { '!=' => undef } } )->count(); >+ return 'item_group' if $item_group_level_count > 0; >+ > my $record_level_count = $self->search( { itemnumber => undef } )->count(); > return 'record' if $record_level_count > 0; > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >index 536bd16484..940e3040ca 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >@@ -179,6 +179,8 @@ > [%- ELSE -%] > [%- IF hold.itemtype -%] > <em>Next available [% ItemTypes.GetDescription( hold.itemtype ) | html %] item</em> >+ [%- ELSIF hold.object.item_group -%] >+ <em>Next available item from group <strong>[% hold.object.item_group.description | html %]</strong></em> > [%- ELSE -%] > <em>Next available</em> > [%- END -%] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index d9801f2ae0..0ca02b0a14 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -599,7 +599,7 @@ > [% UNLESS ( multi_hold ) %] > <li> > <label for="requestany">Hold next available item </label> >- [% IF force_hold_level == 'item' %] >+ [% IF force_hold_level == 'item' || force_hold_level == 'item_group' %] > <input type="checkbox" id="requestany" name="request" disabled="true" /> > [% ELSIF force_hold_level == 'record' %] > <input type="checkbox" id="requestany" checked="checked" value="Any" disabled="true"/> >@@ -658,6 +658,52 @@ > [% END %] > </ol> > >+ <!-- ItemGroup level holds --> >+ [% IF Koha.Preference('EnableItemGroupHolds') && biblio.object.item_groups.count %] >+ <h2 style="padding: 0 1em;"> >+ Hold next available item from an item group >+ [% IF force_hold_level == 'item_group' %] >+ <span class="error"><i>(Required)</i></span> >+ [% END %] >+ </h2> >+ >+ [% IF force_hold_level == 'record' # Patron has placed a record level hold previously for this record %] >+ <span class="error"> >+ <i class="fa fa-times fa-lg" title="Cannot be put on hold"></i> >+ Hold must be record level >+ </span> >+ [% ELSIF force_hold_level == 'item' # Patron has placed an item level hold previously for this record %] >+ <span class="error"> >+ <i class="fa fa-times fa-lg" title="Cannot be put on hold"></i> >+ Hold must be item level >+ </span> >+ [% ELSE %] >+ <table> >+ <thead> >+ <tr> >+ <th>Hold</th> >+ <th>Item group</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH g IN biblio.object.item_groups.search({}, { order_by => ['display_order'] }) %] >+ [% IF g.items %] >+ <tr> >+ <td> >+ <input id="item_group_id_[% g.id | html %]" type="radio" name="item_group_id" value="[% g.id | html %]" /> >+ </td> >+ <td> >+ <label for="item_group_id_[% g.id | html %]">[% g.description | html %]</label> >+ </td> >+ </tr> >+ [% END %] >+ [% END %] >+ </tbody> >+ </table> >+ [% END %] >+ [% END %] >+ <!-- /ItemGroup level holds --> >+ > <h2 style="padding: 0 1em;"> > Place a hold on a specific item > [% IF force_hold_level == 'item' %] >@@ -674,6 +720,9 @@ > <th>Item type</th> > [% END %] > <th>Barcode</th> >+ [% IF Koha.Preference('EnableItemGroupHolds') && biblio.object.item_groups.count %] >+ <th>Item group</th> >+ [% END %] > <th>Home library</th> > <th>Last location</th> > [% IF itemdata_ccode %] >@@ -698,6 +747,11 @@ > <i class="fa fa-times fa-lg" title="Cannot be put on hold"></i> > Hold must be record level > </span> >+ [% ELSIF force_hold_level == 'item_group' %] >+ <span class="error"> >+ <i class="fa fa-times fa-lg" title="Cannot be put on hold"></i> >+ Hold must be item group level >+ </span> > [% ELSIF ( itemloo.available ) %] > <input type="radio" name="checkitem" value="[% itemloo.itemnumber | html %]" /> > [% ELSIF ( itemloo.override ) %] >@@ -767,6 +821,11 @@ > <td> > [% itemloo.barcode | html %] > </td> >+ [% IF Koha.Preference('EnableItemGroupHolds') && biblio.object.item_groups.count %] >+ <td> >+ [% itemloo.object.item_group.description | html %] >+ </td> >+ [% END %] > <td> > [% Branches.GetName( itemloo.homebranch ) | html %] > </td> >@@ -1339,6 +1398,8 @@ > }; > if($('input[name="checkitem"]:checked').length) > data.item_id = $('input[name="checkitem"]:checked').val(); >+ if($('input[name="item_group_id"]:checked').length) >+ data.item_group_id = $('input[name="item_group_id"]:checked').val(); > if($('input[name="borrowernumber"]').length) > data.patron_id = $('input[name="borrowernumber"]').val(); > if($('textarea[name="notes"]').length) >@@ -1384,8 +1445,8 @@ > }); > > [% UNLESS ( multi_hold ) %] >- $("#hold-request-form").on("submit", function(){ >- return check($(this)); >+ $("#hold-request-form").on("submit", function(e){ >+ return check(e, $(this)); > }); > [% ELSE %] > $("#hold-request-form").on("submit", function(){ >@@ -1429,7 +1490,7 @@ > }); > }); > >- function check( table ) { >+ function check( e, table ) { > > var msg = ""; > >@@ -1460,6 +1521,7 @@ > $('#hold-request-form').preventDoubleFormSubmit(); > return(true); > } else { >+ e.preventDefault(); > alert(msg); > return(false); > } >@@ -1613,6 +1675,16 @@ > stickyClass: "floating" > }); > >+ [% IF Koha.Preference('EnableItemGroupHolds') %] >+ $(':radio[name="item_group_id"]').change(function(){ >+ $(':radio[name="checkitem"]').prop('checked', false); >+ }); >+ >+ $(':radio[name="checkitem"]').change(function(){ >+ $(':radio[name="item_group_id"]').prop('checked', false); >+ }); >+ [% END %] >+ > if(!localStorage.selectedHolds || document.referrer.replace(/\?.*/, '') !== document.location.origin+document.location.pathname) { > localStorage.selectedHolds = []; > } >diff --git a/reserve/placerequest.pl b/reserve/placerequest.pl >index 0fc7361b73..a253fb5547 100755 >--- a/reserve/placerequest.pl >+++ b/reserve/placerequest.pl >@@ -45,6 +45,7 @@ my $startdate = $input->param('reserve_date') || ''; > my @rank = $input->multi_param('rank-request'); > my $title = $input->param('title'); > my $checkitem = $input->param('checkitem'); >+my $item_group_id = $input->param('item_group_id'); > my $expirationdate = $input->param('expiration_date'); > my $itemtype = $input->param('itemtype') || undef; > my $non_priority = $input->param('non_priority'); >@@ -140,6 +141,7 @@ if ( $patron ) { > found => $found, > itemtype => $itemtype, > non_priority => $non_priority, >+ item_group_id => $item_group_id, > } > ); > } >diff --git a/reserve/request.pl b/reserve/request.pl >index 2c28f2c58f..e5faf1426a 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -299,12 +299,15 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) > my %biblioloopiter = (); > > my $biblio = Koha::Biblios->find( $biblionumber ); >+ > unless ($biblio) { > $biblioloopiter{noitems} = 1; > $template->param('nobiblio' => 1); > last; > } > >+ $biblioloopiter{object} = $biblio; >+ > if ( $patron ) { > { # CanBookBeReserved > my $canReserve = CanBookBeReserved( $patron->borrowernumber, $biblionumber ); >@@ -397,6 +400,7 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) > for my $item_object ( @items ) { > my $do_check; > my $item = $item_object->unblessed; >+ $item->{object} = $item_object; > if ( $patron ) { > $do_check = $patron->do_check_for_previous_checkout($item) if $wants_check; > if ( $do_check && $wants_check ) { >diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t >index aec261dd1f..1ab51b1ade 100755 >--- a/t/db_dependent/Koha/Holds.t >+++ b/t/db_dependent/Koha/Holds.t >@@ -25,6 +25,7 @@ use Test::Warn; > use C4::Circulation qw( AddIssue ); > use C4::Reserves qw( AddReserve ModReserve ModReserveCancelAll ); > use Koha::AuthorisedValueCategory; >+use Koha::Biblio::ItemGroups; > use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); > use Koha::Holds; >@@ -641,6 +642,32 @@ subtest 'set_waiting+patron_expiration_date' => sub { > }; > }; > >+subtest 'Test Koha::Hold::item_group' => sub { >+ plan tests => 1; >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $item = $builder->build_sample_item; >+ my $item_group = $builder->build_object( >+ { >+ class => 'Koha::Biblio::ItemGroups', >+ value => { biblionumber => $item->biblionumber } >+ } >+ ); >+ my $reserve_id = AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $item->biblionumber, >+ itemnumber => $item->itemnumber, >+ item_group_id => $item_group->id, >+ } >+ ); >+ >+ my $hold = Koha::Holds->find($reserve_id); >+ is( $hold->item_group_id, $item_group->id, >+ 'Koha::Hold::item_group returns the correct item_group' ); >+}; >+ > > $schema->storage->txn_rollback; > >-- >2.30.2
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 24860
:
100644
|
100645
|
100646
|
100647
|
100648
|
100649
|
100650
|
100651
|
101744
|
101745
|
101746
|
101747
|
101748
|
101749
|
101750
|
101751
|
101827
|
101828
|
101829
|
101830
|
101831
|
101832
|
101833
|
101834
|
101835
|
102230
|
102231
|
102232
|
102233
|
102234
|
102235
|
102236
|
102237
|
102238
|
102239
|
102240
|
102241
|
102242
|
102243
|
102244
|
102245
|
102246
|
102247
|
106589
|
106590
|
106591
|
106592
|
106593
|
106594
|
106595
|
106596
|
106597
|
106682
|
106683
|
106684
|
106685
|
106686
|
106687
|
106688
|
106689
|
106690
|
106742
|
106743
|
106744
|
106745
|
106746
|
106747
|
106748
|
106749
|
106750
|
108458
|
108459
|
108460
|
108461
|
108462
|
108463
|
108464
|
108465
|
108466
|
109097
|
109098
|
109099
|
109100
|
109101
|
109102
|
109103
|
109104
|
109105
|
109171
|
109172
|
109173
|
109174
|
109175
|
109176
|
109177
|
109178
|
109179
|
113616
|
113617
|
113618
|
113619
|
113620
|
113621
|
113622
|
113623
|
113624
|
135922
|
135923
|
135924
|
135925
|
135926
|
135927
|
135928
|
135929
|
135930
|
138221
|
138222
|
138224
|
138225
|
138226
|
138227
|
138228
|
138229
|
138230
|
141214
|
141215
|
141735
|
141736
|
141737
|
141738
|
141739
|
141740
|
141741
|
141742
|
141743
|
141744
|
141745
|
141746
|
141747
|
141748
|
141749
|
141750
|
142413
|
142414
|
142415
|
142416
|
142417
|
142418
|
142419
|
142420
|
142421
|
142422
|
142423
|
142424
|
142425
|
142426
|
142427
|
142428
|
142429
|
142430
|
142827
|
142955
|
142956
|
142957
|
142958
|
142959
|
142960
|
142961
|
142962
|
142963
|
142964
|
142965
|
142966
|
142967
|
142968
|
142969
|
142970
|
142971
|
142972
|
142973
|
142974
|
142975
|
142992
|
142993
|
142994
|
142995
|
142996
|
142997
|
142998
|
142999
|
143000
|
143001
|
143002
|
143003
|
143004
|
143005
|
143006
|
143007
|
143008
|
143009
|
143010
|
143011