Viewing file: ExcelindicatorReportPlan.php (15.87 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="testing.xls"');
require_once( "../configuration.php" );
require_once( $_Config_absolute_path . "/includes/framework.php" );
require_once( "../includes/Function.php" );
/** Create Database Object */
$dbObj = new DBConn;
//=== SESSION
$Username = $valid_user;
/** Config Table for This Page */
$myTable ="project_type_tb";
$myTable1 = "project_tb";
$myTable2 = "project_mission";
$myTablePK = "missId";
//$myTable2 = "money_source_tb";
$myTablePK2 = "MoneyS_C";
$myTable3 = "faculty_tb";
//=== projectstdplan_tb //
$query = " SELECT * FROM $myTable3 WHERE Faculty_code='$Faculty_code' ";
$result1 = $dbObj->execQuery($query);
$rs1 = $dbObj->fetchArray($result1);
$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" />
<title>แผนการดำเนินงาน : รายงานประเภทต่างๆ - สรุปยอดเงินที่ขอใช้ตามแผน</title>
<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' ";
$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'
ORDER BY $OrderBy $ASCDESC ";
}
elseif( !isset($_GET['OrderBy']) ) {
$query = " SELECT * FROM $myTable2 WHERE Budget_Year='$Budget_Year'
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="left"> </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="123" align="center" valign="top">
<?php if( $numrows > 0 ) { ?>
<strong>แผนกลยุทธ์ทางการเงิน ปีงบประมาณ <span class="TEXT-RED10">
<?=$Budget_Year;?>
</span></strong>
<table width="1149" border="1" align="center" cellpadding="0" cellspacing="0" class="BORDER-GREY">
<tr bgcolor="#F8F8F8">
<td rowspan="2" align="center">รายละเอียดโครงการ</a></td>
<td height="23" colspan="4" align="center" class="BORDER-LEFT">แผนการใช้จ่าย</td>
<td width="71" rowspan="2" align="center" class="BORDER-LEFT">แผนการ </br>ใช้จ่าย</td>
<td colspan="4" align="center" class="BORDER-LEFT">แผนการจ่ายจริง</td>
<td width="82" rowspan="2" align="center" class="BORDER-LEFT">รวม </br>รายจ่ายจริง</td>
<td width="89" rowspan="2" align="center" class="BORDER-LEFT">งบประมาณ </br> คงเหลือ</td>
<td width="74" rowspan="2" align="center" class="BORDER-LEFT">ร้อยละของ </br>การเบิกจ่าย</td>
<td width="171" rowspan="2" align="center" class="BORDER-LEFT">ผลสัมฤิทธิ์</td>
</tr>
<tr bgcolor="#F8F8F8">
<td width="57" height="23" align="center" class="BORDER-TOP-LEFT">ไตรมาส 1</td>
<td width="60" align="center" class="BORDER-TOP-LEFT">ไตรมาส 2</td>
<td width="65" align="center" class="BORDER-TOP-LEFT">ไตรมาส 3</td>
<td width="74" align="center" class="BORDER-TOP-LEFT">ไตรมาส4</td>
<td width="71" align="center" class="BORDER-TOP-LEFT">ไตรมาส 1</td>
<td width="66" align="center" class="BORDER-TOP-LEFT">ไตรมาส 2</td>
<td width="69" align="center" class="BORDER-TOP-LEFT">ไตรมาส 3</td>
<td width="86" align="center" class="BORDER-TOP-LEFT">ไตรมาส 4</td>
</tr>
<?php
$no = 1+($display-1)*$limit;
while( $rss = $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="19" colspan="14" align="left" bgcolor="<?=$bgColor;?>" class="PADDING-LEFT-5 BORDER-TOP "><strong>
<?=$rss['mission_plan'];?>
</strong></td>
</tr>
<?
$query2 = " SELECT * FROM project_submission WHERE missId= ' ".$rss['missId']." ' ";
$result2 = mysql_query($query2);
while($rs2 = 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="19" colspan="14" align="left" bgcolor="<?=$bgColor;?>" class="PADDING-LEFT-10 BORDER-TOP "><strong></span><? echo "$rs2[sub_Orderlist]"; ?>.<strong><?php echo $rs2['submission_plan']; ?>
</strong> </strong>
</a></a></td>
</tr>
<?php
/*
$no = 1+($display-1)*$limit;
while( $rs1 = $dbObj->fetchArray($result3) ) {
*/
$query3 = " SELECT * FROM project_type_tb WHERE subId = '".$rs2['subId']."' and Faculty_code='$Faculty_code' ";
$result3 = mysql_query($query3);
while($rs = mysql_fetch_array($result3)){
$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 width="225" height="19" align="left" valign="top" nowrap="nowrap" class="PADDING-LEFT-15 BORDER-TOP-RIGHT"><? echo "$rs[Orderlist]"; ?></a>.<?=htmlspecialchars_decode( nl2br( $rs['Project_plan'] ) );?>
</a></td>
<td 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_total) 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_total) 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_total) 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>
<?
} #while
?>
<?php
// $no++;
} # while
?>
<?php
$no++;
} # while
?>
</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);
?>
|