 |
|
Code (PHP)
<?php
$firstmonth = $omonth;
$firstyear = $oyear;
$tmonth = $firstmonth;
$tyear = $firstyear;
$jobtype = array();
for ($i=1; $i<=12; $i++) {
if ($tmonth == 13 ) {
$tmonth = 1;
$tyear = $tyear + 1;
}
$jobtype [$i][1] = $tmonth; //1 ==> month
$jobtype [$i][2] = $tyear; // 2 ==> Year
$jobtype [$i][3] = 0.00; // 3 ==> jobtype_a
$jobtype[$i][4] = 0.00; // 4 ==> jobtype_b
$jobtype[$i][5] = 0.00; // 5 ==> jobtype_c
$jobtype[$i][6] = 0.00; // 6 ==> jobtype_d
$jobtype[$i][7] = 0.00; // 7 ==> jobtype_direct
$jobtype[$i][8] = 0.00; // 8 ==> jobtype_indirect
$tmonth = $tmonth + 1;
}
$sql ="SELECT JobType, year(TransDate), month(TransDate), sum(Amount)
FROM cashflow
WHERE ProjectCode ='$projectcode'
AND TypeCode = 'P'
GROUP BY JobType, year(TransDate), month(TransDate)
Order by JobType ASC, year(TransDate) ASC, month(TransDate) ASC ";
//$cash_plain
$temp = mysql_query($sql) or die("<h1> Error : $sql</h1>");
$countcash = mysql_num_rows($temp);
while ($data = mysql_fetch_array($temp,MYSQL_BOTH)) {
$cash_type = $data["JobType"];
$tmonth = $data["2"];
$tyear = $data["1"];
if ($firstyear == $tyear) { $i = ($tmonth - $firstmonth) + 1;}
if ($firstyear < $tyear) { $i = (12 - $firstmonth)+1 + $tmonth;}
switch ($cash_type) {
case "A" :
$jobtype[$i][3] = $data["3"];
break;
case "B" :
$jobtype[$i][4] = $data["3"];
break;
case "C" :
$jobtype[$i][5] = $data["3"];
break;
case "D" :
$jobtype[$i][6] = $data["3"];
break;
}
}
$sql ="SELECT ExpenseType, year(DateExpense) ,month(DateExpense) , sum(Amount)
FROM expense_cost
WHERE ProjectCode = '$projectcode'
GROUP BY ExpenseType, year(DateExpense), month(DateExpense)
Order by ExpenseType ASC, year(DateExpense) ASC, month(DateExpense) ASC ";
$temp2 =mysql_query($sql) or die("<h1> Error : $sql</h1>");
$countexpense = mysql_num_rows($temp2);
while ($data2 = mysql_fetch_array($temp2,MYSQL_BOTH)) {
$tmonth = $data2["2"];
$tyear = $data2["1"];
if ($firstyear == $tyear) { $i = ($tmonth - $firstmonth) + 1;}
if ($firstyear < $tyear) { $i = (12 - $firstmonth)+1 + $tmonth;}
if ($data2["ExpenseType"] == "D") {$jobtype[$i][7] = $data2["3"] ;}
if ($data2["ExpenseType"] == "I") {$jobtype[$i][8] = $data2["3"] ;}
}
// Display header 12 month
print "<br/>"."<font size='2'>".เดือนปี."<br/>"."</font>";
for ($i=1; $i <= 12; $i++) {
echo $jobtype[$i][1]." / ".$jobtype[$i][2]."---";
}
print "<br/>"."<font size='2'>".ค่าใช้จ่ายในการบริหารงาน."<br/>"."</font>";
for ($i=1; $i <= 12; $i++) {
echo $jobtype[$i][3]."--------";
}
print "<br/>";
for ($i=1; $i <= 12; $i++) {
echo $jobtype[$i][4]."--------";
}
print "<br/>";
for ($i=1; $i <= 12; $i++) {
echo $jobtype[$i][5]."--------";
}
print "<br/>";
for ($i=1; $i <= 12; $i++) {
echo $jobtype[$i][6]."--------";
}
print "<br/>"."<font size='2'>".ค่าใช้จ่ายในการบริหารงานโครงการโดยทางตรง."<br/>"."</font>";
for ($i=1; $i <= 12; $i++) {
echo $jobtype[$i][7]."--------";
}
print "<br/>"."<font size='2'>".ค่าใช้จ่ายในการบริหารงานโครงการโดยทางอ้อม."<br/>"."</font>";
for ($i=1; $i <= 12; $i++) {
echo $jobtype[$i][8]."--------";
}
print "<br/>";
?>
เมื่อ run souce codeแล้วแสดงข้อมูล ดังนี้
เดือนปี
08 / 2010---9 / 2010---10 / 2010---11 / 2010---12 / 2010---1 / 2011---2 / 2011---3 / 2011---4 / 2011---5 / 2011---6 / 2011---7 / 2011---
ค่าใช้จ่ายในการบริหารงาน
0--------10000.00--------800000.00--------0--------0--------0--------0--------0--------0--------0--------0--------0--------
0--------0--------550000.00--------0--------0--------0--------0--------0--------0--------0--------0--------0--------
0--------0--------0--------0--------0--------0--------0--------0--------0--------0--------0--------0--------
0--------0--------0--------0--------0--------0--------0--------0--------0--------0--------0--------0--------
ค่าใช้จ่ายในการบริหารงานโครงการโดยทางตรง
0--------150000.00--------4300.00--------29800.00--------0--------0--------0--------0--------0--------0--------0--------0--------
ค่าใช้จ่ายในการบริหารงานโครงการโดยทางอ้อม
0--------0--------2500.00--------2250.00--------0--------0--------0--------0--------0--------0--------0--------0--------
แต่ดิฉันต้องการให้ข้อมูลแสดงในรูปแบบตารางประมาณนี้ค่ะ
ลำดับที่ รายการ เดือน/ปี
08 / 2010 9 / 2010 10 / 2010 11 / 2010 12 / 2010 1 / 2011 2 / 2011 รวมเป็นเงิน
ค่าใช้จ่ายในการบริหารงาน
1. ค่าแรง 0.00 10000.00 800000.00 0.00 810000.00
2. ค่าของในประเทศ 0.00 0.00 550000.00 0.00 550000.00
3. ค่าของในต่างประเทศ 0.00 0.00 0.00 0.00 0.00
4. ค่าเบ็ดเตล็ด 0.00 0.00 0.00 0.00 0.00
รวมค่าใช้จ่าย 1ถึง 4 10000.00 1350000.00 0.00 1360000.00
5.ค่าใช้จ่ายในการบริหารงานโดยทางตรง0.00 150000.00 4300.00 29800.00 184100.00
6.ค่าใช้จ่ายในการบริหารงานโดยทางอ้อม0.00 0.00 2500.00 2250.00 4750.00
รวมค่าใช้จ่าย 5ถึง 6 150000.00 6800.00 32050.00 188850.00
ช่วยดิฉันด้วยนะค่ะ
Tag : PHP, MySQL, HTML/CSS, JavaScript, CakePHP, Report Others
|
|
 |
 |
 |
 |
Date :
2010-12-29 14:58:42 |
By :
มือใหม่ |
View :
836 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |