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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+6 lines)
Lines 213-218 Patrons: Link Here
213
               yes: Allow only superlibrarians
213
               yes: Allow only superlibrarians
214
               no: Allow all permitted users
214
               no: Allow all permitted users
215
         - "to access/change superlibrarian privileges. Note: A permitted user needs to have the 'permissions' flag (if no superlibrarian)."
215
         - "to access/change superlibrarian privileges. Note: A permitted user needs to have the 'permissions' flag (if no superlibrarian)."
216
     -
217
         - pref: FineChange
218
           choices:
219
               yes: Enable
220
               no: Disable
221
         - fine change display when a user pays a fine.
216
    Privacy:
222
    Privacy:
217
     -
223
     -
218
         - Use the following URL
224
         - Use the following URL
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt (-41 / +39 lines)
Lines 1-7 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Koha %]
3
[% USE Koha %]
4
[% USE Price %]
5
[% USE Branches %]
4
[% USE Branches %]
6
[% USE AuthorisedValues %]
5
[% USE AuthorisedValues %]
7
[% USE Price %]
6
[% USE Price %]
Lines 71-85 Link Here
71
    <form name="payform" id="payform" action="/cgi-bin/koha/members/paycollect.pl" method="post">
70
    <form name="payform" id="payform" action="/cgi-bin/koha/members/paycollect.pl" method="post">
72
[% END %]
71
[% END %]
73
72
74
[% IF (give_change) %]
75
    <div id="change_message" class="dialog message">
76
        <span>The amount collected is greater than the total amount paid.</span><br />
77
        <strong>Change to give back: [% give_change | $Price %]</strong><br /><br />
78
        <input type="submit" name="submitbutton" value="Confirm payment" />
79
        <a class="cancel" href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber %]">Cancel</a>
80
     </div>
81
[% END %]
82
83
[% IF ( pay_individual ) %]
73
[% IF ( pay_individual ) %]
84
    <form name="payindivfine" id="payindivfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
74
    <form name="payindivfine" id="payindivfine" method="post" action="/cgi-bin/koha/members/paycollect.pl">
85
    <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
75
    <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
Lines 117-147 Link Here
117
</table>
107
</table>
118
108
119
<ol>
109
<ol>
120
    [% IF ( give_change ) %]
110
    [% IF FineChange %]
121
    <li>
111
    <li>
122
        <label for="paid">Amount paid:</label>
112
        <label for="paid">Amount paid:</label>
123
        <input type="hidden" name="paid" id="paid" value="[% amount_paid %]" />
113
        <input name="paid" id="paid" value="[% amountoutstanding | $Price %]"/>
124
        <input type="hidden" name="collected" id="collected" value="[% amount_paid %]" />
125
        [% amount_paid | $Price %]
126
    </li>
114
    </li>
127
    <li>
115
    <li>
128
        <label>Collect from patron:</label>
116
        <label for="collected">Collect from patron:</label>
129
        [% amount_collected | $Price %]
117
        <input name="collected" id="collected" value="[% amountoutstanding | $Price %]"/>
130
    </li>
118
    </li>
131
    <li>
119
    <li>
132
        <label>Change to give back:</label>
120
        <label>Change to give back:</label>
133
        [% give_change | $Price %]
121
        <input id="change" value="0.00" disabled/>
134
    </li>
122
    </li>
135
    [% ELSE %]
123
    [% ELSE %]
136
    <li>
124
    <li>
137
        <label for="paid">Amount paid:</label>
125
        <label for="paid">Collect from patron:</label>
138
        <input name="paid" id="paid" value="[% amountoutstanding | format('%.2f') %]" onchange="moneyFormat(document.payform.paid)"/>
126
        <input name="paid" id="collected" value="[% amountoutstanding | $Price %]"/>
139
        [% amount_paid | $Price %]
140
    </li>
141
    <li>
142
        <label for="collected">Collect from patron:</label>
143
        <input name="collected" id="collected" value="[% amountoutstanding %]" onchange="moneyFormat(document.payform.collected)" />
144
    </li>
127
    </li>
128
    [% END %]
145
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
129
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
146
    [% IF payment_types %]
130
    [% IF payment_types %]
147
        <li>
131
        <li>
Lines 154-160 Link Here
154
            </select>
138
            </select>
155
        </li>
139
        </li>
156
    [% END %]
140
    [% END %]
157
    [% END %]
158
</ol>
141
</ol>
159
</fieldset>
142
</fieldset>
160
143
Lines 231-265 Link Here
231
            <span class="label">Total amount outstanding: </span>
214
            <span class="label">Total amount outstanding: </span>
232
            <span class="debit">[% total | $Price %]</span>
215
            <span class="debit">[% total | $Price %]</span>
233
        </li>
216
        </li>
234
    [% IF ( give_change ) %]
217
    [% IF FineChange %]
235
    <li>
218
    <li>
236
        <label for="paid">Amount paid:</label>
219
        <label for="paid">Amount paid :</label>
237
        <input type="hidden" name="paid" id="paid" value="[% amount_paid %]" />
220
        <input name="paid" id="paid" value="[% total | $Price %]"/>
238
        [% amount_paid | $Price %]
239
    </li>
221
    </li>
240
    <li>
222
    <li>
241
        <label>Collected from patron:</label>
223
        [% IF type == 'writeoff' %]
242
        <input type="hidden" name="collected" id="collected" value="[% amount_paid %]" />
224
            <label for="collected">Writeoff amount: </label>
243
        [% amount_collected | $Price %]
225
        [% ELSE %]
