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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt (-4 / +58 lines)
Lines 90-95 Link Here
90
        [% IF CAN_user_updatecharges_refund && account.is_debit && ( account.amountoutstanding != account.amount ) && !(account.status == 'REFUNDED') && !(account.debit_type_code == 'PAYOUT') %]
90
        [% IF CAN_user_updatecharges_refund && account.is_debit && ( account.amountoutstanding != account.amount ) && !(account.status == 'REFUNDED') && !(account.debit_type_code == 'PAYOUT') %]
91
          <button type="button" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=account -%]" data-accountline="[% account.accountlines_id | html %]" data-amount="[% account.amount | $Price %]" data-amountoutstanding="[% account.amountoutstanding | $Price %]" class="btn btn-default btn-xs"><i class="fa fa-money"></i> Issue refund</button>
91
          <button type="button" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=account -%]" data-accountline="[% account.accountlines_id | html %]" data-amount="[% account.amount | $Price %]" data-amountoutstanding="[% account.amountoutstanding | $Price %]" class="btn btn-default btn-xs"><i class="fa fa-money"></i> Issue refund</button>
92
        [% END %]
92
        [% END %]
93
        [% IF CAN_user_updatecharges_discount && account.is_debit && ( account.amountoutstanding == account.amount ) && !(account.debit_type_code == 'PAYOUT') %]
94
          <button type="button" data-toggle="modal" data-target="#applyDiscountModal" data-item="[%- PROCESS account_type_description account=account -%]" data-accountline="[% account.accountlines_id | html %]" data-amount="[% account.amount | $Price %]" data-amountoutstanding="[% account.amountoutstanding | $Price %]" class="btn btn-default btn-xs"><i class="fa fa-percent"></i> Apply discount</button>
95
        [% END %]
93
      </td>
96
      </td>
94
    </tr>
97
    </tr>
95
98
Lines 147-153 Link Here
147
                                [% IF payment_types > 3 %]
150
                                [% IF payment_types > 3 %]
148
                                <li>
151
                                <li>
149
                                    <label for="transaction_type">Transaction type: </label>
152
                                    <label for="transaction_type">Transaction type: </label>
150
                                    <select name="transaction_type" id="transaction_type">
153
                                    <select name="transaction_type" id="payout_transaction_type">
151
                                        [% FOREACH pt IN payment_types %]
154
                                        [% FOREACH pt IN payment_types %]
152
                                            [% UNLESS excluded.grep("^$pt.authorised_value\$").size %]
155
                                            [% UNLESS excluded.grep("^$pt.authorised_value\$").size %]
153
                                            <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
156
                                            <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
