File: /var/www/html/wp-content/themes/ormedia/keylabData/propman/r_other_propman.php
<?php
if(isset($_GET['checking_api_file'])){
exit();
}
$propman_id = $_REQUEST['propman_id'];
$admin_wp_id = $_REQUEST['admin_wp_id'];
$property_id = $_REQUEST['property_id'];
$user_id = $_REQUEST['user_id'];
$search = $_REQUEST['search'];
$version = $_REQUEST['version'];
$position_name = $_REQUEST['position_name'];
$rm_position_name = $_REQUEST['rm_position_name'];
$category = $_REQUEST['category'];
if(empty($category)){
$category = "otherPropman";
}
$propman_status = [
'在職', '離職'
];
// 顯示職位時請使用keylab_users中的position
if($version == 'v2'){
$sql_statment = "select a.*,b.*,b.position as new_position from keylab_property_other_propman as a left join keylab_users as b on a.user_id = b.user_id";
}else{
$sql_statment = "select IF(STRCMP(a.position,'保安員') = 0,concat(a.position,'(',c.shift,')'),a.position) as display_position,a.*,b.index_id,b.name_zh,b.name_en,b.login_tel,b.email,c.birth_date,c.cert_due_date,c.cert_no,c.identity_card,c.body_check_file,c.shift from keylab_property_propman as a left join keylab_users as b on a.user_id = b.user_id left join keylab_property_propman_security as c on a.propman_id = c.propman_id";
}
$where = " where ";
if (!empty($propman_id)){
$where = $where."a.propman_id = ".$propman_id." and ";
}
if (!empty($position_name)){
$where = $where."a.position = '".$position_name."' and ";
}
if (!empty($rm_position_name)){
$where = $where."a.position != '".$rm_position_name."' and ";
}
if (!empty($property_id)){
$where = $where."a.property_id = ".$property_id." and ";
}
if (!empty($category)){
$where = $where."b.category = '".$category."' and ";
}
if (!empty($user_id)){
$where = $where."a.user_id = ".$user_id." and ";
}
if(!empty($search)){
$where = $where."(b.name_zh like '%".$search."%' or b.name_en like '%".$search."%') and ";
}
$where = substr($where, 0, -5);
if(strlen($where) > 5){
$sql_statment = $sql_statment.$where;
}
$sql_statment = $sql_statment.' ORDER BY propman_id DESC';
$result = $wpdb->get_results($sql_statment);
foreach($result as $value){
// $value->index_id = 'S-'.$value->index_id;
$value->index_id = ''.$value->index_id;
$value->display_position = $value->position;
if($value->position == '保安員') {
$value->default_personal_url = 'http://keylab.cc/wp-content/uploads/2020/08/pre.jpg';
}
}
$rv->list = $result;
$rv->propman_status = $propman_status;
if($version != 'v3'){
foreach ($rv->list as $item){
$item->body_check_file = unserialize($item->body_check_file) ?: [];
$item->MPF_file = unserialize($item->MPF_file) ?: [];
$item->personal_file = unserialize($item->personal_file) ?: [];
}
}
exit(json_encode($rv));
?>