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/eoffice/application/document/user/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/eoffice/application/document/user/Copy (2) of org_group.php
<?
/*****************************************************************************
Function		: แก้ไขข้อมูลของ epm_staffgroup
Version			: 1.0
Last Modified	: 16/8/2548
Changes		:

*****************************************************************************/
$type=$_GET[type];
include "epm.inc.php";
$report_title = "กลุ่มบุคลากร";

$msg = "";
if ($_SERVER[REQUEST_METHOD] == "POST"){ 
$type=$_POST[type];
/*
	// remove slashes from variable
	foreach ($_POST as $key => $value){
		if (!is_array($value) && !is_numeric($value)){
			$_POST[$key] = stripslashes($value);
		}
	}
*/

// echo "<pre>";
// print_r($_POST);
	if ($digit){
			$sql_del="
			DELETE FROM ref_digit where ref_digit.gid=$id
			";
			$rsi=mysql_query($sql_del);	
				foreach($digit as $num => $val){
				if($digit_char[$num]){ $val=$digit_char[$num];}
					$sql="
			INSERT INTO `ref_digit` 
			( `id` , `digit` , `value` , `type` , `gid` ) 
			VALUES (
			NULL , '$num', '$val', '$type[$num]', '$id'
			)	
			";
			$rsi=mysql_query($sql);
			}
			$type="system";
	}


	if ($groupname == ""){
		$msg = "กรุณาระบุชื่อของกลุ่มบุคลากร";
	}else{
	
//	if($type=="system"){ 
	
	
	/*
	$sql_check_ref="select * from  $table_staffgroup where refid_info LIKE '%$refid_info%' AND $table_staffgroup.gid !='$id' ";
	$rs_c=mysql_query($sql_check_ref);
	$row_c=mysql_num_rows($rs_c);
	if($row_c){ echo "<br>&nbsp;&nbsp;<b>เลขส่วนหน้าที่ระบุไม่สามารถบันทึกได้ เนื่องจากมีการใช้งานโดย หน่วยงาน/กลุ่มภารกิจ อื่น</b>";}else{
	}
	*/
	
		if ($action == "new" || $action == "addsubgroup"){
		if($type=="profile"){
			$sql = "insert into $table_staffgroup ( org_id,groupname,comment,owner_id,parent,staffid) values ('$org_id','$groupname','$comment','$owner_id','$parent','$session_staffid');";
		}else{ //if($type=="system")
			$sql = "insert into $table_staffgroup ( org_id,groupname,comment,owner_id,parent,refid_info) values ('$org_id','$groupname','$comment','$owner_id','$parent','$refid_info');";
		}
		}else if ($action == "edit"){
			$sql = "update $table_staffgroup  set groupname='$groupname',comment='$comment',org_id='$org_id',owner_id='$owner_id',refid_info='$refid_info' where gid = '$id'; ";
		}else{
			header("Location : ?org_id=$org_id&type=$type");
			exit;
		}

		@mysql_query($sql);
		if (mysql_errno() != 0){
			$msg = "ไม่สามารถบันทึกลงฐานข้อมูลได้<BR>$sql<BR><BR>" . mysql_error() ;
		}else{
			// SUCCESS
			if ($action == "new" || $action == "addsubgroup"){
				$id = mysql_insert_id();
			}

			//จัดการ บุคลากรในกลุ่ม
			mysql_query("delete from $table_groupmember  where gid='$id';"); //ลบ
			if ($_POST[member]){
				foreach ($_POST[member] as $n => $staffid ){
					mysql_query("insert into $table_groupmember (gid,staffid) values('$id','$staffid');"); //เพิ่มอันที่เลือก
				}
			}
			

			//จัดการ สถานะกลุ่ม			
			mysql_query("delete from profile_permission where gid='$id';"); //ลบ
			if ($_POST[permit]){
			
				foreach ($_POST[permit] as $n => $pid ){
					if(($n=="radio")&&($pid)) {$n="$pid";}
					mysql_query("insert into profile_permission (gid,pid) values('$id','$n');"); //เพิ่มอันที่เลือก
				}
			}

			echo "<script>alert('บันทึกข้อมูลเรียบร้อยแล้ว'); if (parent.leftFrame) {parent.leftFrame.location=parent.leftFrame.location;} location.href='?org_id=$org_id&type=$type';</script>";
		//	header("Location: ?org_id=$org_id");
			exit;
		}


//	}

	}
	$action = "";
}else	if ($action == "delete" && $id > ""){

	if (Query1("select count(*) from $table_staffgroup  where parent='$id';") > 0){
		echo "<script>alert('ไม่สามารถลบข้อมูลได้ เพราะยังมีกลุ่มย่อยภายใต้กลุ่มนี้อยู่'); location.href='?org_id=$org_id&type=$type';</script>";
		exit;		
	}

	if (Query1("select count(*) from $table_groupmember  where gid='$id';") > 0){
		echo "<script>alert('ไม่สามารถลบข้อมูลได้ เพราะยังมี ผู้ใช้ที่สังกัดกลุ่มนี้อยู่'); location.href='?org_id=$org_id&type=$type';</script>";
		exit;		
	}

	$gname = Query1("select groupname  from $table_staffgroup  where gid='$id' order by trim($table_staffgroup.groupname) ASC ; ");
	if ($gname != "Guest" && $gname != "Administrator") { //ห้ามลบ Gues และ Administrator
		@mysql_query("delete from $table_staffgroup  where gid='$id';");
		if (mysql_errno() > 0){
			$msg = "ไม่สามารถลบข้อมูลได้";
		}else{
			echo "<script>alert('ลบข้อมูลเรียบร้อยแล้ว'); if (parent.leftFrame) {parent.leftFrame.location=parent.leftFrame.location;} location.href='?org_id=$org_id&type=$type';</script>";
		}
	}
	$action = "";

}
?>


<HTML>
<HEAD>
<TITLE><?=$report_title?></TITLE>
<META http-equiv="Content-Type" content="text/html; charset=windows-874">
<LINK href="../../../common/style.css" rel=StyleSheet type="text/css">
<SCRIPT language=JavaScript>
function checkFields() {
	missinginfo1 = "";
	missinginfo = "";
	if (document.form1.groupname.value == "")  {	missinginfo1 += "\n- ช่องชื่อกลุ่มบุคลากรไม่สามารถเป็นค่าว่าง"; }		
	if (missinginfo1 != "") { 
		missinginfo += "ไม่สามารถเพิ่มข้อมูลได้  เนื่องจาก \n";
		missinginfo +="_____________________________\n";
		missinginfo = missinginfo + missinginfo1  ;
		missinginfo += "\n___________________________";
		missinginfo += "\nกรุณาตรวจสอบ อีกครั้ง";
		alert(missinginfo);
		return false;
		}
	}
	
	
var checkflag = "false";
function check(field) {
	if (checkflag == "false") {
		for (i = 0; i < field.length; i++) {
			field[i].checked = true;
		}
		checkflag = "true";
		return "ไม่เลือกทั้งหมด"; 
	} else {
		for (i = 0; i < field.length; i++) {
			field[i].checked = false; 
		}
		checkflag = "false";
		return "เลือกทั้งหมด"; 
	}

}

function checkAll(field,x) {

	for (i = 0; i < field.length; i++) {
		field[i].checked = x;
	}
}

</SCRIPT>
	  <SCRIPT language="JavaScript" type="text/javascript" src="ajax_search.js"></SCRIPT>
</HEAD>

<BODY bgcolor="#FFFFFF">
<BR>
<?

