<?php
// Manage Ukuran Lensa ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if ($_GET[module]=='ukuran'){
	if (isset($_POST[submit])){
		mysql_query("INSERT INTO rb_ukuran(ukuran) VALUES('$_POST[ukuran]')");
		echo "<script>document.location='ukuran.html';</script>";
	}

	echo "<div class='post_title' style='margin-bottom:10px; position:relative;'><b>List Nama lensa Pada Optik<hr></b></div>";
    echo "<form method=POST action=''>
			<input name='submit' style='float:right;' class='linkkk' type=submit value='Tambahkan'>
			<input type=text name='ukuran' style='float:right; width:20%; margin-right:7px;' placeholder=' Inputkan Nama Lensa...'>
          </form>
          <hr>";

	echo " <div id='container'>
			<div id='demo'>
<table class='display' id='example'>
	<thead>
          <tr bgcolor='#2e2e2e'>
			<th width='50px' >No</th>
			<th>Nama Lensa</th>
			<th style='width:60px; 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 Lensa</th>
			<th style='border: none;'></th>
		</tr>
	</tfoot>";
	echo "<tbody>";
	$no=1;
	$tampil = mysql_query("SELECT * FROM rb_ukuran ORDER BY ukuran ASC");
    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[ukuran]</td>
             <td><center>
			 <a class='linkkk' style='color:red' href=media.php?module=ukuran&delete=$r[id_ukuran] onclick=\"return confirm('Anda yakin ingin hapus data ini?')\">X</a></center></td></tr>";
			 $no++;
		}
		if (isset($_GET[delete])){
			mysql_query("DELETE FROM rb_ukuran WHERE id_ukuran='$_GET[delete]'");
			echo "<script>document.location='ukuran.html';</script>";
		}
echo "	</tbody>
 </table>
</div></div>";
}

// Manage Type Lensa ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
elseif ($_GET[module]=='type'){
	if (isset($_POST[submit])){
		mysql_query("INSERT INTO rb_type(type) VALUES('$_POST[type]')");
		echo "<script>document.location='type.html';</script>";
	}
	echo "<div class='post_title' style='margin-bottom:10px; position:relative;'><b>List atau Daftar Semua Type lensa Pada Optik<hr></b></div>";
    echo "<form method=POST action=''>
			<input name='submit' style='float:right;' class='linkkk' type=submit value='Tambahkan'>
			<input type=text name='type' style='float:right; width:20%; margin-right:7px;' placeholder=' Inputkan Nama type Lensa...'>
          </form>
          <hr>";

	echo " <div id='container'>
			<div id='demo'>
<table class='display' id='example'>
	<thead>
          <tr bgcolor='#2e2e2e'>
			<th width='50px' >No</th>
			<th>Type Lensa</th>
			<th style='width:60px; text-align:center;'>Action</th>
		</tr>
	</thead>
	<tfoot>
		<tr style='border: 2px solid #e3e3e3;'>
			<th style='border: none;'>No</th>
			<th style='border: none;'>Type</th>
			<th style='border: none;'></th>
		</tr>
	</tfoot>";
	echo "<tbody>";
	$no=1;
	$tampil = mysql_query("SELECT * FROM rb_type ORDER BY id_type 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[type]</td>

             <td><center>
			 <a class='linkkk' style='color:red' href=media.php?module=type&delete=$r[id_type]>X</a></center></td></tr>";
			 $no++;
		}
		if (isset($_GET[delete])){
			mysql_query("DELETE FROM rb_type WHERE id_type='$_GET[delete]'");
			echo "<script>document.location='type.html';</script>";
		}
echo "	</tbody>
 </table>
</div></div>";
}

