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

(-)a/circ/set-library.pl (-57 / +29 lines)
Lines 47-57 my $register_id = $query->param('register_id'); Link Here
47
my $userenv_branch      = C4::Context->userenv->{'branch'} || '';
47
my $userenv_branch      = C4::Context->userenv->{'branch'} || '';
48
my $userenv_desk        = C4::Context->userenv->{'desk_id'} || '';
48
my $userenv_desk        = C4::Context->userenv->{'desk_id'} || '';
49
my $userenv_register_id = C4::Context->userenv->{'register_id'} || '';
49
my $userenv_register_id = C4::Context->userenv->{'register_id'} || '';
50
my @updated;
50
my $updated;
51
51
52
my $library = Koha::Libraries->find($branch);
52
my $library = Koha::Libraries->find($branch);
53
# $session lines here are doing the updating
53
# $session lines here are doing the updating
54
## Please see file perltidy.ERR
55
if (
54
if (
56
       $op eq 'cud-set-library'
55
       $op eq 'cud-set-library'
57
    && $library
56
    && $library
Lines 63-138 if ( Link Here
63
        my $branchname = $library->branchname;
62
        my $branchname = $library->branchname;
64
        $session->param( 'branchname', $branchname );    # update sesssion in DB
63
        $session->param( 'branchname', $branchname );    # update sesssion in DB
65
        $session->param( 'branch',     $branch );        # update sesssion in DB
64
        $session->param( 'branch',     $branch );        # update sesssion in DB
66
        push @updated, {
65
        $updated = 1;
67
            updated_branch => 1,
68
            old_branch     => $userenv_branch,
69
            new_branch     => $branch,
70
        };
71
    }    # else branch the same, no update
72
} elsif ( $op eq 'cud-set-library' && $library ) {
73
    if ( $desk_id && ( !$userenv_desk or $userenv_desk ne $desk_id ) ) {
74
        my $desk          = Koha::Desks->find( { desk_id => $desk_id } );
75
        my $old_desk_name = '';
76
        if ($userenv_desk) {
77
            $old_desk_name = Koha::Desks->find( { desk_id => $userenv_desk } )->desk_name;
78
        }
79
        $template->param( LoginDeskname => $desk->desk_name );
80
        $template->param( LoginDeskid   => $desk->desk_id );
81
        $session->param( desk_name => $desk->desk_name );
82
        $session->param( desk_id   => $desk->desk_id );
83
        $session->flush();
84
        push @updated, {
85
            updated_desk => 1,
86
            old_desk     => $old_desk_name,
87
        };
88
    }
66
    }
89
    if ( defined($register_id)
67
} else {
90
        && ( $userenv_register_id ne $register_id ) )
68
    $branch = $userenv_branch;    # fallback value
91
    {
69
}
92
        my $old_register_name = C4::Context->userenv->{'register_name'} || '';
70
93
        my $register          = Koha::Cash::Registers->find($register_id);
71
if ( $desk_id && ( !$userenv_desk or $userenv_desk ne $desk_id ) ) {
94
        $session->param( 'register_id',   $register_id );
72
    my $desk          = Koha::Desks->find( { desk_id => $desk_id } );
95
        $session->param( 'register_name', $register ? $register->name : '' );
73
    my $old_desk_name = '';
96
        push @updated,
74
    if ($userenv_desk) {
97
            {
75
        $old_desk_name = Koha::Desks->find( { desk_id => $userenv_desk } )->desk_name;
98
            updated_register => 1,
99
            old_register     => $old_register_name
100
            };
101
    }
76
    }
102
    $session->flush();
77
    $session->param( desk_name => $desk->desk_name );
78
    $session->param( desk_id   => $desk->desk_id );
79
    $updated = 1;
103
} else {
80
} else {
104
    $branch  = $userenv_branch;    # fallback value
105
    $desk_id = $userenv_desk;
81
    $desk_id = $userenv_desk;
106
}
82
}
107
83
108
$template->param(updated => \@updated) if (scalar @updated);
84
if ( defined($register_id)
109
85
    && ( $userenv_register_id ne $register_id ) )
