From 69ed355977d94f9abaeab00d394f903ff275c876 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 23 May 2023 12:41:56 +0000 Subject: [PATCH] Bug 23059: reserve_stats.pl: Simplify reservestatus This patch does the following: [1] Go back to four statuses: Cancelled, Filled, Waiting or Placed. Placed is used as collective name for all other statuses: pending (placed), processing (found==P) or transit (found==T). Placed before anyway. [2] Allow translation of these statuses in the template. Remove the sub reservestatushuman. [3] The output of changeifreservestatus is considerably shorter and less ugly in the constructed sql statement. Test plan: [1] Use reservestatus as row, as column and only as filter (clicking few statuses). [2] Verify that the shown statistics meet your expectations. Signed-off-by: Marcel de Rooy Signed-off-by: Owen Leonard Signed-off-by: Emily Lamancusa Signed-off-by: Tomas Cohen Arazi --- .../prog/en/modules/reports/reserves_stats.tt | 26 ++++++++++---- reports/reserves_stats.pl | 35 +++---------------- 2 files changed, 23 insertions(+), 38 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tt index b0c781a06a..623e40d04b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reserves_stats.tt @@ -17,6 +17,19 @@ +[% BLOCK reservestatus %] + [% IF field == 'reservestatus' %] + [% SWITCH value %] + [% CASE 'C'%]Cancelled + [% CASE 'F'%]Filled + [% CASE 'P'%]Placed + [% CASE 'W'%]Waiting + [% END %] + [% ELSE %] + [% value | html %] + [% END %] +[% END %] + [% WRAPPER 'header.inc' %] [% INCLUDE 'cat-search.inc' %] @@ -71,13 +84,13 @@ [% mainloo.line | html %] / [% mainloo.column | html %] [% FOREACH loopco IN mainloo.loopcol %] - [% loopco.coltitle_display | html %] + [% PROCESS reservestatus field=mainloo.column value=loopco.coltitle_display %] [% END %] TOTAL [% FOREACH loopro IN mainloo.looprow %] - [% loopro.rowtitle_display or "UNKNOWN VALUE" | html %] + [% PROCESS reservestatus field=mainloo.line value=loopro.rowtitle_display %] [% FOREACH loopcel IN loopro.loopcell %] [% IF ( loopcel.url_complement ) %][% loopcel.value | html %][% ELSE %][% loopcel.value | html %][% END %] @@ -115,11 +128,10 @@ - Asked - Processing - Waiting - Satisfied - Cancelled + Cancelled + Filled + Placed + Waiting diff --git a/reports/reserves_stats.pl b/reports/reserves_stats.pl index af4e0ab379..103ab62356 100755 --- a/reports/reserves_stats.pl +++ b/reports/reserves_stats.pl @@ -300,7 +300,6 @@ sub display_value { : ( $crit =~ /location/ ) ? $locations->{$value} : ( $crit =~ /itemtype/ ) ? Koha::ItemTypes->find( $value )->translated_description : ( $crit =~ /branch/ ) ? Koha::Libraries->find($value)->branchname - : ( $crit =~ /reservestatus/ ) ? reservestatushuman($value) : $value; # default fallback if ($crit =~ /sort1/) { foreach (@$Bsort1) { @@ -324,35 +323,9 @@ sub display_value { return $display_value; } -sub reservestatushuman{ - my ($val)=@_; - my %hashhuman=( - 1=>"1- placed", - 2=>"2- processed", - 3=>"3- pending", - 4=>"4- satisfied", - 5=>"5- cancelled", - 6=>"6- not a status" - ); - $hashhuman{$val}; -} - sub changeifreservestatus{ - my ($val)=@_; - ($val=~/reservestatus/ - ?$val=qq{ case - when priority>0 then 1 - when priority=0 then - (case - when found='f' then 4 - when found='w' then - (case - when cancellationdate is null then 3 - else 5 - end ) - else 2 - end ) - else 6 - end } - :$val); + my ( $field ) = @_; + return $field unless $field =~ /reservestatus/; + # For reservestatus we return C- Cancelled, W- Waiting, F- Filled, P- Placed (or other like processing, transit etc.) + return q|CASE WHEN cancellationdate IS NOT NULL THEN 'C' WHEN found='W' THEN 'W' WHEN found='F' THEN 'F' ELSE 'P' END|; } -- 2.39.5