อันฝั่ง Server ไฟล์ชื่อ get_employee.php Code (PHP)
<?php
@header('Content-Type: text/html; charset=tis-620');
$Temp= ($_REQUEST['Temp']);
$sort = isset($_POST['sort']) ? strval($_POST['sort']) : 'EmpNum';
$order = isset($_POST['order']) ? strval($_POST['order']) : 'asc';
include'DB/conn.php';
$rs = mssql_query(" SELECT
EmpNum ,EmpName ,SurName ,Company as CompanyCheck
,isnull((convert(varchar, convert(datetime,ProbationDate),105)),'') as ProbationDate
,isnull((convert(varchar, convert(datetime,HireDate),105)),'') as HireDate
,(select company+' - '+conamedisplay from company as Co where Co.company=Emp.company) as Company
,(select Code+' - '+DescriptionEng from SetupCode as SCode where SCode.Category= 'EmpGroup' and SCode.Code=Emp.EmpGroup ) as EmpGroup
,(select OrgNum+' - '+OrgNameEng from Organization as Org where Org.OrgNum=Emp.Organize) as Organize
,(select Position+' - '+PosNameEng from Position as Pos where Pos.Position=Emp.Position)as Position
,(select Code+' - '+DescriptionEng from SetupCode as SCode where SCode.Category= 'Level' and SCode.Code=Emp.EmpLevel ) as EmpLevel
,(select DescriptionEng from SetupCode as SCode where SCode.Category= 'EmpStatus' and SCode.Code=Emp.EmpStatus ) as Status
,Emp.EmpLevel as LevelCheck
from Employee as Emp
where EmpName like '$Temp%' order by Company,$sort $order");
$result = array();
while($row = mssql_fetch_object($rs)){
$row->EmpName = iconv('tis-620','utf-8',$row->EmpName);
$row->SurName = iconv('tis-620','utf-8',$row->SurName);
$row->NameEng = iconv('tis-620','utf-8',$row->NameEng);
$row->SurNameEng = iconv('tis-620','utf-8',$row->SurNameEng);
$row->EmpGroup = iconv('tis-620','utf-8',$row->EmpGroup);
array_push($result, $row);
}
echo json_encode($result);
?>