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.
28 [% IF payment_id && !Koha.Preference('FinePaymentAutoPopup') %]
29 <div class="dialog alert audio-alert-action">
30 Payment recieved: <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 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 [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
116 [% IF payment_types %]
118 <label for="payment_type">Payment type: </label>
119 <select name="payment_type" id="payment_type">
120 [% FOREACH pt IN payment_types %]
121 <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
127 [% IF Koha.Preference('UseCashRegisters') %]
129 <label for="cash_register">Cash register: </label>
130 <select name="cash_register" id="cash_register">
131 [% FOREACH register IN registers %]
132 [% IF register.id == registerid %]
133 <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
135 <option value="[% register.id | html %]">[% register.name | html %]</option>
147 <input type="submit" name="submitbutton" value="Confirm" />
148 <a class="cancel" href="/cgi-bin/koha/pos/pay.pl">Cancel</a>
155 <div class="col-sm-2 col-sm-pull-10">
157 [% INCLUDE 'pos-menu.inc' %]
160 </div> <!-- /.row -->
163 <div id="confirm_change_form" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
164 <div class="modal-dialog">
165 <div class="modal-content">
166 <div class="modal-header">
167 <h3>The amount collected is more than the outstanding charge</h3>
169 <div class="modal-body">
170 <p>The amount collected from the patron is higher than the amount to be paid.</p>
171 <p>The change to give is <b><span id="modal_change">0.00</span></b>.</p>
172 <p>Confirm this payment?</p>
174 <div class="modal-footer">
175 <button class="btn btn-default approve" id="modal_submit" type="button"><i class="fa fa-check"></i> Yes</button>
176 <button class="btn btn-default deny cancel" href="#" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> No</button>
182 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
183 <!-- Automatic Print Reciept -->
184 <a id="printReciept" style="display: none" href="#"></a>
187 [% MACRO jsinclude BLOCK %]
188 [% Asset.js("js/admin-menu.js") | $raw %]
189 [% INCLUDE 'format_price.inc' %]
190 [% INCLUDE 'datatables.inc' %]
191 [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
193 function moneyFormat(textObj) {
194 var newValue = textObj.value;
200 for(var i=0; i < newValue.length; i++) {
201 aChar = newValue.substring(i, i+1);
202 if (aChar >= "0" && aChar <= "9") {
204 decAmount = "" + decAmount + aChar;
207 dolAmount = "" + dolAmount + aChar;
219 if (dolAmount == "") {
223 if (dolAmount.length > 1) {
224 while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
225 dolAmount = dolAmount.substring(1,dolAmount.length);
228 if (decAmount.length > 2) {
229 decAmount = decAmount.substring(0,2);
232 if (decAmount.length == 1) {
233 decAmount = decAmount + "0";
235 if (decAmount.length == 0) {
236 decAmount = decAmount + "00";
239 textObj.value = dolAmount + "." + decAmount;
242 function fnClickAddRow( table, invoiceCode, invoiceTitle, invoicePrice ) {
243 var defaultPrice = { value: invoicePrice };
244 moneyFormat(defaultPrice);
250 '<button class="drop"><i class="fa fa-trash"></i> Remove</button>',
256 function updateChangeValues() {
257 var change = $('#change')[0];
258 change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
259 if (change.innerHTML <= 0) {
260 change.innerHTML = "0.00";
262 change.value = change.innerHTML;
264 change.innerHTML = change.value;
267 $(':input[name="change"]').val(change.value);
268 $('#modal_change').html(change.innerHTML);
271 $(document).ready(function() {
272 var sale_table = $("#sale").dataTable($.extend(true, {}, dataTablesDefaults, {
280 "bSearchable": false,
283 "mRender": function ( data, type, full ) {
284 var price = Number.parseFloat(data);
285 return price.format_price();
289 "sClass" : "editable",
292 "sClass" : "editable_int",
301 "fnDrawCallback": function (oSettings) {
303 local.$('.editable').editable( function(value, settings) {
304 var aPos = local.fnGetPosition( this );
305 local.fnUpdate( value, aPos[0], aPos[1], true, false );
313 local.$('.editable_int').editable( function(value, settings) {
314 var aPos = local.fnGetPosition( this );
315 local.fnUpdate( value, aPos[0], aPos[1], true, false );
324 "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
325 var iTotal = aData[1] * aData[2];
326 this.fnUpdate( iTotal.format_price(), nRow, 3, false, false );
328 "fnFooterCallback": function(nFoot, aData, iStart, iEnd, aiDisplay) {
330 for ( var i=0 ; i<aData.length ; i++ )
332 iTotalPrice += aData[i][3]*1;
335 iTotalPrice = Number.parseFloat(iTotalPrice).toFixed(2);
336 nFoot.getElementsByTagName('td')[1].innerHTML = iTotalPrice;
337 $('#paid').val(iTotalPrice);
338 $('#paid').trigger('change');
342 $("#sale").on("click", "button.drop", function(){
343 sale_table.DataTable().row($(this).parents('tr')).remove().draw(false);
346 var items_table = $("#invoices").dataTable($.extend(true,{}, dataTablesDefaults, {
348 { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable":false },
350 "aaSorting": [[ 0, "asc" ]],
351 "paginationType": "full",
354 $(".add_button").on("click", function(e) {
356 fnClickAddRow(sale_table, $( this ).data('invoiceCode'), $( this ).data('invoiceTitle'), $( this ).data('invoicePrice') );
357 items_table.fnFilter( '' );
360 // Change calculation and modal
361 var change = $('#change')[0];
362 $("#paid, #collected").on("change",function() {
364 if (change != undefined) {
365 updateChangeValues();
370 $('#modal_submit').click(function() {
372 $('#payForm').submit();
375 $('#payForm').submit(function(e){
376 if (change != undefined && change.innerHTML > 0.00 && !checked) {
378 $("#confirm_change_form").modal("show");
380 var rows = sale_table.fnGetData();
381 rows.forEach(function (row, index) {
390 value: JSON.stringify(sale)
391 }).appendTo('#payForm');
397 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
398 $("#printReciept").click(function() {
399 var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=[% payment_id | uri %]&collected=[% collected | uri %]&change=[% change | uri %]', '_blank');
402 $("#printReciept").click();
408 [% INCLUDE 'intranet-bottom.inc' %]