Files
musadaq-saas/app/modules_app/invoices/verify_public.php
2026-05-15 17:55:40 +03:00

192 lines
6.0 KiB
PHP

<?php
// Minimal public verification
if (!defined('ROOT_PATH')) define('ROOT_PATH', realpath(dirname(__DIR__, 2)));
// Load Env manually
$envFile = '/home/intaleqapp-musadaq/env/.env';
if (!file_exists($envFile)) $envFile = ROOT_PATH . '/.env';
if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
if (str_starts_with(trim($line), '#')) continue;
$parts = explode('=', $line, 2);
if (count($parts) === 2) {
$n = trim($parts[0]); $v = trim($parts[1], " \t\n\r\0\x0B\"'");
$_ENV[$n] = $v; $_SERVER[$n] = $v;
}
}
}
use App\Core\Database;
use App\Core\Encryption;
header_remove("Content-Security-Policy");
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
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("خطأ في النظام");
}