View | Details | Raw Unified | Return to bug 24786
Collapse All | Expand All

(-)a/C4/Auth.pm (-6 / +17 lines)
Lines 846-852 sub checkauth { Link Here
846
                $session->param('surname'),      $session->param('branch'),
846
                $session->param('surname'),      $session->param('branch'),
847
                $session->param('branchname'),   $session->param('flags'),
847
                $session->param('branchname'),   $session->param('flags'),
848
                $session->param('emailaddress'), $session->param('shibboleth'),
848
                $session->param('emailaddress'), $session->param('shibboleth'),
849
                $session->param('desk_id'),      $session->param('desk_name')
849
                $session->param('desk_id'),      $session->param('desk_name'),
850
                $session->param('register_id')
850
            );
851
            );
851
            C4::Context::set_shelves_userenv( 'bar', $session->param('barshelves') );
852
            C4::Context::set_shelves_userenv( 'bar', $session->param('barshelves') );
852
            C4::Context::set_shelves_userenv( 'pub', $session->param('pubshelves') );
853
            C4::Context::set_shelves_userenv( 'pub', $session->param('pubshelves') );
Lines 1066-1072 sub checkauth { Link Here
1066
                    C4::Context->_unset_userenv($sessionID);
1067
                    C4::Context->_unset_userenv($sessionID);
1067
                }
1068
                }
1068
                my ( $borrowernumber, $firstname, $surname, $userflags,
1069
                my ( $borrowernumber, $firstname, $surname, $userflags,
1069
                    $branchcode, $branchname, $emailaddress, $desk_id, $desk_name );
1070
                    $branchcode, $branchname, $emailaddress, $desk_id,
1071
                    $desk_name, $register_id );
1070
1072
1071
                if ( $return == 1 ) {
1073
                if ( $return == 1 ) {
1072
                    my $select = "
1074
                    my $select = "
Lines 1115-1120 sub checkauth { Link Here
1115
                        my $desk = Koha::Desks->find($desk_id);
1117
                        my $desk = Koha::Desks->find($desk_id);
1116
                        $desk_name = $desk ? $desk->desk_name : '';
1118
                        $desk_name = $desk ? $desk->desk_name : '';
1117
                    }
1119
                    }
1120
                    if ( $query->param('register_id') ) {
1121
                        $register_id = $query->param('register_id');
1122
                    }
1118
                    my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search };
1123
                    my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search };
1119
                    if ( $type ne 'opac' and C4::Context->boolean_preference('AutoLocation') ) {
1124
                    if ( $type ne 'opac' and C4::Context->boolean_preference('AutoLocation') ) {
1120
1125
Lines 1158-1163 sub checkauth { Link Here
1158
                    $session->param( 'lasttime',     time() );
1163
                    $session->param( 'lasttime',     time() );
1159
                    $session->param( 'interface',    $type);
1164
                    $session->param( 'interface',    $type);
1160
                    $session->param( 'shibboleth',   $shibSuccess );
1165
                    $session->param( 'shibboleth',   $shibSuccess );
1166
                    $session->param( 'register_id',  $register_id );
1161
                    $debug and printf STDERR "AUTH_4: (%s)\t%s %s - %s\n", map { $session->param($_) } qw(cardnumber firstname surname branch);
1167
                    $debug and printf STDERR "AUTH_4: (%s)\t%s %s - %s\n", map { $session->param($_) } qw(cardnumber firstname surname branch);
1162
                }
1168
                }
1163
                $session->param('cas_ticket', $cas_ticket) if $cas_ticket;
1169
                $session->param('cas_ticket', $cas_ticket) if $cas_ticket;
Lines 1167-1173 sub checkauth { Link Here
1167
                    $session->param('surname'),      $session->param('branch'),
1173
                    $session->param('surname'),      $session->param('branch'),
1168
                    $session->param('branchname'),   $session->param('flags'),
1174
                    $session->param('branchname'),   $session->param('flags'),
1169
                    $session->param('emailaddress'), $session->param('shibboleth'),
1175
                    $session->param('emailaddress'), $session->param('shibboleth'),
1170
                    $session->param('desk_id'),      $session->param('desk_name')
1176
                    $session->param('desk_id'),      $session->param('desk_name'),
1177
                    $session->param('register_id')
1171
                );
1178
                );
