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_integration/requirement/application/ecomplain/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/pathumthani_integration/requirement/application/ecomplain/xls_report_lsit.php
<?php
	session_start();
	include "../../config/config.inc.php";
	include("function/function.php");
	include("../../common/common_system.inc.php"); 
	//	include("./function.php");
	
	require_once "xls_class/class.writeexcel_workbook.inc.php";
	require_once "xls_class/class.writeexcel_worksheet.inc.php";
	
	# Variables - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -	
	$xlsname = "Search.".date("Ymd.His") . "." . $checkpoint_id . '.xls';
	$fname = tempnam("/tmp", "search.xls");
	$workbook =& new writeexcel_workbook($fname);
	$worksheet =& $workbook->addworksheet($report_date); # เพิ่ม work sheet
	# End Variables - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	# Function - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	function getShDate( $ThisMonth, $ThisYear ) {
		if ( $ThisMonth && $ThisYear ) {
			$arrMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
			$xMonth = $arrMonth[(int)$ThisMonth - 1];
			$xYear = $ThisYear + 543;
			return $xMonth .  $xYear;
		}
	}
	
	function getShortDate( $ThisDate ) {
		$arrMonth = array("ม.ค.", "ก.พ.", "มี.ค.", "เม.ษ.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
		
		if ( $ThisDate ) {
			list($xDate, $xMonth, $xYear) = split("-", $ThisDate);
			$strDate = sprintf("%s %s %s", $xDate*1, $arrMonth[(int)$xMonth - 1], $xYear + 543);
			return $strDate;
		}
	}
	# End Function - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	# Header Styles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	$title =& $workbook->addformat(array('font'=>'CordiaUPC','color'=>'black','size'=>14,'text_wrap'=>1));
	$title =& $workbook->addformat();
	$title->set_bold(1);
	$title->set_size(10);
	$title->set_top(0);
	$title->set_left(0);
	$title->set_bottom(0);
	$title->set_align('center');
	$title->set_align('vcenter');
	$title->set_merge(); # This is the key feature
	
	$title_child_cell =& $workbook->addformat(array('font'=>'CordiaUPC','color'=>'black','size'=>14,'text_wrap'=>1));
	$title_child_cell =& $workbook->addformat();
	$title_child_cell->set_size(10);
	$title_child_cell->set_top(0);
	$title_child_cell->set_right(0);
	$title_child_cell->set_left(0);
	$title_child_cell->set_align('center');
	$title_child_cell->set_align('vcenter');
	$title_child_cell->set_merge(); # This is the key feature
	
	$heading_merge =& $workbook->addformat(array('font'=>'CordiaUPC','color'=>'black','size'=>14,'text_wrap'=>1));
	$heading_merge =& $workbook->addformat();
	$heading_merge->set_bold(1);
	$heading_merge->set_size(10);
	$heading_merge->set_top(1);
	$heading_merge->set_left(1);
	$heading_merge->set_right(1);
	$heading_merge->set_bottom(1);
	$heading_merge->set_align('center');
	$heading_merge->set_align('vcenter');
	$heading_merge->set_merge();
	
	$heading_merge_no_top =& $workbook->addformat(array('font'=>'CordiaUPC','color'=>'black','size'=>14,'text_wrap'=>1));
	$heading_merge_no_top =& $workbook->addformat();
	$heading_merge_no_top->set_bold(1);
	$heading_merge_no_top->set_size(10);
	$heading_merge_no_top->set_top(0);
	$heading_merge_no_top->set_left(1);
	$heading_merge_no_top->set_right(1);
	$heading_merge_no_top->set_bottom(1);
	$heading_merge_no_top->set_align('center');
	$heading_merge_no_top->set_align('vcenter');
	$heading_merge_no_top->set_merge();
	
	$heading_merge_no_bottom =& $workbook->addformat(array('font'=>'CordiaUPC','color'=>'black','size'=>14,'text_wrap'=>1));
	$heading_merge_no_bottom =& $workbook->addformat();
	$heading_merge_no_bottom->set_bold(1);
	$heading_merge_no_bottom->set_size(10);
	$heading_merge_no_bottom->set_top(1);
	$heading_merge_no_bottom->set_left(1);
	$heading_merge_no_bottom->set_right(1);
	$heading_merge_no_bottom->set_bottom(0);
	$heading_merge_no_bottom->set_align('center');
	$heading_merge_no_bottom->set_align('vcenter');
	$heading_merge_no_bottom->set_merge();
	
	$heading_merge_no_top_bottom =& $workbook->addformat(array('font'=>'CordiaUPC','color'=>'black','size'=>14,'text_wrap'=>1));
	$heading_merge_no_top_bottom =& $workbook->addformat();
	$heading_merge_no_top_bottom->set_bold(1);
	$heading_merge_no_top_bottom->set_size(10);
	$heading_merge_no_top_bottom->set_top(0);
	$heading_merge_no_top_bottom->set_left(1);
	$heading_merge_no_top_bottom->set_right(1);
	$heading_merge_no_top_bottom->set_bottom(0);
	$heading_merge_no_top_bottom->set_align('center');
	$heading_merge_no_top_bottom->set_align('vcenter');
	$heading_merge_no_top_bottom->set_merge();
			
	$body =& $workbook->addformat(array('font'=>'CordiaUPC','color'=>'black','size'=>14,'text_wrap'=>1));
	$body =& $workbook->addformat();
	$body->set_size(10);
	$body->set_top(1);
	$body->set_left(1);
	$body->set_right(1);
	$body->set_bottom(1);
	$body->set_align('center');
	$body->set_align('vcenter');
	
	$body_left =& $workbook->addformat(array('font'=>'CordiaUPC','color'=>'black','size'=>14,'text_wrap'=>1));
	$body_left =& $workbook->addformat();
	$body_left->set_size(10);
	$body_left->set_top(1);
	$body_left->set_left(1);
	$body_left->set_right(1);
	$body_left->set_bottom(1);
	$body_left->set_align('vcenter');	
	
	$body_left_bold =& $workbook->addformat(array('font'=>'CordiaUPC','color'=>'black','size'=>14,'text_wrap'=>1));
	$body_left_bold =& $workbook->addformat();
	$body_left_bold->set_bold(1);
	$body_left_bold->set_size(10);
	$body_left_bold->set_top(1);
	$body_left_bold->set_left(1);
	$body_left_bold->set_right(1);
	$body_left_bold->set_bottom(1);
	$body_left_bold->set_align('vcenter');	
	
	$body_bold =& $workbook->addformat(array('font'=>'CordiaUPC','color'=>'black','size'=>14,'text_wrap'=>1));
	$body_bold =& $workbook->addformat();
	$body_bold->set_bold(1);
	$body_bold->set_size(10);
	$body_bold->set_top(1);
	$body_bold->set_left(1);
	$body_bold->set_right(1);
	$body_bold->set_bottom(1);
	$body_bold->set_align('center');
	$body_bold->set_align('vcenter');
	# End Header Styles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	# Write heading =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
	# Set Column
	$xlsRow = 0; # เริ่มต้นแถวที่ 0
	$worksheet->set_column('A:B', 5.00);
	$worksheet->set_column('B:C', 19.86);
	$worksheet->set_column('C:D', 20.43);
	$worksheet->set_column('D:E', 19.14);
	$worksheet->set_column('E:F', 25.43);
	
	# Set Header I
	$xlsRow++;
	$worksheet->write('A'.$xlsRow , "", $title);
	$worksheet->write_blank('B'.$xlsRow, $title_child_cell);
	$worksheet->write_blank('C'.$xlsRow, $title_child_cell);
	$worksheet->write_blank('D'.$xlsRow, $title_child_cell);
	$worksheet->write_blank('E'.$xlsRow, $title_child_cell);

	
	$xlsRow++;
	$worksheet->write('A'.$xlsRow , "รายงานการรับเรื่องร้องเรียน", $title);
	$worksheet->write_blank('B'.$xlsRow, $title_child_cell);
	$worksheet->write_blank('C'.$xlsRow, $title_child_cell);
	$worksheet->write_blank('D'.$xlsRow, $title_child_cell);
	$worksheet->write_blank('E'.$xlsRow, $title_child_cell);

	
	$xlsRow++;
	$worksheet->write('A'.$xlsRow , "", $title);
	$worksheet->write_blank('B'.$xlsRow, $title_child_cell);
	$worksheet->write_blank('C'.$xlsRow, $title_child_cell);
	$worksheet->write_blank('D'.$xlsRow, $title_child_cell);
	$worksheet->write_blank('E'.$xlsRow, $title_child_cell);

	
	# Set Header II   ลำดับ ชื่อตัวและชื่อรอง ชื่อสกุล เพศ หนังสือเดินทาง สัญชาติ เหตุแห่งความจำเป็น ระยะเวลาอนุญาต(วัน) วันที่อนุญาต ผู้อนุญาต 
	$xlsRow++;
	$worksheet->write('A'.$xlsRow, "ลำดับ", $heading_merge);
	$worksheet->write('B'.$xlsRow, "ผู้ร้องเรียน", $heading_merge);
	$worksheet->write('C'.$xlsRow, "เขตพื้นที่", $heading_merge);
	$worksheet->write('D'.$xlsRow, "ประเภทความต้องการ", $heading_merge);
	$worksheet->write('E'.$xlsRow, "ข้อเรียกร้อง", $heading_merge);
	# End Write heading =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
	
	# Body Information =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
	if ( $_SESSION['ExcSQL'] ) {
		$intR = 0;
		$rsConn = mysql_db_query($dbname,$_SESSION['ExcSQL']);
		while( $rs = mysql_fetch_assoc($rsConn) ) {
			$arrResult[$intR][0] = $rs['public_name'];
			$arrResult[$intR][1] = $rs['ccName'];
			$arrResult[$intR][2] = $rs['type_request'];
			$arrResult[$intR][3] = trim($rs[complain_detail]);
			$intR++;
		}
	}
	
	if ( is_array($arrResult) ) {
		$intR = 0;
		foreach ( $arrResult as $Key => $Val ) {
			$xlsRow++;
			$worksheet->write('A'.$xlsRow, $intR+1, $body);
			$worksheet->write('B'.$xlsRow, $Val[0], $body_left);
			$worksheet->write('C'.$xlsRow, $Val[1], $body_left);
			$worksheet->write('D'.$xlsRow, $Val[2], $body_left);
			$worksheet->write('E'.$xlsRow, $Val[3], $body_left);
			$intR++;
		}
	}
	# End Body Information =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
	
	# Send "Excel File" to "Browser" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
	$worksheet->set_landscape(1); #Lanscape Page
	$worksheet->set_margin_left(0.35);
	$worksheet->set_margin_right(0.35);
	$worksheet->set_margin_top(0.35);
	$worksheet->set_margin_bottom(0.35);
//	$worksheet->set_paper(5); #Paper Type : Legal
	
	$workbook->close();
	header("Pragma: public");
	header("Expires: 0");
	header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
	header("Content-Type: application/force-download");
	header("Content-Type: application/octet-stream");
	header("Content-Type: application/download");
	header("Content-Disposition: attachment; filename=".basename($xlsname).";");
	header("Content-Transfer-Encoding: binary ");
	header("Content-Length: ".filesize($fname));
	
	readfile($fname);
	unlink($fname);
	exit();
	# End Send "Excel File" to "Browser" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
	
	function getPageNum($row, $row_per_page){
		$page = ceil($row / $row_per_page);
		//$page += (is_int($page))?1:0;
		return ($page<=0)?1:$page;
	}
	
	function Change_Date($Da){
		$DT=explode("-",$Da);
		$DATE_FIND=($DT[2])."-".$DT[1]."-".$DT[0];
		return $DATE_FIND;
	}
?>

Anon7 - 2021