6 [% USE TablesSettings %]
9 [% INCLUDE 'doc-head-open.inc' %]
10 [% SET registers = Registers.all( filters => { current_branch => 1 } ) %]
11 <title>Payments › Koha</title>
12 [% INCLUDE 'doc-head-close.inc' %]
15 <body id="payments" 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="#" aria-current="page">
32 <div class="main container-fluid">
34 <div class="col-md-10 col-md-push-2">
36 [% IF ( registers.size == 0 ) %]
37 <div id="error_message" class="dialog message">
39 You must have at least one cash register associated with the library before you can record payments.
41 [% IF ( CAN_user_parameters_manage_cash_registers ) %]
42 <form action="/cgi-bin/koha/admin/cash_registers.pl" method="get">
43 <input type="hidden" name="op" value="add_form" />
44 <button class="new" type="submit"><i class="fa fa-plus"></i> Create a new cash register</button>
50 [% IF payment_id && !Koha.Preference('FinePaymentAutoPopup') %]
51 <div class="dialog alert audio-alert-action">
52 Payment received: <a target="_blank" href="/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=[% payment_id | uri %]&collected=[% collected | uri %]&change=[% change | uri %]" class="btn btn-default btn-xs"><i class="fa fa-print"></i> Print receipt</a>
56 <form name="payForm" id="payForm" method="post" action="/cgi-bin/koha/pos/pay.pl">
59 <div class="col-md-6">
60 <fieldset class="rows">
61 <legend>Items for purchase</legend>
62 Please select items from below to add to this transaction:
63 [% IF invoice_types %]
69 <th class="NoSort">Cost</th>
70 <th class="NoSort">Action</th>
74 [% FOREACH invoice IN invoice_types %]
76 <td>[% invoice.code | html %]</td>
77 <td>[% invoice.description | html %]</td>
78 <td>[% invoice.default_amount | $Price %]</td>
80 <button type="button" class="btn btn-default btn-xs add_button" data-invoice-code="[% invoice.code | html %]" data-invoice-title="[% invoice.description | html %]" data-invoice-price="[% invoice.default_amount | html %]"><i class="fa fa-plus"></i> Add</button>
86 You have no manual invoice types defined
91 <div class="col-md-6">
93 <fieldset class="rows">
94 <legend>This sale</legend>
95 <p>Click to edit item cost or quantities</p>
96 <table id="sale" class="table_sale">
111 <td colspan="3">Total payable:</td>
120 <fieldset class="rows">
121 <legend>Collect payment</legend>
124 <label for="paid">Amount being paid: </label>
125 <input type="text" inputmode="none" pattern="[0-9]*" name="paid" id="paid" value="" readonly/>
128 <label for="collected" class="required">Amount tendered: </label>
129 <input type="text" inputmode="numeric" pattern="[0-9]*" name="collected" id="collected" value="" class="required" required="required" />
130 <span class="required">Required</span>
133 <label>Change to give: </label>
134 <span id="change">[% 0 | $Price %]</span>
135 <input type="hidden" name="change" value="[% 0 | $Price %]"/>
138 [% INCLUDE 'transaction_types.inc' type="payment" %]
141 <label for="registerid" class="required">Cash register: </label>
142 <select name="registerid" id="registerid" class="required" required="required">
143 <option id="noregister" disabled selected="selected" value="">-- Select an option--</option>
144 [% PROCESS options_for_registers %]
146 <span class="required">Required</span>
153 <input type="submit" id="submitbutton" name="submitbutton" value="Confirm" />
154 <a class="cancel" href="/cgi-bin/koha/pos/pay.pl">Cancel</a>
162 <div class="col-md-2 col-md-pull-10">
164 [% INCLUDE 'pos-menu.inc' %]
167 </div> <!-- /.row -->
170 <div id="confirm_change_form" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
171 <div class="modal-dialog">
172 <div class="modal-content">
173 <div class="modal-header">
174 <h3>The amount collected is more than the outstanding charge</h3>
176 <div class="modal-body">
177 <p>The amount collected from the patron is higher than the amount to be paid.</p>
178 <p>The change to give is <strong><span id="modal_change">[% 0 | $Price %]</span></strong>.</p>
179 <p>Confirm this payment?</p>
181 <div class="modal-footer">
182 <button class="btn btn-default approve" id="modal_submit" type="button"><i class="fa fa-check"></i> Yes</button>
183 <button class="btn btn-default deny cancel" href="#" data-dismiss="modal" aria-hidden="true" type="button"><i class="fa fa-times"></i> No</button>
189 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
190 <!-- Automatic Print Receipt -->
191 <a id="printReceipt" style="display: none" href="#"></a>
194 [% MACRO jsinclude BLOCK %]
195 [% INCLUDE 'format_price.inc' %]
196 [% INCLUDE 'datatables.inc' %]
197 [% INCLUDE 'columns_settings.inc' %]
198 [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
200 function moneyFormat(textObj) {
201 var newValue = textObj.value;
207 for(var i=0; i < newValue.length; i++) {
208 aChar = newValue.substring(i, i+1);
209 if (aChar >= "0" && aChar <= "9") {
211 decAmount = "" + decAmount + aChar;
214 dolAmount = "" + dolAmount + aChar;
226 if (dolAmount == "") {
230 if (dolAmount.length > 1) {
231 while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
232 dolAmount = dolAmount.substring(1,dolAmount.length);
235 if (decAmount.length > 2) {
236 decAmount = decAmount.substring(0,2);
239 if (decAmount.length == 1) {
240 decAmount = decAmount + "0";
242 if (decAmount.length == 0) {
243 decAmount = decAmount + "00";
246 textObj.value = dolAmount + "." + decAmount;
249 function fnClickAddRow( table, invoiceCode, invoiceTitle, invoicePrice ) {
250 var defaultPrice = { value: invoicePrice };
251 moneyFormat(defaultPrice);
257 '<button class="btn btn-default btn-xs drop" type="button"><i class="fa fa-trash"></i> ' + _("Remove") + '</button>',
263 function updateChangeValues() {
264 var change = $('#change')[0];
265 var zero_formatted = "[% 0 | $Price %]";
266 change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
267 if (change.innerHTML <= 0) {
268 var paid = $('#paid')[0];
270 $('#collected').rules( "add", { min: Number(paid.value) });
271 change.innerHTML = zero_formatted;
272 $(':input[name="change"]').val(zero_formatted);
274 change.value = change.innerHTML;
276 change.innerHTML = change.value;
277 $(':input[name="change"]').val(change.value);
280 $('#modal_change').html(change.innerHTML);
283 $(document).ready(function() {
284 var sale_table = $("#sale").dataTable($.extend(true, {}, dataTablesDefaults, {
291 "bSearchable": false,
294 "mRender": function ( data, type, full ) {
295 var price = Number.parseFloat(data);
296 return price.format_price();
300 "sClass" : "editable",
303 "sClass" : "editable_int",
310 "fnDrawCallback": function (oSettings) {
312 local.$('.editable').editable( function(value, settings) {
313 var aPos = local.fnGetPosition( this );
314 local.fnUpdate( value, aPos[0], aPos[1], true, false );
318 pattern : "^\\d+(\.\\d{2})?$",
321 tooltip : _("Click to edit")
323 local.$('.editable_int').editable( function(value, settings) {
324 var aPos = local.fnGetPosition( this );
325 local.fnUpdate( value, aPos[0], aPos[1], true, false );
332 tooltip : _("Click to edit")
335 "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
336 var iTotal = aData[1] * aData[2];
337 this.fnUpdate( iTotal, nRow, 3, false, false );
339 "fnFooterCallback": function(nFoot, aData, iStart, iEnd, aiDisplay) {
341 for ( var i=0 ; i<aData.length ; i++ )
343 iTotalPrice += aData[i][3]*1;
345 nFoot.getElementsByTagName('td')[1].innerHTML = iTotalPrice.format_price();
346 $('#paid').val(iTotalPrice);
347 $('#paid').trigger('change');
352 $("#sale").on("click", "button.drop", function(){
353 sale_table.DataTable().row($(this).parents('tr')).remove().draw(false);
356 var items_columns_settings = [% TablesSettings.GetColumns('pos', 'pay', 'invoices', 'json') | $raw %];
357 var items_table = KohaTable("invoices", {
358 "sPaginationType": "full",
359 "aaSorting": [[ 0, "asc" ]],
361 }, items_columns_settings, false);
363 $("#invoices").on("click", ".add_button", function(e) {
365 fnClickAddRow(sale_table, $( this ).data('invoiceCode'), $( this ).data('invoiceTitle'), $( this ).data('invoicePrice') );
366 if($('#invoices_filter').find('input[type=search]').val() !== ''){
367 items_table.fnFilter( '' );
371 // Change calculation and modal
372 var change = $('#change')[0];
373 $("#paid, #collected").on("change",function() {
375 if (change != undefined) {
376 updateChangeValues();
381 $('#modal_submit').click(function() {
383 $('#payForm').submit();
386 $('#payForm').validate({
403 $('#payForm').submit(function(e){
404 if (change != undefined && change.innerHTML > 0.00 && !checked) {
406 $("#confirm_change_form").modal("show");
408 var rows = sale_table.fnGetData();
409 rows.forEach(function (row, index) {
418 value: JSON.stringify(sale)
419 }).appendTo('#payForm');
425 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
426 $("#printReceipt").click(function() {
427 var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=[% payment_id | uri %]&collected=[% collected | uri %]&change=[% change | uri %]', '_blank');
430 $("#printReceipt").click();
436 [% INCLUDE 'intranet-bottom.inc' %]