2 [% USE AdditionalContents %]
7 [% USE TablesSettings %]
9 [% PROCESS 'i18n.inc' %]
10 [% SET footerjs = 1 %]
11 [% INCLUDE 'doc-head-open.inc' %]
12 [% SET registers = Registers.all( filters => { current_branch => 1 } ) %]
13 <title>[% FILTER collapse %]
14 [% t("Point of sale") | html %] ›
15 [% t("Koha") | html %]
17 [% INCLUDE 'doc-head-close.inc' %]
20 <body id="payments" class="pos">
21 [% WRAPPER 'header.inc' %]
22 [% INCLUDE 'circ-search.inc' %]
25 [% WRAPPER 'sub-header.inc' %]
26 [% WRAPPER breadcrumbs %]
27 [% WRAPPER breadcrumb_item bc_active= 1 %]
28 <span>Point of sale</span>
30 [% END #/ WRAPPER breadcrumbs %]
31 [% END #/ WRAPPER sub-header.inc %]
33 <div class="main container-fluid">
35 <div class="col-md-10 col-md-push-2">
37 <h1>Point of sale</h1>
39 [% IF ( registers.size == 0 ) %]
40 <div id="error_message" class="dialog message">
42 You must have at least one cash register associated with the library before you can record payments.
44 [% IF ( CAN_user_parameters_manage_cash_registers ) %]
45 <form action="/cgi-bin/koha/admin/cash_registers.pl" method="get">
46 <input type="hidden" name="op" value="add_form" />
47 <button class="new" type="submit"><i class="fa fa-plus"></i> Create a new cash register</button>
53 [% IF payment_id && !Koha.Preference('FinePaymentAutoPopup') %]
54 <div class="dialog message audio-alert-action">
55 <p>Payment received</p>
57 <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"><i class="fa fa-print"></i> Print receipt</a>
58 <a href="#" data-toggle="modal" data-target="#emailReceiptModal" class="btn btn-default"><i class="fa-solid fa-envelope"></i> Email receipt</a>
64 <form name="payForm" id="payForm" method="post" action="/cgi-bin/koha/pos/pay.pl">
67 <div class="col-md-6">
68 <fieldset class="rows">
69 <legend>Items for purchase</legend>
70 Please select items from below to add to this transaction:
71 [% IF invoice_types %]
77 <th class="NoSort">Cost</th>
78 <th class="NoSort">Action</th>
82 [% FOREACH invoice IN invoice_types %]
84 <td>[% invoice.code | html %]</td>
85 <td>[% invoice.description | html %]</td>
86 <td>[% invoice.default_amount | $Price %]</td>
88 <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>
94 You have no manual invoice types defined
99 <div class="col-md-6">
101 <fieldset class="rows">
102 <legend>This sale</legend>
103 <p>Click to edit item cost or quantities</p>
104 <table id="sale" class="table_sale">
119 <td colspan="3">Total payable:</td>
128 <fieldset class="rows">
129 <legend>Collect payment</legend>
132 <label for="paid">Amount being paid: </label>
133 <input type="text" inputmode="none" pattern="[0-9]*" name="paid" id="paid" value="" readonly/>
136 <label for="collected" class="required">Amount tendered: </label>
137 <input type="text" inputmode="numeric" pattern="[0-9]*" name="collected" id="collected" value="" class="required" required="required" />
138 <span class="required">Required</span>
141 <label>Change to give: </label>
142 <span id="change">[% 0 | $Price %]</span>
143 <input type="hidden" name="change" value="[% 0 | $Price %]"/>
146 [% INCLUDE 'transaction_types.inc' type="payment" %]
149 <label for="registerid" class="required">Cash register: </label>
150 <select name="registerid" id="registerid" class="required" required="required">
151 <option id="noregister" disabled="disabled" value="">-- Select an option--</option>
152 [% PROCESS options_for_registers %]
154 <span class="required">Required</span>
160 <fieldset class="action">
161 <input type="submit" id="submitbutton" name="submitbutton" class="btn btn-primary" value="Confirm" />
162 <a class="cancel" href="/cgi-bin/koha/pos/pay.pl">Cancel</a>
169 [%- SET StaffPOSHome = AdditionalContents.get( location => "StaffPOSHome", lang => lang, library => logged_in_user.branchcode ) -%]
170 [%- FOREACH block IN StaffPOSHome.content -%]
171 <div class="page-section">
172 [%- block.content | $raw -%]
178 <div class="col-md-2 col-md-pull-10">
180 [% INCLUDE 'pos-menu.inc' %]
183 </div> <!-- /.row -->
185 <!-- Email receipt modal -->
186 <div class="modal" id="emailReceiptModal" tabindex="-1" role="dialog" aria-labelledby="emailReceiptLabel">
187 <form id="email_form" action="/cgi-bin/koha/pos/pay.pl" method="get" enctype="multipart/form-data" class="validated">
188 <input type="hidden" name="payment_id" value="[% payment_id | uri %]">
189 <input type="hidden" name="collected" value="[% collected | uri %]">
190 <input type="hidden" name="change" value="[% change | uri %]">"
191 <div class="modal-dialog" role="document">
192 <div class="modal-content">
193 <div class="modal-header">
194 <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
195 <h4 class="modal-title" id="emailReceiptLabel">Email receipt</h4>
197 <div class="modal-body">
198 <fieldset class="rows">
201 <label class="required" for="toaddr">Email address: </label>
202 <input type="email" id="toaddr" name="toaddr" required="required">
203 <span class="required">Required</span>
206 </fieldset> <!-- /.rows -->
207 </div> <!-- /.modal-body -->
208 <div class="modal-footer">
209 <input type="hidden" name="action" value="send">
210 <button type="submit" class="btn btn-default">Confirm</button>
211 <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
212 </div> <!-- /.modal-footer -->
213 </div> <!-- /.modal-content -->
214 </div> <!-- /.modal-dialog -->
215 </form> <!-- /#email_form -->
216 </div> <!-- /#emailReceiptModal -->
218 <!-- Change modal -->
219 <div id="confirm_change_form" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
220 <div class="modal-dialog">
221 <div class="modal-content">
222 <div class="modal-header">
223 <h3>The amount collected is more than the outstanding charge</h3>
225 <div class="modal-body">
226 <p>The amount collected from the patron is higher than the amount to be paid.</p>
227 <p>The change to give is <strong><span id="modal_change">[% 0 | $Price %]</span></strong>.</p>
228 <p>Confirm this payment?</p>
230 <div class="modal-footer">
231 <button class="btn btn-default approve" id="modal_submit" type="button"><i class="fa fa-check"></i> Yes</button>
232 <button class="btn btn-default deny cancel" data-dismiss="modal" aria-hidden="true" type="button"><i class="fa fa-times"></i> No</button>
238 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
239 <!-- Automatic Print Receipt -->
240 <a id="printReceipt" style="display: none" href="#"></a>
243 [% MACRO jsinclude BLOCK %]
244 [% INCLUDE 'format_price.inc' %]
245 [% INCLUDE 'datatables.inc' %]
246 [% INCLUDE 'columns_settings.inc' %]
247 [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
249 function moneyFormat(textObj) {
250 var newValue = textObj.value;
256 for(var i = newValue.length; 0 < i; i--) {
257 aChar = newValue.substring(i-1, i);
258 if ("0" <= aChar && aChar <= "9") {
260 dolAmount = "" + aChar + dolAmount;
263 decAmount = "" + aChar + decAmount;
266 if (aChar == "." || aChar == ",") {
272 dolAmount = decAmount;
276 if (dolAmount == "") {
280 if (dolAmount.length > 1) {
281 while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
282 dolAmount = dolAmount.substring(1,dolAmount.length);
285 if (decAmount.length > 2) {
286 decAmount = decAmount.substring(0,2);
289 if (decAmount.length == 1) {
290 decAmount = decAmount + "0";
292 if (decAmount.length == 0) {
293 decAmount = decAmount + "00";
296 textObj.value = dolAmount + "." + decAmount;
299 function fnClickAddRow( table, invoiceCode, invoiceTitle, invoicePrice ) {
300 var defaultPrice = { value: invoicePrice };
301 moneyFormat(defaultPrice);
307 '<button class="btn btn-default btn-xs drop" type="button"><i class="fa fa-trash-can"></i> ' + _("Remove") + '</button>',
313 function updateChangeValues() {
314 var change = $('#change')[0];
315 var zero_formatted = "[% 0 | $Price %]";
316 change.innerHTML = Math.round(($('#collected')[0].value - $('#paid')[0].value) * 100) / 100;
317 if (change.innerHTML <= 0) {
318 var paid = $('#paid')[0];
320 $('#collected').rules( "add", { min: Number(paid.value) });
321 change.innerHTML = zero_formatted;
322 $(':input[name="change"]').val(zero_formatted);
324 change.value = change.innerHTML;
326 change.innerHTML = change.value;
327 $(':input[name="change"]').val(change.value);
330 $('#modal_change').html(change.innerHTML);
333 $(document).ready(function() {
334 var sale_table = $("#sale").dataTable($.extend(true, {}, dataTablesDefaults, {
341 "bSearchable": false,
344 "mRender": function ( data, type, full ) {
345 var price = Number.parseFloat(data);
346 return price.format_price();
350 "sClass" : "editable",
353 "sClass" : "editable_int",
360 "fnDrawCallback": function (oSettings) {
362 local.$('.editable').editable( function(value, settings) {
363 var aPos = local.fnGetPosition( this );
364 local.fnUpdate( value, aPos[0], aPos[1], true, false );
368 pattern : "^\\d+(\.\\d{2})?$",
371 tooltip : _("Click to edit")
373 local.$('.editable_int').editable( function(value, settings) {
374 var aPos = local.fnGetPosition( this );
375 local.fnUpdate( value, aPos[0], aPos[1], true, false );
382 tooltip : _("Click to edit")
385 "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
386 var iTotal = aData[1] * aData[2];
387 this.fnUpdate( iTotal, nRow, 3, false, false );
389 "fnFooterCallback": function(nFoot, aData, iStart, iEnd, aiDisplay) {
391 for ( var i=0 ; i<aData.length ; i++ )
393 iTotalPrice += aData[i][3]*1;
395 iTotalPrice = iTotalPrice.format_price();
396 nFoot.getElementsByTagName('td')[1].innerHTML = iTotalPrice;
397 $('#paid').val(iTotalPrice);
398 $('#paid').trigger('change');
403 $("#sale").on("click", "button.drop", function(){
404 sale_table.DataTable().row($(this).parents('tr')).remove().draw(false);
407 var items_table_settings = [% TablesSettings.GetTableSettings('pos', 'pay', 'invoices', 'json') | $raw %];
408 var items_table = KohaTable("invoices", {
409 "sPaginationType": "full",
410 "aaSorting": [[ 0, "asc" ]],
412 }, items_table_settings, false);
414 $("#invoices").on("click", ".add_button", function(e) {
416 fnClickAddRow(sale_table, $( this ).data('invoiceCode'), $( this ).data('invoiceTitle'), $( this ).data('invoicePrice') );
417 if($('#invoices_filter').find('input[type=search]').val() !== ''){
418 items_table.fnFilter( '' );
422 // Change calculation and modal
423 var change = $('#change')[0];
424 $("#paid, #collected").on("change",function() {
426 if (change != undefined) {
427 updateChangeValues();
432 $('#modal_submit').click(function() {
434 $('#payForm').submit();
437 $('#payForm').validate({
454 $('#payForm').submit(function(e){
455 // first, clear stale sales 'rows' from the payForm
456 if($('input[name="sales"]').length > 0) {
457 $('input[name="sales"]').each(function() {
462 // now, process the current & fresh contents of the sale_table
463 if (change != undefined && change.innerHTML > 0.00 && !checked) {
465 $("#confirm_change_form").modal("show");
467 var rows = sale_table.fnGetData();
468 rows.forEach(function (row, index) {
477 value: JSON.stringify(sale)
478 }).appendTo('#payForm');
484 [% IF payment_id && Koha.Preference('FinePaymentAutoPopup') %]
485 $("#printReceipt").click(function() {
486 var win = window.open('/cgi-bin/koha/pos/printreceipt.pl?action=print&accountlines_id=[% payment_id | uri %]&collected=[% collected | uri %]&change=[% change | uri %]', '_blank');
489 $("#printReceipt").click();
494 [% INCLUDE 'intranet-bottom.inc' %]