106 lines
4.3 KiB
PHP
106 lines
4.3 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();
|
|
|
|
// This is a simple HTML certificate that can be printed or saved as PDF by the user
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Donation Certificate - CharityHub</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=Cinzel:wght@400;700&family=Inter:wght@400;600&display=swap" rel="stylesheet">
|
|
<style>
|
|
body { background: #f3f4f6; padding: 40px 20px; font-family: 'Inter', 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-header { font-family: 'Cinzel', serif; font-size: 3rem; color: #111827; margin-bottom: 10px; }
|
|
.cert-sub { font-size: 1.25rem; color: #059669; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 40px; }
|
|
.cert-body { font-size: 1.2rem; color: #4b5563; line-height: 1.8; margin-bottom: 40px; }
|
|
.cert-name { font-family: 'Cinzel', 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-style: italic; 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; }
|
|
|
|
@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; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="certificate-container">
|
|
<div class="cert-header">Certificate</div>
|
|
<div class="cert-sub">of Appreciation</div>
|
|
|
|
<div class="cert-body">
|
|
This certificate is proudly presented to
|
|
<br>
|
|
<div class="cert-name"><?= htmlspecialchars($don['donor_name'] ?: 'Valued Donor') ?></div>
|
|
<br>
|
|
In recognition of their generous donation of <strong>OMR <?= number_format($don['amount'], 3) ?></strong>
|
|
<br>
|
|
towards the cause: <strong><?= htmlspecialchars($don['case_title']) ?></strong>
|
|
</div>
|
|
|
|
<div class="stamp">
|
|
OFFICIAL<br>SEAL<br>CHARITYHUB
|
|
</div>
|
|
|
|
<div class="cert-footer">
|
|
<div class="signature">
|
|
Date: <?= date('M j, Y', strtotime($don['created_at'])) ?>
|
|
</div>
|
|
<div class="signature">
|
|
Authorized Signature<br>
|
|
<?= htmlspecialchars($org['name_en'] ?? 'CharityHub') ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="no-print">
|
|
<button onclick="window.print()" class="btn-print">Print or Save as PDF</button>
|
|
<a href="index.php" style="margin-left: 15px; color: #6b7280; text-decoration: none;">Back to Home</a>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|