<?php

include("./include/FunctionDB.php");
include(
"admin_menu.php");
include(
"./include/Function.php");
ConnectDB();
$sql "Select * From personal_tb";// Where   Faculty_code='$Faculty_code' "; 
$result mysql_query($sql) or die(" Error").mysql_error();
$num mysql_num_rows($result);
$rs mysql_fetch_array($result); 
$strSQL "SELECT * FROM faculty_tb";
$result mysql_query($strSQL); 
$total mysql_num_rows$result );
?> 

<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}
-->
</style>
<table width="822" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td width="828" ><br> 
          <fieldset>
            <legend><font size="2" color="<?php echo $GLOBALS["COLOR_FONT_3"]; ?>"><a href="index.php">หน้าหลัก</a> <img src="./picture/ico3.gif" width="10" height="10" border="0" align="absmiddle">ค่าตอบแทนบุคลากรจำแนกตามรายหน่วยงาน</font></legend>
            <label>
  <form id="form1" name="form1" method="post" action="">
    <p><font size="2" face="Tahoma"><img src="./picture/previous.gif" onclick="window.history.back()"  width="85" height="22" border="0" /></font></p>
    <table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" style="border:0px solid gray">
      
      <tr bgcolor="#DBE4E9">
        <td height="25" colspan="6" bgcolor="#FFFFFF"><div align="center" class="style1"><font color="#003366" face="Tahoma">ค่าตอบแทนบุคลากรจำแนกตามหน่วยงานตามประเภทบุคลากร</font></div></td>
      </tr>
      
      <tr bgcolor="#CCCCCC">
        <td width="23" height="21" align="center" bgcolor="#eeeeee"><span class="style1"><font color="#000000" face="Tahoma">No.</font></span></td>
        <td width="441" align="center" bgcolor="#eeeeee"><span class="style1"><font color="#000000" face="Tahoma">ชื่อภาควิชา/หน่วยงาน</font></span></td>
        <td width="89" align="center" bgcolor="#eeeeee"><span class="style1"><font face="Tahoma">ข้าราชการ</font></span></td>
        <td width="80" align="center" bgcolor="#eeeeee"><span class="style1"><font face="Tahoma">ลูกจ้างประจำ</font></span></td>
        <td width="85" align="center" bgcolor="#eeeeee"><span class="style1"><font face="Tahoma">ลูกจ้างชั่วคราว</font></span></td>
        <td width="87" align="center" bgcolor="#eeeeee"><span class="style1"><font face="Tahoma">รวมทั้งหมด</font></span></td>
      </tr>
      <?php
