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 147-152 Link Here
147
        </div>
154
        </div>
148
    </div><!-- /.row -->
155
    </div><!-- /.row -->
149
156
157
    <!-- Issue refund modal -->
158
    <div class="modal" id="issueRefundModal" tabindex="-1" role="dialog" aria-labelledby="issueRefundLabel">
159
        <form id="refund_form" method="post" enctype="multipart/form-data" class="validated">
160
            <input type="hidden" name="accountline" value="" id="refundline">
161
            <div class="modal-dialog" role="document">
162
                <div class="modal-content">
163
                    <div class="modal-header">
164
                        <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
165
                        <h4 class="modal-title" id="issueRefundLabel">Issue refund from <em>[% register.description | html %]</em></h4>
166
                    </div>
167
                    <div class="modal-body">
168
                        <fieldset class="rows">
169
                            <ol>
170
                                <li>
171
                                    <span id="item" class="label">Item: </span><span></span>
172
                                </li>
173
                                <li>
174
                                    <span id="paid" class="label">Amount paid: </span><span></span>
175
                                </li>
176
                                <li>
177
                                    <label class="required" for="amount">Returned to patron: </label>
178
                                    <input type="number" step="0.01" id="returned" name="amount" min="0.00" required="required">
179
                                    <span class="required">Required</span>
180
                                </li>
181
                                [% SET payment_types = [] %]
182
                                [% FOR pt IN AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
183
                                    [% NEXT IF pt.authorised_value.grep("^SIP[[:digit:]]{2}$").size() %]
184
                                    [% payment_types.push(pt) %]
185
                                [% END %]
186
                                <li>
187
                                    <label for="transaction_type">Transaction type: </label>
188
                                    <select name="transaction_type" id="transaction_type">
189
                                        [% FOREACH pt IN payment_types %]
190
                                            <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
191
                                        [% END %]
192
                                    </select>
193
                                </li>
194
                            </ol>
195
                        </fieldset> <!-- /.rows -->
196
                    </div> <!-- /.modal-body -->
197
                    <div class="modal-footer">
198
                        <input type="hidden" name="registerid" value="[% register.id | html %]">
199
                        <input type="hidden" name="op" value="refund">
200
                        <button type="submit" class="btn btn-default">Confirm</button>
201
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
202
                    </div> <!-- /.modal-footer -->
203
                </div> <!-- /.modal-content -->
204
            </div> <!-- /.modal-dialog -->
205
        </form> <!-- /#refund_form -->
206
    </div> <!-- /#issueRefundModal -->
207
150
[% MACRO jsinclude BLOCK %]
208
[% MACRO jsinclude BLOCK %]
151
    [% INCLUDE 'datatables.inc' %]
209
    [% INCLUDE 'datatables.inc' %]
152
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
210
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
Lines 171-176 Link Here
171
            }
229
            }
172
        }));
230
        }));
173
231
232
        $("#issueRefundModal").on("shown.bs.modal", function(e){
233
           var button = $(e.relatedTarget);
234
           var item = button.data('item');
235
           $("#item + span").replaceWith(item);
236
           var accountline = button.data('accountline');
237
           $('#refundline').val(accountline);
238
           var amount = button.data('amount');
239
           $("#paid + span").replaceWith(amount);
240
           $("#returned").attr({ "value": amount, "max": amount });
241
           $("#returned, #transaction_type").focus();
242
        });
243
174
        $(".printReceipt").click(function() {
244
        $(".printReceipt").click(function() {
175
            var accountlines_id = $(this).data('accountline');
245
            var accountlines_id = $(this).data('accountline');
176
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
246
            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 39-44 my ( $template, $loggedinuser, $cookie, $user_flags ) = get_template_and_user( Link Here
39
    }
39
    }
40
);
40
);
41
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
41
my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
42
my $schema = Koha::Database->new->schema;
42
43
43
my $library_id = C4::Context->userenv->{'branch'};
44
my $library_id = C4::Context->userenv->{'branch'};
44
my $registerid = $input->param('registerid');
45
my $registerid = $input->param('registerid');
Lines 79-84 else { Link Here
79
            }
80
            }
80
        );
81
        );
81
    }
82
    }
83
    elsif ( $op eq 'refund' ) {
84
        my $amount           = $input->param('amount');
85
        my $quantity         = $input->param('quantity');
86
        my $accountline_id   = $input->param('accountline');
87
        my $transaction_type = $input->param('transaction_type');
88
89
        my $accountline = Koha::Account::Lines->find($accountline_id);
90
        $schema->txn_do(
91
            sub {
92
93
                my $refund = $accountline->reduce(
94
                    {
95
                        reduction_type => 'Refund',
96
                        branch         => $library_id,
97
                        staff_id       => $logged_in_user->id,
98
                        interface      => 'intranet',
99
                        amount         => $amount
100
                    }
101
                );
102
                my $payout = $refund->payout(
103
                    {
104
                        payout_type   => $transaction_type,
105
                        branch        => $library_id,
106
                        staff_id      => $logged_in_user->id,
107
                        cash_register => $cash_register->id,
108
                        interface     => 'intranet',
109
                        amount        => $amount
110
                    }
111
                );
112
113
            }
114
        );
115
    }
82
}
116
}
83
117
84
output_html_with_http_headers( $input, $cookie, $template->output );
118
output_html_with_http_headers( $input, $cookie, $template->output );
85
- 

Return to bug 24082