<?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_user;
                    $username			    = $datpil->username;
                    $password			    = $datpil->password;
                    $nama_lengkap			= $datpil->nama_lengkap;
                    $nama_panggilan		= $datpil->nama_panggilan;
                    $kampus			      = $datpil->kampus;
                    $semester			    = $datpil->semester;
                    $prodi			      = $datpil->prodi;
                    $asal			        = $datpil->asal;
                    $no_wa			      = $datpil->no_wa;

              
                    
                    
                  } else {
                    $act			        = "act_add";
                    $idp			        = "";
                    $username			    = "";
                    $password			    = "";
                    $nama_lengkap			= "";
                    $nama_panggilan		= "";
                    $kampus			      = "";
                    $semester			    = "";
                    $prodi			      = "";
                    $asal			        = "";
                    $no_wa			      = "";

                  }
?>
<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 validateFormFasilitator() {
    var nama_lengkap = document.forms["formfasilitator"]["nama_lengkap"].value;
    var nama_panggilan = document.forms["formfasilitator"]["nama_panggilan"].value;
    var kampus = document.forms["formfasilitator"]["kampus"].value;
    var semester = document.forms["formfasilitator"]["semester"].value;
    var prodi = document.forms["formfasilitator"]["prodi"].value;
    var asal = document.forms["formfasilitator"]["asal"].value;
    var no_wa = document.forms["formfasilitator"]["no_wa"].value;

    if (nama_lengkap == "") {
      alert("Nama Lengkap Harus Diisi");
      return false;
    }
    else if (nama_panggilan == "") {
      alert("Nama Panggilan Harus Diisi");
     
      return false;
    }
    else if (kampus == "") {
      alert("Kampus Harus Diisi");
      return false;
    }
    else if (semester == "") {
      alert("Semester Harus Diisi");
      return false;
    }
    else if (prodi == "") {
      alert("Prodi Harus Diisi");
      return false;
    }
    else if (asal == "") {
      alert("Asal Tempat Tinggal Harus Diisi");
      return false;
    }
    else if (no_wa == "") {
      alert("No WA Aktif 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("formfasilitator").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>Fasilitator</small></h3>
              </div>
              
              <!-- /.card-header -->
              <!-- form start -->
              <form name="formfasilitator" onsubmit="return validateFormFasilitator()" action="<?=base_URL()?>sistem/fasilitator/<?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; ?>">   
              <input onchange="inputsamadanlowercase()" type="hidden" name="username" id="username" value="<?php echo $username; ?>">                                        
              <input type="hidden" name="password" value="bpom2023berdikari">   
              <input type="hidden" name="level" value="User">   
             
              <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 Fasilitator</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 Lengkap:</label>
                  <input type="text" name="nama_lengkap" class="form-control auto-save" id="nama_lengkap"     value="<?php echo $nama_lengkap; ?>" >  
                
                </div>
               
                <div class="form-group">
                  <label>Nama Panggilan:</label>
                  <input onchange="inputsamadanlowercase()" type="text" name="nama_panggilan" class="form-control auto-save" id="nama_panggilan"   value="<?php echo $nama_panggilan; ?>" >  
                
                </div>
                <div class="form-group">
                  <label>Kampus:</label>
                  <input type="text" name="kampus" class="form-control auto-save" id="kampus"    value="<?php echo $kampus; ?>" >  
                </div>
               
                <div class="form-group">
                  <label>Semester:</label>
                  <input type="text" name="semester" maxlength="2" class="form-control auto-save" id="semester"   onkeypress="return hanyaAngka(event)"   value="<?php echo $semester; ?>" >  
                </div>
               
               
              </div>

              <!-- /.col KANAN -->
              <div class="col-md-6">
              
              <div class="form-group">
                  <label>Prodi:</label>
                  <input type="text" name="prodi" class="form-control auto-save" id="prodi"     value="<?php echo $prodi; ?>" >  
                </div>

                <div class="form-group">
                  <label>Asal Tempat Tinggal:</label>
                  <input type="text" name="asal" class="form-control auto-save" id="asal"     value="<?php echo $asal; ?>" >  
                </div>
               
                <div class="form-group">
                  <label>No WA Aktif  :</label>
                  <input type="text" name="no_wa" class="form-control auto-save" id="no_wa" onkeypress="return hanyaAngka(event)" value="<?php echo $no_wa; ?>" >  
                </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>


    

















    
<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</th>
                    <th>Kampus</th>
                    <th>Semester</th>
                    <th>Prodi</th>
                    <th>Asal Tempat Tinggal</th>
                    <th>No WA Aktif</th>
                    <th>Aksi</th>
                  </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_lengkap?> (<?=$b->nama_panggilan?>)
                 
                </td>
                  
                  <td>
                  <?=$b->kampus?>
                  </td>
                    
                  <td>
                    <?=$b->semester?> 
                  </td>

                  <td>
                     <?=$b->prodi?>
                    </td>
                    <td>
                    <?=$b->asal?>
                   </td>
                    <td>
                    <?=$b->no_wa?>
                   </td>
                   
                    <td class="text-center py-0 align-middle">
                      <div class="btn-group btn-group-sm">
                     
                      <a class="btn btn-info" href="<?=base_URL()?>sistem/fasilitator/edt/<?php echo encrypt_url ($b->id_user)?>"><i class="fas fa-pencil-alt "></i></a>
                        <a onclick="return confirm('Anda Yakin..?')" href="<?=base_URL()?>sistem/fasilitator/del/<?php echo encrypt_url ($b->id_user)?>" class="btn btn-danger"><i class="fas fa-trash"></i></a>
                      </div>
                    </td>
                       
                </tr>
                  
                  <?php 
			$no++;
			}
		}
		?> 
                  </tbody>
                 
                </table>
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
    <?php } ?> <!-- Acton Admin-->
    <?php if ($this->session->userdata('admin_level') == "User"){ ?>
      <h1>Page Not Found</h1>
    <p>Sorry, but the page you requested has not been found</p>
      <?php } ?> <!-- Acton Admin-->