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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt (-1 / +71 lines)
Lines 2-7 Link Here
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Koha %]
3
[% USE Koha %]
4
[% USE KohaDates %]
4
[% USE KohaDates %]
5
[% USE AuthorisedValues %]
5
[% USE Price %]
6
[% USE Price %]
6
[% SET footerjs = 1 %]
7
[% SET footerjs = 1 %]
7
[% PROCESS 'accounts.inc' %]
8
[% PROCESS 'accounts.inc' %]
Lines 97-103 Link Here
97
                                    [% credit.debit.amount | $Price %]
98
                                    [% credit.debit.amount | $Price %]
98
                                </td>
99
                                </td>
99
                                <td></td>
100
                                <td></td>
100
                                <td></td>
101
                                <td>
102
                                    [% IF CAN_user_cash_management_anonymous_refund && !(credit.debit.status == 'REFUNDED' ) %]
103
                                    <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=credit.debit -%]" data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-quantity="[% credit.debit.note | html %]"><i class="fa fa-money"></i> Issue refund</button>
104
                                    [% ELSIF CAN_user_updatecharges_refund && !(credit.debit.status == 'REFUNDED') && credit.debit.borrowernumber %]
105
                                    <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#issueRefundModal" data-item="[%- PROCESS account_type_description account=credit.debit -%]" data-accountline="[% credit.debit.accountlines_id | html %]" data-amount="[% credit.debit.amount | $Price %]" data-quantity="[% credit.debit.note | html %]"><i class="fa fa-money"></i> Issue refund</button>
106
                                    [% END %]
107
                                </td>
101
                            </tr>
108
                            </tr>
102
                            [% END %]
109
                            [% END %]
103
                            [% END %]
110
                            [% END %]
Lines 166-171 Link Here
166
        </div> <!-- /.modal-dialog -->
173
        </div> <!-- /.modal-dialog -->
167
    </div> <!-- /#confirmCashupModal -->
174
    </div> <!-- /#confirmCashupModal -->
168
175
176
    <!-- Issue refund modal -->
177
    <div class="modal" id="issueRefundModal" tabindex="-1" role="dialog" aria-labelledby="issueRefundLabel">
178
        <form id="refund_form" method="post" enctype="multipart/form-data" class="validated">
179
            <input type="hidden" name="accountline" value="" id="refundline">
180
            <div class="modal-dialog" role="document">
181
                <div class="modal-content">
182
                    <div class="modal-header">
183
                        <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
184
                        <h4 class="modal-title" id="issueRefundLabel">Issue refund from <em>[% register.description | html %]</em></h4>
185
                    </div>
186
                    <div class="modal-body">
187
                        <fieldset class="rows">
188
                            <ol>
189
                                <li>
190
                                    <span id="item" class="label">Item: </span><span></span>
191
                                </li>
192
                                <li>
193
                                    <span id="paid" class="label">Amount paid: </span><span></span>
194
                                </li>
195
                                <li>
196
                                    <label class="required" for="amount">Returned to patron: </label>
197
                                    <input type="number" step="0.01" id="returned" name="amount" min="0.00" required="required">
198
                                    <span class="required">Required</span>
199
                                </li>
200
                                [% SET payment_types = [] %]
201
                                [% FOR pt IN AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
202
                                    [% NEXT IF pt.authorised_value.grep("^SIP[[:digit:]]{2}$").size() %]
203
                                    [% payment_types.push(pt) %]
204
                                [% END %]
205
                                <li>
206
                                    <label for="transaction_type">Transaction type: </label>
207
                                    <select name="transaction_type" id="transaction_type">
208
                                        [% FOREACH pt IN payment_types %]
209
                                            <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
210
                                        [% END %]
211
                                    </select>
212
                                </li>
213
                            </ol>
214
                        </fieldset> <!-- /.rows -->
215
                    </div> <!-- /.modal-body -->
216
                    <div class="modal-footer">
217
                        <input type="hidden" name="registerid" value="[% register.id | html %]">
218
                        <input type="hidden" name="op" value="refund">
219
                        <button type="submit" class="btn btn-default">Confirm</button>
220
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
221
                    </div> <!-- /.modal-footer -->
222
                </div> <!-- /.modal-content -->
223
            </div> <!-- /.modal-dialog -->
224
        </form> <!-- /#refund_form -->
225
    </div> <!-- /#issueRefundModal -->
226
169
[% MACRO jsinclude BLOCK %]
227
[% MACRO jsinclude BLOCK %]
170
    [% INCLUDE 'datatables.inc' %]
228
    [% INCLUDE 'datatables.inc' %]
171
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
229
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
Lines 190-195 Link Here
190
            }
248
            }
191
        }));
249
        }));
192
250
251
        $("#issueRefundModal").on("shown.bs.modal", function(e){
252
           var button = $(e.relatedTarget);
253
           var item = button.data('item');
254
           $("#item + span").replaceWith(item);
255
           var accountline = button.data('accountline');
256
           $('#refundline').val(accountline);
257
           var amount = button.data('amount');
258
           $("#paid + span").replaceWith(amount);
259
           $("#returned").attr({ "value": amount, "max": amount });
260
           $("#returned, #transaction_type").focus();
261
        });
262
193
        $(".printReceipt").click(function() {
263
        $(".printReceipt").click(function() {
194
            var accountlines_id = $(this).data('accountline');
264
            var accountlines_id = $(this).data('accountline');
195
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
265
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
(-)a/pos/register.pl (-1 / +34 lines)
Lines 38-43 my ( $template, $loggedinuser, $cookie, $user_flags ) = get_template_and_user( Link Here
38
    }
38
    }
39
);
39
);
40
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
40
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
41
my $schema = Koha::Database->new->schema;
41
42
42
my $library_id = C4::Context->userenv->{'branch'};
43
my $library_id = C4::Context->userenv->{'branch'};
43
my $registerid = $input->param('registerid');
44
my $registerid = $input->param('registerid');
Lines 78-83 else { Link Here
78
            }
79
            }
79
        );
80
        );
80
    }
81
    }
82
    elsif ( $op eq 'refund' ) {
83
        my $amount           = $input->param('amount');
84
        my $quantity         = $input->param('quantity');
85
        my $accountline_id   = $input->param('accountline');
86
        my $transaction_type = $input->param('transaction_type');
87
88
        my $accountline = Koha::Account::Lines->find($accountline_id);
89
        $schema->txn_do(
90
            sub {
91
92
                my $refund = $accountline->reduce(
93
                    {
94
                        reduction_type => 'Refund',
95
                        branch         => $library_id,
96
                        staff_id       => $logged_in_user->id,
97
                        interface      => 'intranet',
98
                        amount         => $amount
99
                    }
100
                );
101
                my $payout = $refund->payout(
102
                    {
103
                        payout_type   => $transaction_type,
104
                        branch        => $library_id,
105
                        staff_id      => $logged_in_user->id,
106
                        cash_register => $cash_register->id,
107
                        interface     => 'intranet',
108
                        amount        => $amount
109
                    }
110
                );
111
112
            }
113
        );
114
    }
81
}
115
}
82
116
83
output_html_with_http_headers( $input, $cookie, $template->output );
117
output_html_with_http_headers( $input, $cookie, $template->output );
84
- 

Return to bug 24082