Bug 26602: Don't export "actions" column
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / pos / register.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE AuthorisedValues %]
6 [% USE Price %]
7 [% SET footerjs = 1 %]
8 [% PROCESS 'accounts.inc' %]
9 [% INCLUDE 'doc-head-open.inc' %]
10 <title>Koha &rsaquo; Cashup</title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 [% Asset.css("lib/jquery/plugins/rowGroup/stylesheets/rowGroup.dataTables.min.css") | $raw %]
13 </head>
14
15 <body id="register" class="pos">
16 [% INCLUDE 'header.inc' %]
17 [% INCLUDE 'circ-search.inc' %]
18
19 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/pos/pay.pl">Point of sale</a> &rsaquo; Register details</div>
20
21 <div class="main container-fluid">
22     <div class="row">
23         <div class="col-sm-10 col-sm-push-2">
24
25             [% IF ( error_registers ) %]
26                 <div id="error_message" class="dialog message">
27                     <p>
28                         You must have at least one cash register associated with the library before you can record payments.
29                     </p>
30                     [% IF ( CAN_user_parameters_manage_cash_registers ) %]
31                         <form action="/cgi-bin/koha/admin/cash_registers.pl" method="get">
32                             <input type="hidden" name="op" value="add_form" />
33                             <button class="new" type="submit"><i class="fa fa-plus"></i> Create a new cash register</button>
34                         </form>
35                     [% END %]
36                 </div>
37             [% ELSE %]
38
39             [% IF ( error_cashup_permission ) %]
40             <div id="error_message" class="dialog alert">
41                 You do not have permission to perform cashup actions.
42             </div>
43             [% END %]
44
45             [% IF ( error_refund_permission ) %]
46             <div id="error_message" class="dialog alert">
47                 You do not have permission to perform refund actions.
48             </div>
49             [% END %]
50
51             [% IF ( CAN_user_cash_management_cashup ) %]
52             <div id="toolbar" class="btn-toolbar">
53                 <button id="pos_cashup" type="button" class="btn btn-default" data-toggle="modal" data-target="#confirmCashupModal" ><i class="fa fa-money"></i> Record cashup</button>
54             </div>
55             [% END %]
56
57             <h1>Register transaction details for [% register.name | html %]</h1>
58
59             <h2>Summary</h2>
60             <ul>
61                 [% IF register.last_cashup %]
62                 <li>Last cashup: [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %] (<a data-toggle="modal" href="#cashupSummaryModal" class="button">Summary</a>)</li>
63
64                 [% END %]
65                 <li>Float: [% register.starting_float | $Price %]</li>
66                 <li>Total income (cash): [% accountlines.credits_total * -1 | $Price %] ([% accountlines.credits_total(payment_type => 'CASH') * -1 | $Price %])</li>
67                 <li>Total outgoing (cash): [% accountlines.debits_total * -1 | $Price %] ([% accountlines.debits_total( payment_type => 'CASH') * -1 | $Price %])</li>
68                 <li>Total bankable: [% accountlines.total( payment_type => 'CASH') * -1 | $Price %]</li>
69             </ul>
70
71             [% IF register.last_cashup %]
72             <h2>Transactions since [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %]</h2>
73             [% ELSE %]
74             <h2>Transactions to date</h2>
75             [% END %]
76             <table id="sales" class="table_sales">
77                 <thead>
78                     <th>ID</th>
79                     <th>DATA</th>
80                     <th>Transaction</th>
81                     <th>Description</th>
82                     <th>Price</th>
83                     <th>Total</th>
84                     <th class="noExport">Actions</th>
85                 </thead>
86                 <tbody>
87                     [% FOREACH accountline IN accountlines %]
88                         [% IF accountline.is_credit %]
89                             [% FOREACH credit IN accountline.credit_offsets %]
90                             [% IF credit.debit %]
91                             <tr>
92                                 <td>[% accountline.accountlines_id | html %]</td>
93                                 <td>{ "type": "credit", "identifier": "[%- accountline.credit_number | html -%]", "description": "[%- PROCESS account_type_description account=accountline -%] ([% AuthorisedValues.GetByCode( 'PAYMENT_TYPE', accountline.payment_type ) | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
94                                 <td></td>
95                                 <td>
96                                     [%- PROCESS account_type_description account=credit.debit -%]
97                                     [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
98                                     [%- 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 -%]
99                                 </td>
100                                 <td>[% credit.debit.amount | $Price %]</td>
101                                 <td></td>
102                                 <td>
103                                     [% IF CAN_user_cash_management_anonymous_refund && !(credit.debit.status == 'REFUNDED' ) %]
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                                     [% ELSIF CAN_user_updatecharges_refund && !(credit.debit.status == 'REFUNDED') && credit.debit.borrowernumber %]
106                                     <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>
107                                     [% END %]
108                                 </td>
109                             </tr>
110                             [% END %]
111                             [% END %]
112                         [% ELSE %]
113                             [% FOREACH debit IN accountline.debit_offsets %]
114                             [% IF debit.credit %]
115                             <tr>
116                                 <td>[% accountline.accountlines_id | html %]</td>
117                                 <td>{ "type": "debit", "identifier": "[%- accountline.credit_number | html -%]", "description": "[%- PROCESS account_type_description account=accountline -%] ([% AuthorisedValues.GetByCode( 'PAYMENT_TYPE', accountline.payment_type ) | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
118                                 <td></td>
119                                 <td>[%- PROCESS account_type_description account=debit.credit -%]</td>
120                                 <td>
121                                     [%- IF debit.credit.description %][% debit.credit.description | html %][%- END -%]
122                                     [%- 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 -%]
123                                 </td>
124                                 <td>[% debit.credit.amount | $Price %]</td>
125                                 <td></td>
126                             </tr>
127                             [% END %]
128                             [% END %]
129                         [% END %]
130                     [% END %]
131                 </tbody>
132                 <tfoot>
133                     <tr>
134                         <td colspan="5">Total income: </td>
135                         <td>[% accountlines.total * -1 | $Price %]</td>
136                         <td></td>
137                     </tr>
138                 </tfoot>
139             </table>
140             [% END %]
141
142             [% IF register.cashups %]
143             <h2>Older transactions</h2>
144             <form method="GET" action="/cgi-bin/koha/pos/register.pl">
145                 <fieldset class="rows">
146                     Please select a date range to display transactions for:
147                     <ol>
148                         <li>
149                             <label for="trange_f">From: </label>
150                             <input type="text" size="10" id="from" class="datepickerfrom" name="trange_f" value="[% trange_f | html %]"/>
151                             <label class="inline" for="trange_t">To: </label>
152                             <input type="text" size="10" id="to" class="datepickerto" name="trange_t" value="[% trange_t | html %]" />
153                             <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
154                         </li>
155                     </ol>
156                 </fieldset>
157
158                 <div class="action">
159                     <input type="hidden" name="registerid" value="[% register.id | html %]">
160                     <input type="submit" value="Display" />
161                 </div>
162             </form>
163
164             [% IF trange_f %]
165             <table id="past_sales" class="past_sales_table">
166                 <thead>
167                     <th>ID</th>
168                     <th>DATA</th>
169                     <th>Transaction</th>
170                     <th>Description</th>
171                     <th>Price</th>
172                     <th>Total</th>
173                     <th class="noExport">Actions</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 | html %]</td>
182                                 <td>{ "type": "credit", "identifier": "[%- accountline.credit_number | html -%]", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
183                                 <td></td>
184                                 <td>
185                                     [%- PROCESS account_type_description account=credit.debit -%]
186                                     [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
187                                     [%- 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 -%]
188                                 </td>
189                                 <td>[% credit.debit.amount | $Price %]</td>
190                                 <td></td>
191                                 <td>
192                                     [% IF CAN_user_cash_management_refund_cash_registers && !(credit.debit.status == 'REFUNDED' ) %]
193                                     <button type="button" class="btn btn-default btn-xs pos_refund" 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>
194                                     [% END %]
195                                 </td>
196                             </tr>
197                             [% END %]
198                             [% END %]
199                         [% ELSE %]
200                             [% FOREACH debit IN accountline.debit_offsets %]
201                             [% IF debit.credit %]
202                             <tr>
203                                 <td>[% accountline.accountlines_id | html %]</td>
204                                 <td>{ "type": "debit", "identifier": "[%- accountline.credit_number | html -%]", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
205                                 <td></td>
206                                 <td>[%- PROCESS account_type_description account=debit.credit -%]</td>
207                                 <td>[%- IF debit.credit.description %][% debit.credit.description | html %][% END %]
208         &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>
209                                 <td>[% debit.credit.amount | $Price %]</td>
210                                 <td></td>
211                             </tr>
212                             [% END %]
213                             [% END %]
214                         [% END %]
215                     [% END %]
216                 </tbody>
217                 <tfoot>
218                     <tr>
219                         <td colspan="5">Total income: </td>
220                         <td>[% past_accountlines.total * -1 | $Price %]</td>
221                         <td></td>
222                     </tr>
223                 </tfoot>
224             </table>
225             [% END %]
226
227             [% END %]
228         </div>
229
230         <div class="col-sm-2 col-sm-pull-10">
231             <aside>
232                 [% INCLUDE 'pos-menu.inc' %]
233             </aside>
234         </div>
235     </div><!-- /.row -->
236
237     <!-- Confirm cashup modal -->
238     <div class="modal" id="confirmCashupModal" tabindex="-1" role="dialog" aria-labelledby="confirmCashupLabel">
239         <div class="modal-dialog" role="document">
240             <div class="modal-content">
241                 <div class="modal-header">
242                     <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
243                     <h4 class="modal-title" id="confirmCashupLabel">Confirm cashup of <em>[% register.description | html %]</em></h4>
244                 </div>
245                 <div class="modal-body">
246                     Please confirm that you have removed [% accountlines.total( payment_type => 'CASH') * -1 | $Price %] from the cash register and left a float of [% register.starting_float | $Price %].
247                 </div> <!-- /.modal-body -->
248                 <div class="modal-footer">
249                     <a href="/cgi-bin/koha/pos/register.pl?op=cashup" class="btn btn-default" id="pos_cashup_confirm">Confirm</a>
250                     <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
251                 </div> <!-- /.modal-footer -->
252             </div> <!-- /.modal-content -->
253         </div> <!-- /.modal-dialog -->
254     </div> <!-- /#confirmCashupModal -->
255
256     <!-- Issue refund modal -->
257     <div class="modal" id="issueRefundModal" tabindex="-1" role="dialog" aria-labelledby="issueRefundLabel">
258         <form id="refund_form" method="post" enctype="multipart/form-data" class="validated">
259             <input type="hidden" name="accountline" value="" id="refundline">
260             <div class="modal-dialog" role="document">
261                 <div class="modal-content">
262                     <div class="modal-header">
263                         <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
264                         <h4 class="modal-title" id="issueRefundLabel">Issue refund from <em>[% register.description | html %]</em></h4>
265                     </div>
266                     <div class="modal-body">
267                         <fieldset class="rows">
268                             <ol>
269                                 <li>
270                                     <span id="item" class="label">Item: </span><span></span>
271                                 </li>
272                                 <li>
273                                     <span id="paid" class="label">Amount paid: </span><span></span>
274                                 </li>
275                                 <li>
276                                     <label class="required" for="amount">Returned to patron: </label>
277                                     <input type="number" step="0.01" id="returned" name="amount" min="0.00" required="required">
278                                     <span class="required">Required</span>
279                                 </li>
280                                 [% SET payment_types = [] %]
281                                 [% FOR pt IN AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
282                                     [% NEXT IF pt.authorised_value.grep("^SIP[[:digit:]]{2}$").size() %]
283                                     [% payment_types.push(pt) %]
284                                 [% END %]
285                                 <li>
286                                     <label for="transaction_type">Transaction type: </label>
287                                     <select name="transaction_type" id="transaction_type">
288                                         [% FOREACH pt IN payment_types %]
289                                             <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
290                                         [% END %]
291                                     </select>
292                                 </li>
293                             </ol>
294                         </fieldset> <!-- /.rows -->
295                     </div> <!-- /.modal-body -->
296                     <div class="modal-footer">
297                         <input type="hidden" name="registerid" value="[% register.id | html %]">
298                         <input type="hidden" name="op" value="refund">
299                         <button type="submit" class="btn btn-default" id="pos_refund_confirm">Confirm</button>
300                         <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
301                     </div> <!-- /.modal-footer -->
302                 </div> <!-- /.modal-content -->
303             </div> <!-- /.modal-dialog -->
304         </form> <!-- /#refund_form -->
305     </div> <!-- /#issueRefundModal -->
306
307     <!-- Cashup summary modal -->
308     [% IF register.last_cashup %]
309     <div class="modal printable" id="cashupSummaryModal" tabindex="-1" role="dialog" aria-labelledby="cashupSummaryLabel">
310         <div class="modal-dialog" role="document">
311             <div class="modal-content">
312                 <div class="modal-header">
313                     <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
314                     <h4 class="modal-title" id="cashupSummaryLabel">Cashup summary</h4>
315                 </div>
316                 <div class="modal-body">
317                     <ul>
318                         <li>Cash register: [% register.description | html %]</li>
319                         <li>Period: [% register.last_cashup.cashup_summary.from_date | $KohaDates with_hours => 1 %] to [% register.last_cashup.cashup_summary.to_date | $KohaDates with_hours => 1 %]</li>
320                     </ul>
321                     <table>
322                         <thead>
323                             <tr>
324                                 <th>Type</th>
325                                 <th>Total</th>
326                             </tr>
327                         </thead>
328                         <tbody>
329                             [%- FOREACH out IN register.last_cashup.cashup_summary.outgoing -%]
330                             <tr>
331                                 <td>[%- PROCESS account_type_description account=out -%]</td>
332                                 <td>[% out.total * -1 | $Price %]</td>
333                             </tr>
334                             [%- END -%]
335                             [%- FOREACH in IN register.last_cashup.cashup_summary.income -%]
336                             <tr>
337                                 <td>[%- PROCESS account_type_description account=in -%]</td>
338                                 <td>[% in.total * -1 | $Price %]</td>
339                             </tr>
340                             [%- END -%]
341                         </tbody>
342                         <tfoot>
343                             <tr>
344                                 <td>Total</td>
345                                 <td>[% ( register.last_cashup.cashup_summary.outgoing_transactions.total + register.last_cashup.cashup_summary.income_transactions.total) * -1 | $Price %]</td>
346                             </tr>
347                             [% FOREACH pt IN payment_types %]
348                             <tr>
349                                 <td>[% pt.lib | html %]</td>
350                                 <td>[% ( register.last_cashup.cashup_summary.outgoing_transactions.total( payment_type => pt.authorised_value ) + register.last_cashup.cashup_summary.income_transactions.total( payment_type => pt.authorised_value )) * -1 | $Price %]</td>
351                             </tr>
352                             [% END %]
353
354                         </tfoot>
355                     </table>
356                 </div> <!-- /.modal-body -->
357                 <div class="modal-footer">
358                     <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
359                     <button type="button" class="printModal btn btn-primary"><i class="fa fa-print"></i> Print</button>
360                 </div> <!-- /.modal-footer -->
361             </div> <!-- /.modal-content -->
362         </div> <!-- /.modal-dialog -->
363     </div> <!-- /#cashupSummaryModal -->
364     [% END %]
365
366 [% MACRO jsinclude BLOCK %]
367     [% INCLUDE 'datatables.inc' %]
368     [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
369     [% INCLUDE 'calendar.inc' %]
370     <script>
371         var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
372             orderFixed: [ 0, 'asc'],
373             columnDefs: [ {
374                 targets: [ 0, 1 ],
375                 visible: false
376             }],
377             rowGroup: {
378                 dataSrc: 0,
379                 startRender: function ( rows, group ) {
380                     var details = JSON.parse(rows.data().pluck(1).pop());
381                     var identifier = details.identifier || group;
382                     return $('<tr class="'+details.type+'"/>')
383                         .append( '<td>'+identifier+'</td>' )
384                         .append( '<td colspan="2">'+details.description+'</td>' )
385                         .append( '<td>'+details.amount+'</td>' )
386                         .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> ' + _("Print receipt") + '</button></td>');
387                 },
388                 endRender: null,
389             },
390             initComplete: function() {
391                 $("#sales").show();
392             }
393         }));
394
395         var past_sales_table = $("#past_sales").dataTable($.extend(true, {}, dataTablesDefaults, {
396             orderFixed: [ 0, 'asc'],
397             columnDefs: [ {
398                 targets: [ 0, 1 ],
399                 visible: false
400             }],
401             rowGroup: {
402                 dataSrc: 0,
403                 startRender: function ( rows, group ) {
404                     var details = JSON.parse(rows.data().pluck(1).pop());
405                     var identifier = details.identifier || group;
406                     return $('<tr class="'+details.type+'"/>')
407                         .append( '<td>'+identifier+'</td>' )
408                         .append( '<td colspan="2">'+details.description+'</td>' )
409                         .append( '<td>'+details.amount+'</td>' )
410                         .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> Print receipt</button></td>');
411                 },
412                 endRender: null,
413             }
414         }));
415
416         $("#issueRefundModal").on("shown.bs.modal", function(e){
417            var button = $(e.relatedTarget);
418            var item = button.data('item');
419            $("#item + span").replaceWith(item);
420            var accountline = button.data('accountline');
421            $('#refundline').val(accountline);
422            var amount = button.data('amount');
423            $("#paid + span").replaceWith(amount);
424            $("#returned").attr({ "value": amount, "max": amount });
425            $("#returned, #transaction_type").focus();
426         });
427
428         $(".printReceipt").click(function() {
429             var accountlines_id = $(this).data('accountline');
430             var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
431             win.focus();
432         });
433
434         $('.modal.printable').on('shown.bs.modal', function() {
435             $('.modal-dialog', this).addClass('focused');
436             $('body').addClass('modalprinter');
437
438             if ($(this).hasClass('autoprint')) {
439                 window.print();
440             }
441         }).on('hidden.bs.modal', function () {
442             $('.modal-dialog', this).removeClass('focused');
443             $('body').removeClass('modalprinter');
444         });
445
446         $('.printModal').click(function() {
447             window.print();
448         });
449
450         $(document).ready(function() {
451             // http://jqueryui.com/demos/datepicker/#date-range
452             var dates = $( "#from, #to" ).datepicker({
453                 changeMonth: true,
454                 numberOfMonths: 1,
455                 onSelect: function( selectedDate ) {
456                     var option = this.id == "from" ? "minDate" : "maxDate",
457                         instance = $( this ).data( "datepicker" );
458                         date = $.datepicker.parseDate(
459                             instance.settings.dateFormat ||
460                             $.datepicker._defaults.dateFormat,
461                             selectedDate, instance.settings );
462                     dates.not( this ).datepicker( "option", option, date );
463                 }
464             });
465         });
466     </script>
467 [% END %]
468
469 [% INCLUDE 'intranet-bottom.inc' %]