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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt (+134 lines)
Lines 145-150 Link Here
145
                </tfoot>
145
                </tfoot>
146
            </table>
146
            </table>
147
            [% END %]
147
            [% END %]
148
149
            [% IF trange_f %]
150
            <h2>Older transactions</h2>
151
            <table id="past_sales" class="past_sales_table">
152
                <thead>
153
                    <th>
154
                        ID
155
                    </th>
156
                    <th>
157
                        DATA
158
                    </th>
159
                    <th>
160
                        Transaction
161
                    </th>
162
                    <th>
163
                        Description
164
                    </th>
165
                    <th>
166
                        Price
167
                    </th>
168
                    <th>
169
                        Total
170
                    </th>
171
                    <th>
172
                        Actions
173
                    </th>
174
                </thead>
175
                <tbody>
176
                    [% FOREACH accountline IN past_accountlines %]
177
                        [% IF accountline.is_credit %]
178
                            [% FOREACH credit IN accountline.credit_offsets %]
179
                            [% IF credit.debit %]
180
                            <tr>
181
                                <td>[% accountline.accountlines_id %]</td>
182
                                <td>{ "type": "credit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
183
                                <td></td>
184
                                <td>[%- PROCESS account_type_description account=credit.debit -%]
185
                                    [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
186
                                    [%- 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 -%]
187
                                </td>
188
                                <td>[% credit.debit.amount | $Price %]</td>
189
                                <td></td>
190
                                <td>
191
                                    [% IF CAN_user_cash_management_refund_cash_registers && !(credit.debit.status == 'REFUNDED' ) %]
192
                                    <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>
193
                                    [% END %]
194
                                </td>
195
                            </tr>
196
                            [% END %]
197
                            [% END %]
198
                        [% ELSE %]
199
                            [% FOREACH debit IN accountline.debit_offsets %]
200
                            [% IF debit.credit %]
201
                            <tr>
202
                                <td>[% accountline.accountlines_id %]</td>
203
                                <td>{ "type": "debit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
204
                                <td></td>
205
                                <td>[%- PROCESS account_type_description account=debit.credit -%]</td>
206
                                <td>[%- IF debit.credit.description %][% debit.credit.description | html %][% END %]
207
        &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>
208
                                <td>[% debit.credit.amount | $Price %]</td>
209
                                <td></td>
210
                            </tr>
211
                            [% END %]
212
                            [% END %]
213
                        [% END %]
214
                    [% END %]
215
                </tbody>
216
                <tfoot>
217
                    <tr>
218
                        <td colspan="5">Total income: </td>
219
                        <td>[% past_accountlines.total * -1 | $Price %]</td>
220
                        <td></td>
221
                    </tr>
222
                </tfoot>
223
            </table>
224
            [% ELSE %]
225
            [% IF register.cashups %]
226
            <h2>Older transactions</h2>
227
            <form method="GET" action="/cgi-bin/koha/pos/register.pl">
228
			<fieldset class="rows">
229
                            Please select a date range to display transactions for:
230
                            <ol>
231
                                <li>
232
                                    <label for="trange_f">From: </label>
233
                                    <input type="text" size="10" id="from" name="trange_f" />
234
                                    <label class="inline" for="trange_t">To: </label>
235
                                    <input size="10" id="to" name="trange_t" value="[% trange_t | html %]" type="text" />
236
                                    <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
237
                                </li>
238
                            </ol>
239
			</fieldset>
240
	            <input type="submit" value="Display" />
241
            </form>
242
            [% END %]
243
            [% END %]
148
        </div>
244
        </div>
149
245
150
        <div class="col-sm-2 col-sm-pull-10">
246
        <div class="col-sm-2 col-sm-pull-10">
Lines 208-213 Link Here
208
[% MACRO jsinclude BLOCK %]
304
[% MACRO jsinclude BLOCK %]
209
    [% INCLUDE 'datatables.inc' %]
305
    [% INCLUDE 'datatables.inc' %]
210
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
306
    [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
307
    [% INCLUDE 'calendar.inc' %]
211
    <script>
308
    <script>
212
        var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
309
        var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
213
            orderFixed: [ 0, 'asc'],
310
            orderFixed: [ 0, 'asc'],
Lines 229-234 Link Here
229
            }
326
            }
230
        }));
327
        }));
231
328
329
        var past_sales_table = $("#past_sales").dataTable($.extend(true, {}, dataTablesDefaults, {
330
            orderFixed: [ 0, 'asc'],
331
            columnDefs: [ {
332
                targets: [ 0, 1 ],
333
                visible: false
334
            }],
335
            rowGroup: {
336
                dataSrc: 0,
337
                startRender: function ( rows, group ) {
338
                    var details = JSON.parse(rows.data().pluck(1).pop());
339
                    return $('<tr class="'+details.type+'"/>')
340
                        .append( '<td>'+group+'</td>' )
341
                        .append( '<td colspan="2">'+details.description+'</td>' )
342
                        .append( '<td>'+details.amount+'</td>' )
343
                        .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> Print receipt</button></td>');
344
                },
345
                endRender: null,
346
            }
347
        }));
348
232
        $("#issueRefundModal").on("shown.bs.modal", function(e){
349
        $("#issueRefundModal").on("shown.bs.modal", function(e){
233
           var button = $(e.relatedTarget);
350
           var button = $(e.relatedTarget);
234
           var item = button.data('item');
351
           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');
363
            var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
247
            win.focus();
364
            win.focus();
248
        });
365
        });
366
367
        $(document).ready(function() {
368
            // http://jqueryui.com/demos/datepicker/#date-range
369
            var dates = $( "#from, #to" ).datepicker({
370
                changeMonth: true,
371
                numberOfMonths: 1,
372
                onSelect: function( selectedDate ) {
373
                    var option = this.id == "from" ? "minDate" : "maxDate",
374
                        instance = $( this ).data( "datepicker" );
375
                        date = $.datepicker.parseDate(
376
                            instance.settings.dateFormat ||
377
                            $.datepicker._defaults.dateFormat,
378
                            selectedDate, instance.settings );
379
                    dates.not( this ).datepicker( "option", option, date );
380
                }
381
            });
382
        });
249
    </script>
383
    </script>
250
[% END %]
384
[% END %]
251
385
(-)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 23355