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

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