            <?php include('modal.php'); ?>
            <footer>
                <div class="footer clearfix mb-0 text-muted">
                    <div class="float-start">
                        <p><?php echo date('Y'); ?> &copy; Bactriz CRM</p>
                    </div>
                    <div class="float-end">
                        <p>Crafted with <span class='text-danger'><i data-feather="heart"></i></span> by <a href="">Bactriz</a></p>
                    </div>
                </div>
            </footer>
        </div>
    </div>
    <script src="assets/vendors/jquery/jquery.min.js"></script>
    <script src="assets/vendors/sweetalert/sweetalert.js"></script>
    <script src="assets/js/feather-icons/feather.min.js"></script>
    <script src="assets/vendors/perfect-scrollbar/perfect-scrollbar.min.js"></script>
    <script src="assets/js/app.js"></script>
    
    <script src="assets/vendors/chartjs/chart.umd.min.js"></script>
    <script src="assets/vendors/apexcharts/apexcharts.js"></script>
    <!-- <script src="assets/vendors/select2/select2.min.js"></script> -->
    <script src="assets/js/ajax.js"></script>

    <script src="assets/js/main.js"></script>    
    <script src="assets/vendors/simple-datatables/simple-datatables.js"></script>
    <script type="text/plain" id="chart-data" data-chart='<?php echo htmlspecialchars($chart_data_json, ENT_QUOTES, 'UTF-8'); ?>'></script>
    <!-- <script type="text/plain" id="trips-data" data-chart='<?php echo htmlspecialchars($json_data, ENT_QUOTES, 'UTF-8'); ?>'></script>
    <script type="text/plain" id="main-data" data-chart='<?php echo htmlspecialchars($main_data, ENT_QUOTES, 'UTF-8'); ?>'></script> -->
    <script type="text/plain" id="trip_data" data-chart='<?php echo htmlspecialchars($trip_totals, ENT_QUOTES, 'UTF-8'); ?>'></script>
    <script src="assets/js/vendors.js"></script>
    <script>
        const customerMap = <?php echo json_encode($customer_data); ?>;
        const customerSelect = document.getElementById('customer-colum');
        const locationInput = document.getElementById('location-column');

        customerSelect.addEventListener('change', function() {
            const selectedId = this.value;
            if (customerMap.hasOwnProperty(selectedId)) {
                locationInput.value = customerMap[selectedId].address;
            } else {
                locationInput.value = '';
            }
        });

        const customer_Map = <?php echo json_encode($customer_data_map); ?>;
        const customerSelects = document.querySelectorAll('.customer-select-trigger');
        customerSelects.forEach(customerSelect => {
            customerSelect.addEventListener('change', function() {
                const selectedId = this.value;
                const count = this.id.split('_').pop();
                const locationInput = document.getElementById(`location_column_${count}`);
                if (customer_Map.hasOwnProperty(selectedId) && locationInput) {
                    locationInput.value = customer_Map[selectedId].address;
                } else if (locationInput) {
                    locationInput.value = '';
                }
            });
        });
        function toggleDateInputs() {
            var select = document.getElementById('filterSelect');
            var customDiv = document.getElementById('customDates');
            if (select.value === 'custom') {
                customDiv.classList.remove('d-none');
            } else {
                customDiv.classList.add('d-none');
                document.getElementById('filterForm').submit(); // Auto-submit for presets
            }
        }
    </script>
    <?php ob_end_flush(); ?>