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

(-)a/C4/Auth.pm (-2 / +9 lines)
Lines 1070-1076 sub checkauth { Link Here
1070
                    C4::Context->_unset_userenv($sessionID);
1070
                    C4::Context->_unset_userenv($sessionID);
1071
                }
1071
                }
1072
                my ( $borrowernumber, $firstname, $surname, $userflags,
1072
                my ( $borrowernumber, $firstname, $surname, $userflags,
1073
                    $branchcode, $branchname, $emailaddress );
1073
                    $branchcode, $branchname, $emailaddress, $desk_id, $desk_name );
1074
1074
1075
                if ( $return == 1 ) {
1075
                if ( $return == 1 ) {
1076
                    my $select = "
1076
                    my $select = "
Lines 1114-1119 sub checkauth { Link Here
1114
                        my $library = Koha::Libraries->find($branchcode);
1114
                        my $library = Koha::Libraries->find($branchcode);
1115
                        $branchname = $library? $library->branchname: '';
1115
                        $branchname = $library? $library->branchname: '';
1116
                    }
1116
                    }
1117
                    if ( $query->param('desk_id') ) {
1118
                        $desk_id = $query->param('desk_id');
1119
                        my $desk = Koha::Desks->find($desk_id);
1120
                        $desk_name = $desk ? $desk->desk_name : '';
1121
                    }
1117
                    my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search };
1122
                    my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search };
1118
                    if ( $type ne 'opac' and C4::Context->boolean_preference('AutoLocation') ) {
1123
                    if ( $type ne 'opac' and C4::Context->boolean_preference('AutoLocation') ) {
1119
1124
Lines 1149-1154 sub checkauth { Link Here
1149
                    $session->param( 'surname',      $surname );
1154
                    $session->param( 'surname',      $surname );
1150
                    $session->param( 'branch',       $branchcode );
1155
                    $session->param( 'branch',       $branchcode );
1151
                    $session->param( 'branchname',   $branchname );
1156
                    $session->param( 'branchname',   $branchname );
1157
                    $session->param( 'desk_id',      $desk_id);
1158
                    $session->param( 'desk_name',     $desk_name);
1152
                    $session->param( 'flags',        $userflags );
1159
                    $session->param( 'flags',        $userflags );
1153
                    $session->param( 'emailaddress', $emailaddress );
1160
                    $session->param( 'emailaddress', $emailaddress );
1154
                    $session->param( 'ip',           $session->remote_addr() );
1161
                    $session->param( 'ip',           $session->remote_addr() );
Lines 1164-1170 sub checkauth { Link Here
1164
                    $session->param('surname'),      $session->param('branch'),
1171
                    $session->param('surname'),      $session->param('branch'),
1165
                    $session->param('branchname'),   $session->param('flags'),
1172
                    $session->param('branchname'),   $session->param('flags'),
1166
                    $session->param('emailaddress'), $session->param('shibboleth'),
1173
                    $session->param('emailaddress'), $session->param('shibboleth'),
1167
                    $session->param('desk_id'),      $session->param('desk_name')
1174
                    $session->param('desk_id'), $session->param('desk_name')
1168
                );
1175
                );
1169
1176
1170
            }
1177
            }
(-)a/Koha/Template/Plugin/Desks.pm (-1 / +16 lines)
Lines 73-79 sub GetLoggedInDeskName { Link Here
73
73
74
[% Desks.ListForLibrary %]
74
[% Desks.ListForLibrary %]
75
75
76
returns all desks existing at the library
76
returns all desks existing at the current library
77
77
78
=cut
78
=cut
79
79
Lines 87-90 sub ListForLibrary { Link Here
87
    );
87
    );
88
}
88
}
89
89
90
=head3 all
91
92
[% Desks.all %]
93
94
returns all desks existing at all libraries
95
96
=cut
97
98
99
sub all {
100
101
    my ( $self ) = @_;
102
    return Koha::Desks->search( )->unblessed;
103
}
104
90
1;
105
1;
(-)a/circ/selectdesk.pl (-87 lines)
Lines 1-87 Link Here
1
#!/usr/bin/perl
2
3
# Copyright (C) 2020 BULAC
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
use CGI qw ( -utf8 );
22
23
use C4::Context;
24
use C4::Output;
25
use C4::Auth qw/:DEFAULT get_session/;
26
use C4::Koha;
27
use Koha::Desks;
28
29
my $query = CGI->new();
30
31
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
32
    {
33
        template_name   => "circ/selectdesk.tt",
34
        query           => $query,
35
        type            => "intranet",
36
        debug           => 1,
37
        authnotrequired => 0,
38
        flagsrequired   => { catalogue => 1, },
39
    }
