38394-vm/certificate.php
2026-02-14 07:56:12 +00:00

113 lines
4.8 KiB
PHP

<?php
require_once 'db/config.php';
$donation_id = $_GET['id'] ?? null;
if (!$donation_id) exit('Invalid donation ID');
$pdo = db();
$stmt = $pdo->prepare("
SELECT d.*, c.title_en as case_title, c.title_ar as case_title_ar
FROM donations d
JOIN cases c ON d.case_id = c.id
WHERE d.id = ? AND d.status = 'completed'
");
$stmt->execute([$donation_id]);
$don = $stmt->fetch();
if (!$don) exit('Donation not found or not completed.');
$org = $pdo->query("SELECT * FROM org_profile LIMIT 1")->fetch();
// Prefer Arabic name if available, otherwise English or default
$orgName = $org['name_ar'] ?? ($org['name_en'] ?? 'المؤسسة');
// This is a simple HTML certificate that can be printed or saved as PDF by the user
?>
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>شهادة تبرع - <?= htmlspecialchars($orgName) ?></title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Cairo:wght@400;600;700&display=swap" rel="stylesheet">
<style>
body { background: #f3f4f6; padding: 40px 20px; font-family: 'Cairo', sans-serif; }
.certificate-container {
max-width: 800px;
margin: 0 auto;
background: #fff;
padding: 60px;
border: 20px solid #059669;
position: relative;
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
text-align: center;
}
.certificate-container::after {
content: '';
position: absolute;
top: 10px; left: 10px; right: 10px; bottom: 10px;
border: 2px solid #059669;
pointer-events: none;
}
.cert-logo { margin-bottom: 20px; }
.cert-logo img { max-height: 100px; }
.cert-header { font-family: 'Amiri', serif; font-size: 3rem; color: #111827; margin-bottom: 10px; }
.cert-sub { font-size: 1.25rem; color: #059669; font-weight: 700; margin-bottom: 40px; }
.cert-body { font-size: 1.2rem; color: #4b5563; line-height: 1.8; margin-bottom: 40px; }
.cert-name { font-family: 'Amiri', serif; font-size: 2.5rem; color: #059669; margin: 20px 0; border-bottom: 2px solid #e5e7eb; display: inline-block; padding: 0 40px; }
.cert-footer { margin-top: 60px; display: flex; justify-content: space-between; align-items: flex-end; }
.signature { border-top: 1px solid #9ca3af; padding-top: 10px; width: 200px; font-weight: 600; color: #6b7280; }
.stamp { width: 120px; height: 120px; border: 4px double #059669; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #059669; font-weight: 800; transform: rotate(-15deg); font-size: 0.8rem; margin: 0 auto; text-align: center; line-height: 1.4; }
@media print {
body { background: #fff; padding: 0; }
.certificate-container { box-shadow: none; border-width: 15px; }
.no-print { display: none; }
}
.no-print { margin-top: 30px; text-align: center; }
.btn-print { background: #059669; color: #fff; border: none; padding: 12px 30px; border-radius: 9999px; font-weight: 600; cursor: pointer; text-decoration: none; font-family: 'Cairo', sans-serif; }
</style>
</head>
<body>
<div class="certificate-container">
<div class="cert-logo">
<img src="assets/images/logo_1770967720.jpg" alt="Logo">
</div>
<div class="cert-header">شهادة تقدير</div>
<div class="cert-sub">شكر وعرفان</div>
<div class="cert-body">
يسرنا تقديم هذه الشهادة إلى
<br>
<div class="cert-name"><?= htmlspecialchars($don['donor_name'] ?: 'فاعل خير') ?></div>
<br>
تقديراً لتبرعكم الكريم بمبلغ <strong><?= number_format($don['amount'], 3) ?> ر.ع.</strong>
<br>
لدعم حالة: <strong><?= htmlspecialchars($don['case_title_ar'] ?: $don['case_title']) ?></strong>
</div>
<div class="stamp">
الختم<br>الرسمي<br><?= htmlspecialchars($orgName) ?>
</div>
<div class="cert-footer">
<div class="signature">
التاريخ: <?= date('Y/m/d', strtotime($don['created_at'])) ?>
</div>
<div class="signature">
التوقيع المعتمد<br>
<?= htmlspecialchars($orgName) ?>
</div>
</div>
</div>
<div class="no-print">
<button onclick="window.print()" class="btn-print">طباعة أو حفظ كملف PDF</button>
<a href="index.php" style="margin-right: 15px; color: #6b7280; text-decoration: none;">العودة للرئيسية</a>
</div>
</body>
</html>