<!-- Begin Page Content -->
<div class="container-fluid">
	<div class="d-sm-flex align-items-center justify-content-between mb-4">
	    <h1 class="h3 mb-0 text-gray-800 mb-3"><?= $title;  ?></h1>
	    <a href="" class="btn btn-sm btn-success shadow-sm" data-toggle="modal" data-target="#addDataMenu" >
	        <i class="fas fa-fw fa-plus fa-sm text-white-50"></i>
	        <span class="text">Tambah Menu</span>
	    </a>
	</div>
  	
  	<div class="row clearfix">
	  	<div class="col-lg-12">

			<?= $this->session->flashdata('message'); ?>
			
		</div>
	</div>
	
	<div class="row justify-content-center">
		<div class="col-sm-8">
	  		<div class="card border-bottom-success shadow mb-4">
	            <div class="card-header py-3">
	              <h6 class="m-0 font-weight-bold text-success"></h6>
	            </div>
				<div class="card-body">
					<div class="table-responsive">
				  		<table class="table table-user-management table-striped table-bordered table-sm" id="tabel-data">
						  <thead>
						    <tr>
						      <th scope="col" width="5px">#</th>
						      <th scope="col">Menu</th>
						      <th scope="col">Link</th>
						      <th scope="col">Status</th>
						    </tr>
						  </thead>
						  <tbody>
						  	<form action="<?= base_url('menu/ubah_stts'); ?>" method="POST">
						  	<?php 
						  	$i = 1;
						  	foreach($dt_menu as $row) : ?>
						  		<tr>
						  			<td colspan="6"><?= $i++.'. '.$row['nm_menu'] ?></td>
						  		</tr>
						  		<?php 
						  		$a = 'A';
						  		foreach($row['dt_sub_menu'] as $row_dt) : ?>
						  		<tr>
						  			<td></td>
						  			<td><?= $a++.'. '.$row_dt['nm_sub_menu'] ?></td>
						  			<td><?= $row_dt['link'] ?></td>
						  			<td><?= ($row_dt['is_active'] == 1) ? 'Aktif' : 'Non-Aktif'; ?></td>
						  		</tr>
							  	<?php endforeach; ?>
						  	<?php endforeach; ?>
						  	</form>
						  </tbody>
						</table>
					</div>
				</div>
			</div>
	  	</div>
	</div>

</div>
<!-- /.container-fluid -->

</div>
<!-- End of Main Content -->



<!-- Modal -->
<div class="modal fade" id="addDataMenu" tabindex="-1" role="dialog" aria-labelledby="addDataMenuLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="addDataMenuLabel">Tambah Menu</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <form action="<?= base_url('menu/tambah'); ?>" method="post">
	      <div class="modal-body">
	        
                <div class="form-group row">
                  <label for="nama" class="col-sm-2 col-form-label">Menu</label>
                    <div class="col-sm-10">
                    <input type="text" class="form-control" id="nama" name="nama" value="" required>
                  </div>
                </div>

	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
	        <button type="submit" class="btn btn-success">Tambah</button>
	      </div>
      </form>
    </div>
  </div>
</div>

<!-- Modal -->
<div class="modal fade" id="ubahMenu" tabindex="-1" role="dialog" aria-labelledby="ubahMenuLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="ubahMenuLabel">Ubah Menu</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <form action="<?= base_url('menu/ubah'); ?>" method="post">
	      <div class="modal-body">
	        
                <div class="form-group row">
                  <label for="name" class="col-sm-2 col-form-label">Menu</label>
                    <div class="col-sm-10">
                    <input type="hidden" class="form-control" id="id_menu_edit" name="id_menu" required>
                    <input type="text" class="form-control" id="nama_edit" name="nama" required>
                  </div>
                </div>

	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
	        <button type="submit" class="btn btn-success">Ubah</button>
	      </div>
      </form>
    </div>
  </div>
</div>

<!-- Modal -->
<div class="modal fade" id="hapusMenu" tabindex="-1" role="dialog" aria-labelledby="hapusMenuLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="hapusMenuLabel">Hapus Jabatan</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <form action="<?= base_url('menu/hapus'); ?>" method="post">
	      <div class="modal-body">
	        	<input type="hidden" class="form-control" id="id_menu_hapus" name="id_menu" required>
                <h4>Konfirmasi Hapus!</h4>
                <p>Apakah ingin menghapus data?</p>

	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
	        <button type="submit" class="btn btn-danger">Ya</button>
	      </div>
      </form>
    </div>
  </div>
</div>


<script>
	$('.ubahMenu').on('click',function(){
	    var id = $(this).data('id_menu');
	    var nm = $(this).data('nama');

	    $('#id_menu_edit').val(id);
	    $('#nama_edit').val(nm);
    });

	$('.hapusMenu').on('click',function(){
	    var id = $(this).data('id_menu');

	    $('#id_menu_hapus').val(id);
    });
	
</script>