4 [% USE AuthorisedValues %]
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.
27 <form name="payForm" id="payForm" method="post" action="/cgi-bin/koha/pos/pay.pl">
30 <div class="col-sm-6">
31 <fieldset class="rows">
32 <legend>Items for purchase</legend>
33 Please select items from below to add to this transaction:
34 [% IF invoice_types %]
45 [% FOREACH invoice IN invoice_types %]
47 <td>[% invoice.code | html %]</td>
48 <td>[% invoice.description | html %]</td>
49 <td>[% invoice.default_amount | $Price %]</td>
51 <button class="add_button" data-invoice-code="[% invoice.code %]" data-invoice-title="[% invoice.description | html %]" data-invoice-price="[% invoice.default_amount | html %]"><i class="fa fa-plus"></i> Add</button>
57 You have no manual invoice types defined
62 <div class="col-sm-6">
64 <fieldset class="rows">
65 <legend>This sale</legend>
66 <p>Click to edit item cost or quantities</p>
67 <table id="sale" class="table_sale">
82 <td colspan="3">Total payable:</td>
91 <fieldset class="rows">
92 <legend>Collect payment</legend>
95 <label for="paid">Amount being paid: </label>
96 <input type="number" min="0.00" max="10000.00" step="0.01" name="paid" id="paid" value="[% amountoutstanding | $Price on_editing => 1 %]" readonly/>
99 <label for="collected">Collected from patron: </label>
100 <input type="number" min="0.00" max="10000.00" step="0.01" name="collected" id="collected" value=""/>
103 <label>Change to give: </label>
104 <span id="change">0.00</span>
105 <input type="hidden" name="change" value="0.00"/>
108 [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
109 [% IF payment_types %]
111 <label for="payment_type">Payment type: </label>
112 <select name="payment_type" id="payment_type">
113 [% FOREACH pt IN payment_types %]
114 <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
120 [% IF Koha.Preference('UseCashRegisters') %]
122 <label for="cash_register">Cash register: </label>
123 <select name="cash_register" id="cash_register">
124 [% FOREACH register IN registers %]
125 [% IF register.id == registerid %]
126 <option value="[% register.id %]" selected="selected">[% register.name | html %]</option>
128 <option value="[% register.id %]">[% register.name | html %]</option>
140 <input type="submit" name="submitbutton" value="Confirm" />
141 <a class="cancel" href="/cgi-bin/koha/pos/pay.pl">Cancel</a>
148 <div class="col-sm-2 col-sm-pull-10">
150 [% INCLUDE 'pos-menu.inc' %]
153 </div> <!-- /.row -->
156 <div id="confirm_change_form" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
157 <div class="modal-dialog">
158 <div class="modal-content">
159 <div class="modal-header">
160 <h3>The amount collected is more than the outstanding charge</h3>
162 <div class="modal-body">
163 <p>The amount collected from the patron is higher than the amount to be paid.</p>
164 <p>The change to give is <b><span id="modal_change">0.00</span></b>.</p>
165 <p>Confirm this payment?</p>
167 <div class="modal-footer">
168 <button class="btn btn-default approve" id="modal_submit" type="button"><i class="fa fa-check"></i> Yes</button>
169 <button class="btn btn-default deny cancel" href="#" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> No</button>
175 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
176 <!-- Automatic Print Reciept -->
177 <a id="printReciept" style="display: none" href="#"></a>
180 [% MACRO jsinclude BLOCK %]
181 [% Asset.js("js/admin-menu.js") | $raw %]
182 [% INCLUDE 'format_price.inc' %]
183 [% INCLUDE 'datatables.inc' %]
184 [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
186 function moneyFormat(textObj) {
187 var newValue = textObj.value;
193 for(var i=0; i < newValue.length; i++) {
194 aChar = newValue.substring(i, i+1);
195 if (aChar >= "0" && aChar <= "9") {
197 decAmount = "" + decAmount + aChar;
200 dolAmount = "" + dolAmount + aChar;
212 if (dolAmount == "") {
216 if (dolAmount.length > 1) {
217 while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
218 dolAmount = dolAmount.substring(1,dolAmount.length);
221 if (decAmount.length > 2) {
222 decAmount = decAmount.substring(0,2);
225 if (decAmount.length == 1) {
226 decAmount = decAmount + "0";
228 if (decAmount.length == 0) {
229 decAmount = decAmount + "00";
232 textObj.value = dolAmount + "." + decAmount;
235 function fnClickAddRow( table, invoiceCode, invoiceTitle, invoicePrice ) {
236 var defaultPrice = { value: invoicePrice };
237 moneyFormat(defaultPrice);
243 '<button class="drop"><i class="fa fa-trash"></i> Remove</button>',
249 function updateChangeValues() {
250 var change = $('#change')[0];
251 change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
252 if (change.innerHTML <= 0) {
253 change.innerHTML = "0.00";
255 change.value = change.innerHTML;
257 change.innerHTML = change.value;
260 $(':input[name="change"]').val(change.value);
261 $('#modal_change').html(change.innerHTML);
264 $(document).ready(function() {
265 var sale_table = $("#sale").dataTable($.extend(true, {}, dataTablesDefaults, {
273 "bSearchable": false,
276 "mRender": function ( data, type, full ) {
277 var price = Number.parseFloat(data);
278 return price.format_price();
282 "sClass" : "editable",
285 "sClass" : "editable_int",
294 "fnDrawCallback": function (oSettings) {
296 local.$('.editable').editable( function(value, settings) {
297 var aPos = local.fnGetPosition( this );
298 local.fnUpdate( value, aPos[0], aPos[1], true, false );
305 local.$('.editable_int').editable( function(value, settings) {
306 var aPos = local.fnGetPosition( this );
307 local.fnUpdate( value, aPos[0], aPos[1], true, false );
315 "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
316 var iTotal = aData[1] * aData[2];
317 this.fnUpdate( iTotal.format_price(), nRow, 3, false, false );
319 "fnFooterCallback": function(nFoot, aData, iStart, iEnd, aiDisplay) {
321 for ( var i=0 ; i<aData.length ; i++ )
323 iTotalPrice += aData[i][3]*1;
326 iTotalPrice = Number.parseFloat(iTotalPrice).toFixed(2);
327 nFoot.getElementsByTagName('td')[1].innerHTML = iTotalPrice;
328 $('#paid').val(iTotalPrice);
329 $('#paid').trigger('change');
333 $("#sale").on("click", "button.drop", function(){
334 sale_table.DataTable().row($(this).parents('tr')).remove().draw(false);
337 var items_table = $("#invoices").dataTable($.extend(true,{}, dataTablesDefaults, {
339 { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable":false },
341 "aaSorting": [[ 0, "asc" ]],
342 "paginationType": "full",
345 $(".add_button").on("click", function(e) {
347 fnClickAddRow(sale_table, $( this ).data('invoiceCode'), $( this ).data('invoiceTitle'), $( this ).data('invoicePrice') );
348 items_table.fnFilter( '' );
351 // Change calculation and modal
352 var change = $('#change')[0];
353 $("#paid, #collected").on("change",function() {
355 if (change != undefined) {
356 updateChangeValues();
361 $('#modal_submit').click(function() {
363 $('#payForm').submit();
366 $('#payForm').submit(function(e){
367 if (change != undefined && change.innerHTML > 0.00 && !checked) {
369 $("#confirm_change_form").modal("show");
371 var rows = sale_table.fnGetData();
372 rows.forEach(function (row, index) {
381 value: JSON.stringify(sale)
382 }).appendTo('#payForm');
388 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
389 $("#printReciept").click(function() {
390 var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=[% payment_id | uri %]&collected=[% collected | uri %]&change=[% change | uri %]', '_blank');
393 $("#printReciept").click();
399 [% INCLUDE 'intranet-bottom.inc' %]