Lines 214-220 Link Here
214
                                [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
217
                                [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
215
                                <li>
218
                                <li>
216
                                    <label for="transaction_type">Transaction type: </label>
219
                                    <label for="transaction_type">Transaction type: </label>
217
                                    <select name="transaction_type" id="transaction_type">
220
                                    <select name="transaction_type" id="refund_transaction_type">
218
                                        <option value="AC">Account credit</option>
221
                                        <option value="AC">Account credit</option>
219
                                        [% IF payment_types %]
222
                                        [% IF payment_types %]
220
                                        [% FOREACH pt IN payment_types %]
223
                                        [% FOREACH pt IN payment_types %]
Lines 252-257 Link Here
252
        </form> <!-- /#refund_form -->
255
        </form> <!-- /#refund_form -->
253
    </div> <!-- /#issueRefundModal -->
256
    </div> <!-- /#issueRefundModal -->
254
257
258
    <!-- Apply discount modal -->
259
    <div class="modal" id="applyDiscountModal" tabindex="-1" role="dialog" aria-labelledby="applyDiscountLabel">
260
        <form  id="discount_form" action="/cgi-bin/koha/members/boraccount.pl" method="get" enctype="multipart/form-data" class="validated">
261
            <input type="hidden" name="accountlines_id" value="" id="discountline">
262
            <input type="hidden" name="action" value="discount">
263
            <input type="hidden" name="borrowernumber" value="[% account.borrowernumber | html %]">
264
            <div class="modal-dialog" role="document">
265
                <div class="modal-content">
266
                    <div class="modal-header">
267
                        <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
268
                        <h4 class="modal-title" id="applyDiscountLabel">Apply discount</h4>
269
                    </div>
270
                    <div class="modal-body">
271
                        <fieldset class="rows">
272
                            <ol>
273
                                <li>
274
                                    <span id="item" class="label">Account type: </span><span></span>
275
                                </li>
276
                                <li>
277
                                    <span id="charged" class="label">Amount charged: </span><span></span>
278
                                </li>
279
                                <li>
280
                                    <label class="required" for="amount">Discount to apply: </label>
281
                                    <input type="number" step="0.01" id="discount" name="amount" min="0.00" required="required">
282
                                    <span class="required">Required</span>
283
                                </li>
284
                            </ol>
285
                        </fieldset> <!-- /.rows -->
286
                    </div> <!-- /.modal-body -->
287
                    <div class="modal-footer">
288
                        <input type="hidden" name="op" value="discount">
289
                        <button type="submit" class="btn btn-default">Confirm</button>
290
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
291
                    </div> <!-- /.modal-footer -->
292
                </div> <!-- /.modal-content -->
293
            </div> <!-- /.modal-dialog -->
294
        </form> <!-- /#discount_form -->
295
    </div> <!-- /#applyDiscountModal -->
296
255
[% MACRO jsinclude BLOCK %]
297
[% MACRO jsinclude BLOCK %]
256
    [% INCLUDE 'datatables.inc' %]
298
    [% INCLUDE 'datatables.inc' %]
257
    [% INCLUDE 'columns_settings.inc' %]
299
    [% INCLUDE 'columns_settings.inc' %]
Lines 304-310 Link Here
304
                var amount = button.data('amount') * -1;
346
                var amount = button.data('amount') * -1;
305
                $("#paid + span").replaceWith(amount);
347
                $("#paid + span").replaceWith(amount);
306
                $("#amount").attr({ "value": amount, "max": amount });
348
                $("#amount").attr({ "value": amount, "max": amount });
307
                $("#amount, #transaction_type").focus();
349
                $("#amount, #payout_transaction_type").focus();
308
            });
350
            });
309
351
310
            $("#issueRefundModal").on("shown.bs.modal", function(e){
352
            $("#issueRefundModal").on("shown.bs.modal", function(e){
Lines 318-324 Link Here
318
                var paid = amount - amountoutstanding;
360
                var paid = amount - amountoutstanding;
319
                $("#paid + span").replaceWith(paid);
361
                $("#paid + span").replaceWith(paid);
320
                $("#returned").attr({ "value": paid, "max": paid });
362
                $("#returned").attr({ "value": paid, "max": paid });
321
                $("#returned, #transaction_type").focus();
363
                $("#returned, #refund_transaction_type").focus();
364
            });
365
            
366
            $("#applyDiscountModal").on("shown.bs.modal", function(e){
367
                var button = $(e.relatedTarget);
368
                var item = button.data('item');
369
                $("#item + span").replaceWith(item);
370
                var accountline = button.data('accountline');
371
                $('#discountline').val(accountline);
372
                var amount = button.data('amount');
373
                $("#charged + span").replaceWith(amount);
374
                $("#discount").attr({ "max": amount });
375
                $("#discount").focus();
322
            });
376
            });
323
        });
377
        });
324
    </script>
378
    </script>
(-)a/members/boraccount.pl (-1 / +20 lines)
Lines 151-156 if ( $action eq 'refund' ) { Link Here
151
    );
151
    );
152
}
152
}
153
153
154
if ( $action eq 'discount' ) {
155
    my $charge_id        = scalar $input->param('accountlines_id');
156
    my $charge           = Koha::Account::Lines->find($charge_id);
157
    my $amount           = scalar $input->param('amount');
158
    $schema->txn_do(
159
        sub {
160
161
            my $discount = $charge->reduce(
162
                {
163
                    reduction_type => 'DISCOUNT',
164
                    branch         => $library_id,
165
                    staff_id       => $logged_in_user->id,
166
                    interface      => 'intranet',
167
                    amount         => $amount
168
                }
169
            );
170
        }
171
    );
172
}
173
154
#get account details
174
#get account details
155
my $total = $patron->account->balance;
175
my $total = $patron->account->balance;
156
176
157
- 

Return to bug 24081