Browse Source

Add Z report viewer (closes #17)

master
Skylar Ittner 1 year ago
parent
commit
7d688e071d
7 changed files with 63 additions and 6 deletions
  1. 1
    0
      lang/en_us.php
  2. 2
    2
      lib/generatereceipt.php
  3. 3
    3
      lib/receipts.php
  4. 3
    0
      pages.php
  5. 26
    1
      pages/editregister.php
  6. 12
    0
      static/css/editregister.css
  7. 16
    0
      static/js/editregister.js

+ 1
- 0
lang/en_us.php View File

@@ -117,4 +117,5 @@ define("STRINGS", [
"manage" => "Manage",
"x report" => "X Report",
"z report" => "Z Report",
"pick cash" => "Choose",
]);

+ 2
- 2
lib/generatereceipt.php View File

@@ -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));


+ 3
- 3
lib/receipts.php View File

@@ -53,13 +53,13 @@ class ReceiptLine {
return "<br />";
}
$html = "";
if (!empty($this->left)) {
if (!empty($this->left) || $this->left === 0 || $this->left === "0") {
$html .= '<span>' . htmlspecialchars($this->left) . '&nbsp;</span>';
}
if (!empty($this->middle)) {
if (!empty($this->middle) || $this->middle === 0 || $this->middle === "0") {
$html .= '<span>' . htmlspecialchars($this->middle) . '&nbsp;</span>';
}
if (!empty($this->right)) {
if (!empty($this->right) || $this->right === 0 || $this->right === "0") {
$html .= '<span>' . htmlspecialchars($this->right) . '</span>';
}
$classes = ["flex"];

+ 3
- 0
pages.php View File

@@ -74,6 +74,9 @@ define("PAGES", [
"editregister" => [
"title" => "edit register",
"navbar" => false,
"styles" => [
"static/css/editregister.css",
],
"scripts" => [
"static/js/editregister.js"
]

+ 26
- 1
pages/editregister.php View File

@@ -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) {
</div>
</div>

<div class="card-body row">
<div class="form-group col-12 col-md-6">
<label for="zreport"><i class="fas fa-receipt"></i> <?php lang("z report"); ?></label>
<div class="input-group">
<select id="zreport" class="form-control">
<option value=""><?php lang("pick cash") ?></option>
<?php
for ($i = count($cash) - 1; $i >= 0; $i--) {
$c = $cash[$i];
echo "<option value=\"$c[cashid]\">"
. date(DATETIME_FORMAT, strtotime($c['open']))
. ' - '
. date(DATETIME_FORMAT, strtotime($c['close']))
. "</option>";
}
?>
</select>
<div class="input-group-append">
<button type="button" id="printzreportbtn" class="btn btn-primary"><i class="fas fa-print"></i> <?php lang("print"); ?></button>
</div>
</div>
<iframe id="zframe" class="w-100 shadow-lg"></iframe>
</div>
</div>
<input type="hidden" name="id" value="<?php echo htmlspecialchars($regdata['id']); ?>" />
<input type="hidden" name="action" value="editregister" />
<input type="hidden" name="source" value="registers" />

+ 12
- 0
static/css/editregister.css View File

@@ -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;
}

+ 16
- 0
static/js/editregister.js View File

@@ -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();
});

Loading…
Cancel
Save