/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ $("#openmanagement").click(function () { document.getElementById("xframe").contentDocument.location.reload(true); $("#managermodal").modal(); }); $("#xprintbtn").click(function () { if (nickelbridge) { $.get('action.php', { action: 'xreport', format: 'json', width: receiptwidth, register: $("#register").data('id') }, function (receipt) { $.ajax("http://127.0.0.1:64269/print", { data: JSON.stringify(receipt), contentType: 'application/json', type: 'POST', success: function (resp) { } }).fail(function (resp) { alert("Error: " + JSON.stringify(resp)); }); }); } else { document.getElementById("xframe").contentWindow.print(); } }); function showTransactionList(search) { if (search == "") { return; } $.get('action.php', { action: 'transactionsearch', q: search }, function (data) { var html = ""; if (data['transactions'].length > 0) { for (var i = 0; i < data['transactions'].length; i++) { var txid = ' ' + data['transactions'][i]['txid']; var date = ' ' + data['transactions'][i]['txdate']; var customername = ""; var cashiername = ""; var buttons = ""; if (typeof data['transactions'][i]['customer']['name'] == 'string') { customername = ' ' + data['transactions'][i]['customer']['name']; } if (data['transactions'][i]['cashier']['name'] != "") { cashiername = ' ' + data['transactions'][i]['cashier']['name']; } buttons += ' Receipt '; if (data['transactions'][i]['editable'] === true) { buttons += ' Edit'; } else { buttons += ' Return'; } html += '
' + '
' + buttons + '
' + '
' + txid + '
' + '
' + date + '
' + '
' + cashiername + '
' + '
' + customername + '
' + '
'; } } else { html = '
No results.
'; } $("#transactionselection").html(html); }); } $("#transactionsearch").on('keypress', function (e) { if (e.which === 13) { showTransactionList($("#transactionsearch").val()); $("#transactionsearch").val(""); } }); $("#transactionsearchbtn").on("click", function () { showTransactionList($("#transactionsearch").val()); $("#transactionsearch").val(""); }); $("#managermodal").on("click", ".printreceiptbtn", function () { $("#managermodal").modal("hide"); $("#receiptchangediv").addClass("d-none"); $("#receiptframe").attr("src", 'action.php?action=getreceipt&txid=' + $(this).data("txid")); $("#receiptmodal").modal(); }); $("#managermodal .open-number-pad-btn").click(function () { var inputbox = $("#transactionsearch"); var value = inputbox.val(); if (isNaN(value)) { value = ''; } bsnumpad("Keyboard", value, ' Search', "Cancel", function (answer) { showTransactionList(answer); }); });