From 2a310268d98fa4c02e6d25467fd0a26b51a416bb Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 27 Feb 2019 15:31:29 +0000 Subject: [PATCH] Bug 22424: Add search by all lost statuses to item search This patch changes the item search form so that searching by lost status includes options for all lost authorised values instead of just "yes" or "no." To test you should have multiple authorized values for LOST. - Apply the patch and open the item search form. - Test searches which limit by lost status. Confirm that results are correctly limited. - Confirm that lost statuses are correctly displayed in the search results. - Confirm that in the search results table, the column header for "Lost" includes a dropdown menu for filtering by all available authorized values for lost. - Test the CSV export function and confirm that lost status is correctly exported. --- catalogue/itemsearch.pl | 24 +++++++++++++++++++--- .../en/includes/catalogue/itemsearch_item.csv.inc | 3 ++- .../en/includes/catalogue/itemsearch_item.json.inc | 1 + .../includes/csv_headers/catalogue/itemsearch.tt | 2 +- .../prog/en/modules/catalogue/itemsearch.tt | 13 ++++++++++-- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl index ed6abc9..36e22b6 100755 --- a/catalogue/itemsearch.pl +++ b/catalogue/itemsearch.pl @@ -63,7 +63,7 @@ if (defined $format and $format eq 'json') { push @f, $columns[$i]; push @c, 'and'; - if ( grep /^$columns[$i]$/, qw( ccode homebranch holdingbranch location itype notforloan ) ) { + if ( grep /^$columns[$i]$/, qw( ccode homebranch holdingbranch location itype notforloan itemlost ) ) { push @q, "$word"; push @op, '='; } else { @@ -103,6 +103,9 @@ my $notforloan_values = $mss->count ? GetAuthorisedValues($mss->next->authorised $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.location', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] }); my $location_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_value) : []; +$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.itemlost', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] }); +my $itemlost_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_value) : []; + if (scalar keys %params > 0) { # Parameters given, it's a search @@ -111,7 +114,7 @@ if (scalar keys %params > 0) { filters => [], }; - foreach my $p (qw(homebranch holdingbranch location itype ccode issues datelastborrowed notforloan)) { + foreach my $p (qw(homebranch holdingbranch location itype ccode issues datelastborrowed notforloan itemlost)) { if (my @q = $cgi->multi_param($p)) { if ($q[0] ne '') { my $f = { @@ -164,7 +167,7 @@ if (scalar keys %params > 0) { push @{ $filter->{filters} }, $f; # Yes/No parameters - foreach my $p (qw(damaged itemlost)) { + foreach my $p (qw( damaged )) { my $v = $cgi->param($p) // ''; my $f = { field => $p, @@ -232,6 +235,12 @@ if (scalar keys %params > 0) { $location_map->{$loc_value->{authorised_value}} = $loc_value->{lib}; } + # Get itemlost labels + my $itemlost_map = {}; + foreach my $il_value (@$itemlost_values) { + $itemlost_map->{$il_value->{authorised_value}} = $il_value->{lib}; + } + foreach my $item (@$results) { my $biblio = Koha::Biblios->find( $item->{biblionumber} ); $item->{biblio} = $biblio; @@ -304,6 +313,14 @@ foreach my $value (@$notforloan_values) { }; } +my @itemlosts; +foreach my $value (@$itemlost_values) { + push @itemlosts, { + value => $value->{authorised_value}, + label => $value->{lib}, + }; +} + my @items_search_fields = GetItemSearchFields(); my $authorised_values = {}; @@ -319,6 +336,7 @@ $template->param( itemtypes => \@itemtypes, ccodes => \@ccodes, notforloans => \@notforloans, + itemlosts => \@itemlosts, items_search_fields => \@items_search_fields, authorised_values_json => to_json($authorised_values), ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc index 93379a9..965a497 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc @@ -1,6 +1,7 @@ [%- USE Branches -%] [%- USE Koha -%] [%- USE ItemTypes -%] +[% USE AuthorisedValues %] [%- SET biblio = item.biblio -%] [%- SET biblioitem = item.biblioitem -%] -"[% biblio.title | html %] [% IF ( Koha.Preference( 'marcflavour' ) == 'UNIMARC' && biblio.author ) %]by [% END %][% biblio.author | html %]", "[% (biblioitem.publicationyear || biblio.copyrightdate) | html %]", "[% biblioitem.publishercode | html %]", "[% biblioitem.collectiontitle | html %]", "[% item.barcode | html %]", "[% item.itemcallnumber | html %]", "[% Branches.GetName(item.homebranch) | html %]", "[% Branches.GetName(item.holdingbranch) | html %]", "[% item.location | html %]", "[% ItemTypes.GetDescription(item.itype) | html %]", "[% item.stocknumber | html %]", "[% item.status | html %]", "[% (item.issues || 0) | html %]" +"[% biblio.title | html %] [% IF ( Koha.Preference( 'marcflavour' ) == 'UNIMARC' && biblio.author ) %]by [% END %][% biblio.author | html %]", "[% (biblioitem.publicationyear || biblio.copyrightdate) | html %]", "[% biblioitem.publishercode | html %]", "[% AuthorisedValues.GetByCode( 'CCODE', item.ccode ) | html %]", "[% item.barcode | html %]", "[% item.itemcallnumber | html %]", "[% Branches.GetName(item.homebranch) | html %]", "[% Branches.GetName(item.holdingbranch) | html %]", "[% item.location | html %]", "[% ItemTypes.GetDescription(item.itype) | html %]", "[% item.stocknumber | html %]", "[% item.status | html %]","[% AuthorisedValues.GetByCode( 'LOST', item.itemlost ) | html %]", "[% (item.issues || 0) | html %]" diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc index 0207f6b..98d0d20 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.json.inc @@ -21,6 +21,7 @@ "[% ItemTypes.GetDescription(item.itype) | html %]", "[% item.stocknumber | html %]", "[% item.status | html %]", + "[% AuthorisedValues.GetByCode( 'LOST', item.itemlost ) | html %]", "[% (item.issues || 0) | html %]", "[% FILTER escape_quotes ~%]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt index 8659836..4e61e6e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt @@ -1 +1 @@ -[%- BLOCK -%]Title, Publication date, Publisher, Collection, Barcode, Call number, Home library, Current location, Shelving location, Itemtype, Inventory number, Status, Checkouts[%- END -%] +[%- BLOCK -%]Title, Publication date, Publisher, Collection, Barcode, Call number, Home library, Current location, Shelving location, Itemtype, Inventory number, Status, Lost, Checkouts[%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt index a3309fe..1ad7838 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt @@ -155,6 +155,9 @@ [% IF notforloans.size %] [% INCLUDE form_field_select name="notforloan" options = notforloans empty_option = "All statuses" %] [% END %] + [% IF itemlosts.size %] + [% INCLUDE form_field_select name="itemlost" options = itemlosts empty_option = "All statuses" %] + [% END %]
[% INCLUDE form_field_select_text %] @@ -174,7 +177,6 @@ (inclusive) [% INCLUDE form_field_radio_yes_no name="damaged" %] - [% INCLUDE form_field_radio_yes_no name="itemlost" %]