<?php
session_start();
include 'layouts/dbconn.php';
include 'layouts/session.php';

if (!isset($_SESSION['user_id'])) {
    header('Location: login.php');
    exit();
}
?>
<?php include 'layouts/main.php'; ?>

<head>
    <?php includeFileWithVariables('layouts/title-meta.php', array('title' => 'Custom Reports')); ?>
    <?php include 'layouts/head-css.php'; ?>
</head>

<body>
    <div id="layout-wrapper">
        <?php include 'layouts/menu.php'; ?>
        <div class="main-content">
            <div class="page-content">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-12">
                            <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                                <h4 class="mb-sm-0">Custom Reports</h4>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <!-- Links to various specific reports -->
                        <div class="col-md-4">
                            <div class="card">
                                <div class="card-body text-center">
                                    <div class="avatar-md mx-auto mb-3">
                                        <div class="avatar-title bg-soft-primary text-primary rounded-circle display-6">
                                            <i class="ri-file-chart-line"></i></div>
                                    </div>
                                    <h5 class="card-title">Financial Reports</h5>
                                    <p class="card-text text-muted">Monthly revenue, payment analysis, and tax reports.
                                    </p>
                                    <a href="monthly_reports.php" class="btn btn-primary btn-sm">View Reports</a>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="card">
                                <div class="card-body text-center">
                                    <div class="avatar-md mx-auto mb-3">
                                        <div class="avatar-title bg-soft-success text-success rounded-circle display-6">
                                            <i class="ri-user-star-line"></i></div>
                                    </div>
                                    <h5 class="card-title">Staff Performance</h5>
                                    <p class="card-text text-muted">Doctor performance, commissions, and efficiency
                                        stats.</p>
                                    <a href="doctor_performance.php" class="btn btn-success btn-sm">View Reports</a>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="card">
                                <div class="card-body text-center">
                                    <div class="avatar-md mx-auto mb-3">
                                        <div class="avatar-title bg-soft-warning text-warning rounded-circle display-6">
                                            <i class="ri-group-line"></i></div>
                                    </div>
                                    <h5 class="card-title">Patient Insights</h5>
                                    <p class="card-text text-muted">Demographics, visit trends, and registration stats.
                                    </p>
                                    <a href="patient_reports.php" class="btn btn-warning btn-sm">View Reports</a>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row mt-4">
                        <div class="col-12">
                            <div class="card">
                                <div class="card-header">
                                    <h5 class="card-title mb-0">Ad-hoc Export</h5>
                                </div>
                                <div class="card-body">
                                    <p>Select a data type to export to Excel/CSV.</p>
                                    <div class="d-flex gap-2">
                                        <a href="export_data.php?type=patients" class="btn btn-outline-primary">Export
                                            Patients</a>
                                        <a href="export_data.php?type=invoices" class="btn btn-outline-secondary">Export
                                            Invoices</a>
                                        <a href="export_data.php?type=payments" class="btn btn-outline-success">Export
                                            Payments</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <?php include 'layouts/footer.php'; ?>
        </div>
    </div>
    <?php include 'layouts/vendor-scripts.php'; ?>
</body>

</html>