Browse Source

Bug 24786: (QA follow-up) Fix Registers Plugin

For the QA script we do not set a userenv, so we result in a failure due
to a lack of checking for userenv prior to using it.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Martin Renvoize 10 months ago
committed by Jonathan Druart
parent
commit
085e5739db
  1. 7
      Koha/Template/Plugin/Registers.pm

7
Koha/Template/Plugin/Registers.pm

@ -84,14 +84,15 @@ Returns a list of all cash registers available that adhere to the passed filters
sub all {
my ( $self, $params ) = @_;
my $filters = $params->{filters};
my $filters = $params->{filters} // {};
my $where;
$where->{branch} = C4::Context->userenv->{'branch'}
$where->{branch} =
C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef
if $filters->{current_branch};
my $registers = Koha::Cash::Registers->search($where)->unblessed();
for my $register ( @{$registers} ) {
$register->{selected} = ( defined( $self->session_register_id )
&& $register->{id} == $self->session_register_id ) ? 1 : 0;
&& $register->{id} eq $self->session_register_id ) ? 1 : 0;
}
return $registers;

Loading…
Cancel
Save