<? include ("sess.php");
if($user_sess  != "admin" ){
echo "<script>alert('Sorry .. !!..Modules Admin..!!')</script>";
echo "<script>window.location='index.php'</script>";exit();
} 
 ?>
 <meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<link rel="stylesheet" type="text/css" href="../style.css">
<style type="text/css">
<!--
#Layer1 {
	position:absolute;
	left:13px;
	top:48px;
	width:87px;
	height:28px;
	z-index:1;
}
#Layer2 {
	position:absolute;
	left:11px;
	top:67px;
	width:715px;
	height:159px;
	z-index:1;
}
.menuclick1 {background-color:#33CCFF; color: #FFFFFF; font-size:14px; font-family:Microsoft Sans Serif; font-weight:bold;}
.style11 {	font-family: "Microsoft Sans Serif";
	font-size: 14px; 
	color: #666666;
}
.style14 {color: #0000FF}
.style15 {color: #0033FF}
.style16 {color: #3300FF}
.style17 {color: #FFFFFF}
.style18 {
	font-size: 12px;
	font-weight: bold;
}
.style22 {font-weight: normal; font-size: 14px; text-align: center;}
-->
</style>

<table width="600" border="0" align="center">
  <tr>
    <td height="58"><br />
    <p>
    <a href="<? echo" index.php?module=Admin_";?>">
    <span class="menuclick">&nbsp;<span class="style14">จัดการข้อมูลประเภทหนังสือ&nbsp;</span></span></a>
    &nbsp; &nbsp;
        <a href="<? echo" index.php?module=Admin_2";?>">
    <span class="menuclick style15">&nbsp;<span class="style16">จัดการข้อมูลโปรแกรมวิชา&nbsp;</span></span></a> &nbsp;&nbsp;&nbsp; <a href="<? echo" index.php?module=Admin_staff";?>"> <span class="menuclick style16">&nbsp;จัดการข้อมูลเจ้าหน้าที่&nbsp;</span></a> &nbsp;&nbsp;&nbsp;</p></td>
  </tr>
</table><br />
<table width="600" border="0" align="center" height="250">
  <tr>
    <td><fieldset>
    <legend class="menuclick style17">จัดการข้อมูลประเภทหนังสือ </legend>
    <br />
    <form id="form1" name="form1" method="post" action="">
      <table width="523" border="0" align="center">
        <tr height="50">
          <td width="176" height="31" class="style11"><div align="right"><span class="style2Copy style18"><span class="textstyle3">เพิ่มข้อมูลประเภทหนังสือ</span></span> :</div></td>
          <td colspan="2"><div align="left">
              <label>
              <input name="name" type="text" id="name" size="50" value="<?=$edit?>" />
              </label>
          </div></td>
        </tr>
        <tr>
          <td height="36">&nbsp;</td>
          <td width="302"><label>
              <div align="left">
                  <? if($edit){ ?>
                <input type="hidden" name="data1" value="2" />
                <input name="button" type="submit" class="textstyle3" id="button" value="แก้ไขข้อมูล" />
               <? }else{ ?>
                   <input type="hidden" name="data1" value="1" />
                <input name="button" type="submit" class="textstyle3" id="button" value="เพิ่มข้อมูล" />
         <?       } ?>
              </div>
            </label></td>
          <td width="31">&nbsp;</td>
        </tr>
      </table>
      </form>
    <br />
    <table width="500" border="0" align="center">
      <tr>
        <td width="79" height="28" bgcolor="#FFFFCC" class="menuclick"><div align="center">รหัส</div></td>
        <td width="331" bgcolor="#FFFFCC" class="menuclick"><div align="center">ชื่อประเภทหนังสือ</div></td>
        <td width="76" bgcolor="#FFFFCC" class="menuclick"><div align="center">จัดการ</div></td>
      </tr>
      <? // echo  $real ;exit();


		    $sql_="select * from type_book ";
		//  echo $sql_  ; exit();
		  $re_=mysql_query($sql_);
		  
		while (  $data_=mysql_fetch_array($re_)){?>
      <tr>
        <td height="28" bgcolor="#FFFFCC" class="inputtext"><div align="center"><? echo"$data_[id]";?>

        </div></td>
        <td height="28" bgcolor="#FFFFCC" class="inputtext"><? echo"$data_[name]";?></td>
        <td bgcolor="#FFFFCC" class="inputtext"><div align="center">
          <div align="center"> <a href="<? echo"index.php?module=Admin_&id_name=$data_[id]&edit=$data_[name]";?>"> <img src="images/validate.png" width="16" height="16" border="0" /></a>
 &nbsp;<a href="<? echo" index.php?module=Admin_&id_name=$data_[id]&del=del";?>"><img src="images/cancel.gif" width="16" height="16" border="0" /></a></div></td>
      </tr> <?  }?>
    </table>
    </fieldset>
    </td>
  </tr>
</table>
  <? 
					  if($data1==1){
					  if($name==""){
					  echo "<script>alert('กรุณากรอกข้อมูล')</script>";
					  echo "<script>window.location=''index.php?module=Admin_''</script>";exit();
					  }
					  $sql="insert into type_book values ('','$name')";
				//	  echo $sql ; exit();
					  $re=mysql_query($sql);
					  if($re){
					  echo "<script>alert('ระบบได้เพิ่มข้อมูลของคุณเรียบร้อยแล้ว')</script>";
					  echo "<script>window.location='index.php?module=Admin_'</script>";exit();
					  }
					  }?>
 <? if($del=='del'){
$sql="delete from  type_book where id ='$id_name' ";
//echo $sql ; exit();
$re=mysql_query($sql);
			if($re){
			  echo "<script>alert('ระบบได้ทำการลบข้อมูลเรียบร้อยแล้ว')</script>";
				  echo "<script>window.location='index.php?module=Admin_'</script>";exit();
			}		
	}?>
 <? if($data1==2){
$sql="update   type_book  set name ='$name'  where id ='$id_name' ";
//echo $sql ; exit();
$re=mysql_query($sql);
			if($re){
			  echo "<script>alert('ระบบได้ทำการแก้ไขข้อมูลเรียบร้อยแล้ว')</script>";
				  echo "<script>window.location='index.php?module=Admin_'</script>";exit();
			}		
	}?>