110
my @recycle_loop;
86
{
111
foreach my $param ($query->param()) {
87
    my $old_register_name = C4::Context->userenv->{'register_name'} || '';
112
    $param or next;                   # disclude blanks
88
    my $register          = Koha::Cash::Registers->find($register_id);
113
    $param eq "branch"     and next;  # disclude branch
89
    $session->param( 'register_id',   $register_id );
114
    $param eq "desk_id"    and next;  # disclude desk_id
90
    $session->param( 'register_name', $register ? $register->name : '' );
115
    $param eq "register_id" and next;    # disclude register
91
    $updated = 1;
116
    $param eq "oldreferer" and next;  # disclude oldreferer
92
} else {
117
    push @recycle_loop, {
93
    $register_id = $userenv_register_id;
118
        param => $param,
119
        value => scalar $query->param($param),
120
      };
121
}
94
}
122
95
123
my $referer =  $query->param('oldreferer') || $ENV{HTTP_REFERER} || '';
96
$session->flush();
124
$referer =~ /set-library\.pl/ and undef $referer;   # avoid sending them back to this same page.
125
97
126
if (scalar @updated and not scalar @recycle_loop) {
98
127
    # we updated something, and there were no extra params to POST: quick redirect
99
my $referer =  $query->param('oldreferer') || $ENV{HTTP_REFERER} || '';
128
    print $query->redirect($referer || '/cgi-bin/koha/circ/circulation.pl');
100
if ( $updated ) {
101
    print $query->redirect($referer || '/cgi-bin/koha/mainpage.pl');
129
}
102
}
130
103
131
$template->param(
104
$template->param(
132
    referer     => $referer,
105
    referer     => $referer,
133
    branch      => $branch,
106
    branch      => $branch,
134
    desk_id     => $desk_id,
107
    desk_id     => $desk_id,
135
    recycle_loop=> \@recycle_loop,
136
);
108
);
137
109
138
# Checking if there is a Fast Cataloging Framework
110
# Checking if there is a Fast Cataloging Framework
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt (-123 / +74 lines)
Lines 42-172 Link Here
42
        <div class="col-sm-12">
42
        <div class="col-sm-12">
43
            <main>
43
            <main>
44
                <div class="row">
44
                <div class="row">
45
46
                [% IF Koha.Preference('CircSidebar') %]
47
                    <div class="col-sm-10 col-sm-push-2">
48
                [% ELSE %]
49
                    <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
50
                [% END %]
51
                [% INCLUDE 'messages.inc' %]
52
                <h1>Set library</h1>
53
54
[% IF ( updated ) %]
55
56
<h2>Update succeeded</h2>
57
Updated:<ul>
58
    [% FOREACH update IN updated %]
59
    [% IF ( update.updated_branch || update.updated_desk ||  update.updated_register ) %]
60
        [% IF ( update.updated_branch ) %]
61
        <li>Library: [% update.old_branch or "?" | html %] &rArr; [% update.new_branch or "?" | html %]</li>
62
        [% END %]
63
        [% IF ( update.updated_desk ) %]
64
        <li>Desk: [% update.old_desk or "?" | html %] &rArr; [% LoginDeskname or "?" | html %]</li>
65
        [% END %]
66
        [% IF ( updated.updated_register ) %]
67
        <li>Register: [% updated.old_register or "?" | html %] &rArr; [% Registers.session_register_name or "?" | html %]</li>
68
        [% END %]
69
    [% ELSE %]
70
        <li>ERROR - unknown</li>
71
    [% END %]
72
    [% END %]
73
    </ul>
74
<form method="post" action="[% referer or "/cgi-bin/koha/circ/circulation.pl" %]">
75
    [% INCLUDE 'csrf-token.inc' %]
76
    <div class="noshow">
77
        [% FOREACH recycle_loo IN recycle_loop %]
