[
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(); $search = cleanInput($_GET['search'] ?? ''); $page = max(1, intval($_GET['page'] ?? 1)); $offset = ($page - 1) * RECORDS_PER_PAGE; $whereClause = ''; $params = []; if (!empty($search)) { $whereClause = "WHERE c.name LIKE ? OR c.phone LIKE ?"; $params = ["%$search%", "%$search%"]; } $countSql = "SELECT COUNT(*) as total FROM customers c $whereClause"; $totalRecords = $db->query($countSql, $params)->fetch()['total']; $totalPages = ceil($totalRecords / RECORDS_PER_PAGE); $sql = "SELECT c.*, u.name as created_by_name FROM customers c LEFT JOIN users u ON c.created_by = u.id $whereClause ORDER BY c.created_at DESC LIMIT " . RECORDS_PER_PAGE . " OFFSET $offset"; $customers = $db->query($sql, $params)->fetchAll(); 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-people"></i> إدارة العملاء</h2> <a href="create.php" class="btn btn-primary"> <i class="bi bi-plus-lg"></i> إضافة عميل جديد </a> </div> <?php if (isset($_GET['success'])): ?> <div class="alert alert-success alert-dismissible fade show" role="alert"> <?php $messages = [ 'created' => 'تم إضافة العميل بنجاح', 'updated' => 'تم تحديث بيانات العميل بنجاح', 'deleted' => 'تم حذف العميل بنجاح' ]; echo $messages[$_GET['success']] ?? 'تمت العملية بنجاح'; ?> <button type="button" class="btn-close" data-bs-dismiss="alert"></button> </div> <?php endif; ?> <?php if (isset($_GET['error'])): ?> <div class="alert alert-danger alert-dismissible fade show" role="alert"> <?php $errors = [ 'invalid_phone' => 'رقم الهاتف غير صحيح. يجب أن يبدأ بـ +20', 'phone_exists' => 'رقم الهاتف مسجل بالفعل', 'delete_failed' => 'لا يمكن حذف العميل لوجود فواتير مرتبطة به' ]; echo $errors[$_GET['error']] ?? 'حدث خطأ أثناء العملية'; ?> <button type="button" class="btn-close" data-bs-dismiss="alert"></button> </div> <?php endif; ?> <div class="card shadow-sm"> <div class="card-body"> <form method="GET" class="row g-3 mb-4"> <div class="col-md-10"> <input type="text" name="search" class="form-control" placeholder="بحث بالاسم أو رقم الهاتف..." value="<?php echo htmlspecialchars($search); ?>"> </div> <div class="col-md-2"> <button type="submit" class="btn btn-primary w-100"> <i class="bi bi-search"></i> بحث </button> </div> </form> <div class="table-responsive"> <table class="table table-hover"> <thead class="table-light"> <tr> <th>#</th> <th>اسم العميل</th> <th>رقم الهاتف</th> <th>العنوان</th> <th>المديونية الحالية</th> <th>تاريخ الإضافة</th> <th>الإجراءات</th> </tr> </thead> <tbody> <?php if (empty($customers)): ?> <tr> <td colspan="7" class="text-center text-muted py-4">لا توجد بيانات</td> </tr> <?php else: ?> <?php foreach ($customers as $index => $customer): ?> <tr> <td><?php echo $offset + $index + 1; ?></td> <td> <strong><?php echo htmlspecialchars($customer['name']); ?></strong> </td> <td> <a href="tel:<?php echo $customer['phone']; ?>" class="text-decoration-none"> <?php echo htmlspecialchars($customer['phone']); ?> </a> </td> <td><?php echo htmlspecialchars($customer['address'] ?? '-'); ?></td> <td> <?php if ($customer['current_debt'] > 0): ?> <span class="badge bg-danger"><?php echo formatMoney($customer['current_debt']); ?></span> <?php else: ?> <span class="badge bg-success">لا يوجد</span> <?php endif; ?> </td> <td><?php echo formatDate($customer['created_at']); ?></td> <td> <div class="btn-group" role="group"> <a href="view.php?id=<?php echo $customer['id']; ?>" class="btn btn-sm btn-info" title="عرض"> <i class="bi bi-eye"></i> </a> <a href="edit.php?id=<?php echo $customer['id']; ?>" class="btn btn-sm btn-warning" title="تعديل"> <i class="bi bi-pencil"></i> </a> <button type="button" class="btn btn-sm btn-danger" title="حذف" onclick="confirmDelete(<?php echo $customer['id']; ?>)"> <i class="bi bi-trash"></i> </button> </div> </td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> <?php if ($totalPages > 1): ?> <nav aria-label="الصفحات"> <ul class="pagination justify-content-center"> <?php for ($i = 1; $i <= $totalPages; $i++): ?> <li class="page-item <?php echo $i === $page ? 'active' : ''; ?>"> <a class="page-link" href="?page=<?php echo $i; ?>&search=<?php echo urlencode($search); ?>"> <?php echo $i; ?> </a> </li> <?php endfor; ?> </ul> </nav> <?php endif; ?> </div> </div> </div> </div> <script> function confirmDelete(customerId) { if (confirm('هل أنت متأكد من حذف هذا العميل؟')) { window.location.href = 'delete.php?id=' + customerId; } } </script> <?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.86 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