    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="<?= base_url ('assets/js/jquery-3.4.1.min.js'); ?>"></script>
    <script src="<?= base_url ('assets/js/bootstrap.bundle.min.js'); ?>"></script>
    <script src="<?= base_url ('assets/lib/chart/chart.min.js'); ?>"></script>
    <script src="<?= base_url ('assets/lib/waypoints/waypoints.min.js'); ?>"></script>
    <script src="<?= base_url ('assets/lib/owlcarousel/owl.carousel.min.js'); ?>"></script>
    <script src="<?= base_url ('assets/lib/tempusdominus/js/moment.min.js'); ?>"></script>
    <script src="<?= base_url ('assets/lib/tempusdominus/js/moment-timezone.min.js'); ?>"></script>
    <script src="<?= base_url ('assets/lib/tempusdominus/js/tempusdominus-bootstrap-4.min.js'); ?>"></script>
    <script src="<?= base_url ('assets/lib/easing/easing.min.js'); ?>"></script>

    <!-- Template Javascript -->
    <script src="<?= base_url ('assets/js/main.js'); ?>"></script>
    <script src="<?= base_url ('assets/js/javascript.js'); ?>"></script>
    <script src="<?= base_url ('assets/dataTables/datatables.min.js'); ?>"></script>

    <script src="<?= base_url('assets/template/admin/libs/datatables.net/js/jquery.dataTables.min.js');?>"></script>
    <script src="<?= base_url('assets/template/admin/libs/datatables.net-bs5/js/dataTables.bootstrap5.min.js');?>"></script>
    <script src="<?= base_url('assets/template/admin/libs/datatables.net-responsive/js/dataTables.responsive.min.js');?>"></script>

    <!-- Sweet Alert2 -->
    <script src="<?= base_url('assets/js/myscript.js'); ?>"></script>
    <script src="<?= base_url('assets/js/sweetalert2.min.js'); ?>"></script>

    <script src="<?= base_url('assets/ckeditor/ckeditor.js'); ?>"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            CKEDITOR.replace('ckeditor', {
                filebrowserImageBrowseUrl: '<?= base_url('assets/kcfinder/browse.php'); ?>',
                height: '400px',
                width: '1200px'
            });
        });
    </script>



<script>
    <?php foreach ($weekly as $cabang): ?>
        CKEDITOR.replace('ckeditor_<?php echo $cabang->weekly_report_id; ?>');
    <?php endforeach; ?>
</script>

    <script>
            $(document).ready(function() {
            $('#datatables').DataTable( {
                responsive: true
            } );
        } );
    </script>

    <script>
        var flash = $('#flash').data('flash');
        if(flash) {
            Swal.fire({
                icon: 'success',
                title: 'Sukses',
                text: flash
            })
        }

        
    </script>

    <script>
        $(document).on('click', '#tombol-hapus', function(e) {
            e.preventDefault();
            var link = $(this).attr('href');

            Swal.fire({
                title: 'Apakah anda yakin ?',
                text: "Data akan dihapus !",
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: 'Hapus Data!'
            }).then((result) => {
                if (result.isConfirmed) {
                   window.location = link;
                }
            })
        })
        </script>


<script>
        $(document).ready(function () {
            $('#checkDateButton').on('click', function () {
                var startDate = $('#start_date').val();
                var endDate = $('#end_date').val();

                if (startDate && endDate) {
                    $.ajax({
                        url: "<?php echo site_url('Admin/Utilization/Project_Controller/get_available_crew'); ?>",
                        method: "POST",
                        data: { start_date: startDate, end_date: endDate },
                        dataType: "json",
                        success: function (response) {
                            if (response.length > 0) {
                                // Populate crew dropdown in the add form
                                var crewDropdown = $('#project_crew_id');
                                crewDropdown.empty();
                                crewDropdown.append('<option value="">-- Pilih Crew --</option>');
                                $.each(response, function (index, crew) {
                                    crewDropdown.append('<option value="' + crew.id_akun + '">' + crew.nama_user + '</option>');
                                });

                                // Close date modal and open add form modal
                                $('#DateModal').modal('hide');
                                $('#ProjectModal1').modal('show');
                            } else {
                                alert('Tidak ada crew yang tersedia pada rentang tanggal tersebut.');
                            }
                        },
                        error: function () {
                            alert('Gagal memeriksa ketersediaan crew.');
                        }
                    });
                } else {
                    alert('Harap isi tanggal mulai dan selesai.');
                }
            });
        });
    </script>


<script>
    document.getElementsByName('tanggal_lahir')[0].addEventListener('change', function() {
        var today = new Date();
        var minimumAge = 17;
        var inputDate = new Date(this.value);
        var age = (today.getFullYear() - inputDate.getFullYear()) - (today.getMonth() < inputDate.getMonth() || (today.getMonth() == inputDate.getMonth() && today.getDate() < inputDate.getDate()) ? 1 : 0);

        if (age < minimumAge) {
          alert('Tanggal lahir tidak boleh kurang dari 17 tahun');
          this.value = '';
      }
  });   
</script>



<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/fullcalendar.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.4.0/fullcalendar.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.4.0/fullcalendar.min.js"></script>
</body>

</html>