<script>
function confirmdelete(delUrl) {
   if (confirm("Anda yakin ingin menghapus?")) {
      document.location = delUrl;
   }
}
</script>

<?php

//cek hak akses user
$cek=user_akses($_GET[module],$_SESSION[sessid]);
if($cek==1 OR $_SESSION[leveluser]=='admin'){

$aksi="modul/mod_partnership/aksi_partnership.php";
switch($_GET[act]){
  // Tampil Sekilas Info
  default:
	echo "<div id=main-content> 
      <div class=container_12> 
      <div class=grid_12> 
      <br/>
	  <a href='?module=partnership&act=tambah' class='button'>
	  <span>Tambah Partnership</span>
      </a></div>";
	  
    echo "<div class=grid_12> 
      <div class=block-border> 
      <div class=block-header> 
      <h1>Semua Partnership</h1>
      <span></span> 
      </div> 
      <div class=block-content> 
      <table id=table-example class=table>
      <thead> 
          <tr><th>No</th><th>Nama Partnership</th><th>Link</th><th>Aksi</th></tr>
	  </thead>
	  <tbody>";
    $tampil=mysql_query("SELECT * FROM partnership ORDER BY id_partnership DESC");
    $no=1;
    while ($r=mysql_fetch_array($tampil)){
      echo "<tr class=gradeX><td>$no</td>
                <td>$r[nama_partnership]</td>
                <td>$r[link_partnership]</td>
			
<td><a href=?module=partnership&act=edit&id=$r[id_partnership] class='with-tip'>
<center><img src='img/edit.png'></a>

	  <a href=javascript:confirmdelete('$aksi?module=partnership&act=hapus&id=$r[id_partnership]') class='with-tip'>
	  &nbsp;&nbsp;&nbsp;&nbsp;<img src='img/hapus.png'></center></a>			
		        </td></tr>";
    $no++;
    }
    echo "</tbody></table>";
    break;
  
  case "tambah":
    echo "<div id='main-content'>
		  <div class='container_12'>

		  <div class='grid_12'>
		  <div class='block-border'>
		  <div class='block-header'>
			<h1>TAMBAHKAN PARTNERSHIP</h1>
		  </div>
		  <div class='block-content'>
          <form method=POST action='$aksi?module=partnership&act=input' enctype='multipart/form-data'>
          
		  <p class=inline-small-label> 
		   <label for=field4>Nama </label>
		   <input type=text name='a' size=40>
		   </p> 

		  <p class=inline-small-label> 
		   <label for=field4>Link</label>
		   <textarea name='b'  style='width: 720px; height: 250px;'></textarea>
		   </p><br/>
   		  
		   <div class=block-actions> 
		   <ul class=actions-right> 
		   <li>
		   <a class='button red' id=reset-validate-form href='?module=partnership'>Batal</a>
		   </li> </ul>
		   <ul class=actions-left> 
		   <li>
			  <input type='submit' name='upload' class='button' value=' &nbsp;&nbsp;&nbsp;&nbsp; Simpan &nbsp;&nbsp;&nbsp;&nbsp;'>
		   </form>";
     break;
    
  case "edit":
    $edit = mysql_query("SELECT * FROM partnership WHERE id_partnership='$_GET[id]'");
    $r    = mysql_fetch_array($edit);

	    echo "<div id='main-content'>
		  <div class='container_12'>

		  <div class='grid_12'>
		  <div class='block-border'>
		  <div class='block-header'>
			<h1>EDIT PARTNERSHIP</h1>
		  </div>
		  <div class='block-content'>
          <form method=POST enctype='multipart/form-data' action=$aksi?module=partnership&act=update>
          <input type='hidden' name='id' value='$r[id_partnership]'>
		  
		   
		   <p class=inline-small-label> 
		   <label for=field4>Nama </label>
		   <input type=text name='a' value='$r[nama_partnership]' size=40>
		   </p> 

		   <p class=inline-small-label> 
		   <label for=field4>Link</label>
		   <textarea name='b'  style='width: 720px; height: 250px;'>$r[link_partnership]</textarea>
		   </p><br/>
   		  
		   <div class=block-actions> 
		   <ul class=actions-right> 
		   <li>
		   <a class='button red' id=reset-validate-form href='?module=partnership'>Batal</a>
		   </li> </ul>
		   <ul class=actions-left> 
		   <li>
			  <input type='submit' name='upload' class='button' value=' &nbsp;&nbsp;&nbsp;&nbsp; Update &nbsp;&nbsp;&nbsp;&nbsp;'>
		   </form>";
    break;  
}
//kurawal akhir hak akses module
} else {
	echo akses_salah();
}

?>