226
            <label for="collected">Collect from patron: </label>
227
        [% END %]
228
        <!-- default to paying all -->
229
        <input name="collected" id="collected" value="[% total | $Price %]"/>
244
    </li>
230
    </li>
245
    <li>
231
    <li>
246
        <label>Change to give back:</label>
232
        <label>Change to give back:</label>
247
        [% give_change | $Price %]
233
        <input id="change" value="0.00" disabled/>
248
    </li>
234
    </li>
249
    [% ELSE %]
235
    [% ELSE %]
250
    <li>
236
    <li>
251
        <label for="paid">Amount paid :</label>
252
        <input name="paid" id="paid" value="[% total %]" onchange="moneyFormat(document.payform.paid)" />
253
    </li>
254
    <li>
255
        [% IF type == 'writeoff' %]
237
        [% IF type == 'writeoff' %]
256
            <label for="collected">Writeoff amount: </label>
238
            <label for="paid">Writeoff amount: </label>
257
        [% ELSE %]
239
        [% ELSE %]
258
            <label for="collected">Collect from patron: </label>
240
            <label for="paid">Collect from patron: </label>
259
        [% END %]
241
        [% END %]
260
        <!-- default to paying all -->
242
        <!-- default to paying all -->
261
        <input name="collected" id="collected" value="[% total %]" onchange="moneyFormat(document.payform.collected)"/>
243
        <input name="paid" id="paid" value="[% total | $Price %]"/>
262
    </li>
244
    </li>
245
    [% END %]
263
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
246
    [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
264
    [% IF payment_types %]
247
    [% IF payment_types %]
265
        <li>
248
        <li>
Lines 272-278 Link Here
272
            </select>
255
            </select>
273
        </li>
256
        </li>
274
    [% END %]
257
    [% END %]
275
    [% END %]
276
    <li>
258
    <li>
277
        <label for="selected_accts_notes">Note: </label>
259
        <label for="selected_accts_notes">Note: </label>
278
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes | html %]</textarea>
260
        <textarea name="selected_accts_notes" id="selected_accts_notes">[% selected_accts_notes | html %]</textarea>
Lines 302-307 Link Here
302
            $('#payindivfine, #payfine, #payform').preventDoubleFormSubmit();
284
            $('#payindivfine, #payfine, #payform').preventDoubleFormSubmit();
303
            $("#paid").on("change",function(){
285
            $("#paid").on("change",function(){
304
                moneyFormat( this );
286
                moneyFormat( this );
287
                updateChangeInput();
288
            });
289
            $("#collected").on("change",function(){
290
                moneyFormat( this );
291
                updateChangeInput();
305
            });
292
            });
306
        });
293
        });
307
294
Lines 371-376 Link Here
371
358
372
            textObj.value = dolAmount + "." + decAmount;
359
            textObj.value = dolAmount + "." + decAmount;
373
        }
360
        }
361
362
        function updateChangeInput() {
363
            var change = $('#change')[0];
364
            change.value = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
365
366
            if (change.value < 0) {
367
                change.value = change.defaultValue;
368
            } else {
369
                moneyFormat(change);
370
            }
371
        }
374
    </script>
372
    </script>
375
[% END %]
373
[% END %]
376
374
(-)a/members/paycollect.pl (-16 / +3 lines)
Lines 61-66 my $user = $input->remote_user; Link Here
61
my $branch    = C4::Context->userenv->{'branch'};
61
my $branch    = C4::Context->userenv->{'branch'};
62
my $total_due = $patron->account->outstanding_debits->total_outstanding;
62
my $total_due = $patron->account->outstanding_debits->total_outstanding;
63
63
64
my $fine_change = C4::Context->preference('FineChange');
64
my $total_paid = $input->param('paid');
65
my $total_paid = $input->param('paid');
65
my $total_collected = $input->param('collected');
66
my $total_collected = $input->param('collected');
66
67
Lines 112-135 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
112
            error_negative => 1,
113
            error_negative => 1,
113
        );
114
        );
114
    }
115
    }
115
    elsif (($total_collected - $total_paid) < 0) {
116
    elsif ($fine_change and ($total_collected - $total_paid) < 0) {
116
        $template->param(
117
        $template->param(
117
            error_collected_less => 1,
118
            error_collected_less => 1,
118
        );
119
        );
119
    }
120
    elsif ($total_paid >=  $total_due and $total_collected ne $total_paid) {
121
        $template->param(
122
            amount_paid => $total_due,
123
            amount_collected => $total_collected,
124
            give_change => $total_collected-$total_due,
125
        );
126
    }
127
    elsif ($total_paid < $total_due and $total_collected ne $total_paid) {
128
         $template->param(
129
            amount_paid => $total_paid,
130
            amount_collected => $total_collected,
131
            give_change => $total_collected-$total_paid,
132
        );
133
    } else {
120
    } else {
134
        die "Wrong CSRF token"
121
        die "Wrong CSRF token"
135
            unless Koha::Token->new->check_csrf( {
122
            unless Koha::Token->new->check_csrf( {
Lines 213-218 $template->param( Link Here
213
    patron        => $patron,
200
    patron        => $patron,
214
    total         => $total_due,
201
    total         => $total_due,
215
    ExtendedPatronAttributes => C4::Context->preference('ExtendedPatronAttributes'),
202
    ExtendedPatronAttributes => C4::Context->preference('ExtendedPatronAttributes'),
203
    FineChange => $fine_change,
216
204
217
    csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
205
    csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
218
);
206
);
219
- 

Return to bug 11373