File manager - Edit - /home/autoph/public_html/connectv1/api/reports/reports.php
Back
<?php include_once("../../cfg/db.php"); if(isset($_GET['search'])){ $search = $db -> escape(trim($_GET['search'])); }else{ $search = ""; } if(isset($_GET['offset'])){ $offset = $db -> escape(trim($_GET['offset'])); }else{ $offset = ""; } if(isset($_GET['limit'])){ $limit = $db -> escape(trim($_GET['limit'])); $offset_limit = " LIMIT ". $offset.",".$limit; }else{ $offset_limit = ""; } $json_arr['reports'] = array(); $apiKey= $_REQUEST['apiKey']; $userID= $_REQUEST['userID']; //RecordID / // OwerID or UserID ng nagrequest //name of requestor // Description // Date/Gtime Requested if ($_SERVER["REQUEST_METHOD"] == "POST") { //change get to post later if($apiKey === 'PANGET_NI_JEAN_AT_DAN'){ //change api key as per asa $employee_query = "SELECT %s FROM `report`r INNER JOIN report_type rt ON r.report_type_id = rt.id INNER JOIN employee e ON e.id = r.employee_id INNER JOIN report_status rs ON r.id = rs.report_id WHERE rs.`employee_id` = (SELECT id from employee WHERE asa_id = '$userID') AND rs.status = 0 AND (SELECT DATEDIFF(r.expire,NOW()) > 0) AND ( IF( (SELECT count(id) FROM `report_status` WHERE report_id = r.id AND `status` = 2) = 0 , IF( (SELECT count(id) FROM `report_status` WHERE report_id = r.id AND `status` = 0) = 0 , '1', '0' ), '2' ) ) = 0 AND concat(r.id,r.control_number) LIKE '%%%s%%' ORDER BY r.report_date DESC ,r.report_time DESC"; $count = " count(r.id) "; $fields = " e.asa_id,r.employee_id as requestor_id,concat(e.first_name,' ',e.last_name) as requestor_name,r.id,r.control_number,DATE_FORMAT(r.report_date, '%M %d, %Y') as report_date, TIME_FORMAT(r.report_time, '%h:%i %p') as report_time,rt.name, DATE_FORMAT(r.expire, '%M %d, %Y') as expire,r.`description`, ( IF( (SELECT DATEDIFF(r.expire,NOW()) < 0),'Expired', IF( (SELECT count(id) FROM `report_status` WHERE report_id = r.id AND `status` = 2) = 0 , IF( (SELECT count(id) FROM `report_status` WHERE report_id = r.id AND `status` = 0) = 0 , 'Approved', 'Pending' ), 'Declined' ) ) ) as status"; // echo sprintf($employee_query,$fields,$search);exit; $empoloyee_list_query = $db -> sql_query(sprintf($employee_query,$fields,$search)." $offset_limit"); $employee_list_query_count = $db -> select(sprintf($employee_query,$count,$search)); while($row = $empoloyee_list_query->fetch_assoc()) { $json_arr['reports'] = array_merge($json_arr['reports'] ,array( array( 'requestor_id'=>$row['requestor_id'], 'asa_id'=>$row['asa_id'], 'requestor_name'=>$row['requestor_name'], 'report_id'=>$row['id'], 'report_type'=>$row['name'], 'control_number'=>$row['control_number'], 'report_date'=>$row['report_date'], 'report_time'=>$row['report_time'], 'report_expire_date'=>$row['expire'], 'report_description'=>$row['description'], 'status'=>$row['status']))) ; } if($employee_list_query_count > 0 ){ $json_arr['found'] = $employee_list_query_count." Record".((intval($employee_list_query_count) < 2) ? '' : 's' )." Found"; }else{ $json_arr['found'] = "No Record Found"; } $json_arr['total'] = $employee_list_query_count; //total number of result echo json_encode($json_arr); return; }else{ // $return_arr["status"]=0; $return_arr["message"]=" You are not allowed to do this action."; // echo json_encode($return_arr); echo $return_arr["message"]; return; } }else{ // $return_arr["status"]=0; $return_arr["message"]=" You are not allowed to do this action."; // echo json_encode($return_arr); echo $return_arr["message"]; return; } ?>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings