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 227-232 Link Here
227
[% MACRO jsinclude BLOCK %]
331
[% MACRO jsinclude BLOCK %]
228
    [% INCLUDE 'datatables.inc' %]
332
    [% INCLUDE 'datatables.inc' %]
229
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
333
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
334
    [% INCLUDE 'calendar.inc' %]
230
    <script>
335
    <script>
231
        var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
336
        var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
232
            orderFixed: [ 0, 'asc'],
337
            orderFixed: [ 0, 'asc'],
Lines 248-253 Link Here
248
            }
353
            }
249
        }));
354
        }));
250
355
356
        var past_sales_table = $("#past_sales").dataTable($.extend(true, {}, dataTablesDefaults, {
357
            orderFixed: [ 0, 'asc'],
358
            columnDefs: [ {
359
                targets: [ 0, 1 ],
360
                visible: false
361
            }],
362
            rowGroup: {
363
                dataSrc: 0,
364
                startRender: function ( rows, group ) {
365
                    var details = JSON.parse(rows.data().pluck(1).pop());
366
                    return $('<tr class="'+details.type+'"/>')
367
                        .append( '<td>'+group+'</td>' )
368
                        .append( '<td colspan="2">'+details.description+'</td>' )
369
                        .append( '<td>'+details.amount+'</td>' )
370
                        .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> Print receipt</button></td>');
371
                },
372
                endRender: null,
373
            }
374
        }));
375
251
        $("#issueRefundModal").on("shown.bs.modal", function(e){
376
        $("#issueRefundModal").on("shown.bs.modal", function(e){
252
           var button = $(e.relatedTarget);
377
           var button = $(e.relatedTarget);
253
           var item = button.data('item');
378
           var item = button.data('item');
Lines 265-270 Link Here
265
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
390
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
266
            win.focus();
391
            win.focus();
267
        });
392
        });
393
394
        $(document).ready(function() {
395
            // http://jqueryui.com/demos/datepicker/#date-range
396
            var dates = $( "#from, #to" ).datepicker({
397
                changeMonth: true,
398
                numberOfMonths: 1,
399
                onSelect: function( selectedDate ) {
400
                    var option = this.id == "from" ? "minDate" : "maxDate",
401
                        instance = $( this ).data( "datepicker" );
402
                        date = $.datepicker.parseDate(
403
                            instance.settings.dateFormat ||
404
                            $.datepicker._defaults.dateFormat,
405
                            selectedDate, instance.settings );
406
                    dates.not( this ).datepicker( "option", option, date );
407
                }
408
            });
409
        });
268
    </script>
410
    </script>
269
[% END %]
411
[% END %]
270
412
(-)a/pos/register.pl (-1 / +29 lines)
Lines 23-30 use C4::Auth; Link Here
23
use C4::Output;
23
use C4::Output;
24
use C4::Context;
24
use C4::Context;
25
25
26
use Koha::Account::Lines;
26
use Koha::Cash::Registers;
27
use Koha::Cash::Registers;
27
use Koha::Database;
28
use Koha::Database;
29
use Koha::DateUtils;
28
30
29
my $input = CGI->new();
31
my $input = CGI->new();
30
32
Lines 70-75 else { Link Here
70
        accountlines => $accountlines
72
        accountlines => $accountlines
71
    );
73
    );
72
74
75
    my $transactions_range_from = $input->param('trange_f');
76
    my $last_cashup             = $cash_register->last_cashup;
77
    my $transactions_range_to =
78
        $input->param('trange_t') ? $input->param('trange_t')
79
      : $last_cashup              ? $last_cashup->timestamp
80
      :                             '';
81
    $template->param( trange_t => $transactions_range_to );
82
    if ($transactions_range_from) {
83
        $template->param( trange_f => $transactions_range_from );
84
85
        my $dtf               = $schema->storage->datetime_parser;
86
        my $start             = dt_from_string($transactions_range_from);
87
        my $end               = dt_from_string($transactions_range_to);
88
        my $past_accountlines = Koha::Account::Lines->search(
89
            {
90
                register_id => $registerid,
91
                timestamp   => {
92
                    -between => [
93
                        $dtf->format_datetime($start),
94
                        $dtf->format_datetime($end)
95
                    ]
96
                }
97
            }
98
        );
99
        $template->param( past_accountlines => $past_accountlines );
100
    }
101
73
    my $op = $input->param('op') // '';
102
    my $op = $input->param('op') // '';
74
    if ( $op eq 'cashup' ) {
103
    if ( $op eq 'cashup' ) {
75
        $cash_register->add_cashup(
104
        $cash_register->add_cashup(
76
- 

Return to bug 24082