prepare("SELECT * FROM bills WHERE id = ?"); $stmt->execute([$bill_id]); $bill = $stmt->fetch(); if (!$bill) { throw new Exception("Bill not found"); } // Fetch Visit and Patient Details $stmt = $db->prepare(" SELECT v.*, p.name as patient_name, p.phone as patient_phone, p.civil_id, d.name_en as doctor_name_en, d.name_ar as doctor_name_ar FROM visits v JOIN patients p ON v.patient_id = p.id LEFT JOIN doctors d ON v.doctor_id = d.id WHERE v.id = ? "); $stmt->execute([$bill['visit_id']]); $visit = $stmt->fetch(); // Fetch Bill Items $stmt = $db->prepare("SELECT * FROM bill_items WHERE bill_id = ?"); $stmt->execute([$bill_id]); $items = $stmt->fetchAll(); // Fetch Company Settings (Logo, Address, etc.) $stmt = $db->query("SELECT * FROM settings WHERE id = 1"); $settings = $stmt->fetch(); $lang = $_SESSION['lang'] ?? 'en'; } catch (Exception $e) { die("Error: " . $e->getMessage()); } ?> Invoice #<?php echo $bill_id; ?>


Phone:
Email:

#INV-

Date:

Bill To:

'; ?>

Visit Details:

Doctor:
Visit ID: #
Status:

0): ?>
#
$
Total Amount $
Insurance Covered -$
Patient Due $
PAID via
PENDING

Notes:



_________________________

Authorized Signature