<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title> <?php echo $title; ?> </title>
  <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>

  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/fontawesome-free/css/all.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  <!-- Tempusdominus Bootstrap 4 -->
  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css">
  <!-- iCheck -->
  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/icheck-bootstrap/icheck-bootstrap.min.css">
  <!-- JQVMap -->
  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/jqvmap/jqvmap.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/dist/css/adminlte.min.css">
  <!-- overlayScrollbars -->
  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/overlayScrollbars/css/OverlayScrollbars.min.css">
  <!-- Daterange picker -->
  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/daterangepicker/daterangepicker.css">
  <!-- summernote -->
  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/summernote/summernote-bs4.min.css">


  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/select2/css/select2.min.css">
  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css">

  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/datatables-buttons/css/buttons.bootstrap4.min.css">

  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css">
  <!-- Toastr -->
  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/plugins/toastr/toastr.min.css">

  <style>
    .error {
      color: red;
      font-weight: normal;
    }
  </style>

  <link rel="icon" href="<?php echo $title; ?>">
</head>


<body class="hold-transition sidebar-mini layout-fixed layout-navbar-fixed layout-footer-fixed">
  <div class="wrapper">

    <!-- <div class='preloader flex-column justify-content-center align-items-center'>
      <img class='animation__shake' src='<?php echo base_url(); ?>assets/logo.png' alt='' height='50' width='180'>
    </div> -->


    <!-- Navbar -->
    <nav class="main-header navbar navbar-expand navbar-white navbar-light">
      <!-- Left navbar links -->
      <ul class="navbar-nav">
        <li class="nav-item">
          <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
        </li>
        <li class="nav-item d-none d-sm-inline-block">
          <a href="<?php echo base_url(); ?>dashboard" class="nav-link">Home</a>
        </li>
        <li class="nav-item d-none d-sm-inline-block">
          <a href="#" class="nav-link"><?php echo $this->session->userdata('mst_petugas_nama_lengkap'); ?></a>
        </li>
      </ul>
      <ul class="navbar-nav ml-auto">
        <li class="nav-item">
          <a class="nav-link" data-widget="fullscreen" href="#" role="button">
            <i class="fas fa-expand-arrows-alt"></i>
          </a>
        </li>
      </ul>
    </nav>




    <!-- Main Sidebar Container -->
    <aside class="main-sidebar sidebar-dark-primary elevation-4">
      <center>
        <a href="<?php echo base_url(); ?>dashboard" class="brand-link center">
          <img src="<?php echo base_url(); ?>assets/logo.png" alt="" class="img-rectangle" style="opacity: .9;height: 20px;width= 120px; margin-bottom: 10px;">
        </a>
      </center>

      <!-- Sidebar -->
      <div class="sidebar">
        <div class="form-inline">
        </div>

        <!-- Sidebar adminmenu -->
        <nav class="mt-2">
          <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
            <?php
            $id_level_user = $this->session->userdata('mst_petugas_id');
            $sql_adminmenu = "SELECT * FROM tbl_mst_menu WHERE mst_menu_id IN(SELECT mst_akses_menu_id FROM tbl_mst_akses,tbl_mst_petugas WHERE mst_akses_petugas_id=$id_level_user) and mst_menu_is_main=0 and mst_menu_status='Y' GROUP BY mst_menu_id ASC";
            $main_adminmenu = $this->db->query($sql_adminmenu)->result();
            foreach ($main_adminmenu as $main) {
              //cek subadminmenu
              $sub_adminmenu = $this->db->query("SELECT * FROM tbl_mst_menu WHERE mst_menu_id IN(SELECT mst_akses_menu_id FROM tbl_mst_akses,tbl_mst_petugas WHERE mst_akses_petugas_id=$id_level_user ) and mst_menu_is_main=$main->mst_menu_id and  mst_menu_status='Y'  GROUP BY mst_menu_id ASC");
              if ($sub_adminmenu->num_rows() > 0) {
                //tampilkan sub adminmenu
                echo "<li id='menu' class='nav-item has-treeview'>
                                  <a onclick='menu();' class='nav-link'>
                                    <i class='" . $main->mst_menu_icon . "'></i> 
                                    <p>
                                      " . $main->mst_menu_nama . "
                                      <i class='right fas fa-angle-left'></i>
                                    </p>
                                  </a>
                                  
                                <ul class='nav nav-treeview'>";
                foreach ($sub_adminmenu->result() as $sub) {
                  echo "<li class='nav-item'>
                                          <a onclick='menu();' href='" . base_url() . $sub->mst_menu_link . "' class='nav-link'>
                                            <i class='far fa-circle nav-icon'></i>
                                            <p>" . $sub->mst_menu_nama . "</p>
                                            
                                          </a>
                                        <li>";
                }
                echo "</ul>
                                </li>";
              } else {

                //tampilkan adminmenu utama
                echo "<li  id='menu' class='nav-item'>
                                  <a onclick='menu();' href='" . base_url() . $main->mst_menu_link . "' class='nav-link'>                                   
                                      <i class='" . $main->mst_menu_icon . "'></i> 
                                      <p>" . $main->mst_menu_nama . "</p>
                                  </a>
                                <li>";
              }
            }

            echo "<script type='text/javascript'>
                            function menu() {
                              var element = document.getElementById('menu');
                              element.classList.add('menu-open');
                            }
                          </script>";
            ?>
            <li class='nav-item'>
              <a href="<?php echo base_url(); ?>logout" class="nav-link active">
                <i class="nav-icon fas fa-arrow-right"></i>
                <p>
                  Logout
                </p>

              </a>
            <li>


          </ul>
        </nav>
        <!-- /.sidebar-adminmenu -->
      </div>
      <!-- /.sidebar -->
    </aside>

    <div class="content-wrapper">
      <!-- Content Header (Page header) -->
      <div class="content-header">
        <div class="container-fluid">
          <div class="row mb-2">
            <div class="col-sm-6">
              <!-- <h1 class="m-0 text-dark"><?php echo $halaman ?></h1> -->
            </div>

            <?php if ($halaman != 'Dashboard') {
              echo ' <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                          <li class="breadcrumb-item"><a href="' . base_url() . 'dashboard">Dashboard</a></li>';
              echo  '         <li class="breadcrumb-item active">' . $halaman . '</li>
                        </ol>
                      </div>';
            }
            ?>
            <!-- /.col -->
          </div>
          <!-- /.row -->
        </div>
        <!-- /.container-fluid -->
      </div>
      <!-- /.content-header -->


      <section class="content">
        <?php echo $contents; ?>
      </section>
    </div>




    <footer class="main-footer">
      <strong>Copyright &copy; 2023 <a href="https://Arifah Pulsa.com" target="_blank">Arifah Pulsa</a>.</strong>
      All rights reserved.
      <div class="float-right d-none d-sm-inline-block">

      </div>
    </footer>

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
      <!-- Control sidebar content goes here -->
    </aside>

    <!-- jQuery -->
    <script src="<?php echo base_url(); ?>assets/plugins/jquery/jquery.min.js"></script>
    <!-- jQuery UI 1.11.4 -->
    <script src="<?php echo base_url(); ?>assets/plugins/jquery-ui/jquery-ui.min.js"></script>
    <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
    <script>
      $.widget.bridge('uibutton', $.ui.button)
    </script>
    <!-- Bootstrap 4 -->
    <script src="<?php echo base_url(); ?>assets/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
    <!-- ChartJS -->
    <script src="<?php echo base_url(); ?>assets/plugins/chart.js/Chart.min.js"></script>
    <!-- Sparkline -->
    <script src="<?php echo base_url(); ?>assets/plugins/sparklines/sparkline.js"></script>
    <!-- JQVMap -->
    <script src="<?php echo base_url(); ?>assets/plugins/jqvmap/jquery.vmap.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/jqvmap/maps/jquery.vmap.usa.js"></script>
    <!-- jQuery Knob Chart -->
    <script src="<?php echo base_url(); ?>assets/plugins/jquery-knob/jquery.knob.min.js"></script>
    <!-- daterangepicker -->
    <script src="<?php echo base_url(); ?>assets/plugins/moment/moment.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/daterangepicker/daterangepicker.js"></script>
    <!-- Tempusdominus Bootstrap 4 -->
    <script src="<?php echo base_url(); ?>assets/plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
    <!-- Summernote -->
    <script src="<?php echo base_url(); ?>assets/plugins/summernote/summernote-bs4.min.js"></script>
    <!-- overlayScrollbars -->
    <script src="<?php echo base_url(); ?>assets/plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
    <!-- AdminLTE App -->
    <script src="<?php echo base_url(); ?>assets/dist/js/adminlte.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="<?php echo base_url(); ?>assets/dist/js/demo.js"></script>
    <!-- AdminLTE dashboard demo (This is only for demo purposes) -->
    <script src="<?php echo base_url(); ?>assets/dist/js/pages/dashboard.js"></script>

    <!-- Select2 -->
    <script src="<?php echo base_url(); ?>assets/plugins/select2/js/select2.full.min.js"></script>

    <script src="<?php echo base_url(); ?>assets/plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/jszip/jszip.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/pdfmake/pdfmake.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/pdfmake/vfs_fonts.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/datatables-buttons/js/buttons.html5.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/datatables-buttons/js/buttons.print.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/datatables-buttons/js/buttons.colVis.min.js"></script>

    <!-- Bootstrap 4 -->
    <script src="<?php echo base_url(); ?>assets/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/sweetalert2/sweetalert2.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/plugins/toastr/toastr.min.js"></script>

    <!-- FLOT CHARTS -->
    <script src="<?php echo base_url(); ?>assets/plugins/flot/jquery.flot.js"></script>

    <script type="text/javascript">
      var windowURL = window.location.href;
      pageURL = windowURL.substring(0, windowURL.lastIndexOf('/'));
      var x = $('a[href="' + pageURL + '"]');
      x.addClass('active');
      x.parent().addClass('active');
      var y = $('a[href="' + windowURL + '"]');
      y.addClass('active');
      y.parent().addClass('active');

      $(function() {
        var params = window.location.href;
        params = params.toLowerCase();

        if (params != "/") {
          $(".nav-item li a").each(function(i) {
            var obj = this;
            var url = $(this).attr("href");
            if (url == "" || url == "#") {
              return true;
            }
            url = url.toLowerCase();
            if (url.indexOf(params) > -1) {
              $(this).parent().addClass("active open menu-open");
              $(this).parent().parent().addClass("active open menu-open");
              $(this).parent().parent().parent().addClass("active open menu-open");
              $(this).parent().parent().parent().parent().addClass("active open menu-open");
              $(this).parent().parent().parent().parent().parent().addClass("active open menu-open");
              return false;
            }
          });
        }
      });
    </script>
</body>