File manager - Edit - /home/autoph/public_html/connectv1/api/ltms_report/ltms_report.php
Back
<?php include_once("../../cfg/db.php"); include_once("../../api/controllers/utility.php"); if(!isset($_SESSION['user']['id'])){ echo "Session Expired."; exit; } $utility = new Utility(); if (isset($_REQUEST['apiKey']) && $_REQUEST['apiKey']=='22221111190383') { $date_from = $_REQUEST['date_from']; $date_to = $_REQUEST['date_to']; $cs_number = $_REQUEST['cs_number']; $cs_filter = ''; if($cs_number ==1) { $cs_filter = " AND (cs_number IS NOT NULL AND LENGTH(cs_number) > 2) "; } if($cs_number ==2) { $cs_filter = " AND (cs_number IS NULL OR LENGTH(cs_number)= 0) "; } $results = []; $no_per_request = isset($_REQUEST['limit']) ? (int)$_REQUEST['limit'] : 50; $offset = isset($_REQUEST['offset']) ? (int)$_REQUEST['offset'] : 0; // Total data count $total_data_query = $db->connect()->query("SELECT count(DISTINCT fullname) as total FROM customer_upload_ltms WHERE active = 1 AND DATE(created_at) >= '$date_from' AND DATE(created_at) <= '$date_to' $cs_filter "); $total_data = $total_data_query->fetch_assoc()['total']; // echo "SELECT count(DISTINCT fullname) as total FROM customer_upload_ltms WHERE active = 1 AND DATE(created_at) >= '$date_from' AND DATE(created_at) <= '$date_to' $cs_filter ";exit; // var_dump("SELECT count(DISTINCT fullname) as total FROM customer_upload_ltms WHERE active = 1 AND DATE(created_at) >= '$date_from' AND DATE(created_at) <= '$date_to' $cs_filter ");; // Fetch data with limit and offset $data = $db->connect()->query("SELECT fullname, cs_number, created_at FROM customer_upload_ltms WHERE active = 1 AND DATE(created_at) >= '$date_from' AND DATE(created_at) <= '$date_to' $cs_filter GROUP BY fullname ORDER BY created_at DESC LIMIT $no_per_request OFFSET $offset"); // var_dump("SELECT fullname, cs_number, created_at FROM customer_upload_ltms WHERE active = 1 AND DATE(created_at) >= '$date_from' AND DATE(created_at) <= '$date_to' $cs_filter GROUP BY fullname ORDER BY created_at DESC LIMIT $no_per_request OFFSET $offset");exit; if ($data->num_rows > 0) { // $total_data = $data->num_rows; foreach ($data as $row) { $results[] = $row; } echo json_encode(['total_data' => $total_data, 'results' => $results]); } else { echo json_encode(['total_data' => $total_data, 'results' => []]); } } ?>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings