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


<?php
session_start();
 if (empty($_SESSION['username']) AND empty($_SESSION['passuser'])){
 
  echo "
  <link href='css/zalstyle.css' rel='stylesheet' type='text/css'>";

  echo "
  </head>
  <body class='special-page'>
  <div id='container'>
  <section id='error-number'>
  
  <img src='img/lock.png'>
  <h1>MODUL TIDAK DAPAT DIAKSES</h1>
  
  <p><span class style=\"font-size:14px; color:#ccc;\">Untuk mengakses modul, Anda harus login dahulu!</p></span><br/>
  
  </section>
  
  <section id='error-text'>
  <p><a class='button' href='index.php'>&nbsp;&nbsp; <b>ULANGI LAGI</b> &nbsp;&nbsp;</a></p>
  </section>
  </div>";
  
  }
  else{
  
//cek hak akses user
$cek=user_akses($_GET[module],$_SESSION[sessid]);
if($cek==1 OR $_SESSION[leveluser]=='admin'){

$aksi="modul/mod_ym/aksi_ym.php";
switch($_GET[act]){
  // Tampil YM
  default:
   
	 
   echo "
   <div id='main-content'>
   <div class='container_12'>
   <div class=grid_12> 
   <br/>
   <a href='?module=ym&act=tambahym' class='button'>
   <span>Tambahkan User</span>
   </a></div>	 

	 
    <div class=grid_12> 
    <div class=block-border> 
    <div class=block-header> 
    <h1>Yahoo Messenger </h1>
    <span></span> 
    </div> 
    <div class='block-content'>
		  
    <table id='table-example' class='table'>			  
		  
    <thead><tr>
    <th><center>No</center></th>
	<th>Nama</th>
	<th>Username</th>
	<th>YM Icon</th>
	<th>Aksi</th>
    </thead>
    <tbody>";	 
	 	 		  
  if ($_SESSION[leveluser]=='admin'){
      $tampil = mysql_query("SELECT * FROM mod_ym ORDER BY id DESC");
    }
    else{
      $tampil=mysql_query("SELECT * FROM mod_ym 
                           WHERE username='$_SESSION[namauser]'       
                           ORDER BY id DESC");
    }	
	
    $no=1;
    while ($r=mysql_fetch_array($tampil)){
	
			 
 echo "<tr class=gradeX> 
  <td><center>$no</center></td>
  <td>$r[nama]</td>
  <td>$r[username]</td>
  <td>$r[ym_icon]</td>
  <td width=80>
  
  <table>
  <tr>
  
  <td>
  <a href=?module=ym&act=editym&id=$r[id] title='Edit'  rel=tooltip-top  class='with-tip'>
  <center><img src='img/edit.png'></a>
  </td>
   
  <td>
  <a href=javascript:confirmdelete('$aksi?module=ym&act=hapus&id=$r[id]') title='Hapus'  
  rel=tooltip-top  class='with-tip'>
  <img src='img/hapus.png'></center></a> 
  </td>
  
  </tr>  
  </table>
   
  </td></tr>";		
  			 
   $no++;}
	  
	  
    echo "</table>";
	echo "";
    break;
  
  // Form Tambah YM
  case "tambahym":
  
   echo "
   <div id='main-content'>
   <div class='container_12'>

   <div class='grid_12'>
   <div class='block-border'>
   <div class='block-header'>
   
   <h1>TAMBAHKAN USER Yahoo Messenger</h1>
   </div>
   <div class='block-content'>	
   <form method=POST action='$aksi?module=ym&act=input'>
		  
   <p class=inline-small-label> 
   <label for=field4>Nama</label>
  <input type=text name='nama' size=25>
   </p>          
   
   <p class=inline-small-label> 
   <label for=field4>Username</label>
  <input type=text name='username' size=25>
   </p>    
   
   <p class=inline-small-label> 
   <label for=field4>Ym Icon</label>
  <input type=text name='icon' size=25>
   </p>  

      <div class=block-actions> 
      <ul class=actions-right> 
      <li>
      <a class='button red' id=reset-validate-form href='?module=ym'>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;'>
	  </li> </ul>
	  </form>";
	  
     break;
  
  // Form Edit YM  
  case "editym":
    $edit=mysql_query("SELECT * FROM mod_ym WHERE id='$_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 USER Yahoo Messenger</h1>
   </div>
   <div class='block-content'>		
   <form method=POST action=$aksi?module=ym&act=update>
   <input type=hidden name=id value='$r[id]'>
		  
   <p class=inline-small-label> 
   <label for=field4>Nama</label>
  <input type=text name='nama' value='$r[nama]' size=25>
   </p>		
		  
   <p class=inline-small-label> 
   <label for=field4>Username</label>
  <input type=text name='username' value='$r[username]' size=25>
   </p>		
   
   <p class=inline-small-label> 
   <label for=field4>Ym Icon</label>
  <input type=text name='icon' value='$r[ym_icon]' size=25>
   </p>	
 
	 <div class=block-actions> 
      <ul class=actions-right> 
      <li>
      <a class='button red' id=reset-validate-form href='?module=ym'>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;'>
	  </li> </ul>
	  </form>";
 	  
    break;  
}
//kurawal akhir hak akses module
} else {
	echo akses_salah();
}
}
?>
