[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: print.php
<?php require_once '../config/database.php'; require_once '../config/functions.php'; requireAuth(); // Allow all authenticated users $invoice_id = $_GET['id'] ?? ''; if (!$invoice_id) { header("Location: /dashboard.php"); exit; } // Get invoice details with related data $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 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(); ?> <!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> @media print { .no-print { display: none !important; } body { margin: 0; padding: 0; } } .thermal-width { max-width: 320px; margin: 0 auto; font-family: 'Courier New', monospace; } .thermal-header { text-align: center; border-bottom: 2px dashed #333; padding-bottom: 10px; margin-bottom: 15px; } .thermal-line { border-top: 1px dashed #ccc; margin: 10px 0; } .thermal-footer { text-align: center; border-top: 2px dashed #333; padding-top: 10px; margin-top: 15px; } .thermal-table { width: 100%; font-size: 12px; } .thermal-table td { padding: 2px 1px; border-bottom: 1px dotted #ccc; } .thermal-meta { display: flex; justify-content: space-between; margin: 5px 0; font-size: 13px; } .thermal-total { text-align: right; font-size: 13px; margin: 3px 0; } </style> </head> <body class="bg-light"> <div class="container-fluid mt-4"> <!-- Action buttons --> <div class="row no-print mb-4"> <div class="col-12 text-center"> <button class="btn btn-primary btn-lg me-3" onclick="window.print()"> <i class="fas fa-print me-2"></i>طباعة الفاتورة </button> <a href="/dashboard.php" class="btn btn-success btn-lg me-3"> <i class="fas fa-home me-2"></i>العودة للرئيسية </a> <a href="/invoices/create.php" class="btn btn-info btn-lg"> <i class="fas fa-plus me-2"></i>فاتورة جديدة </a> </div> </div> <!-- Thermal Receipt --> <div class="thermal-width bg-white p-3 shadow rounded"> <!-- Header --> <div class="thermal-header"> <h4 class="mb-1">حسابات عربية بن فريش</h4> <h5 class="mb-0">فاتورة مبيعات</h5> </div> <!-- Meta Information --> <div class="thermal-meta"> <span>رقم الفاتورة:</span> <span><?= htmlspecialchars($invoice['invoice_number']) ?></span> </div> <div class="thermal-meta"> <span>التاريخ:</span> <span><?= date('Y-m-d H:i', strtotime($invoice['created_at'])) ?></span> </div> <div class="thermal-meta"> <span>المندوب:</span> <span><?= htmlspecialchars($invoice['representative_name']) ?></span> </div> <div class="thermal-meta"> <span>العميل:</span> <span><?= htmlspecialchars($invoice['client_name']) ?></span> </div> <div class="thermal-meta"> <span>الهاتف:</span> <span><?= htmlspecialchars($invoice['client_phone']) ?></span> </div> <div class="thermal-line"></div> <!-- Items Table --> <table class="thermal-table"> <thead> <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><?= number_format($item['unit_price'], 2) ?></td> <td><?= number_format($item['line_total'], 2) ?></td> </tr> <?php endforeach; ?> </tbody> </table> <div class="thermal-line"></div> <!-- Totals --> <div class="thermal-total">إجمالي الفاتورة: <?= formatCurrency($invoice['invoice_total']) ?></div> <div class="thermal-total">المبلغ المدفوع: <?= formatCurrency($invoice['amount_paid_at_creation']) ?></div> <div class="thermal-total">المبلغ المتبقي: <?= formatCurrency($invoice['remaining_amount']) ?></div> <div class="thermal-total">الرصيد السابق: <?= formatCurrency($invoice['previous_balance']) ?></div> <div class="thermal-total"><strong>إجمالي المديونية: <?= formatCurrency($invoice['new_total_debt']) ?></strong></div> <!-- Footer --> <div class="thermal-footer"> <p class="mb-1"><strong>شكراً لتعاملكم معنا</strong></p> <p class="mb-0"><small>للاستفسار: اتصل بالمندوب</small></p> </div> </div> <!-- WhatsApp Share (No Print) --> <div class="row no-print 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> <script> // Auto focus print dialog on load (optional) // window.addEventListener('load', function() { // setTimeout(() => window.print(), 500); // }); </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