5 [% USE AuthorisedValues %]
8 [% PROCESS 'accounts.inc' %]
9 [% INCLUDE 'doc-head-open.inc' %]
10 <title>Koha › Cashup</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 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/pos/pay.pl">Point of sale</a> › Register details</div>
21 <div class="main container-fluid">
23 <div class="col-sm-10 col-sm-push-2">
25 [% IF ( error_registers ) %]
26 <div id="error_message" class="dialog message">
28 You must have at least one cash register associated with the library before you can record payments.
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>
39 [% IF ( error_cashup_permission ) %]
40 <div id="error_message" class="dialog alert">
41 You do not have permission to perform cashup actions.
45 [% IF ( error_refund_permission ) %]
46 <div id="error_message" class="dialog alert">
47 You do not have permission to perform refund actions.
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>
57 <h1>Register transaction details for [% register.name | html %]</h1>
61 [% IF register.last_cashup %]
62 <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>
64 <li>Float: [% register.starting_float | $Price %]</li>
65 <li>Total income (cash): [% accountlines.credits_total * -1 | $Price %] ([% accountlines.credits_total(payment_type => 'CASH') * -1 | $Price %])</li>
66 <li>Total outgoing (cash): [% accountlines.debits_total * -1 | $Price %] ([% accountlines.debits_total( payment_type => 'CASH') * -1 | $Price %])</li>
67 <li>Total bankable: [% accountlines.total( payment_type => 'CASH') * -1 | $Price %]</li>
70 [% IF register.last_cashup %]
71 <h2>Transactions since [% register.last_cashup.timestamp | $KohaDates with_hours => 1 %]</h2>
73 <h2>Transactions to date</h2>
75 <table id="sales" class="table_sales">
83 <th class="noExport">Actions</th>
86 [% FOREACH accountline IN accountlines %]
87 [% IF accountline.is_credit %]
88 [% FOREACH credit IN accountline.credit_offsets %]
91 <td>[% accountline.accountlines_id | html %]</td>
92 <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>
95 [%- PROCESS account_type_description account=credit.debit -%]
96 [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
97 [%- 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 -%]
99 <td>[% credit.debit.amount | $Price %]</td>
102 [% IF CAN_user_cash_management_anonymous_refund && !(credit.debit.status == 'REFUNDED' ) %]
103 <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>
104 [% ELSIF CAN_user_updatecharges_refund && !(credit.debit.status == 'REFUNDED') && credit.debit.borrowernumber %]
105 <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>
112 [% FOREACH debit IN accountline.debit_offsets %]
113 [% IF debit.credit %]
115 <td>[% accountline.accountlines_id | html %]</td>
116 <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>[%- PROCESS account_type_description account=debit.credit -%]</td>
120 [%- IF debit.credit.description %][% debit.credit.description | html %][%- END -%]
121 [%- 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 -%]
123 <td>[% debit.credit.amount | $Price %]</td>
133 <td colspan="5">Total income: </td>
134 <td>[% accountlines.total * -1 | $Price %]</td>
141 [% IF register.cashups %]
142 <h2>Older transactions</h2>
143 <form method="GET" action="/cgi-bin/koha/pos/register.pl">
144 <fieldset class="rows">
145 Please select a date range to display transactions for:
148 <label for="trange_f">From: </label>
149 <input type="text" size="10" id="from" class="datepickerfrom" name="trange_f" value="[% trange_f | html %]"/>
150 <label class="inline" for="trange_t">To: </label>
151 <input type="text" size="10" id="to" class="datepickerto" name="trange_t" value="[% trange_t | html %]" />
152 <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
158 <input type="hidden" name="registerid" value="[% register.id | html %]">
159 <input type="submit" value="Display" />
164 <table id="past_sales" class="past_sales_table">
172 <th class="noExport">Actions</th>
175 [% FOREACH accountline IN past_accountlines %]
176 [% IF accountline.is_credit %]
177 [% FOREACH credit IN accountline.credit_offsets %]
178 [% IF credit.debit %]
180 <td>[% accountline.accountlines_id | html %]</td>
181 <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>
184 [%- PROCESS account_type_description account=credit.debit -%]
185 [%- IF credit.debit.description -%] ([% credit.debit.description | html %])[%- END -%]
186 [%- 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 -%]
188 <td>[% credit.debit.amount | $Price %]</td>
191 [% IF CAN_user_cash_management_refund_cash_registers && !(credit.debit.status == 'REFUNDED' ) %]
192 <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>
199 [% FOREACH debit IN accountline.debit_offsets %]
200 [% IF debit.credit %]
202 <td>[% accountline.accountlines_id | html %]</td>
203 <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>[%- PROCESS account_type_description account=debit.credit -%]</td>
206 <td>[%- IF debit.credit.description %][% debit.credit.description | html %][% END %]
207 [% 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>
208 <td>[% debit.credit.amount | $Price %]</td>
218 <td colspan="5">Total income: </td>
219 <td>[% past_accountlines.total * -1 | $Price %]</td>
227 <h2>Cashup history</h2>
228 <table id="table_cashups">
234 <th data-class-name="actions">Actions</th>
241 <div class="col-sm-2 col-sm-pull-10">
243 [% INCLUDE 'pos-menu.inc' %]
248 <!-- Confirm cashup modal -->
249 <div class="modal" id="confirmCashupModal" tabindex="-1" role="dialog" aria-labelledby="confirmCashupLabel">
250 <div class="modal-dialog" role="document">
251 <div class="modal-content">
252 <div class="modal-header">
253 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
254 <h4 class="modal-title" id="confirmCashupLabel">Confirm cashup of <em>[% register.description | html %]</em></h4>
256 <div class="modal-body">
257 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 %].
258 </div> <!-- /.modal-body -->
259 <div class="modal-footer">
260 <a href="/cgi-bin/koha/pos/register.pl?op=cashup" class="btn btn-default" id="pos_cashup_confirm">Confirm</a>
261 <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
262 </div> <!-- /.modal-footer -->
263 </div> <!-- /.modal-content -->
264 </div> <!-- /.modal-dialog -->
265 </div> <!-- /#confirmCashupModal -->
267 <!-- Issue refund modal -->
268 <div class="modal" id="issueRefundModal" tabindex="-1" role="dialog" aria-labelledby="issueRefundLabel">
269 <form id="refund_form" method="post" enctype="multipart/form-data" class="validated">
270 <input type="hidden" name="accountline" value="" id="refundline">
271 <div class="modal-dialog" role="document">
272 <div class="modal-content">
273 <div class="modal-header">
274 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
275 <h4 class="modal-title" id="issueRefundLabel">Issue refund from <em>[% register.description | html %]</em></h4>
277 <div class="modal-body">
278 <fieldset class="rows">
281 <span id="item" class="label">Item: </span><span></span>
284 <span id="paid" class="label">Amount paid: </span><span></span>
287 <label class="required" for="amount">Returned to patron: </label>
288 <input type="text" inputmode="decimal" pattern="^\d+(\.\d{2})?$" id="returned" name="amount" required="required">
289 <span class="required">Required</span>
291 [% SET payment_types = [] %]
292 [% FOR pt IN AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
293 [% NEXT IF pt.authorised_value.grep("^SIP[[:digit:]]{2}$").size() %]
294 [% payment_types.push(pt) %]
297 <label for="transaction_type">Transaction type: </label>
298 <select name="transaction_type" id="transaction_type">
299 [% FOREACH pt IN payment_types %]
300 <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
305 </fieldset> <!-- /.rows -->
306 </div> <!-- /.modal-body -->
307 <div class="modal-footer">
308 <input type="hidden" name="registerid" value="[% register.id | html %]">
309 <input type="hidden" name="op" value="refund">
310 <button type="submit" class="btn btn-default" id="pos_refund_confirm">Confirm</button>
311 <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
312 </div> <!-- /.modal-footer -->
313 </div> <!-- /.modal-content -->
314 </div> <!-- /.modal-dialog -->
315 </form> <!-- /#refund_form -->
316 </div> <!-- /#issueRefundModal -->
318 [% INCLUDE 'modals/cashup_summary.inc' %]
320 [% MACRO jsinclude BLOCK %]
321 [% INCLUDE 'datatables.inc' %]
322 [% Asset.js("lib/jquery/plugins/rowGroup/dataTables.rowGroup.min.js") | $raw %]
323 [% Asset.js("js/cashup_modal.js") | $raw %]
324 [% INCLUDE 'calendar.inc' %]
325 [% INCLUDE 'js-date-format.inc' %]
327 var sales_table = $("#sales").dataTable($.extend(true, {}, dataTablesDefaults, {
328 orderFixed: [ 0, 'asc'],
335 startRender: function ( rows, group ) {
336 var details = JSON.parse(rows.data().pluck(1).pop());
337 var identifier = details.identifier || group;
338 return $('<tr class="'+details.type+'"/>')
339 .append( '<td>'+identifier+'</td>' )
340 .append( '<td colspan="2">'+details.description+'</td>' )
341 .append( '<td>'+details.amount+'</td>' )
342 .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> ' + _("Print receipt") + '</button></td>');
346 initComplete: function() {
351 var past_sales_table = $("#past_sales").dataTable($.extend(true, {}, dataTablesDefaults, {
352 orderFixed: [ 0, 'asc'],
359 startRender: function ( rows, group ) {
360 var details = JSON.parse(rows.data().pluck(1).pop());
361 var identifier = details.identifier || group;
362 return $('<tr class="'+details.type+'"/>')
363 .append( '<td>'+identifier+'</td>' )
364 .append( '<td colspan="2">'+details.description+'</td>' )
365 .append( '<td>'+details.amount+'</td>' )
366 .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> Print receipt</button></td>');
372 $("#issueRefundModal").on("shown.bs.modal", function(e){
373 var button = $(e.relatedTarget);
374 var item = button.data('item');
375 $("#item + span").replaceWith(item);
376 var accountline = button.data('accountline');
377 $('#refundline').val(accountline);
378 var amount = button.data('amount');
379 $("#paid + span").replaceWith(amount);
380 $("#returned").attr({ "value": amount, "max": amount });
381 $("#returned, #transaction_type").focus();
384 $(".printReceipt").click(function() {
385 var accountlines_id = $(this).data('accountline');
386 var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=' + accountlines_id, '_blank');
390 $('.modal.printable').on('shown.bs.modal', function() {
391 $('.modal-dialog', this).addClass('focused');
392 $('body').addClass('modalprinter');
394 if ($(this).hasClass('autoprint')) {
397 }).on('hidden.bs.modal', function () {
398 $('.modal-dialog', this).removeClass('focused');
399 $('body').removeClass('modalprinter');
402 $('.printModal').click(function() {
407 var cashups_table_url = "/api/v1/cash_registers/[% register.id | html %]/cashups?";
408 var cashups_table = $("#table_cashups").api({
410 "url": cashups_table_url
412 "header_filter": true,
416 "order": [[ 0, "asc" ]],
422 "render": function(data, type, row, meta) {
423 return $datetime(row.timestamp);
427 "data": "manager.firstname:manager.surname",
430 "render": function(data, type, row, meta) {
432 if ( row.manager.firstname == null ) {
433 fullname = row.manager.surname;
436 fullname = row.manager.firstname + " " + row.manager.surname;
438 return escape_str(fullname);
445 "render": function(data, type, row, meta) {
446 var amt = row.amount * -1;
447 return escape_price(amt);
451 "data": function( row, type, val, meta ) {
452 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';
461 $(document).ready(function() {
462 // http://jqueryui.com/demos/datepicker/#date-range
463 var dates = $( "#from, #to" ).datepicker({
466 onSelect: function( selectedDate ) {
467 var option = this.id == "from" ? "minDate" : "maxDate",
468 instance = $( this ).data( "datepicker" );
469 date = $.datepicker.parseDate(
470 instance.settings.dateFormat ||
471 $.datepicker._defaults.dateFormat,
472 selectedDate, instance.settings );
473 dates.not( this ).datepicker( "option", option, date );
480 [% INCLUDE 'intranet-bottom.inc' %]