// Manage Jenis Lensa ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
elseif ($_GET[module]=='jenis'){
	if (isset($_POST[submit])){
		mysql_query("INSERT INTO rb_jenis(jenis) VALUES('$_POST[jenis]')");
		echo "<script>document.location='jenis.html';</script>";
	}
	echo "<div class='post_title' style='margin-bottom:10px; position:relative;'><b>List atau Daftar Semua Jenis lensa Pada Optik<hr></b></div>";
    echo "<form method=POST action=''>
			<input name='submit' style='float:right;' class='linkkk' type=submit value='Tambahkan'>
			<input type=text name='jenis' style='float:right; width:20%; margin-right:7px;' placeholder=' Inputkan Nama Jenis Lensa...'>
          </form>
          <hr>";

	echo " <div id='container'>
			<div id='demo'>
<table class='display' id='example'>
	<thead>
          <tr bgcolor='#2e2e2e'>
			<th width='50px' >No</th>
			<th>Jenis Lensa</th>
			<th style='width:60px; text-align:center;'>Action</th>
		</tr>
	</thead>
	<tfoot>
		<tr style='border: 2px solid #e3e3e3;'>
			<th style='border: none;'>No</th>
			<th style='border: none;'>Jenis</th>
			<th style='border: none;'></th>
		</tr>
	</tfoot>";
	echo "<tbody>";
	$no=1;
	$tampil = mysql_query("SELECT * FROM rb_jenis ORDER BY id_jenis 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[jenis]</td>

             <td><center>
			 <a class='linkkk' style='color:red' href=media.php?module=type&delete=$r[id_jenis]>X</a></center></td></tr>";
			 $no++;
		}
		if (isset($_GET[delete])){
			mysql_query("DELETE FROM rb_jenis WHERE id_jenis='$_GET[delete]'");
			echo "<script>document.location='jenis.html';</script>";
		}
echo "	</tbody>
 </table>
</div></div>";
}

elseif ($_GET[module]=='settinglensa'){
	$lensa=mysql_query("SELECT * FROM rb_setting_lensa where id_setting=1");
	$l=mysql_fetch_array($lensa);
	
	    echo "<div class='post_title' style='margin-left:20%;'><b>Setting Lensa untuk Transaksi Penjulan Optik.</b></div><hr><br/><br/>
          <form method=POST action='aksi-setting.html' enctype='multipart/form-data'>
          <center><table width='60%' align='center'>
		  <tr><td width=100 class='td'>SPH</td>     <td class='td' width='20px'>:</td><td class='td'><input type=text name='sph_dari' value='$l[sph_dari]' size=60 style='width:40%; margin-right:5px;'> s/d  
																									  <input type=text name='sph_sampai' value='$l[sph_sampai]' size=60 style='width:40%; margin-left:7px;'></td></tr>
		  <tr><td width=130 class='td'>CYL</td>     <td class='td' width='20px'>:</td><td class='td'><input type=text name='cyl_dari' value='$l[cyl_dari]' size=60 style='width:40%; margin-right:5px;'> s/d  
																									  <input type=text name='cyl_sampai' value='$l[cyl_sampai]' size=60 style='width:40%; margin-left:7px;'></td></tr>
		  <tr><td width=130 class='td'>AXS</td>     <td class='td' width='20px'>:</td><td class='td'><input type=text name='axs_dari' value='$l[axs_dari]' size=60 style='width:40%; margin-right:5px;'> s/d  
																									  <input type=text name='axs_sampai' value='$l[axs_sampai]' size=60 style='width:40%; margin-left:7px;'></td></tr>	
		  <tr><td width=130 class='td'>ADD</td>     <td class='td' width='20px'>:</td><td class='td'><input type=text name='add_dari' value='$l[add_dari]' size=60 style='width:40%; margin-right:5px;'> s/d  
																									  <input type=text name='add_sampai' value='$l[add_sampai]' size=60 style='width:40%; margin-left:7px;'></td></tr>																									
																									 


		  <tr><td colspan=3 class='td'><br/><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><br/><br/><br/><br/>";
	
}

elseif ($_GET[module]=='aksisetting'){
    mysql_query("UPDATE rb_setting_lensa SET sph_dari 	 = '$_POST[sph_dari]',
										   sph_sampai 	 = '$_POST[sph_sampai]',
										   cyl_dari  	 = '$_POST[cyl_dari]',
										   cyl_sampai  	 = '$_POST[cyl_sampai]',
										   axs_dari      = '$_POST[axs_dari]',
										   axs_sampai 	 = '$_POST[axs_sampai]',
										   add_dari  	 = '$_POST[add_dari]',
										   add_sampai    = '$_POST[add_sampai]'
									 WHERE id_setting    = '1'");
	
	echo "<script>window.alert('Berhasil Update Data Lensa.');
				window.location='setting-lensa.html'</script>";	
}