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 <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2023-05-23 12:41:56 +00:00 committed by Tomas Cohen Arazi
parent 8f86dcdce2
commit 69ed355977
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 23 additions and 38 deletions

View file

@ -17,6 +17,19 @@
</style>
</head>
[% 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 %]
<body id="rep_reserve_stats" class="rep">
[% WRAPPER 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
@ -71,13 +84,13 @@
<tr>
<th>[% mainloo.line | html %] / [% mainloo.column | html %]</th>
[% FOREACH loopco IN mainloo.loopcol %]
<th>[% loopco.coltitle_display | html %]</th>
<th>[% PROCESS reservestatus field=mainloo.column value=loopco.coltitle_display %]</th>
[% END %]
<th>TOTAL</th>
</tr>
[% FOREACH loopro IN mainloo.looprow %]
<tr>
<td>[% loopro.rowtitle_display or "UNKNOWN VALUE" | html %]</td>
<td>[% PROCESS reservestatus field=mainloo.line value=loopro.rowtitle_display %]</td>
[% FOREACH loopcel IN loopro.loopcell %]
<td align="center">
[% IF ( loopcel.url_complement ) %]<a href="reserves_stats.pl?output=[% loopcel.output | uri %]&amp;[% loopcel.url_complement | uri %]">[% loopcel.value | html %]</a>[% ELSE %][% loopcel.value | html %][% END %]
@ -115,11 +128,10 @@
<td><input type="radio" name="Line" value="reservestatus" /></td>
<td><input type="radio" name="Column" value="reservestatus" checked="checked" /></td>
<td>
<input type="checkbox" name="filter_reservestatus_or_1" value="1" /> Asked
<input type="checkbox" name="filter_reservestatus_or_2" value="2" /> Processing
<input type="checkbox" name="filter_reservestatus_or_3" value="3" /> Waiting
<input type="checkbox" name="filter_reservestatus_or_4" value="4" /> Satisfied
<input type="checkbox" name="filter_reservestatus_or_5" value="5" /> Cancelled
<input type="checkbox" name="filter_reservestatus_or_C" value="C" /> Cancelled
<input type="checkbox" name="filter_reservestatus_or_F" value="F" /> Filled
<input type="checkbox" name="filter_reservestatus_or_P" value="P" /> Placed
<input type="checkbox" name="filter_reservestatus_or_W" value="W" /> Waiting
</td>
</tr>
<tr>

View file

@ -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|;
}