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 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 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 = [] %]
116 [% FOR pt IN AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
117 [% NEXT IF pt.authorised_value.grep("^SIP[[:digit:]]{2}$").size() %]
118 [% payment_types.push(pt) %]
121 <label for="payment_type">Payment type: </label>
122 <select name="payment_type" id="payment_type">
123 [% FOREACH pt IN payment_types %]
124 <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
129 [% IF Koha.Preference('UseCashRegisters') %]
131 <label for="cash_register">Cash register: </label>
132 <select name="cash_register" id="cash_register">
133 [% FOREACH register IN registers %]
134 [% IF register.id == registerid %]
135 <option value="[% register.id | html %]" selected="selected">[% register.name | html %]</option>
137 <option value="[% register.id | html %]">[% register.name | html %]</option>
149 <input type="submit" name="submitbutton" value="Confirm" />
150 <a class="cancel" href="/cgi-bin/koha/pos/pay.pl">Cancel</a>
157 <div class="col-sm-2 col-sm-pull-10">
159 [% INCLUDE 'pos-menu.inc' %]
162 </div> <!-- /.row -->
165 <div id="confirm_change_form" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
166 <div class="modal-dialog">
167 <div class="modal-content">
168 <div class="modal-header">
169 <h3>The amount collected is more than the outstanding charge</h3>
171 <div class="modal-body">
172 <p>The amount collected from the patron is higher than the amount to be paid.</p>
173 <p>The change to give is <b><span id="modal_change">0.00</span></b>.</p>
174 <p>Confirm this payment?</p>
176 <div class="modal-footer">
177 <button class="btn btn-default approve" id="modal_submit" type="button"><i class="fa fa-check"></i> Yes</button>
178 <button class="btn btn-default deny cancel" href="#" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> No</button>
184 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
185 <!-- Automatic Print Receipt -->
186 <a id="printReceipt" style="display: none" href="#"></a>
189 [% MACRO jsinclude BLOCK %]
190 [% Asset.js("js/admin-menu.js") | $raw %]
191 [% INCLUDE 'format_price.inc' %]
192 [% INCLUDE 'datatables.inc' %]
193 [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
195 function moneyFormat(textObj) {
196 var newValue = textObj.value;
202 for(var i=0; i < newValue.length; i++) {
203 aChar = newValue.substring(i, i+1);
204 if (aChar >= "0" && aChar <= "9") {
206 decAmount = "" + decAmount + aChar;
209 dolAmount = "" + dolAmount + aChar;
221 if (dolAmount == "") {
225 if (dolAmount.length > 1) {
226 while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
227 dolAmount = dolAmount.substring(1,dolAmount.length);
230 if (decAmount.length > 2) {
231 decAmount = decAmount.substring(0,2);
234 if (decAmount.length == 1) {
235 decAmount = decAmount + "0";
237 if (decAmount.length == 0) {
238 decAmount = decAmount + "00";
241 textObj.value = dolAmount + "." + decAmount;
244 function fnClickAddRow( table, invoiceCode, invoiceTitle, invoicePrice ) {
245 var defaultPrice = { value: invoicePrice };
246 moneyFormat(defaultPrice);
252 '<button class="drop"><i class="fa fa-trash"></i> Remove</button>',
258 function updateChangeValues() {
259 var change = $('#change')[0];
260 change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
261 if (change.innerHTML <= 0) {
262 change.innerHTML = "0.00";
264 change.value = change.innerHTML;
266 change.innerHTML = change.value;
269 $(':input[name="change"]').val(change.value);
270 $('#modal_change').html(change.innerHTML);
273 $(document).ready(function() {
274 var sale_table = $("#sale").dataTable($.extend(true, {}, dataTablesDefaults, {
282 "bSearchable": false,
285 "mRender": function ( data, type, full ) {
286 var price = Number.parseFloat(data);
287 return price.format_price();
291 "sClass" : "editable",
294 "sClass" : "editable_int",
303 "fnDrawCallback": function (oSettings) {
305 local.$('.editable').editable( function(value, settings) {
306 var aPos = local.fnGetPosition( this );
307 local.fnUpdate( value, aPos[0], aPos[1], true, false );
315 local.$('.editable_int').editable( function(value, settings) {
316 var aPos = local.fnGetPosition( this );
317 local.fnUpdate( value, aPos[0], aPos[1], true, false );
326 "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
327 var iTotal = aData[1] * aData[2];
328 this.fnUpdate( iTotal, nRow, 3, false, false );
330 "fnFooterCallback": function(nFoot, aData, iStart, iEnd, aiDisplay) {
332 for ( var i=0 ; i<aData.length ; i++ )
334 iTotalPrice += aData[i][3]*1;
336 nFoot.getElementsByTagName('td')[1].innerHTML = iTotalPrice.format_price();
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 $("#printReceipt").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 $("#printReceipt").click();
408 [% INCLUDE 'intranet-bottom.inc' %]