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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt (+142 lines)
Lines 145-150 Link Here
145
                </tfoot>
145
                </tfoot>
146
            </table>
146
            </table>
147
            [% END %]
147
            [% END %]
148
149
            [% IF register.cashups %]
150
            <h2>Older transactions</h2>
151
            <form method="GET" action="/cgi-bin/koha/pos/register.pl">
152
			<fieldset class="rows">
153
                            Please select a date range to display transactions for:
154
                            <ol>
155
                                <li>
156
                                    <label for="trange_f">From: </label>
157
                                    <input type="text" size="10" id="from" name="trange_f" value="[% trange_f | html %]"/>
158
                                    <label class="inline" for="trange_t">To: </label>
159
                                    [% IF trange_t %]
160
                                    <input size="10" id="to" name="trange_t" value="[% trange_t | html %]" type="text"/>
161
                                    [% ELSE %]
162
                                    <input size="10" id="to" name="trange_t" value="[% register.last_cashup.timestamp | $KohaDates with_hours => 0, dateformat => 'metric' %]" type="text"/>
163
                                    [% END %]
164
                                    <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
165
                                </li>
166
                            </ol>
167
			</fieldset>
168
169
            <div class="action">
170
	            <input type="hidden" name="registerid" value="[% register.id | html %]">
171
	            <input type="submit" value="Display" />
172
            </div>
173
            </form>
174
175
            [% IF trange_f %]
176
            <table id="past_sales" class="past_sales_table">
177
                <thead>
178
                    <th>
179
                        ID
180
                    </th>
181
                    <th>
182
                        DATA
183
                    </th>
184
                    <th>
185
                        Transaction
186
                    </th>
187
                    <th>
188
                        Description
189
                    </th>
190
                    <th>
191
                        Price
192
                    </th>
193
                    <th>
194
                        Total
195
                    </th>
196
                    <th>
197
                        Actions
198
                    </th>
199
                </thead>
200
                <tbody>
201
                    [% FOREACH accountline IN past_accountlines %]
202
                        [% IF accountline.is_credit %]
203
                            [% FOREACH credit IN accountline.credit_offsets %]
204
                            [% IF credit.debit %]
205
                            <tr>
206
                                <td>[% accountline.accountlines_id %]</td>
207
                                <td>{ "type": "credit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
208
                                <td></td>
209
                                <td>[%- PROCESS account_type_description account=credit.debit -%]
210
                                    [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
211
                                    [%- IF ( credit.debit.itemnumber ) -%] (<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% credit.debit.item.biblionumber | uri %]&amp;itemnumber=[% credit.debit.itemnumber | uri %]">[% credit.debit.item.biblio.title | html %]</a>)[%- END -%]
212
                                </td>
213
                                <td>[% credit.debit.amount | $Price %]</td>
214
                                <td></td>
215
                                <td>
216
                                    [% IF CAN_user_cash_management_refund_cash_registers && !(credit.debit.status == 'REFUNDED' ) %]
217
                                    <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>
218
                                    [% END %]
219
                                </td>
220
                            </tr>
221
                            [% END %]
222
                            [% END %]
223
                        [% ELSE %]
224
                            [% FOREACH debit IN accountline.debit_offsets %]
225
                            [% IF debit.credit %]
226
                            <tr>
227
                                <td>[% accountline.accountlines_id %]</td>
228
                                <td>{ "type": "debit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
229
                                <td></td>
230
                                <td>[%- PROCESS account_type_description account=debit.credit -%]</td>
231
                                <td>[%- IF debit.credit.description %][% debit.credit.description | html %][% END %]
232
        &nbsp;[% IF ( debit.credit.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% debit.credit.item.biblionumber | uri %]&amp;itemnumber=[% debit.credit.itemnumber | uri %]">[% debit.credit.item.biblio.title | html %]</a>[% END %]</td>
233
                                <td>[% debit.credit.amount | $Price %]</td>
234
                                <td></td>
235
                            </tr>
236
                            [% END %]
237
                            [% END %]
238
                        [% END %]
239
                    [% END %]
240
                </tbody>
241
                <tfoot>
242
                    <tr>
243
                        <td colspan="5">Total income: </td>
244
                        <td>[% past_accountlines.total * -1 | $Price %]</td>
245
                        <td></td>
246
                    </tr>
247
                </tfoot>
248
            </table>
249
            [% END %]
250
251
            [% END %]
148
        </div>
252
        </div>
149
253
150
        <div class="col-sm-2 col-sm-pull-10">
254
        <div class="col-sm-2 col-sm-pull-10">
Lines 208-213 Link Here
208
[% MACRO jsinclude BLOCK %]
312
[% MACRO jsinclude BLOCK %]
209
    [% INCLUDE 'datatables.inc' %]
313
    [% INCLUDE 'datatables.inc' %]
210
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
314
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
315
    [% INCLUDE 'calendar.inc' %]
211
    <script>
316
    <script>
212
        var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
317
        var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
213
            orderFixed: [ 0, 'asc'],
318
            orderFixed: [ 0, 'asc'],
Lines 229-234 Link Here
229
            }
334
            }
230
        }));
