<?php foreach($kontak as $kontak) :   endforeach; ?>
<?php foreach($admin_login as $user) :   endforeach; ?> 
  <!-- Content Wrapper. Contains page content -->
  <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 $title1; ?>
            </h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Home</a></li>
              <li class="breadcrumb-item active"><?php echo $title1; ?></li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
	    <?php 
            $username = $this->session->userdata("username");  
            $this->db->where('username',$username);
            $query = $this->db->get('tb_admin');
            $row = $query->row();
           
            $level = $row->level;

             ?>
          
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
      	  <div class="card">
              <div class="card-header">
                <button type="button" class="btn btn-info" data-toggle="modal" data-target="#modal-default">
                  <i class="fa fa-plus"></i> Tambah Data
                </button>
              

              </div>
              <!-- /.card-header -->
              <div class="card-body">
              	<table id="example1" class="table table-bordered table-striped">
              		<thead>
              			<tr>
              				<th>NO</th>
              				<th>NAMA KATEGORI</th>
              				<th>MIN PEMBELIAN</th>
              				<th>DISKON</th>
              		 
              				<th>Aksi</th>
              				
              			</tr>
              		</thead>
              		<tbody>
              			<?php $no=1; foreach($kat_member as $rows) : ?> 
              				<tr>
												<td><?php echo $no; ?></td>
              					<td><?php echo $rows->nama_kat_member; ?></td>
              					<td><?php echo $rows->min_diskon; ?></td>
              					<td><?php echo $rows->diskon; ?> %</td>
              				 

              					<td>
                          <?php  
                            if($level =='manager'){
                          ?> 
              						<a href=""  type="button" data-toggle="modal" data-target="#modal-edit<?php echo $rows->id_kat_member; ?>"><i class="fa fa-edit"></i></a> | 
              						<a href="" style="color: red;"  type="button"  data-toggle="modal" data-target="#modal-hapus<?php echo $rows->id; ?>"><i class="fa fa-trash"></i></a>
                            <?php } ?>
              						<!-- Edit -->
              						<form class="form-horizontal" action="<?php echo base_url('kat_member/code_ubah'); ?>" method="POST" enctype="multipart/form-data" />  
              							<div class="modal fade" id="modal-edit<?php echo $rows->id_kat_member; ?>">
              								<div class="modal-dialog">
              									<div class="modal-content">
              										<div class="modal-header">
              											<h4 class="modal-title">Edit Data <?php echo $rows->nama_kat_member; ?></h4>
              											<button type="button" class="close" data-dismiss="modal" aria-label="Close">
              												<span aria-hidden="true">&times;</span>
              											</button>
              										</div>
              										<div class="modal-body">

              											<!-- id kirim -->
              											<input type="hidden" name="id" value="<?php echo $rows->id_kat_member; ?>">
              											<div class="form-group">
              												<label for="exampleInputEmail1">Nama <?php echo $title4; ?></label>
              												<input type="text" class="form-control" value="<?php echo $rows->nama_kat_member; ?>" id="exampleInputEmail1" name="nama_kat_member" placeholder="">
              											</div>
              										 
              											<div class="form-group">
              												<label for="exampleInputEmail1">Minimal Pembelian Diskon </label>
              												<input type="text" class="form-control" value="<?php echo $rows->min_diskon; ?>" id="exampleInputEmail1" name="min_diskon" placeholder="">
              											</div>

              											<div class="form-group">
              												<label for="exampleInputEmail1">Diskon %</label>
              												<input type="text" class="form-control" value="<?php echo $rows->diskon; ?>" id="exampleInputEmail1" name="diskon" placeholder="">
              											</div>
                                    
              											 

              										</div>
              										<div class="modal-footer justify-content-between">
              											<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              											<button type="submit" class="btn btn-primary">Simpan</button>
              										</div>
              									</div>
              									<!-- /.modal-content -->
              								</div>
              								<!-- /.modal-dialog -->
              							</div>
              						</form>

              						<!-- Hapus -->

              						<form class="form-horizontal" action="<?php echo base_url('kat_member/code_hapus'); ?>" method="POST" enctype="multipart/form-data" />  
              							<div class="modal fade" id="modal-hapus<?php echo $rows->id; ?>">
              								<div class="modal-dialog">
              									<div class="modal-content bg-danger">
              										<div class="modal-header">
              											<h4 class="modal-title">Hapus Data </h4>
              											<button type="button" class="close" data-dismiss="modal" aria-label="Close">
              												<span aria-hidden="true">&times;</span>
              											</button>
              										</div>
              										<div class="modal-body">
              											<h4>Apakah Yakin Menghapus Data Ini, <?php echo $rows->nama_kat_member; ?> ?</h4>
              											<!-- id kirim -->
              											<input type="hidden" name="id" value="<?php echo $rows->id_kat_member; ?>">


              										</div>
              										<div class="modal-footer justify-content-between">
              											<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              											<button type="submit" class="btn btn-primary">Hapus</button>
              										</div>
              									</div>
              									<!-- /.modal-content -->
              								</div>
              								<!-- /.modal-dialog -->
              							</div>
              						</form>

              					</td>
              				</tr>
              			<?php $no++; endforeach; ?>

              		</tbody>

              	</table>
              </div>
              <!-- /.card-body -->
            </div>
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  	<!-- Modal Tambah Data -->
  	<form class="form-horizontal" action="<?php echo base_url('kat_member/code_tambah'); ?>" method="POST" enctype="multipart/form-data" />  
  		<div class="modal fade" id="modal-default">
  			<div class="modal-dialog">
  				<div class="modal-content">
  					<div class="modal-header">
  						<h4 class="modal-title">Tambah Data</h4>
  						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
  							<span aria-hidden="true">&times;</span>
  						</button>
  					</div>
  					<div class="modal-body">
  					 
             <div class="form-group">
              <label for="exampleInputEmail1">Nama Kategori Member  </label>
              <input type="text" class="form-control"  id="exampleInputEmail1" name="nama_kat_member" placeholder="Kategori Diskon">
            </div>
            <div class="form-group">
              <label for="exampleInputEmail1">Minimal Pembelian Diskon </label>
              <input type="number" class="form-control" id="exampleInputEmail1" name="min_diskon" placeholder="">
            </div>

            <div class="form-group">
              <label for="exampleInputEmail1">Diskon %</label>
              <input type="text" class="form-control"id="exampleInputEmail1" name="diskon" placeholder="">
            </div>



  					 
  						</div>
  						<div class="modal-footer justify-content-between">
  							<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  							<button type="submit" class="btn btn-primary">Simpan</button>
  						</div>
  					</div>
  					<!-- /.modal-content -->
  				</div>
  				<!-- /.modal-dialog -->
  		</div>
  	</form>