<?php
// Manage Sales ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if ($_GET[module]=='sales'){
	echo "<div class='post_title' style='margin-bottom:10px; position:relative;'><b>List atau Daftar Semua Sales Pada Optik<hr></b></div>";
    echo "<input class='linkkk' type=button value='Tambah Sales' onclick=\"window.location.href='tambah-sales.html';\">
          <hr>";

	echo " <div id='container'>
			<div id='demo'>
<table class='display' id='example'>
	<thead>
          <tr bgcolor='#2e2e2e'>
			<th width='20px'>No</th>
			<th>Nama Sales</th>
			<th>No.Telepon/HP</th>
			<th>Alamat Lengkap</th>
			<th>Keterangan</th>
			<th style='width:100px; text-align:center;'>Action</th>
		</tr>
	</thead>
	<tfoot>
		<tr style='border: 2px solid #e3e3e3;'>
			<th style='border: none;'>No</th>
			<th style='border: none;'>Nama Sales</th>
			<th style='border: none;'>No.Telepon/HP</th>
			<th style='border: none;'>Alamat Lengkap</th>
			<th style='border: none;'>Keterangan</th>
			<th style='border: none;'></th>
		</tr>
	</tfoot>";
	echo "<tbody>";
	$no=1;
	$tampil = mysql_query("SELECT * FROM rb_sales ORDER BY id_sales DESC");
    while($r=mysql_fetch_array($tampil)){
	  if(($no % 2)==0){ $warna="#ffffff"; }else{ $warna="#E1E1E1"; }
       echo "<tr bgcolor=$warna><td class='read_only'>$no</td>
             <td>$r[nama_sales]</td>
		     <td>$r[no_telpon]</td>
		     <td>$r[alamat]</td>
			 <td>$r[keterangan]</td>
             <td><center><a class='linkkk' href=edit-sales-$r[id_sales].html>Edit</a>
			 <a class='linkkk' style='color:red' href=aksi_sales.php?act=hapus&id=$r[id_sales]  onclick=\"return confirm('Anda yakin ingin hapus data ini?')\">X</a></center></td></tr>";
			 $no++;
		}
echo "	</tbody>
 </table>
</div></div>";
}

elseif ($_GET[module]=='tambahsales'){
echo "<div class='post_title' style='margin-left:20%;'><b>Tambahkan Sales Baru.</b></div><hr><br/>
          <form method=POST action='aksi_sales.php?act=input'>
          <center><table width='60%'>
          <tr><td width='160px' class='td'><br>Nama Sales</td> <td class='td'><br/>:</td><td class='td'> <br><input type=text name='nama_sales' style='width:50%'></td></tr>  
          <tr><td class='td'>No.Telepon/HP</td>   <td class='td'>:</td><td class='td'> <input type=text name='no_telp' style='width:50%'></td></tr>
		  <tr><td class='td'>Alamat Lengkap</td>   <td class='td'>:</td><td class='td'> <textarea name='alamat_lengkap' style='width:100%; height:60px;'></textarea></td></tr>
		  <tr><td class='td'>Keterangan</td>   <td class='td'>:</td><td class='td'> <textarea name='keterangan' style='width:100%; height:60px;'></textarea></td></tr>
		  
          <tr><td class='td' colspan=3><br/><input class='button-reply' type=button value=Batal onclick=self.history.back()>
							<input class='button-reply' type=submit value=Simpan></td></tr>
          </table></center></form>";
}

elseif ($_GET[module]=='editsales'){
$edit=mysql_query("SELECT * FROM rb_sales WHERE id_sales='$_GET[id]'");
    $r=mysql_fetch_array($edit);
    echo "<div class='post_title' style='margin-left:20%;'><b>Edit Data '$r[nama_sales]' (sales).</b></div><hr style='color:#e3e3e3;'><br/>
		 <div class='h_line'></div>
          <form method=POST action='aksi_sales.php?act=update'>
          <input type=hidden name=id value='$r[id_sales]'>
          <center><table width='60%'>
          <tr><td width='160px' class='td'><br>Nama Sales</td> <td class='td'><br/>:</td><td class='td'><br> <input type=text name='nama_sales' size=30  value='$r[nama_sales]' style='width:50%'></td></tr>
          <tr><td class='td'>No.Telepon/HP</td>   <td class='td'>:</td><td class='td'> <input type=text name='no_telp' size=30 value='$r[no_telpon]' style='width:50%'></td></tr>
		  <tr><td class='td'>Alamat Lengkap</td>   <td class='td'>:</td><td class='td'> <textarea name='alamat_lengkap' style='width:100%; height:60px;'>$r[alamat]</textarea></td></tr>
		  <tr><td class='td'>Keterangan</td>   <td class='td'>:</td><td class='td'> <textarea name='keterangan' style='width:100%; height:60px;'>$r[keterangan]</textarea></td></tr>";
   
    echo "<tr><td class='td' colspan=3><br/><input class='button-reply' type=button value=Batal onclick=self.history.back()>
									   <input class='button-reply' type=submit value=Update></td></tr>
          </table></center></form>";     
}