    <!-- Date Picker jQuery UI-->
    <link type="text/css" href="development-bundle/themes/base/ui.all.css" rel="stylesheet" />   

    <script type="text/javascript" src="development-bundle/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="development-bundle/ui/ui.core.js"></script>
    <script type="text/javascript" src="development-bundle/ui/ui.datepicker.js"></script>
    
    <script type="text/javascript" src="development-bundle/ui/i18n/ui.datepicker-id.js"></script>

    <script type="text/javascript"> 
      $(document).ready(function(){
        $("#tgl_mulai").datepicker({
          dateFormat  : "dd/mm/yy",        
          changeMonth : true,
          changeYear  : true          
        });      
        $("#tgl_selesai").datepicker({
          dateFormat  : "dd/mm/yy",        
          changeMonth : true,
          changeYear  : true          
        });      
      });
    </script>

<?php
// Apabila user belum login
if (empty($_SESSION['namauser']) AND empty($_SESSION['passuser'])){
  echo "<link href=\"../../css/style_login.css\" rel=\"stylesheet\" type=\"text/css\" />
        <div id=\"login\"><h1 class=\"fail\">Untuk mengakses modul, Anda harus login dulu.</h1>
        <p class=\"fail\"><a href=\"../../index.php\">LOGIN</a></p></div>";  
}
// Apabila user sudah login dengan benar, maka terbentuklah session
else{
  $aksi = "modul/mod_agenda/aksi_agenda.php";

  // mengatasi variabel yang belum di definisikan (notice undefined index)
  $act = isset($_GET['act']) ? $_GET['act'] : ''; 

  switch($act){
    // Tampil Agenda
    default:
      echo "

<div class=\"bg-secondary rounded h-100 p-4\">
<div class=\"table-responsive\">

      <h2>Long Course</h2>
        <p><input type=\"button\" value=\"Tambah\" onclick=window.location.href=\"?module=agenda&act=tambahagenda\" class=\"btn btn-sm btn-primary\"></p>
         <table class=\"table\">
          <thead>
          <tr><th>No</th><th>Gambar</th><th>Judul</th><th>Harga</th><th>Aksi</th></tr>
          </thead>
            <tbody>";
            
      if ($_SESSION['leveluser']=='admin'){
        $query  = "SELECT * FROM agenda ORDER BY id_agenda DESC";
        $tampil = mysqli_query($konek, $query);
      }
      else{
        $query  = "SELECT * FROM agenda WHERE username='$_SESSION[namauser]' ORDER BY id_agenda DESC";
        $tampil = mysqli_query($konek, $query);
      }
  
      $no = 1;
      while($r=mysqli_fetch_array($tampil)){
        $tgl_mulai   = tgl_indo($r['tgl_mulai']);
        $tgl_selesai = tgl_indo($r['tgl_selesai']);
        $tgl_posting = tgl_indo($r['tgl_posting']);
        
        echo "<tr style=\"border-color:#6C7293\"><td>$no</td>
                  
                  <td><img src=\"../foto_banner/$r[gambar]\" width=\"100\" ></td>
                  <td >$r[tema]</td>
                  <td >$r[tempat]</td>";
        
        
            echo "
                  <td><a href=\"?module=agenda&act=editagenda&id=$r[id_agenda]\" class=\"btn btn-sm btn-primary\">Edit</a> | 
                      <a href=\"$aksi?module=agenda&act=hapus&id=$r[id_agenda]\" class=\"btn btn-sm btn-primary\">Hapus</a>
              </tr>";
        $no++;
      }
      echo "</tbody>
        </table>


        </div></div>";
    break;

    case "tambahagenda":
      echo "<h2>Tambah Long Course</h2>
            <form method=\"POST\" enctype=\"multipart/form-data\" action=\"$aksi?module=agenda&act=input\">




 <div class=\"row mb-3\">
                                    <label for=\"inputEmail3\" class=\"col-sm-2 col-form-label\">Judul</label>

          <div class=\"col-sm-10\">

        <input type=\"text\" name=\"tema\" class=\"form-control\" style=\"background-color: #fff;\">

</div>
          </div>
          
          
          <div class=\"row mb-3\">
                                    <label for=\"inputEmail3\" class=\"col-sm-2 col-form-label\">Harga</label>

          <div class=\"col-sm-10\">

        <input type=\"text\" name=\"tempat\" class=\"form-control\" style=\"background-color: #fff;\">

</div>
          </div>
          
          


<div class=\"row mb-3\">
                                    <label for=\"inputEmail3\" class=\"col-sm-2 col-form-label\">Deskripsi</label>

          <div class=\"col-sm-10\">

        <textarea name=\"isi_agenda\" id=\"lokomedia\" style=\"width: 800px; height: 150px;\"></textarea>

</div>
          </div>






















          <div class=\"row mb-3\">
                                    <label for=\"inputEmail3\" class=\"col-sm-2 col-form-label\">Foto</label>

          <div class=\"col-sm-10\">

        <input type=\"file\" name=\"foto\" class=\"form-control bg-dark\">

</div>
          </div>


<br/>
         
         <div style=\"text-align: center !important;\">
          <tr><td colspan=\"2\"><input type=\"submit\" value=\"Simpan\" class=\"btn btn-primary\">
                                <input type=\"button\" value=\"Batal\" onclick=\"self.history.back()\" class=\"btn btn-primary\"></td></tr>
          </div>












            </form>";
    break;
  

    case "editagenda":
      if ($_SESSION['leveluser']=='admin'){
        $query = "SELECT * FROM agenda WHERE id_agenda='$_GET[id]'";
        $hasil = mysqli_query($konek, $query);
      }
      else{
        $query = "SELECT * FROM agenda WHERE id_agenda='$_GET[id] AND username='$_SESSION[namauser]''";
        $hasil = mysqli_query($konek, $query);
      }
    
        $r     = mysqli_fetch_array($hasil);
           
        $tgl_mulai   = ubah_tgl2($r['tgl_mulai']);
        $tgl_selesai = ubah_tgl2($r['tgl_selesai']);

      echo "<h2>Edit Long Course</h2>
            <form method=\"POST\" enctype=\"multipart/form-data\"  action=\"$aksi?module=agenda&act=update\">
            <input type=\"hidden\" name=\"id\" value=\"$r[id_agenda]\">


 <div class=\"row mb-3\">
                                    <label for=\"inputEmail3\" class=\"col-sm-2 col-form-label\">Judul</label>

          <div class=\"col-sm-10\">

        <input type=\"text\" name=\"tema\" value=\"$r[tema]\" class=\"form-control\" style=\"background-color: #fff;\">

</div>
          </div>
          
          
          
           <div class=\"row mb-3\">
                                    <label for=\"inputEmail3\" class=\"col-sm-2 col-form-label\">Harga</label>

          <div class=\"col-sm-10\">

        <input type=\"text\" name=\"tempat\" value=\"$r[tempat]\" class=\"form-control\" style=\"background-color: #fff;\">

</div>
          </div>
          
          
          
          


<div class=\"row mb-3\">
                                    <label for=\"inputEmail3\" class=\"col-sm-2 col-form-label\">Deskripsi</label>

          <div class=\"col-sm-10\">

        <textarea name=\"isi_agenda\"  id=\"lokomedia\" style=\"width: 800px; height: 150px;\">$r[isi_agenda]</textarea>

</div>
          </div>






















<div class=\"row mb-3\">
                                    <label for=\"inputEmail3\" class=\"col-sm-2 col-form-label\">Gambar</label>

          <div class=\"col-sm-10\" style=\"text-align: left !important;\">

        ";
          if ($r['gambar']!=''){
            echo "<img src=\"../foto_banner/$r[gambar]\" width=\"200\">";  
          }
          else{
            echo "Belum ada gambar";
          }
          echo"

</div>
          </div>


 <div class=\"row mb-3\">
                                    <label for=\"inputEmail3\" class=\"col-sm-2 col-form-label\">Ganti Gambar</label>

          <div class=\"col-sm-10\">

        <input type=\"file\" name=\"foto\" class=\"form-control bg-dark\">
<label for=\"formFileLg\" class=\"form-control bg-dark\" style=\"text-align: left !important;\"> - Apabila gambar tidak diganti, dikosongkan saja.</label>
</div>

          </div>














<br/>
         
         <div style=\"text-align: center !important;\">
          <tr><td colspan=\"2\"><input type=\"submit\" value=\"Simpan\" class=\"btn btn-primary\">
                                <input type=\"button\" value=\"Batal\" onclick=\"self.history.back()\" class=\"btn btn-primary\"></td></tr>
          </div>















           
            </form>";
    break;  
  }
}
?>
