[
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']; $page = max(1, intval($_GET['page'] ?? 1)); $offset = ($page - 1) * RECORDS_PER_PAGE; if ($userRole === 'representative') { $countSql = "SELECT COUNT(*) as total FROM payments WHERE representative_id = ?"; $totalRecords = $db->query($countSql, [$userId])->fetch()['total']; $sql = "SELECT p.*, c.name as customer_name, u.name as representative_name FROM payments p LEFT JOIN customers c ON p.customer_id = c.id LEFT JOIN users u ON p.representative_id = u.id WHERE p.representative_id = ? ORDER BY p.created_at DESC LIMIT " . RECORDS_PER_PAGE . " OFFSET $offset"; $payments = $db->query($sql, [$userId])->fetchAll(); } else { $countSql = "SELECT COUNT(*) as total FROM payments"; $totalRecords = $db->query($countSql)->fetch()['total']; $sql = "SELECT p.*, c.name as customer_name, u.name as representative_name FROM payments p LEFT JOIN customers c ON p.customer_id = c.id LEFT JOIN users u ON p.representative_id = u.id ORDER BY p.created_at DESC LIMIT " . RECORDS_PER_PAGE . " OFFSET $offset"; $payments = $db->query($sql)->fetchAll(); } $totalPages = ceil($totalRecords / RECORDS_PER_PAGE); $paymentMethods = [ 'cash' => 'نقداً', 'bank_transfer' => 'تحويل بنكي', 'other' => 'أخرى' ]; 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-cash-coin"></i> المدفوعات</h2> <a href="create.php" class="btn btn-success"> <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 = [ 'payment_collected' => 'تم تحصيل الدفعة بنجاح' ]; 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 = [ 'no_active_shift' => 'لا توجد وردية نشطة. يجب طلب وردية جديدة أولاً' ]; 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"> <div class="table-responsive"> <table class="table table-hover"> <thead class="table-light"> <tr> <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($payments)): ?> <tr> <td colspan="<?php echo $userRole !== 'representative' ? '9' : '8'; ?>" class="text-center text-muted py-4"> لا توجد مدفوعات </td> </tr> <?php else: ?> <?php foreach ($payments as $index => $payment): ?> <tr> <td><?php echo $offset + $index + 1; ?></td> <td><?php echo htmlspecialchars($payment['customer_name']); ?></td> <?php if ($userRole !== 'representative'): ?> <td><?php echo htmlspecialchars($payment['representative_name']); ?></td> <?php endif; ?> <td><strong class="text-success"><?php echo formatMoney($payment['amount']); ?></strong></td> <td><?php echo formatMoney($payment['previous_debt']); ?></td> <td><?php echo formatMoney($payment['new_debt']); ?></td> <td> <span class="badge bg-info"> <?php echo $paymentMethods[$payment['payment_method']] ?? $payment['payment_method']; ?> </span> </td> <td><?php echo formatDate($payment['created_at']); ?></td> <td> <button type="button" class="btn btn-sm btn-info" onclick="viewPaymentDetails(<?php echo $payment['id']; ?>)"> <i class="bi bi-eye"></i> عرض </button> </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; ?>"> <?php echo $i; ?> </a> </li> <?php endfor; ?> </ul> </nav> <?php endif; ?> </div> </div> </div> </div> <script> function viewPaymentDetails(paymentId) { alert('عرض تفاصيل الدفعة رقم: ' + paymentId); } </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.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