<?php
include 'includes/config.php';
session_start();

if (!$_SESSION['email']) {
    header('location:login.php');
    exit;
}


?>

<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>List Banks</title>
    <!-- Favicon -->
    <link rel="shortcut icon" href="images/favicon.ico" />
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!-- Typography CSS -->
    <link rel="stylesheet" href="css/typography.css">
    <!-- Style CSS -->
    <link rel="stylesheet" href="css/style.css">
    <!-- Responsive CSS -->
    <link rel="stylesheet" href="css/responsive.css">
    <script type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script>
    <script nomodule src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.23/jspdf.plugin.autotable.min.js"></script>
    <style>
        ion-icon {
            font-size: 20px;
            margin-bottom: -5px;
        }

        .search-container {
            margin-bottom: 20px;
            text-align: center;
        }

        .search-input {
            width: 50%;
            padding: 10px;
            font-size: 16px;
            border: 2px solid #ddd;
            border-radius: 4px;
            outline: none;
            transition: all 0.3s ease;
        }

        .search-input:focus {
            border-color: #007bff;
        }

        .amount-in {
            color: green;
        }

        .amount-out {
            color: red;
        }

        table {
            margin-top: 20px;
        }

        .filter-form {
            padding: 20px;
            background-color: #f9f9f9;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            max-width: 500px;
            margin: auto;
        }

        .form-group {
            margin-bottom: 15px;
        }

        .form-label {
            font-weight: bold;
            display: block;
        }

        .form-input {
            width: 100%;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
            font-size: 16px;
        }

        .form-actions {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .btn-submit,
        .btn-clear {
            padding: 10px 15px;
            font-size: 16px;
            border-radius: 4px;
            text-decoration: none;
            text-align: center;
        }

        .btn-submit {
            background-color: #007bff;
            color: white;
            border: none;
        }

        .btn-submit:hover {
            background-color: #0056b3;
        }

        .btn-clear {
            background-color: #6c757d;
            color: white;
        }

        .btn-clear:hover {
            background-color: #5a6268;
        }
    </style>
</head>

<body>
    <!-- loader Start -->
    <div id="loading">
        <div id="loading-center">
        </div>
    </div>
    <!-- loader END -->
    <!-- Wrapper Start -->
    <div class="wrapper">
        <!-- Sidebar  -->
        <?php
        include 'includes/sidebar.php';
        ?>
        <!-- TOP Nav Bar -->
        <?php include 'includes/header.php'; ?>
        <!-- TOP Nav Bar END -->
        <!-- Page Content  -->
        <div id="content-page" class="content-page">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="iq-card">
                            <div class="iq-card-header d-flex justify-content-between row">
                                <div class="iq-header-title col-lg-6">
                                    <h4 class="card-title"><a href="list_expense_category.php">Bank & Cash Accounts</a> > Supplier Ledger
                                    </h4>
                                </div>
                                <!-- <div class="col-lg-6">
                                    <button type="button" class="btn btn-primary" data-toggle="modal"
                                        data-target="#exampleModalCenter" style="float:inline-end;">
                                        <ion-icon name="add-outline" style="font-size:20px; margin-bottom:-4px;color:white">
                                        </ion-icon>New Income Add
                                    </button>
                                </div> -->
                                <!-- add variation -->

                                <!-- add variation end -->
                            </div>

                            <!----------Updated model---------->
                            <!-- Modal for Editing Bank Details -->


                            <!-----End Update model---------->
                            <!-- search bar -->
                            <!-- <form action="">
                                <div class="row mt-5" style="width:95%;margin:0 auto;">
                                    <div class="col-lg-5">
                                        <input type="search" name="" placeholder="Search" class="form-control" id="">
                                    </div>
                          
                                    <div class="col-lg-2">
                                        <button style="width:100%;" class="btn btn-primary p-2">Search</button>
                                    </div>
                                </div>
                            </form> -->
                            <!-- searchbar end -->
                            <!-- buttons for export -->
                            <div class="row mt-5">
                                <div class="col-lg-2"></div>
                                <!-- <div class="col-lg-8">
                                    <button class="btn btn-primary">
                                        <ion-icon name="document-outline"></ion-icon>Export to CSV
                                    </button>
                                    <button class="btn btn-info">
                                        <ion-icon name="document-outline"></ion-icon>Export to Excel
                                    </button>
                                    <button class="btn btn-warning">
                                        <ion-icon name="print-outline"></ion-icon>Print
                                    </button>
                                    <button class="btn btn-danger">
                                        <ion-icon name="stop-outline"></ion-icon>Column Visibility
                                    </button>
                                    <button class="btn btn-dark">
                                        <ion-icon name="document-outline"></ion-icon>Export to PDF
                                    </button>
                                </div> -->
                            </div>
                            <!-- buttons for export end -->
                            <?php
                            $supplier_id = isset($_GET['supplier_id']) ? $_GET['supplier_id'] : '';
                            $start_date = isset($_GET['start_date']) ? $_GET['start_date'] : '';
                            $end_date = isset($_GET['end_date']) ? $_GET['end_date'] : '';

                            $supplier_name = '';
                            $opening_balance = 0;
                            $opening_balance_date = '';

                            if ($supplier_id) {
                                $stmt0 = $conn->prepare("SELECT name, opening_balance, created_at FROM contacts WHERE id = :supplier_id");
                                $stmt0->execute(['supplier_id' => $supplier_id]);
                                $supplier = $stmt0->fetch();
                                $supplier_name = $supplier['name'] ?? 'Unknown Supplier';
                                $opening_balance = floatval($supplier['opening_balance'] ?? 0);
                                $opening_balance_date = isset($supplier['created_at']) ? date('Y-m-d', strtotime($supplier['created_at'])) : date('Y-m-d');

                                $date_condition_purchase = '';
                                $date_condition_bank = '';
                                $date_condition_supplier_purchase_manual = '';
                                $params = ['supplier_id' => $supplier_id];

                                if (!empty($start_date) && !empty($end_date)) {
                                    $date_condition_purchase = " AND DATE(purchase_date) BETWEEN :start_date AND :end_date";
                                    $date_condition_bank = " AND DATE(date) BETWEEN :start_date AND :end_date";
                                    $date_condition_supplier_purchase_manual = " AND DATE(purchase_date) BETWEEN :start_date AND :end_date";
                                    $params['start_date'] = $start_date;
                                    $params['end_date'] = $end_date;
                                }

                                // Query for purchase lines
                             $stmt1 = $conn->prepare("
    SELECT 
        pl.ref_no, 
        GROUP_CONCAT(DISTINCT p.name SEPARATOR ', ') AS product_names,
        GROUP_CONCAT(DISTINCT pl.drum SEPARATOR ', ') AS drums,
        MAX(pl.note) AS note,  
        (SUM(pl.quantity * pl.purchase_price) + MAX(pl.shipping_charges)) AS total_debit,
        MAX(pl.shipping_charges) AS shipping_charges,
        MAX(pl.purchase_date) AS purchase_date
    FROM purchase_lines pl
    LEFT JOIN products p ON pl.product_id = p.id
    WHERE pl.supplier_id = :supplier_id 
          AND pl.ref_no IS NOT NULL 
          AND pl.ref_no != '' 
          AND pl.ref_no != '0' 
          $date_condition_purchase
    GROUP BY pl.ref_no
");

                                $stmt1->execute($params);
                                $purchases = $stmt1->fetchAll();

                                // Query for bank debit amounts
                                $stmt2 = $conn->prepare("
        SELECT bda.id, bda.ref_no, bda.amount, bda.note, bda.date, banks.bank_name
        FROM bank_debit_amount AS bda
        LEFT JOIN banks ON bda.bank_id = banks.id
        WHERE bda.supplier_id = :supplier_id $date_condition_bank
    ");
                                $stmt2->execute($params);
                                $debits = $stmt2->fetchAll();

                                // Query for supplier manual purchases
                                $stmt3 = $conn->prepare("
        SELECT spm.id, spm.amount, spm.note, spm.purchase_date
        FROM supplier_purchase_manual spm
        WHERE spm.supplier_id = :supplier_id $date_condition_supplier_purchase_manual
    ");
                                $stmt3->execute($params);
                                $supplier_purchase_manuals = $stmt3->fetchAll();

                                $balance = 0;
                                $rows = [];
                                $all_transactions = [];

                                // Add opening balance if available
                                if ($opening_balance > 0) {
                                    $all_transactions[] = [
                                        'id' => null,
                                        'source' => 'opening_balance',
                                        'date' => $opening_balance_date,
                                        'particular' => 'Opening Balance',
                                        'debit' => $opening_balance,
                                        'credit' => 0,
                                    ];
                                }

                                // Add purchases, debits, and manual purchases
                              foreach ($purchases as $purchase) {
    $all_transactions[] = [
        'id' => null,
        'source' => 'purchase',
        'date' => $purchase['purchase_date'],
        'particular' => "Purchase / " . $purchase['ref_no'] . " - " . $purchase['product_names'] . " | Note: " . $purchase['note'],        'debit' => $purchase['total_debit'],
        'credit' => 0,
        'note' => $purchase['note'], // This will be shown only once per ref_no
    ];
}


                                foreach ($debits as $debit) {
                                    $all_transactions[] = [
                                        'id' => $debit['id'],
                                        'source' => 'bank_debit_amount',
                                        'date' => $debit['date'],
                                        'particular' => $debit['note'] . " (Bank: " . $debit['bank_name'] . ")",
                                        'debit' => 0,
                                        'credit' => $debit['amount'],
                                    ];
                                }

                                foreach ($supplier_purchase_manuals as $manual_purchase) {
                                    $all_transactions[] = [
                                        'id' => $manual_purchase['id'],
                                        'source' => 'supplier_purchase_manual',
                                        'date' => $manual_purchase['purchase_date'],
                                        'particular' => "Supplier Purchase / " . $manual_purchase['note'],
                                        'debit' => $manual_purchase['amount'],
                                        'credit' => 0,
                                    ];
                                }

                                // Sort transactions by full datetime (date + time)
                                usort($all_transactions, function ($a, $b) {
                                    $a_time = strtotime($a['date']);
                                    $b_time = strtotime($b['date']);
                                    return $a_time - $b_time;
                                });

                                // Now, correctly calculate balance
                                foreach ($all_transactions as $transaction) {
                                    // Increment debit, subtract credit from balance
                                    $balance += $transaction['debit'];
                                    $balance -= $transaction['credit'];

                                    $rows[] = [
                                        'id' => $transaction['id'],
                                        'source' => $transaction['source'],
                                        'date' => $transaction['date'],
                                        'particular' => $transaction['particular'],
                                        'debit' => number_format($transaction['debit'], 2),
                                        'credit' => number_format($transaction['credit'], 2),
                                        'balance' => number_format($balance, 2),
                                    ];
                                }

                                $total_debit = 0;
                                $total_credit = 0;

                                foreach ($rows as $row) {
                                    $total_debit += floatval(str_replace(',', '', $row['debit']));
                                    $total_credit += floatval(str_replace(',', '', $row['credit']));
                                }
                            }
                            ?>


                            <div class="iq-card-body" style="overflow:auto;">
                                <form action="supplier_ledger_detail.php" method="get" class="filter-form">
                                    <div class="form-group">
                                        <label for="start_date">Start Date:</label>
                                        <input type="date" name="start_date" value="<?php echo htmlspecialchars($start_date); ?>" class="form-input">
                                    </div>
                                    <div class="form-group">
                                        <label for="end_date">End Date:</label>
                                        <input type="date" name="end_date" value="<?php echo htmlspecialchars($end_date); ?>" class="form-input">
                                    </div>
                                    <input type="hidden" name="supplier_id" value="<?php echo htmlspecialchars($supplier_id); ?>">
                                    <div class="form-actions">
                                        <button type="submit" class="btn btn-primary">Filter</button>
                                        <a href="supplier_ledger_detail.php?supplier_id=<?php echo htmlspecialchars($supplier_id); ?>" class="btn btn-secondary">Clear Filter</a>
                                    </div>
                                </form>
                                <h2>Supplier Name: <?php echo htmlspecialchars($supplier_name); ?></h2>
                                <!-- <p><strong>Supplier ID:</strong> <?php echo htmlspecialchars($supplier_id); ?></p> -->

                                <button class="btn-success" id="download-pdf" style="margin-top: 20px;">Download PDF</button>

                                <table class="table table-hover table-bordered">
                                    <thead>
                                        <th>Total Debit</th>
                                        <th>Total Credit</th>
                                        <th>Total Balance</th>
                                        <tr>
                                            <td><strong><span style="color: green;"><?= number_format($total_debit, 2) ?></span></strong></td>
                                            <td><strong><span style="color: red;"><?= number_format($total_credit, 2) ?></span></strong></td>
                                            <td><strong><?= number_format($balance, 2) ?></strong></td>
                                        </tr>
                                    </thead>
                                </table>
                                <table class="table table-hover table-bordered" id="ledgerTable">
                                    <thead>
                                        <tr>
                                            <th>Date</th>
                                            <th>Particular</th>
                                            <th>Debit</th>
                                            <th>Credit</th>
                                            <th>Balance</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php if (!empty($rows)): ?>
                                            <?php foreach ($rows as $row): ?>
                                                <tr>
                                                    <td><?= htmlspecialchars(date('d-m-Y', strtotime($row['date']))) ?></td>
                                                    <td><?= htmlspecialchars($row['particular']) ?></td>
                                                    <td>
                                                        <span style="color: green;">
                                                            <?= htmlspecialchars($row['debit']) ?>
                                                        </span>
                                                        <?php if (($row['debit'] != '0.00') && ($row['source'] === 'bank_debit_amount' || $row['source'] === 'supplier_purchase_manual')): ?>
                                                            <span class="action-dots" style="cursor: pointer;" onclick="toggleDropdown(event, 'dropdown-<?= $row['id'] ?>')">...</span>
                                                            <div id="dropdown-<?= $row['id'] ?>" class="dropdown-menu" style="display: none;">
                                                                <a class="dropdown-item" href="#" onclick="editAmount('<?= $row['id'] ?>', '<?= $row['source'] ?>', 'debit', '<?= $row['debit'] ?>')">Update</a>
                                                                <a class="dropdown-item" href="#" onclick="deleteTransaction('<?= $row['id'] ?>', '<?= $row['source'] ?>')">Delete</a>
                                                            </div>
                                                        <?php endif; ?>
                                                    </td>
                                                    <td>
                                                        <span style="color: red;">
                                                            <?= htmlspecialchars($row['credit']) ?>
                                                        </span>
                                                        <?php if (($row['credit'] != '0.00') && ($row['source'] === 'bank_debit_amount' || $row['source'] === 'supplier_purchase_manual')): ?>
                                                            <span class="action-dots" style="cursor: pointer;" onclick="toggleDropdown(event, 'dropdown-<?= $row['id'] ?>')">...</span>
                                                            <div id="dropdown-<?= $row['id'] ?>" class="dropdown-menu" style="display: none;">
                                                                <a class="dropdown-item" href="#" onclick="editAmount('<?= $row['id'] ?>', '<?= $row['source'] ?>', 'credit', '<?= $row['credit'] ?>')">Update</a>
                                                                <a class="dropdown-item" href="#" onclick="deleteTransaction('<?= $row['id'] ?>', '<?= $row['source'] ?>')">Delete</a>
                                                            </div>
                                                        <?php endif; ?>
                                                    </td>
                                                    <td><?= htmlspecialchars($row['balance']) ?></td>
                                                </tr>
                                            <?php endforeach; ?>
                                        <?php else: ?>
                                            <tr>
                                                <td colspan="6" class="text-center">No records found.</td>
                                            </tr>
                                        <?php endif; ?>
                                    </tbody>
                                    <tfoot>
                                        <tr>
                                            <td colspan="2" class="text-right"><strong>Totals:</strong></td>
                                            <td><strong><span style="color: green;"><?= number_format($total_debit, 2) ?></span></strong></td>
                                            <td><strong><span style="color: red;"><?= number_format($total_credit, 2) ?></span></strong></td>
                                            <td><strong><?= number_format($balance, 2) ?></strong></td>
                                        </tr>
                                    </tfoot>
                                </table>

                                <script>
                                    function toggleDropdown(event, dropdownId) {
                                        event.stopPropagation();

                                        var dropdown = document.getElementById(dropdownId);

                                        var allDropdowns = document.querySelectorAll('.dropdown-menu');
                                        allDropdowns.forEach(function(dropdownMenu) {
                                            if (dropdownMenu !== dropdown) {
                                                dropdownMenu.style.display = 'none';
                                            }
                                        });

                                        dropdown.style.display = dropdown.style.display === 'block' ? 'none' : 'block';
                                    }

                                    function editAmount(id, source, type, currentAmount) {
                                        const newAmount = prompt(`Enter new ${type} amount:`, currentAmount);
                                        if (newAmount !== null && newAmount !== currentAmount) {
                                            fetch('supplier_update_transaction.php', {
                                                    method: 'POST',
                                                    headers: {
                                                        'Content-Type': 'application/json'
                                                    },
                                                    body: JSON.stringify({
                                                        id,
                                                        source,
                                                        type,
                                                        amount: newAmount
                                                    })
                                                })
                                                .then(response => response.json())
                                                .then(data => {
                                                    if (data.success) {
                                                        alert('Transaction updated successfully!');
                                                        location.reload();
                                                    } else {
                                                        alert('Error updating transaction: ' + data.message);
                                                    }
                                                })
                                                .catch(error => {
                                                    console.error('Error:', error);
                                                    alert('An unexpected error occurred.');
                                                });
                                        }
                                    }

                                    function deleteTransaction(id, source) {
                                        if (confirm('Are you sure you want to delete this transaction?')) {
                                            fetch('supplier_delete_transaction.php', {
                                                    method: 'POST',
                                                    headers: {
                                                        'Content-Type': 'application/json'
                                                    },
                                                    body: JSON.stringify({
                                                        id,
                                                        source
                                                    })
                                                })
                                                .then(response => response.json())
                                                .then(data => {
                                                    if (data.success) {
                                                        alert('Transaction deleted successfully!');
                                                        location.reload();
                                                    } else {
                                                        alert('Error deleting transaction: ' + data.message);
                                                    }
                                                })
                                                .catch(error => {
                                                    console.error('Error:', error);
                                                    alert('An unexpected error occurred.');
                                                });
                                        }
                                    }

                                    document.addEventListener('click', function(event) {
                                        var dropdowns = document.querySelectorAll('.dropdown-menu');
                                        dropdowns.forEach(function(dropdown) {
                                            if (!dropdown.contains(event.target) && !event.target.matches('.action-dots')) {
                                                dropdown.style.display = 'none';
                                            }
                                        });
                                    });
                                </script>


                                <style>
                                    td {
                                        position: relative;
                                    }

                                    .dropdown-menu {
                                        position: absolute;
                                        top: 100%;
                                        left: 0;
                                        background-color: #fff;
                                        border: 1px solid #ccc;
                                        padding: 5px;
                                        display: none;
                                        z-index: 1000;
                                        box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2);
                                    }

                                    .dropdown-item {
                                        padding: 8px 12px;
                                        cursor: pointer;
                                        display: block;
                                    }

                                    .dropdown-item:hover {
                                        background-color: #f1f1f1;
                                    }
                                </style>

                            </div>


                            <a href="list_supplier_ledger.php" class="btn btn-secondary">Back to Transactions</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    </div>
    </div>
    </div>
    <script>
     document.getElementById('download-pdf').addEventListener('click', function() {
    const { jsPDF } = window.jspdf;
    const doc = new jsPDF();

    const tableClone = document.getElementById('ledgerTable').cloneNode(true);

    tableClone.querySelectorAll('.action-dots, .dropdown-menu').forEach(el => el.remove());

    const tempDiv = document.createElement('div');
    tempDiv.appendChild(tableClone);

    doc.autoTable({
        html: tempDiv.querySelector('table'),
        startY: 20,
        margin: { horizontal: 10 },
        tableWidth: 'auto',
        theme: 'grid',
        headStyles: { fillColor: [22, 160, 133] },
        styles: { cellPadding: 5, fontSize: 10 }
    });

    const finalY = doc.lastAutoTable.finalY || 20;
    if (doc.internal.pageSize.height - finalY < 30) {
        doc.addPage();
    }

    doc.autoTable({
        body: [
            [
                'Totals:', '',
                '<?= number_format($total_debit, 2) ?>',
                '<?= number_format($total_credit, 2) ?>',
                '<?= number_format($balance, 2) ?>'
            ]
        ],
        startY: doc.internal.pageSize.height - 30, // Position at the bottom of the last page
        theme: 'grid',
        styles: { fontSize: 10, cellPadding: 5 }
    });

    doc.save('<?= htmlspecialchars($supplier_name) ?> Ledger.pdf');
});

    </script>


    <script>
        function filterTable() {
            var input = document.getElementById("searchInput");
            var filter = input.value.toLowerCase();

            // Get the table and rows
            var table = document.getElementById("bankTable");
            var rows = table.getElementsByTagName("tr");

            for (var i = 1; i < rows.length; i++) {
                var cells = rows[i].getElementsByTagName("td");
                var matchFound = false;

                for (var j = 0; j < cells.length; j++) {
                    var cell = cells[j];
                    if (cell) {
                        if (cell.textContent.toLowerCase().indexOf(filter) > -1) {
                            matchFound = true;
                            break;
                        }
                    }
                }

                if (matchFound) {
                    rows[i].style.display = "";
                } else {
                    rows[i].style.display = "none";
                }
            }
        }
    </script>

    <!-- Wrapper END -->
    <!-- Footer -->
    <?php include 'includes/footer.php'; ?>
    <nav class="iq-float-menu">
        <input type="checkbox" href="#" class="iq-float-menu-open" name="menu-open" id="menu-open" />
        <label class="iq-float-menu-open-button" for="menu-open">
            <span class="lines line-1"></span>
            <span class="lines line-2"></span>
            <span class="lines line-3"></span>
        </label>
        <button class="iq-float-menu-item bg-info" data-toggle="tooltip" data-placement="top" title="Direction Mode"
            data-mode="rtl"><i class="ri-text-direction-r"></i></button>
        <button class="iq-float-menu-item bg-danger" data-toggle="tooltip" data-placement="top" title="Color Mode"
            id="dark-mode" data-active="true"><i class="ri-sun-line"></i></button>
        <button class="iq-float-menu-item bg-warning" data-toggle="tooltip" data-placement="top" title="Comming Soon"><i
                class="ri-palette-line"></i></button>
    </nav>
    <!-- Footer END -->
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="js/jquery.min.js"></script>
    <!-- Rtl and Darkmode -->
    <script src="js/rtl.js"></script>
    <script src="js/customizer.js"></script>
    <script src="js/popper.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <!-- Appear JavaScript -->
    <script src="js/jquery.appear.js"></script>
    <!-- Countdown JavaScript -->
    <script src="js/countdown.min.js"></script>
    <!-- Counterup JavaScript -->
    <script src="js/waypoints.min.js"></script>
    <script src="js/jquery.counterup.min.js"></script>
    <!-- Wow JavaScript -->
    <script src="js/wow.min.js"></script>
    <!-- Apexcharts JavaScript -->
    <script src="js/apexcharts.js"></script>
    <!-- Slick JavaScript -->
    <script src="js/slick.min.js"></script>
    <!-- Select2 JavaScript -->
    <script src="js/select2.min.js"></script>
    <!-- Owl Carousel JavaScript -->
    <script src="js/owl.carousel.min.js"></script>
    <!-- Magnific Popup JavaScript -->
    <script src="js/jquery.magnific-popup.min.js"></script>
    <!-- Smooth Scrollbar JavaScript -->
    <script src="js/smooth-scrollbar.js"></script>
    <!-- lottie JavaScript -->
    <script src="js/lottie.js"></script>
    <!-- Chart Custom JavaScript -->
    <script src="js/chart-custom.js"></script>
    <!-- Custom JavaScript -->
    <script src="js/custom.js"></script>
</body>

</html>