From 37174e93ba00194efbbdf83bdc01add7874d0846 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Fri, 13 Oct 2023 21:01:58 +0000 Subject: [PATCH] Bug 26468: Add damaged as a searchable status in item search This patch removes the Damaged radio box options ( Ignore, yes, no ) in favor a full damage status search option To test: 1. APPLY PATCH, restart services. 2. Make sure you mark some items as damaged. 3. Go to the item and search and limit by 'Damaged' 4. You should only see your 'Damaged' items. 5. Export the results as a CSV, make sure the CSV is well-formed and accurate. --- catalogue/itemsearch.pl | 16 ++++++++++++++-- .../includes/catalogue/itemsearch_item.csv.inc | 2 ++ .../includes/catalogue/itemsearch_item.json.inc | 1 + .../includes/csv_headers/catalogue/itemsearch.tt | 2 +- .../prog/en/modules/catalogue/itemsearch.tt | 13 +++++++++++-- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl index fad7d1a8aee..9d22dcad8d9 100755 --- a/catalogue/itemsearch.pl +++ b/catalogue/itemsearch.pl @@ -108,6 +108,9 @@ my $itemlost_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_v $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.withdrawn', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] }); my $withdrawn_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_value) : []; +$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.damaged', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] }); +my $damaged_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_value) : []; + if ( Koha::MarcSubfieldStructures->search( { frameworkcode => '', kohafield => 'items.new_status' } )->count ) { $template->param( has_new_status => 1 ); } @@ -120,7 +123,7 @@ if ( defined $format ) { filters => [], }; - foreach my $p (qw(homebranch holdingbranch location itype ccode issues datelastborrowed notforloan itemlost withdrawn)) { + foreach my $p (qw(homebranch holdingbranch location itype ccode issues datelastborrowed notforloan itemlost withdrawn damaged)) { if (my @q = $cgi->multi_param($p)) { if ($q[0] ne '') { my $f = { @@ -174,7 +177,7 @@ if ( defined $format ) { push @{ $filter->{filters} }, $f; # Yes/No parameters - foreach my $p (qw( damaged new_status )) { + foreach my $p (qw( new_status )) { my $v = $cgi->param($p) // ''; my $f = { field => $p, @@ -309,6 +312,14 @@ foreach my $value (@$withdrawn_values) { }; } +my @damageds; +foreach my $value (@$damaged_values) { + push @damageds, { + value => $value->{authorised_value}, + label => $value->{lib}, + }; +} + my @items_search_fields = GetItemSearchFields(); my $authorised_values = {}; @@ -324,6 +335,7 @@ $template->param( ccodes => \@ccodes, itemlosts => \@itemlosts, withdrawns => \@withdrawns, + damageds => \@damageds, 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 ac91b9e2fba..e59eca534e1 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 @@ -37,6 +37,8 @@ [%- delimiter | $raw -%] "[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => item.withdrawn ) || "" | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] +"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.damaged', authorised_value => item.damaged ) || "" | replace('"', '""') | $raw %]" +[%- delimiter | $raw -%] "[% (item.issues || 0) | $raw %]" [%- delimiter | $raw -%] "[% IF item.checkout %][% item.checkout.date_due | $KohaDates | $raw %][% END %]" 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 dd4810592f4..5ef10199117 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 @@ -29,6 +29,7 @@ "[% AuthorisedValues.GetDescriptionByKohaField( frameworkcode => biblio.frameworkcode, kohafield => 'items.notforloan', authorised_value => item.notforloan) | html %]", "[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.itemlost', authorised_value => item.itemlost ) || "" | html %]", "[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => item.withdrawn ) || "" | html %]", + "[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.damaged', authorised_value => item.damaged ) || "" | html %]", "[% (item.issues || 0) | html %]", "[% IF item.checkout %][% item.checkout.date_due | $KohaDates %][% END %]", "[% 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 cf82cb47ee4..f1f4ebc79ad 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 @@ -3,5 +3,5 @@ [%- PROCESS 'i18n.inc' -%] [%- SET delimiter = Koha.CSVDelimiter() -%] [%- BLOCK -%] - "[% t("Title") | html %]"[%- delimiter | $raw -%]"[% t("Publication date") | html %]"[%- delimiter | $raw -%]"[% t("Publisher") | html %]"[%- delimiter | $raw -%]"[% t("Collection") | html %]"[%- delimiter | $raw -%]"[% t("Barcode") | html %]"[%- delimiter | $raw -%]"[% t("Serial enumeration") | html %]"[%- delimiter | $raw -%]"[% t("Call number") | html %]"[%- delimiter | $raw -%]"[% t("Home library") | html %]"[%- delimiter | $raw -%]"[% t("Current library") | html %]"[%- delimiter | $raw -%]"[% t("Shelving location") | html %]"[%- delimiter | $raw -%]"[% t("Item type") | html %]"[%- delimiter | $raw -%]"[% t("Inventory number") | html %]"[%- delimiter | $raw -%]"[% t("Not for loan status") | html %]"[%- delimiter | $raw -%]"[% t("Lost status") | html %]"[%- delimiter | $raw -%]"[% t("Withdrawn status") | html %]"[%- delimiter | $raw -%]"[% t("Checkouts") | html %]"[%- delimiter | $raw -%]"[% t("Due date") | html %]" + "[% t("Title") | html %]"[%- delimiter | $raw -%]"[% t("Publication date") | html %]"[%- delimiter | $raw -%]"[% t("Publisher") | html %]"[%- delimiter | $raw -%]"[% t("Collection") | html %]"[%- delimiter | $raw -%]"[% t("Barcode") | html %]"[%- delimiter | $raw -%]"[% t("Serial enumeration") | html %]"[%- delimiter | $raw -%]"[% t("Call number") | html %]"[%- delimiter | $raw -%]"[% t("Home library") | html %]"[%- delimiter | $raw -%]"[% t("Current library") | html %]"[%- delimiter | $raw -%]"[% t("Shelving location") | html %]"[%- delimiter | $raw -%]"[% t("Item type") | html %]"[%- delimiter | $raw -%]"[% t("Inventory number") | html %]"[%- delimiter | $raw -%]"[% t("Not for loan status") | html %]"[%- delimiter | $raw -%]"[% t("Lost status") | html %]"[%- delimiter | $raw -%]"[% t("Withdrawn status") | html %]"[%- delimiter | $raw -%]"[% t("Damaged status") | html %]"[%- delimiter | $raw -%]"[% t("Checkouts") | html %]"[%- delimiter | $raw -%]"[% t("Due date") | html %]" [%- 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 67d7fd0552a..6155d64875e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt @@ -26,9 +26,9 @@ [%- CASE 'All collection codes' %]All collections [%- CASE 'notforloan' %]Status [%- CASE 'All statuses' %]All statuses - [%- CASE 'damaged' %]Damaged [%- CASE 'itemlost' %]Lost [%- CASE 'withdrawn' %]Withdrawn + [%- CASE 'damaged' %]Damaged [%- CASE 'new_status' %]Is new [%- END -%] [%- END -%] @@ -204,6 +204,9 @@ [% IF withdrawns.size %] [% INCLUDE form_field_select name="withdrawn" options = withdrawns empty_option = "All statuses" %] [% END %] + [% IF damageds.size %] + [% INCLUDE form_field_select name="damaged" options = damageds empty_option = "All statuses" %] + [% END %]
@@ -231,7 +234,6 @@ (inclusive)
- [% INCLUDE form_field_radio_yes_no name="damaged" %] [% IF ( has_new_status ) %] [% INCLUDE form_field_radio_yes_no name="new_status" divclass='item-new-status' %] [% END %] @@ -336,6 +338,7 @@ + ' ' + _("Not for loan status") + '' + ' ' + _("Lost status") + '' + ' ' + _("Withdrawn status") + '' + + ' ' + _("Damaged status") + '' + ' ' + _("Checkouts") + '' + ' ' + _("Due date") + '' + ' ' @@ -495,6 +498,7 @@ { 'sName': 'notforloan' }, { 'sName': 'itemlost' }, { 'sName': 'withdrawn' }, + { 'sName': 'damaged' }, { 'sName': 'issues' }, { 'sName': 'date_due' }, { 'sName': 'actions', 'bSortable': false } @@ -544,6 +548,11 @@ [% ELSE %] null, [% END %] + [% IF damageds.size %] + { 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => damageds %] }, + [% ELSE %] + null, + [% END %] { 'type': 'text' }, { 'type': 'text' }, null -- 2.30.2