Viewing file: SearchExcelCarList.php (14.38 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/*
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
include("header.php");
$index = 2;
*/
$filename ="report_".(($_REQUEST['dateStart'])?$_REQUEST['dateStart']:date("d/m/Y"))."-".(($_REQUEST['dateFinish'])?$_REQUEST['dateFinish']:date("d/m/Y")).".xls";
header('Content-type: application/xls');
header('Content-Disposition: attachment; filename='.$filename);
/** Define Validate Access */
define( '_VALID_ACCESS', 1 );
/** Configuration */
include( "../configuration.php" );
require_once( $_Config_absolute_path . "/includes/framework.php" );
require_once( $_Config_absolute_path . "/include/Function.php" );
require_once( "../include/Function.php" );
/** Create Database Object */
$dbObj = new DBConn;
/** Config Table for This Page */
$myTable = "formcaroffice";
$myTable1 = "personal_tb";
$myTable3 = "budget_year_tb";
$myTablePK = "Date_start";
$myTableField1 = "Date_start";
$myTableField2 = "Training_name";
/** Paging */
$page = $_GET['page'];
if( $page == "" ) { $page = 1; }
/** Keyword and Field */
$keyword = $_REQUEST['keyword'];
$selectTypeBook = $_REQUEST['selectTypeBook'];
/** จำนวนข้อมูล ต่อ 1 หน้า */
$perpage = $_REQUEST['perpage'];
if( $perpage == "" ) { $perpage = 300; }
if( $Year == "" )
$Year = date("Y")+543;
//** Parameter */
$param = "keyword=$keyword&selectTypeBook=$selectTypeBook";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title><?=$_Config_sitename;?> - ข้อมูลงานสารบรรณ - ข้อมูลรายการหนังสือรับ-ส่ง</title>
<script type="text/javascript" src="../js/utilities.js"></script>
<script type="text/javascript" src="../js/calendarDateInput2.js"></script>
</head>
<body topmargin="0" rightmargin="0" bottommargin="0" leftmargin="0">
<table width="936" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="936" align="left" valign="top" style="padding:10px 0px 5px 10px">
<?php
/** Config Paging */
if( $perpage == "" ) { $limit = $_Config_limit; }
else { $limit = $perpage; }
$scroll = $_Config_scroll;
/** ตั้งค่า Default สำหรับการทำ Order By */
if( $OrderBy == "" ) { $OrderBy = $myTablePK; }
if( !isset($_GET['ASCDESC']) ) { $ASCDESC = "ASC"; }
if( $_GET['ASCDESC'] == "ASC" ) { $ASCDESC = "DESC"; }
elseif( $_GET['ASCDESC'] == "DESC" ) { $ASCDESC = "ASC"; }
/** Query เพื่อหา Numrows ก่อน */
if( $keyword != "" ) { // กรอก Keyword
if( $selectTypeBook != "" ) { // เลือกประเภท
switch( $selectTypeBook ) {
case 1 :
$query = " SELECT * FROM $myTable WHERE $myTableField1 LIKE '%$keyword%' ";
break;
case 2 :
$query = " SELECT * FROM $myTable WHERE $myTableField2 LIKE '%$keyword%' ";
break;
case 3 :
$query = " SELECT * FROM $myTable WHERE $myTableField3 LIKE '%$keyword%' ";
break;
case 4 :
$query = " SELECT * FROM $myTable WHERE $myTableField4 LIKE '%$keyword%' ";
break;
case 5 :
$query = " SELECT * FROM $myTable WHERE $myTableField5 LIKE '%$keyword%' ";
break;
} # switch
} else { // มีแต่ Keyword ไม่ได้ Select ประเภท
$query = " SELECT * FROM $myTable WHERE ( $myTableField1 LIKE '%$keyword%' OR $myTableField2 LIKE '%$keyword%' OR $myTableField3 LIKE '%$keyword%' OR $myTableField4 LIKE '%$keyword%' OR $myTableField5 LIKE '%$keyword%' ) ";
} # else
} else { // ไม่มีการกรอก Keyword
if(isset($_REQUEST['dateStart'])){
$query = " SELECT * FROM $myTable WHERE Date_start >= '".dmyE2ymdE2($_REQUEST['dateStart'])."' AND Date_finish <= '".dmyE2ymdE2($_REQUEST['dateFinish'])."' ";
}
else{
$query = " SELECT * FROM $myTable ";
}
}
$result = $dbObj->execQuery($query);
$numrows = $dbObj->_numrows;
//echo $query;
/** Paging */
$display = ( !isset ($_GET['page']) ) ? 1 : $_GET['page'];
$start = ( ($display * $limit) - $limit );
/** Paging */
if( $keyword != "" ) {
if( $selectTypeBook != "" ) {
if( isset($_GET['OrderBy']) ) {
switch( $selectTypeBook ) {
case 1 :
$query = " SELECT * FROM $myTable WHERE $myTableField1 LIKE '%$keyword%'
ORDER BY $OrderBy $ASCDESC ";
break;
case 2 :
$query = " SELECT * FROM $myTable WHERE $myTableField2 LIKE '%$keyword%'
ORDER BY $OrderBy $ASCDESC ";
break;
case 3 :
$query = " SELECT * FROM $myTable WHERE $myTableField3 LIKE '%$keyword%'
ORDER BY $OrderBy $ASCDESC ";
break;
case 4 :
$query = " SELECT * FROM $myTable WHERE $myTableField4 LIKE '%$keyword%'
ORDER BY $OrderBy $ASCDESC ";
break;
case 5 :
$query = " SELECT * FROM $myTable WHERE $myTableField5 LIKE '%$keyword%'
ORDER BY $OrderBy $ASCDESC ";
break;
} # switch
} # if
elseif( !isset($_GET['OrderBy']) ) {
switch( $selectTypeBook ) {
case 1 :
$query = " SELECT * FROM $myTable WHERE $myTableField1 LIKE '%$keyword%'
ORDER BY $myTablePK ASC ";
break;
case 2 :
$query = " SELECT * FROM $myTable WHERE $myTableField2 LIKE '%$keyword%'
ORDER BY $myTablePK ASC ";
break;
case 3 :
$query = " SELECT * FROM $myTable WHERE $myTableField3 LIKE '%$keyword%'
ORDER BY $myTablePK ASC ";
break;
case 4 :
$query = " SELECT * FROM $myTable WHERE $myTableField4 LIKE '%$keyword%'
ORDER BY $myTablePK ASC ";
break;
case 5 :
$query = " SELECT * FROM $myTable WHERE $myTableField5 LIKE '%$keyword%'
ORDER BY $myTablePK ASC ";
break;
} # switch
} # elseif
} else { // หาเฉพาะที่ใส่ Keyword
if( isset($_GET['OrderBy']) ) {
$query = " SELECT * FROM $myTable WHERE ( $myTableField1 LIKE '%$keyword%'
OR $myTableField2 LIKE '%$keyword%' OR $myTableField3 LIKE '%$keyword%' OR $myTableField4 LIKE '%$keyword%'
OR $myTableField5 LIKE '%$keyword%' ) Group By DateCar ,Teacher_code ORDER BY DateCar ASC ";
}
elseif( !isset($_GET['OrderBy']) ) {
$query = " SELECT * FROM $myTable WHERE ( $myTableField1 LIKE '%$keyword%' OR $myTableField2 LIKE '%$keyword%' OR $myTableField3 LIKE '%$keyword%' OR $myTableField4 LIKE '%$keyword%'
OR $myTableField5 LIKE '%$keyword%' ) Group By DateCar ,Teacher_code ORDER BY DateCar ASC ";
}
} # else
} else {
if( isset($_GET['OrderBy']) ) {
$query = " SELECT * FROM $myTable Group By DateCar ,Teacher_code ORDER BY DateCar ASC ";
}
elseif( !isset($_GET['OrderBy']) ) {
$query = " SELECT * FROM $myTable WHERE Date_start >= '".dmyE2ymdE2($_REQUEST['dateStart'])."' AND Date_finish <= '".dmyE2ymdE2($_REQUEST['dateFinish'])."' Group By DateCar ,Teacher_code ORDER BY DateCar ASC ";
} # elseif
} # else
$query .= " LIMIT $start, $limit ";
$result = $dbObj->execQuery($query);
?>
<table width="936" border="0" cellspacing="0" cellpadding="0">
<form id="myForm" name="myForm" method="post" action="<?=$PHP_SELF;?>?page=<?=$page;?>&Year=<?=$Year;?>">
<tr>
<td width="936" height="5"></td>
</tr>
<tr>
</tr>
<tr>
<td align="center" valign="top"><table width="750" border="0" cellspacing="0" cellpadding="0">
<tr>
</tr>
</table>
<table width="936" border="0" cellpadding="0" cellspacing="0" class="BORDER-GREY">
<tr bgcolor="#F8F8F8">
<td width="220" align="center" bgcolor="#66CCFF" class="BORDER-LEFT-5"><strong>Subject</strong></td>
<td width="43" height="29" align="center" bgcolor="#66CCFF" class="BORDER-LEFT-5"><strong>Start Date</strong></td>
<td width="55" align="center" bgcolor="#66CCFF" class=" PADDING-LEFT-5"><strong>Start Time</strong></td>
<td width="49" align="center" bgcolor="#66CCFF" class=" PADDING-LEFT-5"><strong>End Date</strong></td>
<td width="45" align="center" bgcolor="#66CCFF" class=" PADDING-LEFT-5"><strong>End Time</strong></td>
<td width="53" align="center" bgcolor="#66CCFF" class=" PADDING-LEFT-5"><strong>All Day Event</strong></td>
<td width="189" align="center" bgcolor="#66CCFF" class="BORDER-LEFT"><strong>Description</strong></td>
<td width="180" align="center" bgcolor="#66CCFF" class="BORDER-LEFT"><strong>Location</strong></td>
<td width="42" align="center" bgcolor="#66CCFF" class="BORDER-LEFT"><strong>Private</strong></td>
</tr>
<?php
$no = 1+($display-1)*$limit;
while( $row = $dbObj->fetchArray($result) ) {
$bgColor = ( $bgColor == "#FFFFFF" ) ? "#F9FBFB" : "#FFFFFF";
?>
<tr bgcolor="<?=$bgColor;?>" onmouseover="this.style.backgroundColor='#F5F9F9'" onmouseout="this.style.backgroundColor=''">
<td align="left" valign="top" class="BORDER-TOP-RIGHT">
<?
$name1 = $row["name1"];
$sql = "SELECT *, prefixName as First_name FROM personal_tb LEFT JOIN prefix ON personal_tb.First_name = prefix.prefixId Where Teacher_code ='$name1'";
$result1 = mysql_query($sql) or die("Error".mysql_error());
$rs2 = mysql_fetch_array($result1);
echo "$rs2[First_name] $rs2[Teacher_name] $rs2[Teacher_lastname]";?> <?=$row['Training_name'];?>
</td>
<td align="center" valign="top" class="BORDER-TOP-RIGHT">
<?php
$sday = $row['Date_start'];
$yearthai = explode("-",$sday);
$day = intval($yearthai[2]);
$month = intval($yearthai[1]);
$year = intval($yearthai[0]);
$m = getThaiSubMonth($month);
//echo "$day"." "."$m"." "."$year";
echo $row['Date_start'];
?>
</td>
<td align="left" valign="top" class="PADDING-LEFT-5 BORDER-TOP"><?php echo $row['Time_start']; ?></td>
<td align="center" valign="top" class="PADDING-LEFT-5 BORDER-TOP"><?php
$sday = $row['Date_finish'];
$yearthai = explode("-",$sday);
$day = intval($yearthai[2]);
$month = intval($yearthai[1]);
$year = intval($yearthai[0]);
$m = getThaiSubMonth($month);
echo "$day"." "."$m"." "."$year";
?></td>
<td align="left" valign="top" class="PADDING-LEFT-5 BORDER-TOP"><?php echo $row['Time_finish']; ?></td>
<td align="left" valign="top" class="PADDING-LEFT-5 BORDER-TOP"><strong>False</strong></td>
<td align="left" valign="top" class="BORDER-TOP BORDER-LEFT PADDING-LEFT-5"><?=$row['makeWord'];?><?php
$query2 = " SELECT * FROM province WHERE provinceId='$row[provinceId]' ";
$result2 = $dbObj->execQuery($query2);
$rs2 = $dbObj->fetchArray($result2);
echo $rs2[provinceName];
?>
</a>
เพื่อ
<?=$row['Training_name'];?>
<?
$CarmoId = $row["CarmoId"];
$sql = "Select * From automobile_tb Where CarmoId ='$CarmoId'";
$result1 = mysql_query($sql) or die("Error".mysql_error());
$rs2 = mysql_fetch_array($result1);
echo "$rs2[Acc_name]";?>
ทะเบียน
<?
$CarmoId = $row["CarmoId"];
$sql = "Select * From automobile_tb Where CarmoId ='$CarmoId'";
$result1 = mysql_query($sql) or die("Error".mysql_error());
$rs2 = mysql_fetch_array($result1);
echo "$rs2[CodeNo]";?>
</a>
พขร
<?
$name1 = $row["name1"];
$sql = "SELECT *, prefixName as First_name FROM personal_tb LEFT JOIN prefix ON personal_tb.First_name = prefix.prefixId Where Teacher_code ='$name1'";
$result1 = mysql_query($sql) or die("Error".mysql_error());
$rs2 = mysql_fetch_array($result1);
echo "$rs2[First_name] $rs2[Teacher_name] $rs2[Teacher_lastname]";?>
สถานะ
<?php if( $row['Status']=="อนุมัติ" ) echo "<font color=darkgreen>".$row['Status']."</font>"; else echo "<font color=orangered>".$row['Status']."</font>";?>
ผู้ร่วมเดินทาง
<?=$row['Make'];?>
คน <?php
$Teacher_code = $row['Teacher_code'] ;
$sql11 = " Select *, prefixName as First_name FROM personal_tb LEFT JOIN prefix ON personal_tb.First_name = prefix.prefixId Where Teacher_code='$Teacher_code' ";
$result11 = mysql_query($sql11);
$rs11 = mysql_fetch_array($result11);
echo"$rs11[First_name] $rs11[Teacher_name] $rs11[Teacher_lastname]";
?></td>
<td align="left" valign="top" class="BORDER-TOP BORDER-LEFT PADDING-LEFT-5"><?=$row['makeWord'];?> <?php
$query2 = " SELECT * FROM province WHERE provinceId='$row[provinceId]' ";
$result2 = $dbObj->execQuery($query2);
$rs2 = $dbObj->fetchArray($result2);
echo $rs2[provinceName];
?></a></td>
<td align="left" valign="top" class="BORDER-TOP BORDER-LEFT PADDING-LEFT-5"><strong>False</strong></td>
</tr>
<?php
$no++;
} # while
$dbObj->freeresult($result);
?>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
</tr>
</table></td>
</tr>
<tr>
</tr></form>
</table>
</td>
</tr>
</table>
<?php // include("footer.php"); ?>
</body>
</html>
<?php
/** Free Resource */
$dbObj->freeresult($result);
/** Close the Database */
$dbObj->disconn();
/** Unset Class */
unset($dbObj);
?>
|