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 :  /proc/self/root/home/pathumthani_integration/integration/application/indicator/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/home/pathumthani_integration/integration/application/indicator/insert_detail.php
<?php
	session_start();
	
	include("../../config/config_epm.inc.php");
	
	$action = $_GET['action'];
	$warning="";
	if($action=="add" || $action=="save" || $action=="delete")
	{
		$indicator_id = $_GET[indicator_id];
		$y_text=$_POST[yyyy];
		$runid =$_GET[runid]; 
		$score_type=$_POST[radcond];
		$score_remark="";
		$score=0;
		
		if($_REQUEST[radcond]=="1")//score
		{
			$score = $_REQUEST[txt_point];
		}
		elseif($_REQUEST[radcond]=="2")
		{
			$score_remark=$_REQUEST[txt_remark];
		}
		//echo "score : ".$score."<br>";
		//echo "score remrak : ".$score_remark;
		//exit();
		if($action=="add")
		{	
			$indicator_id = $_GET[indicator_id];
			$y_text = $_REQUEST[sel_year];
			
			$sql_check_dup = "SELECT * FROM indicator_detail WHERE indicator_id='$indicator_id' AND y_text='$y_text'";

			$res = mysql_db_query($dbname,$sql_check_dup);
			while($rs=mysql_fetch_assoc($res))
			{
				$warning="<i>คำเตือน : พบข้อมูลปี  $y_text ในระบบ ไม่อนุญาติใ่ส่ข้อมูลปีซ้ำกัน!</i>";
				break;
			}
			if(!$warning)
			{
				$sql_insert = "INSERT INTO indicator_detail(indicator_id,y_text,score_type,score,score_remark,updatetime) ";
				$sql_insert .= "VALUES('$indicator_id','$y_text','$score_type','$score','$score_remark',now())";
			}
		}
		elseif($action=="save")
		{
			$indicator_id = $_GET[indicator_id];
			
			$y_text = $_REQUEST[sel_year];
			$y_org = $_REQUEST[h_org_year];
			
			
			$sql_check_dup = "SELECT * FROM indicator_detail WHERE indicator_id='$indicator_id' AND y_text='$y_text'";

			$res = mysql_db_query($dbname,$sql_check_dup);
			while($rs=mysql_fetch_assoc($res))
			{
				if($y_text  != $y_org)
				{
					$warning="<i>คำเตือน : พบข้อมูลปี  $y_text ในระบบ ไม่อนุญาติใ่ส่ข้อมูลปีซ้ำกัน!</i>";
				}
				break;
			}
			if(!$warning)
			{
				$sql_insert = "UPDATE indicator_detail SET y_text='$y_text',score_type='$score_type',score='$score',score_remark='$score_remark',updatetime=now() ";
				$sql_insert .= "WHERE runid='$runid'";
			}
			//echo $sql_insert;
			//exit();
		}
		elseif($action=="delete")
		{
			
			$sql_insert = "DELETE from indicator_detail ";
			$sql_insert .= "WHERE runid=$runid";
			//echo $sql_insert;
			//exit();
		}
		
		mysql_db_query($dbname,$sql_insert);
	}
	else
	{
		
	}
	
