<?php session_start();?>
<?php require_once('open_connection.php');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href='css/imagetable.css' rel='stylesheet' type='text/css' />
<title>Add Designation</title>
</head>
<body>

<body bgcolor="#333333"> 
<table width="100%" border="0" align="center">
<tr>
<td width="15%" bgcolor="#333333">&nbsp;</td>
<td width="70%" align="center" bgcolor="#FFFFFF" > 

<table width="100%" border="0" align="center">

<!-- row for header picc 1 -->
<tr>  
     <th width="100%" colspan="4"><img src="images/header-cox.jpg" width="100%" height="100%"></th>
</tr>
<!-- row for header picc 2 -->
<tr>
     <th width="100%" colspan="4"><img src="images/eoffice-cox.jpg" width="100%" height="15%"></th>
</tr>
<!-- calling frame -->	
<tr>
    <td colspan="1" width="10%" align="center"><?php include("header.php");?></td>
	
</tr>
<tr>

<td colspan="3" width="90%" align="center" >
<tr><td>&nbsp;</td></tr>
<tr><td align="left">
<?php 
if (!isset($_SESSION['isLogged_in']))
{
	//$_SESSION['isLogged_in'] = FALSE;
}
echo 'Welcome: ' . $_SESSION['username'];
if (isset($_GET['page'])) 
		{ 
			$page = $_GET['page']; 
		} 
		else 
		{ 
			$page = 1; 
		}
		$start_from = ($page-1) * 20; 

$listcat = mysql_query("SELECT designation_name FROM tbl_ref_designation ORDER BY designation_name ASC LIMIT $start_from, 20");
?>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<!--?php
								echo 'Welcome: ' . $_SESSION['username'];
								?-->
							<a href="staff_logout.php"><img src="images/logout3.gif" align="right"></a>
							</td>
</tr>
<tr><td>
<div align="center">

  <table width="470" class="imagetable">
    <form name="adddesignation" method="post" >
      <tr>
        <td>Designation: </td>
        <td><label>
          <input name="designation_name" type="text" size="50" />
        </label>
		
	  <tr>
        <td colspan="2" align="center"><label>
		
          <input type="submit" name="save" class="myButton" value="Save" />&nbsp;
		  <input type="button" class="myButton"  value="BACK" onClick="window.location.href='staff_admin.php'">
        </label></td>
		<?php

            if (isset($_POST['save'])){
			 		$designation_id=$row['designation_id'];
					$designation_name=$_POST['designation_name'];
	$query = mysql_query("SELECT * FROM tbl_ref_designation WHERE designation_name = '". $designation_name ."' "); 
if (mysql_num_rows($query) > 0) 
{ 
     echo 'Designation Name already Exist'; 
}
else
{
				$add="insert into tbl_ref_designation (designation_id,designation_name) 
                    values('$designation_id ','$designation_name')";
					
                 $result= mysql_query($add);
		
		 	if ($result){
				echo "<script language='javascript'>Succesfull</script>";}
			else{
				echo 'Unsuccessful, please try again';}
    }
	}
        ?>
    </form>
  </table>
  <p><table width="550" class="imagetable">

      <tr>
	  <th align="center"><strong>No</strong></th>
        <th align="center"><strong>Designation</strong></th>
      </tr>
	    <?php 
	$count = 1;
	while($row = mysql_fetch_array($listcat)){
	$no++;
	?>
      <tr>
	    <td><div align="center"><?php echo $no+$start_from;?></div></td>
        <td><?php echo $row['designation_name']?></td>
      </tr>
      <?php $count = $count + 1; }
 ?>
  </table>
  <?php 
		$total_records = mysql_num_rows(mysql_query("SELECT * FROM tbl_ref_designation")); 
		$total_pages = ceil($total_records /20); 
		 
		for ($i=1; $i<=$total_pages; $i++) 
		{ 
			echo "<a href='add_designation.php?page=".$i."'> [".$i."]</a> "; 
		} 
		?>
   </p>
</div>
<tr>
	<th align="center" colspan="4">
	<img src="images/footer-cox.jpg" width="100%" height="70%">
		
	</th>
</tr>

<!--- end for ruang kerja 80% -->
</table>

</td>

<td width="15%" bgcolor="#333333">&nbsp;</td>

</tr>

<!--- end for ruang kerja 100% -->
</table>
</body>
</html>