1172
1179
1173
            }
1180
            }
Lines 1445-1451 sub check_api_auth { Link Here
1445
                $session->param('surname'),      $session->param('branch'),
1452
                $session->param('surname'),      $session->param('branch'),
1446
                $session->param('branchname'),   $session->param('flags'),
1453
                $session->param('branchname'),   $session->param('flags'),
1447
                $session->param('emailaddress'), $session->param('shibboleth'),
1454
                $session->param('emailaddress'), $session->param('shibboleth'),
1448
                $session->param('desk_id'),      $session->param('desk_name')
1455
                $session->param('desk_id'),      $session->param('desk_name'),
1456
                $session->param('register_id')
1449
            );
1457
            );
1450
1458
1451
            my $ip       = $session->param('ip');
1459
            my $ip       = $session->param('ip');
Lines 1604-1611 sub check_api_auth { Link Here
1604
                $session->param('number'),       $session->param('id'),
1612
                $session->param('number'),       $session->param('id'),
1605
                $session->param('cardnumber'),   $session->param('firstname'),
1613
                $session->param('cardnumber'),   $session->param('firstname'),
1606
                $session->param('surname'),      $session->param('branch'),
1614
                $session->param('surname'),      $session->param('branch'),
1615
                $session->param('branchname'),   $session->param('flags'),
1607
                $session->param('emailaddress'), $session->param('shibboleth'),
1616
                $session->param('emailaddress'), $session->param('shibboleth'),
1608
                $session->param('desk_id'),      $session->param('desk_name')
1617
                $session->param('desk_id'),      $session->param('desk_name'),
1618
                $session->param('register_id')
1609
            );
1619
            );
1610
            return ( "ok", $cookie, $sessionID );
1620
            return ( "ok", $cookie, $sessionID );
1611
        } else {
1621
        } else {
Lines 1694-1700 sub check_cookie_auth { Link Here
1694
            $session->param('surname'),      $session->param('branch'),
1704
            $session->param('surname'),      $session->param('branch'),
1695
            $session->param('branchname'),   $session->param('flags'),
1705
            $session->param('branchname'),   $session->param('flags'),
1696
            $session->param('emailaddress'), $session->param('shibboleth'),
1706
            $session->param('emailaddress'), $session->param('shibboleth'),
1697
            $session->param('desk_id'),      $session->param('desk_name')
1707
            $session->param('desk_id'),      $session->param('desk_name'),
1708
            $session->param('register_id')
1698
        );
1709
        );
1699
1710
1700
        my $ip       = $session->param('ip');
1711
        my $ip       = $session->param('ip');
(-)a/C4/Context.pm (-9 / +12 lines)
Lines 808-814 sub userenv { Link Here
808
                           $userfirstname, $usersurname,
808
                           $userfirstname, $usersurname,
809
                           $userbranch, $branchname, $userflags,
809
                           $userbranch, $branchname, $userflags,
810
                           $emailaddress, $shibboleth
810
                           $emailaddress, $shibboleth
811
                           $desk_id, $desk_name);
811
                           $desk_id, $desk_name,
812
                           $register_id);
812
813
813
Establish a hash of user environment variables.
814
Establish a hash of user environment variables.
814
815
Lines 819-825 set_userenv is called in Auth.pm Link Here
819
#'
820
#'
820
sub set_userenv {
821
sub set_userenv {
821
    shift @_;
822
    shift @_;
822
    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $shibboleth, $desk_id, $desk_name)=
823
    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $shibboleth, $desk_id, $desk_name, $register_id)=
