<?php
session_start
();
 if (
session_is_registered("valid_user"))
 {

include(
"../include/FunctionDB.php");
include(
"../include/Function.php");
include(
"admin_menu.php");
 
ConnectDB();
$strSQL "SELECT * FROM  permission_tb";
if (! 
$Page)
$Page 1;
$Pre_Page $Page 1;
$Next_Page $Page +1;
$Per_Page 20;
$result mysql_query($strSQL);

$Page_start = ($Per_Page*$Page) - $Per_Page;
$Num_Rows mysql_num_rows($result);

if( 
$Num_Rows <= $Per_Page)
   
$Num_Pages 1;
else if ((
$Num_Rows $Per_Page) == 0)
       
$Num_Pages = ($Num_Rows $Per_Page);
else
        
$Num_Pages = ($Num_Rows $Per_Page) + 1;
$Num_Pages = (int)$Num_Pages;

if (( 
$Page $Num_Pages) || ($Page 0))
  echo
"Page $Page More than $Num_Pages";
$strSQL .=" LIMIT $Page_start,$Per_Page" ;
$result mysql_query($strSQL); 
///////////////////////////////////////////////////////////////////////////////////
$num mysql_num_rows$result );
//$count = 0;
?>
<meta http-equiv="Content-Type" content="text/html; charset=TIS-620">
<link href="../source/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {
    font-size: 14px;
    font-weight: bold;
}
-->
</style>
<table width="809" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td width="809"><br>
          <fieldset>
            <legend><font size="2" color="<?php echo $GLOBALS["COLOR_FONT_3"]; ?>"><a href="adminmenu.php" >หน้าหลัก</a> <img src="../picture/ico3.gif" width="10" height="10" border="0" align="absmiddle"></font><font size="2" color="<?php echo $GLOBALS["COLOR_FONT_3"]; ?>"><a href="adminmenu.php">ข้อมูลผู้ใช้งานระบบ</a></font><font size="2" color="<?php echo $GLOBALS["COLOR_FONT_3"]; ?>"><img src="../picture/ico3.gif" width="10" height="10" border="0" align="absmiddle" />แสดงระดับการใช้งานระบบ</font></legend>
            <form id="form1" name="form1" method="post" action="InsertUser.php">
              <p align="left"><font size="2" face="Tahoma"><img src="../picture/previous.gif" onclick="window.history.back()"  width="85" height="22" border="0" /></font></p>
              <table width="97%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#AFD2F5" style="border:0px solid gray">
                <tr bordercolor="#003366" bgcolor="#AFD2F5">
                  <td width="28" height="17" align="center"><span class="style1"><font color="#003366" face="Tahoma">No.</font></span></td>
                  <td width="115" align="center"><span class="style1"><font color="#003366" face="Tahoma">ระดับการใช้งาน</font></span></td>
                  <td width="312" align="center" bgcolor="#AFD2F5"><span class="style1"><font color="#003366" face="Tahoma">url 
                    ที่ Link</font></span></td>
                  <td width="321" align="center" bgcolor="#AFD2F5"><span class="style1"><font face="Tahoma">ผู้ใช้</font></span></td>
                </tr>
                <?php
$i 
1;
 while(
$row mysql_fetch_array($result))
 {

     if(
$count==0)
     {
?>
                <tr >
                  <td align="center" bordercolor="#D1D1D1" bgcolor="#FFFFFF" ><strong><font color="#003300" size="2" face="Tahoma">
                    <?=$i?>
                  </font></strong></td>
                  <td align="center" bordercolor="#DFDFDF" bgcolor="#FFFFFF" ><div align="center"><font color="#003300" size="2" face="Tahoma"> <? echo"$row[permision]";?> </font></div></td>
                  <td bordercolor="#DFDFDF" bgcolor="#FFFFFF"><div align="left"><font color="#000000" size="2" face="Tahoma"> <?php echo $row["url"?></font></div></td>
                  <td bordercolor="#DFDFDF" bgcolor="#FFFFFF"><div align="left"><font color="#000000" size="2" face="Tahoma"><?php echo $row["description"?></font></div></td>
                </tr>
                <?
    $count
=1;
     }
else
{
?>
                <tr bgcolor="#eeeeee">
                  <td align="center" bordercolor="#D1D1D1" bgcolor="#FFFFFF" ><strong><font color="#003300" size="2" face="Tahoma">
                    <?=$i?>
                  </font></strong></td>
                  <td height="18" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF" ><div align="center"><font color="#003300" size="2" face="Tahoma"> <? echo"$row[permision]";?> </font></div></td>
                  <td bordercolor="#FFFFFF" bgcolor="#FFFFFF"><div align="left"><font color="#000000" size="2" face="Tahoma"> <?php echo $row["url"?></font></div></td>
                  <td bordercolor="#FFFFFF" bgcolor="#FFFFFF"><div align="left"><font color="#000000" size="2" face="Tahoma"><?php echo $row["description"?></font></div></td>
                </tr>
                <?
$count
=0;
}
$i++;
 }    
CloseDB();
?>
                <tr bgcolor="#AFD2F5">
                  <td colspan="4" align="center" bgcolor="#FFFFFF"><div align="center"><font color="#000000" size="2" face="Tahoma">ทั้งหมด</font><font color="#003399" size="2" face="Tahoma"> <? echo $num ?> </font><font color="#000000" size="2" face="Tahoma">รายการ&nbsp;</font> </div></td>
                </tr>
              </table>
            </form>
          </fieldset><br>
        <font color="<?php echo $GLOBALS["COLOR_FONT_3"];?>" size="2"><b>หมายเหตุ :</b> ใช้เมาส์คลิก<br>
      </font></td>
    </tr>
</table>
<?php 
    
}
else
{
    echo
"<body bgcolor=\"#CCCCCC\">";
     echo
"<meta http-equiv=\"refresh\" content=\"3;URL=../logout.php\" target=\"mainFrame\">\n";
     echo
"<center>";
      echo
"<br><br><br><b><font face=\"Tahoma\" size=\"4\" color=\"#FF0000\">Please Login</font> </b><br>";
      echo
"<br><br><font face=\"Tahoma\" size=\"10\" color=\"#000000\"> ERROR 404 PERMISION DENY</font><br>";
      echo
"<br><font face=\"Tahoma\" size=\"4\" color=\"#000000\"> คุณไม่มีสิทธ์ใช้งาน</font>";
      echo
"</center>";
      echo
"</body>";

?>