adding qr to reciept

This commit is contained in:
Flatlogic Bot 2026-03-10 09:34:51 +00:00
parent c8388831c1
commit c441d54a7a

View File

@ -127,7 +127,8 @@ function format_currency($amount) {
</div>
<div class="mt-3 border-top pt-2">
<?php foreach($items as $item): ?>
<?php foreach($items as $item):
?>
<div class="mb-2">
<div class="item-row">
<div class="item-name"><?= $item['name_en'] ?> / <span class="arabic-text"><?= $item['name_ar'] ?></span> x <?= $item['quantity'] ?></div>
@ -135,7 +136,8 @@ function format_currency($amount) {
</div>
<div class="item-service"><?= $item['service_en'] ?> / <span class="arabic-text"><?= $item['service_ar'] ?></span></div>
</div>
<?php endforeach; ?>
<?php endforeach;
?>
</div>
<?php
@ -149,12 +151,14 @@ function format_currency($amount) {
<span><?= __('subtotal') ?>:</span>
<span><?= format_currency($calculated_subtotal) ?></span>
</div>
<?php if ($order['loyalty_discount'] > 0): ?>
<?php if ($order['loyalty_discount'] > 0):
?>
<div class="info-row">
<span><?= __('loyalty_discount') ?>:</span>
<span>-<?= format_currency($order['loyalty_discount']) ?></span>
</div>
<?php endif; ?>
<?php endif;
?>
<div class="info-row">
<span><?= __('vat') ?>:</span>
<span><?= format_currency($order['vat_total'] ?? 0) ?></span>
@ -170,12 +174,18 @@ function format_currency($amount) {
<div class="arabic-text">شكراً لاختياركم لنا!</div>
</div>
<div class="mt-3 text-center">
<div class="small fw-bold mb-1">Rate Us / <span class="arabic-text">قيمنا</span></div>
<div id="qrcode" class="d-flex justify-content-center"></div>
</div>
<div class="barcode">
<svg id="barcode"></svg>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/jsbarcode@3.11.0/dist/JsBarcode.all.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
<script>
JsBarcode("#barcode", "<?= $order['order_number'] ?? $order['id'] ?>", {
format: "CODE128",
@ -184,6 +194,21 @@ function format_currency($amount) {
height: 40,
displayValue: false
});
<?php
$scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') ? "https" : "http";
$host = $_SERVER['HTTP_HOST'];
$base_dir = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');
$rate_url = $scheme . "://" . $host . $base_dir . "/rate.php?branch_id=" . ($order['branch_id'] ?? 1);
?>
new QRCode(document.getElementById("qrcode"), {
text: "<?= $rate_url ?>",
width: 80,
height: 80,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.M
});
</script>
<script>
window.onload = function() { setTimeout(() => window.print(), 500); };