823
    map { Encode::is_utf8( $_ ) ? $_ : Encode::decode('UTF-8', $_) } # CGI::Session doesn't handle utf-8, so we decode it here
824
    map { Encode::is_utf8( $_ ) ? $_ : Encode::decode('UTF-8', $_) } # CGI::Session doesn't handle utf-8, so we decode it here
824
    @_;
825
    @_;
825
    my $var=$context->{"activeuser"} || '';
826
    my $var=$context->{"activeuser"} || '';
Lines 829-842 sub set_userenv { Link Here
829
        "cardnumber" => $usercnum,
830
        "cardnumber" => $usercnum,
830
        "firstname"  => $userfirstname,
831
        "firstname"  => $userfirstname,
831
        "surname"    => $usersurname,
832
        "surname"    => $usersurname,
833
832
        #possibly a law problem
834
        #possibly a law problem
833
        "branch"     => $userbranch,
835
        "branch"       => $userbranch,
834
        "branchname" => $branchname,
836
        "branchname"   => $branchname,
835
        "desk_id"    => $desk_id,
837
        "flags"        => $userflags,
836
        "desk_name"  => $desk_name,
838
        "emailaddress" => $emailaddress,
837
        "flags"      => $userflags,
839
        "shibboleth"   => $shibboleth,
838
        "emailaddress"     => $emailaddress,
840
        "desk_id"      => $desk_id,
839
        "shibboleth" => $shibboleth,
841
        "desk_name"    => $desk_name,
842
        "register_id"  => $register_id,
840
    };
843
    };
841
    $context->{userenv}->{$var} = $cell;
844
    $context->{userenv}->{$var} = $cell;
842
    return $cell;
845
    return $cell;
