<?php 
if (empty($connection)) {
  header('location:./404');
} else {
  $mod = htmlentities(@$_GET['mod'] ?: 'home');

  // helper opsionalmu tetap
  function get_numbers(){ for($i=1;$i<=500;$i++){ yield $i; } }
  function convert($size){
    $unit=['b','kb','mb','gb','tb','pb'];
    return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
  }
?>
  <footer class="text-muted text-center"><!-- ... --></footer>
</div><!-- /wrapper -->

<!-- ===== Core JS (urutan WAJIB) ===== -->
<script src="./assets/js/jquery-2.2.3.min.js"></script>
<script src="./assets/js/jquery-ui.min.js"></script>
<script src="./assets/js/bootstrap.min.js"></script>

<!-- ===== Plugin umum ===== -->
<script src="./assets/js/jquery.slimscroll.min.js"></script>
<script src="./assets/js/adminlte.js"></script>
<script src="./assets/js/app.js"></script>
<!-- HILANGKAN demo.js karena sering memunculkan notifikasi demo -->
<!-- <script src="./assets/js/demo.js"></script> -->
<!-- SweetAlert boleh tidak dipakai jika mau benar-benar sunyi -->
<!-- <script src="./assets/js/sweetalert.min.js"></script> -->
<script src="./plugins/chart.js/Chart.min.js"></script>
<script src="./assets/js/simple-lightbox.min.js"></script>
<script src="./assets/js/validasi/jquery.validate.js"></script>
<script src="./assets/js/validasi/messages_id.js"></script>

<?php if($mod=='shift'){ ?>
  <script src="./assets/plugins/datepicker/bootstrap-datepicker.js"></script>
  <script src="./assets/plugins/timepicker/bootstrap-timepicker.min.js"></script>
<?php } ?>

<?php if(in_array($mod, ['karyawan','jabatan','shift','lokasi','user','absensi','supervisi'])){ ?>
  <link rel="stylesheet" href="./assets/plugins/datatables/dataTables.bootstrap.css">
  <script src="./assets/plugins/datatables/jquery.dataTables.min.js"></script>
  <script src="./assets/plugins/datatables/dataTables.bootstrap.min.js"></script>
<?php } ?>

<?php if($mod=='absensi'){ ?>
  <script src="../mod/assets/js/plugins/magnific-popup/jquery.magnific-popup.min.js"></script>
<?php } ?>

<?php if(file_exists('mod/'.$mod.'/scripts.js')){ ?>
  <script src="mod/<?php echo $mod; ?>/scripts.js"></script>
<?php } ?>

<script>
// ====== MODE SUNYI: matikan semua notifikasi pop-up ======
(function(){
  // Matikan alert browser
  window.alert = function(){ return false; };

  // Jika ada SweetAlert / Toastr yang di-load dari file lain, buat no-op
  Object.defineProperty(window, 'swal', { value: function(){ return false; }, writable: false });
  if (typeof toastr !== 'undefined') {
    ['info','success','warning','error'].forEach(function(m){ toastr[m] = function(){ return false; }; });
    if (typeof toastr.clear === 'function') toastr.clear();
  }
})();
</script>

<script>
$(function(){
  // Validasi
  $(".validate").length && $(".validate").validate();
  $(".validate2").length && $(".validate2").validate();

  // NONAKTIFKAN trigger notifikasi akses (jika sebelumnya ada)
  $(document).off("click", ".access-failed");

  // Inisialisasi DataTable kalau ada tabel id #swdatatable
  if ($("#swdatatable").length){
    $("#swdatatable").DataTable({
      pageLength: 10,
      ordering: true,
      autoWidth: false
    });
  }
});
</script>
</body>
</html>
<?php } ?>
