<?php if ($this->session->userdata('admin_level') == "Admin"){ ?>
<?php
                  $mode		= $this->uri->segment(3);

                  if ($mode == "edt" || $mode == "act_edt") {
                    
                    $act			= "act_edt";
                    $idp			= $datpil->id_umkm;
                    $nama_usaha			= $datpil->nama_usaha;
                    $nama_pemilik			= $datpil->nama_pemilik;
                    $telp			= $datpil->telp;
                    $jenis_produk			= $datpil->jenis_produk;
                    $nama_produk			= $datpil->nama_produk;
                    $linsek			= $datpil->linsek;

                    
                    
                    
                    
                    
                  } else {
                    $act			= "act_add";
                    $idp			= "";
                    $nama_usaha			= "";
                    $nama_pemilik			= "";
                    $telp			= "";
                    $jenis_produk			= "";
                    $nama_produk			= "";
                    $linsek			= "";

                    

                  }
                  ?>
<html>
<head>
<script>
		function hanyaAngka(evt) {
		  var charCode = (evt.which) ? evt.which : event.keyCode
		   if (charCode > 31 && (charCode < 48 || charCode > 57))
 
		    return false;
		  return true;
		}
  
</script>



 
 <script>
  function validateFormUmkm() {
    
 
    var nama_usaha = document.forms["formumkm"]["nama_usaha"].value;
    var nama_pemilik = document.forms["formumkm"]["nama_pemilik"].value;
    var telp = document.forms["formumkm"]["telp"].value;
    var jenis_produk = document.forms["formumkm"]["jenis_produk"].value;
    var nama_produk = document.forms["formumkm"]["nama_produk"].value;
    var linsek = document.forms["formumkm"]["linsek"].value;

    if (nama_usaha == "") {
      alert("Nama Usaha Harus Diisi");
      return false;
    }
    else if (nama_pemilik == "") {
      alert("Nama Pemilik Harus Diisi");
     
      return false;
    }
    else if (telp == "") {
      alert("Telp Pemilik Harus Diisi");
      return false;
    }
    else if (jenis_produk == "") {
      alert("Jenis Produk Harus Diisi");
      return false;
    }
    else if (nama_produk == "") {
      alert("Nama Produk Harus Diisi");
      return false;
    }
    else if (linsek == "") {
      alert("Lintas Sektor Harus Diisi");
      return false;
    }
    $('.auto-save').savy('destroy',function(){
    console.log("All data from savy are Destroyed");
    window.location.reload();
  });
  }
  
  </script>
<script>
function clearcontent() {
    document.getElementById("formumkm").reset();
}
</script>

</head>
<body>
<section class="content">
      <div class="container-fluid">
        <div class="row">
          <!-- left column -->
          <div class="col-md-12">
            <!-- jquery validation -->
            <div class="card card-primary">
              <div class="card-header">
                <h3 class="card-title">Form <small>UMKM</small></h3>
              </div>
              
              <!-- /.card-header -->
              <!-- form start -->
              <form name="formumkm" onsubmit="return validateFormUmkm()" action="<?=base_URL()?>sistem/umkm/<?php echo $act; ?>" onsubmit="dstry()"  method="post" accept-charset="utf-8" enctype="multipart/form-data" id="quickForm" class="form-horizontal">
              <input type="hidden" name="idp" value="<?php echo $idp; ?>">                                               
              <div class="card-body">
                                     
                                       
                                         
    <section class="content">
      


 <div class="container-fluid">
        <!-- SELECT2 EXAMPLE -->
        <div class="card card-default">
          <div class="card-header">
            <h3 class="card-title">Masukkan Data UMKM</h3>

            <div class="card-tools">
              <button type="button" class="btn btn-tool" data-card-widget="collapse">
                <i class="fas fa-minus"></i>
              </button>
             
            </div>
          </div>
          <!-- /.card-header -->
          <div class="card-body">
            <div class="row">
              <div class="col-md-6">
             
                <div class="form-group">
                  <label>Nama Usaha:</label>
                  <input type="text" name="nama_usaha" class="form-control auto-save" id="nama_usaha"     value="<?php echo $nama_usaha; ?>" >  
                
                </div>
               
                <div class="form-group">
                  <label>Nama Pemilik:</label>
                  <input type="text" name="nama_pemilik" class="form-control auto-save" id="nama_pemilik"   value="<?php echo $nama_pemilik; ?>" >  
                
                </div>
                <div class="form-group">
                  <label>Telp:</label>
                  <input type="text" name="telp" class="form-control auto-save" id="telp"   onkeypress="return hanyaAngka(event)"   value="<?php echo $telp; ?>" >  
                </div>
               
              
               
               
              </div>

              <!-- /.col KANAN -->
              <div class="col-md-6">
              
              <div class="form-group">
                  <label>Jenis Produk</label>
                  <select  name="jenis_produk" id="jenis_produk"  class="form-control auto-save" ><option value=""> - Pilih - </option>
                        <?php
                          $l_jenis_produk	= array('Pangan','Obat Tradisional',);
                          for ($i = 0; $i < sizeof($l_jenis_produk); $i++) {
                            if ($l_jenis_produk[$i] == $jenis_produk) {
                              echo "<option selected value='".$l_jenis_produk[$i]."'>".$l_jenis_produk[$i]."</option>";
                                } else {
                                  echo "<option value='".$l_jenis_produk[$i]."'>".$l_jenis_produk[$i]."</option>";
                                    }				
                                      }			
                        ?>			
                  </select>           
                </div>
                <div class="form-group">
                  <label>Nama Produk Yang Didaftarkan:</label>
                  <input type="text" name="nama_produk" class="form-control auto-save" id="nama_produk"     value="<?php echo $nama_produk; ?>" >  
                </div>
               
                <div class="form-group">
                  <label>Lintas Sektor  :</label>
                  <input type="text" name="linsek" class="form-control auto-save" id="linsek"     value="<?php echo $linsek; ?>" >  
                </div>
              
                
                
                
              </div>
            
              <!-- /.col -->
            </div>
            <!-- /.row -->
            
          
            <!-- /.row -->
          </div>
          <!-- /.card-body -->
          
        </div>
        <!-- /.card -->

        <!-- SELECT2 EXAMPLE -->
       
        <!-- /.card -->

        
        <!-- /.card -->

       
        <!-- /.row -->
        
        <!-- /.row -->
        
        <!-- /.row -->
      </div>

      
      <!-- /.container-fluid -->
    </section>
                                           
                                            
                                          </div>
                                          <!-- /.card-body -->
                                          <div class="card-footer">
                                              <button type="submit"  class="btn btn-primary" >Kirim</button>
                                             
                                          </div>
                                          
                                        </form>
                                        
            </div>
         
            <!-- /.card -->
            </div>
          <!--/.col (left) -->
          <!-- right column -->
          <div class="col-md-3">
            
              <button type="submit" onclick="clearcontent()"  id="hapus"   class="btn btn-secondary" >Bersihkan Form</button>
           
          </div>
          
          <!--/.col (right) -->
        </div>
        <!-- /.row -->
      </div><!-- /.container-fluid -->
    </section>

    <?php } ?> <!-- Acton Admin-->
    

















    
