File: /var/www/doco/keytest/wp-content/themes/ormedia/keylabData/minutes/r_minutes.php
<?php
// if(isset($_REQUEST['checking_api_file'])){
// exit();
// }
// $property_id = $_REQUEST['property_id'];
// $search = $_REQUEST['search'];
// $rv = new stdClass();
// $sql_statment = "select * from keylab_property_minutes";
// $where = " where ";
// if (!empty($property_id)){
// $where = $where."property_id = ".$property_id." and ";
// }
// if(!empty($search)){
// $where = $where."type like '%".$search."%' and ";
// }
// $where = substr($where, 0, -5);
// if(strlen($where) > 5){
// $sql_statment = $sql_statment.$where;
// }
// $result = $wpdb->get_results($sql_statment);
// $rv->list = $result;
// foreach ($rv->list as $item){
// $item->minutes_file = unserialize($item->minutes_file) ?: [];
// $item->agenda_file = unserialize($item->agenda_file) ?: [];
// }
// exit(json_encode($rv));
if(isset($_REQUEST['checking_api_file'])){
exit();
}
$property_id = $_REQUEST['property_id'];
$search = $_REQUEST['search'];
$platform = $_REQUEST['platform'];
$sql_statment = "select * from keylab_property_minutes";
$where = " where ";
if (!empty($property_id)){
$where = $where."property_id = ".$property_id." and ";
}
if(!empty($search)){
$where = $where."type like '%".$search."%' and ";
}
$where = substr($where, 0, -5);
if(strlen($where) > 5){
$sql_statment = $sql_statment.$where;
}
// if($platform=="app"){
// $sql_statment.=" order by meeting_date desc";
// }
$sql_statment = $sql_statment.' ORDER BY minutes_id DESC';
$result = $wpdb->get_results($sql_statment);
if($platform=="app"){
$blocks = [];
foreach($result as $r){
array_push($blocks,$r->oc_term);
}
$blocks = array_unique($blocks);
arsort($blocks);
$list2 = [];
foreach ($blocks as $value) {
$obj = new stdClass();
$obj->type = $value;
$obj->list = [];
foreach ($result as $r) {
if($r->oc_term==$value){
array_push($obj->list,$r);
}
}
foreach ($obj->list as $item){
$item->minutes_file = unserialize($item->minutes_file) ?: [];
$item->agenda_file = unserialize($item->agenda_file) ?: [];
}
array_push($list2,$obj);
}
$rv->list = $list2;
}else{
$rv->list = $result;
foreach ($rv->list as $item){
$item->minutes_file = unserialize($item->minutes_file) ?: [];
$item->agenda_file = unserialize($item->agenda_file) ?: [];
}
}
exit(json_encode($rv));
?>