From 7d688e071d8de08521ed051ac9b61c34593663e7 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Sat, 2 Jun 2018 21:17:09 -0600 Subject: [PATCH] Add Z report viewer (closes #17) --- lang/en_us.php | 1 + lib/generatereceipt.php | 4 ++-- lib/receipts.php | 6 +++--- pages.php | 3 +++ pages/editregister.php | 27 ++++++++++++++++++++++++++- static/css/editregister.css | 12 ++++++++++++ static/js/editregister.js | 16 ++++++++++++++++ 7 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 static/css/editregister.css diff --git a/lang/en_us.php b/lang/en_us.php index 633cf16..18b6ed9 100644 --- a/lang/en_us.php +++ b/lang/en_us.php @@ -117,4 +117,5 @@ define("STRINGS", [ "manage" => "Manage", "x report" => "X Report", "z report" => "Z Report", + "pick cash" => "Choose", ]); diff --git a/lib/generatereceipt.php b/lib/generatereceipt.php index 0d67570..4ffbcfd 100644 --- a/lib/generatereceipt.php +++ b/lib/generatereceipt.php @@ -117,7 +117,7 @@ class GenerateReceipt { $receipt->appendHeader(new ReceiptLine(lang("x report", false), "", "", ReceiptLine::LINEFORMAT_BOLD | ReceiptLine::LINEFORMAT_CENTER)); - $receipt->appendLine(new ReceiptLine("Date:", "", date(DATETIME_FORMAT))); + $receipt->appendLine(new ReceiptLine("Printed:", "", date(DATETIME_FORMAT))); $receipt->appendLine(new ReceiptLine("Register:", "", $registername)); $receipt->appendLine(new ReceiptLine("Transactions:", "", $transactioncount)); @@ -172,7 +172,7 @@ class GenerateReceipt { $receipt->appendHeader(new ReceiptLine(lang("z report", false), "", "", ReceiptLine::LINEFORMAT_BOLD | ReceiptLine::LINEFORMAT_CENTER)); - $receipt->appendLine(new ReceiptLine("Date:", "", date(DATETIME_FORMAT))); + $receipt->appendLine(new ReceiptLine("Printed:", "", date(DATETIME_FORMAT))); $receipt->appendLine(new ReceiptLine("Register:", "", $registername)); $receipt->appendLine(new ReceiptLine("Transactions:", "", $transactioncount)); diff --git a/lib/receipts.php b/lib/receipts.php index e3d4aa1..31a5c25 100644 --- a/lib/receipts.php +++ b/lib/receipts.php @@ -53,13 +53,13 @@ class ReceiptLine { return "
"; } $html = ""; - if (!empty($this->left)) { + if (!empty($this->left) || $this->left === 0 || $this->left === "0") { $html .= '' . htmlspecialchars($this->left) . ' '; } - if (!empty($this->middle)) { + if (!empty($this->middle) || $this->middle === 0 || $this->middle === "0") { $html .= '' . htmlspecialchars($this->middle) . ' '; } - if (!empty($this->right)) { + if (!empty($this->right) || $this->right === 0 || $this->right === "0") { $html .= '' . htmlspecialchars($this->right) . ''; } $classes = ["flex"]; diff --git a/pages.php b/pages.php index c3e6c9e..afcb399 100644 --- a/pages.php +++ b/pages.php @@ -74,6 +74,9 @@ define("PAGES", [ "editregister" => [ "title" => "edit register", "navbar" => false, + "styles" => [ + "static/css/editregister.css", + ], "scripts" => [ "static/js/editregister.js" ] diff --git a/pages/editregister.php b/pages/editregister.php index cd3113f..aca731d 100644 --- a/pages/editregister.php +++ b/pages/editregister.php @@ -11,6 +11,7 @@ $regdata = [ 'id' => '', 'name' => '' ]; +$cash = []; $editing = false; @@ -33,7 +34,7 @@ if (!empty($VARS['id'])) { } if ($editing) { - + $cash = $database->select('cash_drawer', ['cashid', 'open', 'close'], ['AND' => ['registerid' => $regdata['id'], 'open[!]' => null, 'close[!]' => null], 'ORDER' => 'cashid', 'LIMIT' => 30]); } ?> @@ -59,6 +60,30 @@ if ($editing) { +
+
+ +
+ +
+ +
+
+ +
+
diff --git a/static/css/editregister.css b/static/css/editregister.css new file mode 100644 index 0000000..943d992 --- /dev/null +++ b/static/css/editregister.css @@ -0,0 +1,12 @@ +/* +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/. +*/ + + +#zframe { + height: 50vh; + min-height: 400px; + border: 0; +} \ No newline at end of file diff --git a/static/js/editregister.js b/static/js/editregister.js index 0b0deec..7f6b125 100644 --- a/static/js/editregister.js +++ b/static/js/editregister.js @@ -7,4 +7,20 @@ $('#name').on('input propertychange paste', function () { $('#name_title').text($('#name').val()); +}); + +$("#zreport").on('change', function () { + var cashid = $(this).val(); + if (cashid == "") { + return; + } + $("#zframe").attr("src", "action.php?action=zreport&cash=" + cashid); +}); + +$("#printzreportbtn").click(function () { + var cashid = $("#zreport").val(); + if (cashid == "") { + return; + } + document.getElementById("zframe").contentWindow.print(); }); \ No newline at end of file