78
            [% SET param = recycle_loo.param %]
79
            [% NEXT IF param == 'op' %]
80
            [% NEXT IF param == 'csrf_token' %]
81
            [% IF param == 'original_op' %][% param = 'op' %][% END %]
82
            <input type="text" name="[% param | html %]" value="[% recycle_loo.value | html %]" />
83
            [% IF param == 'op' %][% SET has_op = 1 %][% END %]
84
        [% END %]
85
        [% UNLESS has_op %]
86
            <input type="hidden" name="op" value="cud-no-op" /> [%# Trick to pass anti-CSRF requirements %]
87
        [% END %]
88
    </div>
89
    <button type="submit">Continue</button>
90
</form>
91
92
[% ELSE %]
93
94
<form method="post" action="set-library.pl">
95
    [% INCLUDE 'csrf-token.inc' %]
96
    <input type="hidden" name="op" value="cud-set-library" />
97
[% IF ( CAN_user_superlibrarian || CAN_user_loggedinlibrary ) %]
98
<fieldset class="rows">
99
    <legend>Set library</legend>
100
    <ol>
101
        <li><label for="branch">Choose library:</label>
102
        <select name="branch" id="branch">
103
            [% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
104
        </select></li>
105
    </ol>
106
</fieldset>
107
[% ELSE %]
108
<select name="branch" id="branch" style="visibility:hidden;">
109
    [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
110
</select>
111
[% END %]
112
113
[% IF Koha.Preference('UseCirculationDesks') && Desks.all %]
114
<fieldset class="rows">
115
    <legend>Set desk</legend>
116
    <ol>
117
        <li><label for="desk">Choose desk:</label>
118
        <select name="desk_id" id="desk_id">
119
            [% PROCESS options_for_desks desks => Desks.all(), selected => desk_id  %]
120
        </select></li>
121
    </ol>
122
</fieldset>
123
[% END %]
124
125
[% IF Koha.Preference('UseCashRegisters') %]
126
<fieldset class="rows">
127
    <legend>Set cash register</legend>
128
    <ol>
129
        <li>
130
            <label for="register_id">Choose cash register:</label>
131
            <select name="register_id" id="register_id">
132
                <option id="noregister" selected="selected" value="">-- None --</option>
133
                [% PROCESS options_for_registers registers => Registers.all() %]
134
            </select>
135
        </li>
136
    </ol>
137
</fieldset>
138
[% END %]
139
140
<fieldset class="action">
141
    <input type="submit" class="btn btn-primary" value="Submit" />
142
    <a class="cancel" id="cancel_set_library" href="[% referer or '/cgi-bin/koha/circ/circulation.pl' %]">Cancel</a>
143
</fieldset>
144
<div class="noshow">
145
    [% FOREACH recycle_loo IN recycle_loop %]
146
        [% SET param = recycle_loo.param %]
147
        [% IF param == 'op' %][% param = 'original_op' %][% END %]
148
        <input type="text" name="[% param | html %]" value="[% recycle_loo.value | html %]" />
149
    [% END %]
150
    <input type="hidden" name="oldreferer" value="[% referer or "/cgi-bin/koha/circ/circulation.pl" %]" />
151
</div>
152
</form>
153
<!-- /updated -->
154
[% END %]
155
156
                    [% IF Koha.Preference('CircSidebar') %]
45
                    [% IF Koha.Preference('CircSidebar') %]
157
                            </div> <!-- /.col-sm-10.col-sm-push-2 -->
46
                        <div class="col-sm-10 col-sm-push-2">
158
                            <div class="col-sm-2 col-sm-pull-10">
47
                    [% ELSE %]
159
                                <aside>
48
                        <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
160
                                    [% INCLUDE 'circ-nav.inc' %]
161
                                </aside>
162
                            </div> <!-- /.col-sm-2.col-sm-pull-10 -->
163
                        </div> <!-- /.row -->
164
                    [% END %]
49
                    [% END %]
50
                    [% INCLUDE 'messages.inc' %]
51
                    <h1>Set library</h1>
52
                    <form method="post" action="set-library.pl">
53
                        [% INCLUDE 'csrf-token.inc' %]
54
                        <input type="hidden" name="op" value="cud-set-library" />
55
                        [% IF ( CAN_user_superlibrarian || CAN_user_loggedinlibrary ) %]
56
                            <fieldset class="rows">
57
                                <legend>Set library</legend>
58
                                <ol>
59
                                    <li><label for="branch">Choose library:</label>
60
                                    <select name="branch" id="branch">
61
                                        [% PROCESS options_for_libraries libraries => Branches.all( selected => branch, unfiltered => 1 ) %]
62
                                    </select></li>
63
                                </ol>
64
                            </fieldset>
65
                        [% ELSE %]
66
                            <select name="branch" id="branch" style="visibility:hidden;">
67
                                [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
68
                            </select>
69
                        [% END %]
165
70
166
            </main>
71
                    [% IF Koha.Preference('UseCirculationDesks') && Desks.all %]
167
        </div> <!-- /.col-sm-12 -->
72
                        <fieldset class="rows">
168
    </div> <!-- /.row -->
73
                            <legend>Set desk</legend>
169
74
                            <ol>
75
                                <li><label for="desk_id">Choose desk:</label>
76
                                <select name="desk_id" id="desk_id">
77
                                    [% PROCESS options_for_desks desks => Desks.all(), selected => desk_id  %]
78
                                </select></li>
79
                            </ol>
80
                        </fieldset>
81
                    [% IF Koha.Preference('UseCashRegisters') %]
82
                        <fieldset class="rows">
83
                            <legend>Set cash register</legend>
84
                            <ol>
85
                                <li>
86
                                    <label for="register_id">Choose cash register:</label>
87
                                    <select name="register_id" id="register_id">
88
                                        <option id="noregister" selected="selected" value="">-- None --</option>
89
                                        [% PROCESS options_for_registers registers => Registers.all() %]
90
                                    </select>
91
                                </li>
92
                            </ol>
93
                        </fieldset>
94
                    [% END %]
95
                    <fieldset class="action">
96
                        <input type="submit" class="btn btn-primary" value="Submit" />
97
                        <a class="cancel" id="cancel_set_library" href="[% referer or '/cgi-bin/koha/mainpage.pl' %]">Cancel</a>
98
                    </fieldset>
99
                    <div class="noshow">
100
                        [% FOREACH recycle_loo IN recycle_loop %]
101
                            [% SET param = recycle_loo.param %]
102
                            [% IF param == 'op' %][% param = 'original_op' %][% END %]
103
                            <input type="text" name="[% param | html %]" value="[% recycle_loo.value | html %]" />
104
                        [% END %]
105
                        <input type="hidden" name="oldreferer" value="[% referer or "/cgi-bin/koha/mainpage.pl" %]" />
106
                    </div>
107
                </form>
108
                <!-- /updated -->
109
                [% END %]
110
                [% IF Koha.Preference('CircSidebar') %]
111
                    </div> <!-- /.col-sm-10.col-sm-push-2 -->
112
                        <div class="col-sm-2 col-sm-pull-10">
113
                            <aside>
114
                                [% INCLUDE 'circ-nav.inc' %]
115
                            </aside>
116
                        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
117
                    </div> <!-- /.row -->
118
                [% END %]
119
        </main>
120
    </div> <!-- /.col-sm-12 -->
121
</div> <!-- /.row -->
170
[% MACRO jsinclude BLOCK %]
122
[% MACRO jsinclude BLOCK %]
171
  [% Asset.js("js/desk_selection.js") | $raw %]
123
  [% Asset.js("js/desk_selection.js") | $raw %]
172
  [% Asset.js("js/register_selection.js") | $raw %]
124
  [% Asset.js("js/register_selection.js") | $raw %]
173
- 

Return to bug 36572