$i 
1;
 while(
$row mysql_fetch_array($result))
 {

     if(
$count==0)
     {
?>
      <tr bordercolor="#CCCCCC" bgcolor="#EEEEEE" onmouseover="this.style.backgroundColor='#FCFCF3'" onmouseout="this.style.backgroundColor='#EEEEEE'" >
        <td align="center" bgcolor="#FFFFFF" ><font color="#000000" size="2" face="Tahoma">
          <?=$i?>
        </font></td>
        <td align="center" bgcolor="#FFFFFF" ><div align="left"><font color="#0033CC" size="2" face="Tahoma"><a href="PersonalSalary.php?Faculty_code=<?=$row["Faculty_code"]?>&Person_type=1" title="Click to see Detail"class="d" >
          <?=$row["Faculty_name"]?>
        </a></font><font color="#000000" size="2" face="Tahoma">&nbsp;&nbsp;
        <?=$row["Faculty_nameE"]?>
        </font></div>          <div align="left"></div></td>
        <td align="center" bgcolor="#FFFFFF" ><div align="right"><strong><font color="#993333" size="2" face="Tahoma">
          <?php
          $Faculty_code 
$row[Faculty_code];
          
$sql "Select Sum(Salary_1) as Sum From personal_tb   Where  Faculty_code='$Faculty_code' and  Person_type='1' ";
         
$result1 mysql_query($sql) or die("Error".mysql_error());
         
$rss1 mysql_fetch_array($result1);
         echo 
number_format($rss1['Sum'],2,'.',','); 
        
        
         
?>
        </font></strong></div></td>
        <td align="center" bgcolor="#FFFFFF" ><div align="right"><strong><font color="#993333" size="2" face="Tahoma">
          <?php
          $Faculty_code 
$row[Faculty_code];
          
$sql "Select Sum(Salary_1) as Sum From personal_tb   Where  Faculty_code='$Faculty_code' and  Person_type='3' ";
         
$result1 mysql_query($sql) or die("Error".mysql_error());
         
$rss1 mysql_fetch_array($result1);
         echo 
number_format($rss1['Sum'],2,'.',','); 
        
        
         
?>
        </font></strong></div></td>
        <td align="center" bgcolor="#FFFFFF" ><div align="right"><strong><font color="#993333" size="2" face="Tahoma">
          <?php
          $Faculty_code 
$row[Faculty_code];
          
$sql "Select Sum(Salary_1) as Sum From personal_tb   Where  Faculty_code='$Faculty_code' and  Person_type='4' ";
         
$result1 mysql_query($sql) or die("Error".mysql_error());
         
$rss1 mysql_fetch_array($result1);
         echo 
number_format($rss1['Sum'],2,'.',','); 
        
        
         
?>
        </font></strong></div></td>
        <td align="center" bgcolor="#FFFFFF" ><div align="right"><strong><font color="#993333" size="2" face="Tahoma">
          <?php
          $Faculty_code 
$row[Faculty_code];
          
$sql "Select Sum(Salary_1) as Sum From personal_tb   Where  Faculty_code='$Faculty_code'  ";
         
$result1 mysql_query($sql) or die("Error".mysql_error());
         
$rss1 mysql_fetch_array($result1);
         echo 
number_format($rss1['Sum'],2,'.',','); 
        
        
         
?>
        </font></strong></div></td>
      </tr>
      <?
    $count
=1;
     }
else
{
?>
      <tr bordercolor="#CCCCCC" bgcolor="#FFFFFF" onmouseover="this.style.backgroundColor='#FCFCF3'" onmouseout="this.style.backgroundColor='#FFFFFF'">
        <td align="center" ><font color="#000000" size="2" face="Tahoma">
          <?=$i?>
        </font></td>
        <td height="18" align="center" ><div align="left"><font color="#0033CC" size="2" face="Tahoma"><a href="PersonalSalary.php?Faculty_code=<?=$row["Faculty_code"]?>&Person_type=1" title="Click to see Detail"class="d" >
          <?=$row["Faculty_name"]?>
        </a></font><font color="#000000" size="2" face="Tahoma">&nbsp;&nbsp;
        <?=$row["Faculty_nameE"]?>
        </font></div>          <div align="left"></div></td>
        <td align="center" ><div align="right"><strong><font color="#993333" size="2" face="Tahoma">
          <?php
          $Faculty_code 
$row[Faculty_code];
          
$sql "Select Sum(Salary_1) as Sum From personal_tb   Where  Faculty_code='$Faculty_code' and  Person_type='1' ";
         
$result1 mysql_query($sql) or die("Error".mysql_error());
         
$rss1 mysql_fetch_array($result1);
         echo 
number_format($rss1['Sum'],2,'.',','); 
        
        
         
?>
        </font></strong></div></td>
        <td align="center" ><div align="right"><strong><font color="#993333" size="2" face="Tahoma">
          <?php
          $Faculty_code 
$row[Faculty_code];
          
$sql "Select Sum(Salary_1) as Sum From personal_tb   Where  Faculty_code='$Faculty_code' and  Person_type='3' ";
         
$result1 mysql_query($sql) or die("Error".mysql_error());
         
$rss1 mysql_fetch_array($result1);
         echo 
number_format($rss1['Sum'],2,'.',','); 
        
        
         
?>
        </font></strong></div></td>
        <td align="center" ><div align="right"><strong><font color="#993333" size="2" face="Tahoma">
          <?php
          $Faculty_code 
$row[Faculty_code];
          
$sql "Select Sum(Salary_1) as Sum From personal_tb   Where  Faculty_code='$Faculty_code' and  Person_type='4' ";
         
$result1 mysql_query($sql) or die("Error".mysql_error());
         
$rss1 mysql_fetch_array($result1);
         echo 
number_format($rss1['Sum'],2,'.',','); 
        
        
         
?>
        </font></strong></div></td>
        <td align="center" ><div align="right"><strong><font color="#993333" size="2" face="Tahoma">
          <?php
          $Faculty_code 
$row[Faculty_code];
          
$sql "Select Sum(Salary_1) as Sum From personal_tb   Where  Faculty_code='$Faculty_code'  ";
         
$result1 mysql_query($sql) or die("Error".mysql_error());
         
$rss1 mysql_fetch_array($result1);
         echo 
number_format($rss1['Sum'],2,'.',','); 
        
        
         
?>
        </font></strong></div></td>
      </tr>
      
      <?
$count
=0;
}
$i++;
 }    
CloseDB();
?>
      
      <tr bgcolor="#DBE4E9">
        <td colspan="6" align="center" bgcolor="#FFFFFF"><div align="center"><font color="#000000" size="2" face="Tahoma">ทั้งหมด <? echo $total ?> รายการ&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>