From 6d453d9bebd1576047fa9569679a01d34407b3e1 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 21 Jul 2020 14:54:09 +0100 Subject: [PATCH] Bug 24665: Add support for filtering by cash register Signed-off-by: Kelly McElligott --- Koha/Template/Plugin/Registers.pm | 9 ++++++++- .../prog/en/modules/reports/cash_register_stats.tt | 14 ++++++++++++-- reports/cash_register_stats.pl | 9 +++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Koha/Template/Plugin/Registers.pm b/Koha/Template/Plugin/Registers.pm index 7baf5d6bf8..d877de0ba8 100644 --- a/Koha/Template/Plugin/Registers.pm +++ b/Koha/Template/Plugin/Registers.pm @@ -89,9 +89,16 @@ sub all { $where->{branch} = C4::Context->userenv->{'branch'} if ( $filters->{current_branch} && C4::Context->userenv ); my $registers = Koha::Cash::Registers->search($where)->unblessed(); + + my $selected = $params->{selected}; for my $register ( @{$registers} ) { - $register->{selected} = ( defined( $self->session_register_id ) + if ( defined($selected) ) { + $register->{selected} = ( $register->{id} == $selected ) ? 1 : 0; + } + else { + $register->{selected} = ( defined( $self->session_register_id ) && $register->{id} eq $self->session_register_id ) ? 1 : 0; + } } return $registers; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt index cbcc27a056..bc0dd7e9b9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt @@ -1,8 +1,11 @@ [% USE raw %] [% USE Asset %] +[% USE Branches %] +[% USE Koha %] [% USE KohaDates %] [% USE Price %] [% USE ItemTypes %] +[% USE Registers %] [% SET footerjs = 1 %] [% PROCESS 'accounts.inc' %] [% INCLUDE 'doc-head-open.inc' %] @@ -96,9 +99,15 @@ [% END %] [% END %] - - + [% IF Koha.Preference('UseCashRegisters') %] +
  • + + +
  • + [% END %] @@ -186,6 +195,7 @@ [% MACRO jsinclude BLOCK %] + [% Asset.js("js/register_selection.js") | $raw %] [% INCLUDE 'datatables.inc' %]