Viewing file: ExcelReportStdPlan.php (15.62 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="Report.xls"');
require_once( "../configuration.php" );
require_once( $_Config_absolute_path . "/includes/framework.php" );
require_once( "../include/Function.php" );
/** Create Database Object */
$dbObj = new DBConn;
//=== SESSION
$Username = $valid_user;
/** Config Table for This Page */
$myTable2 = "projectstdplan_tb";
$myTable1 = "project_tb";
$myTable ="project_type_tb";
$myTablePK = "Orderlist";
//$myTable2 = "money_source_tb";
$myTablePK2 = "MoneyS_C";
$myTable3 = "faculty_tb";
$startDate1 = ($Budget_Year - 1)."-10-01";
$endDate1 = ($Budget_Year - 1)."-12-31";
$startDate2 = ($Budget_Year )."-01-01";
$endDate2 = ($Budget_Year )."-03-31";
$startDate3 = ($Budget_Year )."-04-01";
$endDate3 = ($Budget_Year )."-06-30";
$startDate4 = ($Budget_Year )."-07-01";
$endDate4 = ($Budget_Year )."-09-30";
/** Paging */
$page = $_GET['page'];
if( $page == "" ) { $page = 1; }
/** จำนวนข้อมูล ต่อ 1 หน้า */
$perpage = $_REQUEST['perpage'];
if( $perpage == "" ) { $perpage = 30; }
} # 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" />
<script language="javascript" src="../js/utilities.js"></script>
<script language="Javascript" src="../charts/charts.js"></script>
<title>แผนการดำเนินงาน : รายงานประเภทต่างๆ - สรุปยอดเงินที่ขอใช้ตามแผน</title>
<style type="text/css">
<!--
.style1 {font-size: 14px}
-->
</style>
</head>
<body topmargin="0" rightmargin="0" bottommargin="0" leftmargin="0">
<table width="1205" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1270" 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 = $myTablePK; }
if( !isset($_GET['ASCDESC']) ) { $ASCDESC = "ASC"; }
if( $_GET['ASCDESC'] == "ASC" ) { $ASCDESC = "DESC"; }
elseif( $_GET['ASCDESC'] == "DESC" ) { $ASCDESC = "ASC"; }
/** Query เพื่อหา Numrows ก่อน */
$query = " SELECT * FROM $myTable2 WHERE Budget_Year='$Budget_Year' And Faculty_code ='$Faculty_code' ";
$result = $dbObj->execQuery($query);
$rs = $dbObj->fetchArray($result);
$numrows = $dbObj->_numrows;
/** Paging */
$display = ( !isset ($_GET['page']) ) ? 1 : $_GET['page'];
$start = ( ($display * $limit) - $limit );
/** Paging */
if( isset($_GET['OrderBy']) ) {
$query = " SELECT * FROM $myTable2 WHERE Budget_Year='$Budget_Year'
And Faculty_code='$Faculty_code' ORDER BY $OrderBy $ASCDESC ";
}
elseif( !isset($_GET['OrderBy']) ) {
$query = " SELECT * FROM $myTable2 WHERE Budget_Year='$Budget_Year'
And Faculty_code='$Faculty_code' ORDER BY $myTablePK ASC ";
}
$query .= " LIMIT $start, $limit ";
$result = $dbObj->execQuery($query);
?>
<fieldset>
<table width="1180" border="0" cellspacing="0" cellpadding="0">
<form id="myForm" name="myForm" method="post" action="<?=$PHP_SELF;?>?Budget_Year=<?=$Budget_Year;?>&ProjectId=<?=$ProjectId;?>&MoneyS_C=<?=$MoneyS_C;?>&page=<?=$page;?>">
<tr>
<td width="1180" height="5"></td>
</tr>
<tr>
<td><table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="10" colspan="2" align="right"></td>
</tr>
<tr>
<td width="74%" align="left" style="padding-bottom:5px;">ทั้งหมด: <strong><?=$numrows;?></strong> รายการ</td>
<td width="26%" align="right" style="padding-bottom:5px;"> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="291" align="center" valign="top">
<?php if( $numrows > 0 ) { ?>
<strong>แผนกลยุทธ์ทางการเงิน ปีงบประมาณ <span class="TEXT-RED10">
<?=$Budget_Year;?>
</span></strong> </p>
<table width="1256" border="0" align="center" cellpadding="0" cellspacing="0" class="BORDER-GREY">
<tr bgcolor="#F8F8F8">
<td width="259" rowspan="2" align="center"><span class="style1"><strong><font color="#0033CC" face="Tahoma">รายละเอียดโครงการ</font></strong></span></td>
<td width="62" rowspan="2" align="center" class="BORDER-LEFT-RIGHT">ประเด็น</br>ยุทธศาสตร์</td>
<td height="23" colspan="4" align="center" class="BORDER">แผนการใช้จ่าย ปี </td>
<td width="69" rowspan="2" align="center" class="BORDER-LEFT">แผนการ </br>ใช้จ่าย</td>
<td colspan="4" align="center" class="BORDER-LEFT">แผนการจ่ายจริง ปี</td>
<td width="73" rowspan="2" align="center" class="BORDER-LEFT">รวม </br>รายจ่ายจริง</td>
<td width="70" rowspan="2" align="center" class="BORDER-LEFT">งบประมาณ </br> คงเหลือ</td>
<td width="70" rowspan="2" align="center" class="BORDER-LEFT">ร้อยละของ </br>การเบิกจ่าย</td>
<td width="162" rowspan="2" align="center" class="BORDER-LEFT">ผลสัมฤิทธิ์</td>
</tr>
<tr bgcolor="#F8F8F8">
<td width="64" height="23" align="center" class="BORDER-TOP">ไตรมาส 1</td>
<td width="58" align="center" class="BORDER-TOP-LEFT">ไตรมาส 2</td>
<td width="60" align="center" class="BORDER-TOP-LEFT">ไตรมาส 3</td>
<td width="62" align="center" class="BORDER-TOP-LEFT">ไตรมาส4</td>
<td width="56" align="center" class="BORDER-TOP-LEFT">ไตรมาส 1</td>
<td width="59" align="center" class="BORDER-TOP-LEFT">ไตรมาส 2</td>
<td width="65" align="center" class="BORDER-TOP-LEFT">ไตรมาส 3</td>
<td width="65" align="center" class="BORDER-TOP-LEFT">ไตรมาส 4</td>
</tr>
<?php
$no = 1+($display-1)*$limit;
while( $rs2 = $dbObj->fetchArray($result) ) {
$bgColor = ( $bgColor == "#FFFFFF" ) ? "#F9FBFB" : "#FFFFFF";
?>
<tr bgcolor="<?=$bgColor;?>" class="PADDING-RIGHT-10 BORDER-TOP BORDER-LEFT" onmouseover="this.style.backgroundColor='#F5F9F9'" onmouseout="this.style.backgroundColor=''">
<td height="30" colspan="15" align="left" bgcolor="<?=$bgColor;?>" class="BORDER-TOP"><font color="#000000" size="2" face="Tahoma">
<?
echo $rs2['Orderlist'].". ".$rs2['Project_plan'];
?>
</font></td>
</tr>
<?php
/*
$no = 1+($display-1)*$limit;
while( $rs1 = $dbObj->fetchArray($result3) ) {
*/
$query2 = " SELECT * FROM $myTable WHERE Project_code = '".$rs2['Project_code']."' ";
$result2 = mysql_query($query2);
while($rs = mysql_fetch_array($result2)){
$bgColor = ( $bgColor == "#FFFFFF" ) ? "#F9FBFB" : "#FFFFFF";
?>
<tr bgcolor="<?=$bgColor;?>" class="PADDING-RIGHT-10 BORDER-TOP BORDER-LEFT" onmouseover="this.style.backgroundColor='#F5F9F9'" onmouseout="this.style.backgroundColor=''">
<td height="30" align="left" bgcolor="<?=$bgColor;?>" class="BORDER-TOP">
<? echo "$rs[Orderlist]"; ?> <?php echo"$rs[Project_plan]"; ?>
</font></a></td>
<td align="right" class="PADDING-LEFT-5 BORDER-TOP-LEFT-RIGHT"></a></td>
<td align="right" class="PADDING-LEFT-5 BORDER-TOP"><?php
$sql1 = " SELECT SUM(October+November+December) AS SumB1 FROM project_type_tb WHERE ProjectId = '$rs[ProjectId]' AND Faculty_code='$rs[Faculty_code]' AND Budget_Year='$rs[Budget_Year]' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
echo number_format($rss1['SumB1'],2,'.',',');
?> </td>
<td align="right" class="BORDER-TOP BORDER-LEFT"><?php
$sql1 = " SELECT SUM(January+February+March) AS SumB1 FROM project_type_tb WHERE ProjectId = '$rs[ProjectId]' AND Faculty_code='$rs[Faculty_code]' AND Budget_Year='$rs[Budget_Year]' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
echo number_format($rss1['SumB1'],2,'.',',');
?> </td>
<td align="right" class="PADDING-RIGHT-10 BORDER-TOP BORDER-LEFT"><?php
$sql1 = " SELECT SUM(April+May+June) AS SumB1 FROM project_type_tb WHERE ProjectId = '$rs[ProjectId]' AND Faculty_code='$rs[Faculty_code]' AND Budget_Year='$rs[Budget_Year]' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
echo number_format($rss1['SumB1'],2,'.',',');
?></td>
<td align="right" class="PADDING-RIGHT-10 BORDER-TOP BORDER-LEFT"><?php
$sql1 = " SELECT SUM(July+Augus+September) AS SumB1 FROM project_type_tb WHERE ProjectId = '$rs[ProjectId]' AND Faculty_code='$rs[Faculty_code]' AND Budget_Year='$rs[Budget_Year]' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
echo number_format($rss1['SumB1'],2,'.',',');
?> </td>
<td align="right" class="PADDING-RIGHT-10 BORDER-TOP BORDER-LEFT"><?php
$sql1 = " SELECT SUM(Budget_use) AS SumB1 FROM project_type_tb WHERE ProjectId = '$rs[ProjectId]' AND Faculty_code='$rs[Faculty_code]' AND Budget_Year='$rs[Budget_Year]' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
echo number_format($rss1['SumB1'],2,'.',',');
?></td>
<td align="right" class="PADDING-RIGHT-10 BORDER-TOP BORDER-LEFT"><?php
$sql10 = " SELECT SUM(Budget_use) AS SumB2 FROM $myTable1 WHERE ProjectId = '$rs[ProjectId]' AND Faculty_code='$rs[Faculty_code]' AND Budget_Year='$rs[Budget_Year]' AND Date >= '$startDate1' AND Date <= '$endDate1' ";
$result10 = mysql_query($sql10);
$rss10 = mysql_fetch_array($result10);
echo number_format($rss10['SumB2'],2,'.',',');
?></td>
<td align="right" class="PADDING-RIGHT-10 BORDER-TOP BORDER-LEFT"><?php
$sql10 = " SELECT SUM(Budget_use) AS SumB2 FROM $myTable1 WHERE ProjectId = '$rs[ProjectId]' AND Faculty_code='$rs[Faculty_code]' AND Budget_Year='$rs[Budget_Year]' AND Date >= '$startDate2' AND Date <= '$endDate2' ";
$result10 = mysql_query($sql10);
$rss10 = mysql_fetch_array($result10);
echo number_format($rss10['SumB2'],2,'.',',');
?></td>
<td align="right" class="PADDING-RIGHT-10 BORDER-TOP BORDER-LEFT"><?php
$sql10 = " SELECT SUM(Budget_use) AS SumB2 FROM $myTable1 WHERE ProjectId = '$rs[ProjectId]' AND Faculty_code='$rs[Faculty_code]' AND Budget_Year='$rs[Budget_Year]' AND Date >= '$startDate3' AND Date <= '$endDate3' ";
$result10 = mysql_query($sql10);
$rss10 = mysql_fetch_array($result10);
echo number_format($rss10['SumB2'],2,'.',',');
?></td>
<td align="right" class="PADDING-RIGHT-10 BORDER-TOP BORDER-LEFT"><?php
$sql10 = " SELECT SUM(Budget_use) AS SumB2 FROM $myTable1 WHERE ProjectId = '$rs[ProjectId]' AND Faculty_code='$rs[Faculty_code]' AND Budget_Year='$rs[Budget_Year]' AND Date >= '$startDate4' AND Date <= '$endDate4' ";
$result10 = mysql_query($sql10);
$rss10 = mysql_fetch_array($result10);
echo number_format($rss10['SumB2'],2,'.',',');
?></td>
<td align="right" class="PADDING-RIGHT-10 BORDER-TOP BORDER-LEFT"><?php
$sql1 = " SELECT SUM(Budget_use) AS SumB1 FROM project_tb WHERE ProjectId = '$rs[ProjectId]' AND Faculty_code='$rs[Faculty_code]' AND Budget_Year='$rs[Budget_Year]' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
echo number_format($rss1['SumB1'],2,'.',',');
?></td>
<td align="right" class="PADDING-RIGHT-10 BORDER-TOP BORDER-LEFT"><?php
$sql1 = " SELECT SUM(Budget_use) AS SumB1 FROM project_type_tb WHERE ProjectId = '$rs[ProjectId]' AND Faculty_code='$rs[Faculty_code]' AND Budget_Year='$rs[Budget_Year]' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
$sql10 = " SELECT SUM(Budget_use) AS SumB2 FROM project_tb WHERE ProjectId = '$rs[ProjectId]' AND Faculty_code='$rs[Faculty_code]' AND Budget_Year='$rs[Budget_Year]' ";
$result10 = mysql_query($sql10);
$rss10 = mysql_fetch_array($result10);
$Sum4 = $rss1[SumB1] - $rss10[SumB2] ;
echo number_format($Sum4,2,'.',',');
?></td>
<td align="right" class="PADDING-RIGHT-10 BORDER-TOP BORDER-LEFT"><?php
$sql1 = " SELECT SUM(Budget_use) AS SumB1 FROM project_type_tb WHERE ProjectId = '$rs[ProjectId]' AND Faculty_code='$rs[Faculty_code]' AND Budget_Year='$rs[Budget_Year]' ";
$result1 = mysql_query($sql1);
$rss1 = mysql_fetch_array($result1);
$sql10 = " SELECT SUM(Budget_use) AS SumB2 FROM project_tb WHERE ProjectId = '$rs[ProjectId]' AND Faculty_code='$rs[Faculty_code]' AND Budget_Year='$rs[Budget_Year]' ";
$result10 = mysql_query($sql10);
$rss10 = mysql_fetch_array($result10);
$Sum4 = $rss10[SumB2]*100 / $rss1[SumB1] ;
if ($Sum4 != '0' ) {
echo number_format($Sum4,2,'.',',');
} else {
echo number_format(0,2,'.',',');
}
?>
%</td>
<td align="right" class="PADDING-RIGHT-10 BORDER-TOP BORDER-LEFT"> </td>
</tr>
<?php
/*
$no++;
} # while
*/
} # while
?>
<?php
$no++;
} # while
//$dbObj->freeresult($result3);
//$dbObj->freeresult($result2);
//$dbObj->freeresult($result);
?>
</table>
<?php } #if ?></td>
</tr>
<tr>
<td> </td>
</tr></form></table>
</fieldset></td>
</tr>
</table>
</body>
</html>
<?php
/** Free Resource */
$dbObj->freeresult($result1);
/** Close the Database */
$dbObj->disconn();
/** Unset Class */
unset($dbObj);
?>
|