[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: details.php
<?php require_once '../config/database.php'; require_once '../config/functions.php'; requireAuth('accountant'); $invoice_id = $_GET['id'] ?? ''; if (!$invoice_id) { header("Location: /invoices/all.php"); exit; } // Get invoice details $stmt = $pdo->prepare(" SELECT i.*, c.name as client_name, c.phone as client_phone, c.address as client_address, u.full_name as representative_name, s.started_at as shift_started FROM invoices i JOIN clients c ON i.client_id = c.id JOIN users u ON i.representative_id = u.id LEFT JOIN shifts s ON i.shift_id = s.id WHERE i.id = ? "); $stmt->execute([$invoice_id]); $invoice = $stmt->fetch(); if (!$invoice) { header("Location: /invoices/all.php?error=invoice_not_found"); exit; } // Get invoice items $stmt = $pdo->prepare(" SELECT ii.*, p.name as product_name, p.unit FROM invoice_items ii JOIN products p ON ii.product_id = p.id WHERE ii.invoice_id = ? ORDER BY p.name ASC "); $stmt->execute([$invoice_id]); $invoice_items = $stmt->fetchAll(); // Get related payments $stmt = $pdo->prepare(" SELECT * FROM payments WHERE linked_invoice_id = ? OR (client_id = ? AND created_at >= ?) ORDER BY created_at ASC "); $stmt->execute([$invoice_id, $invoice['client_id'], $invoice['created_at']]); $related_payments = $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>تفاصيل الفاتورة <?= htmlspecialchars($invoice['invoice_number']) ?></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> .invoice-header { background: linear-gradient(135deg, #0d6efd, #198754); color: white; border-radius: 15px; } .detail-card { border-radius: 10px; border: 1px solid #dee2e6; } .status-paid { color: #198754; } .status-partially-paid { color: #fd7e14; } .status-unpaid { color: #dc3545; } </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 me-2"></i>تفاصيل الفاتورة</h2> <div> <a href="/invoices/print.php?id=<?= $invoice['id'] ?>" class="btn btn-primary me-2"> <i class="fas fa-print me-1"></i>طباعة </a> <a href="/invoices/all.php" class="btn btn-outline-secondary"> <i class="fas fa-arrow-left me-1"></i>العودة </a> </div> </div> <!-- Invoice Header --> <div class="invoice-header p-4 mb-4"> <div class="row"> <div class="col-md-6"> <h3><?= htmlspecialchars($invoice['invoice_number']) ?></h3> <p class="mb-1">التاريخ: <?= date('Y-m-d H:i', strtotime($invoice['created_at'])) ?></p> <p class="mb-0">المندوب: <?= htmlspecialchars($invoice['representative_name']) ?></p> </div> <div class="col-md-6 text-end"> <h4>الإجمالي: <?= formatCurrency($invoice['invoice_total']) ?></h4> <p class="mb-1"> الحالة: <span class="status-<?= str_replace('_', '-', $invoice['status']) ?>"> <?php $status_text = [ 'paid' => 'مدفوعة', 'partially_paid' => 'مدفوعة جزئياً', 'unpaid' => 'غير مدفوعة' ]; echo $status_text[$invoice['status']]; ?> </span> </p> <p class="mb-0">المتبقي: <?= formatCurrency($invoice['remaining_amount']) ?></p> </div> </div> </div> <div class="row"> <!-- Client Information --> <div class="col-md-4 mb-4"> <div class="detail-card card"> <div class="card-header bg-info text-white"> <h5 class="mb-0"><i class="fas fa-user me-2"></i>بيانات العميل</h5> </div> <div class="card-body"> <p><strong>الاسم:</strong> <?= htmlspecialchars($invoice['client_name']) ?></p> <p><strong>الهاتف:</strong> <a href="tel:<?= htmlspecialchars($invoice['client_phone']) ?>"> <?= htmlspecialchars($invoice['client_phone']) ?> </a> </p> <?php if ($invoice['client_address']): ?> <p><strong>العنوان:</strong> <?= htmlspecialchars($invoice['client_address']) ?></p> <?php endif; ?> <p><strong>الرصيد السابق:</strong> <?= formatCurrency($invoice['previous_balance']) ?></p> <p><strong>إجمالي المديونية:</strong> <?= formatCurrency($invoice['new_total_debt']) ?></p> </div> </div> </div> <!-- Invoice Items --> <div class="col-md-8 mb-4"> <div class="detail-card card"> <div class="card-header bg-primary text-white"> <h5 class="mb-0"><i class="fas fa-list me-2"></i>أصناف الفاتورة</h5> </div> <div class="card-body p-0"> <div class="table-responsive"> <table class="table table-hover mb-0"> <thead class="table-light"> <tr> <th>المنتج</th> <th>الكمية</th> <th>السعر</th> <th>الإجمالي</th> </tr> </thead> <tbody> <?php foreach ($invoice_items as $item): ?> <tr> <td><?= htmlspecialchars($item['product_name']) ?></td> <td><?= $item['quantity'] ?> <?= htmlspecialchars($item['unit']) ?></td> <td><?= formatCurrency($item['unit_price']) ?></td> <td><?= formatCurrency($item['line_total']) ?></td> </tr> <?php endforeach; ?> </tbody> <tfoot class="table-light"> <tr> <th colspan="3">الإجمالي</th> <th><?= formatCurrency($invoice['invoice_total']) ?></th> </tr> </tfoot> </table> </div> </div> </div> </div> </div> <!-- Payment Summary --> <div class="row"> <div class="col-12"> <div class="detail-card card"> <div class="card-header bg-success text-white"> <h5 class="mb-0"><i class="fas fa-money-bill me-2"></i>ملخص المدفوعات</h5> </div> <div class="card-body"> <div class="row"> <div class="col-md-3"> <div class="text-center p-3 bg-light rounded"> <h6>إجمالي الفاتورة</h6> <h4 class="text-primary"><?= formatCurrency($invoice['invoice_total']) ?></h4> </div> </div> <div class="col-md-3"> <div class="text-center p-3 bg-light rounded"> <h6>المدفوع عند الإنشاء</h6> <h4 class="text-success"><?= formatCurrency($invoice['amount_paid_at_creation']) ?></h4> </div> </div> <div class="col-md-3"> <div class="text-center p-3 bg-light rounded"> <h6>المبلغ المتبقي</h6> <h4 class="text-warning"><?= formatCurrency($invoice['remaining_amount']) ?></h4> </div> </div> <div class="col-md-3"> <div class="text-center p-3 bg-light rounded"> <h6>إجمالي المديونية</h6> <h4 class="text-danger"><?= formatCurrency($invoice['new_total_debt']) ?></h4> </div> </div> </div> <?php if (!empty($related_payments)): ?> <hr> <h6>المدفوعات المرتبطة</h6> <div class="table-responsive"> <table class="table table-sm"> <thead> <tr> <th>رقم الإيصال</th> <th>التاريخ</th> <th>المبلغ</th> <th>النوع</th> </tr> </thead> <tbody> <?php foreach ($related_payments as $payment): ?> <tr> <td><?= htmlspecialchars($payment['receipt_number']) ?></td> <td><?= date('Y-m-d H:i', strtotime($payment['created_at'])) ?></td> <td><?= formatCurrency($payment['amount']) ?></td> <td> <?= $payment['payment_type'] === 'linked_to_invoice' ? 'مرتبط بالفاتورة' : 'دفعة منفصلة' ?> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php endif; ?> </div> </div> </div> </div> <!-- WhatsApp Share --> <div class="row mt-4"> <div class="col-12 text-center"> <?php if (hasRole('accountant')): ?> <a href="<?= generateInvoiceWhatsAppURL($invoice, $invoice['client_phone']) ?>" target="_blank" class="btn btn-success btn-lg"> <i class="fab fa-whatsapp me-2"></i>إرسال عبر واتساب </a> <?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.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