6 [% USE TablesSettings %]
9 [% PROCESS 'payments.inc' %]
10 [% INCLUDE 'doc-head-open.inc' %]
11 [% SET registers = Registers.all( filters => { current_branch => 1 } ) %]
12 <title>Koha › Payments</title>
13 [% INCLUDE 'doc-head-close.inc' %]
16 <body id="payments" class="pos">
17 [% INCLUDE 'header.inc' %]
18 [% INCLUDE 'circ-search.inc' %]
20 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › Point of sale</div>
22 <div class="main container-fluid">
24 <div class="col-sm-10 col-sm-push-2">
26 [% IF ( registers.size == 0 ) %]
27 <div id="error_message" class="dialog message">
29 You must have at least one cash register associated with the library before you can record payments.
31 [% IF ( CAN_user_parameters_manage_cash_registers ) %]
32 <form action="/cgi-bin/koha/admin/cash_registers.pl" method="get">
33 <input type="hidden" name="op" value="add_form" />
34 <button class="new" type="submit"><i class="fa fa-plus"></i> Create a new cash register</button>
40 [% IF payment_id && !Koha.Preference('FinePaymentAutoPopup') %]
41 <div class="dialog alert audio-alert-action">
42 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>
46 <form name="payForm" id="payForm" method="post" action="/cgi-bin/koha/pos/pay.pl">
49 <div class="col-sm-6">
50 <fieldset class="rows">
51 <legend>Items for purchase</legend>
52 Please select items from below to add to this transaction:
53 [% IF invoice_types %]
59 <th class="NoSort">Cost</th>
60 <th class="NoSort">Action</th>
64 [% FOREACH invoice IN invoice_types %]
66 <td>[% invoice.code | html %]</td>
67 <td>[% invoice.description | html %]</td>
68 <td>[% invoice.default_amount | $Price %]</td>
70 <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>
76 You have no manual invoice types defined
81 <div class="col-sm-6">
83 <fieldset class="rows">
84 <legend>This sale</legend>
85 <p>Click to edit item cost or quantities</p>
86 <table id="sale" class="table_sale">
101 <td colspan="3">Total payable:</td>
110 <fieldset class="rows">
111 <legend>Collect payment</legend>
114 <label for="paid">Amount being paid: </label>
115 <input type="text" inputmode="none" pattern="[0-9]*" name="paid" id="paid" value="" readonly/>
118 <label for="collected" class="required">Amount tendered: </label>
119 <input type="text" inputmode="numeric" pattern="[0-9]*" name="collected" id="collected" value="" class="required" required="required" />
120 <span class="required">Required</span>
123 <label>Change to give: </label>
124 <span id="change">[% 0 | $Price %]</span>
125 <input type="hidden" name="change" value="[% 0 | $Price %]"/>
128 [% PROCESS account_payment_types %]
131 <label for="registerid" class="required">Cash register: </label>
132 <select name="registerid" id="registerid" class="required" required="required">
133 <option id="noregister" disabled selected="selected" value="">-- Select an option--</option>
134 [% PROCESS options_for_registers %]
136 <span class="required">Required</span>
143 <input type="submit" id="submitbutton" name="submitbutton" value="Confirm" />
144 <a class="cancel" href="/cgi-bin/koha/pos/pay.pl">Cancel</a>
152 <div class="col-sm-2 col-sm-pull-10">
154 [% INCLUDE 'pos-menu.inc' %]
157 </div> <!-- /.row -->
160 <div id="confirm_change_form" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
161 <div class="modal-dialog">
162 <div class="modal-content">
163 <div class="modal-header">
164 <h3>The amount collected is more than the outstanding charge</h3>
166 <div class="modal-body">
167 <p>The amount collected from the patron is higher than the amount to be paid.</p>
168 <p>The change to give is <strong><span id="modal_change">[% 0 | $Price %]</span></strong>.</p>
169 <p>Confirm this payment?</p>
171 <div class="modal-footer">
172 <button class="btn btn-default approve" id="modal_submit" type="button"><i class="fa fa-check"></i> Yes</button>
173 <button class="btn btn-default deny cancel" href="#" data-dismiss="modal" aria-hidden="true" type="button"><i class="fa fa-times"></i> No</button>
179 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
180 <!-- Automatic Print Receipt -->
181 <a id="printReceipt" style="display: none" href="#"></a>
184 [% MACRO jsinclude BLOCK %]
185 [% INCLUDE 'format_price.inc' %]
186 [% INCLUDE 'datatables.inc' %]
187 [% INCLUDE 'columns_settings.inc' %]
188 [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
190 function moneyFormat(textObj) {
191 var newValue = textObj.value;
197 for(var i=0; i < newValue.length; i++) {
198 aChar = newValue.substring(i, i+1);
199 if (aChar >= "0" && aChar <= "9") {
201 decAmount = "" + decAmount + aChar;
204 dolAmount = "" + dolAmount + aChar;
216 if (dolAmount == "") {
220 if (dolAmount.length > 1) {
221 while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
222 dolAmount = dolAmount.substring(1,dolAmount.length);
225 if (decAmount.length > 2) {
226 decAmount = decAmount.substring(0,2);
229 if (decAmount.length == 1) {
230 decAmount = decAmount + "0";
232 if (decAmount.length == 0) {
233 decAmount = decAmount + "00";
236 textObj.value = dolAmount + "." + decAmount;
239 function fnClickAddRow( table, invoiceCode, invoiceTitle, invoicePrice ) {
240 var defaultPrice = { value: invoicePrice };
241 moneyFormat(defaultPrice);
247 '<button class="btn btn-default btn-xs drop" type="button"><i class="fa fa-trash"></i> Remove</button>',
253 function updateChangeValues() {
254 var change = $('#change')[0];
255 var zero_formatted = "[% 0 | $Price %]";
256 change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
257 if (change.innerHTML <= 0) {
258 var paid = $('#paid')[0];
260 $('#collected').rules( "add", { min: Number(paid.value) });
261 change.innerHTML = zero_formatted;
262 $(':input[name="change"]').val(zero_formatted);
264 change.value = change.innerHTML;
266 change.innerHTML = change.value;
267 $(':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, {
281 "bSearchable": false,
284 "mRender": function ( data, type, full ) {
285 var price = Number.parseFloat(data);
286 return price.format_price();
290 "sClass" : "editable",
293 "sClass" : "editable_int",
302 "fnDrawCallback": function (oSettings) {
304 local.$('.editable').editable( function(value, settings) {
305 var aPos = local.fnGetPosition( this );
306 local.fnUpdate( value, aPos[0], aPos[1], true, false );
310 pattern : "^\\d+(\.\\d{2})?$",
314 local.$('.editable_int').editable( function(value, settings) {
315 var aPos = local.fnGetPosition( this );
316 local.fnUpdate( value, aPos[0], aPos[1], true, false );
325 "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
326 var iTotal = aData[1] * aData[2];
327 this.fnUpdate( iTotal, nRow, 3, false, false );
329 "fnFooterCallback": function(nFoot, aData, iStart, iEnd, aiDisplay) {
331 for ( var i=0 ; i<aData.length ; i++ )
333 iTotalPrice += aData[i][3]*1;
335 nFoot.getElementsByTagName('td')[1].innerHTML = iTotalPrice.format_price();
336 $('#paid').val(iTotalPrice);
337 $('#paid').trigger('change');
341 $("#sale").on("click", "button.drop", function(){
342 sale_table.DataTable().row($(this).parents('tr')).remove().draw(false);
345 var items_columns_settings = [% TablesSettings.GetColumns('pos', 'pay', 'invoices', 'json') | $raw %];
346 var items_table = KohaTable("invoices", {
347 "sPaginationType": "full",
348 "aaSorting": [[ 0, "asc" ]],
349 }, items_columns_settings, false);
351 $("#invoices").on("click", ".add_button", function(e) {
353 fnClickAddRow(sale_table, $( this ).data('invoiceCode'), $( this ).data('invoiceTitle'), $( this ).data('invoicePrice') );
354 if($('#invoices_filter').find('input[type=search]').val() !== ''){
355 items_table.fnFilter( '' );
359 // Change calculation and modal
360 var change = $('#change')[0];
361 $("#paid, #collected").on("change",function() {
363 if (change != undefined) {
364 updateChangeValues();
369 $('#modal_submit').click(function() {
371 $('#payForm').submit();
374 $('#payForm').validate({
391 $('#payForm').submit(function(e){
392 if (change != undefined && change.innerHTML > 0.00 && !checked) {
394 $("#confirm_change_form").modal("show");
396 var rows = sale_table.fnGetData();
397 rows.forEach(function (row, index) {
406 value: JSON.stringify(sale)
407 }).appendTo('#payForm');
413 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
414 $("#printReceipt").click(function() {
415 var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=[% payment_id | uri %]&collected=[% collected | uri %]&change=[% change | uri %]', '_blank');
418 $("#printReceipt").click();
424 [% INCLUDE 'intranet-bottom.inc' %]