editing printing

This commit is contained in:
Flatlogic Bot 2026-03-01 03:17:52 +00:00
parent e9893232d6
commit efe588ff68
4 changed files with 168 additions and 177 deletions

View File

@ -13,13 +13,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
$id = $_POST['id'] ?? 0; $id = $_POST['id'] ?? 0;
$ref_no = $_POST['ref_no'] ?? ''; $ref_no = $_POST['ref_no'] ?? '';
$date_registered = $_POST['date_registered'] ?? date('Y-m-d'); $date_registered = $_POST['date_registered'] ?? date('Y-m-d');
$due_date = $_POST['due_date'] ?? null; $due_date = !empty($_POST['due_date']) ? $_POST['due_date'] : null;
$sender = $_POST['sender'] ?? ''; $sender = $_POST['sender'] ?? '';
$recipient = $_POST['recipient'] ?? ''; $recipient = $_POST['recipient'] ?? '';
$subject = $_POST['subject'] ?? ''; $subject = $_POST['subject'] ?? '';
$description = $_POST['description'] ?? ''; $description = $_POST['description'] ?? '';
$status_id = $_POST['status_id'] ?? null; $status_id = !empty($_POST['status_id']) ? $_POST['status_id'] : null;
$assigned_to = $_POST['assigned_to'] ?? null; $assigned_to = !empty($_POST['assigned_to']) ? $_POST['assigned_to'] : null;
if ($action === 'add' || $action === 'edit') { if ($action === 'add' || $action === 'edit') {
try { try {

View File

@ -15,7 +15,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['
if (!canAdd('internal')) { if (!canAdd('internal')) {
$error = 'عذراً، ليس لديك الصلاحية لإرسال رسائل'; $error = 'عذراً، ليس لديك الصلاحية لإرسال رسائل';
} else { } else {
$recipient_id = $_POST['recipient_id'] ?? null; $recipient_id = !empty($_POST['recipient_id']) ? $_POST['recipient_id'] : null;
$subject = $_POST['subject'] ?? ''; $subject = $_POST['subject'] ?? '';
$description = $_POST['description'] ?? ''; $description = $_POST['description'] ?? '';
$type = 'internal'; $type = 'internal';

View File

@ -13,13 +13,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
$id = $_POST['id'] ?? 0; $id = $_POST['id'] ?? 0;
$ref_no = $_POST['ref_no'] ?? ''; $ref_no = $_POST['ref_no'] ?? '';
$date_registered = $_POST['date_registered'] ?? date('Y-m-d'); $date_registered = $_POST['date_registered'] ?? date('Y-m-d');
$due_date = $_POST['due_date'] ?? null; $due_date = !empty($_POST['due_date']) ? $_POST['due_date'] : null;
$sender = $_POST['sender'] ?? ''; $sender = $_POST['sender'] ?? '';
$recipient = $_POST['recipient'] ?? ''; $recipient = $_POST['recipient'] ?? '';
$subject = $_POST['subject'] ?? ''; $subject = $_POST['subject'] ?? '';
$description = $_POST['description'] ?? ''; $description = $_POST['description'] ?? '';
$status_id = $_POST['status_id'] ?? null; $status_id = !empty($_POST['status_id']) ? $_POST['status_id'] : null;
$assigned_to = $_POST['assigned_to'] ?? null; $assigned_to = !empty($_POST['assigned_to']) ? $_POST['assigned_to'] : null;
if ($action === 'add' || $action === 'edit') { if ($action === 'add' || $action === 'edit') {
try { try {
@ -311,6 +311,10 @@ if (isset($_GET['id'])) {
<label class="form-label small fw-bold">محتوى الخطاب / الوصف</label> <label class="form-label small fw-bold">محتوى الخطاب / الوصف</label>
<textarea name="description" id="description_editor" class="form-control" rows="5"></textarea> <textarea name="description" id="description_editor" class="form-control" rows="5"></textarea>
</div> </div>
<div class="col-md-6">
<label class="form-label small fw-bold">تاريخ الاستحقاق (اختياري)</label>
<input type="date" name="due_date" id="modalDueDate" class="form-control">
</div>
<div class="col-md-6"> <div class="col-md-6">
<label class="form-label small fw-bold">الحالة</label> <label class="form-label small fw-bold">الحالة</label>
<select name="status_id" id="modalStatusId" class="form-select" required> <select name="status_id" id="modalStatusId" class="form-select" required>
@ -319,7 +323,7 @@ if (isset($_GET['id'])) {
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>
<div class="col-md-6"> <div class="col-md-12">
<label class="form-label small fw-bold">إسناد للمتابعة (اختياري)</label> <label class="form-label small fw-bold">إسناد للمتابعة (اختياري)</label>
<select name="assigned_to" id="modalAssignedTo" class="form-select"> <select name="assigned_to" id="modalAssignedTo" class="form-select">
<option value="">--- اختر مستخدم ---</option> <option value="">--- اختر مستخدم ---</option>
@ -513,4 +517,4 @@ document.addEventListener('DOMContentLoaded', function() {
}); });
</script> </script>
<?php require_once 'includes/footer.php'; ?> <?php require_once 'includes/footer.php'; ?>

View File

@ -8,11 +8,10 @@ if (!isset($_SESSION['user_id'])) {
die('Access Denied'); die('Access Denied');
} }
// Basic permission check (matches header.php logic) // Basic permission check
function isAdmin() { function isAdmin() {
if (isset($_SESSION['is_super_admin']) && $_SESSION['is_super_admin'] == 1) return true; 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['user_role']) && strtolower($_SESSION['user_role']) === 'admin') return true;
if (isset($_SESSION['role']) && strtolower($_SESSION['role']) === 'admin') return true;
return false; return false;
} }
@ -95,164 +94,148 @@ $hijriDate = gregorianToHijri($mail['date_registered']);
<style> <style>
@page { @page {
size: A4; size: A4;
margin: 1cm 1.5cm 2cm 1.5cm; /* Reserved 2cm at bottom for fixed footer */ margin: 0;
} }
body { body {
font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #fff; background-color: #f4f7f6;
color: #333; color: #333;
margin: 0; margin: 0;
padding: 0; padding: 0;
line-height: 1.6; line-height: 1.6;
} }
.print-container {
width: 100%; .print-wrapper {
max-width: 21cm; width: 21cm;
margin: 0 auto; margin: 0 auto;
padding: 20px; background: #fff;
} padding: 1.5cm;
.header { box-shadow: 0 0 10px rgba(0,0,0,0.1);
min-height: 29.7cm;
position: relative;
box-sizing: border-box;
display: flex; display: flex;
justify-content: space-between; flex-direction: column;
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; /* Repeating Header */
max-width: 200px; .report-table {
} width: 100%;
.header-info { border-collapse: collapse;
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; flex-grow: 1;
} }
.header-title h1 { .report-header {
margin: 0; display: table-header-group;
font-size: 28px;
color: #000;
text-decoration: underline;
} }
.mail-meta { .report-footer {
margin-bottom: 30px; display: table-footer-group;
}
/* Header Style */
.header-container {
border-bottom: 3px double #00827F;
padding-bottom: 10px;
margin-bottom: 20px;
display: flex; display: flex;
flex-wrap: wrap; justify-content: space-between;
gap: 20px; align-items: flex-start;
background: #fff;
padding: 10px 0;
} }
.meta-item { .header-logo img {
flex: 1; max-height: 80px;
min-width: 200px;
} }
.meta-label { .header-info { text-align: left; }
font-weight: bold; .site-name { font-size: 24px; font-weight: bold; color: #00827F; margin-bottom: 5px; }
color: #444;
font-size: 14px; /* Meta & Content */
display: inline-block; .mail-meta {
width: 100px; margin-bottom: 25px;
} display: flex;
.meta-value { justify-content: space-between;
font-size: 16px; background: #f9f9f9;
color: #000; padding: 12px;
border-bottom: 1px dotted #ccc; border: 1px solid #eee;
padding-bottom: 2px;
}
.mail-content-container {
border: 1px solid #000;
padding: 30px;
min-height: 500px;
position: relative;
margin-top: 20px;
} }
.mail-content { .mail-content {
font-size: 16px; font-size: 18px;
text-align: justify; text-align: justify;
color: #000;
min-height: 12cm;
padding-bottom: 30px;
} }
.footer {
margin-top: 40px; /* Footer Style */
padding-top: 20px; /* Matched to header padding-bottom */ .footer-container {
border-top: 3px double #333; /* Equal to the top line style */ border-top: 3px double #00827F;
padding-top: 10px;
text-align: center; text-align: center;
font-size: 11px; font-size: 11px;
color: #000; width: 100%;
background: #fff;
margin-top: auto;
} }
.footer-content { .contact-row {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; gap: 15px;
flex-wrap: nowrap; margin-bottom: 5px;
gap: 8px; flex-wrap: wrap;
white-space: nowrap;
} }
.social-icons i { .page-num-display {
margin: 0 2px; font-size: 14px;
font-size: 12px; font-weight: bold;
margin-top: 5px;
} }
.footer-sep {
color: #999; /* Footer Spacer for Table */
margin: 0 2px; .footer-spacer {
height: 80px;
display: none;
} }
/* UI Controls */
.no-print { .no-print {
position: fixed; position: fixed;
top: 20px; top: 20px;
left: 20px; left: 20px;
background: #212529; background: #00827F;
color: #fff; color: #fff;
border: none;
padding: 10px 25px; padding: 10px 25px;
border: none;
border-radius: 30px; border-radius: 30px;
cursor: pointer; cursor: pointer;
z-index: 1000; z-index: 1000;
box-shadow: 0 4px 15px rgba(0,0,0,0.3);
font-family: 'Cairo', sans-serif; font-family: 'Cairo', sans-serif;
font-weight: bold; font-weight: bold;
transition: all 0.3s; box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.no-print:hover {
background: #000;
transform: translateY(-2px);
} }
@media print { @media print {
.no-print { @page {
display: none; margin: 1cm 0;
} }
body { body { background: #fff; }
background: none; .no-print { display: none; }
} .print-wrapper {
.print-container { width: 100%;
padding: 0;
margin: 0; margin: 0;
max-width: 100%; padding: 0 1.5cm;
box-shadow: none;
min-height: auto;
display: block;
} }
.mail-content-container {
border: none; .footer-container {
padding: 10px 0;
}
.footer {
position: fixed; position: fixed;
bottom: 0.5cm; /* Positioned inside the reserved 2cm bottom margin */ bottom: 0;
left: 1.5cm; left: 0;
right: 1.5cm; right: 0;
margin-top: 0; padding: 10px 1.5cm;
background: white; box-sizing: border-box;
z-index: 100;
}
.footer-spacer {
display: block;
} }
} }
</style> </style>
@ -260,67 +243,71 @@ $hijriDate = gregorianToHijri($mail['date_registered']);
<body> <body>
<button class="no-print" onclick="window.print()"> <button class="no-print" onclick="window.print()">
<i class="fas fa-print me-1"></i> طباعة الوثيقة <i class="fas fa-print"></i> طباعة الوثيقة
</button> </button>
<div class="print-container"> <div class="print-wrapper">
<div class="header"> <table class="report-table">
<div class="header-logo"> <thead class="report-header">
<?php if ($logo): ?> <tr>
<img src="<?= htmlspecialchars($logo) ?>" alt="Logo"> <td>
<?php else: ?> <div class="header-container">
<div style="font-weight: bold; font-size: 24px; color: #1a73e8;"><?= htmlspecialchars($site_name) ?></div> <div class="header-logo">
<?php endif; ?> <?php if ($logo): ?>
</div> <img src="<?= htmlspecialchars($logo) ?>" alt="Logo">
<div class="header-title"> <?php else: ?>
<!-- Title removed as per user request --> <div style="font-weight: bold; font-size: 26px; color: #00827F;"><?= htmlspecialchars($site_name) ?></div>
</div> <?php endif; ?>
<div class="header-info"> </div>
<div class="charity-name-header"><?= htmlspecialchars($site_name) ?></div> <div class="header-info">
<div class="charity-address-header"><?= htmlspecialchars($site_address) ?></div> <div class="site-name"><?= htmlspecialchars($site_name) ?></div>
</div> <div style="font-size: 12px; color: #666;"><?= htmlspecialchars($site_address) ?></div>
</div> </div>
</div>
</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="mail-meta">
<div><strong>رقم القيد:</strong> <?= htmlspecialchars($mail['ref_no']) ?></div>
<div><strong>التاريخ:</strong> <?= htmlspecialchars($hijriDate) ?> | <?= htmlspecialchars($mail['date_registered']) ?>م</div>
</div>
<div class="mail-meta"> <div class="mail-content">
<div class="meta-item"> <?= $mail['description'] ?>
<span class="meta-label">رقم القيد:</span> </div>
<span class="meta-value"><?= htmlspecialchars($mail['ref_no']) ?></span> </td>
</div> </tr>
<div class="meta-item" style="flex: 2;"> </tbody>
<span class="meta-label">التاريخ:</span>
<span class="meta-value"> <tfoot class="report-footer">
<?= htmlspecialchars($hijriDate) ?> <tr>
الموافق: <td>
<?= htmlspecialchars($mail['date_registered']) ?> <div class="footer-spacer"></div>
</td>
</tr>
</tfoot>
</table>
<div class="footer-container">
<div class="contact-row">
<span><i class="fas fa-phone"></i> 99621515</span>
<span><i class="fas fa-envelope"></i> ahlalhkair@gmail.com</span>
<span><i class="fas fa-globe"></i> https://alkhairteam.net/</span>
<span class="ms-3">
<i class="fab fa-instagram"></i>
<i class="fab fa-twitter"></i>
<i class="fab fa-facebook"></i>
alkhair_team
</span> </span>
</div> </div>
</div> <div class="page-num-display">
<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> </div>
</div> </div>
</body> </body>
</html> </html>