From 61c832a507286fc636bd4e4c709be3a5be6970fa 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=utf8 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 Signed-off-by: Jonathan Druart --- 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 7e0ef5d50c..2692c15a06 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 61fa864b38..7011052c48 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -309,6 +309,8 @@ modules: columnname: current_location - columnname: location + - + columnname: notforloan - columnname: notes 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 06512312e1..b88ead7735 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt @@ -49,6 +49,7 @@ Item type Current location Location + Not for loan status Notes @@ -59,7 +60,7 @@ [% item.biblio.title |html %] [% item.biblio.author %] - [% AuthorisedValues.GetByCode( 'LOST', item.itemlost ) %] + [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.itemlost', authorised_value => item.itemlost ) %] [% item.barcode %] @@ -71,6 +72,7 @@ [% item.effective_itemtype %] [% Branches.GetName(item.holdingbranch) %] [% item.location %] + [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => item.notforloan ) %] [% item.itemnotes %] [% END %] @@ -95,15 +97,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 6ca5a78d88..fad09a49e0 100755 --- a/reports/itemslost.pl +++ b/reports/itemslost.pl @@ -32,6 +32,8 @@ use C4::Auth; use C4::Output; use C4::Biblio; use C4::Items; + +use Koha::AuthorisedValues; use Koha::DateUtils; my $query = new CGI; @@ -54,6 +56,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 ) : () ), @@ -62,6 +65,11 @@ if ($get_items) { ? ( itemlost => $loststatusfilter ) : ( itemlost => { '!=' => 0 } ) ), + ( + $notforloanfilter + ? ( notforloan => $notforloanfilter ) + : () + ), ( $barcodefilter ? ( barcode => { like => "%$barcodefilter%" } ) : () ), }; @@ -88,12 +96,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.39.5