Add transaction loading, editing, and updating (issue #18)
This commit is contained in:
parent
0c72450c19
commit
61f77f5001
267
action.php
267
action.php
@ -33,115 +33,178 @@ function returnToSender($msg, $arg = "") {
|
|||||||
switch ($VARS['action']) {
|
switch ($VARS['action']) {
|
||||||
case "finish_transaction":
|
case "finish_transaction":
|
||||||
header("Content-Type: application/json");
|
header("Content-Type: application/json");
|
||||||
$items = $VARS['items'];
|
$error = null;
|
||||||
$payments = $VARS['payments'];
|
$oktx = null;
|
||||||
$customer = $VARS['customer'];
|
$database->action(function ($database) {
|
||||||
$register = $VARS['register'];
|
global $VARS, $binstack, $error, $oktx;
|
||||||
$discountpercent = $VARS['discountpercent'];
|
|
||||||
|
|
||||||
if ($customer != "" && !$database->has('customers', ['customerid' => $customer])) {
|
$items = $VARS['items'];
|
||||||
exit(json_encode(["status" => "ERROR", "message" => lang("invalid customer", false)]));
|
$payments = $VARS['payments'];
|
||||||
// exit(json_encode(["status" => "ERROR", "message" => lang("", false)]));
|
$customer = $VARS['customer'];
|
||||||
}
|
$register = $VARS['register'];
|
||||||
if ($register != "" && !$database->has('registers', ['registerid' => $register])) {
|
$discountpercent = $VARS['discountpercent'];
|
||||||
exit(json_encode(["status" => "ERROR", "message" => lang("invalid register", false)]));
|
$cashid = null;
|
||||||
}
|
$editing = false;
|
||||||
if ($register != "" && !$database->has('cash_drawer', ['AND' => ['registerid' => $register, 'close' => null]])) {
|
|
||||||
exit(json_encode(["status" => "ERROR", "message" => lang("cash not open", false)]));
|
|
||||||
}
|
|
||||||
|
|
||||||
$totalcharge = 0.00;
|
if (isset($VARS['txid']) && $database->has('transactions', ['txid' => $VARS['txid']])) {
|
||||||
$totalpaid = 0.00;
|
$editing = true;
|
||||||
$change = 0.0;
|
$txid = $VARS['txid'];
|
||||||
foreach ($items as $i) {
|
$cashid = $database->get('transactions', 'cashid', ['txid' => $txid]);
|
||||||
$totalcharge += $i['each'] * $i['qty'];
|
if (!$database->has('cash_drawer', ['AND' => ['cashid' => $cashid, 'close' => null]])) {
|
||||||
if (!$binstack->has('items', ['itemid' => $i['id']])) {
|
$error = lang("cash already closed", false);
|
||||||
exit(json_encode(["status" => "ERROR", "message" => lang("invalid item", false)]));
|
return false;
|
||||||
}
|
}
|
||||||
}
|
// Nuke the payments to make room for their replacements
|
||||||
foreach ($payments as $p) {
|
// Delete payments
|
||||||
if (!$database->has('payment_types', ['typename' => $p['type']])) {
|
$oldpayments = $database->select('payments', ['payid', 'amount', 'type', 'certid'], ['txid' => $txid]);
|
||||||
exit(json_encode(["status" => "ERROR", "message" => lang("invalid payment type", false)]));
|
foreach ($oldpayments as $p) {
|
||||||
}
|
// Reset gift card balances
|
||||||
$totalpaid += $p['amount'];
|
if (!is_null($p['certid'])) {
|
||||||
if ($p['type'] == "giftcard") {
|
$database->update('certificates', ['amount[+]' => $p['amount']], ['certid' => $p['certid']]);
|
||||||
if (!$database->has('certificates', ['AND' => ['amount[>=]' => $p['amount'], 'deleted[!]' => 1, 'certcode' => $p['code']]])) {
|
}
|
||||||
exit(json_encode(["status" => "ERROR", "message" => lang("invalid giftcard", false)]));
|
$database->delete('payments', ['payid' => $p['payid']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (is_numeric($discountpercent) && $discountpercent > 0 && $discountpercent < 100) {
|
if ($customer != "" && !$database->has('customers', ['customerid' => $customer])) {
|
||||||
$discountpercent = $discountpercent * 1.0;
|
$error = lang("invalid customer", false);
|
||||||
$totalcharge *= 1.0 - ($discountpercent / 100.0);
|
return false;
|
||||||
} else {
|
|
||||||
$discountpercent = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($totalcharge > $totalpaid) {
|
|
||||||
exit(json_encode(["status" => "ERROR", "message" => lang("insufficient payment", false)]));
|
|
||||||
}
|
|
||||||
|
|
||||||
$cashid = null;
|
|
||||||
if ($register != "") {
|
|
||||||
$cashid = $database->get('cash_drawer', 'cashid', ['AND' => ['registerid' => $register, 'close' => null]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$database->insert('transactions', [
|
|
||||||
'txdate' => date('Y-m-d H:i:s'),
|
|
||||||
'customerid' => ($customer != "" ? $customer : null),
|
|
||||||
'type' => 1,
|
|
||||||
'cashier' => $_SESSION['uid'],
|
|
||||||
'cashid' => $cashid,
|
|
||||||
'discountpercent' => $discountpercent
|
|
||||||
]);
|
|
||||||
$txid = $database->id();
|
|
||||||
|
|
||||||
foreach ($items as $i) {
|
|
||||||
$item = $binstack->get('items', ['name', 'qty'], ['itemid' => $i['id']]);
|
|
||||||
|
|
||||||
$database->insert('lines', [
|
|
||||||
'txid' => $txid,
|
|
||||||
'amount' => $i['each'],
|
|
||||||
'name' => $item['name'],
|
|
||||||
'itemid' => $i['id'],
|
|
||||||
'qty' => $i['qty']
|
|
||||||
]);
|
|
||||||
$binstack->update('items', [
|
|
||||||
'qty[-]' => $i['qty']
|
|
||||||
], [
|
|
||||||
'itemid' => $i['id']
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($payments as $p) {
|
|
||||||
$certid = null;
|
|
||||||
if ($p['type'] == "giftcard") {
|
|
||||||
$certid = $database->get('certificates', 'certid', ['certcode' => $p['code']]);
|
|
||||||
}
|
}
|
||||||
$type = $database->get('payment_types', 'typeid', ['typename' => $p['type']]);
|
if ($register != "" && !$database->has('registers', ['registerid' => $register])) {
|
||||||
$database->insert('payments', [
|
$error = lang("invalid register", false);
|
||||||
'amount' => $p['amount'],
|
return false;
|
||||||
'data' => '',
|
}
|
||||||
'type' => $type,
|
if ($register != "" && !$database->has('cash_drawer', ['AND' => ['registerid' => $register, 'close' => null]])) {
|
||||||
'txid' => $txid,
|
$error = lang("cash not open", false);
|
||||||
'certid' => $certid
|
return false;
|
||||||
]);
|
}
|
||||||
|
|
||||||
|
if ($register != "" && $editing === false) {
|
||||||
|
$cashid = $database->get('cash_drawer', 'cashid', ['AND' => ['registerid' => $register, 'close' => null]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$totalcharge = 0.00;
|
||||||
|
$totalpaid = 0.00;
|
||||||
|
$change = 0.0;
|
||||||
|
foreach ($items as $i) {
|
||||||
|
$totalcharge += $i['each'] * $i['qty'];
|
||||||
|
if (!$binstack->has('items', ['itemid' => $i['id']])) {
|
||||||
|
$error = lang("invalid item", false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($payments as $p) {
|
||||||
|
if (!$database->has('payment_types', ['typename' => $p['type']])) {
|
||||||
|
$error = lang("invalid payment type", false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$totalpaid += $p['amount'];
|
||||||
|
if ($p['type'] == "giftcard") {
|
||||||
|
if (!$database->has('certificates', ['AND' => ['amount[>=]' => $p['amount'], 'deleted[!]' => 1, 'certcode' => $p['code']]])) {
|
||||||
|
$error = lang("invalid giftcard", false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_numeric($discountpercent) && $discountpercent > 0 && $discountpercent < 100) {
|
||||||
|
$discountpercent = $discountpercent * 1.0;
|
||||||
|
$totalcharge *= 1.0 - ($discountpercent / 100.0);
|
||||||
|
} else {
|
||||||
|
$discountpercent = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($totalcharge > $totalpaid) {
|
||||||
|
$error = lang("insufficient payment", false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($editing === true) {
|
||||||
|
$database->update('transactions', [
|
||||||
|
'txdate' => date('Y-m-d H:i:s'),
|
||||||
|
'customerid' => ($customer != "" ? $customer : null),
|
||||||
|
'type' => 1,
|
||||||
|
'cashier' => $_SESSION['uid'],
|
||||||
|
'cashid' => $cashid,
|
||||||
|
'discountpercent' => $discountpercent
|
||||||
|
], [
|
||||||
|
'txid' => $txid
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$database->insert('transactions', [
|
||||||
|
'txdate' => date('Y-m-d H:i:s'),
|
||||||
|
'customerid' => ($customer != "" ? $customer : null),
|
||||||
|
'type' => 1,
|
||||||
|
'cashier' => $_SESSION['uid'],
|
||||||
|
'cashid' => $cashid,
|
||||||
|
'discountpercent' => $discountpercent
|
||||||
|
]);
|
||||||
|
$txid = $database->id();
|
||||||
|
}
|
||||||
|
|
||||||
|
$olditems = $database->select('lines', ['itemid (id)', 'qty', 'lineid'], ['txid' => $txid]);
|
||||||
|
foreach ($items as $i) {
|
||||||
|
$item = $binstack->get('items', ['name', 'qty'], ['itemid' => $i['id']]);
|
||||||
|
|
||||||
|
$database->insert('lines', [
|
||||||
|
'txid' => $txid,
|
||||||
|
'amount' => $i['each'],
|
||||||
|
'name' => $item['name'],
|
||||||
|
'itemid' => $i['id'],
|
||||||
|
'qty' => $i['qty']
|
||||||
|
]);
|
||||||
|
$binstack->update('items', [
|
||||||
|
'qty[-]' => $i['qty']
|
||||||
|
], [
|
||||||
|
'itemid' => $i['id']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($payments as $p) {
|
||||||
|
$certid = null;
|
||||||
|
if ($p['type'] == "giftcard") {
|
||||||
|
$certid = $database->get('certificates', 'certid', ['certcode' => $p['code']]);
|
||||||
|
}
|
||||||
|
$type = $database->get('payment_types', 'typeid', ['typename' => $p['type']]);
|
||||||
|
$database->insert('payments', [
|
||||||
|
'amount' => $p['amount'],
|
||||||
|
'data' => '',
|
||||||
|
'type' => $type,
|
||||||
|
'txid' => $txid,
|
||||||
|
'certid' => $certid
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($totalcharge < $totalpaid) {
|
||||||
|
$change = $totalpaid - $totalcharge;
|
||||||
|
$database->insert('payments', [
|
||||||
|
'amount' => $change * -1.0,
|
||||||
|
'data' => '',
|
||||||
|
'type' => 1,
|
||||||
|
'txid' => $txid,
|
||||||
|
'certid' => null
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($olditems as $i) {
|
||||||
|
$database->delete('lines', ['lineid' => $i['lineid']]);
|
||||||
|
$binstack->update('items', [
|
||||||
|
'qty[+]' => $i['qty']
|
||||||
|
], [
|
||||||
|
'itemid' => $i['id']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$oktx = $txid;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!is_null($error)) {
|
||||||
|
exit(json_encode(["status" => "ERROR", "message" => $error]));
|
||||||
|
} else {
|
||||||
|
exit(json_encode(["status" => "OK", "txid" => $oktx]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($totalcharge < $totalpaid) {
|
|
||||||
$change = $totalpaid - $totalcharge;
|
|
||||||
$database->insert('payments', [
|
|
||||||
'amount' => $change * -1.0,
|
|
||||||
'data' => '',
|
|
||||||
'type' => 1,
|
|
||||||
'txid' => $txid,
|
|
||||||
'certid' => null
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
exit(json_encode(["status" => "OK", "txid" => $txid]));
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "getreceipt":
|
case "getreceipt":
|
||||||
require_once __DIR__ . "/lib/generatereceipt.php";
|
require_once __DIR__ . "/lib/generatereceipt.php";
|
||||||
|
@ -118,4 +118,6 @@ define("STRINGS", [
|
|||||||
"x report" => "X Report",
|
"x report" => "X Report",
|
||||||
"z report" => "Z Report",
|
"z report" => "Z Report",
|
||||||
"pick cash" => "Choose",
|
"pick cash" => "Choose",
|
||||||
|
"cash already closed" => "Cash already closed, cannot edit this transaction. Process a return instead.",
|
||||||
|
"update" => "Update",
|
||||||
]);
|
]);
|
||||||
|
121
pages/pos.php
121
pages/pos.php
@ -19,6 +19,16 @@ if (isset($_GET['switch']) || !isset($_SESSION['register']) || !$registeropen) {
|
|||||||
} else {
|
} else {
|
||||||
$register = $database->get('registers', ['registerid (id)', 'registername (name)'], ['registerid' => $_SESSION['register']]);
|
$register = $database->get('registers', ['registerid (id)', 'registername (name)'], ['registerid' => $_SESSION['register']]);
|
||||||
$showgridbydefault = $binstack->count('items', ['AND' => ['price[!]' => null, 'price[!]' => 0]]) <= GRID_BY_DEFAULT_MAX_ITEMS;
|
$showgridbydefault = $binstack->count('items', ['AND' => ['price[!]' => null, 'price[!]' => 0]]) <= GRID_BY_DEFAULT_MAX_ITEMS;
|
||||||
|
$items = [];
|
||||||
|
$payments = [];
|
||||||
|
$editing = false;
|
||||||
|
if (isset($VARS['txid']) && $database->has('transactions', ['txid' => $VARS['txid']])) {
|
||||||
|
$editing = true;
|
||||||
|
$items = $database->select('lines', ['lineid', 'amount', 'name', 'itemid', 'qty'], ['txid' => $VARS['txid']]);
|
||||||
|
$payments = $database->select('payments', ['[>]certificates' => 'certid', '[>]payment_types' => ['type' => 'typeid']], ['payments.amount', 'typename', 'icon', 'text', 'certcode'], ['txid' => $VARS['txid']]);
|
||||||
|
$tx = $database->get('transactions', ['[>]customers' => 'customerid'], ['txid', 'discountpercent', 'transactions.customerid', 'customers.name (customername)'], ['txid' => $VARS['txid']]);
|
||||||
|
echo "<input type=\"hidden\" id=\"txid\" value=\"$VARS[txid]\">";
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<div class="modal fade" tabindex="-1" role="dialog" id="receiptmodal">
|
<div class="modal fade" tabindex="-1" role="dialog" id="receiptmodal">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
@ -122,7 +132,44 @@ if (isset($_GET['switch']) || !isset($_SESSION['register']) || !$registeropen) {
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="list-group list-group-flush" id="pos-lines-box">
|
<div class="list-group list-group-flush" id="pos-lines-box">
|
||||||
<!-- Items go here -->
|
<?php
|
||||||
|
foreach ($items as $i) {
|
||||||
|
?>
|
||||||
|
<div class="list-group-item" data-itemid="<?php echo $i['itemid']; ?>">
|
||||||
|
<div class="d-flex w-100 justify-content-between mb-2">
|
||||||
|
<h5 class="item-name"><?php echo $i['name']; ?></h5>
|
||||||
|
<h5>
|
||||||
|
<span class="badge badge-light">
|
||||||
|
$<span class="line-total"><?php echo number_format($i['amount'] * $i['qty'], 2); ?></span>
|
||||||
|
</span>
|
||||||
|
</h5>
|
||||||
|
</div>
|
||||||
|
<div class="d-inline-flex">
|
||||||
|
<div class="input-group qty-control">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text pr-1"><b>$</b></span>
|
||||||
|
</div>
|
||||||
|
<input type="money" class="form-control item-price" value="<?php echo number_format($i['amount'], 2); ?>"/>
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text px-2"><i class="fas fa-times"></i></span>
|
||||||
|
<button class="btn btn-red qty-minus" type="button"><i class="fas <?php
|
||||||
|
if ($i['qty'] > 1) {
|
||||||
|
echo "fa-minus";
|
||||||
|
} else {
|
||||||
|
echo "fa-trash";
|
||||||
|
}
|
||||||
|
?>"></i></button>
|
||||||
|
</div>
|
||||||
|
<input type="number" class="form-control item-qty px-2" value="<?php echo $i['qty']; ?>" />
|
||||||
|
<div class="input-group-append">
|
||||||
|
<button class="btn btn-light-green qty-plus" type="button"><i class="fas fa-plus"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -138,11 +185,25 @@ if (isset($_GET['switch']) || !isset($_SESSION['register']) || !$registeropen) {
|
|||||||
<div class="card-body d-flex justify-content-center flex-wrap py-0 my-0">
|
<div class="card-body d-flex justify-content-center flex-wrap py-0 my-0">
|
||||||
<div class="btn m-1" id="addcustomerbtn">
|
<div class="btn m-1" id="addcustomerbtn">
|
||||||
<i class="fas fa-user-circle"></i>
|
<i class="fas fa-user-circle"></i>
|
||||||
<span id="customerbtnlabel"></span>
|
<span id="customerbtnlabel"><?php
|
||||||
|
if ($editing && isset($tx['customername'])) {
|
||||||
|
echo $tx['customername'];
|
||||||
|
}
|
||||||
|
?></span>
|
||||||
<span class="sr-only"><?php lang("customer"); ?></span>
|
<span class="sr-only"><?php lang("customer"); ?></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn m-1" id="discountpercentbtn" data-percent="0">
|
<div class="btn m-1" id="discountpercentbtn" data-percent="<?php
|
||||||
<span id="discountpercentbtnlabel"></span>
|
if ($editing && isset($tx['discountpercent']) && $tx['discountpercent'] != 0) {
|
||||||
|
echo (float) $tx['discountpercent'];
|
||||||
|
} else {
|
||||||
|
echo "0";
|
||||||
|
}
|
||||||
|
?>">
|
||||||
|
<span id="discountpercentbtnlabel"><?php
|
||||||
|
if ($editing && isset($tx['discountpercent']) && $tx['discountpercent'] != 0) {
|
||||||
|
echo (float) $tx['discountpercent'];
|
||||||
|
}
|
||||||
|
?></span>
|
||||||
<i class="fas fa-percent"></i>
|
<i class="fas fa-percent"></i>
|
||||||
<span class="sr-only"><?php lang("transaction discount"); ?></span>
|
<span class="sr-only"><?php lang("transaction discount"); ?></span>
|
||||||
</div>
|
</div>
|
||||||
@ -179,18 +240,66 @@ if (isset($_GET['switch']) || !isset($_SESSION['register']) || !$registeropen) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="list-group list-group-flush" id="payment-lines">
|
<div class="list-group list-group-flush" id="payment-lines">
|
||||||
|
<?php
|
||||||
|
foreach ($payments as $p) {
|
||||||
|
if ($p['amount'] <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<div class="list-group-item">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text">
|
||||||
|
<i class="<?php echo $p['icon']; ?> fa-fw mr-1"></i>
|
||||||
|
<?php lang($p['text']); ?>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text">
|
||||||
|
$
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<input class="form-control payment-entry" type="money" data-type="<?php echo $p['typename']; ?>" value="<?php echo number_format($p['amount'], 2); ?>" />
|
||||||
|
<?php
|
||||||
|
if ($p['typename'] == 'giftcard') {
|
||||||
|
?>
|
||||||
|
<div class="input-group-prepend input-group-append">
|
||||||
|
<span class="input-group-text">
|
||||||
|
#
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<input class="form-control giftcard-number" type="number" value="<?php echo $p['certcode']; ?>" />
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<div class="input-group-append">
|
||||||
|
<span class="btn btn-outline-danger remove-payment-btn">
|
||||||
|
<i class="fas fa-trash"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
<!-- Payments go here -->
|
<!-- Payments go here -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<span class="btn btn-green btn-lg btn-block" id="finishbtn"><i class="fas fa-receipt"></i> <?php lang("finish"); ?></span>
|
<span class="btn btn-green btn-lg btn-block" id="finishbtn"><i class="fas fa-receipt"></i> <?php
|
||||||
|
if ($editing) {
|
||||||
|
lang("update");
|
||||||
|
} else {
|
||||||
|
lang("finish");
|
||||||
|
}
|
||||||
|
?></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script nonce="<?php echo $SECURE_NONCE; ?>">
|
<script nonce="<?php echo $SECURE_NONCE; ?>">
|
||||||
var showgridbydefault = <?php echo $showgridbydefault === true ? "true" : "false" ?>;
|
var showgridbydefault = <?php echo $showgridbydefault === true && $editing !== true ? "true" : "false" ?>;
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
@ -57,3 +57,10 @@ function recalculate() {
|
|||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
$.get("action.php", {action: "session_keepalive"});
|
$.get("action.php", {action: "session_keepalive"});
|
||||||
}, 1000 * 60);
|
}, 1000 * 60);
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
if ($("#txid").length) {
|
||||||
|
recalculate();
|
||||||
|
$("#paymentui").removeClass("d-none");
|
||||||
|
}
|
||||||
|
});
|
@ -13,6 +13,10 @@ function sendTransactionToServer(callback) {
|
|||||||
if (discountpercent <= 0) {
|
if (discountpercent <= 0) {
|
||||||
discountpercent = 0.0;
|
discountpercent = 0.0;
|
||||||
}
|
}
|
||||||
|
var txid = "";
|
||||||
|
if ($("#txid").length) {
|
||||||
|
txid = $("#txid").val();
|
||||||
|
}
|
||||||
$("#pos-lines-box .list-group-item").each(function () {
|
$("#pos-lines-box .list-group-item").each(function () {
|
||||||
var each = $(".item-price", this).val() * 1.0;
|
var each = $(".item-price", this).val() * 1.0;
|
||||||
var qty = $(".item-qty", this).val() * 1.0;
|
var qty = $(".item-qty", this).val() * 1.0;
|
||||||
@ -39,13 +43,16 @@ function sendTransactionToServer(callback) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(payments);
|
||||||
|
|
||||||
$.post("action.php", {
|
$.post("action.php", {
|
||||||
action: "finish_transaction",
|
action: "finish_transaction",
|
||||||
items: items,
|
items: items,
|
||||||
payments: payments,
|
payments: payments,
|
||||||
customer: customer,
|
customer: customer,
|
||||||
register: register,
|
register: register,
|
||||||
discountpercent: discountpercent
|
discountpercent: discountpercent,
|
||||||
|
txid: txid
|
||||||
}, function (data) {
|
}, function (data) {
|
||||||
if (data.status == "OK") {
|
if (data.status == "OK") {
|
||||||
callback(data);
|
callback(data);
|
||||||
@ -83,5 +90,5 @@ $("#receiptprintbtn").click(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#receiptmodal").on("hide.bs.modal", function () {
|
$("#receiptmodal").on("hide.bs.modal", function () {
|
||||||
window.location.reload();
|
window.location.href = "app.php?page=pos";
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user