<? 
require_once "include/application.php"; 
require_once "include/paginator.php";
require_once "include/paginator_html.php";
require_once "include/function.php";


if($_SESSION["egoLevel"]<>"M")
	print("<script type='text/javascript'>location.href='index.php'</script>");


?>

<!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 rel="stylesheet" type="text/css" href="sddm.css" >
<script src="include/validation.js" type="text/javascript"></script>
<title><? echo TITLE?></title>
</head>
<body>

<table width="1024" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#f1efd8">
  <tr>
    <td  colspan="2" align="center"><? require_once "include/header.php"; ?></td>
  </tr>
  <tr>
    <td colspan="2" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td width="185" valign="top" bgcolor="e6f3f9">
	
<? require_once "include/columnLeft.php"; ?>	</td>
    <td width="834" valign="top">
	<form name="form" method="post" action="<?=$PHP_SELF ?>" >
	  <table width="820" border="0" align="center" cellpadding="0" cellspacing="0">
      
      <tr>
        <td width="10"><img src="images/border/03.gif" width="10" height="9" alt="" /></td>
        <td width="676"><img src="images/border/04.gif" alt="" width="100%" height="9" /></td>
        <td width="14"><img src="images/border/05.gif" width="14" height="9" alt="" /></td>
        </tr>
      <tr>

        <td valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="100%" height="30" class="TitleH3">Staff Setup </td>
          </tr>
          <tr>
            <td height="1" bgcolor="#B8ED83"></td>
          </tr>
          <tr>
            <td ><? echo "<div class='Msg'>$action_msg</div>" ?>&nbsp;</td>
          </tr>

        </table>
          <table border="0" cellpadding="1" width="100%" cellspacing="2" class="small">

            <tr>
              <td height="16" colspan="8" class="text12"><span class="TextH1">
                <select name="sType" id="sType">
                  <option value="Name">Name</option>
                  <option value="NewIC">New IC No</option>
                  <option value="HP">Contact</option>
                                </select>
                <input name="sReferral" type="text" id="sReferral" value="<? echo $sReferral ?>" />
                <input name="btnSearch" type="submit" class="btn" id="btnSearch" value="Search"/>
                <? stayfocus("form","sType",$sType) ?>
              </span></td>
            </tr>
            <tr>
              <td height="17" colspan="8" class="text12"><input type="button" name="btnAdd" value="Add" class="btn" onclick="location.href='addStaff.php'"/></td>
            </tr>
            <tr>
              <td width="237" height="23" background="images/tab-btns.gif" class="TextH1"><div align="center">Name</div></td>
              <td width="163" background="images/tab-btns.gif" class="TextH1"><div align="center">New IC</div></td>
              <td width="153" background="images/tab-btns.gif" class="TextH1"><div align="center">Contact No </div></td>
              <td width="146" background="images/tab-btns.gif" class="TextH1"><div align="center">Position</div></td>
              <td width="74" background="images/tab-btns.gif">&nbsp;</td>
            </tr>
            <?
	
	$sql="select * from staff";
	if($sReferral){
		if($sType=="Name")$sql.=" where s_name like '%$sReferral%'";			
		else if($sType=="NewIC")$sql.=" where s_ic like '%$sReferral%'";				
		else if($sType=="HP")$sql.=" where s_contact like '%$sReferral%'";			
	}	
	$result=mysql_query($sql);
	$num_rows=mysql_num_rows($result);
	
	$pass="so=1&sReferral=$sReferral&sType=$sType";
    $a =& new Paginator_html($_GET['page'],$num_rows,$pass);	
	$a->set_Limit(15);
	$a->set_Links(10);  	
	$limit1 = $a->getRange1();  
	$limit2 = $a->getRange2();  
	$sql.=" limit $limit1,$limit2 ";	
	$result=mysql_query($sql) or die(mysql_error());
	
	while($myrow=MySQL_fetch_array($result,MYSQL_ASSOC))
	{
		echo "<tr bgcolor='#ffffff' class='TextH1'>"; 
		$id=$myrow["s_id"];
	    echo "<td height='20' align='center' class='text12'>".$myrow["s_name"]."</td>";	  				
	    echo "<td align='center' class='text12'>".$myrow["s_ic"]."</td>";	  				
	    echo "<td align='center' class='text12'>".$myrow["s_contact"]."</td>";	  								
	    echo "<td align='center' class='text12'>".$myrow["s_position"]."</td>";	  										
	    echo "<td align='center' class='text12'><a href='editStaff.php?id=$id'><img src='images/view.jpg' border='0'></a>";
		echo "</td>";	  								
		echo "</tr>";

	}

?>
            <tr>
              <td colspan="8" class="TextH2"><? echo "Total Record :[".$num_rows."] "; if($num_rows)$a->previousNext();?></td>
            </tr>
          </table></td>

      </tr>
 
    </table>
	  <br />
	</form>	</td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#333333"><div align="center"><span class="Footer">
      <br />
      <? require_once "footer.php"; ?>
    </span></div></td>
  </tr>
</table>
</body>
</html>
