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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt (-1 / +76 lines)
Lines 97-103 Link Here
97
                                    [% credit.debit.amount | $Price %]
97
                                    [% credit.debit.amount | $Price %]
98
                                </td>
98
                                </td>
99
                                <td></td>
99
                                <td></td>
100
                                <td></td>
100
                                <td>
101
                                    [% IF CAN_user_cash_management_anonymous_refund && !(credit.debit.status == 'REFUNDED' ) %]
102
                                    <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>
103
                                    [% ELSIF CAN_user_updatecharges_refund && !(credit.debit.status == 'REFUNDED') && credit.debit.borrowernumber %]
104
                                    <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>
105
                                    [% END %]
106
                                </td>
101
                            </tr>
107
                            </tr>
102
                            [% END %]
108
                            [% END %]
103
                            [% END %]
109
                            [% END %]
Lines 147-152 Link Here
147
        </div>
153
        </div>
148
    </div><!-- /.row -->
154
    </div><!-- /.row -->
149
155
156
    <!-- Issue refund modal -->
157
    <div class="modal" id="issueRefundModal" tabindex="-1" role="dialog" aria-labelledby="issueRefundLabel">
158
        <form id="refund_form" method="post" enctype="multipart/form-data" class="validated">
159
            <input type="hidden" name="accountline" value="" id="refundline">
160
            <div class="modal-dialog" role="document">
161
                <div class="modal-content">
162
                    <div class="modal-header">
163
                        <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
164
                        <h4 class="modal-title" id="issueRefundLabel">Issue refund from <em>[% register.name | html %]</em></h4>
165
                    </div>
166
                    <div class="modal-body">
167
                        <fieldset class="rows">
168
                            <ol>
169
                                <li>
170
                                    <span id="item" class="label">Item: </span><span></span>
171
                                </li>
172
                                <li>
173
                                    <span id="paid" class="label">Amount paid: </span><span>[% refund.amount | $Price %]</span>
174
                                </li>
175
                                <li>
176
                                    <label class="required" for="amount">Returned to patron: </label>
177
                                    <input type="number" step="0.01" max="[% refund.amount | $Price %]" id="amount" name="amount" value="[% refund.amount | $Price %]" required="required">
178
                                    <span class="required">Required</span>
179
                                </li>
180
                                <li>
181
                                    <label class="required" for="quantity">Quantity: </label>
182
                                    <input type="text" id="quantity" name="quantity" value="[% refund.quantity | html %]" required="required">
183
                                    <span class="required">Required</span>
184
                                </li>
185
                                [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
186
                                [% IF payment_types %]
187
                                <li>
188
                                    <label for="transaction_type">Transaction type: </label>
189
                                    <select name="transaction_type" id="transaction_type">
190
                                        [% FOREACH pt IN payment_types %]
191
                                            <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
192
                                        [% END %]
193
                                    </select>
194
                                </li>
195
                                [% END %]
196
                            </ol>
197
                        </fieldset> <!-- /.rows -->
198
                    </div> <!-- /.modal-body -->
199
                    <div class="modal-footer">
200
                        <input type="hidden" name="registerid" value="[% register.id | html %]">
201
                        <input type="hidden" name="op" value="refund">
202
                        <button type="submit" class="btn btn-default">Confirm</button>
203
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
204
                    </div> <!-- /.modal-footer -->
205
                </div> <!-- /.modal-content -->
206
            </div> <!-- /.modal-dialog -->
207
        </form> <!-- /#refund_form -->
208
    </div> <!-- /#issueRefundModal -->
209
150
[% MACRO jsinclude BLOCK %]
210
[% MACRO jsinclude BLOCK %]
151
    [% INCLUDE 'datatables.inc' %]
211
    [% INCLUDE 'datatables.inc' %]
152
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
212
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
Lines 171-176 Link Here
171
            }
231
            }
172
        }));
232
        }));
173
233
234
        $("#issueRefundModal").on("shown.bs.modal", function(e){
235
           var button = $(e.relatedTarget);
236
           var item = button.data('item');
237
           $("#item + span").replaceWith(item);
238
           var accountline = button.data('accountline');
239
           $('#refundline').val(accountline);
240
           var amount = button.data('amount');
241
           $("#paid + span").replaceWith(amount);
242
           $("#amount").val(amount);
243
           $("#amount").attr("max", amount);
244
           var quantity = button.data('quantity');
245
           $("#quantity").val(quantity);
246
           $("#amount, #quantity, #transaction_type").focus();
247
        });
248
174
        $(".printReceipt").click(function() {
249
        $(".printReceipt").click(function() {
175
            var accountlines_id = $(this).data('accountline');
250
            var accountlines_id = $(this).data('accountline');
176
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
251
            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