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 :  /home/pathumthani_integration/integration/application/labor/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/pathumthani_integration/integration/application/labor/labor_register_pdf.php
<?php
session_start();
include_once("../../config/config_epm.inc.php");
include_once("manage_user.inc.php");
define('FPDF_FONTPATH','fpdf/font/');
require('fpdf/fpdf.php');

function showDate($value,$dot){
	if($dot=='dot'){
		if($value!='' && $value!='  /  /'){
				$Month = array("", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
				$day = explode("/",$value);
				$Y = $day[2];
				$m = $day[1];
				if($m<10){
					$m = str_replace("0","",$m);
				}
				$d = $day[0]*1;
				$date = $d.' '.$Month[$m].' '.($Y);
				//echo $date;
		}else{
				$date ='-';
		}
	}else if($dot=='sort'){
		if($value!='' && $value!='  /  /'){
				//$Month = array("", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
				$day = explode("/",$value);
				$Y = $day[0];
				$m = $day[1];
				$d = $day[2]*1;
				$date = $d.''.$m.''.$Y;
				//echo $date;
		}else{
				$date ='-';
		}
	}
		return $date;
}

if($_GET['year']){
	$year_value=$_GET['year'];
}else{
	$year_value=(date('Y')+543);
}
		
	//A4 (210 x 297 มม.) ==> X x Y
    $pdf=new FPDF('P', 'mm', 'A4');;
    $pdf->AliasNbPages();
    $pdf->AddThaiFonts();
	$pdf->AddPage();
	$pdf->AddFont('CordiaNew','','cordia.php');
	$pdf->AddFont('CordiaNew','B','cordiab.php');
	$pdf->AddFont('CordiaNew','I','cordiai.php');
	
	/*$num = 7;
	$birth = 15;
	$name = 35;
	$position = 40;
	$radub = 17;
	$vitaya =19;
	$vitayaD = 19;
	$dep = 44;
	$total = $num+$birth+$name+$position+$radub+$vitaya+$vitayaD+$dep;*/
	
	$y = 10; /// START Y
	$x=7;
	$pdf->SetFont('CordiaNew','B',12);
	$highCell = 9;
	
	$wideCell = 196;
	$xField = $x;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,'รายงานข้อมูลโรงงานอุตสาหกรรมจำแนกรายปี',0,0,'C');
		
	$num=12;
	$name=48;
	$type=48;
	$datestart=20;
	$datestop=20;
	$cap=26;
	$fee=22;
	
	$pdf->SetFont('CordiaNew','B',10);
    $y += 9;
	// header field of table		
	$wideCell = $num;
	$xField = $x;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,'ลำดับที่',1,0,'C');
	
	$xField += $wideCell;
	$wideCell = $name;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,'ชื่อโรงงาน',1,0,'C');
		
	$xField += $wideCell;
	$wideCell = $type;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,'หมวดอุตสาหกรรม',1,0,'C');
	
	$xField += $wideCell;
	$wideCell = $datestart;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,'วันเริ่มประกอบ',1,0,'C');
	
	$xField += $wideCell;
	$wideCell = $datestop;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,'วันที่หยุดกิจการ',1,0,'C');
	
	$xField += $wideCell;
	$wideCell = $cap;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,'',1,0,'C');
	 $pdf->SetXY($xField,$y-2);
    $pdf->Cell($wideCell,$highCell,'จำนวนเงินลงทุน',0,0,'C');
	 $pdf->SetXY($xField,$y+2);
    $pdf->Cell($wideCell,$highCell,'(บาท)',0,0,'C');
	
	$xField += $wideCell;
	$wideCell = $fee;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,'',1,0,'C');
	$pdf->SetXY($xField,$y-2);
    $pdf->Cell($wideCell,$highCell,'ค่าธรรมเนียมรายปี',0,0,'C');
	$pdf->SetXY($xField,$y+2);
    $pdf->Cell($wideCell,$highCell,'(บาท)',0,0,'C');
	
		
				$strSQL_1 = "SELECT type_id,commendate,tempdate,fname,capital,year_fee,tempstop									
										FROM		industry_register
										WHERE fyear<=".$year_value."
										ORDER BY commendate
								";
				$rsConn_1 = mysql_db_query($dbname,$strSQL_1);
				$i=0;
				$totalALL_INDUSTRY=0;
				$totalALL_CAPITAL=0;
				$totalALL_YEAR=0;				
				
				while ( $Result_1 = mysql_fetch_assoc($rsConn_1)) {
						$i++;		
						$rowNumb = ($i+($board_link_num*$page)-$board_link_num);
						
						$sqlTypeid="		SELECT * FROM industry_type WHERE type_id='".$Result_1['type_id']."'		";
						$rsTypeid=mysql_db_query($dbname,$sqlTypeid);
						$resTypeid=mysql_fetch_assoc($rsTypeid);
						//echo $sqlTypeid;
						$sqlType="		SELECT * FROM industry_type WHERE runid='".$resTypeid['parent_id']."'		";
						$rsType=mysql_db_query($dbname,$sqlType);
						$resType=mysql_fetch_assoc($rsType);
						//echo $sqlType;
						$totalALL_CAPITAL+=$Result_1['capital'];
						$totalALL_YEAR+=$Result_1['year_fee'];	
						
	
	$y += 9;
			if($y >= 269){		//P=269, L=180
						$pdf->AddPage();
						$y = 10; /// START Y
						$x=7;
						$pdf->SetFont('CordiaNew','B',10);
						$highCell = 9;
						
						$wideCell = $num;
						$xField = $x;
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,'ลำดับที่',1,0,'C');
						
						$xField += $wideCell;
						$wideCell = $name;
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,'ชื่อโรงงาน',1,0,'C');
							
						$xField += $wideCell;
						$wideCell = $type;
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,'หมวดอุตสาหกรรม',1,0,'C');
						
						$xField += $wideCell;
						$wideCell = $datestart;
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,'วันเริ่มประกอบ',1,0,'C');
						
						$xField += $wideCell;
						$wideCell = $datestop;
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,'วันที่หยุดกิจการ',1,0,'C');
						
						$xField += $wideCell;
						$wideCell = $cap;
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,'',1,0,'C');
						 $pdf->SetXY($xField,$y-2);
						$pdf->Cell($wideCell,$highCell,'จำนวนเงินลงทุน',0,0,'C');
						 $pdf->SetXY($xField,$y+2);
						$pdf->Cell($wideCell,$highCell,'(บาท)',0,0,'C');
						
						$xField += $wideCell;
						$wideCell = $fee;
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,'',1,0,'C');
						$pdf->SetXY($xField,$y-2);
						$pdf->Cell($wideCell,$highCell,'ค่าธรรมเนียมรายปี',0,0,'C');
						$pdf->SetXY($xField,$y+2);
						$pdf->Cell($wideCell,$highCell,'(บาท)',0,0,'C');
						
						$y += 9; 
			}
			
	$pdf->SetFont('CordiaNew','',10);		
	// header field of table		
	$wideCell = $num;
	$xField = $x;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,$i,1,0,'C');
		
	$xField += $wideCell;
	$wideCell = $name;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,$Result_1['fname'],1,0,'L');
		
	$xField += $wideCell;
	$wideCell = $type;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,$resType['type_name'],1,0,'L');
	
	$xField += $wideCell;
	$wideCell = $datestart;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,showDate($Result_1['commendate'],'dot'),1,0,'C');
	
	$xField += $wideCell;
	$wideCell = $datestop;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,($Result_1['tempstop']=='0')?'-':showDate($Result_1['tempdate'],'dot'),1,0,'C');
	
	$xField += $wideCell;
	$wideCell = $cap;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,number_format($Result_1['capital'],2),1,0,'R');
	
	$xField += $wideCell;
	$wideCell = $fee;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,number_format($Result_1['year_fee'],2),1,0,'R');
								
				}
	
	$pdf->SetFont('CordiaNew','B',10);		
	$y += 9;
	// header field of table		
	$wideCell = $datestop+$datestart+$type+$name+$num;
	$xField = $x;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,'รวม ',1,0,'R');
	
	$xField += $wideCell;
	$wideCell = $cap;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,number_format($totalALL_CAPITAL,2),1,0,'R');
	
	$xField += $wideCell;
	$wideCell = $fee;
    $pdf->SetXY($xField,$y);
    $pdf->Cell($wideCell,$highCell,number_format($totalALL_YEAR,2),1,0,'R');
	
	
	/*if($_GET['birthday_col'] == 1){
			$xField += $wideCell;
			$wideCell = $wideBirthday;	
			$pdf->SetXY($xField,$y);
			$pdf->Cell($wideCell,$highCell,'วันเดือนปีเกิด',1,0,'C');			
	}
	
	if($_GET['name_col'] == 1){
			$xField += $wideCell;
			$wideCell = $wideName;	
			$pdf->SetXY($xField,$y);
			$pdf->Cell($wideCell,$highCell,'ชื่อ-นามสกุล',1,0,'C');
	}
	
	if($_GET['position_now_col'] == 1){
			$xField += $wideCell;
			$wideCell = $widePosition;	
			$pdf->SetXY($xField,$y);
			$pdf->Cell($wideCell,$highCell,'ตำแหน่งปัจจุบัน',1,0,'C');
	}
	
	if($_GET['radub_col'] == 1){
			$xField += $wideCell;
			$wideCell = $wideRadub;	
			$pdf->SetXY($xField,$y);
			$pdf->Cell($wideCell,$highCell,'ระดับ',1,0,'C');
	}
	
	if($_GET['vitaya_col'] == 1){
			$xField += $wideCell;
			$wideCell = $wideVitaya;	
			$pdf->SetXY($xField,$y);
			$pdf->Cell($wideCell,$highCell,'วิทยะฐานะ',1,0,'C');
	}
	
	if($_GET['vitaya_date_col'] == 1){
			$xField += $wideCell;
			$wideCell = $wideDateVitaya;	
			$pdf->SetXY($xField,$y);
			$pdf->Cell($wideCell,$highCell,'วันที่ได้รับวิทยะฐานะ',1,0,'C');
	}
	
	if($_GET['department_col'] == 1){
			$xField += $wideCell;
			$wideCell = $wideDepartment;	
			$pdf->SetXY($xField,$y);
			$pdf->Cell($wideCell,$highCell,'ชื่อหน่วยงาน',1,0,'C');
	}
	
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	$strSQL_1 = "SELECT *
								FROM view_general
								";
	$chk=0;
	if($_GET['name'] != ''){
		$chk = 1;
		if($chk == 1){
			$strSQL_1 .= "WHERE name_th LIKE '%".$_GET['name']."%'";
		}
	
	}
	if($_GET['sname'] != ''){
		if($chk != 1){
			$strSQL_1 .= "WHERE surname_th LIKE '%".$_GET['sname']."%'";
		}
		else{
			$strSQL_1 .= "AND surname_th LIKE '%".$_GET['sname']."%'";
		}
		$chk = 1;
	}
	if($_GET['id'] != ''){
		if($chk != 1){
			$strSQL_1 .= "WHERE CZ_ID LIKE '%".$_GET['id']."%'";
		}
		else{
			$strSQL_1 .= "AND CZ_ID LIKE '%".$_GET['id']."%'";
		}
		$chk = 1;
	}
	if($_GET['positionid'] != ''){
		$xnoposition = trim($_GET['positionid']);
		$str1 = str_replace(".","",$xnoposition); 
		if($chk != 1){
			//$strSQL_1 .= "WHERE noposition LIKE '%".$_GET['positionid']."%'";
			$strSQL_1 .= "WHERE view_general.noposition = '$str1' "; 
		}
		else{
			//$strSQL_1 .= "AND noposition LIKE '%".$_GET['positionid']."%'";
			$strSQL_1 .= "AND view_general.noposition = '$str1' "; 
		}
		$chk = 1;
	}
			$strSQL_1 .= "GROUP BY CZ_ID ORDER BY siteid  , schoolid"; 
			$rsConn_1 = mysql_db_query("cmss_".$xsiteid,$strSQL_1);
			//$Result_1 = mysql_fetch_assoc($rsConn_1);
			$i=0;
		while ( $Result_1 = mysql_fetch_assoc($rsConn_1)) {
				$y += 9; 
				if($y > 269){
						$pdf->AddPage();
						$y = 10; /// START Y
						$x=7;
						$pdf->SetFont('CordiaNew','B',8);
						$highCell = 9;
						//$y += 5;
						// header field of table	
						
						$wideCell = $number;
						$xField = $x;
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,'ลำดับที่',1,0,'C');
						
						if($_GET['birthday_col'] == 1){
								$xField += $wideCell;
								$wideCell = $wideBirthday;	
								$pdf->SetXY($xField,$y);
								$pdf->Cell($wideCell,$highCell,'วันเดือนปีเกิด',1,0,'C');			
						}
						
						if($_GET['name_col'] == 1){
								$xField += $wideCell;
								$wideCell = $wideName;	
								$pdf->SetXY($xField,$y);
								$pdf->Cell($wideCell,$highCell,'ชื่อ-นามสกุล',1,0,'C');
						}
						
						if($_GET['position_now_col'] == 1){
								$xField += $wideCell;
								$wideCell = $widePosition;	
								$pdf->SetXY($xField,$y);
								$pdf->Cell($wideCell,$highCell,'ตำแหน่งปัจจุบัน',1,0,'C');
						}
						
						if($_GET['radub_col'] == 1){
								$xField += $wideCell;
								$wideCell = $wideRadub;	
								$pdf->SetXY($xField,$y);
								$pdf->Cell($wideCell,$highCell,'ระดับ',1,0,'C');
						}
						
						if($_GET['vitaya_col'] == 1){
								$xField += $wideCell;
								$wideCell = $wideVitaya;	
								$pdf->SetXY($xField,$y);
								$pdf->Cell($wideCell,$highCell,'วิทยะฐานะ',1,0,'C');
						}
						
						if($_GET['vitaya_date_col'] == 1){
								$xField += $wideCell;
								$wideCell = $wideDateVitaya;	
								$pdf->SetXY($xField,$y);
								$pdf->Cell($wideCell,$highCell,'วันที่ได้รับวิทยะฐานะ',1,0,'C');
						}
						
						if($_GET['department_col'] == 1){
								$xField += $wideCell;
								$wideCell = $wideDepartment;	
								$pdf->SetXY($xField,$y);
								$pdf->Cell($wideCell,$highCell,'ชื่อหน่วยงาน',1,0,'C');
						}
						$y += 9; 
				}
				$i++;
				/// START Y
				$x=7;
				$pdf->SetFont('CordiaNew','',8);
				$highCell = 9;
				//$y += 5;
				// header field of table	
				
				$wideCell = $number;
				$xField = $x;
				$pdf->SetXY($xField,$y);
				$pdf->Cell($wideCell,$highCell,$i,1,0,'C');
				
				if($_GET['birthday_col'] == 1){
						$xField += $wideCell;
						$wideCell = $wideBirthday;	
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,dateFormat($Result_1['birthday'],"thaidot"),1,0,'C');			
				}
				
				if($_GET['name_col'] == 1){
						$fullname = $Result_1['prename_th'].$Result_1['name_th'].'   '.$Result_1['surname_th'];
						$xField += $wideCell;
						$wideCell = $wideName;	
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,$fullname,1,0,'L');
				}
				
				if($_GET['position_now_col'] == 1){
						$xField += $wideCell;
						$wideCell = $widePosition;	
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,$Result_1['position_now'],1,0,'L');
				}
				
				if($_GET['radub_col'] == 1){
						$xField += $wideCell;
						$wideCell = $wideRadub;	
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,$Result_1['radub'],1,0,'C');
				}
				
				if($_GET['vitaya_col'] == 1){
						if($Result_1['vitaya'] == ''){
								$vit = "ไม่มีวิทยฐานะ";
						}else{
								$vit = $Result_1['vitaya'];
						}
						$xField += $wideCell;
						$wideCell = $wideVitaya;	
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,$vit,1,0,'C');
				}
				
				if($_GET['vitaya_date_col'] == 1){
						 $vitayaDate = dateFormat($Result_1['date_start'],"thaidot") ; 
						$xField += $wideCell;
						$wideCell = $wideDateVitaya;	
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,$vitayaDate,1,0,'C');
				}
				
				if($_GET['department_col'] == 1){
						if($Result_1['schoolname']   != ''){
							$schoolname = "(โรงเรียน".$Result_1['schoolname'].")" ;
						} else {
							$schoolname = "" ;
						} ### END if($rs[schoolname]   <> ""){
						
						$strSQL_2 = "SELECT secname
								FROM eduarea		
								WHERE secid = '".$Result_1['siteid']."'
								";
						$rsConn_2 = mysql_db_query("cmss_master",$strSQL_2);						
						$Result_2 = mysql_fetch_assoc($rsConn_2);
						
						$secname = searchReplace('',$Result_2['secname']);
						
						if($Result_1['schoolid'] != $Result_1['siteid']){
							$department2 = $schoolname;
						}else{
							$department2 = "(".$Result_1['schoolname'].")" ;
						}
						$xField += $wideCell;
						$wideCell = $wideDepartment;	
						$pdf->SetXY($xField,$y-2);
						$pdf->Cell($wideCell,$highCell,$secname,0,0,'L');
						$pdf->SetXY($xField,$y+2);
						$pdf->Cell($wideCell,$highCell,$department2,0,0,'L');
						$pdf->SetXY($xField,$y);
						$pdf->Cell($wideCell,$highCell,"",1,0,'L');
				}
				
	
	}*/

	$pdf->Output('รายงานข้อมูลโรงงานอุตสาหกรรมจำแนกรายปี.pdf', 'D');
    
?>

Anon7 - 2021