(-)a/Koha/Template/Plugin/Registers.pm (+65 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::Registers;
2
3
# Copyright PTFS Europe 2020
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Template::Plugin;
23
use base qw( Template::Plugin );
24
25
use C4::Koha;
26
use C4::Context;
27
use Koha::Cash::Registers;
28
29
sub session_register_id {
30
    my ($self) = @_;
31
32
    return C4::Context->userenv ?
33
        C4::Context->userenv->{'register_id'} :
34
        '';
35
}
36
37
sub session_register_name {
38
    my ($self) = @_;
39
40
    my $register = Koha::Cash::Registers->find($self->session_register_id);
41
    return $register ? $register->name : '';
42
}
43
44
=head2
45
46
    [% SET registers = Registers.all() %]
47
    [% SET registers = Registers.all( { branch => branchcode } );
48
49
Returns a list of all cash registers available that adhere to the passed filters.
50
51
=cut
52
53
sub all {
54
    my ( $self, $params ) = @_;
55
56
    my $registers = Koha::Cash::Registers->search()->unblessed();
57
    for my $register ( @{$registers} ) {
58
        $register->{selected} = ( defined( $self->session_register_id )
59
              && $register->{id} == $self->session_register_id ) ? 1 : 0;
60
    }
61
62
    return $registers;
63
}
64
65
1;
(-)a/circ/set-library.pl (-7 / +24 lines)
Lines 25-30 use C4::Output; Link Here
25
use C4::Auth qw/:DEFAULT get_session/;
25
use C4::Auth qw/:DEFAULT get_session/;
26
use C4::Koha;
26
use C4::Koha;
27
use Koha::BiblioFrameworks;
27
use Koha::BiblioFrameworks;
28
use Koha::Cash::Registers;
28
use Koha::Libraries;
29
use Koha::Libraries;
29
use Koha::Desks;
30
use Koha::Desks;
30
31
Lines 42-60 my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user({ Link Here
42
my $sessionID = $query->cookie("CGISESSID");
43
my $sessionID = $query->cookie("CGISESSID");
43
my $session = get_session($sessionID);
44
my $session = get_session($sessionID);
44
45
45
my $branch   = $query->param('branch' );
46
my $branch              = $query->param('branch');
46
my $desk_id = $query->param('desk_id');
47
my $desk_id             = $query->param('desk_id');
47
my $userenv_branch  = C4::Context->userenv->{'branch'}        || '';
48
my $register_id         = $query->param('register_id');
48
my $userenv_desk = C4::Context->userenv->{'desk_id'} || '';
49
my $userenv_branch      = C4::Context->userenv->{'branch'} || '';
50
my $userenv_desk        = C4::Context->userenv->{'desk_id'} || '';
51
my $userenv_register_id = C4::Context->userenv->{'register_id'} || '';
49
my @updated;
52
my @updated;
50
53
51
# $session lddines here are doing the updating
54
# $session lines here are doing the updating
52
if ( $branch and my $library = Koha::Libraries->find($branch) ) {
55
if ( $branch and my $library = Koha::Libraries->find($branch) ) {
53
    if (! $userenv_branch or $userenv_branch ne $branch ) {
56
    if (! $userenv_branch or $userenv_branch ne $branch ) {
54
        my $branchname = $library->branchname;
57
        my $branchname = $library->branchname;
55
        $session->param('branchname', $branchname);         # update sesssion in DB
58
        $session->param('branchname', $branchname);         # update sesssion in DB
56
        $session->param('branch', $branch);                 # update sesssion in DB
59
        $session->param('branch', $branch);                 # update sesssion in DB
57
        $session->flush();
58
        push @updated, {
60
        push @updated, {
59
            updated_branch => 1,
61
            updated_branch => 1,
60
                old_branch => $userenv_branch,
62
                old_branch => $userenv_branch,
Lines 77-82 if ( $branch and my $library = Koha::Libraries->find($branch) ) { Link Here
77
            old_desk => $old_desk_name,
79
            old_desk => $old_desk_name,
78
        };
80
        };
79
    }
81
    }
82
    if ( defined($userenv_register_id)
83
        && ( $userenv_register_id ne $register_id ) )
84
    {
85
        my $register = Koha::Cash::Registers->find($register_id);
86
        $template->param(LoginRegisterID   => $register_id);   # update template for new register
87
        $template->param(LoginRegisterName   => $register ? $register->name : '');   # update template for new register
88
        $session->param( 'register_id', $register_id );
89
        push @updated,
90
          {
91
            updated_register => 1,
92
            new_register     => $register ? $register->name : ''
93
          };
94
    }
95
    $session->flush();
80
} else {
96
} else {
81
    $branch = $userenv_branch;  # fallback value
97
    $branch = $userenv_branch;  # fallback value
82
    $desk_id = $userenv_desk;
98
    $desk_id = $userenv_desk;
Lines 89-99 foreach ($query->param()) { Link Here
89
    $_ or next;                   # disclude blanks
105
    $_ or next;                   # disclude blanks
90
    $_ eq "branch"     and next;  # disclude branch
106
    $_ eq "branch"     and next;  # disclude branch
91
    $_ eq "desk_id"    and next;  # disclude desk_id
107
    $_ eq "desk_id"    and next;  # disclude desk_id
108
    $_ eq "register_id" and next;    # disclude register
92
    $_ eq "oldreferer" and next;  # disclude oldreferer
109
    $_ eq "oldreferer" and next;  # disclude oldreferer
93
    push @recycle_loop, {
110
    push @recycle_loop, {
94
        param => $_,
111
        param => $_,
95
        value => scalar $query->param($_),
112
        value => scalar $query->param($_),
96
    };
113
      };
97
}
114
}
98
115
99
my $referer =  $query->param('oldreferer') || $ENV{HTTP_REFERER};
116
my $referer =  $query->param('oldreferer') || $ENV{HTTP_REFERER};
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc (-1 / +13 lines)
Lines 1-6 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Branches %]
2
[% USE Branches %]
3
[% USE Desks %]
3
[% USE Desks %]
4
[% USE Registers %]
4
[% USE Koha %]
5
[% USE Koha %]
5
<nav class="navbar">
6
<nav class="navbar">
6
    <div class="navbar-header">
7
    <div class="navbar-header">
Lines 96-102 Link Here
96
                                    <span class="logged-in-desk-id content_hidden">[% Desks.GetLoggedInDeskId | html %]</span>
97
                                    <span class="logged-in-desk-id content_hidden">[% Desks.GetLoggedInDeskId | html %]</span>
97
                                [% END %]
98
                                [% END %]
98
                            </strong>
99
                            </strong>
99
                         [% END %]
100
                        [% END %]
101
                        [% IF Koha.Preference('UseCashRegisters') %]
102
                            <span class="separator">|</span>
103
                            <strong>
104
                                [% IF ( Registers.session_register_name == '' ) %]
105
                                    <span class="logged-in-register-name">REGISTER NOT SET</span>
106
                                [% ELSE %]
107
                                    <span class="logged-in-register-name">[% Registers.session_register_name | html %]</span>
108
                                    <span class="logged-in-register-id content_hidden">[% Registers.session_register_id | html %]</span>
109
                                [% END %]
110
                            </strong>
111
                        [% END %]
100
                    </span>
112
                    </span>
101
                    <b class="caret"></b>
113
                    <b class="caret"></b>
102
                </a>
114
                </a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc (-1 / +17 lines)
Lines 19-25 Link Here
19
          [% END %]
19
          [% END %]
20
        [% ELSE %]
20
        [% ELSE %]
21
            <option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" disabled hidden>[% d.desk_name | html %]</option>
21
            <option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" disabled hidden>[% d.desk_name | html %]</option>
22
        [% END%]
22
        [% END %]
23
    [% END %]
24
[% END %]
25
26
[% BLOCK options_for_registers %]
27
    <!-- <option hidden disabled selected value> -- select an option -- </option> -->
28
    <option id="noregister" value="">-- None --</option>
29
    [% FOREACH r IN registers %]
30
        [% IF r.branch == branch %]
31
            [% IF r.selected %]
32
                <option class="[% r.branch | html %] [% IF r.branch_default %]default[% END %]" value="[% r.id | html %]" selected="selected">[% r.name | html %]</option>
33
            [% ELSE %]
34
                <option class="[% r.branch | html %] [% IF r.branch_default %]default[% END %]" value="[% r.id | html %]">[% r.name | html %]</option>
35
            [% END%]
36
        [% ELSE %]
37
            <option class="[% r.branch | html %] [% IF r.branch_default %]default[% END %]" value="[% r.id | html %]" disabled hidden>[% r.name | html %]</option>
38
        [% END %]
23
    [% END %]
39
    [% END %]
24
[% END %]
40
[% END %]
25
41
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt (-5 / +56 lines)
Lines 2-7 Link Here
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Branches %]
3
[% USE Branches %]
4
[% USE Desks %]
4
[% USE Desks %]
5
[% USE Registers %]
5
[% USE Koha %]
6
[% USE Koha %]
6
[% SET footerjs = 1 %]
7
[% SET footerjs = 1 %]
7
[% INCLUDE 'doc-head-open.inc' %]
8
[% INCLUDE 'doc-head-open.inc' %]
Lines 39-48 Link Here
39
<h2>Update succeeded</h2>
40
<h2>Update succeeded</h2>
40
Updated:<ul>
41
Updated:<ul>
41
    [% FOREACH update IN updated %]
42
    [% FOREACH update IN updated %]
42
    [% IF ( update.updated_branch ) %]
43
    [% IF ( update.updated_branch || update.updated_desk ||  update.updated_register ) %]
44
        [% IF ( updated.updated.branch ) %]
43
        <li>Library: [% update.old_branch or "?" | html %] &rArr; [% update.new_branch or "?" | html %]</li>
45
        <li>Library: [% update.old_branch or "?" | html %] &rArr; [% update.new_branch or "?" | html %]</li>
44
    [% ELSIF (update.updated_desk) %]
46
        [% END %]
47
        [% IF ( update.updated_desk ) %]
45
        <li>Desk: [% update.old_desk or "?" | html %] &rArr; [% LoginDeskname or "?" | html %]</li>
48
        <li>Desk: [% update.old_desk or "?" | html %] &rArr; [% LoginDeskname or "?" | html %]</li>
49
        [% END %]
50
        [% IF ( updated.updated_register ) %]
51
        <li>Register: [% updated.new_register | html %]</li>
52
        [% END %]
46
    [% ELSE %]
53
    [% ELSE %]
47
        <li>ERROR - unknown</li>
54
        <li>ERROR - unknown</li>
48
    [% END %]
55
    [% END %]
Lines 73-79 Updated:<ul> Link Here
73
    [% END %]
80
    [% END %]
74
    </ol>
81
    </ol>
75
</fieldset>
82
</fieldset>
76
 [% IF Koha.Preference('UseCirculationDesks') && Desks.all %]
83
84
[% IF Koha.Preference('UseCirculationDesks') && Desks.all %]
77
<fieldset class="rows">
85
<fieldset class="rows">
78
    <legend>Set desk</legend>
86
    <legend>Set desk</legend>
79
    <ol>
87
    <ol>
Lines 84-89 Updated:<ul> Link Here
84
    </ol>
92
    </ol>
85
</fieldset>
93
</fieldset>
86
[% END %]
94
[% END %]
95
96
[% IF Koha.Preference('UseCashRegisters') %]
97
<fieldset class="rows">
98
    <legend>Set cash register</legend>
99
    <ol>
100
        <li>
101
            <label for="register_id">Choose cash register:</label>
102
            <select name="register_id" id="register_id">
103
                [% PROCESS options_for_registers registers => Registers.all() %]
104
            </select>
105
        </li>
106
    </ol>
107
</fieldset>
108
[% END %]
109
87
<fieldset class="action">
110
<fieldset class="action">
88
    <input type="submit" value="Submit" />
111
    <input type="submit" value="Submit" />
89
    <a class="cancel" id="cancel_set_library" href="[% referer or '/cgi-bin/koha/circ/circulation.pl' %]">Cancel</a>
112
    <a class="cancel" id="cancel_set_library" href="[% referer or '/cgi-bin/koha/circ/circulation.pl' %]">Cancel</a>
Lines 112-120 Updated:<ul> Link Here
112
        </div> <!-- /.col-sm-12 -->
135
        </div> <!-- /.col-sm-12 -->
113
    </div> <!-- /.row -->
136
    </div> <!-- /.row -->
114
137
115
116
[% MACRO jsinclude BLOCK %]
138
[% MACRO jsinclude BLOCK %]
117
  [% Asset.js("js/desk_selection.js") | $raw %]
139
  [% Asset.js("js/desk_selection.js") | $raw %]
140
  <script>
141
    $(document).ready(function() {
142
        $("#branch").on("change", function() {
143
            var selectedBranch = $("#branch").children(
144
                    "option:selected").val();
145
146
            $("#register_id").children().each(function() {
147
                // default to no-register
148
                if ($(this).is("#noregister")) {
149
                    $(this).prop("selected", true)
150
                }
151
                // display branch registers
152
                else if ($(this).hasClass(selectedBranch)) {
153
                    $(this).prop("disabled", false);
154
                    $(this).show();
155
                    // default to branch default if there is one
156
                    if ($(this).hasClass("default")) {
157
                        $(this).prop("selected", true)
158
                    }
159
                }
160
                // hide non-branch registers
161
                else
162
                {
163
                    $(this).hide();
164
                    $(this).prop("disabled", true);
165
                }
166
            });
167
        });
168
    });
169
  </script>
118
[% END %]
170
[% END %]
119
171
120
[% INCLUDE 'intranet-bottom.inc' %]
172
[% INCLUDE 'intranet-bottom.inc' %]
121
- 

Return to bug 24786