Viewing file: ExcelAbsent.php (12.53 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
session_start();
/** Define Validate Access */
define( '_VALID_ACCESS', 1 );
/** Check Session User Login */
if( !session_is_registered("valid_user") && !session_is_registered("Priority") ) {
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-874\" />";
echo "<p style=padding-top:115px><p align=center><br /><font color=red><strong>กรุณาทำการ Login ก่อน</strong></font></p></p>";
echo "<meta http-equiv=\"refresh\" content=\"1; URL=../login.php\" />";
exit();
}
else {
/** Configuration */
header('Content-type: application/xls');
header('Content-Disposition: attachment; filename="ReportAbsent.xls"');
require_once( "../configuration.php" );
require_once( $_Config_absolute_path . "/includes/framework.php" );
require_once( "../include/Function.php" );
/** Create Database Object */
$dbObj = new DBConn;
/** Config Table for This Page */
$myTable = "personal_tb";
$myTable1 = "history_absent_tb ";
$myTableFK = "Teacher_id";
$myOrderBy = "Teacher_id,Teacher_name";
/** Parameters */
$params = "$Year";
/** Paging */
$page = $_GET['page'];
if( $page == "" ) { $page = 1; }
/** จำนวนข้อมูล ต่อ 1 หน้า */
$perpage = $_REQUEST['perpage'];
if( $perpage == "" ) { $perpage = 1200; }
} # else
?>
<!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=windows-874" />
<title>รายงานการลา</title>
</head>
<body topmargin="0" rightmargin="0" bottommargin="0" leftmargin="0">
<table width="1003" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="892" height="440" align="center" valign="top" style="padding:10px 0px 5px 10px">
<?php
/** Config Paging */
if( $perpage == "" ) { $limit = $_Config_limit; }
else { $limit = $perpage; }
$scroll = $_Config_scroll;
/** ตั้งค่า Default สำหรับการทำ Order By */
if( $OrderBy == "" ) { $OrderBy = $myOrderBy; }
if( !isset($_GET['ASCDESC']) ) { $ASCDESC = "ASC"; }
if( $_GET['ASCDESC'] == "ASC" ) { $ASCDESC = "DESC"; }
elseif( $_GET['ASCDESC'] == "DESC" ) { $ASCDESC = "ASC"; }
/** Query เพื่อหา Numrows ก่อน */
if( $keyword != "" ) {
$query = " SELECT *, prefixName as First_name FROM personal_tb LEFT JOIN prefix ON personal_tb.First_name = prefix.prefixId WHERE StatusId='1' AND
( First_name LIKE '%$keyword%' OR Teacher_name LIKE '%$keyword%' OR Teacher_lastname LIKE '%$keyword%' ) ";
}
else {
$query = " SELECT *, prefixName as First_name FROM personal_tb LEFT JOIN prefix ON personal_tb.First_name = prefix.prefixId WHERE StatusId='1' ";
}
$result = $dbObj->execQuery($query);
$numrows = $dbObj->_numrows;
/** Paging */
$display = ( !isset ($_GET['page']) ) ? 1 : $_GET['page'];
$start = ( ($display * $limit) - $limit );
/** Paging */
//### Search
if( $keyword != "" ) {
if( isset($_GET['OrderBy']) ) {
$query = " SELECT *, prefixName as First_name FROM personal_tb LEFT JOIN prefix ON personal_tb.First_name = prefix.prefixId WHERE StatusId='1' AND
( First_name LIKE '%$keyword%' OR Teacher_name LIKE '%$keyword%' OR Teacher_lastname LIKE '%$keyword%' )
ORDER BY $OrderBy $ASCDESC ";
}
elseif( !isset($_GET['OrderBy']) ) {
$query = " SELECT *, prefixName as First_name FROM personal_tb LEFT JOIN prefix ON personal_tb.First_name = prefix.prefixId WHERE StatusId='1' AND
( First_name LIKE '%$keyword%' OR Teacher_name LIKE '%$keyword%' OR Teacher_lastname LIKE '%$keyword%' )
ORDER BY $myTableFK ASC ";
}
}
else {
if( isset($_GET['OrderBy']) ) {
$query = " SELECT *, prefixName as First_name FROM personal_tb LEFT JOIN prefix ON personal_tb.First_name = prefix.prefixId WHERE StatusId='1' ORDER BY $OrderBy $ASCDESC ";
}
elseif( !isset($_GET['OrderBy']) ) {
$query = " SELECT *, prefixName as First_name FROM personal_tb LEFT JOIN prefix ON personal_tb.First_name = prefix.prefixId WHERE StatusId='1' ORDER BY $myTableFK ASC ";
}
}
$query .= " LIMIT $start, $limit ";
$result = $dbObj->execQuery($query);
?>
<table width="822" border="0" align="center" cellpadding="0" cellspacing="0">
<form id="myForm" name="myForm" method="post" action="<?=$PHP_SELF;?>?page=<?=$page;?>&Year=<?=$Year;?>">
<tr>
<td width="781" height="5"></td>
</tr>
<tr>
<td height="115" align="center" valign="top"><?php if( $numrows > 0 ) { ?>
<table width="994" border="1" align="center" cellpadding="0" cellspacing="0" class="BORDER-GREY">
<tr bgcolor="#F8F8F8">
<td height="38" align="center"> </td>
<td align="center" class="BORDER-LEFT-RIGHT"> </td>
<td align="center" class="BORDER-RIGHT">ปีงบประมาณ
<?=$Year;?></td>
<td align="center" class="BORDER-RIGHT">ว/ด/ป</td>
<td align="center" class="BORDER-RIGHT">ว/ด/ป</td>
<td align="center" class="BORDER-RIGHT">อายุ</td>
<td colspan="4" align="center" class="BORDER-RIGHT">วันลาพักผ่อนประจำปี <strong><span class="NOTE">
<?=$Year;?>
</span></strong></td>
<td align="center" class="BORDER-RIGHT"> </td>
<td align="center" class="BORDER-RIGHT"> </td>
<td align="center" class="BORDER"> </td>
</tr>
<tr bgcolor="#F8F8F8">
<td width="24" height="38" align="center">No</td>
<td width="163" align="center" class="BORDER-LEFT-RIGHT">ชื่อ-นามสกุล</a></td>
<td width="210" align="center" class="BORDER-RIGHT">ตำแหน่งราชการ</a></td>
<td width="111" align="center" class="BORDER-RIGHT">ที่เข้าทำงานในวิลัย</td>
<td width="88" align="center" class="BORDER-RIGHT">ที่รับราชการ</td>
<td width="46" align="center" class="BORDER-RIGHT">ราชการ</td>
<td width="43" align="center" class="BORDER-RIGHT-LEFT">วันลา <br />
สะสม</td>
<td width="37" align="center" class="BORDER-RIGHT-LEFT">รวม <br />
วันลา</td>
<td width="46" align="center" class="BORDER-RIGHT-LEFT">วันลา <br />
พักผ่อน</td>
<td width="54" align="center" class="BORDER-RIGHT-LEFT">วันลา<br />
คงเลือ</td>
<td width="38" align="center" class="BORDER-RIGHT">ลากิจ</td>
<td width="44" align="center" class="BORDER-RIGHT">ลาป่วย</td>
<td width="62" align="center" class="BORDER">ลาคลอด</td>
</tr>
<?php
$no = 1+($display-1)*$limit;
while( $rs = $dbObj->fetchArray($result) ) {
$bgColor = ( $bgColor == "#FFFFFF" ) ? "#F9FBFB" : "#FFFFFF";
$Teacher_code = $rs['Teacher_code'];
/** จำนวนระเบียน */
$sql = " SELECT * FROM $myTable1 WHERE Teacher_code='$Teacher_code' " ;
$result3 = $dbObj->execQuery($sql);
$countnum = $dbObj->_numrows;
$dbObj->freeresult($result3);
$sum += $countnum;
?>
<tr bgcolor="<?=$bgColor;?>" onmouseover="this.style.backgroundColor='#F5F9F9'" onmouseout="this.style.backgroundColor=''">
<td height="23" align="center" class="BORDER-TOP"><?=$no;?></td>
<td align="left" class="PADDING-LEFT-3 BORDER-TOP-LEFT-RIGHT">
<?php echo $rs['First_name']." ".$rs['Teacher_name'] ." ". $rs['Teacher_lastname']; ?>
</td>
<td align="left" class="PADDING-LEFT-3 BORDER-TOP-RIGHT"><?php
$PositionId = $rs["PositionId"] ;
$sql = "Select * From position_tb Where PositionId='$PositionId' ";
$result2 = mysql_query($sql) or die("Error".mysql_error());
$rss4 = mysql_fetch_array($result2);
echo "$rss4[Position_name] ";
?>
</a></td>
<td align="center" class="BORDER-TOP-RIGHT"><font color="#003366" size="2" face="Tahoma"><?php echo "$rs[Year_coll]"; ?></font></td>
<td align="center" class="BORDER-TOP-RIGHT"><font color="#003366" size="2" face="Tahoma"><?php echo "$rs[Year_gov]"; ?></font></td>
<td align="center" class="BORDER-TOP-RIGHT"><?php //// Show Age
$age = $rs['Year_gov'];
$year = explode("-",$age);
$year = intval($year[0]);
$year = $year - 543;
$currentyear = date("Y");
// $currentyear = intval($currentyear[0]);
$age = $currentyear - $year ;
echo"$age";
?></td>
<td align="center" class="BORDER-TOP-RIGHT"><?php
$sql1 = "Select Sum(Times_total) as SumB1 From history_accumu WHERE Teacher_code='$rs[Teacher_code]' and Year ='$Year' " ;
$result1 = mysql_query($sql1) or die("Erro".mysql_error());
$rss1 = mysql_fetch_array($result1);
echo number_format($rss1[SumB1],2,'.',',');
?>
</a></td>
<td align="center" class="BORDER-TOP-RIGHT"><?
$query2 = " SELECT * FROM history_accumu Where Teacher_code='$rs[Teacher_code]' and Year ='$Year' ";
$result2 = $dbObj->execQuery($query2);
$rss2 = $dbObj->fetchObject($result2);
echo (($rss2->Times_total +10) > 30)?"30":$rss2->Times_total+10 ;
// echo $rss2->Times_total +10 - $rss1[SumB1] ;
?></td>
<td align="center" class="BORDER-TOP-RIGHT"><?php
$sql1 = "Select Sum(Absent_times) as SumB1 From history_absent_tb WHERE Teacher_code='$rs[Teacher_code]' and Absent_code ='3' and Year ='$Year' " ;
$result1 = mysql_query($sql1) or die("Erro".mysql_error());
$rss1 = mysql_fetch_array($result1);
echo number_format($rss1[SumB1],2,'.',',');
?></td>
<td align="center" class="BORDER-TOP-RIGHT"><?
$query2 = " SELECT * FROM history_accumu Where Teacher_code='$rs[Teacher_code]' and Year ='$Year' ";
$result2 = $dbObj->execQuery($query2);
$rss2 = $dbObj->fetchObject($result2);
echo (($rss2->Times_total +10) > 30)?"30":$rss2->Times_total+10 - $rss1[SumB1] ;
// echo $rss2->Times_total +10 - $rss1[SumB1] ;
?></td>
<td align="center" class="BORDER-TOP-RIGHT"><?php
$sql1 = "Select Sum(Absent_times) as SumB1 From history_absent_tb WHERE Teacher_code='$rs[Teacher_code]' and Absent_code ='1' and Year ='$Year' " ;
$result1 = mysql_query($sql1) or die("Erro".mysql_error());
$rss1 = mysql_fetch_array($result1);
echo number_format($rss1[SumB1],2,'.',',');
?></td>
<td align="center" class="BORDER-TOP-RIGHT"><?php
$sql1 = "Select Sum(Absent_times) as SumB2 From history_absent_tb WHERE Teacher_code='$rs[Teacher_code]' and Absent_code ='2' and Year ='$Year' " ;
$result1 = mysql_query($sql1) or die("Erro".mysql_error());
$rss1 = mysql_fetch_array($result1);
echo number_format($rss1[SumB2],2,'.',',');
?></td>
<td align="center" class="BORDER-TOP"><?php
$sql1 = "Select Sum(Absent_times) as SumB4 From history_absent_tb WHERE Teacher_code='$rs[Teacher_code]' and Absent_code ='4' and Year ='$Year' " ;
$result1 = mysql_query($sql1) or die("Erro".mysql_error());
$rss1 = mysql_fetch_array($result1);
echo number_format($rss1[SumB4],2,'.',',');
?></td>
</tr>
<?php
$no++;
} # while
?>
</table> <?php } #if ?></td>
</tr>
<tr>
<td> </td>
</tr></form>
</table>
</td>
</tr>
</table>
</body>
</html>
<?php
/** Free Resource */
$dbObj->freeresult($result);
/** Close the Database */
$dbObj->disconn();
/** Unset Class */
unset($dbObj);
?>
|