327 lines
10 KiB
PHP
327 lines
10 KiB
PHP
<?php
|
|
require_once __DIR__ . '/db/config.php';
|
|
require_once __DIR__ . '/includes/settings.php';
|
|
|
|
// Check if user is logged in
|
|
session_start();
|
|
if (!isset($_SESSION['user_id'])) {
|
|
die('Access Denied');
|
|
}
|
|
|
|
// Basic permission check (matches header.php logic)
|
|
function isAdmin() {
|
|
if (isset($_SESSION['is_super_admin']) && $_SESSION['is_super_admin'] == 1) return true;
|
|
if (isset($_SESSION['user_role']) && strtolower($_SESSION['user_role']) === 'admin') return true;
|
|
if (isset($_SESSION['role']) && strtolower($_SESSION['role']) === 'admin') return true;
|
|
return false;
|
|
}
|
|
|
|
function canView($page) {
|
|
if (isAdmin()) return true;
|
|
return $_SESSION['permissions'][$page]['view'] ?? false;
|
|
}
|
|
|
|
if (!canView('outbound')) {
|
|
die('Unauthorized access');
|
|
}
|
|
|
|
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
|
if (!$id) {
|
|
die('Invalid ID');
|
|
}
|
|
|
|
// Fetch outbound mail details
|
|
$stmt = db()->prepare("SELECT * FROM outbound_mail WHERE id = ?");
|
|
$stmt->execute([$id]);
|
|
$mail = $stmt->fetch();
|
|
|
|
if (!$mail) {
|
|
die('Mail not found');
|
|
}
|
|
|
|
$settings = get_settings();
|
|
$logo = !empty($settings['site_logo']) ? $settings['site_logo'] : '';
|
|
$site_name = $settings['site_name'];
|
|
$site_address = $settings['site_address'];
|
|
|
|
/**
|
|
* Convert Gregorian date to Hijri
|
|
*/
|
|
function gregorianToHijri($date) {
|
|
if (!$date) return '';
|
|
$time = strtotime($date);
|
|
$m = date('m', $time);
|
|
$d = date('d', $time);
|
|
$y = date('Y', $time);
|
|
|
|
if (($y > 1582) || (($y == 1582) && ($m > 10)) || (($y == 1582) && ($m == 10) && ($d > 14))) {
|
|
$jd = (int)((1461 * ($y + 4800 + (int)(($m - 14) / 12))) / 4) +
|
|
(int)((367 * ($m - 2 - 12 * ((int)(($m - 14) / 12)))) / 12) -
|
|
(int)((3 * ((int)(($y + 4900 + (int)(($m - 14) / 12)) / 100))) / 4) +
|
|
$d - 32075;
|
|
} else {
|
|
$jd = 367 * $y - (int)((7 * ($y + 5001 + (int)(($m - 9) / 7))) / 4) + (int)((275 * $m) / 9) + $d + 1729777;
|
|
}
|
|
|
|
$l = $jd - 1948440 + 10632;
|
|
$n = (int)(($l - 1) / 10631);
|
|
$l = $l - 10631 * $n + 354;
|
|
$j = ((int)((10985 - $l) / 5316)) * ((int)((50 * $l) / 17719)) + ((int)($l / 5670)) * ((int)((43 * $l) / 15238));
|
|
$l = $l - ((int)((30 - $j) / 15)) * ((int)((17719 * $j) / 50)) - ((int)($j / 16)) * ((int)((15238 * $j) / 43)) + 29;
|
|
|
|
$month = (int)((24 * $l) / 709);
|
|
$day = $l - (int)((709 * $month) / 24);
|
|
$year = 30 * $n + $j - 30;
|
|
|
|
$hijriMonths = [
|
|
1 => "محرم", 2 => "صفر", 3 => "ربيع الأول", 4 => "ربيع الآخر",
|
|
5 => "جمادى الأولى", 6 => "جمادى الآخرة", 7 => "رجب", 8 => "شعبان",
|
|
9 => "رمضان", 10 => "شوال", 11 => "ذو القعدة", 12 => "ذو الحجة"
|
|
];
|
|
|
|
return $day . ' ' . $hijriMonths[$month] . ' ' . $year . ' هـ';
|
|
}
|
|
|
|
$hijriDate = gregorianToHijri($mail['date_registered']);
|
|
?>
|
|
<!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($mail['ref_no']) ?></title>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
<link href="https://fonts.googleapis.com/css2?family=Cairo:wght@400;700&display=swap" rel="stylesheet">
|
|
<style>
|
|
@page {
|
|
size: A4;
|
|
margin: 1cm 1.5cm 2cm 1.5cm; /* Reserved 2cm at bottom for fixed footer */
|
|
}
|
|
body {
|
|
font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
background-color: #fff;
|
|
color: #333;
|
|
margin: 0;
|
|
padding: 0;
|
|
line-height: 1.6;
|
|
}
|
|
.print-container {
|
|
width: 100%;
|
|
max-width: 21cm;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
}
|
|
.header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: flex-start; /* Aligned to start for better header-info layout */
|
|
border-bottom: 3px double #333;
|
|
padding-bottom: 20px;
|
|
margin-bottom: 40px;
|
|
}
|
|
.header-logo img {
|
|
max-height: 100px;
|
|
max-width: 200px;
|
|
}
|
|
.header-info {
|
|
text-align: left;
|
|
line-height: 1.2;
|
|
margin-left: 1.5cm; /* Bring a little to the right from the left edge */
|
|
margin-top: 15px; /* Shifting a little down from the top edge */
|
|
}
|
|
.charity-name-header {
|
|
font-size: 24px;
|
|
font-weight: bold;
|
|
margin-bottom: 5px;
|
|
color: #00827F;
|
|
}
|
|
.charity-address-header {
|
|
font-size: 12px;
|
|
color: #00827F;
|
|
opacity: 0.85;
|
|
}
|
|
.header-title {
|
|
text-align: center;
|
|
flex-grow: 1;
|
|
}
|
|
.header-title h1 {
|
|
margin: 0;
|
|
font-size: 28px;
|
|
color: #000;
|
|
text-decoration: underline;
|
|
}
|
|
.mail-meta {
|
|
margin-bottom: 30px;
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 20px;
|
|
background: #fff;
|
|
padding: 10px 0;
|
|
}
|
|
.meta-item {
|
|
flex: 1;
|
|
min-width: 200px;
|
|
}
|
|
.meta-label {
|
|
font-weight: bold;
|
|
color: #444;
|
|
font-size: 14px;
|
|
display: inline-block;
|
|
width: 100px;
|
|
}
|
|
.meta-value {
|
|
font-size: 16px;
|
|
color: #000;
|
|
border-bottom: 1px dotted #ccc;
|
|
padding-bottom: 2px;
|
|
}
|
|
.mail-content-container {
|
|
border: 1px solid #000;
|
|
padding: 30px;
|
|
min-height: 500px;
|
|
position: relative;
|
|
margin-top: 20px;
|
|
}
|
|
.mail-content {
|
|
font-size: 16px;
|
|
text-align: justify;
|
|
}
|
|
.footer {
|
|
margin-top: 40px;
|
|
padding-top: 20px; /* Matched to header padding-bottom */
|
|
border-top: 3px double #333; /* Equal to the top line style */
|
|
text-align: center;
|
|
font-size: 11px;
|
|
color: #000;
|
|
}
|
|
.footer-content {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
flex-wrap: nowrap;
|
|
gap: 8px;
|
|
white-space: nowrap;
|
|
}
|
|
.social-icons i {
|
|
margin: 0 2px;
|
|
font-size: 12px;
|
|
}
|
|
.footer-sep {
|
|
color: #999;
|
|
margin: 0 2px;
|
|
}
|
|
.no-print {
|
|
position: fixed;
|
|
top: 20px;
|
|
left: 20px;
|
|
background: #212529;
|
|
color: #fff;
|
|
border: none;
|
|
padding: 10px 25px;
|
|
border-radius: 30px;
|
|
cursor: pointer;
|
|
z-index: 1000;
|
|
box-shadow: 0 4px 15px rgba(0,0,0,0.3);
|
|
font-family: 'Cairo', sans-serif;
|
|
font-weight: bold;
|
|
transition: all 0.3s;
|
|
}
|
|
.no-print:hover {
|
|
background: #000;
|
|
transform: translateY(-2px);
|
|
}
|
|
@media print {
|
|
.no-print {
|
|
display: none;
|
|
}
|
|
body {
|
|
background: none;
|
|
}
|
|
.print-container {
|
|
padding: 0;
|
|
margin: 0;
|
|
max-width: 100%;
|
|
}
|
|
.mail-content-container {
|
|
border: none;
|
|
padding: 10px 0;
|
|
}
|
|
.footer {
|
|
position: fixed;
|
|
bottom: 0.5cm; /* Positioned inside the reserved 2cm bottom margin */
|
|
left: 1.5cm;
|
|
right: 1.5cm;
|
|
margin-top: 0;
|
|
background: white;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<button class="no-print" onclick="window.print()">
|
|
<i class="fas fa-print me-1"></i> طباعة الوثيقة
|
|
</button>
|
|
|
|
<div class="print-container">
|
|
<div class="header">
|
|
<div class="header-logo">
|
|
<?php if ($logo): ?>
|
|
<img src="<?= htmlspecialchars($logo) ?>" alt="Logo">
|
|
<?php else: ?>
|
|
<div style="font-weight: bold; font-size: 24px; color: #1a73e8;"><?= htmlspecialchars($site_name) ?></div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="header-title">
|
|
<!-- Title removed as per user request -->
|
|
</div>
|
|
<div class="header-info">
|
|
<div class="charity-name-header"><?= htmlspecialchars($site_name) ?></div>
|
|
<div class="charity-address-header"><?= htmlspecialchars($site_address) ?></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mail-meta">
|
|
<div class="meta-item">
|
|
<span class="meta-label">رقم القيد:</span>
|
|
<span class="meta-value"><?= htmlspecialchars($mail['ref_no']) ?></span>
|
|
</div>
|
|
<div class="meta-item" style="flex: 2;">
|
|
<span class="meta-label">التاريخ:</span>
|
|
<span class="meta-value">
|
|
<?= htmlspecialchars($hijriDate) ?>
|
|
الموافق:
|
|
<?= htmlspecialchars($mail['date_registered']) ?>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mail-content-container">
|
|
<div class="mail-content">
|
|
<?= $mail['description'] ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="footer">
|
|
<div class="footer-content">
|
|
<span>
|
|
<strong>وسائل التواصل:</strong> ahlalhkair
|
|
<span class="social-icons">
|
|
<i class="fab fa-twitter"></i>
|
|
<i class="fab fa-instagram"></i>
|
|
<i class="fab fa-facebook"></i>
|
|
</span>
|
|
</span>
|
|
<span class="footer-sep">|</span>
|
|
<span><strong>هاتف:</strong> 99621515</span>
|
|
<span class="footer-sep">|</span>
|
|
<span><strong>الايميل:</strong> ahlalhkair@gmail.com</span>
|
|
<span class="footer-sep">|</span>
|
|
<span><strong>الموقع:</strong> https://alkhairteam.net/</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|