[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: index.php
<?php require_once '../config/database.php'; require_once '../config/functions.php'; requireAuth('accountant'); // Get date range (default to current month) $date_from = $_GET['date_from'] ?? date('Y-m-01'); $date_to = $_GET['date_to'] ?? date('Y-m-d'); // Sales Report $stmt = $pdo->prepare(" SELECT COUNT(*) as total_invoices, COALESCE(SUM(invoice_total), 0) as total_sales, COALESCE(SUM(amount_paid_at_creation), 0) as cash_at_creation, COALESCE(SUM(remaining_amount), 0) as total_debt FROM invoices WHERE DATE(created_at) BETWEEN ? AND ? "); $stmt->execute([$date_from, $date_to]); $sales_summary = $stmt->fetch(); // Payments Report $stmt = $pdo->prepare(" SELECT COUNT(*) as total_payments, COALESCE(SUM(amount), 0) as total_amount FROM payments WHERE DATE(created_at) BETWEEN ? AND ? "); $stmt->execute([$date_from, $date_to]); $payments_summary = $stmt->fetch(); // Returns Report $stmt = $pdo->prepare(" SELECT COUNT(*) as total_returns, COALESCE(SUM(return_value), 0) as total_value FROM returns WHERE status = 'approved' AND DATE(processed_at) BETWEEN ? AND ? "); $stmt->execute([$date_from, $date_to]); $returns_summary = $stmt->fetch(); // Top Products $stmt = $pdo->prepare(" SELECT p.name, p.unit, SUM(ii.quantity) as total_quantity, SUM(ii.line_total) as total_value FROM invoice_items ii JOIN invoices i ON ii.invoice_id = i.id JOIN products p ON ii.product_id = p.id WHERE DATE(i.created_at) BETWEEN ? AND ? GROUP BY p.id, p.name, p.unit ORDER BY total_value DESC LIMIT 10 "); $stmt->execute([$date_from, $date_to]); $top_products = $stmt->fetchAll(); // Top Representatives $stmt = $pdo->prepare(" SELECT u.full_name, COUNT(i.id) as invoice_count, COALESCE(SUM(i.invoice_total), 0) as total_sales FROM users u LEFT JOIN invoices i ON u.id = i.representative_id AND DATE(i.created_at) BETWEEN ? AND ? WHERE u.role = 'representative' GROUP BY u.id, u.full_name ORDER BY total_sales DESC "); $stmt->execute([$date_from, $date_to]); $representatives_performance = $stmt->fetchAll(); // Daily Sales Chart Data $stmt = $pdo->prepare(" SELECT DATE(created_at) as sale_date, COUNT(*) as invoice_count, COALESCE(SUM(invoice_total), 0) as daily_sales FROM invoices WHERE DATE(created_at) BETWEEN ? AND ? GROUP BY DATE(created_at) ORDER BY sale_date ASC "); $stmt->execute([$date_from, $date_to]); $daily_sales = $stmt->fetchAll(); ?> <!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"> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <style> .report-card { border-radius: 15px; transition: all 0.3s ease; } .report-card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.1); } .stat-card { border-radius: 10px; border-left: 4px solid; } .stat-sales { border-left-color: #198754; } .stat-payments { border-left-color: #0d6efd; } .stat-returns { border-left-color: #fd7e14; } .stat-debt { border-left-color: #dc3545; } .chart-container { position: relative; height: 400px; } .date-filter-card { background: linear-gradient(135deg, #6f42c1 0%, #e83e8c 100%); color: white; border-radius: 15px; } </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-chart-bar me-2"></i>التقارير</h2> <div> <button class="btn btn-success me-2" onclick="window.print()"> <i class="fas fa-print me-1"></i>طباعة التقرير </button> <a href="/dashboard.php" class="btn btn-outline-secondary"> <i class="fas fa-arrow-left me-1"></i>العودة </a> </div> </div> <!-- Date Filter --> <div class="date-filter-card p-4 mb-4"> <h5 class="mb-3"><i class="fas fa-calendar me-2"></i>فترة التقرير</h5> <form method="GET" class="row align-items-end"> <div class="col-md-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"> <label class="form-label">إلى تاريخ</label> <input type="date" class="form-control" name="date_to" value="<?= htmlspecialchars($date_to) ?>"> </div> <div class="col-md-6"> <button type="submit" class="btn btn-light me-2"> <i class="fas fa-search me-1"></i>تحديث التقرير </button> <a href="/reports/index.php" class="btn btn-outline-light"> <i class="fas fa-refresh me-1"></i>الشهر الحالي </a> </div> </form> </div> <!-- Summary Statistics --> <div class="row mb-4"> <div class="col-md-3 mb-3"> <div class="stat-card stat-sales 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"><?= formatCurrency($sales_summary['total_sales']) ?></h4> <small class="text-muted"><?= $sales_summary['total_invoices'] ?> فاتورة</small> </div> <i class="fas fa-chart-line fa-2x text-success"></i> </div> </div> </div> <div class="col-md-3 mb-3"> <div class="stat-card stat-payments 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"><?= formatCurrency($payments_summary['total_amount'] + $sales_summary['cash_at_creation']) ?></h4> <small class="text-muted"><?= $payments_summary['total_payments'] ?> دفعة</small> </div> <i class="fas fa-money-bill fa-2x text-primary"></i> </div> </div> </div> <div class="col-md-3 mb-3"> <div class="stat-card stat-returns 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"><?= formatCurrency($returns_summary['total_value']) ?></h4> <small class="text-muted"><?= $returns_summary['total_returns'] ?> مرتجع</small> </div> <i class="fas fa-undo fa-2x text-warning"></i> </div> </div> </div> <div class="col-md-3 mb-3"> <div class="stat-card stat-debt 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"><?= formatCurrency($sales_summary['total_debt']) ?></h4> <small class="text-muted">من الفترة</small> </div> <i class="fas fa-exclamation-triangle fa-2x text-danger"></i> </div> </div> </div> </div> <!-- Charts Row --> <div class="row mb-4"> <div class="col-md-8"> <div class="report-card card"> <div class="card-header bg-primary text-white"> <h5 class="mb-0"><i class="fas fa-chart-line me-2"></i>المبيعات اليومية</h5> </div> <div class="card-body"> <div class="chart-container"> <canvas id="dailySalesChart"></canvas> </div> </div> </div> </div> <div class="col-md-4"> <div class="report-card card"> <div class="card-header bg-success text-white"> <h5 class="mb-0"><i class="fas fa-trophy me-2"></i>أداء المندوبين</h5> </div> <div class="card-body"> <?php foreach ($representatives_performance as $index => $rep): ?> <?php if ($index < 5): // Top 5 ?> <div class="d-flex justify-content-between align-items-center mb-2"> <div> <strong><?= htmlspecialchars($rep['full_name']) ?></strong> <br><small class="text-muted"><?= $rep['invoice_count'] ?> فاتورة</small> </div> <div class="text-end"> <strong><?= formatCurrency($rep['total_sales']) ?></strong> </div> </div> <?php if ($index < 4): ?><hr><?php endif; ?> <?php endif; ?> <?php endforeach; ?> </div> </div> </div> </div> <!-- Report Links --> <div class="row mb-4"> <div class="col-md-3 mb-3"> <a href="/reports/representatives.php" class="btn btn-warning btn-lg w-100"> <i class="fas fa-users mb-2 d-block"></i> تقرير المندوبين </a> </div> <div class="col-md-3 mb-3"> <a href="/reports/representative_detailed.php" class="btn btn-info btn-lg w-100"> <i class="fas fa-user-chart mb-2 d-block"></i> تقرير مفصل للمندوب </a> </div> <div class="col-md-3 mb-3"> <a href="/reports/overdue_clients.php" class="btn btn-danger btn-lg w-100"> <i class="fas fa-exclamation-triangle mb-2 d-block"></i> العملاء المتأخرين </a> </div> </div> <!-- Top Products --> <div class="row"> <div class="col-12"> <div class="report-card card"> <div class="card-header bg-info text-white"> <h5 class="mb-0"><i class="fas fa-star me-2"></i>أفضل المنتجات مبيعاً</h5> </div> <div class="card-body"> <?php if (empty($top_products)): ?> <div class="text-center py-4"> <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"> <thead> <tr> <th>المنتج</th> <th>الكمية المباعة</th> <th>إجمالي القيمة</th> <th>النسبة</th> </tr> </thead> <tbody> <?php $total_value = array_sum(array_column($top_products, 'total_value')); foreach ($top_products as $product): $percentage = $total_value > 0 ? ($product['total_value'] / $total_value) * 100 : 0; ?> <tr> <td><strong><?= htmlspecialchars($product['name']) ?></strong></td> <td><?= $product['total_quantity'] ?> <?= htmlspecialchars($product['unit']) ?></td> <td><?= formatCurrency($product['total_value']) ?></td> <td> <div class="progress" style="height: 20px;"> <div class="progress-bar" role="progressbar" style="width: <?= $percentage ?>%" aria-valuenow="<?= $percentage ?>" aria-valuemin="0" aria-valuemax="100"> <?= number_format($percentage, 1) ?>% </div> </div> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php endif; ?> </div> </div> </div> </div> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> <script> // Daily Sales Chart const dailySalesData = <?= json_encode($daily_sales) ?>; const ctx = document.getElementById('dailySalesChart').getContext('2d'); new Chart(ctx, { type: 'line', data: { labels: dailySalesData.map(item => item.sale_date), datasets: [{ label: 'المبيعات اليومية', data: dailySalesData.map(item => item.daily_sales), borderColor: '#198754', backgroundColor: 'rgba(25, 135, 84, 0.1)', tension: 0.4, fill: true }] }, options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { display: false } }, scales: { y: { beginAtZero: true, ticks: { callback: function(value) { return value.toLocaleString() + ' جنيه'; } } } } } }); </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.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