?>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
<link href="../libary/style.css" type="text/css" rel="stylesheet">
<link href="../hr_report/images/style.css" type="text/css" rel="stylesheet">
</head>
<style type="text/css">
<!--
A:link {
	FONT-SIZE: 12px;color: #000000;	FONT-FAMILY: Tahoma,  "Microsoft Sans Serif";TEXT-DECORATION: underline;FONT-WEIGHT: bold;
}
A:visited {
	FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: Tahoma,  "Microsoft Sans Serif"; TEXT-DECORATION: underline;FONT-WEIGHT: bold;
}
A:active {
	FONT-SIZE: 12px; COLOR: #014d5f; FONT-FAMILY: Tahoma,  "Microsoft Sans Serif"; TEXT-DECORATION: underline;FONT-WEIGHT: bold;
}
A:hover {
	FONT-SIZE: 12px; COLOR: #f3960b; FONT-FAMILY: Tahoma,  "Microsoft Sans Serif"; TEXT-DECORATION: underline;FONT-WEIGHT: bold;
}
.style1 {color: #FF0000}
-->
</style>

<body>

<form name="form1" action="" method="post">
<?
	if($_GET[action]=="update")
	{
		$indicator_id = $_GET[indicator_id];
		$runid = $_GET[runid];
		$sql_select = "select * from indicator_detail where runid='$runid'";
		$res = mysql_db_query($dbname,$sql_select);
		
		//echo $sql_select;
		//exit();
	
		$rs = mysql_fetch_assoc($res);
		
		$radcond1_check = $rs[score_type]=="1"?"checked":"";
		$radcond2_check = $rs[score_type]=="2"?"checked":"";
			//echo $radcond3_check;
		
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color:#CCCCCC">
  <tr>
    <td align="right">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="30%" align="right"><span class="style1">*</span> ปี พ.ศ.&nbsp;</td>
    <td width="70%"><select name="sel_year">
      <?
			$yyyy = date("Y")+543;
			//echo "<option selected>$yyyy</option>";
			
			while((date("Y")+543)-$yyyy <= 15)
			{
				if($rs[y_text]==$yyyy)
				{
					echo "<option value='".$yyyy."' selected>$yyyy</option>";	
				}
				else
				{
					echo "<option value='".$yyyy."'>$yyyy</option>";	
				}
				
				$yyyy--;
			}
	?>
    </select></td>
  </tr>
  <tr>
    <td width="30%" align="right"><br/>
      เงื่อนไข&nbsp;</td>
    <td><br/>&nbsp;<input name="radcond" id="radcond" type="radio" value="1" <?=$radcond1_check?> onClick="form1.txt_point.focus();" />
      <label> มีคะแนน</label>
         <input type="text" name="txt_point" id="txt_point" value="<?=$rs[score_type]=="1"?$rs[score]:""?>" onClick="form1.radcond[0].checked='checked'"/>
      <br />&nbsp;<input name="radcond" id="radcond" type="radio" value="2" <?=$radcond2_check?> onClick="form1.txt_remark.focus();"/>
      <label> หมายเหตุ</label>
      
      <input type="text" name="txt_remark" id="txt_remark" value="<?=$rs[score_type]=="2"?$rs[score_remark]:""?>" onClick="form1.radcond[1].checked='checked'"/></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><br/>
        <input type="button" name="adddetail2" value="บันทึกการเปลี่ยนแปลง" onClick="return addDetail(form1,'save','<?=$_GET[runid]?>');" />
        <input type="button" name="cleardetail2" value="ยกเลิก" onClick="clearDetail(form1);" /></td>
  </tr>
  <tr>
    <td colspan="3" bgcolor="#CCCCCC">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3" bgcolor="#FFFFFF" height="3"></td>
  </tr>
</table>
<?
	}
	else
	{
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="right">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="30%" align="right"><span class="style1">*</span> ปี พ.ศ.&nbsp;</td>
    <td width="6%"><div><select name="sel_year" onChange="document.getElementById('label_dup').innerHTML='';">
     <?
			$yyyy = date("Y")+543;
			echo "<option selected>$yyyy</option>";
			$yyyy -=1;
			while((date("Y")+543)-$yyyy <= 15)
			{
				if($_REQUEST[sel_year]==$yyyy)
				{
					echo "<option value='".$yyyy."' selected>$yyyy</option>";	
				}
				else
				{
					echo "<option value='".$yyyy."'>$yyyy</option>";	
				}
				$yyyy--;
			}
	?>
    </select></div></td><td width="64%"><div id="label_dup" class="style1"><?=$warning?></div></td>
    <td width="0%">&nbsp;</td>	
  </tr>
  <tr>
    <td width="30%" align="right"><br/>เงื่อนไข&nbsp;</td>
	
   	<td colspan="2">
<br/>
&nbsp;<input name="radcond" id="radcond" type="radio" value="1" onClick="form1.txt_point.focus();form1.txt_remark.value='';" checked="checked" />
<label> มีคะแนน </label>
<input type="text" name="txt_point" id="txt_point" onClick="form1.radcond[0].checked='checked';form1.txt_remark.value=''"/><br />&nbsp;<input name="radcond" id="radcond" type="radio" value="2"  onClick="form1.txt_remark.focus();form1.txt_point.value=''"/>
<label>หมายเหตุ </label>
<input type="text" name="txt_remark" id="txt_remark" onClick="form1.radcond[1].checked='checked';form1.txt_point.value=''"/></td>

   	<td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="2"><br/><input type="button" name="adddetail"  value="บันทึก" onClick="addDetail(form1,'add','<?=$_GET[runid]?>');" />
     
      <input type="button" name="cleardetail" value="ล้าง" onClick="clearDetail(form1);" style="display:none" />      </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3">&nbsp;</td>
    </tr>
</table>
<?
	}
?>
<div align="center">
<div align="center" style="overflow:auto;z-index:99;height:190;width:420;" >
<table width="396" border="0" cellspacing="1" bgcolor="#CCCCCC"  id="table1">
  <tr style="color:#CCCCCC;font-weight:900"	>
    <th width="50" height="20" align="center" style="background-image:url(img/bgheader-2.png)">ลำดับ</th>
	<td width="50" align="center"  style="background-image:url(img/bgheader-2.png)">ปี</td>
	<td align="center"  style="background-image:url(img/bgheader-2.png)">เงื่อนไข</td>
	<td align="center"  style="background-image:url(img/bgheader-2.png)">คะแนน</td>
	<td width="50" style="background-image:url(img/bgheader-2.png)"><div align="center">จัดการ</div></td>
  </tr>
  <?
  /*
  	$_SESSION["check_detail"]=0;
	if($_GET["action"] == "clear")
	{
		unset($_SESSION["arr_detail"]);
		unset($_SESSION["check_detail"]);
	}
	else
	{
		$arr = array("$_GET[yyyy]"=>"$_GET[point]");
		
		if(isset($_SESSION["arr_detail"])) 
		{
			$arr2 = $_SESSION["arr_detail"];
			foreach($arr as $key => $value)
			{
				$arr2[$key] = $value;
			}
			$_SESSION["arr_detail"] = $arr2;
		}
		else
		{
			$_SESSION["arr_detail"] = $arr;
			//print_r($_SESSION[arr_detail]);
		}
	}
  	$arr_temp = $_SESSION["arr_detail"];
	
	*/
	
	$indicator_id = $_GET[indicator_id];
	$rowseq = 0;
	$sql_select = "select * from indicator_detail where indicator_id='$indicator_id' order by y_text desc";
	$res2 = mysql_query($sql_select);
	while($rs=mysql_fetch_assoc($res2))
	{
		//$hilight_tag="";
		$hilight_tag="style=\"background-image:url(img/bgheader-3.png)\"";
		if($_GET["action"]=="update")
		{
			if($rs["runid"] == $_GET["runid"])
			{
				//$hilight_tag="bgcolor=\"#999999\"";
				$hilight_tag="style=\"background-image:url(img/bgheader-2.png)\"";
			}
			else
			{
				$hilight_tag="style=\"background-image:url(img/bgheader-3.png)\"";
			}
		}
	?>
	   <tr  <?=$hilight_tag?>>
		<td>&nbsp;<?=++$rowseq?></td>
		<td align="center"><?=$rs[y_text]?></td>

		<td><div align="right"><?=$rs[score_type]=="1"?"มีคะแนน":"หมายเหตุ";?>&nbsp;</div></td>
		<td><div align="right"><?=$rs[score_type]=="1"?$rs[score]:(trim($rs[score_remark])==""?"-":$rs[score_remark]); ?>&nbsp;</div></td>
		<td><div align="center"><a href="insert_detail.php?action=update&runid=<?=$rs[runid]?>&yyyy=<?=$rs[y_text]?>&indicator_id=<?=$rs[indicator_id]?>"><img src="img/b_edit.png" border="0"/></a>&nbsp;<a href="javascript:deleteDetail(form1,'<?=$rs[runid]?>','<?=$rs[indicator_id]?>')"><img src="img/b_drop.png" border="0"/></a></div></td>
	  </tr>
	  <?
	}
  ?>
</table>
</div>
</div>
<input type="hidden" name="h_org_year" value="<?=$_GET[yyyy]?>">
</form>
</body>
</html>
<script type="text/javascript">
function trim(text)
{
	
	return text.replace( /^\s+|\s+$/g, "" );
}

function checkAddDetail(form)
{
	txt_point = form.txt_point.value;
	
	if(form.radcond[0].checked)
	{
		if(form.txt_point.value=='')
		{
			alert('กรุณาระบุ คะแนน');
			form.txt_point.focus();
			return false;
		}
		else if(!isNumber(txt_point))
		{
				alert('กรุณาระบุค่าเป็นจำนวนตัวเลข ');
				form.txt_point.focus();
				return false
		}
		else
		{
			if(parseFloat(txt_point) < 0 || parseFloat(txt_point) > 5)
			{
				alert('กรุณาระบุค่าเป็นจำนวนตัวเลข ระหว่าง 0 ถึง 5');
				form.txt_point.focus();
				return false
			}		
		}
	}
	return true;
}

function isNumber(n) { 
  return !isNaN(parseFloat(n)) && isFinite(n); 
} 


function clearDetail(form)
{
	window.location.href = "insert_detail.php?indicator_id=<?=$_GET[indicator_id]?>";
}

function deleteDetail(form,runid,indicator_id)
{
	if(confirm('ยืนยันลบ ข้อมูลดังกล่าว'))
	{
		window.location = "insert_detail.php?action=delete&runid="+runid+"&indicator_id="+indicator_id;
	}
}

function addDetail(form,action,runid)
{
	
	yyyy = form.sel_year.options[form.sel_year.options.selectedIndex].text;
	
	if(checkAddDetail(form))
	{
		
		
		for(i=0;i<2;i++)
		{
			//alert(i);
			//alert(form1.radcond[i].checked);
			if(form.radcond[i].checked)
			{
	
				if(i==0)
				{
					point = form.txt_point.value;
				}
				else if(i==1)
				{
					point = form.txt_remark.value;
				}
				break;
			}
		}
	
	//alert("xxx");
	//top.frames["iframe_detail"].location.href="insert_detail.php?yyyy="+yyyy+"&point="+point;
	//return true;
	//window.frames["iframe_detail"].location.href="insert_detail.php?yyyy="+yyyy+"&point="+point;
	//alert("xxx")
	
	//if(
		
	src = "label_dup";
	indicator_id = '<?=$_GET[indicator_id]?>';

	form.action="insert_detail.php?action="+action+"&runid="+runid+"&indicator_id=<?=$_GET[indicator_id]?>";
	form.submit()
	
	}
	//dochange(src,indicator_id,yyyy) 
	
	//if(confirm("are you sure?"))
	//{
	//pause(100);
	//alert(success);
	/*	if(action=="add" && document.getElementById(src).innerHTML != "")
		{
			return false;
		}
		else
		{
			alert("xxx");
			//form.action="insert_detail.php?action="+action+"&runid="+runid+"&indicator_id=<?=$_GET[indicator_id]?>";
			//form.submit();
		}
		*/
	//}

	//	}
	//return true;
}

function pause(numberMillis) 
{
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) 
{
now = new Date();
if (now.getTime() > exitTime)
return;
}
} 



function Inint_AJAX() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest();          } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
};

function dochange(src,indicator_id,yyyy) {
     var req = Inint_AJAX();
     req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
                    document.getElementById(src).innerHTML=req.responseText; //รับค่ากลับมา
               } 
          }
     };
     req.open("GET", "ajax.checkdup.php?action=indicator_detail&indicator_id="+indicator_id+"&yyyy="+yyyy); //สร้าง connection
     req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=tis-620"); // set Header
     req.send(null); //ส่งค่า
}

</script>

Anon7 - 2021