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

(-)a/Koha/Template/Plugin/Desks.pm (+15 lines)
Lines 87-90 sub ListForLibrary { Link Here
87
    );
87
    );
88
}
88
}
89
89
90
sub all {
91
92
    my ( $self, $params ) = @_;
93
    my $selected = $params->{selected};
94
    my $desks = Koha::Desks->search( )->unblessed;
95
    for my $d ( @$desks ) {
96
        if (       defined $selected and $d->{desk_id} eq $selected
97
                   or not defined $selected and C4::Context->userenv and $d->{branchcode} eq ( C4::Context->userenv->{desk_id} // q{} )
98
            ) {
99
            $d->{selected} = 1;
100
        }
101
    }
102
    return $desks;
103
}
104
90
1;
105
1;
(-)a/circ/set-library.pl (-1 / +21 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 ( !$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
        push @updated, {
76
            updated_desk => 1,
77
            old_desk => $old_desk_name,
78
        };
79
    }
62
} else {
80
} else {
63
    $branch = $userenv_branch;  # fallback value
81
    $branch = $userenv_branch;  # fallback value
82
    $desk_id = $userenv_desk;
64
}
83
}
65
84
66
$template->param(updated => \@updated) if (scalar @updated);
85
$template->param(updated => \@updated) if (scalar @updated);
Lines 87-92 if (scalar @updated and not scalar @recycle_loop) { Link Here
87
$template->param(
106
$template->param(
88
    referer     => $referer,
107
    referer     => $referer,
89
    branch      => $branch,
108
    branch      => $branch,
109
    desk_id     => $desk_id,
90
    recycle_loop=> \@recycle_loop,
110
    recycle_loop=> \@recycle_loop,
91
);
111
);
92
112
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc (+10 lines)
Lines 8-13 Link Here
8
    [% END %]
8
    [% END %]
9
[% END %]
9
[% END %]
10
10
11
[% BLOCK options_for_desks %]
12
        [% FOREACH d IN desks %]
13
            [% IF d.branchcode == branch %]
14
                <option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" >[% d.desk_name | html %]</option>
15
            [% ELSE %]
16
                <option class="[% d.branchcode | html %]" value="[% d.desk_id | html %]" disabled hidden>[% d.desk_name | html %]</option>
17
            [% END%]
18
        [% END %]
19
    [% END %]
20
11
[% BLOCK options_for_authorised_value_categories %]
21
[% BLOCK options_for_authorised_value_categories %]
12
    [% FOREACH avc IN authorised_value_categories %]
22
    [% FOREACH avc IN authorised_value_categories %]
13
        [% IF avc.selected %]
23
        [% 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 (+20 lines)
Lines 137-139 Link Here
137
    });
137
    });
138
    </script>
138
    </script>
139
[% END %]
139
[% END %]
140
141
[% IF setdesk %]
142
    <script  type="text/javascript">
143
    $(document).ready(function() {
144
      $("#branch").on("change", function() {
145
        var selectedBranch = $("#branch"). children("option:selected"). val();
146
        $("#desk_id").children().each(function() {
147
          if ($(this).hasClass(selectedBranch)) {
148
              $(this).prop("disabled", false);
149
              $(this).hide(true);
150
              $(this).prop("selected", true)
151
          } else {
152
              $(this).prop("disabled", true);
153
              $(this).hide(false);
154
          }
155
        });
156
      });
157
    }) ;
158
    </script>
159
[% END %]
(-)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 value="">My desk</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/set-library.tt (-3 / +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 libraries => Branches.all( selected => branch ), 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>
74
- 

Return to bug 24201