/* * 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 () { 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 () { showCustomerList($("#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(); });