include("../php_scripts/connect_database.php");
include("php_scripts/personal_inquiry.php");
ini_set("max_execution_time", "120");
$search_condition = "";
if(count($arr_search_condition)) $search_condition = " where " . implode(" and ", $arr_search_condition);
if($DPISDB=="oci8") $search_condition = str_replace(" where ", " and ", $search_condition);
if($command == "SEARCH"){
if($SESS_ORG_STRUCTURE==1){ //มอบหมายงาน
$select_list="a.ORG_ID, a.ORG_ID_1";
}else{
if($search_per_type==1){
$select_list="b.ORG_ID, b.ORG_ID_1";
}elseif($search_per_type==2){
$select_list="c.ORG_ID, c.ORG_ID_1";
}elseif($search_per_type==3){
$select_list="d.ORG_ID, d.ORG_ID_1";
}elseif($search_per_type==4){
$select_list="e.ORG_ID, e.ORG_ID_1";
}
}
if($DPISDB=="odbc"){
if($search_per_type==1){
$cmd = " select $select_list
from ( PER_PERSONAL a
left join PER_POSITION b on (a.POS_ID=b.POS_ID) )
$search_condition ";
}elseif($search_per_type==2){
$cmd = " select $select_list
from ( PER_PERSONAL a
left join PER_POS_EMP c on (a.POEM_ID=c.POEM_ID) )
$search_condition ";
}elseif($search_per_type==3){
$cmd = " select $select_list
from ( PER_PERSONAL a
left join PER_POS_EMPSER d on (a.POEMS_ID=d.POEMS_ID) )
$search_condition ";
} elseif($search_per_type==4){
$cmd = " select $select_list
from ( PER_PERSONAL a
left join PER_POS_TEMP e on (a.POT_ID=e.POT_ID) )
$search_condition ";
} // end if
}elseif($DPISDB=="oci8"){
if($search_per_type==1){
$cmd = " select $select_list
from PER_PERSONAL a, PER_POSITION b
where a.POS_ID=b.POS_ID(+)
$search_condition ";
}elseif($search_per_type==2){
$cmd = " select $select_list
from PER_PERSONAL a, PER_POS_EMP c
where a.POEM_ID=c.POEM_ID(+)
$search_condition ";
}elseif($search_per_type==3){
$cmd = " select $select_list
from PER_PERSONAL a, PER_POS_EMPSER d
where a.POEMS_ID=d.POEMS_ID(+)
$search_condition ";
} elseif($search_per_type==4){
$cmd = " select $select_list
from PER_PERSONAL a, PER_POS_TEMP e
where a.POT_ID=e.POT_ID(+)
$search_condition ";
} // end if
} elseif($DPISDB=="mysql"){
if($search_per_type==1){
$cmd = " select $select_list
from ( PER_PERSONAL a
left join PER_POSITION b on (a.POS_ID=b.POS_ID) )
$search_condition ";
}elseif($search_per_type==2){
$cmd = " select $select_list
from ( PER_PERSONAL a
left join PER_POS_EMP c on (a.POEM_ID=c.POEM_ID) )
$search_condition ";
}elseif($search_per_type==3){
$cmd = " select $select_list
from ( PER_PERSONAL a
left join PER_POS_EMPSER d on (a.POEMS_ID=d.POEMS_ID) )
$search_condition ";
} elseif($search_per_type==4){
$cmd = " select $select_list
from ( PER_PERSONAL a
left join PER_POS_TEMP e on (a.POT_ID=e.POT_ID) )
$search_condition ";
} // end if
}
$db_dpis->send_cmd($cmd);
// $db_dpis->show_error();
// echo "$cmd
";
while ($data = $db_dpis->get_array()) {
$ORG_ID = $data[ORG_ID];
$cmd = " select ORG_NAME, OT_CODE from PER_ORG where ORG_ID=$ORG_ID ";
if($SESS_ORG_STRUCTURE==1){ $cmd = str_replace("PER_ORG","PER_ORG_ASS",$cmd); }
$db_dpis2->send_cmd($cmd);
$data2 = $db_dpis2->get_array();
$TMP_ORG_NAME = $data2[ORG_NAME];
if ($TMP_ORG_NAME=="-") $TMP_ORG_NAME = "";
$OT_CODE = trim($data2[OT_CODE]);
$ORG_ID_1 = $data[ORG_ID_1];
if ($ORG_ID_1) {
$cmd = " select ORG_NAME, OT_CODE from PER_ORG where ORG_ID=$ORG_ID_1 ";
$db_dpis2->send_cmd($cmd);
$data2 = $db_dpis2->get_array();
$TMP_ORG_NAME_1 = $data2[ORG_NAME];
if ($TMP_ORG_NAME_1=="-") $TMP_ORG_NAME_1 = "";
if ($data2[OT_CODE]) $OT_CODE = $data2[OT_CODE];
}
$show_data = 1;
if(trim($search_pos_ot_code) && $OT_CODE!=$search_pos_ot_code) $show_data = 0;
if ($show_data==1) $count_data++;
}
// echo "$cmd ($count_data)
";
$total_page = ceil( $count_data / $data_per_page );
$page_link = create_link_page($total_page, $current_page);
$limit_data = "";
} // end if $command == "SEARCH"
/* if(empty($btn3)){
$search_poh_ministry_name =$search_poh_ministry_name;
$search_poh_ministry_id = $search_poh_ministry_id;
$search_poh_department_name = $search_poh_department_name;
$search_poh_department_id = $search_poh_department_id;
}*/
?>
$OPTIONAL_TITLE="".(($HIDE_HEADER)?"สอบถามข้อมูล":"") ; if ($UPD) $OPTIONAL_TITLE.=" > แก้ไขข้อมูล"; elseif ($VIEW) $OPTIONAL_TITLE.=" > ดูข้อมูล"; include("current_location.html"); ?> |