<div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
           
          </div><!-- /.col -->
         
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-12">
            
            <!-- /.card -->

            <div class="card">
              <div class="card-header">
                <h3 class="card-title"><?php echo $this->session->flashdata("k");?></h3>
                <h3 class="card-title"><?php echo $this->session->flashdata("kk");?></h3>
              </div>
              <!-- /.card-header -->
              <div class="card-body">
              <table  id="example1" class="table table-bordered table-striped">
                  <thead>
                  <tr>
                    <th>No</th>
                    <th>Nama Usaha</th>
                    <th>Nama Pemilik</th>
                    <th>Telp</th>
                    <th>Jenis Produk</th>
                    <th>Nama Produk</th>
                    <th>Instansi</th>
                    <?php if ($this->session->userdata('admin_level') == "Admin"){ ?>
                    <th>Aksi</th>
                    <?php } ?> <!-- Acton Admin-->
                  </tr>
                           
                  </thead>
                  <tbody >
                  <tr>
                  <?php 
                  if (empty($data)) {
                    echo "<tr></tr>";
                  } else {
                    $no 	= ($this->uri->segment(4) + 1);
                    foreach ($data as $b) {
                  ?>
                  <td> 
                <?=$no?>
                 
                </td>
                 <td> 
                <?=$b->nama_usaha?>
                 
                </td>
                  
                  <td>
                  <?=$b->nama_pemilik?>
                  </td>
                    
                  <td>
                    <?=$b->telp?> 
                  </td>

                  <td>
                     <?=$b->jenis_produk?>
                    </td>
                    <td>
                    <?=$b->nama_produk?>
                   </td>
                    <td>
                    <?=$b->linsek?>
                   </td>
                   <?php if ($this->session->userdata('admin_level') == "Admin"){ ?>
                    <td class="text-center py-0 align-middle">
                      <div class="btn-group btn-group-sm">
                     
                      <a class="btn btn-info" href="<?=base_URL()?>sistem/umkm/edt/<?php echo encrypt_url ($b->id_umkm)?>"><i class="fas fa-pencil-alt "></i></a>
                        <a onclick="return confirm('Anda Yakin..?')" href="<?=base_URL()?>sistem/umkm/del/<?php echo encrypt_url ($b->id_umkm)?>" class="btn btn-danger"><i class="fas fa-trash"></i></a>
                      </div>
                    </td>
                    <?php } ?> <!-- Acton Admin-->
                </tr>
                  
                  <?php 
			$no++;
			}
		}
		?> 
                  </tbody>
                 
                </table>
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
  
    	
