[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: all.php
<?php require_once '../config/database.php'; require_once '../config/functions.php'; requireAuth('accountant'); // Get search parameters $search_invoice = $_GET['search_invoice'] ?? ''; $search_client = $_GET['search_client'] ?? ''; $search_representative = $_GET['search_representative'] ?? ''; $status_filter = $_GET['status'] ?? ''; $date_from = $_GET['date_from'] ?? ''; $date_to = $_GET['date_to'] ?? ''; // Build query $where_conditions = []; $params = []; if ($search_invoice) { $where_conditions[] = "i.invoice_number LIKE ?"; $params[] = "%$search_invoice%"; } if ($search_client) { $where_conditions[] = "c.name LIKE ?"; $params[] = "%$search_client%"; } if ($search_representative) { $where_conditions[] = "u.full_name LIKE ?"; $params[] = "%$search_representative%"; } if ($status_filter) { $where_conditions[] = "i.status = ?"; $params[] = $status_filter; } if ($date_from) { $where_conditions[] = "DATE(i.created_at) >= ?"; $params[] = $date_from; } if ($date_to) { $where_conditions[] = "DATE(i.created_at) <= ?"; $params[] = $date_to; } $where_clause = empty($where_conditions) ? '' : 'WHERE ' . implode(' AND ', $where_conditions); // Get invoices $stmt = $pdo->prepare(" SELECT i.*, c.name as client_name, c.phone as client_phone, u.full_name as representative_name FROM invoices i JOIN clients c ON i.client_id = c.id JOIN users u ON i.representative_id = u.id $where_clause ORDER BY i.created_at DESC LIMIT 100 "); $stmt->execute($params); $invoices = $stmt->fetchAll(); // Get summary statistics $stmt = $pdo->prepare(" SELECT COUNT(*) as total_invoices, COALESCE(SUM(invoice_total), 0) as total_amount, COALESCE(SUM(amount_paid_at_creation), 0) as total_paid, COALESCE(SUM(remaining_amount), 0) as total_remaining FROM invoices i JOIN clients c ON i.client_id = c.id JOIN users u ON i.representative_id = u.id $where_clause "); $stmt->execute($params); $summary = $stmt->fetch(); ?> <!DOCTYPE html> <html lang="ar" dir="rtl"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>جميع الفواتير - حسابات عربية بن فريش</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.rtl.min.css" rel="stylesheet"> <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet"> <style> .search-card { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-radius: 15px; } .summary-card { border-radius: 10px; border-left: 4px solid; } .summary-total { border-left-color: #0d6efd; } .summary-paid { border-left-color: #198754; } .summary-remaining { border-left-color: #dc3545; } .whatsapp-btn { background: #25d366; border: none; color: white; border-radius: 50%; width: 35px; height: 35px; display: flex; align-items: center; justify-content: center; } .whatsapp-btn:hover { background: #128c7e; color: white; } .table th { background: #f8f9fa; border-top: none; } </style> </head> <body class="bg-light"> <div class="container-fluid mt-4"> <div class="d-flex justify-content-between align-items-center mb-4"> <h2><i class="fas fa-file-invoice-dollar me-2"></i>جميع الفواتير</h2> <a href="/dashboard.php" class="btn btn-outline-secondary"> <i class="fas fa-arrow-left me-1"></i>العودة </a> </div> <!-- Search Filters --> <div class="search-card p-4 mb-4"> <h5 class="mb-3"><i class="fas fa-search me-2"></i>البحث والتصفية</h5> <form method="GET"> <div class="row"> <div class="col-md-3 mb-3"> <label class="form-label">رقم الفاتورة</label> <input type="text" class="form-control" name="search_invoice" value="<?= htmlspecialchars($search_invoice) ?>" placeholder="INV-..."> </div> <div class="col-md-3 mb-3"> <label class="form-label">اسم العميل</label> <input type="text" class="form-control" name="search_client" value="<?= htmlspecialchars($search_client) ?>" placeholder="اسم العميل"> </div> <div class="col-md-3 mb-3"> <label class="form-label">المندوب</label> <input type="text" class="form-control" name="search_representative" value="<?= htmlspecialchars($search_representative) ?>" placeholder="اسم المندوب"> </div> <div class="col-md-3 mb-3"> <label class="form-label">حالة الدفع</label> <select class="form-select" name="status"> <option value="">جميع الحالات</option> <option value="paid" <?= $status_filter === 'paid' ? 'selected' : '' ?>>مدفوعة</option> <option value="partially_paid" <?= $status_filter === 'partially_paid' ? 'selected' : '' ?>>مدفوعة جزئياً</option> <option value="unpaid" <?= $status_filter === 'unpaid' ? 'selected' : '' ?>>غير مدفوعة</option> </select> </div> </div> <div class="row"> <div class="col-md-3 mb-3"> <label class="form-label">من تاريخ</label> <input type="date" class="form-control" name="date_from" value="<?= htmlspecialchars($date_from) ?>"> </div> <div class="col-md-3 mb-3"> <label class="form-label">إلى تاريخ</label> <input type="date" class="form-control" name="date_to" value="<?= htmlspecialchars($date_to) ?>"> </div> <div class="col-md-6 mb-3 d-flex align-items-end"> <button type="submit" class="btn btn-light me-2"> <i class="fas fa-search me-1"></i>بحث </button> <a href="/invoices/all.php" class="btn btn-outline-light"> <i class="fas fa-refresh me-1"></i>إعادة تعيين </a> </div> </div> </form> </div> <!-- Summary Statistics --> <div class="row mb-4"> <div class="col-md-3 mb-3"> <div class="summary-card summary-total card p-3"> <div class="d-flex justify-content-between align-items-center"> <div> <h6 class="text-muted mb-1">إجمالي الفواتير</h6> <h4 class="mb-0"><?= $summary['total_invoices'] ?></h4> </div> <i class="fas fa-file-invoice fa-2x text-primary"></i> </div> </div> </div> <div class="col-md-3 mb-3"> <div class="summary-card card p-3"> <div class="d-flex justify-content-between align-items-center"> <div> <h6 class="text-muted mb-1">إجمالي المبلغ</h6> <h5 class="mb-0"><?= formatCurrency($summary['total_amount']) ?></h5> </div> <i class="fas fa-calculator fa-2x text-info"></i> </div> </div> </div> <div class="col-md-3 mb-3"> <div class="summary-card summary-paid card p-3"> <div class="d-flex justify-content-between align-items-center"> <div> <h6 class="text-muted mb-1">المدفوع</h6> <h5 class="mb-0"><?= formatCurrency($summary['total_paid']) ?></h5> </div> <i class="fas fa-check-circle fa-2x text-success"></i> </div> </div> </div> <div class="col-md-3 mb-3"> <div class="summary-card summary-remaining card p-3"> <div class="d-flex justify-content-between align-items-center"> <div> <h6 class="text-muted mb-1">المتبقي</h6> <h5 class="mb-0"><?= formatCurrency($summary['total_remaining']) ?></h5> </div> <i class="fas fa-exclamation-circle fa-2x text-danger"></i> </div> </div> </div> </div> <!-- Invoices Table --> <div class="card"> <div class="card-header bg-primary text-white"> <h5 class="mb-0"> <i class="fas fa-list me-2"></i> قائمة الفواتير (<?= count($invoices) ?>) </h5> </div> <div class="card-body p-0"> <?php if (empty($invoices)): ?> <div class="text-center py-5"> <i class="fas fa-inbox fa-3x text-muted mb-3"></i> <p class="text-muted">لا توجد فواتير تطابق معايير البحث</p> </div> <?php else: ?> <div class="table-responsive"> <table class="table table-hover mb-0"> <thead> <tr> <th>رقم الفاتورة</th> <th>العميل</th> <th>المندوب</th> <th>التاريخ</th> <th>الإجمالي</th> <th>المدفوع</th> <th>المتبقي</th> <th>الحالة</th> <th>واتساب</th> <th>إجراءات</th> </tr> </thead> <tbody> <?php foreach ($invoices as $invoice): ?> <tr> <td> <strong><?= htmlspecialchars($invoice['invoice_number']) ?></strong> </td> <td> <?= htmlspecialchars($invoice['client_name']) ?> <br><small class="text-muted"><?= htmlspecialchars($invoice['client_phone']) ?></small> </td> <td><?= htmlspecialchars($invoice['representative_name']) ?></td> <td><?= date('Y-m-d H:i', strtotime($invoice['created_at'])) ?></td> <td><?= formatCurrency($invoice['invoice_total']) ?></td> <td><?= formatCurrency($invoice['amount_paid_at_creation']) ?></td> <td><?= formatCurrency($invoice['remaining_amount']) ?></td> <td> <?php $status_class = [ 'paid' => 'success', 'partially_paid' => 'warning', 'unpaid' => 'danger' ]; $status_text = [ 'paid' => 'مدفوعة', 'partially_paid' => 'جزئية', 'unpaid' => 'غير مدفوعة' ]; ?> <span class="badge bg-<?= $status_class[$invoice['status']] ?>"> <?= $status_text[$invoice['status']] ?> </span> </td> <td> <?php if (hasRole('accountant')): ?> <a href="<?= generateInvoiceWhatsAppURL($invoice, $invoice['client_phone']) ?>" target="_blank" class="whatsapp-btn" title="إرسال عبر واتساب"> <i class="fab fa-whatsapp"></i> </a> <?php endif; ?> </td> <td> <div class="btn-group btn-group-sm"> <a href="/invoices/print.php?id=<?= $invoice['id'] ?>" class="btn btn-outline-primary" title="طباعة"> <i class="fas fa-print"></i> </a> <a href="/invoices/details.php?id=<?= $invoice['id'] ?>" class="btn btn-outline-info" title="التفاصيل"> <i class="fas fa-eye"></i> </a> </div> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php endif; ?> </div> </div> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> </body> </html>
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.87 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