Bug 27835: Add new syspref ChargeFinesOnCloseDay
[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 alert">
27                 You must have at least one cash register associated with this library before you can record payments.
28             </div>
29             [% ELSE %]
30
31             [% IF ( error_cashup_permission ) %]
32             <div id="error_message" class="dialog alert">
33                 You do not have permission to perform cashup actions.
34             </div>
35             [% END %]
36
37             [% IF ( error_refund_permission ) %]
38             <div id="error_message" class="dialog alert">
39                 You do not have permission to perform refund actions.
40             </div>
41             [% END %]
42
43             [% IF ( CAN_user_cash_management_cashup ) %]
44             <div id="toolbar" class="btn-toolbar">
45                 <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>
46             </div>
47             [% END %]
48
49             <h1>Register transaction details for [% register.name | html %]</h1>
50
51             <h2>Summary</h2>
52             <ul>
53                 [% IF register.last_cashup %]
54                 <li>Last cashup: [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %]</li>
55                 [% END %]
56                 <li>Float: [% register.starting_float | $Price %]</li>
57                 <li>Total income (cash): [% accountlines.credits_total * -1 | $Price %] ([% accountlines.credits_total(payment_type => 'CASH') * -1 | $Price %])</li>
58                 <li>Total outgoing (cash): [% accountlines.debits_total * -1 | $Price %] ([% accountlines.debits_total( payment_type => 'CASH') * -1 | $Price %])</li>
59                 <li>Total bankable: [% accountlines.total( payment_type => 'CASH') * -1 | $Price %]</li>
60             </ul>
61
62             [% IF register.last_cashup %]
63             <h2>Transactions since [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %]</h2>
64             [% ELSE %]
65             <h2>Transactions to date</h2>
66             [% END %]
67             <table id="sales" class="table_sales">
68                 <thead>
69                     <th>ID</th>
70                     <th>DATA</th>
71                     <th>Transaction</th>
72                     <th>Description</th>
73                     <th>Price</th>
74                     <th>Total</th>
75                     <th class="noExport">Actions</th>
76                 </thead>
77                 <tbody>
78                     [% FOREACH accountline IN accountlines %]
79                         [% IF accountline.is_credit %]
80                             [% FOREACH credit IN accountline.credit_offsets %]
81                             [% IF credit.debit %]
82                             <tr>
83                                 <td>[% accountline.accountlines_id | html %]</td>
84                                 <td>{ "type": "credit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
85                                 <td></td>
86                                 <td>
87                                     [%- PROCESS account_type_description account=credit.debit -%]
88                                     [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
89                                     [%- 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 -%]
90                                 </td>
91                                 <td>[% credit.debit.amount | $Price %]</td>
92                                 <td></td>
93                                 <td>
94                                     [% IF CAN_user_cash_management_anonymous_refund && !(credit.debit.status == 'REFUNDED' ) %]
95                                     <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>
96                                     [% ELSIF CAN_user_updatecharges_refund && !(credit.debit.status == 'REFUNDED') && credit.debit.borrowernumber %]
97                                     <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>
98                                     [% END %]
99                                 </td>
100                             </tr>
101                             [% END %]
102                             [% END %]
103                         [% ELSE %]
104                             [% FOREACH debit IN accountline.debit_offsets %]
105                             [% IF debit.credit %]
106                             <tr>
107                                 <td>[% accountline.accountlines_id | html %]</td>
108                                 <td>{ "type": "debit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
109                                 <td></td>
110                                 <td>[%- PROCESS account_type_description account=debit.credit -%]</td>
111                                 <td>
112                                     [%- IF debit.credit.description %][% debit.credit.description | html %][%- END -%]
113                                     [%- 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 -%]
114                                 </td>
115                                 <td>[% debit.credit.amount | $Price %]</td>
116                                 <td></td>
117                             </tr>
118                             [% END %]
119                             [% END %]
120                         [% END %]
121                     [% END %]
122                 </tbody>
123                 <tfoot>
124                     <tr>
125                         <td colspan="5">Total income: </td>
126                         <td>[% accountlines.total * -1 | $Price %]</td>
127                         <td></td>
128                     </tr>
129                 </tfoot>
130             </table>
131             [% END %]
132
133             [% IF register.cashups %]
134             <h2>Older transactions</h2>
135             <form method="GET" action="/cgi-bin/koha/pos/register.pl">
136                 <fieldset class="rows">
137                     Please select a date range to display transactions for:
138                     <ol>
139                         <li>
140                             <label for="trange_f">From: </label>
141                             <input type="text" size="10" id="from" class="datepickerfrom" name="trange_f" value="[% trange_f | html %]"/>
142                             <label class="inline" for="trange_t">To: </label>
143                             <input type="text" size="10" id="to" class="datepickerto" name="trange_t" value="[% trange_t | html %]" />
144                             <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
145                         </li>
146                     </ol>
147                 </fieldset>
148
149                 <div class="action">
150                     <input type="hidden" name="registerid" value="[% register.id | html %]">
151                     <input type="submit" value="Display" />
152                 </div>
153             </form>
154
155             [% IF trange_f %]
156             <table id="past_sales" class="past_sales_table">
157                 <thead>
158                     <th>ID</th>
159                     <th>DATA</th>
160                     <th>Transaction</th>
161                     <th>Description</th>
162                     <th>Price</th>
163                     <th>Total</th>
164                     <th class="noExport">Actions</th>
165                 </thead>
166                 <tbody>
167                     [% FOREACH accountline IN past_accountlines %]
168                         [% IF accountline.is_credit %]
169                             [% FOREACH credit IN accountline.credit_offsets %]
170                             [% IF credit.debit %]
171                             <tr>
172                                 <td>[% accountline.accountlines_id | html %]</td>
173                                 <td>{ "type": "credit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
174                                 <td></td>
175                                 <td>
176                                     [%- PROCESS account_type_description account=credit.debit -%]
177                                     [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
178                                     [%- 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 -%]
179                                 </td>
180                                 <td>[% credit.debit.amount | $Price %]</td>
181                                 <td></td>
182                                 <td>
183                                     [% IF CAN_user_cash_management_refund_cash_registers && !(credit.debit.status == 'REFUNDED' ) %]
184                                     <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>
185                                     [% END %]
186                                 </td>
187                             </tr>
188                             [% END %]
189                             [% END %]
190                         [% ELSE %]
191                             [% FOREACH debit IN accountline.debit_offsets %]
192                             [% IF debit.credit %]
193                             <tr>
194                                 <td>[% accountline.accountlines_id | html %]</td>
195                                 <td>{ "type": "debit", "description": "[%- PROCESS account_type_description account=accountline -%] ([% accountline.payment_type | html %])", "amount": "[% accountline.amount * -1 | $Price %]" }</td>
196                                 <td></td>
197                                 <td>[%- PROCESS account_type_description account=debit.credit -%]</td>
198                                 <td>[%- IF debit.credit.description %][% debit.credit.description | html %][% END %]
199         &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>
200                                 <td>[% debit.credit.amount | $Price %]</td>
201                                 <td></td>
202                             </tr>
203                             [% END %]
204                             [% END %]
205                         [% END %]
206                     [% END %]
207                 </tbody>
208                 <tfoot>
209                     <tr>
210                         <td colspan="5">Total income: </td>
211                         <td>[% past_accountlines.total * -1 | $Price %]</td>
212                         <td></td>
213                     </tr>
214                 </tfoot>
215             </table>
216             [% END %]
217
218             [% END %]
219         </div>
220
221         <div class="col-sm-2 col-sm-pull-10">
222             <aside>
223                 [% INCLUDE 'pos-menu.inc' %]
224             </aside>
225         </div>
226     </div><!-- /.row -->
227
228     <!-- Confirm cashup modal -->
229     <div class="modal" id="confirmCashupModal" tabindex="-1" role="dialog" aria-labelledby="confirmCashupLabel">
230         <div class="modal-dialog" role="document">
231             <div class="modal-content">
232                 <div class="modal-header">
233                     <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
234                     <h4 class="modal-title" id="confirmCashupLabel">Confirm cashup of <em>[% register.description | html %]</em></h4>
235                 </div>
236                 <div class="modal-body">
237                     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 %].
238                 </div> <!-- /.modal-body -->
239                 <div class="modal-footer">
240                     <a href="/cgi-bin/koha/pos/register.pl?op=cashup" class="btn btn-default" id="pos_cashup_confirm">Confirm</a>
241                     <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
242                 </div> <!-- /.modal-footer -->
243             </div> <!-- /.modal-content -->
244         </div> <!-- /.modal-dialog -->
245     </div> <!-- /#confirmCashupModal -->
246
247     <!-- Issue refund modal -->
248     <div class="modal" id="issueRefundModal" tabindex="-1" role="dialog" aria-labelledby="issueRefundLabel">
249         <form id="refund_form" method="post" enctype="multipart/form-data" class="validated">
250             <input type="hidden" name="accountline" value="" id="refundline">
251             <div class="modal-dialog" role="document">
252                 <div class="modal-content">
253                     <div class="modal-header">
254                         <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
255                         <h4 class="modal-title" id="issueRefundLabel">Issue refund from <em>[% register.description | html %]</em></h4>
256                     </div>
257                     <div class="modal-body">
258                         <fieldset class="rows">
259                             <ol>
260                                 <li>
261                                     <span id="item" class="label">Item: </span><span></span>
262                                 </li>
263                                 <li>
264                                     <span id="paid" class="label">Amount paid: </span><span></span>
265                                 </li>
266                                 <li>
267                                     <label class="required" for="amount">Returned to patron: </label>
268                                     <input type="number" step="0.01" id="returned" name="amount" min="0.00" required="required">
269                                     <span class="required">Required</span>
270                                 </li>
271                                 [% SET payment_types = [] %]
272                                 [% FOR pt IN AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
273                                     [% NEXT IF pt.authorised_value.grep("^SIP[[:digit:]]{2}$").size() %]
274                                     [% payment_types.push(pt) %]
275                                 [% END %]
276                                 <li>
277                                     <label for="transaction_type">Transaction type: </label>
278                                     <select name="transaction_type" id="transaction_type">
279                                         [% FOREACH pt IN payment_types %]
280                                             <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
281                                         [% END %]
282                                     </select>
283                                 </li>
284                             </ol>
285                         </fieldset> <!-- /.rows -->
286                     </div> <!-- /.modal-body -->
287                     <div class="modal-footer">
288                         <input type="hidden" name="registerid" value="[% register.id | html %]">
289                         <input type="hidden" name="op" value="refund">
290                         <button type="submit" class="btn btn-default" id="pos_refund_confirm">Confirm</button>
291                         <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
292                     </div> <!-- /.modal-footer -->
293                 </div> <!-- /.modal-content -->
294             </div> <!-- /.modal-dialog -->
295         </form> <!-- /#refund_form -->
296     </div> <!-- /#issueRefundModal -->
297
298 [% MACRO jsinclude BLOCK %]
299     [% INCLUDE 'datatables.inc' %]
300     [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
301     [% INCLUDE 'calendar.inc' %]
302     <script>
303         var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
304             orderFixed: [ 0, 'asc'],
305             columnDefs: [ {
306                 targets: [ 0, 1 ],
307                 visible: false
308             }],
309             rowGroup: {
310                 dataSrc: 0,
311                 startRender: function ( rows, group ) {
312                     var details = JSON.parse(rows.data().pluck(1).pop());
313                     return $('<tr class="'+details.type+'"/>')
314                         .append( '<td>'+group+'</td>' )
315                         .append( '<td colspan="2">'+details.description+'</td>' )
316                         .append( '<td>'+details.amount+'</td>' )
317                         .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> ' + _("Print receipt") + '</button></td>');
318                 },
319                 endRender: null,
320             },
321             initComplete: function() {
322                 $("#sales").show();
323             }
324         }));
325
326         var past_sales_table = $("#past_sales").dataTable($.extend(true, {}, dataTablesDefaults, {
327             orderFixed: [ 0, 'asc'],
328             columnDefs: [ {
329                 targets: [ 0, 1 ],
330                 visible: false
331             }],
332             rowGroup: {
333                 dataSrc: 0,
334                 startRender: function ( rows, group ) {
335                     var details = JSON.parse(rows.data().pluck(1).pop());
336                     return $('<tr class="'+details.type+'"/>')
337                         .append( '<td>'+group+'</td>' )
338                         .append( '<td colspan="2">'+details.description+'</td>' )
339                         .append( '<td>'+details.amount+'</td>' )
340                         .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> Print receipt</button></td>');
341                 },
342                 endRender: null,
343             }
344         }));
345
346         $("#issueRefundModal").on("shown.bs.modal", function(e){
347            var button = $(e.relatedTarget);
348            var item = button.data('item');
349            $("#item + span").replaceWith(item);
350            var accountline = button.data('accountline');
351            $('#refundline').val(accountline);
352            var amount = button.data('amount');
353            $("#paid + span").replaceWith(amount);
354            $("#returned").attr({ "value": amount, "max": amount });
355            $("#returned, #transaction_type").focus();
356         });
357
358         $(".printReceipt").click(function() {
359             var accountlines_id = $(this).data('accountline');
360             var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
361             win.focus();
362         });
363
364         $(document).ready(function() {
365             // http://jqueryui.com/demos/datepicker/#date-range
366             var dates = $( "#from, #to" ).datepicker({
367                 changeMonth: true,
368                 numberOfMonths: 1,
369                 onSelect: function( selectedDate ) {
370                     var option = this.id == "from" ? "minDate" : "maxDate",
371                         instance = $( this ).data( "datepicker" );
372                         date = $.datepicker.parseDate(
373                             instance.settings.dateFormat ||
374                             $.datepicker._defaults.dateFormat,
375                             selectedDate, instance.settings );
376                     dates.not( this ).datepicker( "option", option, date );
377                 }
378             });
379         });
380     </script>
381 [% END %]
382
383 [% INCLUDE 'intranet-bottom.inc' %]