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