173 lines
5.2 KiB
PHP
173 lines
5.2 KiB
PHP
<?php
|
|
/**
|
|
* Public Invoice Verification Page
|
|
* GET /v1/verify?id=INVOICE_ID
|
|
*/
|
|
|
|
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
|
|
} catch (\Exception $e) {
|
|
die("خطأ في النظام");
|
|
}
|