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/check_list/r_check_list.php
<?php
function gen_check_obj($title,$var,$limit){
	$obj = new stdClass();
	$obj->title = $title;
	$obj->count = (int)$var;
	$obj->limit = $limit;
	return $obj;
}
function get_obj_by_property_id($table,$property_id,$title,$limit){
	global $wpdb;
	$sql = "select count(property_id) from ".$table;
	$where = $wpdb->prepare(" where property_id = %d",$property_id);
	$var = $wpdb->get_var($sql.$where);
	return gen_check_obj($title,$var,$limit);
}

function get_report_obj_by_property_id($report_type,$property_id,$title,$limit){
	global $wpdb;
	if ($report_type=="term") {
		$sql = "select count(b.regular_report_id) from keylab_property_term_contract as a left join keylab_property_term_contract_regular_report as b on a.term_contract_id = b.term_contract_id";
	}else{
		$sql = "select count(b.work_report_id) from keylab_property_individual_contract as a left join keylab_property_individual_contract_work_report as b on a.individual_contract_id = b.individual_contract_id";
	}
	$where = $wpdb->prepare(" where a.property_id = %d",$property_id);
	$var = $wpdb->get_var($sql.$where);
	return gen_check_obj($title,$var,$limit);
}

function get_unitfile_obj_by_property_id($property_id,$title,$limit){
	global $wpdb;
	$sql = "select count(b.unit_file_id) from keylab_property_unit_list as a left join keylab_property_unit_file as b on a.unit_id = b.unit_id";
	$where = $wpdb->prepare(" where a.property_id = %d",$property_id);
	$var = $wpdb->get_var($sql.$where);
	return gen_check_obj($title,$var,$limit);
}

if(isset($_REQUEST['checking_api_file'])){
    exit();
}

$property_id = $_REQUEST['property_id'];

$rv->list = array();

$docs = new stdClass();
$docs->title = "大廈相關人員";
$docs->list = array();
array_push($docs->list,get_obj_by_property_id("keylab_property_propman",$property_id,"物管人員",10));
array_push($docs->list,get_obj_by_property_id("keylab_property_oc",$property_id,"法團成員",10));
array_push($docs->list,get_obj_by_property_id("keylab_property_contractor",$property_id,"承辦商",10));
array_push($rv->list,$docs);

$docs = new stdClass();
$docs->title = "大廈檔案";
$docs->list = array();
array_push($docs->list,get_obj_by_property_id("keylab_property_notice",$property_id,"大廈通告",5));
array_push($docs->list,get_obj_by_property_id("keylab_property_important",$property_id,"政府法令",5));
array_push($docs->list,get_obj_by_property_id("keylab_property_minutes",$property_id,"會議紀錄",5));
array_push($docs->list,get_obj_by_property_id("keylab_property_insurance_claims",$property_id,"保險索償",5));
array_push($rv->list,$docs);

$docs = new stdClass();
$docs->title = "大廈工程合約";
$docs->list = array();
array_push($docs->list,get_obj_by_property_id("keylab_property_term_contract",$property_id,"常規合約",6));
array_push($docs->list,get_report_obj_by_property_id("term",$property_id,"常規合約 - 檢查報告",6));
array_push($docs->list,get_obj_by_property_id("keylab_property_individual_contract",$property_id,"一次性合約",6));
array_push($docs->list,get_report_obj_by_property_id("individual",$property_id,"一次性合約 - 工作報告",6));
array_push($rv->list,$docs);

$docs = new stdClass();
$docs->title = "大廈單位資料";
$docs->list = array();
array_push($docs->list,get_obj_by_property_id("keylab_property_unit_list",$property_id,"單位列表",20));
array_push($docs->list,get_unitfile_obj_by_property_id($property_id,"單位檔案",20));
array_push($rv->list,$docs);

exit(json_encode($rv));
?>