Bug 24786: Default to 'branch default' on auth.

If no branch is selected (i.e. 'My library') then we should default to
'branch default' if one is defined for the users library at login.

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Martin Renvoize 2020-08-11 14:24:19 +01:00 committed by Jonathan Druart
parent 1bc723b33c
commit 8ece86e769
2 changed files with 13 additions and 5 deletions

View file

@ -1141,10 +1141,15 @@ sub checkauth {
my $desk = Koha::Desks->find($desk_id); my $desk = Koha::Desks->find($desk_id);
$desk_name = $desk ? $desk->desk_name : ''; $desk_name = $desk ? $desk->desk_name : '';
} }
if ( $query->param('register_id') ) { if ( C4::Context->preference('UseCashRegisters') ) {
$register_id = $query->param('register_id'); my $register =
my $register = Koha::Cash::Registers->find($register_id); $query->param('register_id')
$register_name = $register ? $register->name : ''; ? Koha::Cash::Registers->find($query->param('register_id'))
: Koha::Cash::Registers->search(
{ branch => $branchcode, branch_default => 1 },
{ rows => 1 } )->single;
$register_id = $register->id if ($register);
$register_name = $register->name if ($register);
} }
my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search }; my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search };
if ( $type ne 'opac' and C4::Context->boolean_preference('AutoLocation') ) { if ( $type ne 'opac' and C4::Context->boolean_preference('AutoLocation') ) {

View file

@ -101,7 +101,10 @@
<p> <p>
<label for="register_id">Cash register:</label> <label for="register_id">Cash register:</label>
<select name="register_id" id="register_id" class="input" tabindex="4"> <select name="register_id" id="register_id" class="input" tabindex="4">
[% PROCESS options_for_registers registers => Registers.all() %] <option id="noregister" value="" selected="selected">Branch default</option>
[% FOREACH r IN Registers.all() %]
<option class="[% r.branch | html %] [% IF r.branch_default %]default[% END %]" value="[% r.id | html %]" disabled hidden>[% r.name | html %]</option>
[% END %]
</select> </select>
</p> </p>
[% END %] [% END %]