5 [% USE AuthorisedValues %]
8 [% PROCESS 'accounts.inc' %]
9 [% INCLUDE 'doc-head-open.inc' %]
10 <title>Cashup › Koha</title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 [% Asset.css("lib/jquery/plugins/rowGroup/stylesheets/rowGroup.dataTables.min.css") | $raw %]
15 <body id="register" class="pos">
16 [% INCLUDE 'header.inc' %]
17 [% INCLUDE 'circ-search.inc' %]
19 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
22 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
25 <a href="/cgi-bin/koha/pos/pay.pl">Point of sale</a>
28 <a href="#" aria-current="page">
35 <div class="main container-fluid">
37 <div class="col-sm-10 col-sm-push-2">
39 [% IF ( error_registers ) %]
40 <div id="error_message" class="dialog message">
42 You must have at least one cash register associated with the library before you can record payments.
44 [% IF ( CAN_user_parameters_manage_cash_registers ) %]
45 <form action="/cgi-bin/koha/admin/cash_registers.pl" method="get">
46 <input type="hidden" name="op" value="add_form" />
47 <button class="new" type="submit"><i class="fa fa-plus"></i> Create a new cash register</button>
53 [% IF ( error_cashup_permission ) %]
54 <div id="error_message" class="dialog alert">
55 You do not have permission to perform cashup actions.
59 [% IF ( error_refund_permission ) %]
60 <div id="error_message" class="dialog alert">
61 You do not have permission to perform refund actions.
65 [% IF ( CAN_user_cash_management_cashup ) %]
66 <div id="toolbar" class="btn-toolbar">
67 <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>
71 <h1>Register transaction details for [% register.name | html %]</h1>
75 [% IF register.last_cashup %]
76 <li>Last cashup: [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %] (<a data-toggle="modal" data-cashup="[% register.last_cashup.id | html %]" data-register="[% register.description | html %]" href="#cashupSummaryModal" class="button">Summary</a>)</li>
78 <li>Float: [% register.starting_float | $Price %]</li>
79 <li>Total income (cash): [% accountlines.credits_total * -1 | $Price %] ([% accountlines.credits_total(payment_type => 'CASH') * -1 | $Price %])</li>
80 <li>Total outgoing (cash): [% accountlines.debits_total * -1 | $Price %] ([% accountlines.debits_total( payment_type => 'CASH') * -1 | $Price %])</li>
81 <li>Total bankable: [% accountlines.total( payment_type => 'CASH') * -1 | $Price %]</li>
84 [% IF register.last_cashup %]
85 <h2>Transactions since [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %]</h2>
87 <h2>Transactions to date</h2>
89 <table id="sales" class="table_sales">
97 <th class="noExport">Actions</th>
100 [% FOREACH accountline IN accountlines %]
101 [% IF accountline.is_credit %]
102 [% FOREACH credit IN accountline.credit_offsets %]
103 [% IF credit.debit %]
105 <td>[% accountline.accountlines_id | html %]</td>
106 <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>
109 [%- PROCESS account_type_description account=credit.debit -%]
110 [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
111 [%- IF ( credit.debit.itemnumber ) -%] (<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% credit.debit.item.biblionumber | uri %]&itemnumber=[% credit.debit.itemnumber | uri %]">[% credit.debit.item.biblio.title | html %]</a>)[%- END -%]
113 <td>[% credit.debit.amount | $Price %]</td>
116 [% IF CAN_user_cash_management_anonymous_refund && !(credit.debit.status == 'REFUNDED' ) %]
117 <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-amountoutstanding="[% credit.debit.amountoutstanding | $Price %]" data-member="[% credit.debit.borrowernumber | html %]"><i class="fa fa-money"></i> Issue refund</button>
118 [% ELSIF CAN_user_updatecharges_refund && !(credit.debit.status == 'REFUNDED') && credit.debit.borrowernumber %]
119 <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-amountoutstanding="[% credit.debit.amountoutstanding | $Price %]" data-member="[% credit.debit.borrowernumber | html %]"><i class="fa fa-money"></i> Issue refund</button>
126 [% FOREACH debit IN accountline.debit_offsets %]
127 [% IF debit.credit %]
129 <td>[% accountline.accountlines_id | html %]</td>
130 <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>
132 <td>[%- PROCESS account_type_description account=debit.credit -%]</td>
134 [%- IF debit.credit.description %][% debit.credit.description | html %][%- END -%]
135 [%- IF ( debit.credit.itemnumber ) -%] (<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% debit.credit.item.biblionumber | uri %]&itemnumber=[% debit.credit.itemnumber | uri %]">[% debit.credit.item.biblio.title | html %]</a>)[%- END -%]
137 <td>[% debit.credit.amount | $Price %]</td>
147 <td colspan="5">Total income: </td>
148 <td>[% accountlines.total * -1 | $Price %]</td>
155 [% IF register.cashups %]
156 <h2>Older transactions</h2>
157 <form method="GET" action="/cgi-bin/koha/pos/register.pl">
158 <fieldset class="rows">
159 Please select a date range to display transactions for:
162 <label for="trange_f">From: </label>
163 <input type="text" size="10" id="from" class="datepickerfrom" name="trange_f" value="[% trange_f | html %]"/>
164 <label class="inline" for="trange_t">To: </label>
165 <input type="text" size="10" id="to" class="datepickerto" name="trange_t" value="[% trange_t | html %]" />
166 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
172 <input type="hidden" name="registerid" value="[% register.id | html %]">
173 <input type="submit" value="Display" />
178 <table id="past_sales" class="past_sales_table">
186 <th class="noExport">Actions</th>
189 [% FOREACH accountline IN past_accountlines %]
190 [% IF accountline.is_credit %]
191 [% FOREACH credit IN accountline.credit_offsets %]
192 [% IF credit.debit %]
194 <td>[% accountline.accountlines_id | html %]</td>
195 <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>
198 [%- PROCESS account_type_description account=credit.debit -%]
199 [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
200 [%- IF ( credit.debit.itemnumber ) -%] (<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% credit.debit.item.biblionumber | uri %]&itemnumber=[% credit.debit.itemnumber | uri %]">[% credit.debit.item.biblio.title | html %]</a>)[%- END -%]
202 <td>[% credit.debit.amount | $Price %]</td>
205 [% IF CAN_user_cash_management_refund_cash_registers && !(credit.debit.status == 'REFUNDED') && !(credit.debit.debit_type_code == 'PAYOUT') %]
206 <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-amountoutstanding="[% credit.debit.amountoutstanding | $Price %]" data-member="[% credit.debit.borrowernumber | html %]"><i class="fa fa-money"></i> Issue refund</button>
213 [% FOREACH debit IN accountline.debit_offsets %]
214 [% IF debit.credit %]
216 <td>[% accountline.accountlines_id | html %]</td>
217 <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>
219 <td>[%- PROCESS account_type_description account=debit.credit -%]</td>
220 <td>[%- IF debit.credit.description %][% debit.credit.description | html %][% END %]
221 [% IF ( debit.credit.itemnumber ) %]<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% debit.credit.item.biblionumber | uri %]&itemnumber=[% debit.credit.itemnumber | uri %]">[% debit.credit.item.biblio.title | html %]</a>[% END %]</td>
222 <td>[% debit.credit.amount | $Price %]</td>
232 <td colspan="5">Total income: </td>
233 <td>[% past_accountlines.total * -1 | $Price %]</td>
241 <h2>Cashup history</h2>
242 <table id="table_cashups">
248 <th data-class-name="actions">Actions</th>
255 <div class="col-sm-2 col-sm-pull-10">
257 [% INCLUDE 'pos-menu.inc' %]
262 <!-- Confirm cashup modal -->
263 <div class="modal" id="confirmCashupModal" tabindex="-1" role="dialog" aria-labelledby="confirmCashupLabel">
264 <div class="modal-dialog" role="document">
265 <div class="modal-content">
266 <div class="modal-header">
267 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
268 <h4 class="modal-title" id="confirmCashupLabel">Confirm cashup of <em>[% register.description | html %]</em></h4>
270 <div class="modal-body">
271 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 %].
272 </div> <!-- /.modal-body -->
273 <div class="modal-footer">
274 <a href="/cgi-bin/koha/pos/register.pl?op=cashup" class="btn btn-default" id="pos_cashup_confirm">Confirm</a>
275 <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
276 </div> <!-- /.modal-footer -->
277 </div> <!-- /.modal-content -->
278 </div> <!-- /.modal-dialog -->
279 </div> <!-- /#confirmCashupModal -->
281 <!-- Issue refund modal -->
282 <div class="modal" id="issueRefundModal" tabindex="-1" role="dialog" aria-labelledby="issueRefundLabel">
283 <form id="refund_form" method="post" enctype="multipart/form-data" class="validated">
284 <input type="hidden" name="accountline" value="" id="refundline">
285 <div class="modal-dialog" role="document">
286 <div class="modal-content">
287 <div class="modal-header">
288 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
289 <h4 class="modal-title" id="issueRefundLabel">Issue refund from <em>[% register.description | html %]</em></h4>
291 <div class="modal-body">
292 <fieldset class="rows">
295 <span id="item" class="label">Item: </span><span></span>
298 <span id="paid" class="label">Amount paid: </span><span></span>
301 <label class="required" for="amount">Returned to patron: </label>
302 <input type="text" inputmode="decimal" pattern="^\d+(\.\d{2})?$" id="returned" name="amount" required="required">
303 <span class="required">Required</span>
305 [% INCLUDE 'transaction_types.inc' type="refund" %]
307 </fieldset> <!-- /.rows -->
308 </div> <!-- /.modal-body -->
309 <div class="modal-footer">
310 <input type="hidden" name="registerid" value="[% register.id | html %]">
311 <input type="hidden" name="op" value="refund">
312 <button type="submit" class="btn btn-default" id="pos_refund_confirm">Confirm</button>
313 <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
314 </div> <!-- /.modal-footer -->
315 </div> <!-- /.modal-content -->
316 </div> <!-- /.modal-dialog -->
317 </form> <!-- /#refund_form -->
318 </div> <!-- /#issueRefundModal -->
320 [% INCLUDE 'modals/cashup_summary.inc' %]
322 [% MACRO jsinclude BLOCK %]
323 [% INCLUDE 'datatables.inc' %]
324 [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
325 [% Asset.js("js/cashup_modal.js") | $raw %]
326 [% INCLUDE 'calendar.inc' %]
327 [% INCLUDE 'js-date-format.inc' %]
329 var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
330 orderFixed: [ 0, 'asc'],
337 startRender: function ( rows, group ) {
338 var details = JSON.parse(rows.data().pluck(1).pop());
339 var identifier = details.identifier || group;
340 return $('<tr class="'+details.type+'"/>')
341 .append( '<td>'+identifier+'</td>' )
342 .append( '<td colspan="2">'+details.description+'</td>' )
343 .append( '<td>'+details.amount+'</td>' )
344 .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> ' + _("Print receipt") + '</button></td>');
348 initComplete: function() {
353 var past_sales_table = $("#past_sales").dataTable($.extend(true, {}, dataTablesDefaults, {
354 orderFixed: [ 0, 'asc'],
361 startRender: function ( rows, group ) {
362 var details = JSON.parse(rows.data().pluck(1).pop());
363 var identifier = details.identifier || group;
364 return $('<tr class="'+details.type+'"/>')
365 .append( '<td>'+identifier+'</td>' )
366 .append( '<td colspan="2">'+details.description+'</td>' )
367 .append( '<td>'+details.amount+'</td>' )
368 .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> Print receipt</button></td>');
374 $("#issueRefundModal").on("shown.bs.modal", function(e){
375 var button = $(e.relatedTarget);
376 var item = button.data('item');
377 $("#item + span").replaceWith(item);
378 var accountline = button.data('accountline');
379 $('#refundline').val(accountline);
380 var amount = button.data('amount');
381 var amountoutstanding = button.data('amountoutstanding') || 0;
382 var paid = amount - amountoutstanding;
383 $("#paid + span").replaceWith(paid);
384 $("#returned").attr({ "value": paid, "max": paid });
385 var member = button.data('member');
386 if ( member === '' ) {
387 $("#refund_type option[value='AC']").remove();
388 } else if ( $("#refund_type option[value='AC']").length == 0 ) {
389 $("#refund_type").prepend('<option value="AC" selected="selected">Account credit</option>');
391 $("#returned, #refund_type").focus();
394 $(".printReceipt").click(function() {
395 var accountlines_id = $(this).data('accountline');
396 var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
400 $('.modal.printable').on('shown.bs.modal', function() {
401 $('.modal-dialog', this).addClass('focused');
402 $('body').addClass('modalprinter');
404 if ($(this).hasClass('autoprint')) {
407 }).on('hidden.bs.modal', function () {
408 $('.modal-dialog', this).removeClass('focused');
409 $('body').removeClass('modalprinter');
412 $('.printModal').click(function() {
417 var cashups_table_url = "/api/v1/cash_registers/[% register.id | html %]/cashups?";
418 var cashups_table = $("#table_cashups").api({
420 "url": cashups_table_url
422 "header_filter": true,
426 "order": [[ 0, "asc" ]],
432 "render": function(data, type, row, meta) {
433 return $datetime(row.timestamp);
437 "data": "manager.firstname:manager.surname",
440 "render": function(data, type, row, meta) {
442 if ( row.manager.firstname == null ) {
443 fullname = row.manager.surname;
446 fullname = row.manager.firstname + " " + row.manager.surname;
448 return escape_str(fullname);
455 "render": function(data, type, row, meta) {
456 var amt = row.amount * -1;
457 return escape_price(amt);
461 "data": function( row, type, val, meta ) {
462 var result = '<a class="btn btn-default btn-xs" role="button" data-toggle="modal" data-cashup="'+encodeURIComponent(row.cashup_id)+'" data-register="[% register.description | html %]" href="#cashupSummaryModal"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Summary")+'</a>\n';
471 $(document).ready(function() {
472 // http://jqueryui.com/demos/datepicker/#date-range
473 var dates = $( "#from, #to" ).datepicker({
476 onSelect: function( selectedDate ) {
477 var option = this.id == "from" ? "minDate" : "maxDate",
478 instance = $( this ).data( "datepicker" );
479 date = $.datepicker.parseDate(
480 instance.settings.dateFormat ||
481 $.datepicker._defaults.dateFormat,
482 selectedDate, instance.settings );
483 dates.not( this ).datepicker( "option", option, date );
490 [% INCLUDE 'intranet-bottom.inc' %]