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="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="number" min="0.00" max="10000.00" step="0.01" name="paid" id="paid" value="[% amountoutstanding | $Price on_editing => 1 %]" readonly/>
118 <label for="collected">Amount tendered: </label>
119 <input type="number" min="0.00" max="10000.00" step="0.01" name="collected" id="collected" value=""/>
122 <label>Change to give: </label>
123 <span id="change">[% 0 | $Price %]</span>
124 <input type="hidden" name="change" value="[% 0 | $Price %]"/>
127 [% PROCESS account_payment_types %]
130 <label for="registerid">Cash register: </label>
131 <select name="registerid" id="registerid">
132 <option id="noregister" disabled selected="selected" value="">-- Select an option--</option>
133 [% PROCESS options_for_registers %]
141 <input type="submit" id="submitbutton" name="submitbutton" value="Confirm" />
142 <a class="cancel" href="/cgi-bin/koha/pos/pay.pl">Cancel</a>
150 <div class="col-sm-2 col-sm-pull-10">
152 [% INCLUDE 'pos-menu.inc' %]
155 </div> <!-- /.row -->
158 <div id="confirm_change_form" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
159 <div class="modal-dialog">
160 <div class="modal-content">
161 <div class="modal-header">
162 <h3>The amount collected is more than the outstanding charge</h3>
164 <div class="modal-body">
165 <p>The amount collected from the patron is higher than the amount to be paid.</p>
166 <p>The change to give is <strong><span id="modal_change">[% 0 | $Price %]</span></strong>.</p>
167 <p>Confirm this payment?</p>
169 <div class="modal-footer">
170 <button class="btn btn-default approve" id="modal_submit" type="button"><i class="fa fa-check"></i> Yes</button>
171 <button class="btn btn-default deny cancel" href="#" data-dismiss="modal" aria-hidden="true" type="button"><i class="fa fa-times"></i> No</button>
177 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
178 <!-- Automatic Print Receipt -->
179 <a id="printReceipt" style="display: none" href="#"></a>
182 [% MACRO jsinclude BLOCK %]
183 [% INCLUDE 'format_price.inc' %]
184 [% INCLUDE 'datatables.inc' %]
185 [% INCLUDE 'columns_settings.inc' %]
186 [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
188 function moneyFormat(textObj) {
189 var newValue = textObj.value;
195 for(var i=0; i < newValue.length; i++) {
196 aChar = newValue.substring(i, i+1);
197 if (aChar >= "0" && aChar <= "9") {
199 decAmount = "" + decAmount + aChar;
202 dolAmount = "" + dolAmount + aChar;
214 if (dolAmount == "") {
218 if (dolAmount.length > 1) {
219 while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
220 dolAmount = dolAmount.substring(1,dolAmount.length);
223 if (decAmount.length > 2) {
224 decAmount = decAmount.substring(0,2);
227 if (decAmount.length == 1) {
228 decAmount = decAmount + "0";
230 if (decAmount.length == 0) {
231 decAmount = decAmount + "00";
234 textObj.value = dolAmount + "." + decAmount;
237 function fnClickAddRow( table, invoiceCode, invoiceTitle, invoicePrice ) {
238 var defaultPrice = { value: invoicePrice };
239 moneyFormat(defaultPrice);
245 '<button class="drop" type="button"><i class="fa fa-trash"></i> Remove</button>',
251 function updateChangeValues() {
252 var change = $('#change')[0];
253 var zero_formatted = "[% 0 | $Price %]";
254 change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
255 if (change.innerHTML <= 0) {
256 change.innerHTML = zero_formatted;
258 change.value = change.innerHTML;
260 change.innerHTML = change.value;
263 $(':input[name="change"]').val(change.value);
264 $('#modal_change').html(change.innerHTML);
267 $(document).ready(function() {
268 var sale_table = $("#sale").dataTable($.extend(true, {}, dataTablesDefaults, {
275 "bSearchable": false,
278 "mRender": function ( data, type, full ) {
279 var price = Number.parseFloat(data);
280 return price.format_price();
284 "sClass" : "editable",
287 "sClass" : "editable_int",
296 "fnDrawCallback": function (oSettings) {
298 local.$('.editable').editable( function(value, settings) {
299 var aPos = local.fnGetPosition( this );
300 local.fnUpdate( value, aPos[0], aPos[1], true, false );
308 local.$('.editable_int').editable( function(value, settings) {
309 var aPos = local.fnGetPosition( this );
310 local.fnUpdate( value, aPos[0], aPos[1], true, false );
319 "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
320 var iTotal = aData[1] * aData[2];
321 this.fnUpdate( iTotal, nRow, 3, false, false );
323 "fnFooterCallback": function(nFoot, aData, iStart, iEnd, aiDisplay) {
325 for ( var i=0 ; i<aData.length ; i++ )
327 iTotalPrice += aData[i][3]*1;
329 nFoot.getElementsByTagName('td')[1].innerHTML = iTotalPrice.format_price();
330 $('#paid').val(iTotalPrice);
331 $('#paid').trigger('change');
335 $("#sale").on("click", "button.drop", function(){
336 sale_table.DataTable().row($(this).parents('tr')).remove().draw(false);
339 var items_columns_settings = [% TablesSettings.GetColumns('pos', 'pay', 'invoices', 'json') | $raw %];
340 var items_table = KohaTable("invoices", {
341 "sPaginationType": "full",
342 "aaSorting": [[ 0, "asc" ]],
343 }, items_columns_settings, false);
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 $('#payForm').validate({
399 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
400 $("#printReceipt").click(function() {
401 var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=[% payment_id | uri %]&collected=[% collected | uri %]&change=[% change | uri %]', '_blank');
404 $("#printReceipt").click();
410 [% INCLUDE 'intranet-bottom.inc' %]