| Server IP : 134.236.49.22 / Your IP : 216.73.216.114 Web Server : Apache/2.2.15 (Fedora) System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 User : apache ( 48) PHP Version : 5.3.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/comIT/ |
Upload File : |
<?php
$ebits = ini_get('error_reporting');
error_reporting($ebits ^ E_NOTICE);
session_start();
include("dbconfig.php");
mysql_select_db("KPI");
mysql_query("SET NAMES 'tis620'; ");
if (isset($_GET['logoff']) && $_GET['logoff']=='yes') {
$_SESSION["uDept"]='NA';
$_SESSION["cUserName"] ='Guest';
$usr='xxxx';
} else {
if (!isset($_SESSION["cUserName"]))$_SESSION["cUserName"] ='Guest';
if (!isset($_SESSION["uDept"]))$_SESSION["uDept"]='NA';
if (!isset($_SESSION["cUserID"]))$usr='xxxx';
else $usr=$_SESSION["cUserID"];
}
if (!isset($_SESSION["Done"])) $_SESSION["Done"] = 'Y';
/* =====================================================================
Authentication
=====================================================================*/
if (isset($_POST['username'])) {
$Login ='UnAuth';
$_SESSION["uDept"]='NA';
$usr = trim($_POST['username']);
/*
เช็ค user ด้วย UDP ผ่านโปรแกรม Register.exe
ให้บริการที่ 192.168.1.14 port 81
ถ้าถูกต้อง จะได้คำตอบเป็น คำนำหน้าชื่อ;ชื่อ นามสกุล
ถ้าไม่ถูกจะได้คำตอบเป็น UnAuth
*/
$server = '192.168.1.14';
$port = 81;
if(($sock = socket_create(AF_INET, SOCK_DGRAM, 0)))
{
$input = 'ChkUsr'.$usr.'#'.trim($_POST['password']);
if (socket_sendto($sock, $input , strlen($input) , 0 , $server , $port))
if (socket_recv ( $sock , $reply , 2045 , MSG_WAITALL ) )$Login =$reply;
}
//---------------------------------------------------------------------------
if ($Login <>'UnAuth') {
$_SESSION["cUserName"] = substr($Login,10);
$cName = substr($_SESSION["cUserName"],strpos($_SESSION["cUserName"],";")+1 );
if (strpos($cName,' ')) $cName =substr($cName ,0,strpos($cName,' '));
$_SESSION["cUserName"] =str_replace(";","",$_SESSION["cUserName"]);
$sql= "select * from indicators where name like '%".$usr."%' "; //เช็คว่ามี usr (id) ใน indicators ไหม
$result=mysql_query($sql);
while ($object = mysql_fetch_array($result)) {
$sql= 'ok' ;
break;
}
if ($sql=='ok'){ //พบ user ID ใน ตาราง indicator
$sql='select * from users where password = "'.$usr.'"';
$result=mysql_query($sql);
while ($object = mysql_fetch_array($result)) { //และพบใน ตาราง Users
if ($object['username']<>$cName || $object['name']<>$_SESSION["cUserName"]){ //ชื่อไม่ตรงให้ update
$sql='update users set username = "'.$cName.'" ,name ="'.$_SESSION["cUserName"].'" where password = "'.$usr.'"';
$result2=mysql_query($sql);
}
if (trim($object['dept'])<>'') $_SESSION["uDept"] = $object['dept'];
$sql='ok';
break;
}
if ($sql <> 'ok'){
$sql='insert into users (username ,name,password) values ("'.$cName.'" ,"'.$_SESSION["cUserName"].'" , "'.$usr.'")';
$result=mysql_query($sql);
}
}
else { //ไม่พบ user ID ใน ตาราง indicator อาจพบใน ตาราง Users
$sql='select * from users where password = "'.$usr.'"';
$result=mysql_query($sql);
while ($object = mysql_fetch_array($result)) {
$_SESSION["uDept"] = $object['dept'];
}
}
}
if ($_SESSION["cUserName"] =='Guest'){
echo '<script language="javascript">';
echo 'alert("ไม่ถูกต้อง")';
echo '</script>';
}
}
$_SESSION["cUserID"]=$usr;
//-----------
if (!isset($_SESSION["DeptName"])){
//เพื่อให้ให้ค้นครั้งเดียวพอ จะได้ไม่หน่วงหน้า web
$curID=0;
$deptList='';
$sql="select * from dept order by dept_id";
$result=mysql_query($sql);
while ($object = mysql_fetch_array($result)) {
if ( $object['dept_id'] == $curID) {
if ($deptList == '') $deptList='"'.$object['dept'].'"';
else $deptList .=',"'.$object['dept'].'"';
$curID +=1;
} else {
for ($i = $curID; $i <= $object['dept_id']; $i++) {
if ($i == $object['dept_id']){
if ($deptList == '') $deptList='"'.$object['dept'].'"';
else $deptList .=',"'.$object['dept'].'"';
} else {
if ($deptList == '') $deptList='""';
else $deptList .=',""';
}
}
$curID = $object['dept_id']+1;
}
}
eval ('$_SESSION["DeptName"] = array('.$deptList.'); ');
}
/* =====================================================================
Call from ADD_Report
/* =====================================================================*/
if ($_SESSION["Done"] <> 'Y'){ //ป้องกัน Refresh
if (isset( $_POST['delete']) && $_POST['delete']=='ลบตัวชี้วัด'){
$sql="update indicators set active ='N' where id_no=".$_POST['id_no'];
$result=mysql_query($sql);
} else {
if (isset($_POST['insert']) || isset( $_POST['append']) ) {
if ($_POST['insert']=='บันทึกข้อมูล' || $_POST['append']=='เพิ่มตัวชี้วัด') {
/*
กรณีที่ SAVE จาก "add_report "
1.ปรับปรุง หน่วยงานรับผิดชอบ dept ฐาน indicators
*************************************
*/
//echo $_POST['insert'].'<br>' ;
//echo $_POST['append'].'<br>' ;
$Savedate = (substr($_POST['DateRegis'],6)-543).'-'.substr($_POST['DateRegis'],3,2).'-'.substr($_POST['DateRegis'],0,2);
$deptList = '';
foreach($_POST["framework"] as $row) {
$deptList .= $row . ','; //ต้องมี , ปิดท้ายเสมอ ไว้ค้นหา
}
$response = str_replace(",",";",$_POST['response']);
if(substr($response,0,1)<> ";") $response =";".$response ;
if ( $_POST['append']=='เพิ่มตัวชี้วัด') {
$sql="insert into indicators (indicators,dept,name,name1,name2,def,sd,st,sr,HA,PA,GA)
values ('".$_POST['indicators']."','".$deptList."','".$_POST['name']."','".$_POST['name1']."','".$_POST['name2']."','"
.$_POST['def']."','".$_POST['sd']."','".$_POST['st']."','".$_POST['sr']."','".$_POST['response2']."','".$_POST['response3']."','".$_POST['response4']."')";
}else{
$sql="update indicators set indicators='".$_POST['indicators']."',dept ='".$deptList."',name='".$_POST['name1']."',
name1='".$_POST['name1']."',name2='".$_POST['name2']."',def='".$_POST['def']."' ,sd='".$_POST['sd']."',st='".$_POST['st']."',sr='".$_POST['sr']."',HA='"
.$_POST['response2']."',PA='".$_POST['response3']."',GA='".$_POST['response4']."',name='".$_POST['name']."' where id_no=".$_POST['id_no'];
}
$result=mysql_query($sql);
//echo $_POST['insert'].'<br>' ; //เอาไว้ตรวจสอบ $_POST['insert']
//echo $_POST['append'].'<br>' ;
//echo $sql.'<br>';
// echo mysql_error(); //เอาไว้ตรวจสอบ error
//echo $Savedate;
//echo $sql; //ตรวจคำสั่ง update
//=======================================================
/*
2.บันทึกข้อมูล " รายวัน " ฐาน Result
************************
โดยลบข้อมูลวันเดิมออกก่อน (ป้องกันบันทึกซ้ำ )
*/
$sql="delete from result where id_no=".$_POST['id_no']." and date = '".$Savedate."'";
$result=mysql_query($sql);
if (($_POST['amount']+0) <> 0 || ($_POST['total']+0) <> 0 ) {
// แล้ว insert ใหม่
$sql="insert into result (id_no,date,amount,total) values (".$_POST['id_no'].",'".$Savedate."',".$_POST['amount'].",".$_POST['total'].")";
$result=mysql_query($sql);
}
/*
3.รวมข้อมูลเป็นรายเดือน
******************
จาก Result เพื่อบันทึกในฐาน goal ช่องเดือน(m1-12 และ m1b-m12b)ของ reccord ตามปีงบปรมาณนั้น
*/
$suma=0;
$sumt=0;
$ButgMonth = substr($Savedate,5,2);
$ButgYear = substr($Savedate,0,4);
if ($ButgMonth >='10') {
$firstButgDate =$ButgYear.'-10-01';
$ButgMonth = $ButgMonth-9; //1,2,3 คือเดือนตุลาคม 10 - ธันวาคม 12
$ButgYear = $ButgYear+1;
} else {
$firstButgDate = ($ButgYear-1).'-10-01';
$ButgMonth = ($ButgMonth+3); //4-12 คือเดือนมกราคม 1 - กันยายน
}
$nextm = date('Y-m-t',strtotime($Savedate)); //วันสุดท้ายของเดือน
if ( $_POST['sr'] =='Y' ) {
/*
3.1 กรณีระบุว่าใช้ผลงาน สุดท้าย
*/
$lSumm=false;
$sql="select * from result where id_no=".$_POST['id_no']." and date >= '".substr($Savedate,0,8)."01' and date <= '".$nextm."' order by date DESC limit 1" ;
$result=mysql_query($sql);
while ($object = mysql_fetch_object($result)) {
$suma = ($object ->amount)+0; //ยอดสุดท้ายในเดือน
break;
}
} else {
/*
3.2 กรณีระบุว่าใช้ผลงานสะสม
*/
$lSumm=true;
$sql="select sum(amount) as suma from result where id_no=".$_POST['id_no']." and date >= '".substr($Savedate,0,8)."01' and date <= '".$nextm."'" ;
$result=mysql_query($sql);
while ($object = mysql_fetch_object($result)) {
$suma = ($object ->suma)+0; //ยอดรวมในเดือน
break;
}
}
if ( $_POST['st'] =='Y' ) {
/*
3.3 กรณีระบุว่าไม่สะสม
*/
$lSumY=false;
$sql="select * from result where id_no=".$_POST['id_no']." and total > 0 and date >= '".$firstButgDate."' and date <= '".$nextm."' order by date DESC limit 1" ;
$result=mysql_query($sql);
while ($object = mysql_fetch_object($result)) {
$sumt = ($object ->total)+0; //ยอดเป้าหมายที่ใส่ล่าสุดในปีถึงเดือนนี้
break;
}
} else {
/*
3.4 กรณีระบุว่าใช้เป้าหมายสะสม
*/
$lSumY=true;
$sql="select sum(total) as sumt from result where id_no=".$_POST['id_no']." and date >= '".substr($Savedate,0,8)."01' and date <= '".$nextm."'" ;
$result=mysql_query($sql);
while ($object = mysql_fetch_object($result)) {
$sumt = ($object -> sumt)+0; //เป้าหมายสะสมในเดือน
break;
}
}
// 4 บันทึก ผลรายเดือนที่ได้ ลงฐาน goal บรรทัด " ปีงบประมาณ "ที่ระบุ
$sql="select * from goal where id_no=".$_POST['id_no']." and year = '".$ButgYear."' limit 1" ;
$result = mysql_query($sql);
$Rows = mysql_num_rows($result);
if ($Rows == 0) //ไม่เคยมีบรรทัดปีนี้ ให้ insert
$sql="insert into goal (id_no,year,compair,goal,eva,m".$ButgMonth.",m".$ButgMonth."b)
value (".$_POST['id_no'].",'".$ButgYear."','".$_POST['goal1']."',".$_POST['goal2'].",'".$_POST['goal3']."',".$suma.",".$sumt.")";
else //เคยมีบรรทัดปี ให้Update
$sql="update goal set m".$ButgMonth."=".$suma.",m".$ButgMonth."b=".$sumt.
",goal=".$_POST['goal2'].",eva='".$_POST['goal3']."',compair='".$_POST['goal1'].
"' where id_no=".$_POST['id_no']." and year='".$ButgYear."'";
$result=mysql_query($sql);
/*
5.รวมข้อมูลรายปี goal ช่องเดือน 1 ถึง 12
*/
$suma=0;
$sumt=0;
$sql="select * from goal where id_no=".$_POST['id_no']." and year = '".$ButgYear."' limit 1" ;
$result=mysql_query($sql);
while ($object = mysql_fetch_array($result)) {
$compair = trim($object['compair'] );
$eva =$object['eva'] ;
$goal =$object['goal'] ;
for ($i = 1; $i <= 12; $i++) {
if ($lSumm) $suma = $suma+$object["m".$i];
else if ($object["m".$i] > 0) $suma = $object["m".$i]; // กรณีระบุว่าใช้ผลงาน สุดท้าย (ลงท้ายด้วย L)
if ($lSumY) $sumt = $sumt +$object["m".$i."b"]; //รวมทุกเดือน
else if ($object["m".$i."b"] > 0) $sumt = $object["m".$i."b"]; //เดือนที่มีค่าล่าสุด
}
}
$totalx=$suma; // ผลประเมิน บันทึกไว้ใน $totalx
switch (substr(trim($eva),0,1)) {
case 'n':
if ($suma==0) $totalx = 0.00;
else {
if ($sumt==0) $totalx = $suma;
else $totalx = $suma /$sumt ;
}
break;
case ':':
if ($suma==0) $totalx = 0.00;
else {
if ($sumt==0) $totalx = 1.00;
else $totalx = $suma /$sumt ;
}
break;
case '%': // ถ้าเป้าเป็น % ผลประเมินต้องเป็น %
if ($suma==0) $totalx = 0.00;
else {
if ($sumt==0) $totalx = 100.00 ;
else $totalx = $suma *100/$sumt ;
}
break;
case 'T': // ถ้าเป้าเป็น % ผลประเมินต้องเป็น %
if ($suma==0) $totalx = 0.00;
else {
if ($sumt==0) $totalx = 1000.00 ;
else $totalx = $suma *1000/$sumt ;
}
break;
case 'H': // ถ้าเป้าเป็น % ผลประเมินต้องเป็น %
if ($suma==0) $totalx = 0.00;
else {
if ($sumt==0) $totalx = 100000.00 ;
else $totalx = $suma *100000/$sumt ;
}
break;
case '/': // ถ้าเป้าเป็นค่าเฉลี่ย
if ($suma==0) $totalx = 0.00;
else {
if ($sumt==0) $totalx = $suma;
else $totalx = $suma /$sumt ;
}
break;
}
if ($compair =="=" || $compair=='') $compair ="==";
$result='red';
//พิจารณาตาม compair
eval ('if ('.$totalx.$compair.$goal.') $result = "green"; ');
//บันทึกผลประเมิน ปี
$sql="update goal set total=".$suma.",totalb=".$sumt.",totalx=".$totalx.",result='".$result."'
where id_no=".$_POST['id_no']." and year='".$ButgYear."'";
//echo $sql.'<br>';
$result=mysql_query($sql);
}
}
}
}
$_SESSION["Done"] = 'Y';
/* =====================================================================
onChange() จะมีตัวแปร $_GET[ ] ส่งมาด้วย
=====================================================================*/
if (isset($_GET['Rdept'])) $_SESSION['deptRep'] = $_GET['Rdept'];
elseif (!isset($_SESSION['deptRep'])) $_SESSION['deptRep'] = 'All';
if (isset($_GET['resp'])) $_SESSION['resp'] = $_GET['resp'];
elseif (!isset($_SESSION['resp'])) $_SESSION['resp'] = 'All';
if (isset($_GET['work'])) $_SESSION['work'] = $_GET['work'];
elseif (!isset($_SESSION['work'])) $_SESSION['work'] = 'All';
if (isset($_GET['byear'])) $_SESSION['byear'] = $_GET['byear'];
if (!isset($_SESSION['byear'])){ // -- เข้า page นี้ครั้งแรกให้ใช้ ปีปัจจุบัน
$year = date('Y');
$mon = date('m');
if ($mon >= 10) $_SESSION['byear'] =$year+544;
else $_SESSION['byear'] =$year+543;
}
$year = $_SESSION['byear']-543; // -- เข้า page ครั้งต่อๆไป จะมีปีเป็นตามที่ใช้อยู่
?>
<!DOCTYPE html>
<html>
<script type="text/javascript">
function getValue(vname)
{
var n = document.getElementById(vname).value
return n;
}
function changeFunc(cLOG) {
var URL;
URL= "<?php echo $_SERVER['PHP_SELF'] ?>";
URL+= "?&byear=";
URL+= getValue('byear');
URL+= "&Rdept=";
URL+= getValue('dept_id');
URL+= "&resp=";
URL+= getValue('resp_id');
URL+= "&work=";
URL+= getValue('work');
URL+= "&logoff=";
URL+= cLOG;
window.location= URL;
}
function createDynamicURL(cIDNO,cYear,cName){
var URL;
URL="index_y2.php?&id_no=";
URL+= cIDNO;
URL+= "&rYear=";
URL+= cYear;
URL+= "&RepName=";
URL+= cName;
return URL;
}
function RedirectURL(cIDNO,cYear,cName){
//window.location= createDynamicURL(cIDNO,cYear,cName);
window.open(createDynamicURL(cIDNO,cYear,cName), '_blank');
}
</script>
<style>
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
</style>
<head>
<title>รายงานตัวชี้วัด</title>
<script language="JavaScript" src="file:///W|/KPI monitor/bak/date-picker.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<body background="file:///W|/KPI monitor/image/bg.JPG" >
<table width="1015" height="51" border="0" align="center" cellpadding="3">
<tr>
<td align="center"><table width="1200" border="0">
<tr align="left" valign="top">
<td width="180"><p><a href="file:///W|/KPI monitor/K/index.html"></a><a href="image/คู่มือ KPI.pdf"><img src="file:///W|/KPI monitor/image/major.gif" align="left" title="คู่มือการใช้งาน" ></p>
<p>คู่มือการใช้งาน</p></a></td>
<td width="700" align="center"><img src="file:///W|/KPI monitor/image/templatemo_logo.png" width="184" height="43" align="top"></a>
<div align="center"><br>
<span class="style3" > ตอบสนองวิสัยทัศน์ : บริการปลอดภัย ร่วมใจทุกภาคี เจ้าหน้าที่มีความสุข</span></td>
<td width="306"> ชื่อผู้ใช้งาน : <?php echo $_SESSION["cUserName"].'<br>Department:'.$_SESSION["uDept"]; ?></td>
</tr>
</table>
<table width="1200" height="45" border="2" align="center" cellpadding="3" cellspacing="2" bordercolor="#000000" background="file:///W|/KPI monitor/bak/image/bg.JPG">
<tr>
<td width="75" align="center" ><span class="style4"><a href="file:///W|/KPI monitor/index.php">เกี่ยวกับเรา</a></span></td>
<td width="100"><p>ปี
<input type="text" name="byear" id="byear" size="10" value="<? echo $_SESSION['byear'];?>" onChange="changeFunc('')">
</td>
<td width="264" bgcolor="#F0F0F0"><p>ฝ่ายงาน
<select name="dept_id" id="dept_id" style="width:75%; height:24px" onChange="changeFunc('')" >
<option value="All" <?php if($_SESSION['deptRep'] == 'All'){echo("selected");}?>> ทั้งหมด</option>
<option value="Adm" <?php if($_SESSION['deptRep'] == 'Adm'){echo("selected");}?>> ที่รับผิดชอบ</option>
<?php
//mysql_select_db("KPI");
//mysql_query("SET NAMES 'tis620'; ");
$sql="select * from dept ";
$result=mysql_query($sql);
while ($rowResp = mysql_fetch_object($result)) {
if ($_SESSION['deptRep'] == $rowResp -> dept_id)
echo '<option value="'.$rowResp -> dept_id .'" selected >'.$rowResp-> dept_id.
" ".$rowResp-> dept.'</option>';
else
echo '<option value="'.$rowResp -> dept_id .'" >'.$rowResp-> dept_id.
" ".$rowResp-> dept.'</option>';
}
?>
</select></p></td>
<td width="228"><p>ภารกิจ
<select name="resp_id" id="resp_id" style="width:75%; height:26px" onChange="changeFunc('')" >
<option value="All" <?php if($_SESSION['resp'] == 'All'){echo("selected");}?>> ทั้งหมด</option>
<?php
mysql_select_db("KPI");
mysql_query("SET NAMES 'tis620'; ");
$sql="select * from response order by resp_id";
$result=mysql_query($sql);
while ($rowresp = mysql_fetch_object($result)) {
if ($_SESSION['resp'] == $rowresp -> colum_name)
echo '<option value="'.$rowresp -> colum_name .'" selected >'.$rowresp-> resp_id.
" ".$rowresp-> response.'</option>';
else
echo '<option value="'.$rowresp ->colum_name.'" >'.$rowresp-> resp_id.
" ".$rowresp-> response.'</option>';
}
?>
</select>
</p></td>
<td width="200">ประเมินผล
<select name="work" id="work" style="width:50%; height:26px" onChange="changeFunc('')" >
<option value="All" <?php if ($_SESSION['work'] == 'All') echo 'selected'; ?>>ทั้งหมด</option>
<option value="green" <?php if ($_SESSION['work'] == 'green') echo 'selected'; ?>>ผ่าน</option>
<option value="red" <?php if ($_SESSION['work'] == 'red') echo 'selected'; ?>>ไม่ผ่าน</option>
<option value="null" <?php if ($_SESSION['work'] == 'null') echo 'selected'; ?>>ไม่มีผลงาน</option>
</select> </td>
<td width="42" align="center" valign="top"><?php
if ($_SESSION["uDept"]=='NA')
echo '<a href="login.php"><img src="image/user.gif"
width="31" height="30" border="0" title="ลงชื่อเข้าใช้งาน">Login</a>';
else
echo '<img src="image/log_off.png"
width="31" height="30" border="0" title="ออกจากระบบ" onclick="changeFunc(\'yes\')">Logout';
?></td>
</tr>
</table>
<?php
$sql="select b.id_no,b.dept,b.indicators,b.HA,b.PA,b.GA,b.name1,b.name2,b.name,b.def from indicators b where b.active = 'Y'";
if ($_SESSION['deptRep'] <>'All' ) {
if ($_SESSION['deptRep'] == 'Adm' ) $sql .=" AND instr(b.name,'".$usr."') " ;
else $sql .=" AND instr(b.dept,'".$_SESSION['deptRep']."')" ;
}
if ($_SESSION['resp'] <> 'All' ) {
$sql.= " AND b." .$_SESSION['resp']." is not null AND b.".$_SESSION['resp']." <> '' order by b.".$_SESSION['resp'];
}
else $sql .= " order by id_no";
//echo $sql.'<br>';
//echo $sql; // เอาไว้อ่านทบทวนค่ำสั่ง SQL
?>
<br>
<table width="1300" height="63" border="2" align="center" cellpadding="3" bgcolor="#FFFFFF">
<tr>
<td width="75" align="center" bgcolor="#66FFFF"><strong> <?php
if ($_SESSION['resp'] <> 'All' ) echo $_SESSION['resp'];
else echo 'ID_NO';
?></strong>
</td>
<td width="320" align="center" bgcolor="#66FFFF"><strong> ตัวชี้วัด Indicators</strong></td>
<td width="94" align="center" bgcolor="#66FFFF"><strong> ค่าเป้าหมาย </strong></td>
<td width="54" align="center" bgcolor="#CCCCCC"><strong> ปี <? echo $year+537;?></strong></td>
<td width="54" align="center" bgcolor="#CCCCCC"><strong> ปี <? echo $year+538;?></strong></td>
<td width="54" align="center" bgcolor="#CCCCCC"><strong> ปี <? echo $year+539;?></strong></td>
<td width="54" align="center" bgcolor="#CCCCCC"><strong> ปี <? echo $year+540;?></strong></td>
<td width="54" align="center" bgcolor="#CCCCCC"><strong> ปี <? echo $year+541;?></strong></td>
<td width="54" align="center" bgcolor="#CCCCCC"><strong> ปี <? echo $year+542;?></strong></td>
<td width="54" align="center" bgcolor="#66FFFF"><strong> ปี <? echo $year+543;?></strong></td>
<td width="120" align="center" bgcolor="#66FFFF"><strong>กลุ่มงาน</strong></td>
<td width="100" align="center" bgcolor="#66FFFF"><strong>ผู้รับผิดชอบ</strong></td>
</tr>
<?php
$nIndicators=0;
$nPass=0;
$nlIndicators=0;
$nlPass=0;
$nHpass=0;
$nHIndi=0;
$lastID='';
$result=mysql_query($sql);
while ($object = mysql_fetch_object($result)) { //แต่ละ ID_NO ในตาราง indicators ที่ Active ='Y' (ไม่ได้ลบ)
$deptList = $object -> dept;
$id_no = $object -> id_no;
$indicators=$object -> indicators;
$name1=$object -> iname1;
$name2=$object -> iname2;
$def=$object -> def;
if ($_SESSION['resp'] <> 'All' ) eval ('$showid = $object ->'.$_SESSION['resp'].';');
else $showid = $id_no;
if ( substr($showid,-2,2)=='00') { //กรณีหัวข้อกลุ่ม
$lastID=$showid;
$nIndicators +=$nHIndi;
$nPass += $nHpass;
if ($_SESSION['resp']=='HA'){
if ( substr($showid,2,5)=='00000'){
$color1='#880088'; //สีของหัวข้อหลัก <a>
$color2='#0000ff'; //สีของหัวข้อหลัก
$pb = '<br>';
$pe='';
$nHpass=0;
$nHIndi=0;
$colsp='10';
} else {
$color1='#0000ff'; //สีของหัวข้อรอง <a>
$color2='#000000'; //สีของหัวข้อรอง
$pb = '';
$pe='';
$nHpass=1;
$nHIndi=1;
$colsp='11';
}
echo '<tr height="24" >';
if (InDept( $deptList, $_SESSION['uDept'] ) || strpos($namecode,$usr ) ) {
echo '<td >'.$pb.'<div align="center"><a href="add_report.php?&id_no='.$id_no.'&goal=&eva=&compair=" style="color:'.$color1.';">'.$showid.'</a></div>'.$pe.'</td>';
echo '<td colspan="'.$colsp.'">'.$pb.'<div align="left"><a href="add_report.php?&id_no='.$id_no.'&goal=&eva=&compair=" style="color:'.$color1.';">'.$indicators.'</a></div>'.$pe.'</td>';
} else {
echo '<td >'.$pb.'<font color="'.$color2.'" ><div align="center">'.$showid.'</div></font>'.$pe.'</td>';
echo '<td colspan="'.$colsp.'">'.$pb.'<font color="'.$color2.'" ><div align="left" >'.$indicators.'</div></font>'.$pe.'</td>';
}
if ($colsp=='10'){
echo '<td ><font color="'.$color2.'" ><div align="left" >';
if ($nIndicators > 0){
echo $nPass-$nlPass;
echo ' / ';
echo $nIndicators - $nlIndicators;
}
$nlIndicators=$nIndicators;
$nlPass=$nPass;
echo '</div></font></td>';
}
echo '</tr>';
}
} else {
//รายการย่อย
$namecode =$object ->name ;
$name =''; //ชื่อ user สำหรับแสดง
while ($namecode <> ''){ //นำรหัสมาแปลงเป็นชื่อ ทีละคน
if (strpos($namecode,',')){
$i = strpos($namecode,',');
$tcode = trim(substr($namecode,0,$i));
$namecode =trim(substr($namecode,$i+1));
}else{
$tcode = trim($namecode);
$namecode = '';
}
$sql ="select username from users where password='".$tcode."' limit 1";
$resname=mysql_query($sql);
while ($rec = mysql_fetch_object($resname)) {
$sql = $rec-> username;
if (strpos( $sql,' ')) $sql = substr($sql,0,strpos( $sql,' '));
if ( $name =='') $name = $sql ;
else $name.= ', '. $sql ;
}
}
$namecode =$object ->name ;
$ntotalb =0;
$cResult = '';
$ntotalx = 0;
$sql="select * from goal where id_no=".$id_no." and year ='".$year."'";
$rg=mysql_query($sql);
while ($re = mysql_fetch_object($rg)) {
$ntotalb = $re -> totalb;
$ntotalx = $re -> totalx;
$cResult = $re -> result;
$no= $re -> no;
$compair = $re ->compair ;
$eva = $re ->eva ;
$goal = $re ->goal ;
$cgoal = trim($compair).trim($goal).' '.trim($eva);
}
$cInlist = 'Y';
if ($_SESSION['work'] <> 'All' ){ //ตรวจผลงาน เพื่อแสดงพื้นสี ประกอบด้วย
if ($_SESSION['work'] == 'null' ) {
if ($ntotalb > 0) $cInlist = 'N';
} else {
if (trim($cResult)<>$_SESSION['work']) $cInlist='N';
}
}
if ($cInlist=='Y') {
$Ayear =array(array('green','- '),array('green',' '),array('green',' '),array('green',' '),array('green',' ')
,array('green',' '));
$minYear = $year-6;
$sql="select year,totalx,result from goal where id_no=".$id_no." and year >='".$minYear."' and year < '".$year."'";
$resYear=mysql_query($sql);
while ($rec = mysql_fetch_object($resYear)) {
$nowY =$rec-> year;
$nowY = 6-($year-$nowY );
$Ayear[$nowY][1] = $rec-> totalx;
$Ayear[$nowY][0] = ($rec-> result);
}
//<tr>
if (substr($lastID,0,5) == substr($showid,0,5)) { //เป็นข้อย่อย
$lSub=true;
$color1='#002255'; //สีของหัวข้อย่อย มี link
$color2='#004499'; //สีของหัวข้อย่อย
} else { //หัวข้อรายการปกติ
$lSub=false;
$color1='#0000ff'; //สีของหัวข้อปกติ มี link
$color2='#000000';
}
echo '<tr height="24" >';
if (InDept( $deptList, $_SESSION['uDept'] ) || strpos($namecode,$usr ) ) {
echo '<td ><div align="center"><a href="add_report.php?&id_no='.$id_no.'&goal='.$goal.'&eva='.$eva.'&compair='.$compair.'" style="color:'.$color1.';">'.$showid.'</a></div></td>';
echo '<td ><div align="left"><a href="add_report.php?&id_no='.$id_no.'&goal='.$goal.'&eva='.$eva.'&compair='.$compair.'" style="color:'.$color1.';">'.$indicators.'</a></div></td>';
} else {
echo '<td ><font color="'.$color2.'" ><div align="center">'.$showid.'</div></font></td>';
echo '<td ><font color="'.$color2.'" ><div align="left" >'.$indicators.'</div></font></td>';
}
echo '<td align="center"><div align="center" class="tooltip">'.$cgoal .'<span class="tooltiptext">'.$def.'</span></div></td>';
for ($i = 0; $i <= 6; $i++) { // --- แสดง ข้อมูลปี
$show = '<td align="right" ';
if ($i==6 && $ntotalb == 0) $show.='bgcolor="#FFFF00"';
$show.=' bordercolor="#FFFFFF"><a href="#" onclick="RedirectURL(\''.$id_no.
'\',\''.($year+(537+$i)).'\',\''.$indicators.'\');return false;" target="_parent" class="style14"
style="text-decoration: none;"><font color="';
if ($i == 6){ //ปีเป้าหมาย
$show .=$cResult.'">'.$ntotalx.'</font></a></td>';
if ($lSub) {
if ($cResult=='red') $nHpass =0;;
} else {
$nIndicators += $nHIndi+1;
$nHIndi =0;
$nPass += $nHpass;
if ($cResult=='green') $nPass += 1; //ผลงานผ่านตัวชีวัด
$nHpass =0;
}
}
else $show .=$Ayear[$i][0].'">'.$Ayear[$i][1].'</font></a></td>';
echo $show;
}
if (substr_count($deptList,',') > 1) echo '<td align="center"><div class="tooltip">'.$deptList.'<span class="tooltiptext">'. DeptName($deptList).'</span></div></td>';
else echo '<td>'.DeptName($deptList).'</td>';
echo '<td align="center">'. $name.'</td></tr>';
//</tr>
}
}
}
$nIndicators +=$nHIndi;
$nPass += $nHpass;
if ($nIndicators > 0){
echo '<tr height="24" >';
echo '<td colspan="11"></td><td><font color="#000000"><div align="left" >';
echo $nPass-$nlPass;
echo ' / ';
echo $nIndicators - $nlIndicators;
echo '</div></font></td></tr>';
}
?>
</table>
<table width="1300" height="63" border="2" align="center" cellpadding="3" bgcolor="#FFFFFF">
<tr>
<td width="184" align="center"><strong> จำนวนตัวชี้วัดทั้งหมด</strong></td>
<td><?php echo $nIndicators; ?></td>
<td>ผ่านเป้าหมาย :<?php echo $nPass; ?></td>
<td>ผ่านเป้าหมาย :<?php echo number_format($nPass*100/$nIndicators,2); ?> %</td>
</tr>
</table>
<?php
function InDept($i_Dept,$u_Dept){
if ($u_Dept=='All,') return true;
if (trim($i_Dept)=='' || $u_Dept=='NA') return false;
while ($i_Dept<>''){
$nAt = strpos($i_Dept,',');
if ($nAt ) {
$subc = substr($i_Dept,0,$nAt+1);
if (substr_count($u_Dept,$subc) > 0) return true;
$i_Dept = substr($i_Dept,$nAt+1);
} else return false;
}
return false;
}
function DeptName($cList){
$cName='';
while ($cList<>''){
$nAt = strpos($cList,',');
if ($nAt ) {
$subc = substr($cList,0,$nAt);
$cList = substr($cList,$nAt+1);
} else {
$subc = 'NA';
$cList = '';
}
if ($subc <> 'NA'){
if ($cName=='') $cName =$_SESSION['DeptName'][($subc+0)];
else $cName .= ','.$_SESSION['DeptName'][($subc+0)];
}
}
return $cName; //number_format($number, 2, '.', '');
}
?>
</body>
</html>