40
);
41
42
my $sessionID = $query->cookie("CGISESSID");
43
my $session   = get_session($sessionID);
44
45
my $branch = C4::Context->userenv->{'branch'};
46
my $searchfield = $query->param('searchfield');
47
my $desks_lists;
48
if ($branch) {
49
    $desks_lists = Koha::Desks->search( { branchcode => $branch } )->unblessed;
50
}
51
else {
52
    $desks_lists = Koha::Desks->search( )->unblessed;
53
}
54
55
my $desk_id = $query->param('desk_id');
56
57
my $userenv_desk = C4::Context->userenv->{'desk_id'} || '';
58
my $updated = '';
59
60
if ($desk_id) {
61
    if ( !$userenv_desk or $userenv_desk ne $desk_id ) {
62
        my $desk = Koha::Desks->find( { desk_id => $desk_id } );
63
        $template->param( LoginDeskname => $desk->desk_name );
64
        $template->param( LoginDeskid => $desk->desk_id );
65
        $session->param( desk_name => $desk->desk_name );
66
        $session->param( desk_id => $desk->desk_id );
67
        $updated = 1;
68
    }
69
}
70
else {
71
    $desk_id = $userenv_desk;
72
}
73
74
$template->param( updated => \$updated );
75
76
my $referer = $query->param('oldreferer') || $ENV{HTTP_REFERER};
77
if ($updated) {
78
    print $query->redirect( $referer || '/cgi-bin/koha/mainpage.pl' );
79
}
80
81
$template->param(
82
    referer    => $referer,
83
    desks_list => $desks_lists,
84
    desk_id     => $desk_id,
85
);
86
87
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/circ/set-library.pl (-1 / +23 lines)
Lines 26-31 use C4::Auth qw/:DEFAULT get_session/; Link Here
26
use C4::Koha;
26
use C4::Koha;
27
use Koha::BiblioFrameworks;
27
use Koha::BiblioFrameworks;
28
use Koha::Libraries;
28
use Koha::Libraries;
29
use Koha::Desks;
29
30
30
my $query = CGI->new();
31
my $query = CGI->new();
31
32
Lines 42-48 my $sessionID = $query->cookie("CGISESSID"); Link Here
42
my $session = get_session($sessionID);
43
my $session = get_session($sessionID);
43
44
44
my $branch   = $query->param('branch' );
45
my $branch   = $query->param('branch' );
46
my $desk_id = $query->param('desk_id');
45
my $userenv_branch  = C4::Context->userenv->{'branch'}        || '';
47
my $userenv_branch  = C4::Context->userenv->{'branch'}        || '';
48
my $userenv_desk = C4::Context->userenv->{'desk_id'} || '';
46
my @updated;
49
my @updated;
47
50
48
# $session lddines here are doing the updating
51
# $session lddines here are doing the updating
Lines 56-66 if ( $branch and my $library = Koha::Libraries->find($branch) ) { Link Here
56
        $session->flush();
59
        $session->flush();
57
        push @updated, {
60
        push @updated, {
58
            updated_branch => 1,
61
            updated_branch => 1,
59
                old_branch => $userenv_branch,
62
            old_branch => $userenv_branch,
60
        };
63
        };
61
    } # else branch the same, no update
64
    } # else branch the same, no update
65
    if ( $desk_id && (!$userenv_desk or $userenv_desk ne $desk_id) ) {
66
        my $desk = Koha::Desks->find( { desk_id => $desk_id } );
67
        my $old_desk_name = '';
68
        if ($userenv_desk) {
69
            $old_desk_name = Koha::Desks->find( { desk_id => $userenv_desk })->desk_name;
70
        }
71
        $template->param( LoginDeskname => $desk->desk_name );
72
        $template->param( LoginDeskid => $desk->desk_id );
73
        $session->param( desk_name => $desk->desk_name );
74
        $session->param( desk_id => $desk->desk_id );
75
        $session->flush();
76
        push @updated, {
77
            updated_desk => 1,
78
            old_desk => $old_desk_name,
79
        };
80
    }
62
} else {
81
} else {
63
    $branch = $userenv_branch;  # fallback value
82
    $branch = $userenv_branch;  # fallback value
83
    $desk_id = $userenv_desk;
64
}
84
}
65
85
66
$template->param(updated => \@updated) if (scalar @updated);
86
$template->param(updated => \@updated) if (scalar @updated);
Lines 69-74 my @recycle_loop; Link Here
69
foreach ($query->param()) {
89
foreach ($query->param()) {
70
    $_ or next;                   # disclude blanks
90
    $_ or next;                   # disclude blanks
71
    $_ eq "branch"     and next;  # disclude branch
91
    $_ eq "branch"     and next;  # disclude branch
92
    $_ eq "desk_id"    and next;  # disclude desk_id
72
    $_ eq "oldreferer" and next;  # disclude oldreferer
93
    $_ eq "oldreferer" and next;  # disclude oldreferer
73
    push @recycle_loop, {
94
    push @recycle_loop, {
74
        param => $_,
95
        param => $_,
Lines 87-92 if (scalar @updated and not scalar @recycle_loop) { Link Here
87
$template->param(
108
$template->param(
88
    referer     => $referer,
109
    referer     => $referer,
89
    branch      => $branch,
110
    branch      => $branch,
111
    desk_id     => $desk_id,
90
    recycle_loop=> \@recycle_loop,
112
    recycle_loop=> \@recycle_loop,
91
);
113
);
92
114
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc (-4 lines)
Lines 1-5 Link Here
1
[% USE Branches %]
1
[% USE Branches %]
2
[% USE Desks %]
3
<div id="navmenu">
2
<div id="navmenu">
4
    <div id="navmenulist">
3
    <div id="navmenulist">
5
4
Lines 18-26 Link Here
18
            [% IF ( AutoLocation ) %][% ELSE %][% IF ( IndependentBranches ) %][% ELSE %]
17
            [% IF ( AutoLocation ) %][% ELSE %][% IF ( IndependentBranches ) %][% ELSE %]
19
                <li><a href="/cgi-bin/koha/circ/set-library.pl">Set library</a></li>
18
                <li><a href="/cgi-bin/koha/circ/set-library.pl">Set library</a></li>
20
            [% END %][% END %]
19
            [% END %][% END %]
21
            [% IF Desks.ListForLibrary.count %]
22
                <li><a href="/cgi-bin/koha/circ/selectdesk.pl">Set desk</a></li>
23
            [% END %]
24
            [% IF ( fast_cataloging ) %][% IF ( CAN_user_editcatalogue_fast_cataloging ) %]
20
            [% IF ( fast_cataloging ) %][% IF ( CAN_user_editcatalogue_fast_cataloging ) %]
25
                <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=FA">Fast cataloging</a></li>
21
                <li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=FA">Fast cataloging</a></li>
26
            [% END %][% END %]
22
            [% END %][% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc (-5 lines)
Lines 139-149 Link Here
139
                        <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set library</a>
139
                        <a class="toplinks" href="/cgi-bin/koha/circ/set-library.pl">Set library</a>
140
                    </li>
140
                    </li>
141
                    [% END %]
141
                    [% END %]
142
                    [% IF Desks.ListForLibrary.count %]
143
                    <li>
144
                        <a class="toplinks" href="/cgi-bin/koha/circ/selectdesk.pl">Set desk</a>
145
                    </li>
146
                    [% END %]
147
                    [% IF EnableSearchHistory %]
142
                    [% IF EnableSearchHistory %]
148
                    <li>
143
                    <li>
149
                        <a class="toplinks" href="/cgi-bin/koha/catalogue/search-history.pl">Search history</a>
144
                        <a class="toplinks" href="/cgi-bin/koha/catalogue/search-history.pl">Search history</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc (+11 lines)
Lines 8-13 Link Here
8
    [% END %]
8
    [% END %]
9
[% END %]
9
[% END %]
10
10
11
[% BLOCK options_for_desks %]
12
                <option id="nodesk" value="">---</option>
13
       [% FOREACH d IN desks %]
14
            [% IF d.branchcode == branch %]
15
                <option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" >[% d.desk_name | html %]</option>
16
            [% ELSE %]
17
                <option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" disabled hidden>[% d.desk_name | html %]</option>
18
            [% END%]
19
        [% END %]
20
    [% END %]
21
11
[% BLOCK options_for_authorised_value_categories %]
22
[% BLOCK options_for_authorised_value_categories %]
12
    [% FOREACH avc IN authorised_value_categories %]
23
    [% FOREACH avc IN authorised_value_categories %]
13
        [% IF avc.selected %]
24
        [% IF avc.selected %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc (+1 lines)
Lines 73-77 Link Here
73
        [% jsinclude | $raw # Parse the page template's JavaScript block if necessary %]
73
        [% jsinclude | $raw # Parse the page template's JavaScript block if necessary %]
74
    [% END %]
74
    [% END %]
75
[% KohaPlugins.get_plugins_intranet_js | $raw %]
75
[% KohaPlugins.get_plugins_intranet_js | $raw %]
76
76
</body>
77
</body>
77
</html>
78
</html>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc (+3 lines)
Lines 26-31 Link Here
26
<!-- koha core js -->
26
<!-- koha core js -->
27
[% Asset.js("js/staff-global.js") | $raw %]
27
[% Asset.js("js/staff-global.js") | $raw %]
28
[% Asset.js("js/commons.js") | $raw %]
28
[% Asset.js("js/commons.js") | $raw %]
29
[% IF setdesk %]
30
[% Asset.js("js/desk_selection.js") | $raw %]
31
[% END %]
29
32
30
[% INCLUDE 'validator-strings.inc' %]
33
[% INCLUDE 'validator-strings.inc' %]
31
[% IF ( IntranetUserJS ) %]
34
[% IF ( IntranetUserJS ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt (+16 lines)
Lines 1-8 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE Branches %]
3
[% USE Branches %]
4
[% USE Desks %]
4
[% USE Categories %]
5
[% USE Categories %]
5
[% SET footerjs = 1 %]
6
[% SET footerjs = 1 %]
7
[% IF Desks.all %]
8
    [% SET setdesk = 1 %]
9
[% END %]
6
[% INCLUDE 'doc-head-open.inc' %]
10
[% INCLUDE 'doc-head-open.inc' %]
7
<title>Koha &rsaquo; 
11
<title>Koha &rsaquo; 
8
    [% IF ( nopermission ) %]Access denied[% END %]
12
    [% IF ( nopermission ) %]Access denied[% END %]
Lines 81-86 Link Here
81
            [% END %]
85
            [% END %]
82
        </select>
86
        </select>
83
    </p>
87
    </p>
88
    [% IF Desks.all %]
89
        <p>
90
            <label for="desk">Desk:</label>
91
            <select name="desk_id" id="desk_id" class="input" tabindex="3">
92
                <option id="nodesk" value="">---</option>
93
                    [% FOREACH d IN Desks.all %]
94
                    <option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" disabled >[% d.desk_name | html %]</option>
95
                    [% END %]
96
            </select>
97
        </p>
98
</fieldset>
99
[% END %]
84
[% END %]
100
[% END %]
85
101
86
<!-- <p><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="3" />Remember me</label></p> -->
102
<!-- <p><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="3" />Remember me</label></p> -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt (-6 lines)
Lines 1-7 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE Branches %]
3
[% USE Branches %]
4
[% USE Desks %]
5
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Koha &rsaquo; Circulation</title>
5
<title>Koha &rsaquo; Circulation</title>
7
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
Lines 34-44 Link Here
34
                            <a class="circ-button" href="/cgi-bin/koha/circ/set-library.pl"><i class="fa fa-home"></i> Set library</a>
33
                            <a class="circ-button" href="/cgi-bin/koha/circ/set-library.pl"><i class="fa fa-home"></i> Set library</a>
35
                        </li>
34
                        </li>
36
                    [% END %]
35
                    [% END %]
37
                    [% IF Desks.ListForLibrary.count %]
38
                        <li>
39
                            <a class="circ-button" href="/cgi-bin/koha/circ/selectdesk.pl"><i class="fa fa-location-arrow"></i> Set desk</a>
40
                        </li>
41
                    [% END %]
42
                    [% IF ( fast_cataloging ) %]
36
                    [% IF ( fast_cataloging ) %]
43
                        [% IF ( CAN_user_editcatalogue_fast_cataloging ) %]
37
                        [% IF ( CAN_user_editcatalogue_fast_cataloging ) %]
44
                            <li>
38
                            <li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt (-2 / +18 lines)
Lines 1-5 Link Here
1
[% USE Branches %]
1
[% USE Branches %]
2
[% USE Desks %]
2
[% USE Koha %]
3
[% USE Koha %]
4
[% IF Desks.all %]
5
    [% SET setdesk = 1 %]
6
[% END %]
3
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Circulation &rsaquo; Set library</title>
8
<title>Koha &rsaquo; Circulation &rsaquo; Set library</title>
5
[% INCLUDE 'doc-head-close.inc' %]
9
[% INCLUDE 'doc-head-close.inc' %]
Lines 36-42 Link Here
36
Updated:<ul>
40
Updated:<ul>
37
    [% FOREACH update IN updated %]
41
    [% FOREACH update IN updated %]
38
    [% IF ( update.updated_branch ) %]
42
    [% IF ( update.updated_branch ) %]
39
        <li>Library: [% update.old_branch or "?" | html %] &rArr; [% update.LoginBranchcode or "?" | html %]</li>
43
        <li>Library: [% update.old_branch or "?" | html %] &rArr; [% LoginBranchcode or "?" | html %]</li>
44
    [% ELSIF (update.updated_desk) %]
45
        <li>Desk: [% update.old_desk or "?" | html %] &rArr; [% LoginDeskname or "?" | html %]</li>
40
    [% ELSE %]
46
    [% ELSE %]
41
        <li>ERROR - unknown</li>
47
        <li>ERROR - unknown</li>
42
    [% END %]
48
    [% END %]
Lines 63-73 Updated:<ul> Link Here
63
        <li><label for="branch">Choose library:</label>
69
        <li><label for="branch">Choose library:</label>
64
        <select name="branch" id="branch">
70
        <select name="branch" id="branch">
65
            [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
71
            [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
66
                        [% PROCESS options_for_yallah yallah => Branches.all( selected => branch ) %]
67
        </select></li>
72
        </select></li>
68
    [% END %]
73
    [% END %]
69
    </ol>
74
    </ol>
70
</fieldset>
75
</fieldset>
76
[% IF Desks.all %]
77
<fieldset class="rows">
78
    <legend>Set Desk</legend>
79
    <ol>
80
        <li><label for="desk">Choose Desk:</label>
81
        <select name="desk_id" id="desk_id">
82
            [% PROCESS options_for_desks desks => Desks.all( selected => desk_id ) %]
83
        </select></li>
84
    </ol>
85
</fieldset>
86
[% END %]
71
<fieldset class="action">
87
<fieldset class="action">
72
    <input type="submit" value="Submit" />
88
    <input type="submit" value="Submit" />
73
    <a class="cancel" id="cancel_set_library" href="[% referer or '/cgi-bin/koha/circ/circulation.pl' %]">Cancel</a>
89
    <a class="cancel" id="cancel_set_library" href="[% referer or '/cgi-bin/koha/circ/circulation.pl' %]">Cancel</a>
(-)a/koha-tmpl/intranet-tmpl/prog/js/desk_selection.js (-1 / +42 lines)
Line 0 Link Here
0
- 
1
$(document).ready(function() {
2
    $("#desk_id").children().each(function() {
3
        var selectedBranch = $("#branch"). children("option:selected"). val();
4
        if ($(this).attr('id') === "nodesk") { //set no desk by default, should be first element
5
            $(this).prop("selected", true);
6
            $(this).prop("disabled", false);
7
            $(this).show();
8
        }
9
        else if ($(this).hasClass(selectedBranch)) {
10
            $('#nodesk').prop("disabled", true); // we have desk, no need for nodesk option
11
            $('#nodesk').hide();
12
            $(this).prop("disabled", false);
13
            $(this).show();
14
            $(this).prop("selected", true)
15
        } else {
16
            $(this).prop("disabled", true);
17
            $(this).hide();
18
        }
19
    });
20
21
    $("#branch").on("change", function() {
22
23
        $("#desk_id").children().each(function() {
24
            var selectedBranch = $("#branch"). children("option:selected"). val();
25
            if ($(this).attr('id') === "nodesk") { //set no desk by default, should be first element
26
                $(this).prop("selected", true);
27
                $(this).prop("disabled", false);
28
                $(this).show();
29
            }
30
            else if ($(this).hasClass(selectedBranch)) {
31
                $('#nodesk').prop("disabled", true); // we have desk, no need for nodesk option
32
                $('#nodesk').hide();
33
                $(this).prop("disabled", false);
34
                $(this).show();
35
                $(this).prop("selected", true)
36
            } else {
37
                $(this).prop("disabled", true);
38
                $(this).hide();
39
            }
40
        });
41
    });
42
}) ;

Return to bug 24201