add qr to admin page

This commit is contained in:
Flatlogic Bot 2026-03-10 09:41:24 +00:00
parent c441d54a7a
commit 0f040f6eca
2 changed files with 54 additions and 3 deletions

View File

@ -29,6 +29,7 @@ $translations = [
'service_rating' => 'Service Rating',
'branch_links' => 'Branch Links',
'copy_link' => 'Copy Link',
'print_qr' => 'Print QR',
'link_copied' => 'Copied!',
'rating' => 'Rating',
'comment' => 'Comment',
@ -306,6 +307,7 @@ $translations = [
'service_rating' => 'تقييم الخدمة',
'branch_links' => 'روابط الفروع',
'copy_link' => 'نسخ الرابط',
'print_qr' => 'طباعة QR',
'link_copied' => 'تم النسخ!',
'rating' => 'التقييم',
'comment' => 'تعليق',

View File

@ -243,9 +243,14 @@ $ratings = $stmt->fetchAll(PDO::FETCH_ASSOC);
<h6 class="mb-1 fw-bold"><?= htmlspecialchars($br_name) ?></h6>
<a href="<?= htmlspecialchars($br_link) ?>" target="_blank" class="text-decoration-none small text-primary"><?= htmlspecialchars($br_link) ?></a>
</div>
<button class="btn btn-sm btn-outline-secondary text-nowrap" onclick="copyToClipboard('<?= $br_link ?>', this)">
<i class="bi bi-clipboard"></i> <span class="d-none d-sm-inline"><?= __('copy_link') ?? 'Copy Link' ?></span>
</button>
<div class="text-nowrap">
<button class="btn btn-sm btn-outline-secondary me-2" onclick="copyToClipboard('<?= $br_link ?>', this)">
<i class="bi bi-clipboard"></i> <span class="d-none d-sm-inline"><?= __('copy_link') ?? 'Copy Link' ?></span>
</button>
<button class="btn btn-sm btn-outline-primary" onclick="printQR('<?= $br_link ?>', '<?= addslashes(htmlspecialchars($br_name)) ?>')">
<i class="bi bi-qr-code"></i> <span class="d-none d-sm-inline"><?= __('print_qr') ?? 'Print QR' ?></span>
</button>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
@ -256,6 +261,50 @@ $ratings = $stmt->fetchAll(PDO::FETCH_ASSOC);
</div>
<script>
function printQR(url, branchName) {
let printWindow = window.open('', '_blank', 'width=400,height=600');
printWindow.document.write(`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Print QR - ${branchName}</title>
<style>
body { font-family: sans-serif; text-align: center; padding: 50px; background: #fff; color: #000; }
h2 { margin-bottom: 5px; font-size: 24px; }
#qrcode { display: flex; justify-content: center; margin-top: 30px; }
#qrcode img { margin: 0 auto; }
.rate-text { font-size: 20px; font-weight: bold; margin-top: 20px; }
</style>
</head>
<body>
<h2>${branchName}</h2>
<div id="qrcode"></div>
<div class="rate-text">Rate Us / قيمنا</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"><\/script>
<script>
window.onload = function() {
new QRCode(document.getElementById("qrcode"), {
text: "${url}",
width: 200,
height: 200,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.M
});
setTimeout(function() {
window.print();
window.close();
}, 500);
};
<\/script>
</body>
</html>
`);
printWindow.document.close();
}
function copyToClipboard(text, btn) {
if (navigator.clipboard) {
navigator.clipboard.writeText(text).then(function() {