if ($_GET[action] == "edit" || $_GET[action] == "new" || $_GET[action] == "addsubgroup" ){
	if ($_GET[action] == "edit"){
		$sql = "select * from $table_staffgroup  where gid='$id'  ";
		$result = mysql_query($sql);
		$rs = mysql_fetch_assoc($result);
		$title="แก้ไข";
		if ($rs[groupname] == "Guest" || $rs[groupname] == "Administrator"){
			$systemgroup = " onfocus='blur();' stylle='background: #8090A0;' "; // Lock
		}else{
			$systemgroup = "";
		}
	}else if ($_GET[action] == "addsubgroup"){
		$title = "เพิ่ม";
		$report_title = "กลุ่มย่อยในกลุ่ม " . Query1("select groupname  from $table_staffgroup  where gid='$parent'  ;");
	}else{
		$rs = array();
		$title = "เพิ่ม";
	}
?>
<FORM action="" method="POST" NAME="form1" ONSUBMIT="checkFields();">
<INPUT TYPE="hidden" NAME="id" VALUE="<?=$id?>" >
<INPUT TYPE="hidden" NAME="parent" VALUE="<?=$parent?>" >
<INPUT TYPE="hidden" NAME="org_id" VALUE="<?=$org_id?>" >
<INPUT TYPE="hidden" NAME="action" VALUE="<?=$action?>"  >
<INPUT TYPE="hidden" NAME="type" VALUE="<?=$type?>"  >
<TABLE border=0 align=center cellspacing=1 cellpadding=3 bgcolor="#808080" width="98%">
    <TR bgcolor="#A3B2CC"> 
      <TD colspan=2> &nbsp; <FONT COLOR="WHITE" style="font-size:14pt;"><B><?=$title?>ข้อมูล<?=$report_title?></B></FONT></TD>
    </TR>


	<TR bgcolor=white valign=top> 
      <TD class="link_back">ชื่อกลุ่ม</TD>
      <TD> 
        <INPUT TYPE="text" NAME="groupname" VALUE="<?=$rs[groupname]?>" size="80" maxlength=200 class=inputbox <?=$systemgroup?>>      </TD>
    </TR>
	<? if($type=="system"){ ?>
	<TR bgcolor=white valign=top>
		<TD class="link_back">สิทธิ์</TD>
		<TD>
			<?
			$sql_check="select * from profile_permission where gid='$id' ";
			$result_check = mysql_query($sql_check);
			while($crs = mysql_fetch_assoc($result_check)){
			$check_status[$crs[pid]]="on"; 
			}
			
			$sql_status="select * from permission_status";
			$result = mysql_query($sql_status);$radio_check=0;
			while($rse = mysql_fetch_assoc($result))	{
			if(!$rse[type]){
			?>
			<INPUT type="checkbox" name="permit[<?=$rse[pid]?>]" value="on" <? if($check_status[$rse[pid]]=="on"){echo "checked";}?>><?=$rse[status]?><BR>
			<?
			}else if($rse[type]=="radio"){ if($radio_check==0){echo "<hr>"; $radio_check++;}
			?><INPUT type="radio" name="permit[radio]" value="<?=$rse[pid]?>" <? if($check_status[$rs[pid]]=="on"){echo "checked";}?>><?=$rse[status]?><?
			}
			}
			?>		</TD>
	</TR>
	<?}?>
	<!--<TR bgcolor=white valign=top> 
      <TD class="link_back">หัวหน้า/ผู้รับผิดชอบ</TD>
      <TD> 
       <SELECT name="owner_id">
	   <OPTION value="0"> - ไม่ระบุ -</OPTION>
	   <?
		$sql = "select * from $table_staff  where org_id='$org_id';"; 
		$xresult = mysql_query($sql);
		while ($xrs=mysql_fetch_assoc($xresult)){
			if ($xrs[staffid] == $rs[owner_id]) $sel = "SELECTED"; else $sel="";
			echo "<option value='$xrs[staffid]' $sel> $xrs[staffname]  $xrs[staffsurname] </option>";
		}
		?>
	   </SELECT>	 </TD>
    </TR>-->
<? if($type=="system"){ ?>
	<TR bgcolor=white valign=top>
		<TD class="link_back">รูปแบบการ<BR>
ออกเลขทะเบียนหนังสือ</TD>
		<TD>
		<!--<TABLE width="96%" border="0" cellspacing="0" cellpadding="0">
			<TR>
				<TD width="26%" align="center" valign="middle"><INPUT name="refid_info" type="text" id="refid_info"style="width:90px;" value="<?=$rs[refid_info]?>" /></TD>
				<TD width="1%" align="left" valign="top">&nbsp;</TD>
				<TD width="74%" align="left" valign="middle">รหัสประจำหน่วยงาน คือ รหัสที่หน่วยงานลงทะเบียนไว้กับสารบรรณกลางของสำนักงานจังหวัด ที่ขึ้นต้นด้วย ลป เว้นวรรค และตามด้วยเลขรหัสประจำหน่วยงาน เช่นสำนักงานจังหวัดได้แก่ &quot;ลป 0016&quot;</TD>
			</TR>
		</TABLE>-->
<?
$select_tag="";
$sql="
SELECT
ref_digit.id,
ref_digit.digit,
ref_digit.value,
ref_digit.`type`,
ref_digit.gid,
ref_type.`type` as name,
ref_type.`key` as varkey
FROM
ref_digit
Inner Join ref_type ON ref_type.id = ref_digit.`type`
where gid=$id
order by ref_digit.digit
";
$rst=mysql_query($sql);$i=0;
$row_rst=mysql_num_rows($rst);
	$wording="";
	if($row_rst){ echo "รูปแบบการออกเลขทะเบียนหนังสือในปัจจุบันของท่าน<br>";
		while($var=mysql_fetch_assoc($rst)){$i++;
		if( ($var[value])&&($var[varkey]!="autonumber") ){
			$wording.=$var[value];
		}elseif($var[varkey]=="autonumber"){
			if($var[value]){ 
				for($i=0;$i<$var[value];$i++){
				$wording.="x";
				}
			}
		}else{
			$wording.=$var[varkey];
		}
		echo "หลักที่ $i  ประเภท $var[name] ";
		if($var[type]=='1'){echo " ประกอบด้วย [&#8220;<u>$var[value]</u>&#8221;] ";}
		echo "<br>";
		}
		echo "<br>";
		echo " ตัวอย่าง รูปแบบในปัจจุบันของท่าน <br>";
		echo "<b>$wording</b>";
		echo "<br>";
		echo "<br>หากต้องการเปลี่ยนแปลงรูปแบบ เลือกเพิ่มจำนวนหลักเพื่อเปลี่ยนแปลงรูปแบบใหม่";
	}

$select_tag="";
$sql="select * from ref_type";
$rs=mysql_query($sql);
while($list=mysql_fetch_assoc($rs)){

if($list[id]=="2"){ $inner_code="  จำนวนหลัก : <input name=digit_char['+(gFiles)+']  type=text size=4 maxlength=2 >"; }else{ $inner_code="";}

$select_tag.="&nbsp;&nbsp;<INPUT name=type['+(gFiles)+'] type=radio value=$list[id]> $list[type]  $inner_code <br>";
}
?>
<SCRIPT type=text/javaSCRIPT>
					// FILE ADD FUNCTION
					var gFiles = 1;
					function addFile() {
					var li = document.createElement('li');
					li.setAttribute('id', 'file-' + gFiles);
					li.innerHTML = ' <b>หลักที่ '+(gFiles)+' </b><input type="text" name="digit['+(gFiles)+']" class="input" /> <span onclick="removeFile(\'file-' + gFiles + '\')" style="cursor:pointer;"> <img src="../../../images/profile_sub.gif" /></span><br><?=$select_tag?>';
					document.getElementById('files-root').appendChild(li);
					gFiles++;
					}
					
					
					
			
					function removeFile(aId){
					var obj = document.getElementById(aId);
					obj.parentNode.removeChild(obj);
					}
					
					function checkDigit(){
					var ch  = document.form1.digit.value;
					var chc = document.form1.digit_check.value;
						for (i=1;i<=chc;i++){
						var obj = document.getElementById('digit-' + i );
						
						// obj.parentNode.removeChild(obj);
						// removeFile('digit-' + i + );
						//	removeFile(obj);
						}					
						for (i=1;i<=ch;i++){
							addFile();
						}
					}
</SCRIPT>



		<!--จำนวนหลัก <INPUT name="digit" type="text" onKeyUp="checkDigit();" size="1" maxlength="1"> 
		<INPUT name="digit_check" type="hidden" size="1" maxlength="1">
		ในกระบวนการออกเลขหนังสือ<BR>--> 	<BR>
		<BR>
		<SPAN style="cursor:pointer;" onClick="addFile()"><IMG src="../../../images/profile_plus.gif" />เพิ่มจำนวนหลักในกระบวนการออกเลขหนังสือ	</SPAN>
		<ul id="files-root">		</TD>
	</TR>
	<? }?>
	<TR bgcolor=white valign=top>
	  <TD class="link_back">หมายเหตุ</TD>
	  <TD><TEXTAREA NAME="comment" ROWS="8" COLS="80"><?=$rs[comment]?></TEXTAREA></TD>
    </TR>

    <TR bgcolor="#DDDDEE" valign=top> 
	  <TD class="link_back" colspan=2>บุคลากรในกลุ่ม</TD>
    </TR>

    <TR bgcolor="white" valign=top>
    	<TD colspan=2><TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
			<TR>
				<TD align="left"><INPUT TYPE="checkbox" NAME="chk" ONCLICK="checkAll(this.form.list,this.checked)">
เลือก / ไม่เลือก ทั้งหมด</TD>
				<TD align="right">
				<!--<? if($action=="edit") { ?>
				 ค้นหา<IMG src="../../../images/search.jpg" width="16" height="16">
					<INPUT name="keyword" type="text" onKeyUp="searchSuggest();" AUTOCOMPLETE="off">
				<? }?>
					  <SCRIPT language="javascript">
	  //Starts the AJAX request.
		function savingkey() {
			if (searchReq.readyState == 4 || searchReq.readyState == 0) {
				var str = escape(document.post..value);
				str =unescape(str);
				if(str !=""){
				searchReq.open("GET", 'searchSuggest.php?search=' + str, true);
				searchReq.onreadystatechange = handleSearchSuggest; 
				searchReq.send(null);
				}
			}		
		}
	  </SCRIPT>
				
				-->					</TD>
			</TR>
		</TABLE></TD>
    	</TR>
    <TR bgcolor="white" valign=top> 
	  <TD colspan=2>

		<DIV id="search_suggest">
		<?
		if($type=="organize"){ 
			$inner_code="
			SELECT
				org_groupmember.staffid
			FROM
				org_groupmember
			WHERE
				org_groupmember.gid != $id
			GROUP BY
				org_groupmember.staffid
			 ";
				 $yresult=mysql_query($inner_code);
				 while($yrs=mysql_fetch_assoc($yresult)){
				 $row_check[$yrs[staffid]]=$yrs[staffid];
			//	 echo $row_check[$yrs[staffid]]."-".$id."<br>";
				 }
			}

		$sql = "select * from $table_staff  where  username <> 'admin_$org_id' and username <> 'root'  Order by trim(staffname) "; 
		
		$xresult = mysql_query($sql);
		while ($xrs=mysql_fetch_assoc($xresult)){
			if (Query1("select count(*) from $table_groupmember  where gid='$id' and staffid='$xrs[staffid]' ") > 0) {
				$chk="CHECKED"; 
			} else{
				$chk="";
			}
			
			
			/* else if (Query1("select count(*) from $table_groupmember  t1 inner join $table_staffgroup  t2 on t1.gid=t2.gid where t1.gid<>'$id' and t1.staffid='$xrs[staffid]' and t2.$table_groupmember  not in ('Guest','Administrator');") > 0) {
				//ตรวจสอบว่าอยู่กลุ่มอื่นแล้วหรือยัง
				continue; //ไม่เอามาแสดง
			// }else {
			
				$chk="";
			}*/
			
			
			
			if ($xrs[sex] == "M") $sex = "man"; else $sex="girl";
	//		if($db_mode=="epm"){ $disabled=" disabled ";}
			if(!$row_check[$xrs[staffid]]){
	//		echo "$xrs[staffid]";
			echo " &nbsp; &nbsp; &nbsp; <INPUT TYPE='checkbox' NAME='member[]' id='list' VALUE='$xrs[staffid]' $chk $disabled $savepack> <img src='images/$sex.gif'>  $xrs[staffname]  $xrs[staffsurname] <BR>";
			}
		}
		?>	
		</DIV>		 </TD>
    </TR>

    <TR bgcolor="#888899" valign=top> 
      <TD colspan=2 align=right> 
        <INPUT TYPE="submit" VALUE="    บันทึก    " CLASS=xbutton>
        <INPUT TYPE="reset" VALUE=" ยกเลิก " class=xbutton ONCLICK="location.href='?org_id=<?=$org_id?>';">      </TD>
    </TR>
  </TABLE>
</FORM>


<?
//====================================================================
}else if ($_GET[action] == "show" ){
	$sql = "select * from $table_staffgroup  where gid='$id';";
	$result = mysql_query($sql);
	$rs = mysql_fetch_assoc($result);
?>
<TABLE border=0 align=center cellspacing=1 cellpadding=3 bgcolor="#808080" width="98%">
    <TR bgcolor="#A3B2CC"> 
      <TD > <FONT COLOR="WHITE" style="font-size:14pt;"><IMG src="images/users.gif" align=middle> <B>ข้อมูล<?=$report_title?></B></FONT></TD>
       <TD align=right> 
	   <? // if(($id==$id_check ) || ($db_mode=="self")){ ?>
        <INPUT TYPE="reset" VALUE=" แก้ไข " class=xbutton ONCLICK="location.href='?org_id=<?=$org_id?>&id=<?=$id?>&action=edit&type=<?=$type?>';">
		<? // } ?>		</TD>
    </TR>


	<TR bgcolor=white valign=top> 
      <TD class="link_back" width="150">ชื่อกลุ่ม</TD>
      <TD><?=$rs[groupname]?></TD>
    </TR>
<? if($type=="system"){ ?>
	<TR bgcolor=white valign=top>
		<TD class="link_back">สิทธิ์</TD>
		<TD><LABEL></LABEL>
			<?
			$sql_check="select * from profile_permission where gid='$id' ";
			$result_check = mysql_query($sql_check);
			while($crs = mysql_fetch_assoc($result_check)){
			$check_status[$crs[pid]]="on"; 
			}
			
			$sql_status="select * from permission_status";
			$result = mysql_query($sql_status);
			while($rse = mysql_fetch_assoc($result))	{
			?>
			<? if($check_status[$rse[pid]]=="on"){?><?=$rse[status]?><BR><?}?>
			<?
			}
			?>			</TD>
	</TR>
	<?}?>
	<!--<TR bgcolor=white valign=top> 
      <TD class="link_back">หัวหน้า/ผู้รับผิดชอบ</TD>
      <TD> 
       <?
		$sql = "select * from $table_staff  where org_id='$org_id' and staffid='$rs[owner_id]';"; 
		$xresult = mysql_query($sql);
		$xrs=mysql_fetch_assoc($xresult);
		if ($xrs){
			echo " $xrs[prename] $xrs[staffname]  $xrs[staffsurname] ";
		}else{
			echo " - ไม่ระบุ -";
		}
		?>	 </TD>
    </TR>-->
<? if($type=="system"){ ?>
	<TR bgcolor=white valign=top>
		<TD class="link_back">รูปแบบการ<BR>
ออกเลขทะเบียนหนังสือ</TD>
		<TD>
			<!--<TABLE width="96%" border="0" cellspacing="0" cellpadding="0">
				<TR>
					<TD width="26%" align="center" valign="middle"><?=$rs[refid_info]?></TD>
					<TD width="1%" align="left" valign="top">&nbsp;</TD>
					<TD width="74%" align="left" valign="middle">รหัสประจำหน่วยงาน คือ รหัสที่หน่วยงานลงทะเบียนไว้กับสารบรรณกลางของสำนักงานจังหวัด ที่ขึ้นต้นด้วย ลป เว้นวรรค และตามด้วยเลขรหัสประจำหน่วยงาน เช่นสำนักงานจังหวัดได้แก่ &quot;ลป 0016&quot;</TD>
				</TR>
			</TABLE>-->
			
			<?

$select_tag="";
$sql="
SELECT
ref_digit.id,
ref_digit.digit,
ref_digit.value,
ref_digit.`type`,
ref_digit.gid,
ref_type.`type` as name,
ref_type.`key` as varkey
FROM
ref_digit
Inner Join ref_type ON ref_type.id = ref_digit.`type`
where gid=$id
order by ref_digit.digit
";
$rst=mysql_query($sql);$i=0;
$row_rst=mysql_num_rows($rst);
	$wording="";
	if($row_rst){ echo "รูปแบบการออกเลขทะเบียนหนังสือในปัจจุบันของท่าน<br>";
		while($var=mysql_fetch_assoc($rst)){$i++;
		if( ($var[value])&&($var[varkey]!="autonumber") ){
			$wording.=$var[value];
		}elseif($var[varkey]=="autonumber"){
			if($var[value]){ 
				for($i=0;$i<$var[value];$i++){
				$wording.="x";
				}
			}
		}else{
			$wording.=$var[varkey];
		}
		echo "หลักที่ $i  ประเภท $var[name] ";
		if($var[type]=='1'){echo " ประกอบด้วย [&#8220;<u>$var[value]</u>&#8221;] ";}
		echo "<br>";
		}
		echo "<br>";
		echo " ตัวอย่าง รูปแบบในปัจจุบันของท่าน <br>";
		echo "<b>$wording</b>";
		echo "<br>";

	}
	?>		</TD>
	</TR>
	<? }?>
	<TR bgcolor=white valign=top>
	  <TD class="link_back">หมายเหตุ</TD>
	  <TD><?=nl2br($rs[comment])?></TD>
    </TR>

    <TR bgcolor="#DDDDEE"> 
	  <TD class="link_back"><IMG src="dtree/img/users.gif" align=middle> กลุ่มย่อย</TD>
       <TD align=right> 
		<?  if($db_mode=="self"){ ?>		
		<INPUT TYPE="reset" VALUE=" เพิ่มกลุ่มย่อย " class=xbutton ONCLICK="location.href='?org_id=<?=$org_id?>&parent=<?=$id?>&action=addsubgroup&type=<?=$type?>';">
		<?  } ?>		</TD>
    </TR>
	<TR bgcolor="white" valign=top> 
	  <TD colspan=2>
	  <?
		$n=0;
		$sql = "select * from $table_staffgroup  where parent='$id';"; 
		$xresult = mysql_query($sql);
		while ($xrs=mysql_fetch_assoc($xresult)){
			$n++;
			echo " &nbsp; &nbsp; &nbsp; <img src='dtree/img/users.gif' align=middle> $xrs[groupname]<BR>";
		}
		if ($n == 0) echo "- ไม่มีกลุ่มย่อย -<BR><BR>";
		?>	  </TD>
    </TR>


    <TR bgcolor="#DDDDEE"> 
	  <TD class="link_back" colspan=2><IMG src="images/man.gif" align=middle> บุคลากรในกลุ่ม</TD>
    </TR>

	<TR bgcolor="white" valign=top> 
	  <TD colspan=2>
	  <?
		$n=0;
		$sql = "select t2.* from $table_groupmember t1 inner join $table_staff t2 on t1.staffid=t2.staffid where t1.gid='$id' order by  trim(t2.staffname)  ;"; 
		$xresult = mysql_query($sql);
		if($type)
		while ($xrs=mysql_fetch_assoc($xresult)){
			$n++;
			if ($xrs[sex] == "M") $sex = "man"; else $sex="girl";
			echo " &nbsp; &nbsp; &nbsp; <img src='images/$sex.gif' align=middle> $xrs[prename] $xrs[staffname] $xrs[staffsurname]<BR>";
		}
		if ($n == 0) echo "- ไม่มีบุคลากรในกลุ่มนี้ -<BR><BR>";
		?>	  </TD>
    </TR>
  </TABLE>

<?
}else{

//====================================================================

?>


<TABLE border=0 align=center cellspacing=1 cellpadding=2 width="98%">
<TR><TD width=35><IMG src="images/group_icon.gif"></TD>
<TD> <B style="font-size: 12pt;">กลุ่มบุคลากรในหน่วยงาน <?=Query1("select NLABEL from $table_mainmenu where NID='$org_id';")?></B>
</TD></TR>

<TR valign=top height=1 bgcolor="#808080"><TD colspan=2></TD></TR>

<TR valign=top><TD colspan=2>
<BR><BR>
<?  if($db_mode=="self"){ ?>
<IMG src="images/profile_collapsed.gif"> <A HREF="?action=new&org_id=<?=$org_id?>&type=<?=$type?>">เพิ่มข้อมูลใหม่</A>
<?  } ?>
</TD>
</TR>
</TABLE>



<TABLE border=0 align=center cellspacing=1 cellpadding=2 bgcolor=black width="98%" class="sortable" id="unique_id">
<TR bgcolor="#A3B2CC">
<TH width=80>ลำดับ</TH>
<TH>ชื่อกลุ่ม</TH>
<?  if($db_mode=="self"){ ?>
<TH width=80>&nbsp;</TH>
<?  } ?>
</TR>
<?
$n = 0;

if($type=="profile"){
$sql = "select * from  $table_staffgroup  where org_id='$org_id' AND $table_staffgroup.staffid='$session_staffid' order by trim($table_staffgroup.groupname) ASC ;";
}else{ //if($type=="system")
$sql = "select * from  $table_staffgroup  where org_id='$org_id' order by trim($table_staffgroup.groupname) ASC ;";
}

$result = mysql_query($sql);
while ($rs=mysql_fetch_assoc($result)){
	if ($n++ %  2){
		$bgcolor = "#F0F0F0";
	}else{
		$bgcolor = "#FFFFFF";
	}
	
?>
<TR valign=top bgcolor="<?=$bgcolor?>">
<TD align=center ><?=$n?></TD>
<TD ><?=$rs[groupname]?></TD>
<?  if($db_mode=="self"){ ?>
<TD align=center>
<?/*
if ($rs[gid] != 1){ // สงวนไว้ ไม่ได้แก้ ข้อมูลกลุ่มทั่วไป	

	if ($rs[groupname] == "Guest" || $rs[groupname] == "Administrator"){
		echo "<I>System Group</I>";
	}else{*/
?>
<A href="?action=edit&id=<?=$rs['gid']?>&org_id=<?=$org_id?>&type=<?=$type?>&type=<?=$type?>"><IMG src="../../../images/b_edit.png" alt="แก้ไข" width="16" height="16" border="0"></A>	&nbsp;&nbsp;
<A href="#" ONCLICK="if (confirm('ต้องการลบข้อมูลนี้ใช่หรือไม่?')) location.href='?action=delete&id=<?=$rs['gid']?>&org_id=<?=$org_id?>&type=<?=$type?>';">
<IMG src="../../../images/b_drop.png" alt="ลบข้อมูล" width="16" height="16" border="0"></A>
<?
	//} // if guest || admin

//} // if	
?>

</TD>
<?  } ?>
</TR>
<?
}// while
?>
</TABLE>

<?
}	
?>
<BR><BR>
</BODY>
</HTML>

Anon7 - 2021