based on this database (Database Structure
The database for the admin dashboard and patient management system consists of the following tables:
a. Patients
id (INT, AUTO_INCREMENT, PRIMARY KEY): Unique identifier for each patient.
name (VARCHAR): Full name of the patient.
age (INT): Age of the patient.
gender (ENUM('Male', 'Female', 'Other')): Gender of the patient.
phone (VARCHAR): Phone number of the patient.
email (VARCHAR): Email address of the patient.
medical_history (TEXT): Medical history of the patient.
date_of_birth (DATE): Date of birth of the patient.
registration_date (DATE): Date when the patient was registered.
registration_datetime (DATETIME): Date and time when the patient was registered.
status (ENUM): Current status of the patient (e.g., 'Initial Consultation', 'Treatment in Progress').
b. Health Records
id (INT, AUTO_INCREMENT, PRIMARY KEY): Unique identifier for each health record.
patient_id (INT, FOREIGN KEY REFERENCES patients(id)): ID of the patient associated with this health record.
blood_pressure (VARCHAR): Blood pressure reading.
weight (DECIMAL): Weight of the patient.
bmi (DECIMAL): Body Mass Index of the patient.
cholesterol (DECIMAL): Cholesterol level of the patient.
prescription (TEXT): Prescriptions given to the patient.
treatment_progress (TEXT): Notes on the treatment progress.
record_date (DATE): Date of the health record.
c. Admins
id (INT, AUTO_INCREMENT, PRIMARY KEY): Unique identifier for each admin.
username (VARCHAR): Admin's username.
password (VARCHAR): Hashed password for the admin.
email (VARCHAR): Email address of the admin.
d. Patient Logins
id (INT, AUTO_INCREMENT, PRIMARY KEY): Unique identifier for each patient login.
patient_id (INT, FOREIGN KEY REFERENCES patients(id)): ID of the patient associated with this login.
username (VARCHAR): Username for patient login.
password (VARCHAR): Hashed password for patient login.
e. Invoices
id (INT, AUTO_INCREMENT, PRIMARY KEY): Unique identifier for each invoice.
patient_id (INT NOT NULL, FOREIGN KEY REFERENCES patients(id)): ID of the patient associated with this invoice.
service_name (VARCHAR(255) NOT NULL): Name of the service rendered.
service_description (TEXT): Description of the service.
cost (DECIMAL(10, 2) NOT NULL): Cost of the service.
tax_rate (DECIMAL(5, 2) DEFAULT 0): Tax rate applied to the service.
discount (DECIMAL(5, 2) DEFAULT 0): Discount applied to the service.
total_amount (DECIMAL(10, 2) NOT NULL): Total amount due after tax and discount.
invoice_date (DATE DEFAULT CURRENT_DATE): Date of the invoice.
notes (TEXT): Additional notes for the invoice.
f. Services
service_id (INT, AUTO_INCREMENT, PRIMARY KEY): Unique identifier for each service.
service_name (VARCHAR(255) NOT NULL): Name of the service.
service_price (DECIMAL(10, 2) NOT NULL): Price of the service.
service_description (TEXT): Description of the service.
created_at (TIMESTAMP DEFAULT CURRENT_TIMESTAMP): Timestamp when the service was created.
updated_at (TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP): Timestamp when the service was last updated.
g. Invoice Services
id (INT, AUTO_INCREMENT, PRIMARY KEY): Unique identifier for each entry in the invoice services table.
invoice_id (INT NOT NULL, FOREIGN KEY REFERENCES invoices(id)): ID of the associated invoice.
service_id (INT NOT NULL, FOREIGN KEY REFERENCES services(service_id)): ID of the associated service.
service_name (VARCHAR(255) NOT NULL): Name of the service rendered.
cost (DECIMAL(10, 2) NOT NULL): Cost of the service rendered.
h. Comments
id (INT, AUTO_INCREMENT, PRIMARY KEY): Unique identifier for each comment.
patient_id (INT NOT NULL, FOREIGN KEY REFERENCES patients(id)): ID of the patient associated with the comment.
sender (ENUM('patient', 'doctor', 'admin') NOT NULL): Sender of the comment, which can be 'patient', 'doctor', or 'admin'.
message (TEXT NOT NULL): The message or comment content.
timestamp (DATETIME DEFAULT CURRENT_TIMESTAMP): Date and time the comment was made.
parent_id (INT NULL DEFAULT NULL): ID of the parent comment (for threaded conversations), if applicable.
i. Doctor-Patient
id (INT, AUTO_INCREMENT, PRIMARY KEY): Unique identifier for each doctor-patient relationship.
doctor_id (INT NOT NULL, FOREIGN KEY REFERENCES doctors(id)): ID of the associated doctor.
patient_id (INT NOT NULL, FOREIGN KEY REFERENCES patients(id)): ID of the associated patient.
UNIQUE (doctor_id, patient_id): Ensures a unique doctor-patient pair.
SQL Update for Doctor-Patient Table
The SQL statement ALTER TABLE doctor_patient ADD CONSTRAINT fk_doctor FOREIGN KEY (doctor_id) REFERENCES doctors(id) ON DELETE CASCADE ON UPDATE CASCADE; ensures that any deletion or update of a doctor in the doctors table will automatically cascade to the doctor_patient table, maintaining referential integrity.
j. Employees
id (INT, AUTO_INCREMENT, PRIMARY KEY): Unique identifier for each employee.
name (VARCHAR(255) NOT NULL): Full name of the employee.
role (ENUM('admin', 'doctor', 'staff') NOT NULL): Role of the employee, which can be 'admin', 'doctor', or 'staff'.
email (VARCHAR(255) NOT NULL UNIQUE): Email address of the employee, ensuring it is unique.
phone (VARCHAR(20)): Phone number of the employee.
department (VARCHAR(100)): Department where the employee works.
date_of_joining (DATE): The date when the employee joined the organization.
status (ENUM('active', 'inactive') DEFAULT 'active'): Employment status, either 'active' or 'inactive', with 'active' as the default.
username (VARCHAR(100) NOT NULL UNIQUE): Username for employee login, ensuring it is unique.
password (VARCHAR(255) NOT NULL): Hashed password for the employee.
created_at (TIMESTAMP DEFAULT CURRENT_TIMESTAMP): Timestamp when the employee record was created.
updated_at (TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP): Timestamp when the employee record was last updated.
profile_picture (VARCHAR(255) DEFAULT 'default_profile.png'): Profile picture of the employee.
specialization (VARCHAR(255) DEFAULT NULL): Specialization of the employee.
k. Doctors
id (INT, AUTO_INCREMENT, PRIMARY KEY): Unique identifier for each doctor.
employee_id (INT NOT NULL, FOREIGN KEY REFERENCES employees(id)): ID of the associated employee record.
department (VARCHAR(100) DEFAULT NULL): Department where the doctor works.
date_of_joining (DATE DEFAULT NULL): The date when the doctor joined the organization.
status (ENUM('active', 'inactive') DEFAULT 'active'): Employment status of the doctor.
profile_picture (VARCHAR(255) DEFAULT 'default_profile.png'): Profile picture of the doctor.
l. Payments
id (INT AUTO_INCREMENT, PRIMARY KEY): Unique identifier for each payment.
patient_id (INT NOT NULL, FOREIGN KEY REFERENCES patients(id)): ID of the patient associated with this payment.
invoice_id (INT NOT NULL, FOREIGN KEY REFERENCES invoices(id)): ID of the invoice associated with this payment.
amount_paid (DECIMAL(10,2) NOT NULL): Amount paid by the patient.
payment_date (DATE NOT NULL): Date of the payment.
payment_method (VARCHAR(50)): Method of payment (e.g., cash, card, insurance).
notes (TEXT): Additional notes regarding the payment.

m. Salaries
id (INT AUTO_INCREMENT, PRIMARY KEY): Unique identifier for each salary record.
employee_id (INT NOT NULL, FOREIGN KEY REFERENCES employees(id)): ID of the employee receiving the salary.
amount (DECIMAL(10,2) NOT NULL): Amount of the salary paid.
payment_date (DATE NOT NULL): Date of the salary payment.
notes (TEXT): Additional notes regarding the salary.

SQL Updates for Doctors Table
The SQL statement ALTER TABLE doctors ADD COLUMN date_of_joining DATE DEFAULT NULL; adds a date_of_joining column to the doctors table, allowing the storage of the date when a doctor joined the organization.
The SQL statement ALTER TABLE doctors ADD COLUMN department VARCHAR(100) DEFAULT NULL; adds a department column to the doctors table, enabling the specification of the department where the doctor works.

) based on accontant/dasboard.php (<?php
session_start();
require_once '../db_connect.php';

// Disable error reporting in production
// ini_set('display_errors', 0);
// error_reporting(0);

// Enable error reporting during development (comment out in production)
ini_set('display_errors', 1);
error_reporting(E_ALL);

// Check if accountant is logged in
if (!isset($_SESSION['accountant_id'])) {
    // Not logged in, redirect to login page
    header("Location: login.php");
    exit();
}

// Accountant is logged in, proceed to fetch data
// Default date range: last 30 days
$start_date = isset($_GET['start_date']) ? $_GET['start_date'] : date('Y-m-d', strtotime('-30 days'));
$end_date = isset($_GET['end_date']) ? $_GET['end_date'] : date('Y-m-d');

try {
    // Prepare statements with date filters
    // Total number of invoices
    $stmt = $pdo->prepare("SELECT COUNT(*) AS total_invoices FROM invoices WHERE invoice_date BETWEEN ? AND ?");
    $stmt->execute([$start_date, $end_date]);
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    $total_invoices = $row['total_invoices'];

    // Total revenue from invoices
    $stmt = $pdo->prepare("SELECT SUM(total_amount) AS total_revenue FROM invoices WHERE invoice_date BETWEEN ? AND ?");
    $stmt->execute([$start_date, $end_date]);
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    $total_revenue = $row['total_revenue'] ?? 0;

    // Average revenue per invoice
    $average_revenue = $total_invoices > 0 ? $total_revenue / $total_invoices : 0;

    // Total salaries paid
    $stmt = $pdo->prepare("SELECT SUM(amount) AS total_salaries FROM salaries WHERE payment_date BETWEEN ? AND ?");
    $stmt->execute([$start_date, $end_date]);
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    $total_salaries = $row['total_salaries'] ?? 0;

    // Total expenses (assuming salaries are the expenses)
    $total_expenses = $total_salaries;

    // Profit (Revenue - Expenses)
    $profit = $total_revenue - $total_expenses;

    // Outstanding payments (unpaid invoices)
    $stmt = $pdo->prepare("SELECT SUM(total_amount) AS outstanding_payments FROM invoices WHERE invoice_date BETWEEN ? AND ? AND id NOT IN (SELECT DISTINCT invoice_id FROM payments)");
    $stmt->execute([$start_date, $end_date]);
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    $outstanding_payments = $row['outstanding_payments'] ?? 0;

    // Fetch data for charts
    // Revenue over time (grouped by date)
    $stmt = $pdo->prepare("SELECT invoice_date, SUM(total_amount) AS daily_revenue FROM invoices WHERE invoice_date BETWEEN ? AND ? GROUP BY invoice_date ORDER BY invoice_date ASC");
    $stmt->execute([$start_date, $end_date]);
    $revenue_data = $stmt->fetchAll(PDO::FETCH_ASSOC);

    // Expenses over time (grouped by date)
    $stmt = $pdo->prepare("SELECT payment_date, SUM(amount) AS daily_expenses FROM salaries WHERE payment_date BETWEEN ? AND ? GROUP BY payment_date ORDER BY payment_date ASC");
    $stmt->execute([$start_date, $end_date]);
    $expenses_data = $stmt->fetchAll(PDO::FETCH_ASSOC);

} catch (PDOException $e) {
    echo "Error: " . $e->getMessage();
    exit();
}

// Prepare data for charts
$dates = [];
$revenues = [];
$expenses = [];
$start = new DateTime($start_date);
$end = new DateTime($end_date);
$end->modify('+1 day');
$period = new DatePeriod($start, new DateInterval('P1D'), $end);

foreach ($period as $date) {
    $current_date = $date->format('Y-m-d');
    $dates[] = $current_date;
    $revenues[$current_date] = 0; // Initialize with 0
    $expenses[$current_date] = 0; // Initialize with 0
}

// Map revenue data
foreach ($revenue_data as $data) {
    $invoice_date = $data['invoice_date'];
    if (isset($revenues[$invoice_date])) {
        $revenues[$invoice_date] = $data['daily_revenue'];
    }
}

// Map expenses data
foreach ($expenses_data as $data) {
    $payment_date = $data['payment_date'];
    if (isset($expenses[$payment_date])) {
        $expenses[$payment_date] = $data['daily_expenses'];
    }
}

// Prepare data arrays for charts
$chart_dates = array_values($dates);
$chart_revenues = array_values($revenues);
$chart_expenses = array_values($expenses);

?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Accountant Dashboard</title>
    <!-- Meta tags for responsiveness -->
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Chart.js Library -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <!-- Custom Styles -->
    <style>
        /* Import Google Fonts */
        @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

        /* Root Variables */
        :root {
            --primary-color: #4F3F02;
            --secondary-color: #D1C287;
            --background-color: #F8F9FA;
            --card-background: #FFFFFF;
            --text-color: #333333;
            --success-color: #28a745;
            --danger-color: #dc3545;
            --info-color: #17a2b8;
            --font-family: 'Poppins', sans-serif;
        }

        /* Reset and Base Styles */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background-color: var(--background-color);
            font-family: var(--font-family);
            color: var(--text-color);
        }

        /* Header */
        .dashboard-header {
            background-color: var(--primary-color);
            color: #fff;
            padding: 30px;
            text-align: center;
            border-radius: 0 0 25px 25px;
            margin-bottom: 40px;
        }

        .dashboard-header h1 {
            font-weight: 700;
        }

        .dashboard-header p a {
            color: #fff;
            margin: 0 10px;
        }

        .dashboard-header p a:hover {
            text-decoration: underline;
        }

        /* Cards */
        .card {
            border: none;
            border-radius: 15px;
            box-shadow: 0 6px 10px rgba(0, 0, 0, 0.1);
            margin-bottom: 30px;
            background-color: var(--card-background);
        }

        .card .card-body {
            padding: 25px;
        }

        .card .card-title {
            color: var(--primary-color);
            font-weight: 600;
            margin-bottom: 15px;
        }

        .card .card-text {
            font-size: 2em;
            font-weight: 700;
        }

        /* Buttons */
        .btn-custom {
            background-color: var(--secondary-color);
            border-color: var(--secondary-color);
            color: var(--primary-color);
            font-weight: 600;
            width: 100%;
            padding: 15px;
            border-radius: 10px;
            transition: all 0.3s ease;
        }

        .btn-custom:hover {
            background-color: var(--primary-color);
            color: #fff;
            border-color: var(--secondary-color);
            transform: translateY(-3px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
        }

        /* Filters */
        .filters {
            background-color: var(--card-background);
            padding: 25px;
            border-radius: 15px;
            box-shadow: 0 6px 10px rgba(0, 0, 0, 0.1);
            margin-bottom: 40px;
        }

        /* Charts */
        .chart-container {
            position: relative;
            height: 400px;
        }

        /* Responsive Adjustments */
        @media (max-width: 768px) {
            .dashboard-header h1 {
                font-size: 24px;
            }

            .btn-custom {
                margin-bottom: 15px;
            }
        }

        @media (max-width: 576px) {
            .dashboard-header h1 {
                font-size: 20px;
            }

            .card .card-body {
                padding: 20px;
            }

            .card .card-text {
                font-size: 1.5em;
            }

            .filters {
                padding: 20px;
            }
        }
    </style>
</head>
<body>
    <div class="dashboard-header">
        <h1>Welcome, <?php echo htmlspecialchars($_SESSION['accountant_username']); ?></h1>
        <p>
            <a href="accountant_profile.php">Profile</a> | <a href="logout.php">Logout</a>
        </p>
    </div>

    <div class="container">

        <!-- Date Range Filters -->
        <div class="filters">
            <form method="GET" action="" class="row g-3">
                <div class="col-md-5">
                    <label for="start_date" class="form-label">Start Date:</label>
                    <input type="date" id="start_date" name="start_date" class="form-control" value="<?php echo htmlspecialchars($start_date); ?>" required>
                </div>
                <div class="col-md-5">
                    <label for="end_date" class="form-label">End Date:</label>
                    <input type="date" id="end_date" name="end_date" class="form-control" value="<?php echo htmlspecialchars($end_date); ?>" required>
                </div>
                <div class="col-md-2 d-flex align-items-end">
                    <button type="submit" class="btn btn-custom">Apply Filters</button>
                </div>
            </form>
        </div>

        <!-- Financial Metrics -->
        <div class="row">
            <!-- Total Invoices -->
            <div class="col-lg-3 col-md-6">
                <div class="card text-center">
                    <div class="card-body">
                        <h5 class="card-title">Total Invoices</h5>
                        <p class="card-text"><?php echo number_format($total_invoices); ?></p>
                    </div>
                </div>
            </div>
            <!-- Total Revenue -->
            <div class="col-lg-3 col-md-6">
                <div class="card text-center">
                    <div class="card-body">
                        <h5 class="card-title">Total Revenue</h5>
                        <p class="card-text">$<?php echo number_format($total_revenue, 2); ?></p>
                    </div>
                </div>
            </div>
            <!-- Total Expenses -->
            <div class="col-lg-3 col-md-6">
                <div class="card text-center">
                    <div class="card-body">
                        <h5 class="card-title">Total Expenses</h5>
                        <p class="card-text">$<?php echo number_format($total_expenses, 2); ?></p>
                    </div>
                </div>
            </div>
            <!-- Profit -->
            <div class="col-lg-3 col-md-6">
                <div class="card text-center">
                    <div class="card-body">
                        <h5 class="card-title">Profit</h5>
                        <p class="card-text" style="color: <?php echo $profit >= 0 ? 'var(--success-color)' : 'var(--danger-color)'; ?>">
                            $<?php echo number_format($profit, 2); ?>
                        </p>
                    </div>
                </div>
            </div>
            <!-- Average Revenue per Invoice -->
            <div class="col-lg-6 col-md-6">
                <div class="card text-center">
                    <div class="card-body">
                        <h5 class="card-title">Avg. Revenue per Invoice</h5>
                        <p class="card-text">$<?php echo number_format($average_revenue, 2); ?></p>
                    </div>
                </div>
            </div>
            <!-- Outstanding Payments -->
            <div class="col-lg-6 col-md-6">
                <div class="card text-center">
                    <div class="card-body">
                        <h5 class="card-title">Outstanding Payments</h5>
                        <p class="card-text" style="color: var(--danger-color);">
                            $<?php echo number_format($outstanding_payments, 2); ?>
                        </p>
                    </div>
                </div>
            </div>
        </div>

        <!-- Charts -->
        <div class="row">
            <!-- Revenue vs. Expenses Chart -->
            <div class="col-md-12">
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">Revenue vs. Expenses Over Time</h5>
                        <div class="chart-container">
                            <canvas id="revenueExpensesChart"></canvas>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Actions -->
        <h3 class="mt-5 mb-4" style="color: var(--primary-color); font-weight: 700;">Actions</h3>
        <div class="row">
            <div class="col-md-3 mb-3">
                <a href="manage_invoices.php" class="btn btn-custom">Manage Invoices</a>
            </div>
            <div class="col-md-3 mb-3">
                <a href="manage_payments.php" class="btn btn-custom">Manage Payments</a>
            </div>
            <div class="col-md-3 mb-3">
                <a href="manage_salaries.php" class="btn btn-custom">Manage Salaries</a>
            </div>
            <div class="col-md-3 mb-3">
                <a href="generate_report.php" class="btn btn-custom">Generate Reports</a>
            </div>
        </div>

    </div>

    <!-- Bootstrap JS and dependencies (optional but recommended) -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <!-- Popper.js (for Bootstrap 4, can omit for Bootstrap 5) -->
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.3/dist/umd/popper.min.js"></script>
    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>

    <!-- Chart.js Script -->
    <script>
        (function() {
            const ctx = document.getElementById('revenueExpensesChart').getContext('2d');
            const revenueExpensesChart = new Chart(ctx, {
                type: 'line',
                data: {
                    labels: <?php echo json_encode($chart_dates); ?>,
                    datasets: [
                        {
                            label: 'Revenue',
                            data: <?php echo json_encode(array_values($chart_revenues)); ?>,
                            borderColor: 'rgba(40, 167, 69, 1)',
                            backgroundColor: 'rgba(40, 167, 69, 0.2)',
                            fill: true,
                            tension: 0.3,
                            pointRadius: 0,
                        },
                        {
                            label: 'Expenses',
                            data: <?php echo json_encode(array_values($chart_expenses)); ?>,
                            borderColor: 'rgba(220, 53, 69, 1)',
                            backgroundColor: 'rgba(220, 53, 69, 0.2)',
                            fill: true,
                            tension: 0.3,
                            pointRadius: 0,
                        }
                    ]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    interaction: {
                        mode: 'index',
                        intersect: false
                    },
                    plugins: {
                        legend: {
                            labels: {
                                font: {
                                    family: 'Poppins',
                                    size: 14,
                                    weight: '600'
                                }
                            }
                        },
                        tooltip: {
                            enabled: true,
                            callbacks: {
                                label: function(context) {
                                    let label = context.dataset.label || '';
                                    if (label) {
                                        label += ': ';
                                    }
                                    if (context.parsed.y !== null) {
                                        label += '$' + context.parsed.y.toLocaleString();
                                    }
                                    return label;
                                }
                            }
                        }
                    },
                    scales: {
                        x: {
                            title: {
                                display: true,
                                text: 'Date',
                                font: {
                                    family: 'Poppins',
                                    size: 14,
                                    weight: '600'
                                }
                            },
                            ticks: {
                                autoSkip: true,
                                maxTicksLimit: 20,
                                font: {
                                    family: 'Poppins',
                                }
                            },
                            grid: {
                                display: false
                            }
                        },
                        y: {
                            title: {
                                display: true,
                                text: 'Amount ($)',
                                font: {
                                    family: 'Poppins',
                                    size: 14,
                                    weight: '600'
                                }
                            },
                            ticks: {
                                beginAtZero: true,
                                font: {
                                    family: 'Poppins',
                                }
                            },
                            grid: {
                                color: '#e9ecef'
                            }
                        }
                    }
                }
            });
        })();
    </script>
</body>
</html>) update this manage_invoices.php (<?php
session_start();
require_once '../db_connect.php';

// Check if accountant is logged in
if (!isset($_SESSION['accountant_id'])) {
    // Not logged in, redirect to login page
    header("Location: login.php");
    exit();
}

// Fetch invoices
$sql = "SELECT invoices.*, patients.name AS patient_name FROM invoices JOIN patients ON invoices.patient_id = patients.id";
$result = $conn->query($sql);

?>
<!DOCTYPE html>
<html>
<head>
    <title>Manage Invoices</title>
</head>
<body>
    <h2>Manage Invoices</h2>
    <p><a href="dashboard.php">Back to Dashboard</a> | <a href="logout.php">Logout</a></p>
    <p><a href="create_invoice.php">Create New Invoice</a></p>
    <table border="1">
        <tr>
            <th>Invoice ID</th>
            <th>Patient Name</th>
            <th>Total Amount</th>
            <th>Invoice Date</th>
            <th>Actions</th>
        </tr>
        <?php
        if ($result->num_rows > 0) {
            while ($invoice = $result->fetch_assoc()) {
                echo "<tr>";
                echo "<td>{$invoice['id']}</td>";
                echo "<td>{$invoice['patient_name']}</td>";
                echo "<td>\${$invoice['total_amount']}</td>";
                echo "<td>{$invoice['invoice_date']}</td>";
                echo "<td>";
                echo "<a href='view_invoice.php?id={$invoice['id']}'>View</a> | ";
                echo "<a href='edit_invoice.php?id={$invoice['id']}'>Edit</a> | ";
                echo "<a href='delete_invoice.php?id={$invoice['id']}' onclick='return confirm(\"Are you sure you want to delete this invoice?\");'>Delete</a>";
                echo "</td>";
                echo "</tr>";
            }
        } else {
            echo "<tr><td colspan='5'>No invoices found.</td></tr>";
        }
        ?>
    </table>
</body>
</html>) and type full codes manage_invoices.php