6 [% PROCESS 'payments.inc' %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha › Payments</title>
9 [% INCLUDE 'doc-head-close.inc' %]
12 <body id="payments" class="pos">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'circ-search.inc' %]
16 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › Point of sale</div>
18 <div class="main container-fluid">
20 <div class="col-sm-10 col-sm-push-2">
22 [% IF ( error_registers ) %]
23 <div id="error_message" class="dialog alert">
24 You must have at least one cash register associated with this branch before you can record payments.
28 [% IF payment_id && !Koha.Preference('FinePaymentAutoPopup') %]
29 <div class="dialog alert audio-alert-action">
30 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>
34 <form name="payForm" id="payForm" method="post" action="/cgi-bin/koha/pos/pay.pl">
37 <div class="col-sm-6">
38 <fieldset class="rows">
39 <legend>Items for purchase</legend>
40 Please select items from below to add to this transaction:
41 [% IF invoice_types %]
52 [% FOREACH invoice IN invoice_types %]
54 <td>[% invoice.code | html %]</td>
55 <td>[% invoice.description | html %]</td>
56 <td>[% invoice.default_amount | $Price %]</td>
58 <button type="button" class="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>
64 You have no manual invoice types defined
69 <div class="col-sm-6">
71 <fieldset class="rows">
72 <legend>This sale</legend>
73 <p>Click to edit item cost or quantities</p>
74 <table id="sale" class="table_sale">
89 <td colspan="3">Total payable:</td>
98 <fieldset class="rows">
99 <legend>Collect payment</legend>
102 <label for="paid">Amount being paid: </label>
103 <input type="number" min="0.00" max="10000.00" step="0.01" name="paid" id="paid" value="[% amountoutstanding | $Price on_editing => 1 %]" readonly/>
106 <label for="collected">Collected from patron: </label>
107 <input type="number" min="0.00" max="10000.00" step="0.01" name="collected" id="collected" value=""/>
110 <label>Change to give: </label>
111 <span id="change">0.00</span>
112 <input type="hidden" name="change" value="0.00"/>
115 [% PROCESS account_payment_types %]
118 <label for="cash_register">Cash register: </label>
119 <select name="cash_register" id="cash_register">
120 [% FOREACH register IN registers %]
121 [% IF register.id == registerid %]
122 <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
124 <option value="[% register.id | html %]">[% register.name | html %]</option>
135 <input type="submit" name="submitbutton" value="Confirm" />
136 <a class="cancel" href="/cgi-bin/koha/pos/pay.pl">Cancel</a>
143 <div class="col-sm-2 col-sm-pull-10">
145 [% INCLUDE 'pos-menu.inc' %]
148 </div> <!-- /.row -->
151 <div id="confirm_change_form" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
152 <div class="modal-dialog">
153 <div class="modal-content">
154 <div class="modal-header">
155 <h3>The amount collected is more than the outstanding charge</h3>
157 <div class="modal-body">
158 <p>The amount collected from the patron is higher than the amount to be paid.</p>
159 <p>The change to give is <b><span id="modal_change">0.00</span></b>.</p>
160 <p>Confirm this payment?</p>
162 <div class="modal-footer">
163 <button class="btn btn-default approve" id="modal_submit" type="button"><i class="fa fa-check"></i> Yes</button>
164 <button class="btn btn-default deny cancel" href="#" data-dismiss="modal" aria-hidden="true" type="button"><i class="fa fa-times"></i> No</button>
170 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
171 <!-- Automatic Print Receipt -->
172 <a id="printReceipt" style="display: none" href="#"></a>
175 [% MACRO jsinclude BLOCK %]
176 [% INCLUDE 'format_price.inc' %]
177 [% INCLUDE 'datatables.inc' %]
178 [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
180 function moneyFormat(textObj) {
181 var newValue = textObj.value;
187 for(var i=0; i < newValue.length; i++) {
188 aChar = newValue.substring(i, i+1);
189 if (aChar >= "0" && aChar <= "9") {
191 decAmount = "" + decAmount + aChar;
194 dolAmount = "" + dolAmount + aChar;
206 if (dolAmount == "") {
210 if (dolAmount.length > 1) {
211 while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
212 dolAmount = dolAmount.substring(1,dolAmount.length);
215 if (decAmount.length > 2) {
216 decAmount = decAmount.substring(0,2);
219 if (decAmount.length == 1) {
220 decAmount = decAmount + "0";
222 if (decAmount.length == 0) {
223 decAmount = decAmount + "00";
226 textObj.value = dolAmount + "." + decAmount;
229 function fnClickAddRow( table, invoiceCode, invoiceTitle, invoicePrice ) {
230 var defaultPrice = { value: invoicePrice };
231 moneyFormat(defaultPrice);
237 '<button class="drop" type="button"><i class="fa fa-trash"></i> Remove</button>',
243 function updateChangeValues() {
244 var change = $('#change')[0];
245 change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
246 if (change.innerHTML <= 0) {
247 change.innerHTML = "0.00";
249 change.value = change.innerHTML;
251 change.innerHTML = change.value;
254 $(':input[name="change"]').val(change.value);
255 $('#modal_change').html(change.innerHTML);
258 $(document).ready(function() {
259 var sale_table = $("#sale").dataTable($.extend(true, {}, dataTablesDefaults, {
267 "bSearchable": false,
270 "mRender": function ( data, type, full ) {
271 var price = Number.parseFloat(data);
272 return price.format_price();
276 "sClass" : "editable",
279 "sClass" : "editable_int",
288 "fnDrawCallback": function (oSettings) {
290 local.$('.editable').editable( function(value, settings) {
291 var aPos = local.fnGetPosition( this );
292 local.fnUpdate( value, aPos[0], aPos[1], true, false );
300 local.$('.editable_int').editable( function(value, settings) {
301 var aPos = local.fnGetPosition( this );
302 local.fnUpdate( value, aPos[0], aPos[1], true, false );
311 "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
312 var iTotal = aData[1] * aData[2];
313 this.fnUpdate( iTotal, nRow, 3, false, false );
315 "fnFooterCallback": function(nFoot, aData, iStart, iEnd, aiDisplay) {
317 for ( var i=0 ; i<aData.length ; i++ )
319 iTotalPrice += aData[i][3]*1;
321 nFoot.getElementsByTagName('td')[1].innerHTML = iTotalPrice.format_price();
322 $('#paid').val(iTotalPrice);
323 $('#paid').trigger('change');
327 $("#sale").on("click", "button.drop", function(){
328 sale_table.DataTable().row($(this).parents('tr')).remove().draw(false);
331 var items_table = $("#invoices").dataTable($.extend(true,{}, dataTablesDefaults, {
333 { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable":false },
335 "aaSorting": [[ 0, "asc" ]],
336 "paginationType": "full",
339 $(".add_button").on("click", function(e) {
341 fnClickAddRow(sale_table, $( this ).data('invoiceCode'), $( this ).data('invoiceTitle'), $( this ).data('invoicePrice') );
342 items_table.fnFilter( '' );
345 // Change calculation and modal
346 var change = $('#change')[0];
347 $("#paid, #collected").on("change",function() {
349 if (change != undefined) {
350 updateChangeValues();
355 $('#modal_submit').click(function() {
357 $('#payForm').submit();
360 $('#payForm').submit(function(e){
361 if (change != undefined && change.innerHTML > 0.00 && !checked) {
363 $("#confirm_change_form").modal("show");
365 var rows = sale_table.fnGetData();
366 rows.forEach(function (row, index) {
375 value: JSON.stringify(sale)
376 }).appendTo('#payForm');
382 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
383 $("#printReceipt").click(function() {
384 var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=[% payment_id | uri %]&collected=[% collected | uri %]&change=[% change | uri %]', '_blank');
387 $("#printReceipt").click();
393 [% INCLUDE 'intranet-bottom.inc' %]