HEX
Server: Apache/2.4.59 (Debian)
System: Linux keymana 4.19.0-21-cloud-amd64 #1 SMP Debian 4.19.249-2 (2022-06-30) x86_64
User: lijunjie (1003)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wp-content/themes/ormedia/keylabData/propman/r_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'];

$propman_status = [
    '在職', '離職' 
];

// 顯示職位時請使用keylab_users中的position
if($version == 'v3'){
    $sql_statment = "select a.*,b.index_id,b.type,b.name_zh,b.login_tel,c.name_zh as property_name
     from keylab_property_propman as a left join keylab_users as b on a.user_id = b.user_id left join keylab_property as c on a.property_id = c.property_id";
}else if($version == 'v2'){
    $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,b.type,b.position as new_position,c.birth_date,c.cert_due_date,
    c.cert_due_date2,c.cert_due_date3,c.cert_due_date4,c.physical_date,c.cert_no,c.identity_card,c.body_check_file,c.shift,
    c.license_no,
    c.propman_no,
    c.separation,
    c.exchange_date,
    c.departure_date,
    c.on_work_time,
    c.out_work_time,
    c.morning,
    c.noon,
    c.extra,
    c.daily_wage,
    c.wage,
    c.address,
    c.post_rank,
    c.HKID,
    c.certificate,
    c.QAS,
    c.bank_account,
    c.bank_name,
    c.personal_file
     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";
}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."b.position = '".$position_name."' and ";
}
if (!empty($rm_position_name)){
    $where = $where."b.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($admin_wp_id)){
    $where = $where."c.admin_wp_id = ".$admin_wp_id." 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;
    if($version != 'v3'){
        $value->position = $value->new_position;
        $value->display_position = $value->new_position;
    }
    if($value->position == '保安員'|| $value->new_position == '保安員') {
        $value->default_personal_url = 'http://keylab.cc/wp-content/uploads/2020/08/pre.jpg';
    }
}
$rv->list = $result;
$rv->propman_status = $propman_status;
$rv->sql = $wpdb->last_query;
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));
?>