Update: 2026-05-15 17:43:57
This commit is contained in:
@@ -367,7 +367,7 @@ foreach ($invoices as $invIdx => $inv) {
|
||||
|
||||
// --- Add Verification QR Code ---
|
||||
try {
|
||||
$verifyUrl = "https://musadaq.intaleqapp.com/index.php?route=verify&id=" . $inv['id'];
|
||||
$verifyUrl = "https://musadaq.intaleqapp.com/v.php?id=" . $inv['id'];
|
||||
$qrApiUrl = "https://api.qrserver.com/v1/create-qr-code/?size=100x100&data=" . urlencode($verifyUrl);
|
||||
$qrData = $downloadUrl($qrApiUrl);
|
||||
if ($qrData) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
use App\Core\Database;
|
||||
use App\Core\Encryption;
|
||||
|
||||
// die('REACHED VERIFY'); // Debug
|
||||
try {
|
||||
$invoiceId = $_GET['id'] ?? null;
|
||||
|
||||
@@ -167,6 +168,7 @@ try {
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
die("خطأ في النظام");
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ class ThermalPrinterService {
|
||||
}
|
||||
}
|
||||
|
||||
void _buildInvoiceTicket(NetworkPrinter printer, Map<String, dynamic> invoice) {
|
||||
void _buildInvoiceTicket(
|
||||
NetworkPrinter printer, Map<String, dynamic> invoice) {
|
||||
// Header
|
||||
printer.text(
|
||||
'M U S A D A Q',
|
||||
@@ -66,8 +67,14 @@ class ThermalPrinterService {
|
||||
// Table Header
|
||||
printer.row([
|
||||
PosColumn(text: 'البند', width: 6),
|
||||
PosColumn(text: 'الكمية', width: 2, styles: const PosStyles(align: PosAlign.center)),
|
||||
PosColumn(text: 'الإجمالي', width: 4, styles: const PosStyles(align: PosAlign.right)),
|
||||
PosColumn(
|
||||
text: 'الكمية',
|
||||
width: 2,
|
||||
styles: const PosStyles(align: PosAlign.center)),
|
||||
PosColumn(
|
||||
text: 'الإجمالي',
|
||||
width: 4,
|
||||
styles: const PosStyles(align: PosAlign.right)),
|
||||
]);
|
||||
printer.hr();
|
||||
|
||||
@@ -76,8 +83,14 @@ class ThermalPrinterService {
|
||||
for (var item in items) {
|
||||
printer.row([
|
||||
PosColumn(text: item['description'] ?? '-', width: 6),
|
||||
PosColumn(text: item['quantity']?.toString() ?? '1', width: 2, styles: const PosStyles(align: PosAlign.center)),
|
||||
PosColumn(text: item['line_total']?.toString() ?? '0', width: 4, styles: const PosStyles(align: PosAlign.right)),
|
||||
PosColumn(
|
||||
text: item['quantity']?.toString() ?? '1',
|
||||
width: 2,
|
||||
styles: const PosStyles(align: PosAlign.center)),
|
||||
PosColumn(
|
||||
text: item['line_total']?.toString() ?? '0',
|
||||
width: 4,
|
||||
styles: const PosStyles(align: PosAlign.right)),
|
||||
]);
|
||||
}
|
||||
printer.hr();
|
||||
@@ -85,15 +98,27 @@ class ThermalPrinterService {
|
||||
// Totals
|
||||
printer.row([
|
||||
PosColumn(text: 'المجموع الجزئي:', width: 8),
|
||||
PosColumn(text: '${invoice['subtotal'] ?? 0}', width: 4, styles: const PosStyles(align: PosAlign.right)),
|
||||
PosColumn(
|
||||
text: '${invoice['subtotal'] ?? 0}',
|
||||
width: 4,
|
||||
styles: const PosStyles(align: PosAlign.right)),
|
||||
]);
|
||||
printer.row([
|
||||
PosColumn(text: 'الضريبة:', width: 8),
|
||||
PosColumn(text: '${invoice['tax_amount'] ?? 0}', width: 4, styles: const PosStyles(align: PosAlign.right)),
|
||||
PosColumn(
|
||||
text: '${invoice['tax_amount'] ?? 0}',
|
||||
width: 4,
|
||||
styles: const PosStyles(align: PosAlign.right)),
|
||||
]);
|
||||
printer.row([
|
||||
PosColumn(text: 'الإجمالي الكلي:', width: 8, styles: const PosStyles(bold: true)),
|
||||
PosColumn(text: '${invoice['grand_total'] ?? 0} JOD', width: 4, styles: const PosStyles(align: PosAlign.right, bold: true)),
|
||||
PosColumn(
|
||||
text: 'الإجمالي الكلي:',
|
||||
width: 8,
|
||||
styles: const PosStyles(bold: true)),
|
||||
PosColumn(
|
||||
text: '${invoice['grand_total'] ?? 0} JOD',
|
||||
width: 4,
|
||||
styles: const PosStyles(align: PosAlign.right, bold: true)),
|
||||
]);
|
||||
|
||||
printer.hr();
|
||||
|
||||
10
public/.htaccess
Normal file
10
public/.htaccess
Normal file
@@ -0,0 +1,10 @@
|
||||
RewriteEngine On
|
||||
|
||||
# Ensure HTTPS
|
||||
RewriteCond %{HTTPS} off
|
||||
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|
||||
|
||||
# Handle Clean URLs
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^(.*)$ index.php?route=$1 [QSA,L]
|
||||
@@ -3039,7 +3039,7 @@
|
||||
getQrSrc(inv) {
|
||||
if (!inv) return '';
|
||||
if (inv.jofotara?.qr_image_uri) return inv.jofotara.qr_image_uri;
|
||||
const verifyUrl = 'https://musadaq.intaleqapp.com/index.php?route=verify&id=' + inv.id;
|
||||
const verifyUrl = `https://musadaq.intaleqapp.com/v.php?id=${inv.id}`;
|
||||
const qr = new QRious({ value: verifyUrl, size: 300, level: 'H' });
|
||||
return qr.toDataURL();
|
||||
},
|
||||
|
||||
176
public/v.php
Normal file
176
public/v.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/**
|
||||
* Standalone Public Invoice Verification Page
|
||||
* Bypass index.php router to avoid any accidental redirects.
|
||||
*/
|
||||
|
||||
// 1. Load Bootstrap
|
||||
require_once __DIR__ . '/../app/bootstrap/init.php';
|
||||
|
||||
use App\Core\Database;
|
||||
use App\Core\Encryption;
|
||||
|
||||
try {
|
||||
$invoiceId = $_GET['id'] ?? null;
|
||||
|
||||
if (!$invoiceId) {
|
||||
die("<h1>رابط التحقق غير صالح</h1>");
|
||||
}
|
||||
|
||||
$db = Database::getInstance();
|
||||
|
||||
// Fetch invoice with company and supplier details
|
||||
$stmt = $db->prepare("
|
||||
SELECT i.*, c.name as company_name_raw
|
||||
FROM invoices i
|
||||
JOIN companies c ON i.company_id = c.id
|
||||
WHERE i.id = ? AND i.deleted_at IS NULL
|
||||
");
|
||||
$stmt->execute([$invoiceId]);
|
||||
$invoice = $stmt->fetch();
|
||||
|
||||
if (!$invoice) {
|
||||
die("<h1>الفاتورة غير موجودة أو تم حذفها</h1>");
|
||||
}
|
||||
|
||||
// Decrypt helper
|
||||
$dec = function($val) {
|
||||
if (empty($val)) return '-';
|
||||
$result = Encryption::decrypt((string)$val);
|
||||
return ($result !== false && $result !== null) ? $result : (string)$val;
|
||||
};
|
||||
|
||||
$supplierName = $dec($invoice['supplier_name']);
|
||||
$companyName = $dec($invoice['company_name_raw']);
|
||||
$total = number_format((float)$invoice['grand_total'], 3);
|
||||
$date = $invoice['invoice_date'] ?: 'غير محدد';
|
||||
$status = match($invoice['status']) {
|
||||
'extracted' => 'مستخرجة',
|
||||
'approved' => 'معتمدة ✅',
|
||||
'submitted' => 'مقدمة للضريبة 🏛️',
|
||||
'rejected' => 'مرفوضة ❌',
|
||||
default => 'قيد المعالجة'
|
||||
};
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ar" dir="rtl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>التحقق من الفاتورة - مُصادَق</title>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Tajawal:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--primary: #1C1550;
|
||||
--accent: #00D1B2;
|
||||
--bg: #F8F9FA;
|
||||
}
|
||||
body {
|
||||
font-family: 'Tajawal', sans-serif;
|
||||
background-color: var(--bg);
|
||||
margin: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
color: #333;
|
||||
}
|
||||
.verify-card {
|
||||
background: white;
|
||||
padding: 30px;
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
|
||||
max-width: 450px;
|
||||
width: 90%;
|
||||
text-align: center;
|
||||
}
|
||||
.logo {
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
color: var(--primary);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.status-badge {
|
||||
display: inline-block;
|
||||
padding: 8px 20px;
|
||||
border-radius: 50px;
|
||||
background: #E9ECEF;
|
||||
font-weight: bold;
|
||||
margin-bottom: 25px;
|
||||
color: var(--primary);
|
||||
}
|
||||
.info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 15px;
|
||||
text-align: right;
|
||||
border-top: 1px solid #EEE;
|
||||
padding-top: 20px;
|
||||
}
|
||||
.info-item label {
|
||||
font-size: 13px;
|
||||
color: #888;
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.info-item span {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: var(--primary);
|
||||
}
|
||||
.footer-note {
|
||||
margin-top: 30px;
|
||||
font-size: 12px;
|
||||
color: #AAA;
|
||||
}
|
||||
.btn-home {
|
||||
margin-top: 20px;
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
color: var(--accent);
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="verify-card">
|
||||
<div class="logo">مُـصَـادَق</div>
|
||||
<div class="status-badge"><?php echo $status; ?></div>
|
||||
|
||||
<div class="info-grid">
|
||||
<div class="info-item">
|
||||
<label>اسم المكتب (الشركة)</label>
|
||||
<span><?php echo htmlspecialchars($companyName); ?></span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<label>اسم المورّد</label>
|
||||
<span><?php echo htmlspecialchars($supplierName); ?></span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<label>رقم الفاتورة</label>
|
||||
<span><?php echo htmlspecialchars($invoice['invoice_number'] ?: '-'); ?></span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<label>تاريخ الفاتورة</label>
|
||||
<span><?php echo htmlspecialchars($date); ?></span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<label>المبلغ الإجمالي</label>
|
||||
<span style="font-size: 24px; color: var(--accent);"><?php echo $total; ?> JOD</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer-note">
|
||||
تم التحقق من هذه الفاتورة رسمياً عبر منصة مُصادَق.<br>
|
||||
<?php echo date('Y-m-d H:i:s'); ?>
|
||||
</div>
|
||||
<a href="https://musadaq.intaleqapp.com/" class="btn-home">زيارة منصة مُصادَق</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
die("خطأ في النظام: " . $e->getMessage());
|
||||
}
|
||||
Reference in New Issue
Block a user