From b8ac3b9d19c9b1d513a7646f96cdccb7b9e629c3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 5 Oct 2017 13:02:58 -0300 Subject: [PATCH] Bug 9573: Lost items report - Add items.notforloan as a filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds a new "Not for loan" status filter to the lost items report. Test plan: 0/ Apply all patches from this patch set 1/ Use the new "Not for loan" filter to search lost items 2/ The table result must be consistent and a new "Not for loan" column should be there 3/ Confirm that you are able to hide/show this column with the column settings tool. Signed-off-by: Katrin Fischer Signed-off-by: Séverine QUEUNE --- Koha/Template/Plugin/AuthorisedValues.pm | 30 +++++++++++++++++ admin/columns_settings.yml | 2 ++ .../prog/en/modules/reports/itemslost.tt | 39 +++++++++++++++++----- reports/itemslost.pl | 14 +++++--- 4 files changed, 71 insertions(+), 14 deletions(-) diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm index 7e0ef5d..2692c15 100644 --- a/Koha/Template/Plugin/AuthorisedValues.pm +++ b/Koha/Template/Plugin/AuthorisedValues.pm @@ -68,6 +68,28 @@ sub GetCategories { ]; } +sub GetDescriptionsByKohaField { + my ( $self, $params ) = @_; + return Koha::AuthorisedValues->get_descriptions_by_koha_field( + { kohafield => $params->{kohafield} } ); +} + +sub GetDescriptionByKohaField { + my ( $self, $params ) = @_; + my $av = Koha::AuthorisedValues->get_description_by_koha_field( + { + kohafield => $params->{kohafield}, + authorised_value => $params->{authorised_value}, + } + ); + return %$av + ? $params->{opac} + ? $av->{opac_description} + : $av->{lib} + : ''; # Maybe we should return $params->{authorised_value}? + +} + 1; =head1 NAME @@ -93,6 +115,14 @@ the following TT code: [% AuthorisedValues.GetByCode( 'CATEGORY', 'AUTHORISED_VA The parameters are identical to those used by the subroutine C4::Koha::GetAuthValueDropbox +=head2 GetDescriptionsByKohaField + +The parameters are identical to those used by the subroutine Koha::AuthorisedValues->get_descriptions_by_koha_field + +=head2 GetDescriptionByKohaField + +The parameters are identical to those used by the subroutine Koha::AuthorisedValues->get_description_by_koha_field + =head1 AUTHOR Kyle M Hall diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index 5198c0d..d2f377f 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -285,6 +285,8 @@ modules: - columnname: location - + columnname: notforloan + - columnname: notes circ: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt index e3b8e26..327fe8e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt @@ -67,6 +67,7 @@ Item type Current location Location + Not for loan status Notes @@ -77,7 +78,7 @@ [% item.biblio.title |html %] [% item.biblio.author %] - [% AuthorisedValues.GetByCode( 'LOST', item.itemlost ) %] + [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.itemlost', authorised_value => item.itemlost ) %] [% item.barcode %] @@ -89,6 +90,7 @@ [% item.effective_itemtype %] [% Branches.GetName(item.holdingbranch) %] [% item.location %] + [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => item.notforloan ) %] [% item.itemnotes %] [% END %] @@ -113,15 +115,34 @@ [% END %] -
  • + + [% FOREACH l IN AuthorisedValues.GetDescriptionsByKohaField( kohafield => 'items.itemlost') %] + [% IF l.authorised_value == lostfilter %] + + [% ELSE %] + [% END %] -
  • + [% END %] + + + +
  • + + +
  • +
    diff --git a/reports/itemslost.pl b/reports/itemslost.pl index 75bb067..41de7dd 100755 --- a/reports/itemslost.pl +++ b/reports/itemslost.pl @@ -33,6 +33,8 @@ use C4::Auth; use C4::Output; use C4::Biblio; use C4::Items; + +use Koha::AuthorisedValues; use Koha::DateUtils; my $query = new CGI; @@ -55,6 +57,7 @@ if ($get_items) { my $barcodefilter = $params->{'barcodefilter'} || undef; my $itemtypesfilter = $params->{'itemtypesfilter'} || undef; my $loststatusfilter = $params->{'loststatusfilter'} || undef; + my $notforloanfilter = $params->{'notforloanfilter'} || undef; my $params = { ( $branchfilter ? ( homebranch => $branchfilter ) : () ), @@ -63,6 +66,11 @@ if ($get_items) { ? ( itemlost => $loststatusfilter ) : ( itemlost => { '!=' => 0 } ) ), + ( + $notforloanfilter + ? ( notforloan => $notforloanfilter ) + : () + ), ( $barcodefilter ? ( barcode => { like => "%$barcodefilter%" } ) : () ), }; @@ -89,12 +97,8 @@ if ($get_items) { # getting all itemtypes my $itemtypes = Koha::ItemTypes->search_with_localization; -# get lost statuses -my $lost_status_loop = C4::Koha::GetAuthorisedValues( 'LOST' ); - $template->param( - itemtypes => $itemtypes, - loststatusloop => $lost_status_loop, + itemtypes => $itemtypes, ); # writing the template -- 2.7.4