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">
32 <fieldset class="rows">
33 <legend>This sale</legend>
34 <p>Click to edit item cost or quantities</p>
35 <table id="sale" class="table_sale">
48 <td colspan="3">Total payable:</td>
55 <fieldset class="rows">
56 <legend>Collect payment</legend>
59 <label for="paid">Amount being paid: </label>
60 <input name="paid" id="paid" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
63 <label for="collected">Collected from patron: </label>
64 <input id="collected" value="[% amountoutstanding | $Price on_editing => 1 %]"/>
67 <label>Change to give: </label>
68 <span id="change">0.00</span>
71 [% SET payment_types = AuthorisedValues.GetAuthValueDropbox('PAYMENT_TYPE') %]
72 [% IF payment_types %]
74 <label for="payment_type">Payment type: </label>
75 <select name="payment_type" id="payment_type">
76 [% FOREACH pt IN payment_types %]
77 <option value="[% pt.authorised_value | html %]">[% pt.lib | html %]</option>
83 [% IF Koha.Preference('UseCashRegisters') %]
85 <label for="cash_register">Cash register: </label>
86 <select name="cash_register" id="cash_register">
87 [% FOREACH register IN registers %]
88 [% IF register.id == registerid %]
89 <option value="[% register.id %]" selected="selected">[% register.name | html %]</option>
91 <option value="[% register.id %]">[% register.name | html %]</option>
102 <div class="col-sm-6">
103 <fieldset class="rows">
104 <legend>Items for purchase</legend>
105 [% SET invoice_types = AuthorisedValues.GetAuthValueDropbox('MANUAL_INV') %]
106 [% IF invoice_types %]
107 <table id="invoices">
117 [% FOREACH invoice IN invoice_types %]
119 <td>[% invoice.authorised_value | html %]</td>
120 <td>[% invoice.lib_opac | html %]</td>
121 <td>[% invoice.lib | html %]</td>
123 <button class="add_button" data-invoice-code="[% invoice.lib_opac %]" data-invoice-title="[% invoice.authorised_value | html %]" data-invoice-price="[% invoice.lib | html %]"><i class="fa fa-plus"></i> Add</button>
129 You have no manual invoice types defined
135 <input type="submit" name="submitbutton" value="Confirm" />
136 <a class="cancel" href="/cgi-bin/koha/pos/pay.pl">Cancel</a>
143 <div class="col-sm-2 col-sm-pull-10">
145 [% INCLUDE 'pos-menu.inc' %]
149 </div> <!-- /.row -->
151 [% MACRO jsinclude BLOCK %]
152 [% Asset.js("js/admin-menu.js") | $raw %]
153 [% INCLUDE 'datatables.inc' %]
154 [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
156 function fnClickAddRow( table, invoiceTitle, invoicePrice ) {
166 function moneyFormat(textObj) {
167 var newValue = textObj.value;
173 for(i=0; i < newValue.length; i++) {
174 aChar = newValue.substring(i, i+1);
175 if (aChar >= "0" && aChar <= "9") {
177 decAmount = "" + decAmount + aChar;
180 dolAmount = "" + dolAmount + aChar;
192 if (dolAmount == "") {
196 if (dolAmount.length > 1) {
197 while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
198 dolAmount = dolAmount.substring(1,dolAmount.length);
201 if (decAmount.length > 2) {
202 decAmount = decAmount.substring(0,2);
205 if (decAmount.length == 1) {
206 decAmount = decAmount + "0";
208 if (decAmount.length == 0) {
209 decAmount = decAmount + "00";
212 textObj.value = dolAmount + "." + decAmount;
215 function updateChangeValues() {
216 var change = $('#change')[0];
217 change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
218 if (change.innerHTML <= 0) {
219 change.innerHTML = "0.00";
221 change.value = change.innerHTML;
223 change.innerHTML = change.value;
225 $('#modal_change').html(change.innerHTML);
228 $(document).ready(function() {
229 var sale_table = $("#sale").dataTable($.extend(true, {}, dataTablesDefaults, {
237 "bSearchable": false,
240 "mRender": function ( data, type, full ) {
241 var price = Number.parseFloat(data).toFixed(2);
245 "aTargets": [-2, -3],
246 "sClass" : "editable",
251 "fnDrawCallback": function (oSettings) {
253 local.$('.editable').editable( function(value, settings) {
254 var aPos = local.fnGetPosition( this );
255 local.fnUpdate( value, aPos[0], aPos[1], true, false );
261 "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
262 var iTotal = aData[1] * aData[2];
263 this.fnUpdate( iTotal, nRow, 3, false, false );
265 "fnFooterCallback": function(nFoot, aData, iStart, iEnd, aiDisplay) {
267 for ( var i=0 ; i<aData.length ; i++ )
269 iTotalPrice += aData[i][3]*1;
272 iTotalPrice = Number.parseFloat(iTotalPrice).toFixed(2);
273 nFoot.getElementsByTagName('td')[1].innerHTML = iTotalPrice;
274 $('#paid').val(iTotalPrice);
278 var items_table = $("#invoices").dataTable($.extend(true,{}, dataTablesDefaults, {
280 { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable":false },
282 "aaSorting": [[ 0, "asc" ]],
283 "paginationType": "full",
286 $(".add_button").on("click", function(ev) {
288 fnClickAddRow(sale_table, $( this ).data('invoiceTitle'), $( this ).data('invoicePrice') );
289 items_table.fnFilter( '' );
292 $("#paid, #collected").on("change",function() {
294 if (change != undefined) {
295 updateChangeValues();
299 $("#payForm").submit(function(e){
300 var rows = sale_table.fnGetData();
301 rows.forEach(function (row, index) {
310 value: JSON.stringify(sale)
311 }).appendTo('#payForm');
319 [% INCLUDE 'intranet-bottom.inc' %]