335
        }));
231
336
337
        var past_sales_table = $("#past_sales").dataTable($.extend(true, {}, dataTablesDefaults, {
338
            orderFixed: [ 0, 'asc'],
339
            columnDefs: [ {
340
                targets: [ 0, 1 ],
341
                visible: false
342
            }],
343
            rowGroup: {
344
                dataSrc: 0,
345
                startRender: function ( rows, group ) {
346
                    var details = JSON.parse(rows.data().pluck(1).pop());
347
                    return $('<tr class="'+details.type+'"/>')
348
                        .append( '<td>'+group+'</td>' )
349
                        .append( '<td colspan="2">'+details.description+'</td>' )
350
                        .append( '<td>'+details.amount+'</td>' )
351
                        .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> Print receipt</button></td>');
352
                },
353
                endRender: null,
354
            }
355
        }));
356
232
        $("#issueRefundModal").on("shown.bs.modal", function(e){
357
        $("#issueRefundModal").on("shown.bs.modal", function(e){
233
           var button = $(e.relatedTarget);
358
           var button = $(e.relatedTarget);
234
           var item = button.data('item');
359
           var item = button.data('item');
Lines 246-251 Link Here
246
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
371
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
247
            win.focus();
372
            win.focus();
248
        });
373
        });
374
375
        $(document).ready(function() {
376
            // http://jqueryui.com/demos/datepicker/#date-range
377
            var dates = $( "#from, #to" ).datepicker({
378
                changeMonth: true,
379
                numberOfMonths: 1,
380
                onSelect: function( selectedDate ) {
381
                    var option = this.id == "from" ? "minDate" : "maxDate",
382
                        instance = $( this ).data( "datepicker" );
383
                        date = $.datepicker.parseDate(
384
                            instance.settings.dateFormat ||
385
                            $.datepicker._defaults.dateFormat,
386
                            selectedDate, instance.settings );
387
                    dates.not( this ).datepicker( "option", option, date );
388
                }
389
            });
390
        });
249
    </script>
391
    </script>
250
[% END %]
392
[% END %]
251
393
(-)a/pos/register.pl (-1 / +29 lines)
Lines 24-31 use C4::Auth; Link Here
24
use C4::Output;
24
use C4::Output;
25
use C4::Context;
25
use C4::Context;
26
26
27
use Koha::Account::Lines;
27
use Koha::Cash::Registers;
28
use Koha::Cash::Registers;
28
use Koha::Database;
29
use Koha::Database;
30
use Koha::DateUtils;
29
31
30
my $input = CGI->new();
32
my $input = CGI->new();
31
33
Lines 71-76 else { Link Here
71
        accountlines => $accountlines
73
        accountlines => $accountlines
72
    );
74
    );
73
75
76
    my $transactions_range_from = $input->param('trange_f');
77
    my $last_cashup             = $cash_register->last_cashup;
78
    my $transactions_range_to =
79
        $input->param('trange_t') ? $input->param('trange_t')
80
      : $last_cashup              ? $last_cashup->timestamp
81
      :                             '';
82
    $template->param( trange_t => $transactions_range_to );
83
    if ($transactions_range_from) {
84
        $template->param( trange_f => $transactions_range_from );
85
86
        my $dtf               = $schema->storage->datetime_parser;
87
        my $start             = dt_from_string($transactions_range_from);
88
        my $end               = dt_from_string($transactions_range_to);
89
        my $past_accountlines = Koha::Account::Lines->search(
90
            {
91
                register_id => $registerid,
92
                timestamp   => {
93
                    -between => [
94
                        $dtf->format_datetime($start),
95
                        $dtf->format_datetime($end)
96
                    ]
97
                }
98
            }
99
        );
100
        $template->param( past_accountlines => $past_accountlines );
101
    }
102
74
    my $op = $input->param('op') // '';
103
    my $op = $input->param('op') // '';
75
    if ( $op eq 'cashup' ) {
104
    if ( $op eq 'cashup' ) {
76
        $cash_register->add_cashup(
105
        $cash_register->add_cashup(
77
- 

Return to bug 24082