Viewing file: SpendingYear.php (18.44 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 */
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_year";
$myTablePK = "Budget_Year";
$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";
/** Parameters */
$params = "Budget_Year=$Budget_Year";
} # 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" />
<link href="../css/default.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../js/utilities.js"></script>
<title>ข้อมูลแผนดำเนินงานและรายงาน : รายงานประเภทต่างๆ - สรุปยอดเงินที่ใช้จริงตามแผน</title>
</head>
<body topmargin="0" rightmargin="0" bottommargin="0" leftmargin="0">
<?php
include("../templates/incHeader.php");
?>
<table width="1003" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="203" align="left" valign="top" style="padding:10px 0px 0px 5px"><?php include("./_incMainMenu.php");?></td>
<td width="800" align="center" valign="top" style="padding:10px 0px 5px 10px">
<?php
/** Query เพื่อหา Numrows ก่อน */
$query = " SELECT * FROM $myTable Where Budget_Year ='$Budget_Year' ";
$result = $dbObj->execQuery($query);
$numrows = $dbObj->_numrows;
?>
<fieldset>
<table width="780" border="0" cellspacing="0" cellpadding="0">
<form id="myForm" name="myForm" method="post" action="<?=$PHP_SELF;?>?page=<?=$page;?>">
<tr>
<td height="5" colspan="2"></td>
</tr>
<tr>
<td width="570" height="30" background="../images/background/bg-head-topic.gif" class="PADDING-LEFT-10"><strong><a href="index.php">หน้าหลัก</a></strong> <strong>» <a href="Menu_Report.php?Budget_Year=<?=$Budget_Year ;?>">รายงานประเภทต่างๆ</a> » <span class="NOTE">ตารางสรุปการขออนุมัติการใช้เงินรายไตรมาส</span></strong></td>
<td width="210" align="right" style="padding-right:10px"> </td>
</tr>
<tr>
<td colspan="2"><table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="PADDING-TOP-10 PADDING-BOTTOM-10"><img src="../images/icons/arrow-circle-225-left.png" width="16" height="16" border="0" align="absmiddle" /> <a href="javascript:;" onclick="window.history.back();"><strong>‹ ย้อนกลับ</strong></a></td>
</tr>
<tr>
<td class="PADDING-TOP-10 PADDING-BOTTOM-10"> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="196" colspan="2" align="center" valign="top"><table width="632" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="background-color:#eeeeee; border:0px solid gray">
<tr bgcolor="#F8F8F8">
<td height="22" colspan="6" align="left" bordercolor="#999966" class="PADDING-LEFT-10">ปีงบประมาณ
<?=$Budget_Year ;?>
</td>
</tr>
<?php
$no = 1+($display-1)*$limit;
while( $rs = $dbObj->fetchArray($result) ) {
$bgColor = ( $bgColor == "#FFFFFF" ) ? "#F9FBFB" : "#FFFFFF";
?>
<tr bgcolor="<?=$bgColor;?>">
<td height="20" align="left"> </td>
<td align="center" class="PADDING-LEFT-3 BORDER-TOP BORDER-LEFT">รายการ</td>
<td align="center"class="PADDING-LEFT-3 BORDER-TOP BORDER-LEFT">จำนวนเงินที่ขอใช้</td>
<td align="center"class="PADDING-LEFT-3 BORDER-TOP BORDER-LEFT">จำนวนเงินที่ใช้จริง</td>
<td align="center"class="PADDING-LEFT-3 BORDER-TOP BORDER-LEFT-RIGHT">คงเหลือเงิน</td>
<td align="center"class="PADDING-LEFT-3 BORDER-TOP BORDER-RIGHT">ร้อยละ</td>
</tr>
<tr bgcolor="<?=$bgColor;?>">
<td width="3%" height="20" align="left"> </td>
<td width="23%" align="left" class="PADDING-LEFT-3 BORDER-TOP BORDER-LEFT"><img src="../images/icons/calendar-select-month.png" width="16" height="16" border="0" align="absmiddle" /> <a href="Rep_1.php?Budget_Year=<?php echo $rs['Budget_Year']; ?>">ไตรมาส 1</a></td>
<td width="19%" align="right"class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT">
<?php
$sql4 = " SELECT SUM(October+November+December) AS SumC6 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result4 = $dbObj->execQuery($sql4);
$rss4 = $dbObj->fetchArray($result4);
echo number_format($rss4['SumC6'],2,'.',',');
?>
</td>
<td width="18%" align="right" class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT">
<?php
$sql3 = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb pt, project_type_tb ptt WHERE pt.Budget_Year='$Budget_Year' and pt.ProjectId=ptt.ProjectId and pt.Date >='$startDate1' and pt.Date<= '$endDate1' ";
$result3 = $dbObj->execQuery($sql3);
$rss3 = $dbObj->fetchArray($result3);
echo number_format($rss3['SumB2'],2,'.',',');
?>
</td>
<td width="24%" align="right" class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT-RIGHT"><?php
$sql3 = " SELECT SUM(October+November+December) AS SumC1 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result3 = $dbObj->execQuery($sql3);
$rss3 = $dbObj->fetchArray($result3);
$sql10 = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb pt, project_type_tb ptt WHERE pt.Budget_Year='$Budget_Year' and pt.ProjectId=ptt.ProjectId and pt.Date >='$startDate1' and pt.Date<= '$endDate1' ";
$result10 = $dbObj->execQuery($sql10);
$rss10 = $dbObj->fetchArray($result10);
$Sum4 = $rss3[SumC1] - $rss10[SumB2] ;
echo number_format($Sum4,2,'.',',');
?></td>
<td width="13%" align="center" class="PADDING-RIGHT-5 BORDER-TOP BORDER-RIGHT"><?php
$sql = " SELECT SUM(October+November+December) AS SumC6 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result13 = $dbObj->execQuery($sql);
$rs13 = $dbObj->fetchArray($result13);
$sql = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb pt, project_type_tb ptt WHERE pt.Budget_Year='$Budget_Year' and pt.ProjectId=ptt.ProjectId and pt.Date >='$startDate1' and pt.Date<= '$endDate1' ";
$result14 = $dbObj->execQuery($sql);
$rs14 = $dbObj->fetchArray($result14);
$Sum = $rs13[SumC6] - $rs14[SumB2] ;
$per4 = ($rs14[SumB2] * 100 ) / $rs13[SumC6];
echo number_format($per4,2,'.','.');
?></td>
</tr>
<tr bgcolor="<?=$bgColor;?>">
<td height="20" align="left"></td>
<td width="23%" align="left" class="PADDING-LEFT-3 BORDER-TOP BORDER-LEFT"><img src="../images/icons/calendar-select-month.png" width="16" height="16" border="0" align="absmiddle" /> <a href="Rep_2.php?Budget_Year=<?php echo $rs['Budget_Year']; ?>">ไตรมาส 2</a></td>
<td align="right" class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT">
<?php
$sql4 = " SELECT SUM(January+February+March) AS SumC6 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result4 = $dbObj->execQuery($sql4);
$rss4 = $dbObj->fetchArray($result4);
echo number_format($rss4['SumC6'],2,'.',',');
?>
</td>
<td align="right" class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT">
<?php
$sql3 = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb pt, project_type_tb ptt WHERE pt.Budget_Year='$Budget_Year' and pt.ProjectId=ptt.ProjectId and pt.Date >='$startDate2' and pt.Date<= '$endDate2' ";
$result3 = $dbObj->execQuery($sql3);
$rss3 = $dbObj->fetchArray($result3);
echo number_format($rss3['SumB2'],2,'.',',');
?>
</td>
<td align="right" class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT-RIGHT"><?php
$sql3 = " SELECT SUM(January+February+March) AS SumC1 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result3 = $dbObj->execQuery($sql3);
$rss3 = $dbObj->fetchArray($result3);
$sql10 = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb pt, project_type_tb ptt WHERE pt.Budget_Year='$Budget_Year' and pt.ProjectId=ptt.ProjectId and pt.Date >='$startDate2' and pt.Date<= '$endDate2' ";
$result10 = $dbObj->execQuery($sql10);
$rss10 = $dbObj->fetchArray($result10);
$Sum4 = $rss3[SumC1] - $rss10[SumB2] ;
echo number_format($Sum4,2,'.',',');
?></td>
<td align="center" class="PADDING-RIGHT-5 BORDER-TOP BORDER-RIGHT">
<?php
$sql3 = " SELECT SUM(January+February+March) AS SumC1 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result3 = $dbObj->execQuery($sql3);
$rss3 = $dbObj->fetchArray($result3);
$sql10 = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb pt, project_type_tb ptt WHERE pt.Budget_Year='$Budget_Year' and pt.ProjectId=ptt.ProjectId and pt.Date >='$startDate2' and pt.Date<= '$endDate2' ";
$result10 = $dbObj->execQuery($sql10);
$rss10 = $dbObj->fetchArray($result10);
$Sum4 = $rss3[SumC1] - $rss10[SumB2] ;
$per4 = ($rss10[SumB2] * 100 ) / $rss3[SumC1];
echo number_format($per4,2,'.','.');
?>
</td>
</tr>
<tr bgcolor="<?=$bgColor;?>">
<td height="20" align="left"></td>
<td width="23%" align="left" class="PADDING-LEFT-3 BORDER-TOP BORDER-LEFT"><img src="../images/icons/calendar-select-month.png" width="16" height="16" border="0" align="absmiddle" /> <a href="Rep_3.php?Budget_Year=<?php echo $rs['Budget_Year']; ?>">ไตรมาส 3</a></td>
<td align="right" class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT"><?php
$sql4 = " SELECT SUM(April+May+June) AS SumC6 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result4 = $dbObj->execQuery($sql4);
$rss4 = $dbObj->fetchArray($result4);
echo number_format($rss4['SumC6'],2,'.',',');
?> </td>
<td align="right" class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT">
<?php
$sql3 = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb pt, project_type_tb ptt WHERE pt.Budget_Year='$Budget_Year' and pt.ProjectId=ptt.ProjectId and pt.Date >='$startDate3' and pt.Date<= '$endDate3' ";
$result3 = $dbObj->execQuery($sql3);
$rss3 = $dbObj->fetchArray($result3);
echo number_format($rss3['SumB2'],2,'.',',');
?>
</td>
<td align="right" class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT-RIGHT"><?php
$sql3 = " SELECT SUM(April+May+June) AS SumC1 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result3 = $dbObj->execQuery($sql3);
$rss3 = $dbObj->fetchArray($result3);
$sql10 = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb pt, project_type_tb ptt WHERE pt.Budget_Year='$Budget_Year' and pt.ProjectId=ptt.ProjectId and pt.Date >='$startDate3' and pt.Date<= '$endDate3' ";
$result10 = $dbObj->execQuery($sql10);
$rss10 = $dbObj->fetchArray($result10);
$Sum4 = $rss3[SumC1] - $rss10[SumB2] ;
echo number_format($Sum4,2,'.',',');
?></td>
<td align="center" class="PADDING-RIGHT-5 BORDER-TOP BORDER-RIGHT">
<?php
$sql3 = " SELECT SUM(April+May+June) AS SumC1 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result3 = $dbObj->execQuery($sql3);
$rss3 = $dbObj->fetchArray($result3);
$sql10 = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb pt, project_type_tb ptt WHERE pt.Budget_Year='$Budget_Year' and pt.ProjectId=ptt.ProjectId and pt.Date >='$startDate3' and pt.Date<= '$endDate3' ";
$result10 = $dbObj->execQuery($sql10);
$rss10 = $dbObj->fetchArray($result10);
$Sum4 = $rss3[SumC1] - $rss10[SumB2] ;
$per4 = ($rss10[SumB2] * 100 ) / $rss3[SumC1];
echo number_format($per4,2,'.','.');
?>
</td>
</tr>
<tr bgcolor="<?=$bgColor;?>">
<td height="20" align="left"></td>
<td align="left" class="PADDING-LEFT-3 BORDER-TOP BORDER-LEFT"><img src="../images/icons/calendar-select-month.png" width="16" height="16" border="0" align="absmiddle" /> <a href="Rep_4.php?Budget_Year=<?php echo $rs['Budget_Year']; ?>">ไตรมาส 4</a></td>
<td align="right" class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT"><?php
$sql4 = " SELECT SUM(July+Augus+September) AS SumC6 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result4 = $dbObj->execQuery($sql4);
$rss4 = $dbObj->fetchArray($result4);
echo number_format($rss4['SumC6'],2,'.',',');
?> </td>
<td align="right" class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT">
<?php
$sql3 = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb pt, project_type_tb ptt WHERE pt.Budget_Year='$Budget_Year' and pt.ProjectId=ptt.ProjectId and pt.Date >='$startDate4' and pt.Date<= '$endDate4' ";
$result3 = $dbObj->execQuery($sql3);
$rss3 = $dbObj->fetchArray($result3);
echo number_format($rss3['SumB2'],2,'.',',');
?>
</td>
<td align="right" class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT-RIGHT"><?php
$sql3 = " SELECT SUM(July+Augus+September) AS SumC1 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result3 = $dbObj->execQuery($sql3);
$rss3 = $dbObj->fetchArray($result3);
$sql10 = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb pt, project_type_tb ptt WHERE pt.Budget_Year='$Budget_Year' and pt.ProjectId=ptt.ProjectId and pt.Date >='$startDate4' and pt.Date<= '$endDate4' ";
$result10 = $dbObj->execQuery($sql10);
$rss10 = $dbObj->fetchArray($result10);
$Sum4 = $rss3[SumC1] - $rss10[SumB2] ;
echo number_format($Sum4,2,'.',',');
?></td>
<td align="center" class="PADDING-RIGHT-5 BORDER-TOP BORDER-RIGHT">
<?php
$sql3 = " SELECT SUM(July+Augus+September) AS SumC1 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result3 = $dbObj->execQuery($sql3);
$rss3 = $dbObj->fetchArray($result3);
$sql10 = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb pt, project_type_tb ptt WHERE pt.Budget_Year='$Budget_Year' and pt.ProjectId=ptt.ProjectId and pt.Date >='$startDate4' and pt.Date<= '$endDate4' ";
$result10 = $dbObj->execQuery($sql10);
$rss10 = $dbObj->fetchArray($result10);
$Sum4 = $rss3[SumC1] - $rss10[SumB2] ;
$per4 = ($rss10[SumB2] * 100 ) / $rss3[SumC1];
echo number_format($per4,2,'.','.');
?>
</td>
</tr>
<tr bgcolor="<?=$bgColor;?>">
<td height="20" align="left"></td>
<td align="center" class="PADDING-LEFT-3 BORDER-TOP BORDER-LEFT">สรุปการใช้เงิน</td>
<td align="right" class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT"><?php
$sql4 = " SELECT SUM(Budget_total) AS SumC8 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result4 = $dbObj->execQuery($sql4);
$rss4 = $dbObj->fetchArray($result4);
echo number_format($rss4['SumC8'],2,'.',',');
?></td>
<td align="right" class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT"><?php
$sql3 = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb WHERE Budget_Year='$Budget_Year' ";
$result3 = $dbObj->execQuery($sql3);
$rss3 = $dbObj->fetchArray($result3);
echo number_format($rss3['SumB2'],2,'.',',');
?></td>
<td align="right" class="PADDING-RIGHT-5 BORDER-TOP BORDER-LEFT-RIGHT"><?php
$sql3 = " SELECT SUM(Budget_total) AS SumC1 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result3 = $dbObj->execQuery($sql3);
$rss3 = $dbObj->fetchArray($result3);
$sql10 = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb WHERE Budget_Year='$Budget_Year' ";
$result10 = $dbObj->execQuery($sql10);
$rss10 = $dbObj->fetchArray($result10);
$Sum4 = $rss3[SumC1] - $rss10[SumB2] ;
echo number_format($Sum4,2,'.',',');
?></td>
<td align="center" class="PADDING-RIGHT-5 BORDER-TOP BORDER-RIGHT">
<?php
$sql3 = " SELECT SUM(Budget_total) AS SumC1 FROM project_type_tb WHERE Budget_Year='$Budget_Year' ";
$result3 = $dbObj->execQuery($sql3);
$rss3 = $dbObj->fetchArray($result3);
$sql10 = " SELECT SUM(Spending_use) AS SumB2 FROM project_tb WHERE Budget_Year='$Budget_Year' ";
$result10 = $dbObj->execQuery($sql10);
$rss10 = $dbObj->fetchArray($result10);
$Sum4 = $rss3[SumC1] - $rss10[SumB2] ;
$per4 = ($rss10[SumB2] * 100 ) / $rss3[SumC1];
echo number_format($per4,2,'.','.');
?>
</td>
</tr>
<?php
$no++;
} # while
?>
</table></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr></form></table>
</fieldset></td>
</tr>
</table>
<?php include("../templates/incFooter.php"); ?>
</body>
</html>
<?php
/** Free Resource */
$dbObj->freeresult($result);
/** Close the Database */
$dbObj->disconn();
/** Unset Class */
unset($dbObj);
?>
|