From 2a6af1a6bd4dcddb7aab823833b60b1ef44c0463 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 14 Sep 2021 19:29:27 +0000 Subject: [PATCH] Bug 29015: Add options for itemtype, collection, and shelving location to view_holdsqueue.pl This patch makes the code for itemtypeslimit work, and adds options for shelving location and collection code This also remove the 'post' method from the form to allow easy bookmarking To test: 1 - Add holds to your system 2 - Run the holds queue builder 3 - Browse to Circulation->Holds queue 4 - Note the library dropdown 5 - Apply patch 6 - Reload and note new options 7 - Test that both limits and 'All' options work as expected 8 - Note that description at top includes options when selected "### items found for All libraries and item type:(Books)" Signed-off-by: Owen Leonard Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- C4/HoldsQueue.pm | 23 ++++++++++++---- circ/view_holdsqueue.pl | 13 ++++++++-- .../prog/en/includes/html_helpers.inc | 10 +++++++ .../prog/en/modules/circ/view_holdsqueue.tt | 26 ++++++++++++++++++- 4 files changed, 64 insertions(+), 8 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index b4d2b026f2..b8abe21496 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -114,14 +114,14 @@ sub UpdateTransportCostMatrix { =head2 GetHoldsQueueItems - GetHoldsQueueItems($branch); + GetHoldsQueueItems({ branchlimit => $branch, itemtypeslimit => $itype, ccodeslimit => $ccode, locationslimit => $location ); Returns hold queue for a holding branch. If branch is omitted, then whole queue is returned =cut sub GetHoldsQueueItems { - my ($branchlimit) = @_; + my $params = shift; my $dbh = C4::Context->dbh; my @bind_params = (); @@ -135,10 +135,23 @@ sub GetHoldsQueueItems { JOIN biblio USING (biblionumber) LEFT JOIN biblioitems USING (biblionumber) LEFT JOIN items USING ( itemnumber) + WHERE 1=1 /; - if ($branchlimit) { - $query .=" WHERE tmp_holdsqueue.holdingbranch = ?"; - push @bind_params, $branchlimit; + if ($params->{branchlimit}) { + $query .="AND tmp_holdsqueue.holdingbranch = ? "; + push @bind_params, $params->{branchlimit}; + } + if( $params->{itemtypeslimit} ) { + $query .=" AND items.itype = ? "; + push @bind_params, $params->{itemtypeslimit}; + } + if( $params->{ccodeslimit} ) { + $query .=" AND items.ccode = ? "; + push @bind_params, $params->{ccodeslimit}; + } + if( $params->{locationslimit} ) { + $query .=" AND items.location = ? "; + push @bind_params, $params->{locationslimit}; } $query .= " ORDER BY ccode, location, cn_sort, author, title, pickbranch, reservedate"; my $sth = $dbh->prepare($query); diff --git a/circ/view_holdsqueue.pl b/circ/view_holdsqueue.pl index 81b900ba2a..b7070fd7a1 100755 --- a/circ/view_holdsqueue.pl +++ b/circ/view_holdsqueue.pl @@ -44,15 +44,24 @@ my $params = $query->Vars; my $run_report = $params->{'run_report'}; my $branchlimit = $params->{'branchlimit'}; my $itemtypeslimit = $params->{'itemtypeslimit'}; +my $ccodeslimit = $params->{'ccodeslimit'}; +my $locationslimit = $params->{'locationslimit'}; if ( $run_report ) { - # XXX GetHoldsQueueItems() does not support $itemtypeslimit! - my $items = GetHoldsQueueItems($branchlimit, $itemtypeslimit); + my $items = GetHoldsQueueItems({ + branchlimit => $branchlimit, + itemtypeslimit => $itemtypeslimit, + ccodeslimit => $ccodeslimit, + locationslimit => $locationslimit + }); for my $item ( @$items ) { $item->{patron} = Koha::Patrons->find( $item->{borrowernumber} ); } $template->param( branchlimit => $branchlimit, + itemtypeslimit => $itemtypeslimit, + ccodeslimit => $ccodeslimit, + locationslimit => $locationslimit, total => scalar @$items, itemsloop => $items, run_report => $run_report, diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc index 26e1f348a3..8f148947b4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc @@ -47,6 +47,16 @@ [% END %] [% END %] +[% BLOCK options_for_authorised_values %] + [% FOREACH av IN authorised_values %] + [% IF av.authorised_value == selected_av %] + + [% ELSE %] + + [% END %] + [% END %] +[% END %] + [% BLOCK options_for_item_types %] [% FOREACH itemtype IN itemtypes %] [% IF itemtype.itemtype == selected_itemtype %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt index 564ab5f54f..6c9e5ffea1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt @@ -65,6 +65,9 @@ [% IF ( total ) %]
[% total | html %] items found for [% IF ( branchlimit ) %][% Branches.GetName( branchlimit ) | html %][% ELSE %]All libraries[% END %] + [% IF ( itemtypeslimit ) %] and item type:([% ItemTypes.GetDescription( itemtypeslimit ) | html %])[% END %] + [% IF ( ccodeslimit ) %] and collection code:([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode' authorised_value = ccodeslimit ) | html %])[% END %] + [% IF ( locationslimit ) %] and shelving location:([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location' authorised_value = locationslimit ) | html %])[% END %]
[% ELSE %]
No items found.
@@ -200,7 +203,7 @@ [% END %] [% UNLESS ( total ) %] -
+
  1. @@ -210,6 +213,27 @@ [% PROCESS options_for_libraries libraries => Branches.all( only_from_group => 1 ) %]
  2. +
  3. + + +
  4. +
  5. + + +
  6. +
  7. + + +
-- 2.39.5