Batch 6a: application controllers base
This commit is contained in:
90
application/controllers/ai-lab-translate/Ai_lab.php
Normal file
90
application/controllers/ai-lab-translate/Ai_lab.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
class Ai_lab extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
var $hostname;
|
||||
|
||||
public function index()
|
||||
{
|
||||
// Ini di devone
|
||||
echo "BE untuk AI Lab";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db_onedev = $this->load->database('one_aditya', TRUE);
|
||||
$this->hostname = "devone.aplikasi.web.id";
|
||||
}
|
||||
|
||||
public function sendToAi()
|
||||
{
|
||||
// $inputs = $_POST['data'];
|
||||
$input = file_get_contents('php://input');
|
||||
|
||||
/* Coba CURL ke /translate-array */
|
||||
|
||||
$curl = curl_init();
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'http://10.9.10.205:4321/translate',
|
||||
// CURLOPT_URL => 'http://10.9.10.205:4321/nonlab',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => json_encode(['input' => $input]), // JSON-encode the string with "data" key
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json', // Set content type to JSON
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
if ($response === false) {
|
||||
// An error occurred during the cURL request
|
||||
$error = curl_error($curl);
|
||||
$this->sys_error($error);
|
||||
exit;
|
||||
} else {
|
||||
$result = json_decode($response, true);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
|
||||
public function sendToAiArr()
|
||||
{
|
||||
$inputs = $_POST['data'];
|
||||
// $inputs = ["reaktif", "proaktif", "kamu harus makan obat"];
|
||||
|
||||
/* Coba CURL ke /translate-array */
|
||||
$payload = json_encode(['input' => array_values($inputs)]);
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'http://10.9.10.204:4321/translate-array',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => $payload,
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json'
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
if ($response === false) {
|
||||
// An error occurred during the cURL request
|
||||
$error = curl_error($curl);
|
||||
$this->sys_error($error);
|
||||
exit;
|
||||
} else {
|
||||
$result = json_decode($response, true);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
181
application/controllers/ais/Bridging.php
Normal file
181
application/controllers/ais/Bridging.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
class Bridging extends MY_Controller
|
||||
{
|
||||
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Resultentry API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->db_log = $this->load->database("log", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
public function error_log($data,$userid=999)
|
||||
{
|
||||
|
||||
$sql = "INSERT INTO ais_error_log (
|
||||
AisErrorLogFnName,
|
||||
AisErrorLogMessage,
|
||||
AisErrorLogQuery,
|
||||
AisErrorLogJson,
|
||||
AisErrorLogUserID,
|
||||
AisErrorLogCreated
|
||||
)
|
||||
VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db_log->query($sql, array($data['fn_name'],$data['message'],$data['query'],$data['json'],$userid));
|
||||
//echo $this->db_log->last_query();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic POST request function
|
||||
* @param string $url API endpoint URL
|
||||
* @param array $data Request payload
|
||||
* @param array $headers Custom headers (optional)
|
||||
* @return array Response from API
|
||||
*/
|
||||
public function post_request($url, $data = array(), $headers = array())
|
||||
{
|
||||
// Default headers
|
||||
$default_headers = array(
|
||||
'Content-Type: application/json'
|
||||
);
|
||||
|
||||
// Merge custom headers with default headers
|
||||
$final_headers = array_merge($default_headers, $headers);
|
||||
|
||||
// Initialize cURL
|
||||
$ch = curl_init();
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
|
||||
// Execute cURL request
|
||||
$response = curl_exec($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$error = curl_error($ch);
|
||||
|
||||
// Close cURL
|
||||
curl_close($ch);
|
||||
|
||||
// Prepare result
|
||||
$result = array(
|
||||
'success' => false,
|
||||
'http_code' => $http_code,
|
||||
'response' => null,
|
||||
'error' => null
|
||||
);
|
||||
|
||||
if ($error) {
|
||||
$result['error'] = $error;
|
||||
} else {
|
||||
$result = json_decode($response, true);
|
||||
$result['success'] = true;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function get_config()
|
||||
{
|
||||
$sql = "SELECT * FROM ais_config LIMIT 1";
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
$dt_config = $qry->row_array();
|
||||
return $dt_config;
|
||||
}
|
||||
|
||||
/**
|
||||
* POST request to auth API
|
||||
* @param string $username Username for authentication
|
||||
* @param string $password Password for authentication
|
||||
* @return array Response from API
|
||||
*/
|
||||
public function post_auth()
|
||||
{
|
||||
$dt_config = $this->get_config();
|
||||
$baseUrl = $dt_config['AisConfigBaseUrl'];
|
||||
$url = $baseUrl.'/api/auth/auth.php';
|
||||
$headers = array(
|
||||
'Header-Token: '.$dt_config['AisConfigHeaderToken']
|
||||
);
|
||||
|
||||
$username = $dt_config['AisConfigUsername'];
|
||||
$password = $dt_config['AisConfigPassword'];
|
||||
|
||||
$data = array(
|
||||
'username' => $username,
|
||||
'password' => $password
|
||||
);
|
||||
|
||||
$result = $this->post_request($url, $data, $headers);
|
||||
$sql = "INSERT INTO ais_login_log(
|
||||
AisLoginLogUsername,
|
||||
AisLoginLogPassword,
|
||||
AisLoginLogHeaderToken,
|
||||
AisLoginLogResult,
|
||||
AisLoginLogCreated
|
||||
)
|
||||
VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db_log->query($sql, array($username,$password,$dt_config['AisConfigHeaderToken'],json_encode($result)));
|
||||
|
||||
|
||||
if(!$qry){
|
||||
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_login_log insert','query'=>$sql,'json'=>json_encode($result)),999);
|
||||
exit;
|
||||
}
|
||||
//print_r($result);
|
||||
//exit;
|
||||
// Check if success
|
||||
if(!$result['success']){
|
||||
$this->error_log(array('fn_name'=>'post_auth','message'=>'failed auth','query'=>'','json'=>json_encode($result)),999);
|
||||
$errors = array('status' => 'error','message' => 'Gagal Login');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}else{
|
||||
// Update token
|
||||
$token = $result['data']['token'];;
|
||||
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
|
||||
$qry = $this->db_onedev->query($sql, array($token));
|
||||
//echo $this->db_onedev->last_query();
|
||||
//exit;
|
||||
if(!$qry){
|
||||
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_config update','query'=>$sql,'json'=>''),999);
|
||||
$errors = array('status' => 'error','message' => 'Gagal Update Token');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
|
||||
$success = array('status' => 'success','message' => 'Berhasil Login');
|
||||
echo json_encode($success);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
417
application/controllers/ais/Corporate.php
Normal file
417
application/controllers/ais/Corporate.php
Normal file
@@ -0,0 +1,417 @@
|
||||
<?php
|
||||
class Corporate extends MY_Controller
|
||||
{
|
||||
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Resultentry API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->db_log = $this->load->database("log", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
public function error_log($data, $userid = 999)
|
||||
{
|
||||
|
||||
$sql = "INSERT INTO ais_error_log (
|
||||
AisErrorLogFnName,
|
||||
AisErrorLogMessage,
|
||||
AisErrorLogQuery,
|
||||
AisErrorLogJson,
|
||||
AisErrorLogUserID,
|
||||
AisErrorLogCreated
|
||||
)
|
||||
VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db_log->query($sql, array($data['fn_name'], $data['message'], $data['query'], $data['json'], $userid));
|
||||
//echo $this->db_log->last_query();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic POST request function
|
||||
* @param string $url API endpoint URL
|
||||
* @param array $data Request payload
|
||||
* @param array $headers Custom headers (optional)
|
||||
* @return array Response from API
|
||||
*/
|
||||
public function post_request($url, $data = array(), $headers = array())
|
||||
{
|
||||
// Default headers
|
||||
$default_headers = array(
|
||||
'Content-Type: application/json'
|
||||
);
|
||||
|
||||
// Merge custom headers with default headers
|
||||
$final_headers = array_merge($default_headers, $headers);
|
||||
|
||||
// Initialize cURL
|
||||
$ch = curl_init();
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
|
||||
// Execute cURL request
|
||||
$response = curl_exec($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$error = curl_error($ch);
|
||||
|
||||
// Close cURL
|
||||
curl_close($ch);
|
||||
|
||||
// Prepare result
|
||||
$result = array(
|
||||
'success' => false,
|
||||
'http_code' => $http_code,
|
||||
'response' => null,
|
||||
'error' => null
|
||||
);
|
||||
|
||||
if ($error) {
|
||||
$result['error'] = $error;
|
||||
} else {
|
||||
$result = json_decode($response, true);
|
||||
if ($result['status'] == 200) {
|
||||
$result['success'] = true;
|
||||
} else {
|
||||
$result['success'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function get_request($url, $headers = array())
|
||||
{
|
||||
// Retrieve configuration
|
||||
$config = $this->get_config();
|
||||
$token = $config['AisConfigAuthToken'] ?? 'default-token';
|
||||
$header_token = $config['AisConfigHeaderToken'];
|
||||
|
||||
// Default headers based on the curl command
|
||||
$default_headers = array(
|
||||
'Header-Token: ' . $header_token,
|
||||
'Authorization: Bearer ' . $token
|
||||
);
|
||||
|
||||
// Merge custom headers with default headers
|
||||
$final_headers = array_merge($default_headers, $headers);
|
||||
|
||||
// Initialize cURL
|
||||
$ch = curl_init();
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_HTTPGET, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
|
||||
// Execute cURL request
|
||||
$response = curl_exec($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$error = curl_error($ch);
|
||||
|
||||
// Close cURL
|
||||
curl_close($ch);
|
||||
|
||||
// Prepare result
|
||||
$result = array(
|
||||
'success' => false,
|
||||
'http_code' => $http_code,
|
||||
'response' => null,
|
||||
'error' => null
|
||||
);
|
||||
|
||||
if ($error) {
|
||||
$result['error'] = $error;
|
||||
} else {
|
||||
$decoded = json_decode($response, true);
|
||||
$result['response'] = $decoded;
|
||||
// Check if response is successful based on http code
|
||||
if ($http_code === 200) {
|
||||
$result['success'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function get_config()
|
||||
{
|
||||
$sql = "SELECT * FROM ais_config LIMIT 1";
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'get_config', 'message' => 'ais_config select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
exit;
|
||||
}
|
||||
$dt_config = $qry->row_array();
|
||||
return $dt_config;
|
||||
}
|
||||
|
||||
/**
|
||||
* POST request to auth API
|
||||
* @param string $username Username for authentication
|
||||
* @param string $password Password for authentication
|
||||
* @return array Response from API
|
||||
*/
|
||||
public function post_auth()
|
||||
{
|
||||
$dt_config = $this->get_config();
|
||||
$baseUrl = $dt_config['AisConfigBaseUrl'];
|
||||
$url = $baseUrl . '/api/auth/auth.php';
|
||||
$headers = array(
|
||||
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
|
||||
);
|
||||
|
||||
$username = $dt_config['AisConfigUsername'];
|
||||
$password = $dt_config['AisConfigPassword'];
|
||||
|
||||
$data = array(
|
||||
'username' => $username,
|
||||
'password' => $password
|
||||
);
|
||||
|
||||
$result = $this->post_request($url, $data, $headers);
|
||||
$sql = "INSERT INTO ais_login_log(
|
||||
AisLoginLogUsername,
|
||||
AisLoginLogPassword,
|
||||
AisLoginLogHeaderToken,
|
||||
AisLoginLogResult,
|
||||
AisLoginLogCreated
|
||||
)
|
||||
VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db_log->query($sql, array($username, $password, $dt_config['AisConfigHeaderToken'], json_encode($result)));
|
||||
|
||||
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_login_log insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
|
||||
exit;
|
||||
}
|
||||
//print_r($result);
|
||||
//exit;
|
||||
// Check if success
|
||||
if (!$result['success']) {
|
||||
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($result)), 999);
|
||||
$errors = array('status' => 'error', 'message' => 'Gagal Login');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
} else {
|
||||
// Update token
|
||||
$token = $result['data']['token'];
|
||||
;
|
||||
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
|
||||
$qry = $this->db_onedev->query($sql, array($token));
|
||||
//echo $this->db_onedev->last_query();
|
||||
//exit;
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_config update', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
$errors = array('status' => 'error', 'message' => 'Gagal Update Token');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
|
||||
//$success = array('status' => 'success', 'message' => 'Berhasil Login', 'token' => $token);
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* POST request to jenis layanan API
|
||||
* @param array $data Array of jenis layanan data
|
||||
* @return array Response from API
|
||||
*/
|
||||
|
||||
function monitoring_corporate()
|
||||
{
|
||||
|
||||
|
||||
// Ambil parameter
|
||||
$corporate_name = $this->input->get('corporate_name');
|
||||
$corporate_status = $this->input->get('corporate_status');
|
||||
$corporate_code = $this->input->get('corporate_code');
|
||||
|
||||
$where_query = "WHERE c.CorporateIsActive = 'Y'";
|
||||
if ($corporate_name || $corporate_code) {
|
||||
$where_query .= "AND ( c.CorporateName LIKE '%{$corporate_code}%' OR c.CorporateCode LIKE '%{$corporate_code}%' ) ";
|
||||
|
||||
}
|
||||
|
||||
// Pagination
|
||||
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
|
||||
$limit = 10;
|
||||
$offset = ($page - 1) * $limit;
|
||||
|
||||
$sql_base = "SELECT
|
||||
|
||||
DISTINCT c.CorporateID AS corporate_id,
|
||||
0 as T_OrderHeaderID,
|
||||
c.CorporateName AS corporate_name,
|
||||
c.CorporateCode AS corporate_code,
|
||||
c.CorporateAddress AS corporate_address,
|
||||
c.CorporateEmail AS corporate_email,
|
||||
c.CorporatePhone AS corporate_phone,
|
||||
ais_pillar_name,
|
||||
'' as Ais_CorporateStatus ,
|
||||
'' AS corporate_status,
|
||||
'' AS Ais_CorporateID
|
||||
FROM corporate c
|
||||
LEFT JOIN corporate_type ON CorporateCorporateTypeID = CorporateTypeID
|
||||
LEFT JOIN ais_pillar ON CorporateTypeais_pillar_code = ais_pillar_code
|
||||
$where_query
|
||||
GROUP BY c.CorporateID
|
||||
ORDER BY c.CorporateID ASC
|
||||
LIMIT $limit OFFSET $offset";
|
||||
|
||||
//echo $sql_base;
|
||||
|
||||
$params = [];
|
||||
|
||||
|
||||
|
||||
// Count total records for pagination
|
||||
$count_sql = "
|
||||
SELECT COUNT(*) AS total
|
||||
FROM (
|
||||
SELECT
|
||||
|
||||
DISTINCT c.CorporateID AS corporate_id
|
||||
FROM corporate c
|
||||
$where_query
|
||||
) AS x
|
||||
";
|
||||
|
||||
$qry_count = $this->db_onedev->query($count_sql);
|
||||
// echo $this->db_onedev->last_query();
|
||||
$total = $qry_count->row()->total ?? 0;
|
||||
|
||||
|
||||
$qry = $this->db_onedev->query($sql_base);
|
||||
// echo $this->db_onedev->last_query();
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data = $qry->result_array();
|
||||
if($data){
|
||||
foreach($data as $k => $d){
|
||||
$data[$k]['corporate_status'] = 'N';
|
||||
$data[$k]['Ais_CorporateStatus'] = null;
|
||||
$data[$k]['Ais_CorporateID'] = null;
|
||||
$sql = "SELECT *
|
||||
FROM ".$this->db_log->database.".ais_corporate
|
||||
WHERE Ais_CorporateCorporateCode = ?
|
||||
ORDER BY Ais_CorporateLastUpdate DESC
|
||||
LIMIT 1";
|
||||
$qry_corporate = $this->db_log->query($sql, [$d['corporate_code']]);
|
||||
if($qry_corporate){
|
||||
$data[$k]['corporate_status'] = 'N';
|
||||
$status = $qry_corporate->row()->Ais_CorporateStatus;
|
||||
if($status && $status == 'SUCCESS'){
|
||||
$data[$k]['corporate_status'] = 'Y';
|
||||
}
|
||||
$data[$k]['Ais_CorporateStatus'] = $qry_corporate->row()->Ais_CorporateStatus;
|
||||
$data[$k]['Ais_CorporateID'] = $qry_corporate->row()->Ais_CorporateID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'status' => 'success',
|
||||
'message' => 'Berhasil mengambil data monitoring.',
|
||||
'data' => $data,
|
||||
'total' => $total,
|
||||
'page' => $page,
|
||||
'limit' => $limit,
|
||||
'total_page' => ceil($total / $limit)
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_json_response()
|
||||
{
|
||||
// Ambil corporate_code dari query parameter
|
||||
$corporate_code = $this->input->get('corporate_code');
|
||||
|
||||
if (empty($corporate_code)) {
|
||||
return $this->output
|
||||
->set_status_header(400)
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'corporate_code parameter is required'
|
||||
]));
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
Ais_CorporateID AS id,
|
||||
Ais_CorporateCorporateCode AS corporate_code,
|
||||
Ais_CorporateJSON AS json,
|
||||
Ais_CorporateStatus AS status,
|
||||
Ais_CorporateResponse AS response,
|
||||
Ais_CorporateLastUpdate AS last_update,
|
||||
Ais_CorporateUserID AS user_id
|
||||
FROM ais_corporate
|
||||
WHERE Ais_CorporateCorporateCode = ?
|
||||
ORDER BY Ais_CorporateLastUpdate DESC";
|
||||
|
||||
// Query ke database LOG
|
||||
$qry = $this->db_log->query($sql, [$corporate_code]);
|
||||
$results = $qry->result_array();
|
||||
|
||||
if ($results) {
|
||||
foreach ($results as &$r) {
|
||||
$r['json'] = json_decode($r['json']);
|
||||
$r['response'] = json_decode($r['response']);
|
||||
}
|
||||
unset($r);
|
||||
|
||||
return $this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode([
|
||||
'status' => 'success',
|
||||
'data' => $results
|
||||
]));
|
||||
}
|
||||
|
||||
return $this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => "No data found for corporate_code: $corporate_code"
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
4338
application/controllers/ais/Masterdata.php
Normal file
4338
application/controllers/ais/Masterdata.php
Normal file
File diff suppressed because it is too large
Load Diff
3820
application/controllers/ais/Masterdata.php--011225-0909
Normal file
3820
application/controllers/ais/Masterdata.php--011225-0909
Normal file
File diff suppressed because it is too large
Load Diff
421
application/controllers/ais/Packet.php
Normal file
421
application/controllers/ais/Packet.php
Normal file
@@ -0,0 +1,421 @@
|
||||
<?php
|
||||
class Packet extends MY_Controller
|
||||
{
|
||||
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Resultentry API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->db_log = $this->load->database("log", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
public function error_log($data, $userid = 999)
|
||||
{
|
||||
|
||||
$sql = "INSERT INTO ais_error_log (
|
||||
AisErrorLogFnName,
|
||||
AisErrorLogMessage,
|
||||
AisErrorLogQuery,
|
||||
AisErrorLogJson,
|
||||
AisErrorLogUserID,
|
||||
AisErrorLogCreated
|
||||
)
|
||||
VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db_log->query($sql, array($data['fn_name'], $data['message'], $data['query'], $data['json'], $userid));
|
||||
//echo $this->db_log->last_query();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic POST request function
|
||||
* @param string $url API endpoint URL
|
||||
* @param array $data Request payload
|
||||
* @param array $headers Custom headers (optional)
|
||||
* @return array Response from API
|
||||
*/
|
||||
public function post_request($url, $data = array(), $headers = array())
|
||||
{
|
||||
// Default headers
|
||||
$default_headers = array(
|
||||
'Content-Type: application/json'
|
||||
);
|
||||
|
||||
// Merge custom headers with default headers
|
||||
$final_headers = array_merge($default_headers, $headers);
|
||||
|
||||
// Initialize cURL
|
||||
$ch = curl_init();
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
|
||||
// Execute cURL request
|
||||
$response = curl_exec($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$error = curl_error($ch);
|
||||
|
||||
// Close cURL
|
||||
curl_close($ch);
|
||||
|
||||
// Prepare result
|
||||
$result = array(
|
||||
'success' => false,
|
||||
'http_code' => $http_code,
|
||||
'response' => null,
|
||||
'error' => null
|
||||
);
|
||||
|
||||
if ($error) {
|
||||
$result['error'] = $error;
|
||||
} else {
|
||||
$result = json_decode($response, true);
|
||||
if ($result['status'] == 200) {
|
||||
$result['success'] = true;
|
||||
} else {
|
||||
$result['success'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function get_request($url, $headers = array())
|
||||
{
|
||||
// Retrieve configuration
|
||||
$config = $this->get_config();
|
||||
$token = $config['AisConfigAuthToken'] ?? 'default-token';
|
||||
$header_token = $config['AisConfigHeaderToken'];
|
||||
|
||||
// Default headers based on the curl command
|
||||
$default_headers = array(
|
||||
'Header-Token: ' . $header_token,
|
||||
'Authorization: Bearer ' . $token
|
||||
);
|
||||
|
||||
// Merge custom headers with default headers
|
||||
$final_headers = array_merge($default_headers, $headers);
|
||||
|
||||
// Initialize cURL
|
||||
$ch = curl_init();
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_HTTPGET, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
|
||||
// Execute cURL request
|
||||
$response = curl_exec($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$error = curl_error($ch);
|
||||
|
||||
// Close cURL
|
||||
curl_close($ch);
|
||||
|
||||
// Prepare result
|
||||
$result = array(
|
||||
'success' => false,
|
||||
'http_code' => $http_code,
|
||||
'response' => null,
|
||||
'error' => null
|
||||
);
|
||||
|
||||
if ($error) {
|
||||
$result['error'] = $error;
|
||||
} else {
|
||||
$decoded = json_decode($response, true);
|
||||
$result['response'] = $decoded;
|
||||
// Check if response is successful based on http code
|
||||
if ($http_code === 200) {
|
||||
$result['success'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function get_config()
|
||||
{
|
||||
$sql = "SELECT * FROM ais_config LIMIT 1";
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'get_config', 'message' => 'ais_config select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
exit;
|
||||
}
|
||||
$dt_config = $qry->row_array();
|
||||
return $dt_config;
|
||||
}
|
||||
|
||||
/**
|
||||
* POST request to auth API
|
||||
* @param string $username Username for authentication
|
||||
* @param string $password Password for authentication
|
||||
* @return array Response from API
|
||||
*/
|
||||
public function post_auth()
|
||||
{
|
||||
$dt_config = $this->get_config();
|
||||
$baseUrl = $dt_config['AisConfigBaseUrl'];
|
||||
$url = $baseUrl . '/api/auth/auth.php';
|
||||
$headers = array(
|
||||
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
|
||||
);
|
||||
|
||||
$username = $dt_config['AisConfigUsername'];
|
||||
$password = $dt_config['AisConfigPassword'];
|
||||
|
||||
$data = array(
|
||||
'username' => $username,
|
||||
'password' => $password
|
||||
);
|
||||
|
||||
$result = $this->post_request($url, $data, $headers);
|
||||
$sql = "INSERT INTO ais_login_log(
|
||||
AisLoginLogUsername,
|
||||
AisLoginLogPassword,
|
||||
AisLoginLogHeaderToken,
|
||||
AisLoginLogResult,
|
||||
AisLoginLogCreated
|
||||
)
|
||||
VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db_log->query($sql, array($username, $password, $dt_config['AisConfigHeaderToken'], json_encode($result)));
|
||||
|
||||
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_login_log insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
|
||||
exit;
|
||||
}
|
||||
//print_r($result);
|
||||
//exit;
|
||||
// Check if success
|
||||
if (!$result['success']) {
|
||||
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($result)), 999);
|
||||
$errors = array('status' => 'error', 'message' => 'Gagal Login');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
} else {
|
||||
// Update token
|
||||
$token = $result['data']['token'];
|
||||
;
|
||||
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
|
||||
$qry = $this->db_onedev->query($sql, array($token));
|
||||
//echo $this->db_onedev->last_query();
|
||||
//exit;
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_auth', 'message' => 'ais_config update', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
$errors = array('status' => 'error', 'message' => 'Gagal Update Token');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
|
||||
//$success = array('status' => 'success', 'message' => 'Berhasil Login', 'token' => $token);
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* POST request to jenis layanan API
|
||||
* @param array $data Array of jenis layanan data
|
||||
* @return array Response from API
|
||||
*/
|
||||
|
||||
function monitoring_packet()
|
||||
{
|
||||
$sql_base = "SELECT
|
||||
p.T_PacketID,
|
||||
p.T_PacketName AS packet_name,
|
||||
p.T_PacketType,
|
||||
p.T_PacketPrice,
|
||||
p.T_PacketSasCode AS packet_code,
|
||||
p.T_PacketStartDate,
|
||||
p.T_PacketEndDate,
|
||||
|
||||
ph.T_PriceHeaderID,
|
||||
ph.T_PriceHeaderName AS priceheader_name,
|
||||
ph.T_PriceHeaderCode AS priceheader_code,
|
||||
ph.T_PriceHeaderStartDate,
|
||||
ph.T_PriceHeaderEndDate,
|
||||
|
||||
ap.Ais_PacketStatus AS Ais_PacketStatus,
|
||||
IF(MAX(ap.Ais_PacketID) IS NULL, 'N', 'Y') AS packet_status
|
||||
FROM t_packet p
|
||||
JOIN t_priceheader ph
|
||||
ON ph.T_PriceHeaderID = p.T_PacketT_PriceHeaderID
|
||||
LEFT JOIN ".$this->db_log->database.".ais_packet ap
|
||||
ON ap.Ais_PacketT_PacketSasCode = p.T_PacketSasCode
|
||||
";
|
||||
|
||||
// Ambil parameter
|
||||
$packet_name = $this->input->get('packet_name');
|
||||
$packet_code = $this->input->get('packet_code');
|
||||
$priceheader_name = $this->input->get('priceheader_name');
|
||||
$priceheader_code = $this->input->get('priceheader_code');
|
||||
$packet_status = $this->input->get('packet_status'); // Y / N
|
||||
|
||||
// Pagination
|
||||
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
|
||||
$limit = 10;
|
||||
$offset = ($page - 1) * $limit;
|
||||
|
||||
$params = [];
|
||||
$where_clauses = [];
|
||||
|
||||
// Status packet Y/N dari ais_packet
|
||||
if ($packet_status === 'Y') {
|
||||
$where_clauses[] = "ap.Ais_PacketID IS NOT NULL";
|
||||
} elseif ($packet_status === 'N') {
|
||||
$where_clauses[] = "ap.Ais_PacketID IS NULL";
|
||||
}
|
||||
|
||||
// Filter by packet name
|
||||
if ($packet_name) {
|
||||
$where_clauses[] = "p.T_PacketName LIKE ?";
|
||||
$params[] = "%$packet_name%";
|
||||
}
|
||||
|
||||
// Filter by packet code
|
||||
if ($packet_code) {
|
||||
$where_clauses[] = "p.T_PacketSasCode LIKE ?";
|
||||
$params[] = "%$packet_code%";
|
||||
}
|
||||
|
||||
// Filter by priceheader name
|
||||
if ($priceheader_name) {
|
||||
$where_clauses[] = "ph.T_PriceHeaderName LIKE ?";
|
||||
$params[] = "%$priceheader_name%";
|
||||
}
|
||||
|
||||
// Filter by priceheader code
|
||||
if ($priceheader_code) {
|
||||
$where_clauses[] = "ph.T_PriceHeaderCode LIKE ?";
|
||||
$params[] = "%$priceheader_code%";
|
||||
}
|
||||
|
||||
// Build WHERE
|
||||
$where_sql = "";
|
||||
if (!empty($where_clauses)) {
|
||||
$where_sql = " WHERE " . implode(" AND ", $where_clauses);
|
||||
}
|
||||
|
||||
// Count total records for pagination
|
||||
// Count distinct packet ID
|
||||
$count_sql = "
|
||||
SELECT COUNT(*) AS total
|
||||
FROM (
|
||||
SELECT p.T_PacketID
|
||||
FROM t_packet p
|
||||
JOIN t_priceheader ph
|
||||
ON ph.T_PriceHeaderID = p.T_PacketT_PriceHeaderID
|
||||
LEFT JOIN ".$this->db_log->database.".ais_packet ap
|
||||
ON ap.Ais_PacketT_PacketSasCode = p.T_PacketSasCode
|
||||
$where_sql
|
||||
GROUP BY p.T_PacketID
|
||||
) AS x
|
||||
";
|
||||
|
||||
$qry_count = $this->db_onedev->query($count_sql, $params);
|
||||
$total = $qry_count->row()->total ?? 0;
|
||||
|
||||
// Main SQL
|
||||
$sql = $sql_base . $where_sql . "
|
||||
GROUP BY p.T_PacketID
|
||||
ORDER BY p.T_PacketID ASC
|
||||
LIMIT $limit OFFSET $offset";
|
||||
|
||||
$qry = $this->db_onedev->query($sql, $params);
|
||||
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring packet.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data = $qry->result_array();
|
||||
|
||||
echo json_encode([
|
||||
'status' => 'success',
|
||||
'message' => 'Berhasil mengambil data monitoring packet.',
|
||||
'data' => $data,
|
||||
'total' => $total,
|
||||
'page' => $page,
|
||||
'limit' => $limit,
|
||||
'total_page' => ceil($total / $limit)
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_json_response()
|
||||
{
|
||||
$packet_code = $this->input->get('packet_code');
|
||||
|
||||
if (empty($packet_code)) {
|
||||
return $this->output
|
||||
->set_status_header(400)
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode([
|
||||
'status' => 'error', 'message' => 'packet_code parameter is required']));
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
Ais_PacketT_PacketSasCode AS packet_code,
|
||||
Ais_PacketLastUpdated AS packet_update,
|
||||
Ais_PacketJson AS packet_json,
|
||||
Ais_PacketStatus AS status,
|
||||
Ais_PacketResponse AS packet_response
|
||||
FROM ais_packet
|
||||
WHERE Ais_PacketT_PacketSasCode = ?
|
||||
ORDER BY Ais_PacketLastUpdated DESC";
|
||||
|
||||
// Query ke database LOG
|
||||
$qry = $this->db_log->query($sql, array($packet_code));
|
||||
|
||||
$results = $qry->row_array();
|
||||
$results = $qry->result_array();
|
||||
|
||||
if ($results) {
|
||||
// Loop through each result to decode JSON
|
||||
foreach ($results as &$result) {
|
||||
$result['packet_json'] = json_decode($result['packet_json']);
|
||||
$result['packet_response'] = json_decode($result['packet_response']);
|
||||
}
|
||||
unset($result); // Unset reference to avoid side effects
|
||||
|
||||
echo json_encode(['status' => 'success', 'data' => $results]);
|
||||
} else {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Data not found for the given sas code.']);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
269
application/controllers/ais/Test.php
Normal file
269
application/controllers/ais/Test.php
Normal file
@@ -0,0 +1,269 @@
|
||||
<?php
|
||||
class Test extends MY_Controller
|
||||
{
|
||||
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Transaction API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->db_log = $this->load->database("log", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
/**
|
||||
* Generic POST request function
|
||||
* @param string $url API endpoint URL
|
||||
* @param array $data Request payload
|
||||
* @param array $headers Custom headers (optional)
|
||||
* @return array Response from API
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generic PUT request function
|
||||
* @param string $url API endpoint URL
|
||||
* @param array $data Request payload
|
||||
* @param array $headers Custom headers (optional)
|
||||
* @return array Response from API
|
||||
*/
|
||||
|
||||
/**
|
||||
* POST request to auth API
|
||||
* @param string $username Username for authentication
|
||||
* @param string $password Password for authentication
|
||||
* @return array Response from API
|
||||
*/
|
||||
public function post_auth()
|
||||
{
|
||||
$dt_config = $this->get_config();
|
||||
$baseUrl = $dt_config['AisConfigBaseUrl'];
|
||||
$url = $baseUrl.'/api/auth/auth.php';
|
||||
$headers = array(
|
||||
'Header-Token: '.$dt_config['AisConfigHeaderToken']
|
||||
);
|
||||
|
||||
$username = $dt_config['AisConfigUsername'];
|
||||
$password = $dt_config['AisConfigPassword'];
|
||||
|
||||
$data = array(
|
||||
'username' => $username,
|
||||
'password' => $password
|
||||
);
|
||||
|
||||
$result = $this->post_request($url, $data, $headers);
|
||||
$sql = "INSERT INTO ais_login_log(
|
||||
AisLoginLogUsername,
|
||||
AisLoginLogPassword,
|
||||
AisLoginLogHeaderToken,
|
||||
AisLoginLogResult,
|
||||
AisLoginLogCreated
|
||||
)
|
||||
VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db_log->query($sql, array($username,$password,$dt_config['AisConfigHeaderToken'],json_encode($result)));
|
||||
|
||||
|
||||
if(!$qry){
|
||||
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_login_log insert','query'=>$sql,'json'=>json_encode($result)),999);
|
||||
exit;
|
||||
}
|
||||
//print_r($result);
|
||||
//exit;
|
||||
// Check if success
|
||||
if(!$result['success']){
|
||||
$this->error_log(array('fn_name'=>'post_auth','message'=>'failed auth','query'=>'','json'=>json_encode($result)),999);
|
||||
$errors = array('status' => 'error','message' => 'Gagal Login');
|
||||
return $errors;
|
||||
|
||||
}else{
|
||||
// Update token
|
||||
$token = $result['data']['token'];;
|
||||
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
|
||||
$qry = $this->db_onedev->query($sql, array($token));
|
||||
//echo $this->db_onedev->last_query();
|
||||
//exit;
|
||||
if(!$qry){
|
||||
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_config update','query'=>$sql,'json'=>''),999);
|
||||
$errors = array('status' => 'error','message' => 'Gagal Update Token');
|
||||
return $errors;
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
function monitoring_test()
|
||||
{
|
||||
// SQL base
|
||||
$sql_base = "SELECT
|
||||
t.T_TestID,
|
||||
t.T_TestCode AS test_code,
|
||||
t.T_TestSasCode AS sas_code,
|
||||
t.T_TestName AS test_name,
|
||||
t.T_TestIsPrice AS is_price,
|
||||
t.T_TestIsResult AS is_result,
|
||||
t.T_TestIsActive AS test_active,
|
||||
at.Ais_TestStatus AS Ais_TestStatus,
|
||||
at.Ais_TestLastUpdate AS test_last_update,
|
||||
IF (at.Ais_TestID IS NULL, 'N', 'Y') AS test_status
|
||||
FROM t_test t
|
||||
LEFT JOIN (
|
||||
SELECT Ais_TestTestSasCode, Ais_TestStatus, Ais_TestLastUpdate, Ais_TestID
|
||||
FROM ".$this->db_log->database.".ais_test
|
||||
WHERE Ais_TestStatus = 'success'
|
||||
) at
|
||||
ON at.Ais_TestTestSasCode = t.T_TestSasCode
|
||||
";
|
||||
|
||||
// Ambil parameter
|
||||
$test_name = $this->input->get('test_name'); // TRUE for XSS filtering
|
||||
$sas_code = $this->input->get('sas_code');
|
||||
$test_code = $this->input->get('test_code');
|
||||
$test_status = $this->input->get('test_status');
|
||||
|
||||
// Pagination
|
||||
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
|
||||
$limit = 10;
|
||||
$offset = ($page - 1) * $limit;
|
||||
|
||||
$params = [];
|
||||
$where_clauses = [
|
||||
"t.T_TestIsActive = 'Y'"
|
||||
];
|
||||
|
||||
// Status filter
|
||||
if ($test_status === 'Y') {
|
||||
$where_clauses[] = "at.Ais_TestID IS NOT NULL";
|
||||
} elseif ($test_status === 'N') {
|
||||
$where_clauses[] = "at.Ais_TestID IS NULL";
|
||||
}
|
||||
|
||||
if ($test_name) {
|
||||
$where_clauses[] = "t.T_TestName LIKE ?";
|
||||
$params[] = "%$test_name%";
|
||||
}
|
||||
|
||||
if ($test_code) {
|
||||
$where_clauses[] = "t.T_TestCode LIKE ?";
|
||||
$params[] = "%$test_code%";
|
||||
}
|
||||
|
||||
if ($sas_code) {
|
||||
$where_clauses[] = "t.T_TestSasCode LIKE ?";
|
||||
$params[] = "%$sas_code%";
|
||||
}
|
||||
|
||||
$where_sql = "";
|
||||
if (!empty($where_clauses)) {
|
||||
$where_sql = " WHERE " . implode(" AND ", $where_clauses);
|
||||
}
|
||||
|
||||
// COUNT
|
||||
$count_sql = "
|
||||
SELECT COUNT(*) AS total
|
||||
FROM (
|
||||
SELECT t.T_TestID
|
||||
FROM t_test t
|
||||
LEFT JOIN (
|
||||
SELECT Ais_TestTestSasCode, Ais_TestID
|
||||
FROM ".$this->db_log->database.".ais_test
|
||||
WHERE Ais_TestStatus = 'success'
|
||||
) at
|
||||
ON at.Ais_TestTestSasCode = t.T_TestSasCode
|
||||
$where_sql
|
||||
GROUP BY t.T_TestID
|
||||
) AS x
|
||||
";
|
||||
|
||||
$qry_count = $this->db_onedev->query($count_sql, $params);
|
||||
$total = $qry_count->row()->total ?? 0;
|
||||
|
||||
// MAIN QUERY
|
||||
$sql = $sql_base . $where_sql . "
|
||||
GROUP BY t.T_TestID
|
||||
ORDER BY t.T_TestID ASC
|
||||
LIMIT $limit OFFSET $offset";
|
||||
|
||||
$qry = $this->db_onedev->query($sql, $params);
|
||||
|
||||
// if (!$qry) {
|
||||
// $this->output
|
||||
// ->set_content_type('application/json')
|
||||
// ->set_output(json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring.']));
|
||||
// return;
|
||||
// }
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Gagal mengambil data monitoring.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data = $qry->result_array();
|
||||
|
||||
echo json_encode([
|
||||
'status' => 'success',
|
||||
'message' => 'Berhasil mengambil data monitoring.',
|
||||
'data' => $data,
|
||||
'total' => $total,
|
||||
'page' => $page,
|
||||
'limit' => $limit,
|
||||
'total_page' => ceil($total / $limit)
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_json_response()
|
||||
{
|
||||
$sas_code = $this->input->get('sas_code');
|
||||
|
||||
if (empty($sas_code)) {
|
||||
return $this->output
|
||||
->set_status_header(400)
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'sas_code parameter is required'
|
||||
]));
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
Ais_TestID AS id,
|
||||
Ais_TestTestSasCode AS sas_code,
|
||||
Ais_TestJSON AS test_json,
|
||||
Ais_TestStatus AS test_status,
|
||||
Ais_TestResponse AS test_response,
|
||||
Ais_TestLastUpdate AS test_last_update
|
||||
FROM ais_test
|
||||
WHERE Ais_TestTestSasCode = ?
|
||||
ORDER BY Ais_TestLastUpdate DESC";
|
||||
|
||||
// Query ke database LOG
|
||||
$qry = $this->db_log->query($sql, [$sas_code]);
|
||||
|
||||
$results = $qry->row_array();
|
||||
$results = $qry->result_array();
|
||||
|
||||
if ($results) {
|
||||
// Loop through each result to decode JSON
|
||||
foreach ($results as &$result) {
|
||||
$result['packet_json'] = json_decode($result['packet_json']);
|
||||
$result['packet_response'] = json_decode($result['packet_response']);
|
||||
}
|
||||
unset($result); // Unset reference to avoid side effects
|
||||
|
||||
echo json_encode(['status' => 'success', 'data' => $results]);
|
||||
} else {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Data not found for the given sas code.']);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
2488
application/controllers/ais/Transaction.php
Normal file
2488
application/controllers/ais/Transaction.php
Normal file
File diff suppressed because it is too large
Load Diff
761
application/controllers/ais/Transaction.php--251125
Normal file
761
application/controllers/ais/Transaction.php--251125
Normal file
@@ -0,0 +1,761 @@
|
||||
<?php
|
||||
class Transaction extends MY_Controller
|
||||
{
|
||||
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Transaction API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->db_log = $this->load->database("log", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
public function error_log($data,$userid=999)
|
||||
{
|
||||
|
||||
$sql = "INSERT INTO ais_error_log (
|
||||
AisErrorLogFnName,
|
||||
AisErrorLogMessage,
|
||||
AisErrorLogQuery,
|
||||
AisErrorLogJson,
|
||||
AisErrorLogUserID,
|
||||
AisErrorLogCreated
|
||||
)
|
||||
VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db_log->query($sql, array($data['fn_name'],$data['message'],$data['query'],$data['json'],$userid));
|
||||
//echo $this->db_log->last_query();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic POST request function
|
||||
* @param string $url API endpoint URL
|
||||
* @param array $data Request payload
|
||||
* @param array $headers Custom headers (optional)
|
||||
* @return array Response from API
|
||||
*/
|
||||
public function post_request($url, $data = array(), $headers = array())
|
||||
{
|
||||
// Default headers
|
||||
$default_headers = array(
|
||||
'Content-Type: application/json'
|
||||
);
|
||||
|
||||
// Merge custom headers with default headers
|
||||
$final_headers = array_merge($default_headers, $headers);
|
||||
|
||||
// Initialize cURL
|
||||
$ch = curl_init();
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
|
||||
// Execute cURL request
|
||||
$response = curl_exec($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$error = curl_error($ch);
|
||||
|
||||
// Close cURL
|
||||
curl_close($ch);
|
||||
|
||||
// Prepare result
|
||||
$result = array(
|
||||
'success' => false,
|
||||
'http_code' => $http_code,
|
||||
'response' => null,
|
||||
'error' => null
|
||||
);
|
||||
|
||||
if ($error) {
|
||||
$result['error'] = $error;
|
||||
} else {
|
||||
$result = json_decode($response, true);
|
||||
$result['success'] = true;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function get_request($url, $headers = array())
|
||||
{
|
||||
// Retrieve configuration
|
||||
$config = $this->get_config();
|
||||
$token = $config['AisConfigAuthToken'] ?? 'default-token';
|
||||
$header_token = $config['AisConfigHeaderToken'];
|
||||
|
||||
// Default headers based on the curl command
|
||||
$default_headers = array(
|
||||
'Header-Token: ' . $header_token,
|
||||
'Authorization: Bearer ' . $token
|
||||
);
|
||||
|
||||
// Merge custom headers with default headers
|
||||
$final_headers = array_merge($default_headers, $headers);
|
||||
|
||||
// Initialize cURL
|
||||
$ch = curl_init();
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_HTTPGET, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $final_headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
|
||||
// Execute cURL request
|
||||
$response = curl_exec($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$error = curl_error($ch);
|
||||
|
||||
// Close cURL
|
||||
curl_close($ch);
|
||||
|
||||
// Prepare result
|
||||
$result = array(
|
||||
'success' => false,
|
||||
'http_code' => $http_code,
|
||||
'response' => null,
|
||||
'error' => null
|
||||
);
|
||||
|
||||
if ($error) {
|
||||
$result['error'] = $error;
|
||||
} else {
|
||||
$decoded = json_decode($response, true);
|
||||
$result['response'] = $decoded;
|
||||
// Check if response is successful based on http code
|
||||
if ($http_code === 200) {
|
||||
$result['success'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function get_config()
|
||||
{
|
||||
$sql = "SELECT * FROM ais_config LIMIT 1";
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
$dt_config = $qry->row_array();
|
||||
return $dt_config;
|
||||
}
|
||||
|
||||
/**
|
||||
* POST request to auth API
|
||||
* @param string $username Username for authentication
|
||||
* @param string $password Password for authentication
|
||||
* @return array Response from API
|
||||
*/
|
||||
public function post_auth()
|
||||
{
|
||||
$dt_config = $this->get_config();
|
||||
$baseUrl = $dt_config['AisConfigBaseUrl'];
|
||||
$url = $baseUrl.'/api/auth/auth.php';
|
||||
$headers = array(
|
||||
'Header-Token: '.$dt_config['AisConfigHeaderToken']
|
||||
);
|
||||
|
||||
$username = $dt_config['AisConfigUsername'];
|
||||
$password = $dt_config['AisConfigPassword'];
|
||||
|
||||
$data = array(
|
||||
'username' => $username,
|
||||
'password' => $password
|
||||
);
|
||||
|
||||
$result = $this->post_request($url, $data, $headers);
|
||||
$sql = "INSERT INTO ais_login_log(
|
||||
AisLoginLogUsername,
|
||||
AisLoginLogPassword,
|
||||
AisLoginLogHeaderToken,
|
||||
AisLoginLogResult,
|
||||
AisLoginLogCreated
|
||||
)
|
||||
VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db_log->query($sql, array($username,$password,$dt_config['AisConfigHeaderToken'],json_encode($result)));
|
||||
|
||||
|
||||
if(!$qry){
|
||||
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_login_log insert','query'=>$sql,'json'=>json_encode($result)),999);
|
||||
exit;
|
||||
}
|
||||
//print_r($result);
|
||||
//exit;
|
||||
// Check if success
|
||||
if(!$result['success']){
|
||||
$this->error_log(array('fn_name'=>'post_auth','message'=>'failed auth','query'=>'','json'=>json_encode($result)),999);
|
||||
$errors = array('status' => 'error','message' => 'Gagal Login');
|
||||
return $errors;
|
||||
|
||||
}else{
|
||||
// Update token
|
||||
$token = $result['data']['token'];;
|
||||
$sql = "UPDATE ais_config SET AisConfigAuthToken = ? WHERE AisConfigID = 1";
|
||||
$qry = $this->db_onedev->query($sql, array($token));
|
||||
//echo $this->db_onedev->last_query();
|
||||
//exit;
|
||||
if(!$qry){
|
||||
$this->error_log(array('fn_name'=>'post_auth','message'=>'ais_config update','query'=>$sql,'json'=>''),999);
|
||||
$errors = array('status' => 'error','message' => 'Gagal Update Token');
|
||||
return $errors;
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
function post_transaction($labnum='',$xdate=null)
|
||||
{
|
||||
// Auth Login
|
||||
$login = $this->post_auth();
|
||||
if (!$login['success']) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($login)), 555);
|
||||
$errors = array('status' => 'error', 'message' => 'Gagal Login');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
// Get config
|
||||
$dt_config = $this->get_config();
|
||||
$baseUrl = $dt_config['AisConfigBaseUrl'];
|
||||
$url = $baseUrl . '/api/transaction_full/transaksi.php';
|
||||
|
||||
$headers = array(
|
||||
'Header-Token: ' . $dt_config['AisConfigHeaderToken'],
|
||||
'Authorization: Bearer ' . $dt_config['AisConfigAuthToken']
|
||||
);
|
||||
|
||||
|
||||
|
||||
if($labnum == ''){
|
||||
$xdate = $xdate == null ? date('Y-m-d') : $xdate;
|
||||
}
|
||||
// Get data
|
||||
$sql = "SELECT T_OrderHeaderID,
|
||||
T_OrderHeaderTotal as Total,
|
||||
T_OrderHeaderLabNumber as RegID,
|
||||
Mgm_McuM_BranchID as mgm_mcu_m_branch_id,
|
||||
M_PatientNoReg as MEDRECID,
|
||||
T_OrderHeaderDate as Tanggal,
|
||||
T_OrderHeaderDate as PulangTanggal,
|
||||
IF(Mgm_McuM_BranchID = 100,'',CorporateCode) as PerusahaanID,
|
||||
IF(Mgm_McuM_BranchID = 100,'',CorporateCode) as AsuransiID,
|
||||
T_PriceHeaderCode as GroupTarifID,
|
||||
M_PatientName as Nama,
|
||||
M_PatientIdentifierValue as NIK,
|
||||
DATE_FORMAT(M_PatientDOB, '%Y-%m-%d %H:%i:%s') as TglLahir,
|
||||
IF(M_PatientGender = 'male','L','P') as JnsKelamin,
|
||||
'' as NomorPolis,
|
||||
'' as NomerJaminan,
|
||||
'2' as JenisRegID,
|
||||
IF(Mgm_McuM_BranchID = 100,0,1) as JenisPasienID,
|
||||
'LAB-WESTERINDO-01' as DepartemenID,
|
||||
'Y' as Pulang,
|
||||
'Y' as BolehPulang,
|
||||
'' as Catatan,
|
||||
'Y' as Verified,
|
||||
'LABKLINIK' as KelasID,
|
||||
M_UserEmail as LoginBuat,
|
||||
T_OrderHeaderCreated as TanggalBuat,
|
||||
branch_order.M_BranchAis_branch_code as BranchCode,
|
||||
CorporateTypeais_pillar_code as PillarCode,
|
||||
'4569' as SiteCenterCode,
|
||||
M_UserEmail as VerifiedBy,
|
||||
T_OrderHeaderCreated as VerifiedDate,
|
||||
'' as TrxLayanan,
|
||||
'' as TrxItem,
|
||||
'' as TrxItemReturn,
|
||||
'' as RegpasNominal,
|
||||
'' as Trxtt,
|
||||
'' as TrxBayar,
|
||||
'' as TrxLain,
|
||||
'' as PaketDispenser
|
||||
FROM t_orderheader
|
||||
JOIN m_branch branch_order ON branch_order.M_BranchID = T_OrderHeaderM_BranchID
|
||||
JOIN m_patient ON M_PatientID = T_OrderHeaderM_PatientID
|
||||
JOIN corporate ON CorporateID = T_OrderHeaderCorporateID
|
||||
JOIN corporate_type ON CorporateTypeID = CorporateTypeID
|
||||
JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID -- AND Mgm_McuID = 1566
|
||||
JOIN t_priceheader ON Mgm_McuT_PriceHeaderID = T_PriceHeaderID
|
||||
JOIN m_user ON T_OrderHeaderCreatedUserID = M_UserID
|
||||
LEFT JOIN cpone_log.ais_transaction ON Ais_TransactionOrderHeaderLabNumber = T_OrderHeaderLabNumber AND
|
||||
Ais_TransactionStatus = 'success'
|
||||
WHERE T_OrderHeaderIsActive = 'Y' AND
|
||||
T_OrderHeaderLabNumber = ? AND
|
||||
Ais_TransactionID IS NULL
|
||||
GROUP BY T_OrderHeaderID
|
||||
LIMIT 100";
|
||||
$qry = $this->db_onedev->query($sql, array($labnum));
|
||||
//echo $this->db_onedev->last_query();
|
||||
//exit;
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderheader select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
exit;
|
||||
}
|
||||
$raw_data = $qry->result_array();
|
||||
|
||||
$data = array();
|
||||
foreach ($raw_data as $key => $row) {
|
||||
|
||||
$row['TrxLayanan'] = [];
|
||||
$row['TrxItem'] = [];
|
||||
$row['TrxItemReturn'] = [];
|
||||
$row['RegpasNominal'] = [];
|
||||
$row['Trxtt'] = null;
|
||||
$row['TrxBayar'] = [];
|
||||
$row['TrxLain'] = null;
|
||||
$row['PaketDispenser'] = null;
|
||||
|
||||
$layanan = [];
|
||||
$sql = "SELECT * FROM (
|
||||
SELECT T_OrderDetailID as TrxLayananID,
|
||||
case
|
||||
when Nat_GroupID = 1 then '1100'
|
||||
when Nat_GroupID = 2 then '1200'
|
||||
when Nat_GroupID = 3 then '1200'
|
||||
when Nat_GroupID = 4 then '1303'
|
||||
end as ProfitCostCenterCode,
|
||||
'' as TrxDepartemenID,
|
||||
T_OrderDetailCreated as TanggalBuat,
|
||||
T_OrderDetailT_TestSasCode as LayananID,
|
||||
T_OrderDetailT_TestName as LayananName,
|
||||
doctorlab.M_DoctorCode as DokterID,
|
||||
0 as ShareRS,
|
||||
0 as ShareDokter,
|
||||
0 as ShareExternal,
|
||||
0 as ShareLain2,
|
||||
'' as PihakExternal,
|
||||
'' as PihakLain2,
|
||||
'Percentage' as ShareTipe,
|
||||
T_OrderDetailPrice as Harga,
|
||||
1 as Jumlah,
|
||||
1 as Rate,
|
||||
'N' as FOC,
|
||||
T_OrderDetailDiscTotal as Diskon,
|
||||
'Absolute' as TipeDiskon,
|
||||
'' as DepartemenID,
|
||||
IF(Mgm_McuM_BranchID = 100,T_OrderDetailTotal,0) as DitanggungPasien,
|
||||
IF(Mgm_McuM_BranchID = 100,0,T_OrderDetailTotal) as DitanggungPenjamin,
|
||||
0 as MarkUpCito,
|
||||
'N' as Cito,
|
||||
T_PacketSasCode as PaketID,
|
||||
'LABKLINIK' as KelasID,
|
||||
'' as TrxLayananDetail,
|
||||
'Y' as Tagihkan
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_TestID = T_OrderDetailT_TestID AND T_TestIsActive = 'Y'
|
||||
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
|
||||
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y'
|
||||
JOIN t_orderdetailorder ON T_OrderDetailT_OrderDetailOrderID = T_OrderDetailOrderID AND
|
||||
T_OrderDetailOrderIsPacket = 'Y' AND T_OrderDetailOrderIsActive = 'Y'
|
||||
JOIN t_packet ON T_OrderDetailOrderT_PacketID = T_PacketID
|
||||
JOIN t_packetdetail ON T_PacketDetailT_PacketID = T_PacketID AND T_PacketDetailT_TestID = T_OrderDetailT_TestID AND
|
||||
T_PacketDetailIsActive = 'Y'
|
||||
JOIN t_orderheader ON T_OrderHeaderID = T_OrderDetailOrderT_OrderHeaderID
|
||||
JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
|
||||
JOIN m_doctor doctorlab ON T_OrderHeaderPjM_DoctorID = M_DoctorID
|
||||
LEFT JOIN f_payment ON T_OrderHeaderID = F_PaymentT_OrderHeaderID AND F_PaymentIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = ? AND
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
UNION
|
||||
SELECT T_OrderDetailID as TrxLayananID,
|
||||
Nat_GroupID as ProfitCostCenterCode,
|
||||
'' as TrxDepartemenID,
|
||||
T_OrderDetailCreated as TanggalBuat,
|
||||
T_OrderDetailT_TestSasCode as LayananID,
|
||||
T_OrderDetailT_TestName as LayananName,
|
||||
doctorlab.M_DoctorCode as DokterID,
|
||||
0 as ShareRS,
|
||||
0 as ShareDokter,
|
||||
0 as ShareExternal,
|
||||
0 as ShareLain2,
|
||||
'' as PihakExternal,
|
||||
'' as PihakLain2,
|
||||
'Percentage' as ShareTipe,
|
||||
T_OrderDetailPrice as Harga,
|
||||
1 as Jumlah,
|
||||
1 as Rate,
|
||||
'N' as FOC,
|
||||
T_OrderDetailDiscTotal as Diskon,
|
||||
'Absolute' as TipeDiskon,
|
||||
'' as DepartemenID,
|
||||
IF(Mgm_McuM_BranchID = 100,T_OrderDetailTotal,0) as DitanggungPasien,
|
||||
IF(Mgm_McuM_BranchID = 100,0,T_OrderDetailTotal) as DitanggungPenjamin,
|
||||
0 as MarkUpCito,
|
||||
'N' as Cito,
|
||||
'' as PaketID,
|
||||
'LABKLINIK' as KelasID,
|
||||
NULL as TrxLayananDetail,
|
||||
'Y' as Tagihkan
|
||||
FROM `t_orderdetailorder`
|
||||
JOIN t_orderdetail ON T_OrderdetailT_OrderHeaderID = T_OrderDetailOrderT_OrderHeaderID AND
|
||||
T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderDetailOrderID = T_OrderDetailOrderID
|
||||
JOIN t_test ON T_TestID = T_OrderDetailT_TestID AND T_TestIsActive = 'Y'
|
||||
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
|
||||
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y'
|
||||
JOIN t_orderheader ON T_OrderHeaderID = T_OrderDetailOrderT_OrderHeaderID
|
||||
JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
|
||||
JOIN m_doctor doctorlab ON T_OrderHeaderPjM_DoctorID = M_DoctorID
|
||||
LEFT JOIN f_payment ON T_OrderHeaderID = F_PaymentT_OrderHeaderID AND F_PaymentIsActive = 'Y'
|
||||
WHERE `T_OrderDetailOrderT_OrderHeaderID` = ? AND `T_OrderDetailOrderIsPacket` = 'N' AND
|
||||
T_OrderDetailOrderIsActive = 'Y'
|
||||
) AS t_orderdetailorder";
|
||||
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID'],$row['T_OrderHeaderID']));
|
||||
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
exit;
|
||||
}
|
||||
$total_layanan_debug = 0;
|
||||
$layanan = $qry->result_array();
|
||||
$raw_data[$key]['TrxLayanan'] = [];
|
||||
if(count($layanan) > 0){
|
||||
foreach($layanan as $key_layanan => $row_layanan){
|
||||
$total_layanan_debug += $row_layanan['Harga'];
|
||||
$layanan[$key_layanan]['TrxLayananDetail'] = [];
|
||||
$sql = "SELECT M_DoctorCode, M_DoctorID
|
||||
FROM `so_resultentry`
|
||||
JOIN t_orderdetail ON ? = So_ResultEntryT_OrderDetailID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN m_doctor ON M_DoctorID = So_ResultEntryM_DoctorID AND M_DoctorIsActive = 'Y'
|
||||
WHERE `So_ResultEntryT_OrderHeaderID` = ? AND
|
||||
`So_ResultEntryIsActive` = 'Y' AND `So_ResultEntryM_DoctorID` > '0'
|
||||
LIMIT 1
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql, array($row_layanan['TrxLayananID'],$row['T_OrderHeaderID']));
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'so_resultentry select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
exit;
|
||||
}
|
||||
$get_resultentry = $qry->result_array();
|
||||
if (count($get_resultentry) > 0) {
|
||||
$row_layanan['DokterID'] = $get_resultentry[0]['M_DoctorCode'];
|
||||
}
|
||||
$raw_data[$key]['TrxLayanan'][] = $row_layanan;
|
||||
}
|
||||
}
|
||||
|
||||
$regpasnominal = [];
|
||||
$jumlah_layanan_lab = 0;
|
||||
$sql = "SELECT IFNULL(SUM(T_OrderDetailTotal),0) as total_layanan_lab
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsActive = 'Y'
|
||||
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
|
||||
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y' AND
|
||||
Nat_GroupID = 1
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y'
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
|
||||
//echo $this->db_onedev->last_query();
|
||||
//exit;
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail lab select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
exit;
|
||||
}
|
||||
|
||||
$get_layanan_lab = $qry->row_array();
|
||||
$jumlah_layanan_lab = $get_layanan_lab['total_layanan_lab'];
|
||||
|
||||
$jumlah_layanan_radiologi = 0;
|
||||
$sql = "SELECT IFNULL(SUM(T_OrderDetailTotal),0) as total_layanan_radiologi
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsActive = 'Y'
|
||||
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
|
||||
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y' AND
|
||||
Nat_GroupID = 3
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y'
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail radiologi select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
exit;
|
||||
}
|
||||
$get_layanan_radiologi = $qry->row_array();
|
||||
$jumlah_layanan_radiologi = $get_layanan_radiologi['total_layanan_radiologi'];
|
||||
|
||||
$jumlah_layanan_lain = 0;
|
||||
$sql = "SELECT IFNULL(SUM(T_OrderDetailTotal),0) as total_layanan_lain
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsActive = 'Y'
|
||||
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
|
||||
JOIN nat_group ON Nat_GroupID = Nat_TestNat_GroupID AND Nat_GroupIsActive = 'Y' AND
|
||||
Nat_GroupID IN (2,4)
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y'
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail lain select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$get_layanan_lain = $qry->row_array();
|
||||
$jumlah_layanan_lain = $get_layanan_lain['total_layanan_lain'];
|
||||
|
||||
$total_layanan = 0;
|
||||
$sql = "SELECT SUM(T_OrderDetailTotal) as total_layanan, Mgm_McuM_BranchID as BranchID
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN mgm_mcu ON T_OrderHeaderMgm_McuID = Mgm_McuID
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ? AND T_OrderDetailIsActive = 'Y'
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderdetail total layanan select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
exit;
|
||||
}
|
||||
$total_layanan = $qry->row_array();
|
||||
$total_layanan = $total_layanan['total_layanan'];
|
||||
|
||||
|
||||
$total_bayar = 0;
|
||||
$sql = "SELECT F_PaymentTotal as total
|
||||
FROM f_payment
|
||||
WHERE F_PaymentT_OrderHeaderID = ? AND F_PaymentIsActive = 'Y'
|
||||
";
|
||||
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'f_payment select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
exit;
|
||||
}
|
||||
|
||||
$get_total_bayar = $qry->result_array();
|
||||
if (count($get_total_bayar) > 0) {
|
||||
foreach($get_total_bayar as $key_total_bayar => $row_total_bayar){
|
||||
$total_bayar += $row_total_bayar['total'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$mgm_mcu_m_branch_id = $row['mgm_mcu_m_branch_id'];
|
||||
|
||||
$total_ditanggung_pasien = $mgm_mcu_m_branch_id == 100 ? $total_layanan : 0;
|
||||
$total_ditanggung_penjamin = $mgm_mcu_m_branch_id == 100 ? 0 : $total_layanan;
|
||||
|
||||
$regpasnominal = array(
|
||||
"BiayaParamedik" => "0.00",
|
||||
"ParamedikDitanggungPasien" => "0.00",
|
||||
"ParamedikDitanggungPenjamin" => "0.00",
|
||||
"BiayaAdministrasi" => "0",
|
||||
"AdmDitanggungPasien" => "0.00",
|
||||
"AdmDitanggungPenjamin" => "0.00",
|
||||
"BiayaMaterai" => "0.00",
|
||||
"BiayaMateraiDitanggungPasien" => "0.00",
|
||||
"BiayaMateraiDitanggungPenjamin" => "0.00",
|
||||
"JumlahLayanan" => $jumlah_layanan_lain,
|
||||
"JumlahLayananRadiologi" => $jumlah_layanan_radiologi,
|
||||
"JumlahLayananLaboratorium" => $jumlah_layanan_lab,
|
||||
"JumlahItem" => 0,
|
||||
"JumlahItemRetur" => 0,
|
||||
"JumlahTT" => "0.00",
|
||||
"JumlahBiayaLain" => "0.00",
|
||||
"JumlahBayar" => $total_bayar,
|
||||
"TipeDiskonGlobal" => "Absolute",
|
||||
"DiskonGlobal" => "0.00",
|
||||
"TotalDitanggungPasien" => $total_ditanggung_pasien,
|
||||
"TotalDitanggungPenjamin" => $total_ditanggung_penjamin
|
||||
);
|
||||
|
||||
$raw_data[$key]['RegpasNominal'] = array(
|
||||
$regpasnominal
|
||||
);
|
||||
|
||||
//echo $total_bayar;
|
||||
$raw_data[$key]['TrxBayar'] = null;
|
||||
if($total_bayar > 0){
|
||||
$sql = "SELECT M_PatientNoReg as MEDRECID,
|
||||
F_PaymentDetailID as BayarID,
|
||||
IFNULL(F_PaymentDetailAmount,0) as Jumlah,
|
||||
F_PaymentDetailCreated as Tanggal,
|
||||
'Pelunasan' as JenisBayarID,
|
||||
CONCAT(F_PaymentNumber,'.',F_PaymentDetailID) as KwitansiID,
|
||||
CONCAT(F_PaymentDetailM_PaymentTypeID,F_PaymentDetailM_BankAccountID) as TipeBayarID,
|
||||
'N' as Dibatalkan
|
||||
FROM f_paymentdetail
|
||||
JOIN f_payment ON F_PaymentDetailF_PaymentID = F_PaymentID AND F_PaymentIsActive = 'Y'
|
||||
JOIN t_orderheader ON F_PaymentT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND M_PatientIsActive = 'Y'
|
||||
WHERE
|
||||
F_PaymentT_OrderHeaderID = ? AND F_PaymentDetailIsActive = 'Y'
|
||||
GROUP BY F_PaymentDetailID";
|
||||
$qry = $this->db_onedev->query($sql, array($row['T_OrderHeaderID']));
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'f_payment select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
exit;
|
||||
}
|
||||
//echo $this->db_onedev->last_query();
|
||||
//exit;
|
||||
$bayar = $qry->result_array();
|
||||
|
||||
$raw_data[$key]['TrxBayar'] = $bayar;
|
||||
}
|
||||
|
||||
$raw_data[$key]['Trxtt'] = null;
|
||||
$raw_data[$key]['TrxLain'] = null;
|
||||
$raw_data[$key]['PaketDispenser'] = null;
|
||||
$errors = [];
|
||||
|
||||
//echo json_encode($raw_data[$key]);
|
||||
//exit;
|
||||
$result = $this->post_request($url, $raw_data[$key], $headers);
|
||||
|
||||
|
||||
if ($result['status'] == '400') {
|
||||
$sql = "INSERT INTO ais_transaction(
|
||||
Ais_TransactionOrderHeaderLabNumber,
|
||||
Ais_TransactionJson,
|
||||
Ais_TransactionStatus,
|
||||
Ais_TransactionResponse,
|
||||
Ais_TransactionUrl,
|
||||
Ais_TransactionUserID,
|
||||
Ais_TransactionCreated
|
||||
)
|
||||
VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db_log->query($sql, array(
|
||||
$row['RegID'],
|
||||
json_encode($raw_data[$key]),
|
||||
'error',
|
||||
json_encode($result),
|
||||
$url,
|
||||
555
|
||||
));
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'ais_transaction insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
|
||||
exit;
|
||||
}
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'transaction insert', 'query' => $this->db_onedev->last_query(), 'json' => json_encode($result)), 999);
|
||||
|
||||
$errors[] = array('RegID' => $row['RegID'], 'error' => $result['message']);
|
||||
|
||||
|
||||
}else{
|
||||
//echo 'insert ais_transaction';
|
||||
$sql = "INSERT INTO ais_transaction(
|
||||
Ais_TransactionOrderHeaderLabNumber,
|
||||
Ais_TransactionJson,
|
||||
Ais_TransactionStatus,
|
||||
Ais_TransactionResponse,
|
||||
Ais_TransactionUrl,
|
||||
Ais_TransactionUserID,
|
||||
Ais_TransactionCreated
|
||||
)
|
||||
VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db_log->query($sql, array(
|
||||
$row['RegID'],
|
||||
json_encode($raw_data[$key]),
|
||||
'success',
|
||||
json_encode($result),
|
||||
$url,
|
||||
555
|
||||
));
|
||||
|
||||
if (!$qry) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'ais_transaction insert', 'query' => $this->db_log->last_query(), 'json' => json_encode($result)), 999);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(count($errors) > 0){
|
||||
$success = array('status' => 'error', 'message' => 'Gagal Post Transaction', 'errors' => $errors);
|
||||
echo json_encode($success);
|
||||
exit;
|
||||
}else{
|
||||
$success = array('status' => 'success', 'message' => 'Berhasil Post Transaction');
|
||||
echo json_encode($success);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function get_transaction()
|
||||
{
|
||||
// Get id from query parameter
|
||||
$id = $this->input->get('id');
|
||||
|
||||
if (empty($id)) {
|
||||
$errors = array('status' => 'error', 'message' => 'ID parameter is required');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
|
||||
$login = $this->post_auth();
|
||||
if (!$login['success']) {
|
||||
$this->error_log(array('fn_name' => 'get_transaction_auth', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($login)), 999);
|
||||
$errors = array('status' => 'error', 'message' => 'Gagal Login');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
|
||||
$dt_config = $this->get_config();
|
||||
$baseUrl = $dt_config['AisConfigBaseUrl'];
|
||||
$url = $baseUrl . '/api/transaksi?id=' . $id;
|
||||
|
||||
|
||||
$result = $this->get_request($url);
|
||||
if (!$result['success']) {
|
||||
$this->error_log(array('fn_name' => 'get_transaction', 'message' => 'failed get transaction', 'query' => '', 'json' => json_encode($result)), 999);
|
||||
$errors = array('status' => 'error', 'message' => 'Gagal Get Transaction');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data = $result['response']['data'] ?? null;
|
||||
// $data = json_encode($data);
|
||||
$success = array('status' => 'success', 'message' => 'Berhasil Get Transaction', 'data' => $data);
|
||||
echo json_encode($success);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1370
application/controllers/ais/Transaction.php--25112501
Normal file
1370
application/controllers/ais/Transaction.php--25112501
Normal file
File diff suppressed because it is too large
Load Diff
2786
application/controllers/ais/Transactionv2.php
Normal file
2786
application/controllers/ais/Transactionv2.php
Normal file
File diff suppressed because it is too large
Load Diff
124
application/controllers/ais/example.http
Normal file
124
application/controllers/ais/example.http
Normal file
@@ -0,0 +1,124 @@
|
||||
@baseUrl = https://cpone.aplikasi.web.id/one-api/ais
|
||||
# @baseUrl = http://his.sismedika.online:4081/westerindo_ais
|
||||
|
||||
|
||||
POST {{baseUrl}}/transaction/post_transaction_by_labnumber
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"labnumber": "H2509010001"
|
||||
}
|
||||
|
||||
### POST Re Post Transaction by Labnumber
|
||||
POST {{baseUrl}}/transaction/re_post_transaction_by_labnumber
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"labnumber": "H2509010001"
|
||||
}
|
||||
|
||||
### POST Medrec by No Reg
|
||||
POST {{baseUrl}}/masterdata/post_medrec_by_noreg
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"noreg": "CP2406200033"
|
||||
}
|
||||
|
||||
|
||||
|
||||
### GET Medrec by No Reg
|
||||
POST {{baseUrl}}/masterdata/get_medrec_by_noreg
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"noreg": "CP2406200033"
|
||||
}
|
||||
|
||||
|
||||
### GET Perusahaan by Code
|
||||
POST {{baseUrl}}/masterdata/get_perusahaan_by_code
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"corporate_code": "CP0029"
|
||||
}
|
||||
|
||||
### GET Doctor by Code
|
||||
POST {{baseUrl}}/masterdata/get_doctor_by_code
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"doctor_code": "D240700001"
|
||||
}
|
||||
|
||||
### POST Doctor by Code
|
||||
POST {{baseUrl}}/masterdata/post_doctor_by_code
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"doctor_code": "D240700001"
|
||||
}
|
||||
|
||||
### POST Jenis Layanan
|
||||
POST {{baseUrl}}/post_jenis_layanan
|
||||
|
||||
### GET Jenis Perusahaan
|
||||
GET {{baseUrl}}/get_jenis_perusahaan?id=1
|
||||
|
||||
### POST Jenis Perusahaan
|
||||
POST {{baseUrl}}/post_jenis_perusahaan
|
||||
|
||||
### POST Perusahaan
|
||||
POST {{baseUrl}}/post_perusahaan
|
||||
|
||||
### GET Perusahaan
|
||||
GET {{baseUrl}}/get_perusahaan
|
||||
|
||||
### POST Perusahaan Bulk
|
||||
POST {{baseUrl}}/post_perusahaan_bulk
|
||||
|
||||
|
||||
### GET Jenis Layanan
|
||||
GET {{baseUrl}}/get_jenislayanan
|
||||
|
||||
### Post Jenis Layanan
|
||||
Post {{baseUrl}}/post_jenislayanan
|
||||
|
||||
|
||||
### GET Layanan
|
||||
GET {{baseUrl}}/get_layanan
|
||||
|
||||
### Post Layanan
|
||||
POST {{baseUrl}}/post_layanan
|
||||
|
||||
|
||||
### GET Group Layanan
|
||||
GET {{baseUrl}}/get_grouplayanan
|
||||
|
||||
### Post Group Layanan
|
||||
POST {{baseUrl}}/post_grouplayanan
|
||||
|
||||
### GET Departemen
|
||||
GET {{baseUrl}}/get_departemen
|
||||
|
||||
### Post Departement
|
||||
POST {{baseUrl}}/post_departemen
|
||||
|
||||
### GET Departement
|
||||
GET {{baseUrl}}/get_medrec
|
||||
|
||||
### Post Departement
|
||||
POST {{baseUrl}}/post_medrec
|
||||
|
||||
### GET Transaction
|
||||
GET {{baseUrl}}/get_transaction
|
||||
|
||||
### Post Transaction
|
||||
POST {{baseUrl}}/post_transaction
|
||||
|
||||
### Post Transaction
|
||||
POST {{baseUrl}}/post_transaction?date=2024-02-08&limit=1&offset=0
|
||||
|
||||
### GET Payment
|
||||
GET {{baseUrl}}/get_payment?id=6
|
||||
208
application/controllers/antrian/AntrianCounterDedicated.php
Normal file
208
application/controllers/antrian/AntrianCounterDedicated.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
class AntrianCounterDedicated extends MY_Controller
|
||||
{
|
||||
var $db_antrione;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_antrione = $this->load->database("antrione", true);
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo "Api: Training Playground";
|
||||
}
|
||||
|
||||
function list_location()
|
||||
{
|
||||
try {
|
||||
$sql = "SELECT * FROM location WHERE locationIsActive = 'Y'";
|
||||
$qry = $this->db_antrione->query($sql);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$data = $qry->result_array();
|
||||
$result = array(
|
||||
"records" => $data,
|
||||
"qry" => $last_qry
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function list_counter()
|
||||
{
|
||||
try {
|
||||
// $prm = $this->sys_input;
|
||||
// $locationID = array();
|
||||
// if (isset($prm['locationID'])) {
|
||||
// $locationID = trim($prm["locationID"]);
|
||||
// }
|
||||
$sql = "SELECT counter.* , locationID, locationName,
|
||||
fn_get_serviceID(counterID,counterIsDedicated) as serviceID
|
||||
FROM counter
|
||||
JOIN location ON counterLocationID = locationID
|
||||
AND locationIsActive = 'Y'
|
||||
WHERE counterIsActive = 'Y';
|
||||
";
|
||||
// $sql = "SELECT *
|
||||
// FROM counter
|
||||
// WHERE counterIsActive = 'Y'
|
||||
// AND counterLocationID = ?";
|
||||
$qry = $this->db_antrione->query($sql, []);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$data = $qry->result_array();
|
||||
$result = array(
|
||||
"records" => $data,
|
||||
"qry" => $last_qry
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function get_antrian()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
$arrCounter = array();
|
||||
if (isset($prm['arr_counter'])) {
|
||||
array_push($prm['arr_counter'], 0);
|
||||
$arrCounter = implode(",", $prm["arr_counter"]);
|
||||
}
|
||||
|
||||
$sqlNotServed = "SELECT queueID,
|
||||
statusID, IFNULL(queueNumber,'') as queueNumber,
|
||||
IFNULL(queueSkipDate, 'NEW') as skipQueue,
|
||||
( CASE
|
||||
WHEN statusID = 1 THEN 1
|
||||
END ) as order_status
|
||||
FROM queue
|
||||
JOIN service
|
||||
ON serviceID = queueServiceID
|
||||
AND serviceIsActive = 'Y'
|
||||
AND serviceIsConsultDoctor = 'N'
|
||||
JOIN status
|
||||
ON statusID = queueStatusID
|
||||
WHERE queueIsActive = 'Y'
|
||||
AND statusID IN (1)
|
||||
AND queueLocationID IN (SELECT GROUP_CONCAT(counterLocationID) FROM counter WHERE counterID IN ($arrCounter))
|
||||
AND queueCounterID IN ($arrCounter)
|
||||
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
|
||||
ORDER BY IFNULL(queueSkipDate, queueCreated)";
|
||||
$qryNotServed = $this->db_antrione->query($sqlNotServed, []);
|
||||
$last_qry_not = $this->db_antrione->last_query();
|
||||
if (!$qryNotServed) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry_not
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$notServed = $qryNotServed->result_array();
|
||||
|
||||
$sqlCall = "SELECT queueID,
|
||||
statusID, IFNULL(queueNumber,'') as queueNumber,
|
||||
queueCounterID,
|
||||
counterCode,
|
||||
counterID,
|
||||
( CASE
|
||||
WHEN statusID = 2 THEN 1
|
||||
WHEN statusID = 5 THEN 2
|
||||
END ) as order_status
|
||||
FROM queue
|
||||
JOIN service
|
||||
ON serviceID = queueServiceID
|
||||
AND serviceIsActive = 'Y'
|
||||
AND serviceIsConsultDoctor = 'N'
|
||||
JOIN status
|
||||
ON statusID = queueStatusID
|
||||
JOIN counter ON queueCounterID = counterID
|
||||
WHERE queueIsActive = 'Y'
|
||||
AND statusID IN (2, 5)
|
||||
AND queueCounterID IN ($arrCounter)
|
||||
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
|
||||
ORDER BY order_status, queueCreated asc";
|
||||
$qryCall = $this->db_antrione->query($sqlCall, []);
|
||||
$last_qry_served = $this->db_antrione->last_query();
|
||||
if (!$qryCall) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry_served
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$call = $qryCall->result_array();
|
||||
|
||||
$sqlServed = "SELECT queueID,
|
||||
statusID, IFNULL(queueNumber,'') as queueNumber,
|
||||
queueCounterID,
|
||||
counterCode,
|
||||
counterID,
|
||||
( CASE
|
||||
WHEN statusID = 3 THEN 1
|
||||
END ) as order_status
|
||||
FROM queue
|
||||
JOIN service
|
||||
ON serviceID = queueServiceID
|
||||
AND serviceIsActive = 'Y'
|
||||
AND serviceIsConsultDoctor = 'N'
|
||||
JOIN status
|
||||
ON statusID = queueStatusID
|
||||
JOIN counter ON queueCounterID = counterID
|
||||
WHERE queueIsActive = 'Y'
|
||||
AND statusID IN (3)
|
||||
AND queueCounterID IN ($arrCounter)
|
||||
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
|
||||
ORDER BY order_status, queueCreated asc";
|
||||
$qryServed = $this->db_antrione->query($sqlServed, []);
|
||||
$last_qry_call = $this->db_antrione->last_query();
|
||||
if (!$qryServed) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry_call
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$served = $qryServed->result_array();
|
||||
$data = [];
|
||||
$data["served"] = $served;
|
||||
$data['not_served'] = $notServed;
|
||||
$data['call'] = $call;
|
||||
$data['qry_call'] = $last_qry_call;
|
||||
$data['qry_not_served'] = $last_qry_not;
|
||||
$data['qry_serve'] = $last_qry_served;
|
||||
$result = array(
|
||||
$data
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
191
application/controllers/antrian/Apiclinic.php
Normal file
191
application/controllers/antrian/Apiclinic.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
class Apiclinic extends MY_Controller
|
||||
{
|
||||
var $db_antrione;
|
||||
var $load;
|
||||
var $endpoint;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_antrione = $this->load->database("antrione", true);
|
||||
$this->endpoint = "http://10.9.10.38:8787/";
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "API token clinic";
|
||||
}
|
||||
|
||||
function refresh_token()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$login = $prm["login"];
|
||||
$password_hash = $prm["password_hash"];
|
||||
$tenant_code = $prm["tenant_code"];
|
||||
|
||||
$url = $this->endpoint . "api/ibl/login";
|
||||
$param = [
|
||||
"login" => $login,
|
||||
"password_hash" => $password_hash,
|
||||
"tenant_code" => $tenant_code
|
||||
];
|
||||
|
||||
$resp = $this->post_xmod($url, json_encode($param));
|
||||
|
||||
$jresp = json_decode($resp, true);
|
||||
if ($jresp["token"] != "") {
|
||||
$this->insert_or_update($jresp);
|
||||
} else {
|
||||
echo $resp;
|
||||
}
|
||||
}
|
||||
|
||||
public function post_xmod($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json"
|
||||
]);
|
||||
$result = curl_exec($ch);
|
||||
|
||||
if (curl_error($ch) != "") {
|
||||
return "ERROR CLINIC API [$url] : " . curl_error($ch) . "\n";
|
||||
}
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function insert_or_update($data)
|
||||
{
|
||||
$expires_iso = $data["expires_at"];
|
||||
$expires = date("Y-m-d H:i:s", strtotime($expires_iso));
|
||||
$user_id = $data['user']['id'];
|
||||
$username = $data['user']['login'];
|
||||
$redirect_to = $data['redirect_to'];
|
||||
$token = $data['token'];
|
||||
|
||||
if (!$user_id) {
|
||||
echo json_encode([
|
||||
"status" => "error",
|
||||
"message" => "ClinicLoginIdUser wajib diisi"
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
# cek apakah token sudah ada
|
||||
$chek = "SELECT ClinicLoginID
|
||||
FROM clinic_login
|
||||
WHERE ClinicLoginIdUser = ?
|
||||
LIMIT 1";
|
||||
$query_check = $this->db_antrione->query($chek, [$user_id]);
|
||||
if (!$query_check) {
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db("cek token clinic error", $this->db_antrione);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data = $query_check->result_array();
|
||||
|
||||
if (count($data) > 0) {
|
||||
# UPDATE
|
||||
|
||||
$sql_update = "UPDATE clinic_login
|
||||
SET
|
||||
ClinicLoginExpires = ?,
|
||||
ClinicLoginRedirectTo = ?,
|
||||
ClinicLoginIdUser = ?,
|
||||
ClinicLoginUsername = ?,
|
||||
ClinicLoginToken = ?,
|
||||
ClinicLoginLastUpdated = NOW()
|
||||
WHERE ClinicLoginIdUser = ?";
|
||||
$qry_update = $this->db_antrione->query($sql_update, [
|
||||
$expires,
|
||||
$redirect_to,
|
||||
$user_id,
|
||||
$username,
|
||||
$token,
|
||||
$user_id
|
||||
]);
|
||||
if (!$qry_update) {
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db("Error update clinic tokne", $this->db_antrione);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"message" => "Token berhasil diupdate"
|
||||
]);
|
||||
} else {
|
||||
|
||||
# INSERT
|
||||
$sql_insert = "INSERT INTO clinic_login
|
||||
(
|
||||
ClinicLoginExpires,
|
||||
ClinicLoginRedirectTo,
|
||||
ClinicLoginIdUser,
|
||||
ClinicLoginUsername,
|
||||
ClinicLoginToken,
|
||||
ClinicLoginCreated
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?,NOW())";
|
||||
$qry_update = $this->db_antrione->query($sql_insert, [
|
||||
$expires,
|
||||
$redirect_to,
|
||||
$user_id,
|
||||
$username,
|
||||
$token,
|
||||
]);
|
||||
if (!$qry_update) {
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db("Error insert clinic tokne", $this->db_antrione);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"message" => "Token berhasil disimpan"
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function password_hash_api()
|
||||
{
|
||||
try {
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$password = $prm["password"] ?? "";
|
||||
|
||||
if ($password == "") {
|
||||
echo json_encode([
|
||||
"status" => "error",
|
||||
"message" => "Password kosong"
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$hash = password_hash($password, PASSWORD_BCRYPT, [
|
||||
"cost" => 10
|
||||
]);
|
||||
|
||||
$result = [
|
||||
"password" => $password,
|
||||
"password_hash" => $hash
|
||||
];
|
||||
|
||||
echo json_encode($result);
|
||||
} catch (Exception $e) {
|
||||
|
||||
echo json_encode([
|
||||
"status" => "error",
|
||||
"message" => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
243
application/controllers/antrian/Layanandokter.php
Normal file
243
application/controllers/antrian/Layanandokter.php
Normal file
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
class Layanandokter extends MY_Controller
|
||||
{
|
||||
var $db_antrione;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_antrione = $this->load->database("antrione", true);
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo ('API SERVICE');
|
||||
}
|
||||
|
||||
function list_layanan_dokter()
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
$prm = $this->sys_input;
|
||||
$serviceId = "0";
|
||||
if (isset($prm['serviceId'])) {
|
||||
// $serviceId = trim(str_replace("[]","",$prm["serviceId"]));
|
||||
$serviceId = implode(",", $prm['serviceId']);
|
||||
}
|
||||
|
||||
// $serviceIdfix = "1,15";
|
||||
|
||||
// belum dilayani
|
||||
$sql_belum_dilayani = "SELECT queueID,
|
||||
statusID,
|
||||
IFNULL(queueNumber,'') as queueNumber,
|
||||
IFNULL(serviceDoctorName,'') as serviceDoctorName,
|
||||
CONCAT(queueNumber,'-',serviceDoctorName) as antrian_selanjutnya,
|
||||
( CASE
|
||||
WHEN statusID = 1 THEN 1
|
||||
END ) as order_status
|
||||
FROM queue
|
||||
JOIN service
|
||||
ON serviceID = queueServiceID
|
||||
AND serviceIsActive = 'Y'
|
||||
JOIN status
|
||||
ON statusID = queueStatusID
|
||||
WHERE queueIsActive = 'Y'
|
||||
AND statusID IN (1)
|
||||
AND serviceIsConsultDoctor = 'Y'
|
||||
AND serviceId IN ($serviceId)
|
||||
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
|
||||
ORDER BY IFNULL(queueSkipDate, queueCreated)";
|
||||
|
||||
$qry_belum_dilayani = $this->db_antrione->query($sql_belum_dilayani);
|
||||
$last_qry_belum_dilayani = $this->db_antrione->last_query();
|
||||
if (!$qry_belum_dilayani) {
|
||||
// $error = array(
|
||||
// "message" => $this->db_antrione->error()["message"],
|
||||
// "sql" => $last_qry
|
||||
// );
|
||||
// $this->sys_error_db($error);
|
||||
// exit;
|
||||
|
||||
$this->db_antrione->trans_rollback();
|
||||
echo json_encode(
|
||||
array("status" => "ERR", "message" => $last_qry_belum_dilayani)
|
||||
);
|
||||
exit;
|
||||
}
|
||||
$belum_dilayani = $qry_belum_dilayani->result_array();
|
||||
|
||||
$arr_serviceName = [];
|
||||
$result = [];
|
||||
foreach ($belum_dilayani as $key => $val) {
|
||||
$serviceName = $val['serviceDoctorName'];
|
||||
|
||||
if (in_array($serviceName, $arr_serviceName)) {
|
||||
continue;
|
||||
}
|
||||
$result[] = $val;
|
||||
$arr_serviceName[] = $serviceName;
|
||||
}
|
||||
|
||||
$belum_dilayani = $result;
|
||||
|
||||
$sql_call = "SELECT queueID,
|
||||
statusID,
|
||||
queueServiceID as serviceID,
|
||||
IFNULL(queueNumber,'') as queueNumber,
|
||||
IFNULL(serviceDoctorName,'') as serviceDoctorName,
|
||||
CONCAT(queueNumber,'-',serviceDoctorName) as antrian_selanjutnya,
|
||||
( CASE
|
||||
WHEN statusID = 2 THEN 1
|
||||
WHEN statusID = 5 THEN 3
|
||||
END ) as order_status
|
||||
FROM queue
|
||||
JOIN service
|
||||
ON serviceID = queueServiceID
|
||||
AND serviceIsActive = 'Y'
|
||||
JOIN status
|
||||
ON statusID = queueStatusID
|
||||
WHERE queueIsActive = 'Y'
|
||||
AND statusID IN (2,5)
|
||||
AND serviceIsConsultDoctor = 'Y'
|
||||
AND serviceId IN ($serviceId)
|
||||
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
|
||||
ORDER BY order_status, queueCreated asc";
|
||||
$qry_call = $this->db_antrione->query($sql_call);
|
||||
$last_qry_call = $this->db_antrione->last_query();
|
||||
if (!$qry_call) {
|
||||
$this->db_antrione->trans_rollback();
|
||||
echo json_encode(
|
||||
array("status" => "ERR", "message" => $last_qry_call)
|
||||
);
|
||||
exit;
|
||||
}
|
||||
$call = $qry_call->result_array();
|
||||
|
||||
$arr_serviceName = [];
|
||||
$result = [];
|
||||
foreach ($call as $key => $val) {
|
||||
$serviceName = $val['serviceDoctorName'];
|
||||
|
||||
if (in_array($serviceName, $arr_serviceName)) {
|
||||
continue;
|
||||
}
|
||||
$result[] = $val;
|
||||
$arr_serviceName[] = $serviceName;
|
||||
}
|
||||
|
||||
$call = $result;
|
||||
|
||||
// sedang dilayani
|
||||
$sql_sedang_dilayani = "SELECT queueID,
|
||||
queueServiceID as serviceID,
|
||||
IFNULL(queueNumber,'') as queueNumber,
|
||||
IFNULL(serviceDoctorName,'') as serviceDoctorName,
|
||||
CONCAT(queueNumber,'-',serviceDoctorName) as antrian_selanjutnya,
|
||||
( CASE
|
||||
WHEN statusID = 3 THEN 1
|
||||
END ) as order_status
|
||||
FROM queue
|
||||
JOIN service
|
||||
ON serviceID = queueServiceID
|
||||
AND serviceIsActive = 'Y'
|
||||
JOIN status
|
||||
ON statusID = queueStatusID
|
||||
WHERE queueIsActive = 'Y'
|
||||
AND statusID IN (3)
|
||||
AND serviceIsConsultDoctor = 'Y'
|
||||
AND serviceId IN ($serviceId)
|
||||
AND DATE_FORMAT(queueCreated, '%d-%m-%Y') = DATE_FORMAT(NOW(), '%d-%m-%Y')
|
||||
ORDER BY order_status, queueCreated asc";
|
||||
$qry_sedang_dilayani = $this->db_antrione->query($sql_sedang_dilayani);
|
||||
$last_qry_sedang_dilayani = $this->db_antrione->last_query();
|
||||
if (!$qry_sedang_dilayani) {
|
||||
// $error = array(
|
||||
// "message" => $this->db_antrione->error()["message"],
|
||||
// "sql" => $last_qry
|
||||
// );
|
||||
// $this->sys_error_db($error);
|
||||
// exit;
|
||||
|
||||
$this->db_antrione->trans_rollback();
|
||||
echo json_encode(
|
||||
array("status" => "ERR", "message" => $last_qry_sedang_dilayani)
|
||||
);
|
||||
exit;
|
||||
}
|
||||
$sedang_dilayani = $qry_sedang_dilayani->result_array();
|
||||
|
||||
$data = [];
|
||||
$data['call'] = $call;
|
||||
$data['belumDilayani'] = $belum_dilayani;
|
||||
$data['sedangDilayani'] = $sedang_dilayani;
|
||||
|
||||
$result = array(
|
||||
$data
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function list_service()
|
||||
{
|
||||
try {
|
||||
$sql = "SELECT * FROM service WHERE serviceIsActive = 'Y'
|
||||
and serviceIsConsultDoctor = 'Y'";
|
||||
$qry = $this->db_antrione->query($sql, []);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$data = $qry->result_array();
|
||||
$result = array(
|
||||
"records" => $data,
|
||||
"qry" => $last_qry
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function list_service_not_consult()
|
||||
{
|
||||
try {
|
||||
$sql = "SELECT * FROM service
|
||||
WHERE serviceIsActive = 'Y'";
|
||||
$qry = $this->db_antrione->query($sql, []);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$data = $qry->result_array();
|
||||
$result = array(
|
||||
"records" => $data,
|
||||
"qry" => $last_qry
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
252
application/controllers/antrian/Location.php
Normal file
252
application/controllers/antrian/Location.php
Normal file
@@ -0,0 +1,252 @@
|
||||
<?php
|
||||
class Location extends MY_Controller
|
||||
{
|
||||
var $db_antrione;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_antrione = $this->load->database("antrione", true);
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
$cek = $this->db_antrione->query("select database() as current_db")->result();
|
||||
// echo $this->db->last_query();
|
||||
|
||||
print_r($cek);
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
try{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_antrione->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$code = "";
|
||||
if (isset($prm['code'])) {
|
||||
$code = trim($prm["code"]);
|
||||
}
|
||||
|
||||
$name = "";
|
||||
if (isset($prm['name'])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
|
||||
$sql_data = "INSERT INTO location(
|
||||
locationCode,
|
||||
locationName,
|
||||
locationUserID,
|
||||
locationCreated,
|
||||
locationLastUpdated)
|
||||
VALUES (?, ?, ?, NOW(), NOW())";
|
||||
|
||||
$qry_data = $this->db_antrione->query($sql_data, [$code, $name, $userid]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
echo $last_qry;
|
||||
|
||||
// if(!$qry_data) {
|
||||
// $this->db_antrione->trans_rollback();
|
||||
// $error = array(
|
||||
// "message" => $this->db_antrione->error()["message"],
|
||||
// "sql" => $last_qry
|
||||
// );
|
||||
// $this->sys_error_db($error, $this->db_antrione);
|
||||
// exit;
|
||||
// }
|
||||
|
||||
// $this->db_antrione->trans_commit();
|
||||
// $result = array(
|
||||
// "affected_rows" => $this->db_antrione->affected_rows(),
|
||||
// "inserted_id" => $this->db_antrione->insert_id()
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if(isset($prm["search"])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != ""){
|
||||
$search = "%" . $prm["search"] . "%";
|
||||
}else{
|
||||
$search = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$sortBy = $prm["sortBy"];
|
||||
$sortStatus = $prm["sortStatus"];
|
||||
if($sortBy){
|
||||
$q_sort = "ORDER BY ".$sortBy." ".$sortStatus;
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT count(DISTINCT locationID) as total
|
||||
FROM location
|
||||
WHERE locationName like ? AND locationIsActive = 'Y'";
|
||||
|
||||
$qry_filter = $this->db_antrione->query($sql_filter, [$search]);
|
||||
// $last_qry = $this->db_antrione->last_query();
|
||||
// print_r($last_qry);
|
||||
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if($qry_filter) {
|
||||
$tot_count = $qry_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
}else{
|
||||
$this->sys_error_db("location select count", $this->db_antrione);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_data = "SELECT DISTINCT locationID as id,
|
||||
locationName, locationIsActive
|
||||
FROM location
|
||||
WHERE locationName like ? AND locationIsActive = 'Y'
|
||||
$q_sort
|
||||
limit ? offset ?";
|
||||
|
||||
$qry_data = $this->db_antrione->query($sql_data, [$search, $number_limit, $number_offset]);
|
||||
if($qry_data) {
|
||||
$rows = $qry_data->result_array();
|
||||
}else{
|
||||
$this->sys_error_db("location select", $this->db_antrione);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function edit()
|
||||
{
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db_antrione->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$name = "";
|
||||
if (isset($prm['name'])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm['id'])) {
|
||||
if (is_numeric($prm["id"])){
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "UPDATE location
|
||||
SET locationName = ?,
|
||||
locationUserID = ?,
|
||||
locationLastUpdated = NOW()
|
||||
WHERE locationID = ?";
|
||||
|
||||
$qry = $this->db_antrione->query($sql, [$name, $userid, $id]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
// print_r($last_qry);
|
||||
if(!$qry) {
|
||||
$this->db_antrione->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db_antrione);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db_antrione->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db_antrione->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function delete()
|
||||
{
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db_antrione->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$id = "";
|
||||
if(isset($prm['id'])) {
|
||||
if(is_numeric($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "UPDATE location
|
||||
SET locationIsActive = 'N',
|
||||
locationUserID = ?,
|
||||
locationLastUpdated = NOW()
|
||||
WHERE locationID = ?";
|
||||
|
||||
$qry = $this->db_antrione->query($sql, [$userid, $id]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if(!$qry){
|
||||
$this->db_antrione->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db_antrione);
|
||||
exit;
|
||||
}
|
||||
// print_r($last_qry);
|
||||
|
||||
$this->db_antrione->trans_commit();
|
||||
$result = array(
|
||||
"affected_rows" => $this->db_antrione->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
131
application/controllers/antrian/Nonlab.php
Normal file
131
application/controllers/antrian/Nonlab.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
class Nonlab extends MY_Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
function get_call($station_id=NULL,$trx_date=NULL,$status=NULL) {
|
||||
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$sql = " SELECT CONCAT(IFNULL(M_TitleName,''),' ',IFNULL(M_PatientPrefix,''),M_PatientName,IFNULL(M_PatientSuffix,'')) as patient_name,
|
||||
T_SamplingQueueLastStatusID as trx_id,
|
||||
T_SampleStationName as sample_station,
|
||||
T_OrderHeaderLabNumber as nolab,
|
||||
T_OrderHeaderLabNumberExt as nolab_ext
|
||||
FROM t_sampling_queue_last_status
|
||||
JOIN t_orderheader ON T_OrderHeaderID = T_SamplingQueueLastStatusT_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN t_samplestation ON T_SamplingQueueLastStatusT_SampleStationID = T_SampleStationID AND
|
||||
T_SampleStationIsActive = 'Y'
|
||||
WHERE
|
||||
T_SamplingQueueLastStatusT_SampleStationID = ? AND
|
||||
T_SamplingQueueLastStatusT_SamplingQueueStatusID = ? AND
|
||||
DATE(T_SamplingQueueLastStatusLastUpdated) = ? AND
|
||||
T_SamplingQueueLastStatusIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,array($station_id,$status,$trx_date));
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->result_array();
|
||||
$s_data = $row;
|
||||
$this->sys_ok($s_data);
|
||||
exit;
|
||||
}
|
||||
//echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("NOT FOUND CALL", $this->db_onedev);
|
||||
|
||||
}
|
||||
|
||||
function get_data($station_id=NULL,$trx_date=NULL) {
|
||||
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$sql = "SELECT T_OrderHeaderID as order_id,
|
||||
T_OrderHeaderLabNumber as nolab,
|
||||
T_OrderHeaderLabNumberExt as nolab_ext,
|
||||
CONCAT(IFNULL(M_TitleName,''),' ',IFNULL(M_PatientPrefix,''),M_PatientName,IFNULL(M_PatientSuffix,'')) as patient_name,
|
||||
IFNULL(T_SamplingQueueStatusName,'new') as status,
|
||||
IFNULL(T_SamplingQueueLastStatusT_SamplingQueueStatusID,0) as last_status_id
|
||||
FROM t_orderheader
|
||||
JOIN t_orderheaderaddon ON T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
LEFT JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = ?
|
||||
JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_SamplingSoT_TestID = T_TestID AND
|
||||
T_SamplingSoT_SampleStationID = T_SampleStationID AND
|
||||
T_SamplingSoIsActive = 'Y'
|
||||
LEFT JOIN t_sampling_queue_last_status ON T_OrderHeaderID = T_SamplingQueueLastStatusT_OrderHeaderID
|
||||
LEFT JOIN t_sampling_queue_status ON T_SamplingQueueLastStatusT_SamplingQueueStatusID = T_SamplingQueueStatusID AND
|
||||
T_SamplingCallStatusIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderHeaderIsActive = 'Y' AND
|
||||
( DATE(T_OrderHeaderAddonIsComingDate) = ? OR DATE(T_OrderHeaderDate) = ? )
|
||||
GROUP BY T_OrderHeaderID
|
||||
HAVING fn_fo_get_laststatus(T_OrderHeaderID) IN (3,5) AND last_status_id NOT IN (1,3,5)
|
||||
ORDER BY T_OrderHeaderIsCito DESC, T_OrderHeaderID ASC";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,array($station_id,$trx_date,$trx_date));
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->result_array();
|
||||
$s_data = $row;
|
||||
$this->sys_ok($s_data);
|
||||
exit;
|
||||
}
|
||||
//echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("NOT FOUND CALL", $this->db_onedev);
|
||||
|
||||
}
|
||||
|
||||
function get_station(){
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$sql = " SELECT T_SampleStationID as id,
|
||||
T_SampleStationCode as code,
|
||||
T_SampleStationName as name,
|
||||
T_SampleStationIsNonLab as is_nonlab
|
||||
FROM t_samplestation
|
||||
WHERE
|
||||
T_SampleStationIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->result_array();
|
||||
$s_data = $row;
|
||||
$this->sys_ok($s_data);
|
||||
exit;
|
||||
}
|
||||
$this->sys_error_db("NOT FOUND CALL", $this->db_onedev);
|
||||
}
|
||||
|
||||
function get_images(){
|
||||
$dir = "/home/one/project/one/one-media/one-antrian/nonlab/";
|
||||
$files = scandir($dir);
|
||||
$results = [];
|
||||
foreach ($files as $key => $value) {
|
||||
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
|
||||
if (!is_dir($path)) {
|
||||
$results[] = $_SERVER['SERVER_NAME']."/one-media/one-antrian/nonlab/".basename($path, ".pdf");
|
||||
} else if ($value != "." && $value != "..") {
|
||||
getDirContents($path, $results);
|
||||
$results[] = $_SERVER['SERVER_NAME']."/one-media/one-antrian/nonlab/".basename($path, ".pdf");
|
||||
}
|
||||
}
|
||||
$this->sys_ok($results);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
1210
application/controllers/antrian/Queuefov2-12-04-2023.php
Normal file
1210
application/controllers/antrian/Queuefov2-12-04-2023.php
Normal file
File diff suppressed because it is too large
Load Diff
1673
application/controllers/antrian/Queuefov2.php
Normal file
1673
application/controllers/antrian/Queuefov2.php
Normal file
File diff suppressed because it is too large
Load Diff
349
application/controllers/antrian/Service.php
Normal file
349
application/controllers/antrian/Service.php
Normal file
@@ -0,0 +1,349 @@
|
||||
<?php
|
||||
class Service extends MY_Controller
|
||||
{
|
||||
var $db_antrione;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_antrione = $this->load->database("antrione", true);
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo ('API SERVICE');
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// print_r($prm);
|
||||
// exit;
|
||||
$search = "%%";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
}
|
||||
$order_by = "serviceCode";
|
||||
if (isset($prm['order_by'])) {
|
||||
$order_by = trim($prm["order_by"]);
|
||||
}
|
||||
$order = "asc";
|
||||
if (isset($prm['order'])) {
|
||||
$order = trim($prm["order"]);
|
||||
}
|
||||
$sort = "order by " . $order_by . " " . $order;
|
||||
$page = $prm["page"];
|
||||
$ROW_PER_PAGE = 10;
|
||||
$start_offset = 0;
|
||||
if (isset($prm["page"])) {
|
||||
if (
|
||||
is_numeric($prm["page"]) && $prm["page"] > 0
|
||||
) {
|
||||
$start_offset = ($page - 1) * $ROW_PER_PAGE;
|
||||
}
|
||||
}
|
||||
$total_count = 0;
|
||||
$total_page = 0;
|
||||
|
||||
$sqlCount = "SELECT COUNT(*) AS total FROM service
|
||||
WHERE serviceIsActive = 'Y'
|
||||
AND ( serviceCode LIKE ? OR serviceName LIKE ?)
|
||||
ORDER BY serviceCode";
|
||||
$qryCount = $this->db_antrione->query($sqlCount, [$search, $search]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryCount) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT * FROM service
|
||||
WHERE serviceIsActive = 'Y'
|
||||
AND ( serviceCode LIKE ? OR serviceName LIKE ?)
|
||||
$sort
|
||||
LIMIT 10 OFFSET ?";
|
||||
$qry = $this->db_antrione->query($sql, [$search, $search, $start_offset]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$total = $qryCount->row_array();
|
||||
$total_count = $total['total'];
|
||||
$total_page = ceil($total_count / $ROW_PER_PAGE);
|
||||
$data = $qry->result_array();
|
||||
$result = array(
|
||||
"total_filter" => $total_count,
|
||||
"total" => $total_page,
|
||||
"records" => $data,
|
||||
"qry" => $last_qry
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$code = "";
|
||||
if (isset($prm['code'])) {
|
||||
$code = trim($prm["code"]);
|
||||
}
|
||||
$name = "";
|
||||
if (isset($prm['name'])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$priority = "";
|
||||
if (isset($prm['priority'])) {
|
||||
$priority = trim($prm["priority"]);
|
||||
}
|
||||
$foOrder = "";
|
||||
if (isset($prm['foOrder'])) {
|
||||
$foOrder = trim($prm["foOrder"]);
|
||||
}
|
||||
|
||||
$isConsultDoctor = "";
|
||||
if (isset($prm['isConsultDoctor'])) {
|
||||
$isConsultDoctor = trim($prm["isConsultDoctor"]);
|
||||
}
|
||||
|
||||
$nameDoctor = "";
|
||||
if (isset($prm['nameDoctor'])) {
|
||||
$nameDoctor = trim($prm["nameDoctor"]);
|
||||
}
|
||||
|
||||
if ($isConsultDoctor == 'Y') {
|
||||
if ($code == "" || $name == "" || $priority == "" || $foOrder == "" || $nameDoctor == "") {
|
||||
$this->sys_error("code, name, priority, fo order, nama dokter is mandatory");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
if ($code == "" || $name == "" || $priority == "" || $foOrder == "") {
|
||||
$this->sys_error("code, name, priority, fo order is mandatory");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$this->db_antrione->trans_begin();
|
||||
$sql = "INSERT INTO service
|
||||
(serviceCode,
|
||||
serviceName,
|
||||
servicePriority,
|
||||
serviceIsFoOrder,
|
||||
serviceIsConsultDoctor,
|
||||
serviceDoctorName
|
||||
)
|
||||
VALUES(?, ?, ?, ?, ?, ?)";
|
||||
$qry = $this->db_antrione->query($sql, [$code, $name, $priority, $foOrder, $isConsultDoctor, $nameDoctor]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$insertedId = $this->db_antrione->insert_id();
|
||||
$sqlNumbering = "INSERT INTO numbering
|
||||
(numberingServiceID,
|
||||
numberingPrefix,
|
||||
numberingDigit,
|
||||
numberingReset)
|
||||
VALUES(? ,? , 4, 'D')";
|
||||
$qryNumbering = $this->db_antrione->query($sqlNumbering, [$insertedId, $insertedId]);
|
||||
if (!$qryNumbering) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$this->db_antrione->trans_complete();
|
||||
$result = array(
|
||||
"qry" => $last_qry
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function update()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$code = "";
|
||||
if (isset($prm['code'])) {
|
||||
$code = trim($prm["code"]);
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm['id'])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
$name = "";
|
||||
if (isset($prm['name'])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$priority = "";
|
||||
if (isset($prm['priority'])) {
|
||||
$priority = trim($prm["priority"]);
|
||||
}
|
||||
$foOrder = "";
|
||||
if (isset($prm['foOrder'])) {
|
||||
$foOrder = trim($prm["foOrder"]);
|
||||
}
|
||||
|
||||
$isConsultDoctor = "";
|
||||
if (isset($prm['isConsultDoctor'])) {
|
||||
$isConsultDoctor = trim($prm["isConsultDoctor"]);
|
||||
}
|
||||
|
||||
$nameDoctor = "";
|
||||
if (isset($prm['nameDoctor'])) {
|
||||
$nameDoctor = trim($prm["nameDoctor"]);
|
||||
}
|
||||
|
||||
if ($isConsultDoctor == 'Y') {
|
||||
if ($code == "" || $name == "" || $priority == "" || $foOrder == "" || $nameDoctor == "") {
|
||||
$this->sys_error("code, name, priority, fo order, nama dokter is mandatory");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
if ($code == "" || $name == "" || $priority == "" || $foOrder == "") {
|
||||
$this->sys_error("code, name, priority, fo order is mandatory");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "UPDATE service SET serviceCode = ?,
|
||||
serviceName = ?,
|
||||
servicePriority = ?,
|
||||
serviceIsFoOrder = ?,
|
||||
serviceIsConsultDoctor = ?,
|
||||
serviceDoctorName = ?
|
||||
WHERE serviceID = ?";
|
||||
$qry = $this->db_antrione->query($sql, [$code, $name, $priority, $foOrder, $isConsultDoctor, $nameDoctor, $id]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$result = array(
|
||||
"qry" => $last_qry
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$id = "";
|
||||
if (isset($prm['id'])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
$this->db_antrione->trans_begin();
|
||||
$sql = "UPDATE service SET
|
||||
serviceIsActive = 'N'
|
||||
WHERE serviceID = ?";
|
||||
$qry = $this->db_antrione->query($sql, [intval($id)]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$sqlNumbering = "UPDATE numbering SET
|
||||
numberingIsActive = 'N'
|
||||
WHERE numberingServiceID = ?";
|
||||
$qryNumbering = $this->db_antrione->query($sqlNumbering, [intval($id)]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryNumbering) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$this->db_antrione->trans_complete();
|
||||
$result = array(
|
||||
"qry" => $last_qry
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function listService()
|
||||
{
|
||||
try {
|
||||
$sql = "SELECT * FROM service WHERE serviceIsActive = 'Y'";
|
||||
$qry = $this->db_antrione->query($sql, []);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$data = $qry->result_array();
|
||||
$result = array(
|
||||
"records" => $data,
|
||||
"qry" => $last_qry
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
303
application/controllers/antrian/Ticket.php
Normal file
303
application/controllers/antrian/Ticket.php
Normal file
@@ -0,0 +1,303 @@
|
||||
<?php
|
||||
class Ticket extends MY_Controller
|
||||
{
|
||||
var $db_antrione;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_antrione = $this->load->database("antrione", true);
|
||||
$this->IP_SOCKET_IO = "localhost";
|
||||
// $this->IP_SOCKET_IO = "devone.aplikasi.web.id";
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo ('API GET ANTRIAN NUMBER');
|
||||
}
|
||||
function getAntrian()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
$serviceId = '';
|
||||
if (isset($prm['service_id'])) {
|
||||
$serviceId = trim($prm["service_id"]);
|
||||
}
|
||||
$boothId = '';
|
||||
if (isset($prm['booth_id'])) {
|
||||
$boothId = trim($prm["booth_id"]);
|
||||
}
|
||||
if ($serviceId == '' || $boothId == '') {
|
||||
$this->sys_error_db("service id & booth id is mandatory");
|
||||
exit;
|
||||
}
|
||||
$this->db_antrione->trans_begin();
|
||||
$sqlCek = "SELECT * FROM service
|
||||
WHERE serviceIsActive = 'Y'
|
||||
AND serviceID = ?";
|
||||
$qryCek = $this->db_antrione->query($sqlCek, [$serviceId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryCek) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
$serviceCek = $qryCek->result_array();
|
||||
if (count($serviceCek) == 0) {
|
||||
$error = array(
|
||||
"message" => "service tidak ada ",
|
||||
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db_antrione->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
|
||||
$sqlGetLocation = "SELECT *, SUM(fn_get_max_queue(counterID)) as maxQueue FROM counter
|
||||
LEFT JOIN counter_service ON counterID = counterServiceCounterID
|
||||
AND counterServiceIsActive = 'Y'
|
||||
JOIN location ON counterLocationID = locationID
|
||||
AND locationIsActive = 'Y'
|
||||
WHERE (counterIsDedicated = 'N' OR counterServiceServiceID = ?)
|
||||
AND counterIsActive = 'Y'
|
||||
GROUP BY locationID
|
||||
ORDER BY locationID";
|
||||
// $sqlGetLocation = "SELECT *, SUM(counterMaxQueue) as maxQueue FROM
|
||||
// counter_service
|
||||
// JOIN counter ON counterServiceCounterID = counterID
|
||||
// AND counterIsActive = 'Y'
|
||||
// JOIN location ON counterLocationID = locationID
|
||||
// AND locationIsActive = 'Y'
|
||||
// WHERE counterServiceServiceID = ?
|
||||
// AND counterServiceIsActive = 'Y'
|
||||
// GROUP BY locationID
|
||||
// ORDER BY locationID";
|
||||
$qrygetLocation = $this->db_antrione->query($sqlGetLocation, [$serviceId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryCek) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$location = $qrygetLocation->result_array();
|
||||
// print_r($location);
|
||||
// exit;
|
||||
$ticketMsg = '';
|
||||
|
||||
$locationIdFinal = 0;
|
||||
$countLocation = count($location);
|
||||
$masukMana = "";
|
||||
if ($countLocation == 0) {
|
||||
$locationIdFinal = 1;
|
||||
$ticketMsg = "Anda Akan Dilayan Di Front Office";
|
||||
$masukMana = "TIdak ada counter yang melayani";
|
||||
}
|
||||
if ($countLocation == 1) {
|
||||
$locationId = intval($location[0]['locationID']);
|
||||
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
|
||||
WHERE
|
||||
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
|
||||
AND queueIsActive = 'Y'
|
||||
AND queueStatusID <> 4
|
||||
AND queueLocationID = ?
|
||||
AND queueServiceID = ?";
|
||||
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryCek) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$queue = $qryCek->row_array();
|
||||
$queueNum = intval($queue['total']);
|
||||
if ($queueNum < $location[0]["maxQueue"]) {
|
||||
$locationIdFinal = $location[0]['locationID'];
|
||||
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $location[0]['locationName'];
|
||||
$masukMana = "ada 1 counter yang melayani";
|
||||
} else {
|
||||
$locationIdFinal = 1;
|
||||
$ticketMsg = "Anda Akan Dilayan Di Front Office Lantai 1";
|
||||
$masukMana = "ada 1 counter yang melayani";
|
||||
}
|
||||
}
|
||||
if ($countLocation > 1) {
|
||||
|
||||
$locationDedicated = array();
|
||||
foreach ($location as $value) {
|
||||
$locationId = intval($value["locationID"]);
|
||||
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
|
||||
WHERE
|
||||
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
|
||||
AND queueIsActive = 'Y'
|
||||
AND queueStatusID <> 4
|
||||
AND queueLocationID = ?
|
||||
AND queueServiceID = ?";
|
||||
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryCek) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$queue = $qryCek->row_array();
|
||||
$queueNum = intval($queue['total']);
|
||||
|
||||
if ($value['counterIsDedicated'] == 'Y' && $queueNum < $value["maxQueue"]) {
|
||||
$locationDedicated = $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// print_r($locationDedicated);
|
||||
// exit;
|
||||
if ($locationDedicated) {
|
||||
$locationIdFinal = $locationDedicated['locationID'];
|
||||
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $locationDedicated['locationName'];
|
||||
} else {
|
||||
for ($i = 0; $i < $countLocation; $i++) {
|
||||
$val = $location[$i];
|
||||
$maxQueue = intval($val["maxQueue"]);
|
||||
$locationId = intval($val["locationID"]);
|
||||
$locationName = $val['locationName'];
|
||||
$isDedicated = $val['counterIsDedicated'];
|
||||
|
||||
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
|
||||
WHERE
|
||||
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
|
||||
AND queueIsActive = 'Y'
|
||||
AND queueStatusID <> 4
|
||||
AND queueLocationID = ?
|
||||
AND queueServiceID = ?";
|
||||
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryCek) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$queue = $qryCek->row_array();
|
||||
$queueNum = intval($queue['total']);
|
||||
if ($countLocation == ($i + 1) && $queueNum >= $maxQueue) {
|
||||
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $location[0]['locationName'];
|
||||
$locationIdFinal = $location[0]['locationID'];
|
||||
$masukMana = "countLocation == key && queueNum >= maxQueue";
|
||||
break;
|
||||
}
|
||||
if ($queueNum < $maxQueue) {
|
||||
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $locationName;
|
||||
$masukMana = "queueNum < maxQueue";
|
||||
$locationIdFinal = $locationId;
|
||||
break;
|
||||
}
|
||||
if ($queueNum >= $maxQueue) {
|
||||
$masukMana = "queueNum >= maxQueue";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// print_r([$masukMana, $queueNum, $location, $queue, $ticketMsg]);
|
||||
// exit;
|
||||
$sqlGetNumber = "SELECT fn_get_numbering(?) AS number";
|
||||
$qryGetNumber = $this->db_antrione->query($sqlGetNumber, [$serviceId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryCek) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$number = $qryGetNumber->row_array();
|
||||
$numberQueue = $number['number'];
|
||||
|
||||
$sqlInsert = "INSERT INTO queue
|
||||
(queueNumber,
|
||||
queueStatusID,
|
||||
queueServiceID,
|
||||
queueLocationID,
|
||||
queueTicketBoothID)
|
||||
VALUES
|
||||
(?, 1, ?, ?, ?)";
|
||||
$qryInsert = $this->db_antrione->query($sqlInsert, [$numberQueue, $serviceId, $locationIdFinal, $boothId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryInsert) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$queueId = $this->db_antrione->insert_id();
|
||||
|
||||
$sqlLog = "INSERT INTO queuelog
|
||||
(queueLogDate,
|
||||
queueLogStatusID,
|
||||
queueLogCounterID)
|
||||
VALUES(NOW(),1,0)";
|
||||
$qryLog = $this->db_antrione->query($sqlLog);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryLog) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$logId = $this->db_antrione->insert_id();
|
||||
|
||||
$sqlUpdate = "UPDATE queue SET
|
||||
queueQueueLogID = ?
|
||||
WHERE queueID = ?";
|
||||
$qryUpdate = $this->db_antrione->query($sqlUpdate, [$logId, $queueId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryUpdate) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$logId = $this->db_antrione->insert_id();
|
||||
$this->db_antrione->trans_complete();
|
||||
$result = array(
|
||||
"number" => $numberQueue,
|
||||
"location" => $ticketMsg,
|
||||
"bagian" => $masukMana,
|
||||
"maxQueuePerLantai" => $location
|
||||
);
|
||||
file_get_contents("http://" . $this->IP_SOCKET_IO . ":9099/broadcast/printed.fo.{$serviceId}");
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
302
application/controllers/antrian/Ticketrspad.php
Normal file
302
application/controllers/antrian/Ticketrspad.php
Normal file
@@ -0,0 +1,302 @@
|
||||
<?php
|
||||
class Ticketrspad extends MY_Controller
|
||||
{
|
||||
var $db_antrione;
|
||||
var $load;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_antrione = $this->load->database("antrione", true);
|
||||
$this->IP_SOCKET_IO = "devone.aplikasi.web.id";
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo ('API GET ANTRIAN NUMBER');
|
||||
}
|
||||
function getAntrian()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
$serviceId = '';
|
||||
if (isset($prm['service_id'])) {
|
||||
$serviceId = trim($prm["service_id"]);
|
||||
}
|
||||
$boothId = '';
|
||||
if (isset($prm['booth_id'])) {
|
||||
$boothId = trim($prm["booth_id"]);
|
||||
}
|
||||
if ($serviceId == '' || $boothId == '') {
|
||||
$this->sys_error_db("service id & booth id is mandatory");
|
||||
exit;
|
||||
}
|
||||
$this->db_antrione->trans_begin();
|
||||
$sqlCek = "SELECT * FROM service
|
||||
WHERE serviceIsActive = 'Y'
|
||||
AND serviceID = ?";
|
||||
$qryCek = $this->db_antrione->query($sqlCek, [$serviceId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryCek) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
$serviceCek = $qryCek->result_array();
|
||||
if (count($serviceCek) == 0) {
|
||||
$error = array(
|
||||
"message" => "service tidak ada ",
|
||||
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
$this->db_antrione->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
|
||||
$sqlGetLocation = "SELECT *, SUM(fn_get_max_queue(counterID)) as maxQueue FROM counter
|
||||
LEFT JOIN counter_service ON counterID = counterServiceCounterID
|
||||
AND counterServiceIsActive = 'Y'
|
||||
JOIN location ON counterLocationID = locationID
|
||||
AND locationIsActive = 'Y'
|
||||
WHERE (counterIsDedicated = 'N' OR counterServiceServiceID = ?)
|
||||
AND counterIsActive = 'Y'
|
||||
GROUP BY locationID
|
||||
ORDER BY locationID";
|
||||
// $sqlGetLocation = "SELECT *, SUM(counterMaxQueue) as maxQueue FROM
|
||||
// counter_service
|
||||
// JOIN counter ON counterServiceCounterID = counterID
|
||||
// AND counterIsActive = 'Y'
|
||||
// JOIN location ON counterLocationID = locationID
|
||||
// AND locationIsActive = 'Y'
|
||||
// WHERE counterServiceServiceID = ?
|
||||
// AND counterServiceIsActive = 'Y'
|
||||
// GROUP BY locationID
|
||||
// ORDER BY locationID";
|
||||
$qrygetLocation = $this->db_antrione->query($sqlGetLocation, [$serviceId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryCek) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$location = $qrygetLocation->result_array();
|
||||
// print_r($location);
|
||||
// exit;
|
||||
$ticketMsg = '';
|
||||
|
||||
$locationIdFinal = 0;
|
||||
$countLocation = count($location);
|
||||
$masukMana = "";
|
||||
if ($countLocation == 0) {
|
||||
$locationIdFinal = 1;
|
||||
$ticketMsg = "Anda Akan Dilayan Di Front Office";
|
||||
$masukMana = "TIdak ada counter yang melayani";
|
||||
}
|
||||
if ($countLocation == 1) {
|
||||
$locationId = intval($location[0]['locationID']);
|
||||
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
|
||||
WHERE
|
||||
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
|
||||
AND queueIsActive = 'Y'
|
||||
AND queueStatusID <> 4
|
||||
AND queueLocationID = ?
|
||||
AND queueServiceID = ?";
|
||||
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryCek) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$queue = $qryCek->row_array();
|
||||
$queueNum = intval($queue['total']);
|
||||
if ($queueNum < $location[0]["maxQueue"]) {
|
||||
$locationIdFinal = $location[0]['locationID'];
|
||||
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $location[0]['locationName'];
|
||||
$masukMana = "ada 1 counter yang melayani";
|
||||
} else {
|
||||
$locationIdFinal = 1;
|
||||
$ticketMsg = "Anda Akan Dilayan Di Front Office Lantai 1";
|
||||
$masukMana = "ada 1 counter yang melayani";
|
||||
}
|
||||
}
|
||||
if ($countLocation > 1) {
|
||||
|
||||
$locationDedicated = array();
|
||||
foreach ($location as $value) {
|
||||
$locationId = intval($value["locationID"]);
|
||||
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
|
||||
WHERE
|
||||
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
|
||||
AND queueIsActive = 'Y'
|
||||
AND queueStatusID <> 4
|
||||
AND queueLocationID = ?
|
||||
AND queueServiceID = ?";
|
||||
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryCek) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$queue = $qryCek->row_array();
|
||||
$queueNum = intval($queue['total']);
|
||||
|
||||
if ($value['counterIsDedicated'] == 'Y' && $queueNum < $value["maxQueue"]) {
|
||||
$locationDedicated = $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// print_r($locationDedicated);
|
||||
// exit;
|
||||
if ($locationDedicated) {
|
||||
$locationIdFinal = $locationDedicated['locationID'];
|
||||
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $locationDedicated['locationName'];
|
||||
} else {
|
||||
for ($i = 0; $i < $countLocation; $i++) {
|
||||
$val = $location[$i];
|
||||
$maxQueue = intval($val["maxQueue"]);
|
||||
$locationId = intval($val["locationID"]);
|
||||
$locationName = $val['locationName'];
|
||||
$isDedicated = $val['counterIsDedicated'];
|
||||
|
||||
$sqlCek = "SELECT COUNT(queueID) as total FROM queue
|
||||
WHERE
|
||||
DATE_FORMAT(queueCreated, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
|
||||
AND queueIsActive = 'Y'
|
||||
AND queueStatusID <> 4
|
||||
AND queueLocationID = ?
|
||||
AND queueServiceID = ?";
|
||||
$qryCek = $this->db_antrione->query($sqlCek, [$locationId, $serviceId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryCek) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$queue = $qryCek->row_array();
|
||||
$queueNum = intval($queue['total']);
|
||||
if ($countLocation == ($i + 1) && $queueNum >= $maxQueue) {
|
||||
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $location[0]['locationName'];
|
||||
$locationIdFinal = $location[0]['locationID'];
|
||||
$masukMana = "countLocation == key && queueNum >= maxQueue";
|
||||
break;
|
||||
}
|
||||
if ($queueNum < $maxQueue) {
|
||||
$ticketMsg = "Anda Akan Dilayan Di Front Office " . $locationName;
|
||||
$masukMana = "queueNum < maxQueue";
|
||||
$locationIdFinal = $locationId;
|
||||
break;
|
||||
}
|
||||
if ($queueNum >= $maxQueue) {
|
||||
$masukMana = "queueNum >= maxQueue";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// print_r([$masukMana, $queueNum, $location, $queue, $ticketMsg]);
|
||||
// exit;
|
||||
$sqlGetNumber = "SELECT fn_get_numbering(?) AS number";
|
||||
$qryGetNumber = $this->db_antrione->query($sqlGetNumber, [$serviceId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryCek) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$number = $qryGetNumber->row_array();
|
||||
$numberQueue = $number['number'];
|
||||
|
||||
$sqlInsert = "INSERT INTO queue
|
||||
(queueNumber,
|
||||
queueStatusID,
|
||||
queueServiceID,
|
||||
queueLocationID,
|
||||
queueTicketBoothID)
|
||||
VALUES
|
||||
(?, 1, ?, ?, ?)";
|
||||
$qryInsert = $this->db_antrione->query($sqlInsert, [$numberQueue, $serviceId, $locationIdFinal, $boothId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryInsert) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$queueId = $this->db_antrione->insert_id();
|
||||
|
||||
$sqlLog = "INSERT INTO queuelog
|
||||
(queueLogDate,
|
||||
queueLogStatusID,
|
||||
queueLogCounterID)
|
||||
VALUES(NOW(),1,0)";
|
||||
$qryLog = $this->db_antrione->query($sqlLog);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryLog) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$logId = $this->db_antrione->insert_id();
|
||||
|
||||
$sqlUpdate = "UPDATE queue SET
|
||||
queueQueueLogID = ?
|
||||
WHERE queueID = ?";
|
||||
$qryUpdate = $this->db_antrione->query($sqlUpdate, [$logId, $queueId]);
|
||||
$last_qry = $this->db_antrione->last_query();
|
||||
if (!$qryUpdate) {
|
||||
$error = array(
|
||||
"message" => $this->db_antrione->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->db_antrione->trans_rollback();
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$logId = $this->db_antrione->insert_id();
|
||||
$this->db_antrione->trans_complete();
|
||||
$result = array(
|
||||
"number" => $numberQueue,
|
||||
"location" => $ticketMsg,
|
||||
"bagian" => $masukMana,
|
||||
"maxQueuePerLantai" => $location
|
||||
);
|
||||
file_get_contents("http://" . $this->IP_SOCKET_IO . ":9099/broadcast/printed.fo.{$serviceId}");
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
162
application/controllers/aoh/Databranch.php
Normal file
162
application/controllers/aoh/Databranch.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
class Databranch extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "DATA BRANCH API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
public function request_hold($mouid, $billid)
|
||||
{
|
||||
// Kirim request hold ke regional
|
||||
|
||||
|
||||
// select data dari f_bill_issue
|
||||
// join f_bill, m_mou, m_company, m_branch (M_BranchIsActive = 'Y' & M_BranchIsDefault = 'Y')
|
||||
// pastikan M_MouIsActive = 'H'
|
||||
// Data yang dibutuhkan M_BranchID, M_BranchCode, M_BranchName,F_BillNo, M_MouID, M_MouName, M_MouNumber, M_CompanyID, M_CompanyNumber, M_MouLastUpdated (untuk info tanggal terholdnya)
|
||||
$sql = "";
|
||||
$qry = $this->onedev->query($sql, array());
|
||||
$rows = array();
|
||||
|
||||
if($qry) {
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$param = json_encode($rows);
|
||||
|
||||
// insert data ke tabel log_aoh
|
||||
$sql_insert = "";
|
||||
|
||||
//get data dari tabel conf_systems S_SystemIPAddressRegional untuk mendapatkan ip regional
|
||||
$regional_ip_address = "";
|
||||
|
||||
$url = "http://$regional_ip_address/one-api/aoh/receive_request_hold";
|
||||
|
||||
$result = $this->post($url,$param);
|
||||
echo "to $url \nresponse : $result\n";
|
||||
$result = json_decode($result,true);
|
||||
if ($result["status"] == "OK" ) {
|
||||
// update log_aoh field Log_AohStatus menjadi S
|
||||
return true;
|
||||
} else {
|
||||
// update log_aoh field Log_AohStatus menjadi E
|
||||
print_r($result);
|
||||
}
|
||||
}else {
|
||||
print_r($this->db_onedev->error());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public function receive_excute_hold()
|
||||
{
|
||||
// Update data hold dari regional
|
||||
$prm = $this->sys_input;
|
||||
// parameter array mou_id
|
||||
|
||||
foreach($prm as $p ) {
|
||||
// Update data m_mou field M_MouIsActive menjadi H
|
||||
$sql = "";
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
|
||||
}
|
||||
// return array mou_id beserta statusnya
|
||||
|
||||
}
|
||||
public function request_unhold($mouid,$billid)
|
||||
{
|
||||
// Kirim request unhold ke regional
|
||||
|
||||
|
||||
// select data dari f_bill_issue
|
||||
// jika F_BillIssueIsAllMou = 'Y' join f_bill_mou untuk mendapatkan mouid , jika F_BillIssueIsAllMou = 'N' langsung ambil dari F_BillIssueM_MouID
|
||||
// join f_bill, m_mou, m_company
|
||||
// Data yang dibutuhkan F_BillNo, M_MouID, M_MouName, M_MouNumber, M_CompanyID, M_CompanyNumber
|
||||
// pastikan F_BillIsLunas = 'Y'
|
||||
$sql = "";
|
||||
$qry = $this->onedev->query($sql, array());
|
||||
$rows = array();
|
||||
|
||||
if($qry) {
|
||||
$rows = $qry->result_array();
|
||||
|
||||
//get data dari tabel conf_systems S_SystemIPAddressRegional untuk mendapatkan ip regional
|
||||
$regional_ip_address = "";
|
||||
|
||||
$param = json_encode($rows);
|
||||
|
||||
$url = "http://$regional_ip_address/one-api/aoh/receive_request_unhold";
|
||||
|
||||
$result = $this->post($url,$param);
|
||||
echo "to $url \nresponse : $result\n";
|
||||
$result = json_decode($result,true);
|
||||
if ($result["status"] == "OK" ) {
|
||||
return true;
|
||||
} else {
|
||||
print_r($result);
|
||||
}
|
||||
}else {
|
||||
print_r($this->db_onedev->error());
|
||||
}
|
||||
}
|
||||
public function receive_chek_agrement_status()
|
||||
{
|
||||
// select data dari f_bill_issue
|
||||
// jika F_BillIssueIsAllMou = 'Y' join f_bill_mou untuk mendapatkan mouid , jika F_BillIssueIsAllMou = 'N' langsung ambil dari F_BillIssueM_MouID
|
||||
// join f_bill, m_mou, m_company
|
||||
// cek apakah agreement tersebut masih ada tagihan jatuh tempo & belum lunas
|
||||
// jika F_BillIssueExtendDay = 0 maka F_BillDueDate + 7 & F_BillIsLunas = 'N'
|
||||
// jika F_BillIssueExtendDay <> 0 maka F_BillDueDate + F_BillIssueExtendDay & F_BillIsLunas = 'N'
|
||||
|
||||
$sql = "";
|
||||
$qry = $this->onedev->query($sql);
|
||||
$rows = array();
|
||||
|
||||
if($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0) {
|
||||
// jika ada tagihan belum tuntas maka status Tidak OK
|
||||
}else{
|
||||
// jika tidak ada tagihan yang pending maka status OK
|
||||
}
|
||||
}else {
|
||||
print_r($this->db_onedev->error());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public function receive_excute_unhold()
|
||||
{
|
||||
// Update data unhold dari regional
|
||||
$prm = $this->sys_input;
|
||||
// parameter array mou_id
|
||||
|
||||
foreach($prm as $p ) {
|
||||
// Update data tabel m_mou field M_MouIsActive menjadi Y
|
||||
$sql = "";
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
|
||||
}
|
||||
// return array mou_id beserta statusnya
|
||||
}
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
//echo "RST : $result ";
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
175
application/controllers/auto_verif/Order.php
Normal file
175
application/controllers/auto_verif/Order.php
Normal file
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
class Order extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function reply($resp)
|
||||
{
|
||||
echo json_encode($resp);
|
||||
exit;
|
||||
}
|
||||
function index()
|
||||
{
|
||||
$resp = array("status" => "ERR", "message" => "", "rows" => array());
|
||||
|
||||
$param = $this->sys_input;
|
||||
$date = $param["date"];
|
||||
$maxIDcito = 0;
|
||||
$maxIDnormal = 0;
|
||||
if (isset($param["maxID"])) {
|
||||
list($maxIDcito, $maxIDnormal) = explode("|", $param["maxID"]);
|
||||
}
|
||||
//janji hasil hari ini
|
||||
$sql = "select distinct T_OrderPromiseT_OrderHeaderID
|
||||
from t_orderpromise
|
||||
where T_OrderPromiseIsActive = 'Y'
|
||||
and date(T_OrderPromiseDateTime) = ?
|
||||
";
|
||||
$qry = $this->db->query($sql, array($date));
|
||||
if (!$qry) {
|
||||
$resp["message"] = "ERR : " . $this->db->error()["message"] . "|"
|
||||
. $this->db->last_query();
|
||||
$this->reply($resp);
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$promise_ids = "0";
|
||||
foreach ($rows as $r) {
|
||||
$promise_ids .= ", " . $r["T_OrderPromiseT_OrderHeaderID"];
|
||||
}
|
||||
|
||||
//order hari ini atu janji hasil hari ini
|
||||
$sql = "select T_OrderHeaderID
|
||||
from t_orderheader
|
||||
join t_orderheaderaddon
|
||||
on T_OrderHeaderIsActive = 'Y'
|
||||
and (
|
||||
( T_OrderHeaderIsCito = 'N' and T_OrderHeaderID > ? )
|
||||
or
|
||||
( T_OrderHeaderIsCito = 'Y' and T_OrderHeaderID > ? )
|
||||
)
|
||||
and (
|
||||
date(T_OrderHeaderDate) = ?
|
||||
or
|
||||
T_OrderHeaderID in ($promise_ids)
|
||||
)
|
||||
and T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
-- and T_OrderHeaderAddOnVerificationDone <> 'Y'
|
||||
order by T_OrderHeaderIsCito desc, T_OrderHeaderID
|
||||
limit 0,10";
|
||||
$qry = $this->db->query($sql, array($maxIDnormal, $maxIDcito, $date));
|
||||
if (!$qry) {
|
||||
$resp["message"] = "ERR : " . $this->db->error()["message"] . "|"
|
||||
. $this->db->last_query();
|
||||
$this->reply($resp);
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$s_ids = "0";
|
||||
foreach ($rows as $r) {
|
||||
$s_ids .= ", " . $r["T_OrderHeaderID"];
|
||||
}
|
||||
$sql = "
|
||||
select T_OrderHeaderID,
|
||||
date_format(T_OrderHeaderDate,'%Y-%m-%d %H:%i') T_OrderHeaderDate
|
||||
,T_OrderHeaderLabNumber,
|
||||
if (T_OrderHeaderAddOnLabNumberOrigin is null ,
|
||||
T_OrderHeaderLabNumberExt,
|
||||
T_OrderHeaderAddOnLabNumberOrigin )
|
||||
T_OrderHeaderLabNumberExt,
|
||||
T_OrderHeaderIsCito,
|
||||
fn_global_patient_name(T_OrderHeaderM_PatientID) PatientName
|
||||
from
|
||||
t_orderheader
|
||||
join t_orderheaderaddon
|
||||
on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderID in ($s_ids)
|
||||
order by T_OrderHeaderIsCito desc, T_OrderHeaderDate
|
||||
";
|
||||
$qry = $this->db->query($sql, array($maxIDnormal, $maxIDcito, $date));
|
||||
if (!$qry) {
|
||||
$resp["message"] = "ERR : " . $this->db->error()["message"] . "|"
|
||||
. $this->db->last_query();
|
||||
$this->reply($resp);
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$result = array();
|
||||
|
||||
foreach ($rows as $r) {
|
||||
$result[] = array(
|
||||
"id" => intVal($r["T_OrderHeaderID"]),
|
||||
"date" => $r["T_OrderHeaderDate"],
|
||||
"nolab" => $r["T_OrderHeaderLabNumber"],
|
||||
"nolabExt" => $r["T_OrderHeaderLabNumberExt"],
|
||||
"maxID" => "",
|
||||
"name" => $r["PatientName"],
|
||||
"isCito" => $r["T_OrderHeaderIsCito"]
|
||||
);
|
||||
if ($r["T_OrderHeaderIsCito"] == "Y") {
|
||||
if ($r["T_OrderHeaderID"] > $maxIDcito) {
|
||||
$maxIDcito = $r["T_OrderHeaderID"];
|
||||
}
|
||||
} else {
|
||||
if ($r["T_OrderHeaderID"] > $maxIDnormal) {
|
||||
$maxIDnormal = $r["T_OrderHeaderID"];
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($result as $idx => $r) {
|
||||
$result[$idx]["maxID"] = $maxIDcito . "|" . $maxIDnormal;
|
||||
}
|
||||
$resp["status"] = "OK";
|
||||
$resp["rows"] = $result;
|
||||
$this->reply($resp);
|
||||
}
|
||||
|
||||
function get_verif() {
|
||||
// OK, NOT_OK, NOT_APPLICABLE, NOT_IMPLEMENTED
|
||||
$param = $this->sys_input;
|
||||
$item = $param["item"];
|
||||
$orderDetailID = $param["orderDetailID"];
|
||||
$resp["status"] = "OK";
|
||||
$result = array();
|
||||
for($i=0;$i<7;$i++) {
|
||||
$result[$i] = rand(0,3);
|
||||
}
|
||||
$resp["result"] = $result;
|
||||
sleep(3);
|
||||
$this->reply($resp);
|
||||
|
||||
|
||||
}
|
||||
function detail()
|
||||
{
|
||||
$resp = array("status" => "ERR", "message" => "", "rows" => array());
|
||||
|
||||
$param = $this->sys_input;
|
||||
|
||||
$id = $param["id"];
|
||||
$sql = "select T_OrderDetailID,
|
||||
T_OrderDetailT_TestName, T_OrderDetailResult,
|
||||
ifnull(T_OrderDetailNat_UnitName,'') T_OrderDetailUnitName,
|
||||
ifnull(T_OrderDetailNote,'') T_OrderDetailNote,
|
||||
T_OrderDetailResultFlag, T_OrderDetailVerification,
|
||||
ifnull(T_OrderDetailNormalValueNote,'') T_OrderDetailNormalValueNote,
|
||||
T_OrderdetailNat_MethodeName
|
||||
from
|
||||
t_orderdetail where T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailT_TestIsResult = 'Y'
|
||||
and T_OrderDetailResult <> ''
|
||||
order by T_OrderDetailT_TestSasCode
|
||||
";
|
||||
$qry = $this->db->query($sql, array($id));
|
||||
if (!$qry) {
|
||||
$resp["message"] = "ERR : " . $this->db->error()["message"] . "|"
|
||||
. $this->db->last_query();
|
||||
$this->reply($resp);
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$resp["status"] = "OK";
|
||||
$resp["rows"] = $rows;
|
||||
$this->reply($resp);
|
||||
}
|
||||
}
|
||||
0
application/controllers/bdtools/Superarmor.php
Normal file
0
application/controllers/bdtools/Superarmor.php
Normal file
12
application/controllers/biodata-confirm/Biodataconfirm.http
Normal file
12
application/controllers/biodata-confirm/Biodataconfirm.http
Normal file
@@ -0,0 +1,12 @@
|
||||
POST http://{{host}}/biodata-confirm/biodataconfirm/search/
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"startdate": "2024-05-07",
|
||||
"enddate": "2024-05-08",
|
||||
"search": "",
|
||||
"companyid": 0,
|
||||
"mou_id": 0,
|
||||
"current_page": 1,
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM0MCIsIk1fVXNlclVzZXJuYW1lIjoiYWRtaW5zYXMgIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI1IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMCIsIk1fU3RhZmZOYW1lIjoiQURNSU4iLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjEyMCIsImlwIjoiMTM5LjE5Mi4xNzAuNzciLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdFwvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lXC8xMjIuMC4wLjAgU2FmYXJpXC81MzcuMzYgRWRnXC8xMjIuMC4wLjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNC0wMy0yOCAwODoxOToxMSIsIk1fU2F0ZWxsaXRlSUQiOjB9.I5GrVzvfn1Puhszy5rSCIk0hTwsGXm7GtmoSXhLhp8A"
|
||||
}
|
||||
568
application/controllers/biodata-confirm/Biodataconfirm.php
Normal file
568
application/controllers/biodata-confirm/Biodataconfirm.php
Normal file
@@ -0,0 +1,568 @@
|
||||
<?php
|
||||
class Biodataconfirm extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// db wilayah contoh surabaya
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "request upload biodata";
|
||||
}
|
||||
|
||||
// search dibawah ini dengan proteksi lunas
|
||||
// pas di listing ketambahan WHERE
|
||||
// (F_OrderheaderLunas = Y
|
||||
// OR M_MouIsBill = Y)
|
||||
// AND T_OrderHeaderID ada di tabel result_processtooffice
|
||||
// update code tanggal 20-07-2023
|
||||
|
||||
public function search()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
$mouID = $prm["mou_id"];
|
||||
|
||||
$where_company = "";
|
||||
|
||||
$companyid = $prm['companyid'];
|
||||
if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
$companyid = $prm['companyid'];
|
||||
$where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
}
|
||||
if (isset($prm['mou_id'])) {
|
||||
# code...
|
||||
if (
|
||||
$mouID != "" || $mouID != 0 || $mouID != "0"
|
||||
) {
|
||||
$mouID = $prm['mou_id'];
|
||||
$where_company .= " AND M_MouID = $mouID";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$where = "";
|
||||
|
||||
$startdate = $prm['startdate'];
|
||||
$enddate = $prm['enddate'];
|
||||
|
||||
$filter_date = " DATE(T_OrderHeaderDate) BETWEEN '{$startdate}' AND '{$enddate}'";
|
||||
if ($startdate != '' && $enddate != '') {
|
||||
$where = "$filter_date ";
|
||||
}
|
||||
|
||||
if ($search != '') {
|
||||
$where .= " AND ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' ) ";
|
||||
}
|
||||
|
||||
$sortBy = $prm['sortBy'];
|
||||
// $sortStatus = $prm['sortStatus'];
|
||||
$q_sort = '';
|
||||
$limit = '';
|
||||
if ($sortBy) {
|
||||
$q_sort = "ORDER BY " . $sortBy;
|
||||
}
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "select count(*) as total
|
||||
from (
|
||||
select
|
||||
BiodataConfirmID,
|
||||
BiodataConfirmRetry,
|
||||
BiodataConfirmStatus,
|
||||
DATE_FORMAT(BiodataConfirmCreated, '%d-%m-%Y %H:%i:%s') AS BiodataConfirmCreated,
|
||||
DATE_FORMAT(BiodataConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS BiodataConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join biodata_confirm
|
||||
ON T_OrderHeaderID = BiodataConfirmT_OrderHeaderID
|
||||
AND BiodataConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join t_orderdelivery
|
||||
ON T_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID
|
||||
join m_deliverytype
|
||||
ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
AND M_DeliveryTypeCode = 'ERESULT'
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
BiodataConfirmID,
|
||||
BiodataConfirmRetry,
|
||||
BiodataConfirmStatus,
|
||||
DATE_FORMAT(BiodataConfirmCreated, '%d-%m-%Y %H:%i:%s') AS BiodataConfirmCreated,
|
||||
DATE_FORMAT(BiodataConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS BiodataConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
left join biodata_confirm
|
||||
ON T_OrderHeaderID = BiodataConfirmT_OrderHeaderID
|
||||
AND BiodataConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join t_orderdelivery
|
||||
ON T_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID
|
||||
join m_deliverytype
|
||||
ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
AND M_DeliveryTypeCode = 'ERESULT'
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
|
||||
$query_filter = $this->db->query($sql_filter);
|
||||
// $last_qry = $this->db->last_query();
|
||||
// print_r($last_qry);
|
||||
// exit;
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request upload biodata count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql_data = "
|
||||
select
|
||||
BiodataConfirmID,
|
||||
BiodataConfirmRetry,
|
||||
BiodataConfirmStatus,
|
||||
DATE_FORMAT(BiodataConfirmCreated, '%d-%m-%Y %H:%i:%s') AS BiodataConfirmCreated,
|
||||
DATE_FORMAT(BiodataConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS BiodataConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join biodata_confirm
|
||||
ON T_OrderHeaderID = BiodataConfirmT_OrderHeaderID
|
||||
AND BiodataConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join t_orderdelivery
|
||||
ON T_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID
|
||||
join m_deliverytype
|
||||
ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
AND M_DeliveryTypeCode = 'ERESULT'
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
BiodataConfirmID,
|
||||
BiodataConfirmRetry,
|
||||
BiodataConfirmStatus,
|
||||
DATE_FORMAT(BiodataConfirmCreated, '%d-%m-%Y %H:%i:%s') AS BiodataConfirmCreated,
|
||||
DATE_FORMAT(BiodataConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS BiodataConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
left join biodata_confirm
|
||||
ON T_OrderHeaderID = BiodataConfirmT_OrderHeaderID
|
||||
AND BiodataConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join t_orderdelivery
|
||||
ON T_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID
|
||||
join m_deliverytype
|
||||
ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
AND M_DeliveryTypeCode = 'ERESULT'
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db->query($sql_data);
|
||||
//echo $this->db->last_query();
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request upload biodata select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query(),
|
||||
"sql_data" => ($sql_data),
|
||||
"sql_filter" => ($sql_filter)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// proses insert log
|
||||
public function proses_insert_one_result_log($OneResultConfirmStatus, $OneResultLogOneResultConfirmID)
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
|
||||
$sql_insert = "INSERT INTO one_result_log(
|
||||
OneResultLogAction,
|
||||
OneResultLogM_UserID,
|
||||
OneResultLogDate,
|
||||
OneResultLogOneResultConfirmID
|
||||
) values (
|
||||
?,
|
||||
?,
|
||||
NOW(),
|
||||
?
|
||||
)";
|
||||
|
||||
$qry = $this->db->query(
|
||||
$sql_insert,
|
||||
[
|
||||
$OneResultConfirmStatus,
|
||||
$userID,
|
||||
$OneResultLogOneResultConfirmID
|
||||
]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert one_result_log | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
return $this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// proses confirm
|
||||
public function process_confirm()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$OneResultConfirmT_OrderHeaderID = $prm['OneResultConfirmT_OrderHeaderID'];
|
||||
|
||||
$sql_insert = "INSERT INTO one_result_confirm(
|
||||
OneResultConfirmT_OrderHeaderID,
|
||||
OneResultConfirmStatus,
|
||||
OneResultConfirmM_UserID,
|
||||
OneResultConfirmCreated
|
||||
) values (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
|
||||
$qry = $this->db->query(
|
||||
$sql_insert,
|
||||
[
|
||||
$OneResultConfirmT_OrderHeaderID,
|
||||
"C",
|
||||
$userID
|
||||
]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert one_result_confirm | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$OneResultLogOneResultConfirmID = $this->db->insert_id();
|
||||
|
||||
// Confirmed
|
||||
$OneResultConfirmStatus = "C";
|
||||
$this->proses_insert_one_result_log($OneResultConfirmStatus, $OneResultLogOneResultConfirmID);
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
// $result = array(
|
||||
// "total" => 1 ,
|
||||
// "records" => $prm
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// proses reupload
|
||||
public function process_reupload()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$BiodataConfirmID = $prm['BiodataConfirmID'];
|
||||
|
||||
$sql_update = "UPDATE biodata_confirm
|
||||
SET
|
||||
BiodataConfirmStatus = ?,
|
||||
BiodataConfirmRetry = ?,
|
||||
BiodataConfirmLastUpdated = NOW()
|
||||
WHERE BiodataConfirmID = ?";
|
||||
|
||||
$qry = $this->db->query(
|
||||
$sql_update,
|
||||
[
|
||||
"R",
|
||||
"0",
|
||||
$BiodataConfirmID,
|
||||
]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "update biodata_confirm | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// autocomplete M_CompanyID
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
|
||||
$sql = "Select M_CompanyID, M_CompanyName
|
||||
from m_company
|
||||
where M_CompanyName like ?
|
||||
and M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName DESC";
|
||||
$query = $this->db->query($sql, array($qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("", $this->db);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua");
|
||||
$result = array("data" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
public function search_mou()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
$companyID = $prm["company_id"];
|
||||
|
||||
$sql = "SELECT
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
M_MouM_CompanyID
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouM_CompanyID = ?
|
||||
AND M_MouName LIKE ?
|
||||
AND M_MouIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, array($companyID, $qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("", $this->db);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_MouID" => 0, "M_MouName" => "Semua", "M_MouM_CompanyID" => 0);
|
||||
$result = array("data" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
6
application/controllers/biodata-confirm/Getorder.http
Normal file
6
application/controllers/biodata-confirm/Getorder.http
Normal file
@@ -0,0 +1,6 @@
|
||||
POST http://{{host}}/biodata-confirm/getorder/getdata/
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
232
application/controllers/biodata-confirm/Getorder.php
Normal file
232
application/controllers/biodata-confirm/Getorder.php
Normal file
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
class Getorder extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// db wilayah contoh surabaya
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "GET BIODATA";
|
||||
}
|
||||
|
||||
public function getdata()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
$limit = 10;
|
||||
if (isset($prm['limit'])) {
|
||||
$limit = trim($prm["limit"]);
|
||||
$limit = $prm['limit'];
|
||||
}
|
||||
$sql = "SELECT
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
BiodataConfirmStatus,
|
||||
BiodataConfirmRetry
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join biodata_confirm
|
||||
ON T_OrderHeaderID = BiodataConfirmT_OrderHeaderID
|
||||
AND BiodataConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
AND (M_PatientIDNumber <> '' AND M_PatientIDNumber IS NOT NULL)
|
||||
AND (M_PatientHP <> '' AND M_PatientHP IS NOT NULL AND M_PatientHP <> '-')
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join t_orderdelivery
|
||||
ON T_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID
|
||||
join m_deliverytype
|
||||
ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
AND M_DeliveryTypeCode = 'ERESULT'
|
||||
WHERE BiodataConfirmStatus IS NULL OR (BiodataConfirmStatus = 'R' OR BiodataConfirmStatus = 'E') AND BiodataConfirmRetry < 10
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
BiodataConfirmStatus,
|
||||
BiodataConfirmRetry
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
left join biodata_confirm
|
||||
ON T_OrderHeaderID = BiodataConfirmT_OrderHeaderID
|
||||
AND BiodataConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
AND (M_PatientIDNumber <> '' AND M_PatientIDNumber IS NOT NULL)
|
||||
AND (M_PatientHP <> '' AND M_PatientHP IS NOT NULL AND M_PatientHP <> '-')
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join t_orderdelivery
|
||||
ON T_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID
|
||||
join m_deliverytype
|
||||
ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
AND M_DeliveryTypeCode = 'ERESULT'
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
WHERE BiodataConfirmStatus IS NULL OR (BiodataConfirmStatus = 'R' OR BiodataConfirmStatus = 'E') AND BiodataConfirmRetry < 10
|
||||
group by T_OrderHeaderID
|
||||
limit $limit";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$query) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok($rows);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function update_status()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
$id = 0;
|
||||
if (isset($prm['id'])) {
|
||||
$id = trim($prm["id"]);
|
||||
$id = $prm['id'];
|
||||
}
|
||||
$status = "A";
|
||||
if (isset($prm['status'])) {
|
||||
$status = trim($prm["status"]);
|
||||
$status = $prm['status'];
|
||||
}
|
||||
|
||||
// print_r("$status & $id");
|
||||
// exit;
|
||||
|
||||
if ($id == 0) {
|
||||
$this->sys_error("ID mandatory !");
|
||||
exit;
|
||||
}
|
||||
if ($status == "A") {
|
||||
$this->sys_error("status mandatory !");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_retry = "SELECT BiodataConfirmRetry
|
||||
FROM biodata_confirm
|
||||
WHERE BiodataConfirmT_OrderHeaderID = ?";
|
||||
$query_retry = $this->db->query($sql_retry, [$id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$query_retry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$retry = intval($query_retry->result_array()[0]['BiodataConfirmRetry']) + 1;
|
||||
// print_r(
|
||||
// array(
|
||||
// "retrydb" => $query_retry->result_array()[0]['OneResultConfirmRetry'],
|
||||
// "retry + 1" => $query_retry->result_array()[0]['OneResultConfirmRetry'] + 1,
|
||||
// "resp" => $query_retry->result_array(),
|
||||
// "last_qry" => $this->db->last_query(),
|
||||
// "retry_var" => $retry
|
||||
// )
|
||||
|
||||
// );
|
||||
// exit;
|
||||
|
||||
if (count($query_retry->result_array()) > 0) {
|
||||
if ($status == "E") {
|
||||
|
||||
$sql = "UPDATE biodata_confirm SET
|
||||
BiodataConfirmStatus = 'E'
|
||||
,BiodataConfirmRetry = ?
|
||||
,BiodataConfirmLastUpdated = ?
|
||||
WHERE BiodataConfirmT_OrderHeaderID = ?";
|
||||
$query = $this->db->query($sql, [$retry, date("Y-m-d H:i:s"), $id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$query) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
} else if ($status == "S") {
|
||||
$sql = "UPDATE biodata_confirm SET
|
||||
BiodataConfirmStatus = 'S'
|
||||
WHERE BiodataConfirmT_OrderHeaderID = ?";
|
||||
$query = $this->db->query($sql, [$id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$query) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = array(
|
||||
"message" => "ID not found",
|
||||
);
|
||||
$this->sys_error($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_ok("OK");
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
14
application/controllers/biodata-confirm/Uploaderbiodata.http
Normal file
14
application/controllers/biodata-confirm/Uploaderbiodata.http
Normal file
@@ -0,0 +1,14 @@
|
||||
POST http://{{host}}/biodata-confirm/uploaderbiodata/process/132160
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
###
|
||||
POST http://{{host}}/biodata-confirm/uploaderbiodata/update/132160/E
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
415
application/controllers/biodata-confirm/Uploaderbiodata.php
Normal file
415
application/controllers/biodata-confirm/Uploaderbiodata.php
Normal file
@@ -0,0 +1,415 @@
|
||||
<?php
|
||||
class Uploaderbiodata extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function get_param()
|
||||
{
|
||||
$raw = file_get_contents("php://input");
|
||||
return json_decode($raw, true);
|
||||
}
|
||||
function get_company($companyID)
|
||||
{
|
||||
$sql = "select M_CompanyID, M_CompanyOldID, M_BranchID M_CompanyM_BranchID, M_CompanyName, M_CompanyNumber,
|
||||
M_CompanyIDParent, M_CompanyM_CompanyTypeID, M_CompanyM_CompanyBusinessID,
|
||||
M_CompanyM_ProvinceID, M_CompanyM_CityID, M_CompanyM_DistrictID, M_CompanyM_KelurahanID,
|
||||
M_CompanyAddress, M_CompanyPhone, M_CompanyFax, M_CompanyEmail, M_CompanyPIC,
|
||||
M_CompanyM_StaffID, M_CompanyNat_CompanyLevelID, M_CompanyNat_HierarchyID,
|
||||
M_CompanyIsLabFrom, M_CompanyIsLabTo, M_CompanyIsDefault, M_CompanyM_DoctorID,
|
||||
M_CompanyCreated, M_CompanyLastUpdated, M_CompanyIsActive, M_CompanyAddressLocation,
|
||||
M_CompanyHp, M_CompanyPrivateRequest
|
||||
from m_company
|
||||
join m_branch on M_CompanyID = ?
|
||||
and M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'";
|
||||
$qry = $this->db->query($sql, [$companyID]);
|
||||
if (!$qry) {
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
])
|
||||
);
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "OK",
|
||||
"data" => $rows,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//Get Detail Mou
|
||||
function reply_gz($resp)
|
||||
{
|
||||
echo gzcompress($resp);
|
||||
exit();
|
||||
}
|
||||
function get_branch()
|
||||
{
|
||||
$sql =
|
||||
"select M_BranchID,M_BranchCode from m_branch where M_BranchIsActive='Y' and M_BranchIsDefault ='Y'";
|
||||
$resp = $this->get_row($sql);
|
||||
if ($resp["status"] != 1) {
|
||||
echo json_encode($resp);
|
||||
exit();
|
||||
}
|
||||
return [$resp["data"]["M_BranchID"], $resp["data"]["M_BranchCode"]];
|
||||
}
|
||||
function log($msg)
|
||||
{
|
||||
$dt = date("Y-m-d H:i:s");
|
||||
echo "$dt $msg\n";
|
||||
}
|
||||
function error_reply_gz($msg)
|
||||
{
|
||||
echo gzcompress(json_encode(["status" => "ERR", "message" => $msg]));
|
||||
}
|
||||
function reply($resp, $type = 1)
|
||||
{
|
||||
echo json_encode($resp);
|
||||
}
|
||||
function error_reply($msg)
|
||||
{
|
||||
echo json_encode(["status" => "ERR", "message" => $msg]);
|
||||
}
|
||||
|
||||
function getCompanyNumber($companyID)
|
||||
{
|
||||
$sql = "select M_CompanyNumber from m_company where M_CompanyID = ?";
|
||||
$resp = $this->get_row($sql, [$companyID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply(
|
||||
"Err Get Company from $companyID: " . $resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
return "";
|
||||
}
|
||||
$r = $resp["data"];
|
||||
return $r["M_CompanyNumber"];
|
||||
}
|
||||
//
|
||||
|
||||
|
||||
|
||||
function process($headerID)
|
||||
{
|
||||
// branch
|
||||
$sql_get_branch = "
|
||||
select IFNULL(M_BranchID,'') as M_BranchID,
|
||||
IFNULL(M_BranchCode,'') as M_BranchCode,
|
||||
IFNULL(M_BranchName,'') as M_BranchName,
|
||||
IFNULL(S_RegionalID,'') as S_RegionalID,
|
||||
IFNULL(S_RegionalName,'') as S_RegionalName
|
||||
from m_branch
|
||||
LEFT JOIN s_regional ON S_RegionalID = M_BranchS_RegionalID
|
||||
WHERE M_BranchIsDefault='Y'
|
||||
AND M_BranchIsActive ='Y'
|
||||
";
|
||||
|
||||
$query_m_branch = $this->db->query($sql_get_branch);
|
||||
if (!$query_m_branch) {
|
||||
$this->db->trans_rollback();
|
||||
$message = $this->db->error();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows_branch = $query_m_branch->result_array();
|
||||
if (count($rows_branch) == 0) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error('Cabang Tidak Ketemu');
|
||||
exit;
|
||||
}
|
||||
|
||||
$branch_id = $rows_branch[0]['M_BranchID'];
|
||||
$branch_code = $rows_branch[0]['M_BranchCode'];
|
||||
$branch_name = $rows_branch[0]['M_BranchName'];
|
||||
$regional_id = $rows_branch[0]['S_RegionalID'];
|
||||
$regional_name = $rows_branch[0]['S_RegionalName'];
|
||||
|
||||
$sql_field = "SELECT
|
||||
T_OrderHeaderID,
|
||||
'{$branch_id}' as branch_id,
|
||||
'{$branch_code}' as branch_code,
|
||||
'{$branch_name}' as branch_name,
|
||||
'{$regional_id}' as regional_id,
|
||||
'{$regional_name}' as regional_name,
|
||||
M_PatientIDNumber as NIK,
|
||||
T_OrderHeaderLabNumber as NO_REG,
|
||||
M_PatientNoReg as PID,
|
||||
M_PatientHP as NO_HP,
|
||||
M_PatientID
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
AND M_PatientIsActive = 'Y'
|
||||
AND T_OrderHeaderID = ?
|
||||
LEFT JOIN biodata_confirm ON T_OrderHeaderID = BiodataConfirmT_OrderHeaderID
|
||||
AND (BiodataConfirmRetry < 10 OR BiodataConfirmRetry = 0)
|
||||
AND (BiodataConfirmIsActive = 'Y' OR BiodataConfirmIsActive = 0)
|
||||
WHERE BiodataConfirmStatus IS NULL OR (BiodataConfirmStatus = 'R' OR BiodataConfirmStatus = 'E')";
|
||||
|
||||
$qry_field = $this->db->query($sql_field, [$headerID]);
|
||||
if (!$qry_field) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("select biodata_confirm by order_id", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows_field = $qry_field->result_array();
|
||||
// print_r($rows_field);
|
||||
// exit;
|
||||
$result = [];
|
||||
if (count($rows_field) > 0) {
|
||||
$result = $rows_field;
|
||||
}
|
||||
|
||||
// m_patient
|
||||
$sql_m_patient_field = "SELECT *
|
||||
FROM m_patient
|
||||
WHERE M_PatientIsActive = 'Y'
|
||||
AND M_PatientID = ?";
|
||||
|
||||
$qry = $this->db->query($sql_m_patient_field, [$result[0]['M_PatientID']]);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("select m_patient by patientId", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows_m_patient = $qry->result_array();
|
||||
$m_patient_all = [];
|
||||
if (count($rows_m_patient) > 0) {
|
||||
$m_patient_all = $rows_m_patient;
|
||||
}
|
||||
|
||||
echo json_encode(
|
||||
[
|
||||
"status" => "OK",
|
||||
"message" => "Data Ditemukan",
|
||||
"T_OrderHeaderID" => $result[0]['T_OrderHeaderID'],
|
||||
'branch_id' => $result[0]['branch_id'],
|
||||
'branch_code' => $result[0]['branch_code'],
|
||||
'branch_name' => $result[0]['branch_name'],
|
||||
'regional_id' => $result[0]['regional_id'],
|
||||
'regional_name' => $result[0]['regional_name'],
|
||||
"NIK" => $result[0]['NIK'],
|
||||
"NO_REG" => $result[0]['NO_REG'],
|
||||
"PID" => $result[0]['PID'],
|
||||
"NO_HP" => $result[0]['NO_HP'],
|
||||
"M_PatientID" => $result[0]['M_PatientID'],
|
||||
"patient" => $m_patient_all[0],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
function update($orderheaderID, $status)
|
||||
{
|
||||
$sql_cek = "SELECT BiodataConfirmID,
|
||||
BiodataConfirmT_OrderHeaderID,
|
||||
BiodataConfirmStatus
|
||||
FROM biodata_confirm
|
||||
WHERE BiodataConfirmT_OrderHeaderID = ?";
|
||||
$qry_cek = $this->db->query($sql_cek, [$orderheaderID]);
|
||||
if (!$qry_cek) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("select biodata_confirm", $this->db);
|
||||
exit;
|
||||
}
|
||||
$row = $qry_cek->result_array();
|
||||
|
||||
if (count($row) > 0) {
|
||||
$sql_update = "UPDATE biodata_confirm SET
|
||||
BiodataConfirmT_OrderHeaderID = ?,
|
||||
BiodataConfirmStatus = ?,
|
||||
BiodataConfirmRetry = ?,
|
||||
BiodataConfirmLastUpdated = NOW()
|
||||
WHERE BiodataConfirmID = ?";
|
||||
$qry_update = $this->db->query($sql_update, [$orderheaderID, $status, '0', $row[0]['BiodataConfirmID']]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry_update) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql_insert = "INSERT INTO biodata_confirm (
|
||||
BiodataConfirmT_OrderHeaderID,
|
||||
BiodataConfirmStatus,
|
||||
BiodataConfirmRetry,
|
||||
BiodataConfirmCreated,
|
||||
BiodataConfirmLastUpdated)
|
||||
VALUES(?,?,'0',now(),now())";
|
||||
$qry_insert = $this->db->query($sql_insert, [$orderheaderID, $status]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry_insert) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
function get($url, $timeout = 60, $c_timeout = 5)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $c_timeout);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$result = curl_exec($ch);
|
||||
$err_msg = curl_error($ch);
|
||||
if ($err_msg != "") {
|
||||
return json_encode(["status" => "ERR", "message" => $err_msg]);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function get_mou($companyID)
|
||||
{
|
||||
$sql = "select M_MouID,M_MouName, M_MouNumber
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y' and M_MouM_CompanyID = ?";
|
||||
$resp = $this->get_rows($sql, [$companyID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply("Error Get MOU by Company $companyID");
|
||||
exit();
|
||||
}
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"data" => $resp["data"],
|
||||
]);
|
||||
}
|
||||
function step_debug($rows)
|
||||
{
|
||||
print_r($rows);
|
||||
exit();
|
||||
}
|
||||
function get_rows($sql, $param = false)
|
||||
{
|
||||
if ($param) {
|
||||
$qry = $this->db->query($sql, $param);
|
||||
} else {
|
||||
$qry = $this->db->query($sql);
|
||||
}
|
||||
if (!$qry) {
|
||||
return [
|
||||
"status" => -1,
|
||||
"message" =>
|
||||
$this->db->last_query() .
|
||||
"|" .
|
||||
$this->db->error()["message"],
|
||||
];
|
||||
}
|
||||
return ["status" => 0, "data" => $qry->result_array()];
|
||||
}
|
||||
function get_row($sql, $param = false)
|
||||
{
|
||||
$resp = $this->get_rows($sql, $param);
|
||||
if ($resp["status"] == -1) {
|
||||
return $resp;
|
||||
}
|
||||
if (count($resp["data"]) == 0) {
|
||||
return ["status" => 0, "message" => "Not found."];
|
||||
}
|
||||
return ["status" => 1, "data" => $resp["data"][0]];
|
||||
}
|
||||
|
||||
// get_field_m_patient_address_by_m_patient_id
|
||||
function get_field_m_patient_address_by_m_patient_id($M_PatientID)
|
||||
{
|
||||
// kolom fields
|
||||
$sql_m_patient_address_field = "SELECT *
|
||||
from m_patientaddress
|
||||
WHERE M_PatientAddressM_PatientID = ?";
|
||||
|
||||
$qry = $this->db->query($sql_m_patient_address_field, [$M_PatientID]);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("select m_patientaddress by patientId", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows_m_patient_address = $qry->result_array();
|
||||
// echo json_encode($result_header);
|
||||
|
||||
if (count($rows_m_patient_address) > 0) {
|
||||
return $rows_m_patient_address;
|
||||
}
|
||||
|
||||
return $rows_m_patient_address;
|
||||
}
|
||||
|
||||
// get_field_m_patient_by_m_patient_id
|
||||
function get_field_m_patient_by_m_patient_id($M_PatientID)
|
||||
{
|
||||
// kolom fields
|
||||
$sql_m_patient_field = "SELECT *
|
||||
from m_patient
|
||||
WHERE
|
||||
M_PatientIsActive = 'Y'
|
||||
AND M_PatientID = ?";
|
||||
|
||||
$qry = $this->db->query($sql_m_patient_field, [$M_PatientID]);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("select m_patient by patientId", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows_m_patient = $qry->result_array();
|
||||
|
||||
$result = [];
|
||||
if (count($rows_m_patient) > 0) {
|
||||
foreach ($rows_m_patient as $key => $value) {
|
||||
$result = $value;
|
||||
}
|
||||
|
||||
$data_address = $this->get_field_m_patient_address_by_m_patient_id($M_PatientID);
|
||||
$result['m_address_json'] = $data_address;
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// get_field_m_company_by_m_company_id
|
||||
function get_field_m_company_by_m_company_id($M_CompanyID)
|
||||
{
|
||||
// kolom fields
|
||||
$sql_m_company_field = "SELECT *
|
||||
from m_company
|
||||
WHERE M_CompanyID = ? AND M_CompanyIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql_m_company_field, [$M_CompanyID]);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("select m_company by companyId", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows_m_company = $qry->result_array();
|
||||
if (count($rows_m_company) > 0) {
|
||||
return $rows_m_company[0];
|
||||
}
|
||||
|
||||
return $rows_m_company;
|
||||
}
|
||||
}
|
||||
39
application/controllers/chart/Qr_polos.php
Normal file
39
application/controllers/chart/Qr_polos.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
class Qr_polos extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function pcr($nolab)
|
||||
{
|
||||
$img_qrcode = $this->post("http://localhost/charts/qrtext.php", $nolab);
|
||||
header("Content-type: image/png");
|
||||
echo $img_qrcode;
|
||||
exit;
|
||||
}
|
||||
public function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/text',
|
||||
'Content-Length: ' . strlen($data)
|
||||
)
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
|
||||
if (curl_error($ch) != "") {
|
||||
return "ERROR Accessing QrCode : " . curl_error($ch) . "\n";
|
||||
}
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
125
application/controllers/chart/The_qr.php
Normal file
125
application/controllers/chart/The_qr.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
class The_qr extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function get_one_row($sql, $param=false)
|
||||
{
|
||||
if ($param) {
|
||||
$qry = $this->db->query($sql, $param);
|
||||
} else {
|
||||
$qry = $this->db->query($sql);
|
||||
}
|
||||
if (!$qry) {
|
||||
return array("status" => -1);
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
return array("status" => 0);
|
||||
}
|
||||
return array("status" => 1 , "data" => $rows[0]);
|
||||
}
|
||||
public function get_rows($sql, $param=false)
|
||||
{
|
||||
if ($param) {
|
||||
$qry = $this->db->query($sql, $param);
|
||||
} else {
|
||||
$qry = $this->db->query($sql);
|
||||
}
|
||||
if (!$qry) {
|
||||
return array("status" => -1);
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
return array("status" => 0);
|
||||
}
|
||||
return array("status" => 1 , "data" => $rows);
|
||||
}
|
||||
public function v1($orderHeaderID, $date = "")
|
||||
{
|
||||
$sql = "call sp_rpt_t_hasil2(?,'admin')";
|
||||
$rs = $this->get_rows($sql, array($orderHeaderID));
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
if ($rs["status"] == -1) {
|
||||
echo "Error : sp_rpt | " . $this->db->error()["message"];
|
||||
exit;
|
||||
}
|
||||
if ($rs["status"] == 0) {
|
||||
echo "Error : No Order found.";
|
||||
exit;
|
||||
}
|
||||
$rows = $rs["data"];
|
||||
$r = $rows[0];
|
||||
$msg =<<<EOF
|
||||
{$r['T_OrderHeaderLabNumber']}
|
||||
{$r['M_PatientName']}
|
||||
EOF
|
||||
;
|
||||
$msg = trim($msg);
|
||||
$msg .= "\n";
|
||||
foreach ($rows as $r) {
|
||||
$msg .= $r["T_TestNameAA"] . " : " . $r["T_OrderDetailResult"] . "\n";
|
||||
}
|
||||
$img_qrcode = $this->post("http://localhost/charts/qrtext.php", $msg);
|
||||
header("Content-type: image/png");
|
||||
echo $img_qrcode;
|
||||
exit;
|
||||
}
|
||||
public function post($url, $data)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array(
|
||||
'Content-Type: application/text',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
if (curl_error($ch) != "") {
|
||||
return "ERROR Accessing QrCode\n";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function v2($orderHeaderID)
|
||||
{
|
||||
$this->load->library("Jwt");
|
||||
$sql = "call sp_rpt_t_hasil2(?,'admin')";
|
||||
$rs = $this->get_rows($sql, array($orderHeaderID));
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
if ($rs["status"] == -1) {
|
||||
echo "Error : sp_rpt | " . $this->db->error()["message"];
|
||||
exit;
|
||||
}
|
||||
if ($rs["status"] == 0) {
|
||||
echo "Error : No Order found.";
|
||||
exit;
|
||||
}
|
||||
$rows = $rs["data"];
|
||||
$r = $rows[0];
|
||||
$header = array(
|
||||
"nolab" => $r['T_OrderHeaderLabNumber'],
|
||||
"nama" => $r['M_PatientName'],
|
||||
"sampling" => $r['T_OrderSampleSamplingDate'] . " " . $r['T_OrderSampleSamplingTime'],
|
||||
"umur" => $r["Umur"]
|
||||
);
|
||||
$detail = array();
|
||||
foreach ($rows as $r) {
|
||||
$detail[] = array("px" => $r["T_TestNameAA"], "result" => $r["T_OrderDetailResult"]);
|
||||
}
|
||||
$secretToken = "--!!Super!!Suket#@!1231456";
|
||||
$j_result = json_encode(array("header" => $header, "detail" => $detail));
|
||||
|
||||
$jwtToken = JWT::encode($j_result, $secretToken);
|
||||
$url = "https://result.pramita.co.id/one-api/verify/do/$jwtToken";
|
||||
$img_qrcode = $this->post("http://localhost/charts/qrtext.php", $url);
|
||||
header("Content-type: image/png");
|
||||
echo $img_qrcode;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
788
application/controllers/confirm-result/Confirmresult.php
Normal file
788
application/controllers/confirm-result/Confirmresult.php
Normal file
@@ -0,0 +1,788 @@
|
||||
<?php
|
||||
class Confirmresult extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// db wilayah contoh surabaya
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
|
||||
// string database
|
||||
$this->db_str_doctor = 'one_doctor';
|
||||
$this->M_MouM_CompanyID = "1235";
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "request upload";
|
||||
}
|
||||
|
||||
// search v1 tanpa proteksi lunas dan ini yang lama
|
||||
public function search_v1()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
// if (isset($prm['search'])) {
|
||||
// $search = trim($prm["search"]);
|
||||
// if ($search != "") {
|
||||
// $search = '%' . $prm['search'] . '%';
|
||||
// }else{
|
||||
// $search = '%%';
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
$where = " T_OrderHeaderIsActive = 'Y' ";
|
||||
|
||||
$startdate = $prm['startdate'];
|
||||
$enddate = $prm['enddate'];
|
||||
|
||||
$filter_date = " AND DATE(T_OrderHeaderDate) BETWEEN '{$startdate}' AND '{$enddate}'";
|
||||
if ($startdate != '' && $enddate != '') {
|
||||
$where = " T_OrderHeaderIsActive = 'Y' $filter_date ";
|
||||
}
|
||||
|
||||
if ($search != '')
|
||||
$where .= " AND ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' )";
|
||||
|
||||
|
||||
$sortBy = $prm['sortBy'];
|
||||
// $sortStatus = $prm['sortStatus'];
|
||||
$q_sort = '';
|
||||
$limit = '';
|
||||
if ($sortBy) {
|
||||
$q_sort = "ORDER BY " . $sortBy;
|
||||
}
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "select count(*) as total
|
||||
from (
|
||||
select
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
)
|
||||
as nama_pasien,
|
||||
fn_get_doctor_fullname($this->db_str_doctor.order_fo.OrderFoM_DoctorID) as nama_dokter,
|
||||
M_MouName as nama_mou,
|
||||
T_OrderHeaderTotal as total,
|
||||
if($this->db_str_doctor.request_upload.RequestUploadIsUploaded is NULL,'N',RequestUploadIsUploaded) as RequestIsUploaded
|
||||
from t_orderheader
|
||||
join $this->db_str_doctor.order_fo
|
||||
ON OrderFoT_OrderHeaderID = T_OrderHeaderID
|
||||
AND OrderFoIsActive = 'Y'
|
||||
join $this->db_str_doctor.order_patient
|
||||
ON OrderFoOrderPatientID = OrderPatientID
|
||||
AND OrderPatientIsActive = 'Y'
|
||||
left join $this->db_str_doctor.request_upload
|
||||
ON T_OrderHeaderID = RequestUploadT_OrderHeaderID
|
||||
AND RequestUploadIsActive = 'Y'
|
||||
AND RequestUploadIsUploaded = 'N'
|
||||
join m_mou
|
||||
ON OrderFoM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouM_CompanyID = 1235
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
// $sql_param = array($search);
|
||||
// $total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
|
||||
$query_filter = $this->db->query($sql_filter);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql_data = "select
|
||||
ifnull(RequestUploadIsUploaded,'x') as RequestUploadIsUploaded,
|
||||
if(RequestUploadLastUpdated is null,'', DATE_FORMAT(RequestUploadLastUpdated,'%d-%m-%Y %H:%i'))
|
||||
as RequestUploadLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
OrderPatientID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
)
|
||||
as nama_pasien,
|
||||
fn_get_doctor_fullname($this->db_str_doctor.order_fo.OrderFoM_DoctorID) as nama_dokter,
|
||||
M_MouName as nama_mou,
|
||||
T_OrderHeaderTotal as total,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join $this->db_str_doctor.order_fo
|
||||
ON OrderFoT_OrderHeaderID = T_OrderHeaderID
|
||||
AND OrderFoIsActive = 'Y'
|
||||
join $this->db_str_doctor.order_patient
|
||||
ON OrderFoOrderPatientID = OrderPatientID
|
||||
AND OrderPatientIsActive = 'Y'
|
||||
left join $this->db_str_doctor.request_upload
|
||||
ON T_OrderHeaderID = RequestUploadT_OrderHeaderID
|
||||
AND RequestUploadIsActive = 'Y'
|
||||
AND RequestUploadIsUploaded = 'N'
|
||||
join m_mou
|
||||
ON OrderFoM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouM_CompanyID = 1235
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db->query($sql_data);
|
||||
//echo $this->db->last_query();
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload select");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
// $result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows, 'sql'=> $this->db->last_query());
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// search dibawah ini dengan proteksi lunas
|
||||
// pas di listing ketambahan WHERE
|
||||
// (F_OrderheaderLunas = Y
|
||||
// OR M_MouIsBill = Y)
|
||||
// AND T_OrderHeaderID ada di tabel result_processtooffice
|
||||
// update code tanggal 20-07-2023
|
||||
|
||||
public function search()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
$mouID = $prm["mou_id"];
|
||||
|
||||
// if (isset($prm['search'])) {
|
||||
// $search = trim($prm["search"]);
|
||||
// if ($search != "") {
|
||||
// $search = '%' . $prm['search'] . '%';
|
||||
// }else{
|
||||
// $search = '%%';
|
||||
// }
|
||||
// }
|
||||
|
||||
$where_company = "";
|
||||
|
||||
$companyid = $prm['companyid'];
|
||||
if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
$companyid = $prm['companyid'];
|
||||
$where_company = " AND M_MouM_CompanyID = $companyid";
|
||||
}
|
||||
if (isset($prm['mou_id'])) {
|
||||
# code...
|
||||
if (
|
||||
$mouID != "" || $mouID != 0 || $mouID != "0"
|
||||
) {
|
||||
$mouID = $prm['mou_id'];
|
||||
$where_company .= " AND M_MouID = $mouID";
|
||||
}
|
||||
}
|
||||
|
||||
// if (isset($prm['companyid'])) {
|
||||
// $companyid = trim($prm["companyid"]);
|
||||
// // selain all dan kosong
|
||||
// if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
// $companyid = $prm['companyid'];
|
||||
// $where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
// }else{
|
||||
// $where_company = "";
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
$where = "";
|
||||
|
||||
$startdate = $prm['startdate'];
|
||||
$enddate = $prm['enddate'];
|
||||
|
||||
$filter_date = " DATE(T_OrderHeaderDate) BETWEEN '{$startdate}' AND '{$enddate}'";
|
||||
if ($startdate != '' && $enddate != '') {
|
||||
$where = "$filter_date ";
|
||||
}
|
||||
|
||||
if ($search != '') {
|
||||
$where .= " AND ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' ) ";
|
||||
}
|
||||
|
||||
$sortBy = $prm['sortBy'];
|
||||
// $sortStatus = $prm['sortStatus'];
|
||||
$q_sort = '';
|
||||
$limit = '';
|
||||
if ($sortBy) {
|
||||
$q_sort = "ORDER BY " . $sortBy;
|
||||
}
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "select count(*) as total
|
||||
from (
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
|
||||
$query_filter = $this->db->query($sql_filter);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql_data = "
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db->query($sql_data);
|
||||
//echo $this->db->last_query();
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query(),
|
||||
"sql_data" => ($sql_data),
|
||||
"sql_filter" => ($sql_filter)
|
||||
);
|
||||
// $result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows, 'sql'=> $this->db->last_query());
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// proses insert log
|
||||
public function proses_insert_one_result_log($OneResultConfirmStatus, $OneResultLogOneResultConfirmID)
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
|
||||
$sql_insert = "INSERT INTO one_result_log(
|
||||
OneResultLogAction,
|
||||
OneResultLogM_UserID,
|
||||
OneResultLogDate,
|
||||
OneResultLogOneResultConfirmID
|
||||
) values (
|
||||
?,
|
||||
?,
|
||||
NOW(),
|
||||
?
|
||||
)";
|
||||
|
||||
$qry = $this->db->query(
|
||||
$sql_insert,
|
||||
[
|
||||
$OneResultConfirmStatus,
|
||||
$userID,
|
||||
$OneResultLogOneResultConfirmID
|
||||
]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert one_result_log | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
return $this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// proses confirm
|
||||
public function process_confirm()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$OneResultConfirmT_OrderHeaderID = $prm['OneResultConfirmT_OrderHeaderID'];
|
||||
|
||||
$sql_insert = "INSERT INTO one_result_confirm(
|
||||
OneResultConfirmT_OrderHeaderID,
|
||||
OneResultConfirmStatus,
|
||||
OneResultConfirmM_UserID,
|
||||
OneResultConfirmCreated
|
||||
) values (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
|
||||
$qry = $this->db->query(
|
||||
$sql_insert,
|
||||
[
|
||||
$OneResultConfirmT_OrderHeaderID,
|
||||
"C",
|
||||
$userID
|
||||
]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert one_result_confirm | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$OneResultLogOneResultConfirmID = $this->db->insert_id();
|
||||
|
||||
// Confirmed
|
||||
$OneResultConfirmStatus = "C";
|
||||
$this->proses_insert_one_result_log($OneResultConfirmStatus, $OneResultLogOneResultConfirmID);
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
// $result = array(
|
||||
// "total" => 1 ,
|
||||
// "records" => $prm
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// proses reupload
|
||||
public function process_reupload()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$OneResultConfirmID = $prm['OneResultConfirmID'];
|
||||
|
||||
$sql_update = "UPDATE one_result_confirm
|
||||
SET
|
||||
OneResultConfirmStatus = ?,
|
||||
OneResultConfirmRetry = ?,
|
||||
OneResultConfirmLastUpdated = NOW()
|
||||
WHERE OneResultConfirmID = ?";
|
||||
|
||||
$qry = $this->db->query(
|
||||
$sql_update,
|
||||
[
|
||||
"R",
|
||||
"0",
|
||||
$OneResultConfirmID,
|
||||
]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "update one_result_confirm | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Confirmed
|
||||
$OneResultConfirmStatus = "R";
|
||||
$this->proses_insert_one_result_log($OneResultConfirmStatus, $OneResultConfirmID);
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
// $result = array(
|
||||
// "total" => 1 ,
|
||||
// "records" => $prm
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// autocomplete M_CompanyID
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
|
||||
$sql = "Select M_CompanyID, M_CompanyName
|
||||
from m_company
|
||||
where M_CompanyName like ?
|
||||
and M_CompanyIsActive = 'Y'
|
||||
limit 0,30";
|
||||
$query = $this->db->query($sql, array($qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("", $this->db);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua");
|
||||
$result = array("data" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
public function search_mou()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
$companyID = $prm["company_id"];
|
||||
|
||||
$sql = "SELECT
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
M_MouM_CompanyID
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouM_CompanyID = ?
|
||||
AND M_MouName LIKE ?
|
||||
AND M_MouIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, array($companyID, $qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("", $this->db);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_MouID" => 0, "M_MouName" => "Semua", "M_MouM_CompanyID" => 0);
|
||||
$result = array("data" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
744
application/controllers/confirm-result/Confirmresult.php190224
Normal file
744
application/controllers/confirm-result/Confirmresult.php190224
Normal file
@@ -0,0 +1,744 @@
|
||||
<?php
|
||||
class Confirmresult extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// db wilayah contoh surabaya
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
|
||||
// string database
|
||||
$this->db_str_doctor = 'one_doctor';
|
||||
$this->M_MouM_CompanyID = "1235";
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "request upload";
|
||||
}
|
||||
|
||||
// search v1 tanpa proteksi lunas dan ini yang lama
|
||||
public function search_v1()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
// if (isset($prm['search'])) {
|
||||
// $search = trim($prm["search"]);
|
||||
// if ($search != "") {
|
||||
// $search = '%' . $prm['search'] . '%';
|
||||
// }else{
|
||||
// $search = '%%';
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
$where = " T_OrderHeaderIsActive = 'Y' ";
|
||||
|
||||
$startdate = $prm['startdate'];
|
||||
$enddate = $prm['enddate'];
|
||||
|
||||
$filter_date = " AND DATE(T_OrderHeaderDate) BETWEEN '{$startdate}' AND '{$enddate}'";
|
||||
if($startdate != '' && $enddate !=''){
|
||||
$where = " T_OrderHeaderIsActive = 'Y' $filter_date ";
|
||||
}
|
||||
|
||||
if($search != '')
|
||||
$where .= " AND ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' )";
|
||||
|
||||
|
||||
$sortBy = $prm['sortBy'];
|
||||
// $sortStatus = $prm['sortStatus'];
|
||||
$q_sort = '';
|
||||
$limit = '';
|
||||
if($sortBy){
|
||||
$q_sort = "ORDER BY ".$sortBy;
|
||||
}
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "select count(*) as total
|
||||
from (
|
||||
select
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
)
|
||||
as nama_pasien,
|
||||
fn_get_doctor_fullname($this->db_str_doctor.order_fo.OrderFoM_DoctorID) as nama_dokter,
|
||||
M_MouName as nama_mou,
|
||||
T_OrderHeaderTotal as total,
|
||||
if($this->db_str_doctor.request_upload.RequestUploadIsUploaded is NULL,'N',RequestUploadIsUploaded) as RequestIsUploaded
|
||||
from t_orderheader
|
||||
join $this->db_str_doctor.order_fo
|
||||
ON OrderFoT_OrderHeaderID = T_OrderHeaderID
|
||||
AND OrderFoIsActive = 'Y'
|
||||
join $this->db_str_doctor.order_patient
|
||||
ON OrderFoOrderPatientID = OrderPatientID
|
||||
AND OrderPatientIsActive = 'Y'
|
||||
left join $this->db_str_doctor.request_upload
|
||||
ON T_OrderHeaderID = RequestUploadT_OrderHeaderID
|
||||
AND RequestUploadIsActive = 'Y'
|
||||
AND RequestUploadIsUploaded = 'N'
|
||||
join m_mou
|
||||
ON OrderFoM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouM_CompanyID = 1235
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
// $sql_param = array($search);
|
||||
// $total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
|
||||
$query_filter = $this->db->query($sql_filter);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql_data = "select
|
||||
ifnull(RequestUploadIsUploaded,'x') as RequestUploadIsUploaded,
|
||||
if(RequestUploadLastUpdated is null,'', DATE_FORMAT(RequestUploadLastUpdated,'%d-%m-%Y %H:%i'))
|
||||
as RequestUploadLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
OrderPatientID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
)
|
||||
as nama_pasien,
|
||||
fn_get_doctor_fullname($this->db_str_doctor.order_fo.OrderFoM_DoctorID) as nama_dokter,
|
||||
M_MouName as nama_mou,
|
||||
T_OrderHeaderTotal as total,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join $this->db_str_doctor.order_fo
|
||||
ON OrderFoT_OrderHeaderID = T_OrderHeaderID
|
||||
AND OrderFoIsActive = 'Y'
|
||||
join $this->db_str_doctor.order_patient
|
||||
ON OrderFoOrderPatientID = OrderPatientID
|
||||
AND OrderPatientIsActive = 'Y'
|
||||
left join $this->db_str_doctor.request_upload
|
||||
ON T_OrderHeaderID = RequestUploadT_OrderHeaderID
|
||||
AND RequestUploadIsActive = 'Y'
|
||||
AND RequestUploadIsUploaded = 'N'
|
||||
join m_mou
|
||||
ON OrderFoM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouM_CompanyID = 1235
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db->query($sql_data);
|
||||
//echo $this->db->last_query();
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if(count($rows) > 0){
|
||||
$sql_dt = "";
|
||||
foreach($rows as $k => $v){
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if(!$xdt_test){
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
}else{
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload select");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_all"=>$tot_count,
|
||||
"total_filter"=>count($rows),
|
||||
"records" => $rows,
|
||||
"sql"=> $this->db->last_query()
|
||||
);
|
||||
// $result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows, 'sql'=> $this->db->last_query());
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// search dibawah ini dengan proteksi lunas
|
||||
// pas di listing ketambahan WHERE
|
||||
// (F_OrderheaderLunas = Y
|
||||
// OR M_MouIsBill = Y)
|
||||
// AND T_OrderHeaderID ada di tabel result_processtooffice
|
||||
// update code tanggal 20-07-2023
|
||||
|
||||
public function search()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
// if (isset($prm['search'])) {
|
||||
// $search = trim($prm["search"]);
|
||||
// if ($search != "") {
|
||||
// $search = '%' . $prm['search'] . '%';
|
||||
// }else{
|
||||
// $search = '%%';
|
||||
// }
|
||||
// }
|
||||
|
||||
$where_company = "";
|
||||
|
||||
$companyid = $prm['companyid'];
|
||||
if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
$companyid = $prm['companyid'];
|
||||
$where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
}
|
||||
|
||||
// if (isset($prm['companyid'])) {
|
||||
// $companyid = trim($prm["companyid"]);
|
||||
// // selain all dan kosong
|
||||
// if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
// $companyid = $prm['companyid'];
|
||||
// $where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
// }else{
|
||||
// $where_company = "";
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
$where = "";
|
||||
|
||||
$startdate = $prm['startdate'];
|
||||
$enddate = $prm['enddate'];
|
||||
|
||||
$filter_date = " DATE(T_OrderHeaderDate) BETWEEN '{$startdate}' AND '{$enddate}'";
|
||||
if($startdate != '' && $enddate !=''){
|
||||
$where = "$filter_date ";
|
||||
}
|
||||
|
||||
if($search != ''){
|
||||
$where .= " AND ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' ) ";
|
||||
}
|
||||
|
||||
$sortBy = $prm['sortBy'];
|
||||
// $sortStatus = $prm['sortStatus'];
|
||||
$q_sort = '';
|
||||
$limit = '';
|
||||
if($sortBy){
|
||||
$q_sort = "ORDER BY ".$sortBy;
|
||||
}
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "select count(*) as total
|
||||
from (
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
|
||||
$query_filter = $this->db->query($sql_filter);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql_data = "
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db->query($sql_data);
|
||||
//echo $this->db->last_query();
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if(count($rows) > 0){
|
||||
$sql_dt = "";
|
||||
foreach($rows as $k => $v){
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if(!$xdt_test){
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
}else{
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query(),
|
||||
"sql_data" => ($sql_data),
|
||||
"sql_filter" => ($sql_filter)
|
||||
);
|
||||
// $result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows, 'sql'=> $this->db->last_query());
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// proses insert log
|
||||
public function proses_insert_one_result_log($OneResultConfirmStatus, $OneResultLogOneResultConfirmID)
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
|
||||
$sql_insert = "INSERT INTO one_result_log(
|
||||
OneResultLogAction,
|
||||
OneResultLogM_UserID,
|
||||
OneResultLogDate,
|
||||
OneResultLogOneResultConfirmID
|
||||
) values (
|
||||
?,
|
||||
?,
|
||||
NOW(),
|
||||
?
|
||||
)";
|
||||
|
||||
$qry = $this->db->query($sql_insert,
|
||||
[
|
||||
$OneResultConfirmStatus,
|
||||
$userID,
|
||||
$OneResultLogOneResultConfirmID
|
||||
]);
|
||||
|
||||
if(!$qry){
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert one_result_log | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
return $this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// proses confirm
|
||||
public function process_confirm()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$OneResultConfirmT_OrderHeaderID = $prm['OneResultConfirmT_OrderHeaderID'];
|
||||
|
||||
$sql_insert = "INSERT INTO one_result_confirm(
|
||||
OneResultConfirmT_OrderHeaderID,
|
||||
OneResultConfirmStatus,
|
||||
OneResultConfirmM_UserID,
|
||||
OneResultConfirmCreated
|
||||
) values (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
|
||||
$qry = $this->db->query($sql_insert,
|
||||
[
|
||||
$OneResultConfirmT_OrderHeaderID,
|
||||
"C",
|
||||
$userID
|
||||
]);
|
||||
|
||||
if(!$qry){
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert one_result_confirm | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$OneResultLogOneResultConfirmID = $this->db->insert_id();
|
||||
|
||||
// Confirmed
|
||||
$OneResultConfirmStatus = "C";
|
||||
$this->proses_insert_one_result_log($OneResultConfirmStatus, $OneResultLogOneResultConfirmID);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
// $result = array(
|
||||
// "total" => 1 ,
|
||||
// "records" => $prm
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// proses reupload
|
||||
public function process_reupload()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$OneResultConfirmID = $prm['OneResultConfirmID'];
|
||||
|
||||
$sql_update = "UPDATE one_result_confirm
|
||||
SET
|
||||
OneResultConfirmStatus = ?,
|
||||
OneResultConfirmRetry = ?,
|
||||
OneResultConfirmLastUpdated = NOW()
|
||||
WHERE OneResultConfirmID = ?";
|
||||
|
||||
$qry = $this->db->query($sql_update,
|
||||
[
|
||||
"R",
|
||||
"0",
|
||||
$OneResultConfirmID,
|
||||
]);
|
||||
|
||||
if(!$qry){
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "update one_result_confirm | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Confirmed
|
||||
$OneResultConfirmStatus = "R";
|
||||
$this->proses_insert_one_result_log($OneResultConfirmStatus, $OneResultConfirmID);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
// $result = array(
|
||||
// "total" => 1 ,
|
||||
// "records" => $prm
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// autocomplete M_CompanyID
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
|
||||
$sql = "Select M_CompanyID, M_CompanyName
|
||||
from m_company
|
||||
where M_CompanyName like ?
|
||||
and M_CompanyIsActive = 'Y'
|
||||
limit 0,30";
|
||||
$query = $this->db->query($sql, array($qry) );
|
||||
if(!$query){
|
||||
$this->sys_error_db("", $this->db);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua");
|
||||
$result = array("data" => $rows );
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
860
application/controllers/confirm-result/Confirmresult_v2.php
Normal file
860
application/controllers/confirm-result/Confirmresult_v2.php
Normal file
@@ -0,0 +1,860 @@
|
||||
<?php
|
||||
class Confirmresult_v2 extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// db wilayah contoh surabaya
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
|
||||
// string database
|
||||
$this->db_str_doctor = 'one_doctor';
|
||||
$this->M_MouM_CompanyID = "1235";
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "request upload";
|
||||
}
|
||||
|
||||
// search v1 tanpa proteksi lunas dan ini yang lama
|
||||
public function search_v1()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
// if (isset($prm['search'])) {
|
||||
// $search = trim($prm["search"]);
|
||||
// if ($search != "") {
|
||||
// $search = '%' . $prm['search'] . '%';
|
||||
// }else{
|
||||
// $search = '%%';
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
$where = " T_OrderHeaderIsActive = 'Y' ";
|
||||
|
||||
$startdate = $prm['startdate'];
|
||||
$enddate = $prm['enddate'];
|
||||
|
||||
$filter_date = " AND DATE(T_OrderHeaderDate) BETWEEN '{$startdate}' AND '{$enddate}'";
|
||||
if ($startdate != '' && $enddate != '') {
|
||||
$where = " T_OrderHeaderIsActive = 'Y' $filter_date ";
|
||||
}
|
||||
|
||||
if ($search != '')
|
||||
$where .= " AND ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' )";
|
||||
|
||||
|
||||
$sortBy = $prm['sortBy'];
|
||||
// $sortStatus = $prm['sortStatus'];
|
||||
$q_sort = '';
|
||||
$limit = '';
|
||||
if ($sortBy) {
|
||||
$q_sort = "ORDER BY " . $sortBy;
|
||||
}
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "select count(*) as total
|
||||
from (
|
||||
select
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
)
|
||||
as nama_pasien,
|
||||
fn_get_doctor_fullname($this->db_str_doctor.order_fo.OrderFoM_DoctorID) as nama_dokter,
|
||||
M_MouName as nama_mou,
|
||||
T_OrderHeaderTotal as total,
|
||||
if($this->db_str_doctor.request_upload.RequestUploadIsUploaded is NULL,'N',RequestUploadIsUploaded) as RequestIsUploaded
|
||||
from t_orderheader
|
||||
join $this->db_str_doctor.order_fo
|
||||
ON OrderFoT_OrderHeaderID = T_OrderHeaderID
|
||||
AND OrderFoIsActive = 'Y'
|
||||
join $this->db_str_doctor.order_patient
|
||||
ON OrderFoOrderPatientID = OrderPatientID
|
||||
AND OrderPatientIsActive = 'Y'
|
||||
left join $this->db_str_doctor.request_upload
|
||||
ON T_OrderHeaderID = RequestUploadT_OrderHeaderID
|
||||
AND RequestUploadIsActive = 'Y'
|
||||
AND RequestUploadIsUploaded = 'N'
|
||||
join m_mou
|
||||
ON OrderFoM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
AND M_MouM_CompanyID = 1235
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
// $sql_param = array($search);
|
||||
// $total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
|
||||
$query_filter = $this->db->query($sql_filter);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql_data = "select
|
||||
ifnull(RequestUploadIsUploaded,'x') as RequestUploadIsUploaded,
|
||||
if(RequestUploadLastUpdated is null,'', DATE_FORMAT(RequestUploadLastUpdated,'%d-%m-%Y %H:%i'))
|
||||
as RequestUploadLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
OrderPatientID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
)
|
||||
as nama_pasien,
|
||||
fn_get_doctor_fullname($this->db_str_doctor.order_fo.OrderFoM_DoctorID) as nama_dokter,
|
||||
M_MouName as nama_mou,
|
||||
T_OrderHeaderTotal as total,
|
||||
'' as test
|
||||
from t_orderheader
|
||||
join $this->db_str_doctor.order_fo
|
||||
ON OrderFoT_OrderHeaderID = T_OrderHeaderID
|
||||
AND OrderFoIsActive = 'Y'
|
||||
join $this->db_str_doctor.order_patient
|
||||
ON OrderFoOrderPatientID = OrderPatientID
|
||||
AND OrderPatientIsActive = 'Y'
|
||||
left join $this->db_str_doctor.request_upload
|
||||
ON T_OrderHeaderID = RequestUploadT_OrderHeaderID
|
||||
AND RequestUploadIsActive = 'Y'
|
||||
AND RequestUploadIsUploaded = 'N'
|
||||
join m_mou
|
||||
ON OrderFoM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
AND M_MouM_CompanyID = 1235
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db->query($sql_data);
|
||||
//echo $this->db->last_query();
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload select");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
// $result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows, 'sql'=> $this->db->last_query());
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// search dibawah ini dengan proteksi lunas
|
||||
// pas di listing ketambahan WHERE
|
||||
// (F_OrderheaderLunas = Y
|
||||
// OR M_MouIsBill = Y)
|
||||
// AND T_OrderHeaderID ada di tabel result_processtooffice
|
||||
// update code tanggal 20-07-2023
|
||||
|
||||
public function search()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
$mouID = $prm["mou_id"];
|
||||
|
||||
// if (isset($prm['search'])) {
|
||||
// $search = trim($prm["search"]);
|
||||
// if ($search != "") {
|
||||
// $search = '%' . $prm['search'] . '%';
|
||||
// }else{
|
||||
// $search = '%%';
|
||||
// }
|
||||
// }
|
||||
|
||||
$where_company = "";
|
||||
|
||||
$companyid = $prm['companyid'];
|
||||
if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
$companyid = $prm['companyid'];
|
||||
$where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
}
|
||||
if (isset($prm['mou_id'])) {
|
||||
# code...
|
||||
if (
|
||||
$mouID != "" || $mouID != 0 || $mouID != "0"
|
||||
) {
|
||||
$mouID = $prm['mou_id'];
|
||||
$where_company .= " AND M_MouID = $mouID";
|
||||
}
|
||||
}
|
||||
|
||||
// if (isset($prm['companyid'])) {
|
||||
// $companyid = trim($prm["companyid"]);
|
||||
// // selain all dan kosong
|
||||
// if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
// $companyid = $prm['companyid'];
|
||||
// $where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
// }else{
|
||||
// $where_company = "";
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
$where = "";
|
||||
|
||||
$startdate = $prm['startdate'];
|
||||
$enddate = $prm['enddate'];
|
||||
|
||||
$filter_date = " DATE(T_OrderHeaderDate) BETWEEN '{$startdate}' AND '{$enddate}'";
|
||||
if ($startdate != '' && $enddate != '') {
|
||||
$where = "$filter_date ";
|
||||
}
|
||||
|
||||
if ($search != '') {
|
||||
$where .= " AND ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' ) ";
|
||||
}
|
||||
|
||||
$sortBy = $prm['sortBy'];
|
||||
// $sortStatus = $prm['sortStatus'];
|
||||
$q_sort = '';
|
||||
$limit = '';
|
||||
if ($sortBy) {
|
||||
$q_sort = "ORDER BY " . $sortBy;
|
||||
}
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "select count(*) as total
|
||||
from (
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join group_resultdetail on Group_ResultDetailT_TestID = T_OrderDetailT_TestID
|
||||
and T_OrderDetailIsActive = 'Y' and Group_ResultDetailIsActive = 'Y'
|
||||
and T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
join group_result on Group_ResultDetailGroup_ResultID = Group_ResultID
|
||||
join t_orderdelivery on T_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID and T_OrderDeliveryIsActive = 'Y'
|
||||
join m_deliverytype
|
||||
ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
AND M_DeliveryTypeCode = 'ERESULT'
|
||||
JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN result_processtooffice ON Result_ProcessToOfficeT_OrderPromiseID IN(SELECT T_OrderPromiseID FROM t_orderpromise WHERE T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID) AND
|
||||
T_OrderDeliveryID = Result_ProcessToOfficeT_OrderDeliveryID AND Result_ProcessToOfficeStatus = 'S'
|
||||
AND
|
||||
(( Result_ProcessToOfficeGroup_ResultID = T_OrderDetailT_TestID AND Group_ResultFlagPerTest = 'Y')
|
||||
or (Result_ProcessToOfficeGroup_ResultID = Group_ResultID AND Group_ResultFlagPerTest = 'N' ))
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
join group_resultdetail on Group_ResultDetailT_TestID = T_OrderDetailT_TestID
|
||||
and T_OrderDetailIsActive = 'Y' and Group_ResultDetailIsActive = 'Y'
|
||||
and T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
join group_result on Group_ResultDetailGroup_ResultID = Group_ResultID
|
||||
join t_orderdelivery on T_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID and T_OrderDeliveryIsActive = 'Y'
|
||||
join m_deliverytype
|
||||
ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
AND M_DeliveryTypeCode = 'ERESULT'
|
||||
JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN result_processtooffice ON Result_ProcessToOfficeT_OrderPromiseID IN(SELECT T_OrderPromiseID FROM t_orderpromise WHERE T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID) AND
|
||||
T_OrderDeliveryID = Result_ProcessToOfficeT_OrderDeliveryID AND Result_ProcessToOfficeStatus = 'S'
|
||||
AND
|
||||
(( Result_ProcessToOfficeGroup_ResultID = T_OrderDetailT_TestID AND Group_ResultFlagPerTest = 'Y')
|
||||
or (Result_ProcessToOfficeGroup_ResultID = Group_ResultID AND Group_ResultFlagPerTest = 'N' ))
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
|
||||
$query_filter = $this->db->query($sql_filter);
|
||||
// $last_qry = $this->db->last_query();
|
||||
// print_r($last_qry);
|
||||
// exit;
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql_data = " SELECT * FROM
|
||||
(select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
IF(M_PatientIDNumber IS NULL OR M_PatientIDNumber = '','-',M_PatientIDNumber) M_PatientIDNumber,
|
||||
IF(M_PatientHP IS NULL OR M_PatientHP = '' OR M_PatientHP = '-','-',M_PatientHP) M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName,
|
||||
IF (IFNULL(MAX(Result_ProcessToOfficeID),0) > 0 ,'Sudah Serah Terima','Belum Serah Terima') as serahterima,
|
||||
'Y' as lunas
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join group_resultdetail on Group_ResultDetailT_TestID = T_OrderDetailT_TestID
|
||||
and T_OrderDetailIsActive = 'Y' and Group_ResultDetailIsActive = 'Y'
|
||||
and T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
join group_result on Group_ResultDetailGroup_ResultID = Group_ResultID
|
||||
join t_orderdelivery on T_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID and T_OrderDeliveryIsActive = 'Y'
|
||||
join m_deliverytype
|
||||
ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
AND M_DeliveryTypeCode = 'ERESULT'
|
||||
JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN result_processtooffice ON Result_ProcessToOfficeT_OrderPromiseID IN(SELECT T_OrderPromiseID FROM t_orderpromise WHERE T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID) AND
|
||||
T_OrderDeliveryID = Result_ProcessToOfficeT_OrderDeliveryID AND Result_ProcessToOfficeStatus = 'S'
|
||||
AND
|
||||
(( Result_ProcessToOfficeGroup_ResultID = T_OrderDetailT_TestID AND Group_ResultFlagPerTest = 'Y')
|
||||
or (Result_ProcessToOfficeGroup_ResultID = Group_ResultID AND Group_ResultFlagPerTest = 'N' ))
|
||||
where $where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
OneResultConfirmID,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry,
|
||||
DATE_FORMAT(OneResultConfirmCreated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmCreated,
|
||||
DATE_FORMAT(OneResultConfirmLastUpdated, '%d-%m-%Y %H:%i:%s') AS OneResultConfirmLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
IF(M_PatientIDNumber IS NULL OR M_PatientIDNumber = '','-',M_PatientIDNumber) M_PatientIDNumber,
|
||||
IF(M_PatientHP IS NULL OR M_PatientHP = '' OR M_PatientHP = '-','-',M_PatientHP) M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName,
|
||||
IF (IFNULL(MAX(Result_ProcessToOfficeID),0) > 0 ,'Sudah Serah Terima','Belum Serah Terima') as serahterima,
|
||||
IFNULL(F_Payment_OrderHeaderIsLunas,'N') as lunas
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
$where_company
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
left join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
LEFT join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
join group_resultdetail on Group_ResultDetailT_TestID = T_OrderDetailT_TestID
|
||||
and T_OrderDetailIsActive = 'Y' and Group_ResultDetailIsActive = 'Y'
|
||||
and T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
join group_result on Group_ResultDetailGroup_ResultID = Group_ResultID
|
||||
join t_orderdelivery on T_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID and T_OrderDeliveryIsActive = 'Y'
|
||||
join m_deliverytype
|
||||
ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
AND M_DeliveryTypeCode = 'ERESULT'
|
||||
JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN result_processtooffice ON Result_ProcessToOfficeT_OrderPromiseID IN(SELECT T_OrderPromiseID FROM t_orderpromise WHERE T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID) AND
|
||||
T_OrderDeliveryID = Result_ProcessToOfficeT_OrderDeliveryID AND Result_ProcessToOfficeStatus = 'S'
|
||||
AND
|
||||
(( Result_ProcessToOfficeGroup_ResultID = T_OrderDetailT_TestID AND Group_ResultFlagPerTest = 'Y')
|
||||
or (Result_ProcessToOfficeGroup_ResultID = Group_ResultID AND Group_ResultFlagPerTest = 'N' ))
|
||||
where $where
|
||||
group by T_OrderHeaderID) a
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db->query($sql_data);
|
||||
//echo $this->db->last_query();
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("request_upload select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query(),
|
||||
"sql_data" => ($sql_data),
|
||||
"sql_filter" => ($sql_filter)
|
||||
);
|
||||
// $result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows, 'sql'=> $this->db->last_query());
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// proses insert log
|
||||
public function proses_insert_one_result_log($OneResultConfirmStatus, $OneResultLogOneResultConfirmID)
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
|
||||
$sql_insert = "INSERT INTO one_result_log(
|
||||
OneResultLogAction,
|
||||
OneResultLogM_UserID,
|
||||
OneResultLogDate,
|
||||
OneResultLogOneResultConfirmID
|
||||
) values (
|
||||
?,
|
||||
?,
|
||||
NOW(),
|
||||
?
|
||||
)";
|
||||
|
||||
$qry = $this->db->query(
|
||||
$sql_insert,
|
||||
[
|
||||
$OneResultConfirmStatus,
|
||||
$userID,
|
||||
$OneResultLogOneResultConfirmID
|
||||
]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert one_result_log | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
return $this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// proses confirm
|
||||
public function process_confirm()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$OneResultConfirmT_OrderHeaderID = $prm['OneResultConfirmT_OrderHeaderID'];
|
||||
|
||||
$sql_insert = "INSERT INTO one_result_confirm(
|
||||
OneResultConfirmT_OrderHeaderID,
|
||||
OneResultConfirmStatus,
|
||||
OneResultConfirmM_UserID,
|
||||
OneResultConfirmCreated
|
||||
) values (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
|
||||
$qry = $this->db->query(
|
||||
$sql_insert,
|
||||
[
|
||||
$OneResultConfirmT_OrderHeaderID,
|
||||
"C",
|
||||
$userID
|
||||
]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert one_result_confirm | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$OneResultLogOneResultConfirmID = $this->db->insert_id();
|
||||
|
||||
// Confirmed
|
||||
$OneResultConfirmStatus = "C";
|
||||
$this->proses_insert_one_result_log($OneResultConfirmStatus, $OneResultLogOneResultConfirmID);
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
// $result = array(
|
||||
// "total" => 1 ,
|
||||
// "records" => $prm
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// proses reupload
|
||||
public function process_reupload()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$OneResultConfirmID = $prm['OneResultConfirmID'];
|
||||
|
||||
$sql_update = "UPDATE one_result_confirm
|
||||
SET
|
||||
OneResultConfirmStatus = ?,
|
||||
OneResultConfirmRetry = ?,
|
||||
OneResultConfirmLastUpdated = NOW()
|
||||
WHERE OneResultConfirmID = ?";
|
||||
|
||||
$qry = $this->db->query(
|
||||
$sql_update,
|
||||
[
|
||||
"R",
|
||||
"0",
|
||||
$OneResultConfirmID,
|
||||
]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "update one_result_confirm | " .
|
||||
$this->db->error()["message"], "debug" => $this->db->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Confirmed
|
||||
$OneResultConfirmStatus = "R";
|
||||
$this->proses_insert_one_result_log($OneResultConfirmStatus, $OneResultConfirmID);
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
// $result = array(
|
||||
// "total" => 1 ,
|
||||
// "records" => $prm
|
||||
// );
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
// autocomplete M_CompanyID
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
|
||||
$sql = "Select M_CompanyID, M_CompanyName
|
||||
from m_company
|
||||
where M_CompanyName like ?
|
||||
and M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName DESC";
|
||||
$query = $this->db->query($sql, array($qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("", $this->db);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua");
|
||||
$result = array("data" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
public function search_mou()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["qry"] . '%';
|
||||
$companyID = $prm["company_id"];
|
||||
|
||||
$sql = "SELECT
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
M_MouM_CompanyID
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouM_CompanyID = ?
|
||||
AND M_MouName LIKE ?
|
||||
AND M_MouIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, array($companyID, $qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("", $this->db);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_MouID" => 0, "M_MouName" => "Semua", "M_MouM_CompanyID" => 0);
|
||||
$result = array("data" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
234
application/controllers/confirm-result/Getorder.php
Normal file
234
application/controllers/confirm-result/Getorder.php
Normal file
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
class Getorder extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// db wilayah contoh surabaya
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
|
||||
// string database
|
||||
$this->db_str_doctor = 'one_doctor';
|
||||
$this->M_MouM_CompanyID = "1235";
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "GET RESULT";
|
||||
}
|
||||
|
||||
public function getdata()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
$limit = 10;
|
||||
if (isset($prm['limit'])) {
|
||||
$limit = trim($prm["limit"]);
|
||||
$limit = $prm['limit'];
|
||||
}
|
||||
$sql = "SELECT
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
AND (M_PatientIDNumber <> '' AND M_PatientIDNumber IS NOT NULL)
|
||||
AND (M_PatientHP <> '' AND M_PatientHP IS NOT NULL AND M_PatientHP <> '-')
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join t_orderdelivery on T_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID and T_OrderDeliveryIsActive = 'Y'
|
||||
join m_deliverytype
|
||||
ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
AND M_DeliveryTypeCode = 'ERESULT'
|
||||
WHERE (OneResultConfirmStatus = 'C' OR OneResultConfirmStatus = 'R' OR OneResultConfirmStatus = 'E') AND OneResultConfirmRetry <= 5
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
AND (M_PatientIDNumber <> '' AND M_PatientIDNumber IS NOT NULL)
|
||||
AND (M_PatientHP <> '' AND M_PatientHP IS NOT NULL AND M_PatientHP <> '-')
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
join t_orderdelivery on T_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID and T_OrderDeliveryIsActive = 'Y'
|
||||
join m_deliverytype
|
||||
ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
AND M_DeliveryTypeCode = 'ERESULT'
|
||||
WHERE (OneResultConfirmStatus = 'C' OR OneResultConfirmStatus = 'R' OR OneResultConfirmStatus = 'E') AND OneResultConfirmRetry <= 5
|
||||
group by T_OrderHeaderID
|
||||
limit $limit";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$query) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok($rows);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function update_status()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
$id = 0;
|
||||
if (isset($prm['id'])) {
|
||||
$id = trim($prm["id"]);
|
||||
$id = $prm['id'];
|
||||
}
|
||||
$status = "A";
|
||||
if (isset($prm['status'])) {
|
||||
$status = trim($prm["status"]);
|
||||
$status = $prm['status'];
|
||||
}
|
||||
|
||||
// print_r("$status & $id");
|
||||
// exit;
|
||||
|
||||
if ($id == 0) {
|
||||
$this->sys_error("ID mandatory !");
|
||||
exit;
|
||||
}
|
||||
if ($status == "A") {
|
||||
$this->sys_error("status mandatory !");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_retry = "SELECT OneResultConfirmRetry
|
||||
FROM one_result_confirm
|
||||
WHERE OneResultConfirmT_OrderHeaderID = ?";
|
||||
$query_retry = $this->db->query($sql_retry, [$id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$query_retry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$retry = intval($query_retry->result_array()[0]['OneResultConfirmRetry']) + 1;
|
||||
// print_r(
|
||||
// array(
|
||||
// "retrydb" => $query_retry->result_array()[0]['OneResultConfirmRetry'],
|
||||
// "retry + 1" => $query_retry->result_array()[0]['OneResultConfirmRetry'] + 1,
|
||||
// "resp" => $query_retry->result_array(),
|
||||
// "last_qry" => $this->db->last_query(),
|
||||
// "retry_var" => $retry
|
||||
// )
|
||||
|
||||
// );
|
||||
// exit;
|
||||
|
||||
if (count($query_retry->result_array()) > 0) {
|
||||
if ($status == "E") {
|
||||
|
||||
$sql = "UPDATE one_result_confirm SET
|
||||
OneResultConfirmStatus = 'E'
|
||||
,OneResultConfirmRetry = ?
|
||||
,OneResultConfirmLastUpdated = ?
|
||||
WHERE OneResultConfirmT_OrderHeaderID = ?";
|
||||
$query = $this->db->query($sql, [$retry, date("Y-m-d H:i:s"), $id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$query) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
} else if ($status == "S") {
|
||||
$sql = "UPDATE one_result_confirm SET
|
||||
OneResultConfirmStatus = 'S'
|
||||
WHERE OneResultConfirmT_OrderHeaderID = ?";
|
||||
$query = $this->db->query($sql, [$id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$query) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = array(
|
||||
"message" => "ID not found",
|
||||
);
|
||||
$this->sys_error($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_ok("OK");
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
application/controllers/confirm-result/Or_dummy.php
Normal file
33
application/controllers/confirm-result/Or_dummy.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
class Or_dummy extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function svc()
|
||||
{
|
||||
$data = $this->get_param();
|
||||
$param = [
|
||||
"IncomingJSONData" => json_encode($data),
|
||||
"IncomingM_BranchID" => $data["branch_id"],
|
||||
"IncomingT_OrderHeaderID" => $data["T_OrderHeaderID"],
|
||||
];
|
||||
$qry = $this->db->insert("or_dummy.incoming", $param);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Err incoming " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
echo json_encode(["status" => "OK", "message" => ""]);
|
||||
}
|
||||
function get_param()
|
||||
{
|
||||
$zdata = file_get_contents("php://input");
|
||||
$data = gzuncompress($zdata);
|
||||
|
||||
return json_decode($data, true);
|
||||
}
|
||||
}
|
||||
1811
application/controllers/confirm-result/Uploaderconfirmresult.php
Normal file
1811
application/controllers/confirm-result/Uploaderconfirmresult.php
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
61
application/controllers/confirm_eform/Confirmeformx.http
Normal file
61
application/controllers/confirm_eform/Confirmeformx.http
Normal file
@@ -0,0 +1,61 @@
|
||||
POST http://{{host}}/confirm_eform/confirmeformx/index/
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM0MCIsIk1fVXNlclVzZXJuYW1lIjoiYWRtaW5zYXMgIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI1IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMCIsIk1fU3RhZmZOYW1lIjoiQURNSU4iLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjEyMCIsImlwIjoiMTM5LjE5Mi4xNzAuNzciLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdFwvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lXC8xMjIuMC4wLjAgU2FmYXJpXC81MzcuMzYgRWRnXC8xMjIuMC4wLjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNC0wMy0yOCAwODoxOToxMSIsIk1fU2F0ZWxsaXRlSUQiOjB9.I5GrVzvfn1Puhszy5rSCIk0hTwsGXm7GtmoSXhLhp8A"
|
||||
}
|
||||
|
||||
###
|
||||
# Branch
|
||||
POST http://{{host}}/confirm_eform/confirmeformx/search_company
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"search": "",
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM0MCIsIk1fVXNlclVzZXJuYW1lIjoiYWRtaW5zYXMgIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI1IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMCIsIk1fU3RhZmZOYW1lIjoiQURNSU4iLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjEyMCIsImlwIjoiMTM5LjE5Mi4xNzAuNzciLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdFwvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lXC8xMjIuMC4wLjAgU2FmYXJpXC81MzcuMzYgRWRnXC8xMjIuMC4wLjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNC0wMy0yOCAwODoxOToxMSIsIk1fU2F0ZWxsaXRlSUQiOjB9.I5GrVzvfn1Puhszy5rSCIk0hTwsGXm7GtmoSXhLhp8A"
|
||||
}
|
||||
|
||||
###
|
||||
# Aggrement
|
||||
POST http://{{host}}/confirm_eform/confirmeformx/search_mou
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"company_id": 7728,
|
||||
"search": "",
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM0MCIsIk1fVXNlclVzZXJuYW1lIjoiYWRtaW5zYXMgIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI1IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMCIsIk1fU3RhZmZOYW1lIjoiQURNSU4iLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjEyMCIsImlwIjoiMTM5LjE5Mi4xNzAuNzciLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdFwvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lXC8xMjIuMC4wLjAgU2FmYXJpXC81MzcuMzYgRWRnXC8xMjIuMC4wLjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNC0wMy0yOCAwODoxOToxMSIsIk1fU2F0ZWxsaXRlSUQiOjB9.I5GrVzvfn1Puhszy5rSCIk0hTwsGXm7GtmoSXhLhp8A"
|
||||
}
|
||||
|
||||
###
|
||||
# listing data tabel
|
||||
POST http://{{host}}/confirm_eform/confirmeformx/lookup
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"companyid": "7728",
|
||||
"mou_id": "2709",
|
||||
"date": "2024-06-25",
|
||||
"current_page": 1,
|
||||
"search": "",
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM0MCIsIk1fVXNlclVzZXJuYW1lIjoiYWRtaW5zYXMgIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI1IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMCIsIk1fU3RhZmZOYW1lIjoiQURNSU4iLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjEyMCIsImlwIjoiMTM5LjE5Mi4xNzAuNzciLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdFwvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lXC8xMjIuMC4wLjAgU2FmYXJpXC81MzcuMzYgRWRnXC8xMjIuMC4wLjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNC0wMy0yOCAwODoxOToxMSIsIk1fU2F0ZWxsaXRlSUQiOjB9.I5GrVzvfn1Puhszy5rSCIk0hTwsGXm7GtmoSXhLhp8A"
|
||||
}
|
||||
|
||||
###
|
||||
# Proses konfirmasi
|
||||
POST http://{{host}}/confirm_eform/confirmeformx/confirm
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"orderheaderID": "132199",
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM0MCIsIk1fVXNlclVzZXJuYW1lIjoiYWRtaW5zYXMgIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI1IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMCIsIk1fU3RhZmZOYW1lIjoiQURNSU4iLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjEyMCIsImlwIjoiMTM5LjE5Mi4xNzAuNzciLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdFwvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lXC8xMjIuMC4wLjAgU2FmYXJpXC81MzcuMzYgRWRnXC8xMjIuMC4wLjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNC0wMy0yOCAwODoxOToxMSIsIk1fU2F0ZWxsaXRlSUQiOjB9.I5GrVzvfn1Puhszy5rSCIk0hTwsGXm7GtmoSXhLhp8A"
|
||||
}
|
||||
|
||||
###
|
||||
# Proses reupload
|
||||
POST http://{{host}}/confirm_eform/confirmeformx/reupload
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"logconfirmeformID": "1",
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM0MCIsIk1fVXNlclVzZXJuYW1lIjoiYWRtaW5zYXMgIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI1IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMCIsIk1fU3RhZmZOYW1lIjoiQURNSU4iLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjEyMCIsImlwIjoiMTM5LjE5Mi4xNzAuNzciLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdFwvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lXC8xMjIuMC4wLjAgU2FmYXJpXC81MzcuMzYgRWRnXC8xMjIuMC4wLjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNC0wMy0yOCAwODoxOToxMSIsIk1fU2F0ZWxsaXRlSUQiOjB9.I5GrVzvfn1Puhszy5rSCIk0hTwsGXm7GtmoSXhLhp8A"
|
||||
}
|
||||
510
application/controllers/confirm_eform/Confirmeformx.php
Normal file
510
application/controllers/confirm_eform/Confirmeformx.php
Normal file
@@ -0,0 +1,510 @@
|
||||
<?php
|
||||
class Confirmeformx extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "API CONFIRM EFORM";
|
||||
// $cek = $this->db_onedev->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
}
|
||||
|
||||
function search_company()
|
||||
{
|
||||
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
|
||||
$sql = "SELECT M_CompanyID, M_CompanyName
|
||||
FROM m_company
|
||||
WHERE M_CompanyName LIKE ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName DESC";
|
||||
$query = $this->db_onedev->query($sql, array($qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select company error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua");
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_mou()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
$companyID = $prm["company_id"];
|
||||
|
||||
$sql = "SELECT
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
M_MouM_CompanyID
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouM_CompanyID = ?
|
||||
AND M_MouName LIKE ?
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsMcu = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, array($companyID, $qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select mou error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_MouID" => 0, "M_MouName" => "Semua", "M_MouM_CompanyID" => 0);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookup()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
$mouID = $prm["mou_id"];
|
||||
|
||||
$where_company = "";
|
||||
|
||||
$companyid = $prm['companyid'];
|
||||
if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
$companyid = $prm['companyid'];
|
||||
$where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
}
|
||||
if (isset($prm['mou_id'])) {
|
||||
# code...
|
||||
if (
|
||||
$mouID != "" || $mouID != 0 || $mouID != "0"
|
||||
) {
|
||||
$mouID = $prm['mou_id'];
|
||||
$where_company .= " AND M_MouID = $mouID";
|
||||
}
|
||||
}
|
||||
|
||||
$where = "";
|
||||
$date = $prm['date'];
|
||||
|
||||
$start_date = $date . " 00:00:00";
|
||||
$end_date = $date . " 23:59:59";
|
||||
|
||||
// $filter_date = " DATE(T_OrderHeaderDate) = '{$date}'";
|
||||
// if ($date != '') {
|
||||
// $where = "$filter_date ";
|
||||
// }
|
||||
|
||||
if ($search != '') {
|
||||
$where .= " WHERE ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' ) ";
|
||||
}
|
||||
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '),M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
-- AND T_OrderHeaderDate >= '{$start_date}'
|
||||
-- AND T_OrderHeaderDate <= '{$end_date}'
|
||||
AND DATE(T_OrderHeaderDate) = '{$date}'
|
||||
join so_testtemplate
|
||||
ON T_OrderDetailT_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
AND So_TemplateID IN (6,8,9)
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
-- AND T_OrderHeaderDate >= '{$start_date}'
|
||||
-- AND T_OrderHeaderDate <= '{$end_date}'
|
||||
AND DATE(T_OrderHeaderDate) = '{$date}'
|
||||
join so_testtemplate
|
||||
ON T_OrderDetailT_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
AND So_TemplateID IN (6,8,9)
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
|
||||
$query_filter = $this->db_onedev->query($sql_filter);
|
||||
// $last_qry = $this->db_onedev->last_query();
|
||||
// print_r($last_qry);
|
||||
// exit;
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_data = "SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
IFNULL(NULLIF(M_PatientHP, ''), '-') as M_PatientHP,
|
||||
IFNULL(NULLIF(M_PatientIDNumber,''),'-') as M_PatientIDNumber,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
-- AND T_OrderHeaderDate >= '{$start_date}'
|
||||
-- AND T_OrderHeaderDate <= '{$end_date}'
|
||||
AND DATE(T_OrderHeaderDate) = '{$date}'
|
||||
join so_testtemplate
|
||||
ON T_OrderDetailT_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
AND So_TemplateID IN (6,8,9)
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
IFNULL(NULLIF(M_PatientHP, ''), '-') as M_PatientHP,
|
||||
IFNULL(NULLIF(M_PatientIDNumber,''),'-') as M_PatientIDNumber,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
-- AND T_OrderHeaderDate >= '{$start_date}'
|
||||
-- AND T_OrderHeaderDate <= '{$end_date}'
|
||||
AND DATE(T_OrderHeaderDate) = '{$date}'
|
||||
join so_testtemplate
|
||||
ON T_OrderDetailT_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
AND So_TemplateID IN (6,8,9)
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db_onedev->query($sql_data);
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test,
|
||||
So_TemplateName
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
join so_testtemplate
|
||||
ON T_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
AND So_TemplateID IN (6,8,9)
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db_onedev->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query(),
|
||||
"sql_data" => ($sql_data),
|
||||
"sql_filter" => ($sql_filter)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function confirm()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$orderheaderID = $prm["orderheaderID"];
|
||||
|
||||
$sql = "INSERT INTO log_confirm_eform(
|
||||
LogConfirmEformT_OrderHeaderID,
|
||||
LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
LogConfirmEformCreated,
|
||||
LogConfirmEformLastUpdated,
|
||||
LogConfirmEformUserID) VALUES(?,?,?,NOW(),NOW(),?)";
|
||||
$qry = $this->db_onedev->query($sql, array($orderheaderID, "C", "0", $userID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function reupload()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$logconfirmeformID = $prm["logconfirmeformID"];
|
||||
|
||||
$sql = "UPDATE log_confirm_eform
|
||||
SET LogConfirmEformStatus = ?,
|
||||
LogConfirmEformRetry = ?,
|
||||
LogConfirmEformLastUpdated = NOW(),
|
||||
LogConfirmEformUserID = ?
|
||||
WHERE LogConfirmEformID = ?";
|
||||
$qry = $this->db_onedev->query($sql, array("R", "0", $userID, $logconfirmeformID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "update log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,470 @@
|
||||
<?php
|
||||
class Confirmeformx extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "API CONFIRM EFORM";
|
||||
// $cek = $this->db_onedev->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
}
|
||||
|
||||
function search_company()
|
||||
{
|
||||
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
|
||||
$sql = "SELECT M_CompanyID, M_CompanyName
|
||||
FROM m_company
|
||||
WHERE M_CompanyName LIKE ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName DESC";
|
||||
$query = $this->db_onedev->query($sql, array($qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select company error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua");
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_mou()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
$companyID = $prm["company_id"];
|
||||
|
||||
$sql = "SELECT
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
M_MouM_CompanyID
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouM_CompanyID = ?
|
||||
AND M_MouName LIKE ?
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsMcu = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, array($companyID, $qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select mou error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_MouID" => 0, "M_MouName" => "Semua", "M_MouM_CompanyID" => 0);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookup()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
$mouID = $prm["mou_id"];
|
||||
|
||||
$where_company = "";
|
||||
|
||||
$companyid = $prm['companyid'];
|
||||
if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
$companyid = $prm['companyid'];
|
||||
$where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
}
|
||||
if (isset($prm['mou_id'])) {
|
||||
# code...
|
||||
if (
|
||||
$mouID != "" || $mouID != 0 || $mouID != "0"
|
||||
) {
|
||||
$mouID = $prm['mou_id'];
|
||||
$where_company .= " AND M_MouID = $mouID";
|
||||
}
|
||||
}
|
||||
|
||||
$where = "";
|
||||
$date = $prm['date'];
|
||||
|
||||
$start_date = $date . " 00:00:00";
|
||||
$end_date = $date . " 23:59:59";
|
||||
|
||||
// $filter_date = " DATE(T_OrderHeaderDate) = '{$date}'";
|
||||
// if ($date != '') {
|
||||
// $where = "$filter_date ";
|
||||
// }
|
||||
|
||||
if ($search != '') {
|
||||
$where .= " WHERE ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' ) ";
|
||||
}
|
||||
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '),M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
|
||||
$query_filter = $this->db_onedev->query($sql_filter);
|
||||
// $last_qry = $this->db_onedev->last_query();
|
||||
// print_r($last_qry);
|
||||
// exit;
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_data = "SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db_onedev->query($sql_data);
|
||||
// echo $this->db_onedev->last_query();
|
||||
// exit;
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db_onedev->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query(),
|
||||
"sql_data" => ($sql_data),
|
||||
"sql_filter" => ($sql_filter)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function confirm()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$orderheaderID = $prm["orderheaderID"];
|
||||
|
||||
$sql = "INSERT INTO log_confirm_eform(
|
||||
LogConfirmEformT_OrderHeaderID,
|
||||
LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
LogConfirmEformCreated,
|
||||
LogConfirmEformLastUpdated,
|
||||
LogConfirmEformUserID) VALUES(?,?,?,NOW(),NOW(),?)";
|
||||
$qry = $this->db_onedev->query($sql, array($orderheaderID, "C", "0", $userID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function reupload()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$logconfirmeformID = $prm["logconfirmeformID"];
|
||||
|
||||
$sql = "UPDATE log_confirm_eform
|
||||
SET LogConfirmEformStatus = ?,
|
||||
LogConfirmEformRetry = ?,
|
||||
LogConfirmEformLastUpdated = NOW(),
|
||||
LogConfirmEformUserID = ?
|
||||
WHERE LogConfirmEformID = ?";
|
||||
$qry = $this->db_onedev->query($sql, array("R", "0", $userID, $logconfirmeformID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "update log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
477
application/controllers/confirm_eform/Confirmeformx_mike.php
Normal file
477
application/controllers/confirm_eform/Confirmeformx_mike.php
Normal file
@@ -0,0 +1,477 @@
|
||||
<?php
|
||||
class Confirmeformx_mike extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "API CONFIRM EFORM";
|
||||
// $cek = $this->db_onedev->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
}
|
||||
|
||||
function search_company()
|
||||
{
|
||||
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
|
||||
$sql = "SELECT M_CompanyID, M_CompanyName
|
||||
FROM m_company
|
||||
WHERE M_CompanyName LIKE ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName DESC";
|
||||
$query = $this->db_onedev->query($sql, array($qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select company error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua");
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_mou()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
$companyID = $prm["company_id"];
|
||||
|
||||
$sql = "SELECT
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
M_MouM_CompanyID
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouM_CompanyID = ?
|
||||
AND M_MouName LIKE ?
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsMcu = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, array($companyID, $qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select mou error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_MouID" => 0, "M_MouName" => "Semua", "M_MouM_CompanyID" => 0);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookup()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
$mouID = $prm["mou_id"];
|
||||
|
||||
$where_company = "";
|
||||
|
||||
$companyid = $prm['companyid'];
|
||||
if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
$companyid = $prm['companyid'];
|
||||
$where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
}
|
||||
if (isset($prm['mou_id'])) {
|
||||
# code...
|
||||
if (
|
||||
$mouID != "" || $mouID != 0 || $mouID != "0"
|
||||
) {
|
||||
$mouID = $prm['mou_id'];
|
||||
$where_company .= " AND M_MouID = $mouID";
|
||||
}
|
||||
}
|
||||
|
||||
$where = "";
|
||||
$date = $prm['date'];
|
||||
|
||||
$start_date = $date . " 00:00:00";
|
||||
$end_date = $date . " 23:59:59";
|
||||
|
||||
// $filter_date = " DATE(T_OrderHeaderDate) = '{$date}'";
|
||||
// if ($date != '') {
|
||||
// $where = "$filter_date ";
|
||||
// }
|
||||
|
||||
if ($search != '') {
|
||||
$where .= " WHERE ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' ) ";
|
||||
}
|
||||
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '),M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
|
||||
$query_filter = $this->db_onedev->query($sql_filter);
|
||||
// $last_qry = $this->db_onedev->last_query();
|
||||
// print_r($last_qry);
|
||||
// exit;
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_data = "SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db_onedev->query($sql_data);
|
||||
// echo $this->db_onedev->last_query();
|
||||
// exit;
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test,
|
||||
So_TemplateID,
|
||||
So_TemplateName
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
left join so_testtemplate
|
||||
ON T_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
left join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db_onedev->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query(),
|
||||
"sql_data" => ($sql_data),
|
||||
"sql_filter" => ($sql_filter)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function confirm()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$orderheaderID = $prm["orderheaderID"];
|
||||
|
||||
$sql = "INSERT INTO log_confirm_eform(
|
||||
LogConfirmEformT_OrderHeaderID,
|
||||
LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
LogConfirmEformCreated,
|
||||
LogConfirmEformLastUpdated,
|
||||
LogConfirmEformUserID) VALUES(?,?,?,NOW(),NOW(),?)";
|
||||
$qry = $this->db_onedev->query($sql, array($orderheaderID, "C", "0", $userID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function reupload()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$logconfirmeformID = $prm["logconfirmeformID"];
|
||||
|
||||
$sql = "UPDATE log_confirm_eform
|
||||
SET LogConfirmEformStatus = ?,
|
||||
LogConfirmEformRetry = ?,
|
||||
LogConfirmEformLastUpdated = NOW(),
|
||||
LogConfirmEformUserID = ?
|
||||
WHERE LogConfirmEformID = ?";
|
||||
$qry = $this->db_onedev->query($sql, array("R", "0", $userID, $logconfirmeformID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "update log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
470
application/controllers/confirm_eform/Confirmeformx_second.php
Normal file
470
application/controllers/confirm_eform/Confirmeformx_second.php
Normal file
@@ -0,0 +1,470 @@
|
||||
<?php
|
||||
class Confirmeformx_second extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "API CONFIRM EFORM";
|
||||
// $cek = $this->db_onedev->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
}
|
||||
|
||||
function search_company()
|
||||
{
|
||||
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
|
||||
$sql = "SELECT M_CompanyID, M_CompanyName
|
||||
FROM m_company
|
||||
WHERE M_CompanyName LIKE ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName DESC";
|
||||
$query = $this->db_onedev->query($sql, array($qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select company error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua");
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_mou()
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
$companyID = $prm["company_id"];
|
||||
|
||||
$sql = "SELECT
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
M_MouM_CompanyID
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouM_CompanyID = ?
|
||||
AND M_MouName LIKE ?
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsMcu = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, array($companyID, $qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select mou error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_MouID" => 0, "M_MouName" => "Semua", "M_MouM_CompanyID" => 0);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookup()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
$mouID = $prm["mou_id"];
|
||||
|
||||
$where_company = "";
|
||||
|
||||
$companyid = $prm['companyid'];
|
||||
if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
$companyid = $prm['companyid'];
|
||||
$where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
}
|
||||
if (isset($prm['mou_id'])) {
|
||||
# code...
|
||||
if (
|
||||
$mouID != "" || $mouID != 0 || $mouID != "0"
|
||||
) {
|
||||
$mouID = $prm['mou_id'];
|
||||
$where_company .= " AND M_MouID = $mouID";
|
||||
}
|
||||
}
|
||||
|
||||
$where = "";
|
||||
$date = $prm['date'];
|
||||
|
||||
$start_date = $date . " 00:00:00";
|
||||
$end_date = $date . " 23:59:59";
|
||||
|
||||
// $filter_date = " DATE(T_OrderHeaderDate) = '{$date}'";
|
||||
// if ($date != '') {
|
||||
// $where = "$filter_date ";
|
||||
// }
|
||||
|
||||
if ($search != '') {
|
||||
$where .= " WHERE ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' ) ";
|
||||
}
|
||||
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '),M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
|
||||
$query_filter = $this->db_onedev->query($sql_filter);
|
||||
// $last_qry = $this->db_onedev->last_query();
|
||||
// print_r($last_qry);
|
||||
// exit;
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_data = "SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db_onedev->query($sql_data);
|
||||
// echo $this->db_onedev->last_query();
|
||||
// exit;
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db_onedev->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query(),
|
||||
"sql_data" => ($sql_data),
|
||||
"sql_filter" => ($sql_filter)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function confirm()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$orderheaderID = $prm["orderheaderID"];
|
||||
|
||||
$sql = "INSERT INTO log_confirm_eform(
|
||||
LogConfirmEformT_OrderHeaderID,
|
||||
LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
LogConfirmEformCreated,
|
||||
LogConfirmEformLastUpdated,
|
||||
LogConfirmEformUserID) VALUES(?,?,?,NOW(),NOW(),?)";
|
||||
$qry = $this->db_onedev->query($sql, array($orderheaderID, "C", "0", $userID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function reupload()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$logconfirmeformID = $prm["logconfirmeformID"];
|
||||
|
||||
$sql = "UPDATE log_confirm_eform
|
||||
SET LogConfirmEformStatus = ?,
|
||||
LogConfirmEformRetry = ?,
|
||||
LogConfirmEformLastUpdated = NOW(),
|
||||
LogConfirmEformUserID = ?
|
||||
WHERE LogConfirmEformID = ?";
|
||||
$qry = $this->db_onedev->query($sql, array("R", "0", $userID, $logconfirmeformID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "update log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
15
application/controllers/confirm_eform/Getorder.http
Normal file
15
application/controllers/confirm_eform/Getorder.http
Normal file
@@ -0,0 +1,15 @@
|
||||
###
|
||||
POST http://{{host}}/confirm_eform/getorder/listpatient
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
###
|
||||
POST http://{{host}}/confirm_eform/getorder/update_status
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"id": "132199",
|
||||
"status": "E"
|
||||
}
|
||||
210
application/controllers/confirm_eform/Getorder.php
Normal file
210
application/controllers/confirm_eform/Getorder.php
Normal file
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
class Getorder extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
echo "GET LIST PATIENT";
|
||||
}
|
||||
|
||||
public function listpatient()
|
||||
{
|
||||
try {
|
||||
|
||||
$sql = "SELECT
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumberExt,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
So_TemplateName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join so_testtemplate
|
||||
ON T_OrderDetailT_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
AND So_TemplateID IN (6,8,9)
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
AND M_MouIsBill = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
AND (M_PatientIDNumber <> '' AND M_PatientIDNumber IS NOT NULL)
|
||||
AND (M_PatientHP <> '' AND M_PatientHP IS NOT NULL AND M_PatientHP <> '-')
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
WHERE (LogConfirmEformStatus = 'C' OR LogConfirmEformStatus = 'R' OR LogConfirmEformStatus = 'E') AND LogConfirmEformRetry <= 5
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumberExt,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
So_TemplateName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join so_testtemplate
|
||||
ON T_OrderDetailT_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
AND So_TemplateID IN (6,8,9)
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
AND (M_PatientIDNumber <> '' AND M_PatientIDNumber IS NOT NULL)
|
||||
AND (M_PatientHP <> '' AND M_PatientHP IS NOT NULL AND M_PatientHP <> '-')
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
WHERE (LogConfirmEformStatus = 'C' OR LogConfirmEformStatus = 'R' OR LogConfirmEformStatus = 'E') AND LogConfirmEformRetry <= 5
|
||||
group by T_OrderHeaderID";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
$last_query = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_query
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$this->sys_ok($rows);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function update_status()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
$id = 0;
|
||||
if (isset($prm['id'])) {
|
||||
$id = trim($prm["id"]);
|
||||
$id = $prm['id'];
|
||||
}
|
||||
$status = "A";
|
||||
if (isset($prm['status'])) {
|
||||
$status = trim($prm["status"]);
|
||||
$status = $prm['status'];
|
||||
}
|
||||
|
||||
if ($id == 0) {
|
||||
$this->sys_error("ID mandatory !");
|
||||
exit;
|
||||
}
|
||||
if ($status == "A") {
|
||||
$this->sys_error("status mandatory !");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_retry = "SELECT LogConfirmEformRetry
|
||||
FROM log_confirm_eform
|
||||
WHERE LogConfirmEformT_OrderHeaderID = ?";
|
||||
$qry_retry = $this->db->query($sql_retry, [$id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$last_qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$retry = intval($qry_retry->result_array()[0]["LogConfirmEformRetry"]) + 1;
|
||||
|
||||
if (count($qry_retry->result_array()) > 0) {
|
||||
if ($status == "E") {
|
||||
$sql = "UPDATE log_confirm_eform SET
|
||||
LogConfirmEformStatus = 'E',
|
||||
LogConfirmEformRetry = ?,
|
||||
LogConfirmEformLastUpdated = ?
|
||||
WHERE LogConfirmEformT_OrderHeaderID = ?";
|
||||
|
||||
$qry = $this->db->query($sql, [$retry, date("Y-m-d H:i:s"), $id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
} else if ($status == "S") {
|
||||
$sql = "UPDATE log_confirm_eform SET
|
||||
LogConfirmEformStatus = 'S',
|
||||
LogConfirmEformLastUpdated = ?
|
||||
WHERE LogConfirmEformT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, [date("Y-m-d H:i:s"), $id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = array(
|
||||
"message" => "ID not found",
|
||||
);
|
||||
$this->sys_error($error);
|
||||
exit;
|
||||
}
|
||||
$this->sys_ok("OK");
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
15
application/controllers/confirm_eform/Send_wa.http
Normal file
15
application/controllers/confirm_eform/Send_wa.http
Normal file
@@ -0,0 +1,15 @@
|
||||
POST http://{{host}}/confirm_eform/send_wa/index
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
###
|
||||
POST http://{{host}}/confirm_eform/send_wa/send
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"nohp": "082142459585",
|
||||
"numberlabext": "ADXM001",
|
||||
"sotemplate": "Fisik umum"
|
||||
}
|
||||
63
application/controllers/confirm_eform/Send_wa.php
Normal file
63
application/controllers/confirm_eform/Send_wa.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
class Send_wa extends MY_Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
echo "API SEND WA";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library("Wa_krmv3");
|
||||
}
|
||||
|
||||
public function send()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$orderheaderid = $prm["orderheaderid"];
|
||||
$nomorlab = $prm["nomorlab"];
|
||||
$namapasien = $prm["namapasien"];
|
||||
$sotemplate = $prm["sotemplate"];
|
||||
$nohp = $prm["nohp"];
|
||||
$numberlabext = $prm["numberlabext"];
|
||||
|
||||
$sql_branch = "SELECT M_BranchID,
|
||||
M_BranchCode,
|
||||
M_BranchName
|
||||
FROM m_branch
|
||||
WHERE M_BranchIsDefault = 'Y'";
|
||||
$qry_branch = $this->db->query($sql_branch);
|
||||
if ($qry_branch) {
|
||||
$rowCode = $qry_branch->result_array()[0]["M_BranchCode"];
|
||||
} else {
|
||||
$this->db->sys_error_db("select branch error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = $this->wa_krmv3->send_eform($nohp, $rowCode, $numberlabext, $sotemplate);
|
||||
if ($result["code"] == 200) {
|
||||
//
|
||||
$resp = array(
|
||||
"status" => "OK",
|
||||
"message" => "Pesan berhasil di kirimkan"
|
||||
);
|
||||
|
||||
echo json_encode($resp);
|
||||
} else {
|
||||
//
|
||||
$resp = array(
|
||||
"status" => "ERR",
|
||||
"message" => $result
|
||||
);
|
||||
|
||||
echo json_encode($resp);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
POST http://{{host}}/confirm_eform/confirmeformx/index/
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM0MCIsIk1fVXNlclVzZXJuYW1lIjoiYWRtaW5zYXMgIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI1IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMCIsIk1fU3RhZmZOYW1lIjoiQURNSU4iLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjEyMCIsImlwIjoiMTM5LjE5Mi4xNzAuNzciLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdFwvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lXC8xMjIuMC4wLjAgU2FmYXJpXC81MzcuMzYgRWRnXC8xMjIuMC4wLjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNC0wMy0yOCAwODoxOToxMSIsIk1fU2F0ZWxsaXRlSUQiOjB9.I5GrVzvfn1Puhszy5rSCIk0hTwsGXm7GtmoSXhLhp8A"
|
||||
}
|
||||
|
||||
###
|
||||
# Branch
|
||||
POST http://{{host}}/confirm_eform/confirmeformx/search_company
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"search": "",
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM0MCIsIk1fVXNlclVzZXJuYW1lIjoiYWRtaW5zYXMgIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI1IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMCIsIk1fU3RhZmZOYW1lIjoiQURNSU4iLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjEyMCIsImlwIjoiMTM5LjE5Mi4xNzAuNzciLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdFwvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lXC8xMjIuMC4wLjAgU2FmYXJpXC81MzcuMzYgRWRnXC8xMjIuMC4wLjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNC0wMy0yOCAwODoxOToxMSIsIk1fU2F0ZWxsaXRlSUQiOjB9.I5GrVzvfn1Puhszy5rSCIk0hTwsGXm7GtmoSXhLhp8A"
|
||||
}
|
||||
|
||||
###
|
||||
# Aggrement
|
||||
POST http://{{host}}/confirm_eform/confirmeformx/search_mou
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"company_id": 7728,
|
||||
"search": "",
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM0MCIsIk1fVXNlclVzZXJuYW1lIjoiYWRtaW5zYXMgIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI1IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMCIsIk1fU3RhZmZOYW1lIjoiQURNSU4iLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjEyMCIsImlwIjoiMTM5LjE5Mi4xNzAuNzciLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdFwvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lXC8xMjIuMC4wLjAgU2FmYXJpXC81MzcuMzYgRWRnXC8xMjIuMC4wLjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNC0wMy0yOCAwODoxOToxMSIsIk1fU2F0ZWxsaXRlSUQiOjB9.I5GrVzvfn1Puhszy5rSCIk0hTwsGXm7GtmoSXhLhp8A"
|
||||
}
|
||||
|
||||
###
|
||||
# listing data tabel
|
||||
POST http://{{host}}/confirm_eform/confirmeformx/lookup
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"companyid": "7728",
|
||||
"mou_id": "2709",
|
||||
"date": "2024-06-25",
|
||||
"current_page": 1,
|
||||
"search": "",
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM0MCIsIk1fVXNlclVzZXJuYW1lIjoiYWRtaW5zYXMgIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI1IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMCIsIk1fU3RhZmZOYW1lIjoiQURNSU4iLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjEyMCIsImlwIjoiMTM5LjE5Mi4xNzAuNzciLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdFwvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lXC8xMjIuMC4wLjAgU2FmYXJpXC81MzcuMzYgRWRnXC8xMjIuMC4wLjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNC0wMy0yOCAwODoxOToxMSIsIk1fU2F0ZWxsaXRlSUQiOjB9.I5GrVzvfn1Puhszy5rSCIk0hTwsGXm7GtmoSXhLhp8A"
|
||||
}
|
||||
|
||||
###
|
||||
# Proses konfirmasi
|
||||
POST http://{{host}}/confirm_eform/confirmeformx/confirm
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"orderheaderID": "132199",
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM0MCIsIk1fVXNlclVzZXJuYW1lIjoiYWRtaW5zYXMgIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI1IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMCIsIk1fU3RhZmZOYW1lIjoiQURNSU4iLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjEyMCIsImlwIjoiMTM5LjE5Mi4xNzAuNzciLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdFwvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lXC8xMjIuMC4wLjAgU2FmYXJpXC81MzcuMzYgRWRnXC8xMjIuMC4wLjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNC0wMy0yOCAwODoxOToxMSIsIk1fU2F0ZWxsaXRlSUQiOjB9.I5GrVzvfn1Puhszy5rSCIk0hTwsGXm7GtmoSXhLhp8A"
|
||||
}
|
||||
|
||||
###
|
||||
# Proses reupload
|
||||
POST http://{{host}}/confirm_eform/confirmeformx/reupload
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"logconfirmeformID": "1",
|
||||
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM0MCIsIk1fVXNlclVzZXJuYW1lIjoiYWRtaW5zYXMgIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI1IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMCIsIk1fU3RhZmZOYW1lIjoiQURNSU4iLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjEyMCIsImlwIjoiMTM5LjE5Mi4xNzAuNzciLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoV2luZG93cyBOVCAxMC4wOyBXaW42NDsgeDY0KSBBcHBsZVdlYktpdFwvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lXC8xMjIuMC4wLjAgU2FmYXJpXC81MzcuMzYgRWRnXC8xMjIuMC4wLjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNC0wMy0yOCAwODoxOToxMSIsIk1fU2F0ZWxsaXRlSUQiOjB9.I5GrVzvfn1Puhszy5rSCIk0hTwsGXm7GtmoSXhLhp8A"
|
||||
}
|
||||
@@ -0,0 +1,504 @@
|
||||
<?php
|
||||
class Confirmeformx extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "API CONFIRM EFORM";
|
||||
// $cek = $this->db_onedev->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
}
|
||||
|
||||
function search_company()
|
||||
{
|
||||
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
|
||||
$sql = "SELECT M_CompanyID, M_CompanyName
|
||||
FROM m_company
|
||||
WHERE M_CompanyName LIKE ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName DESC";
|
||||
$query = $this->db_onedev->query($sql, array($qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select company error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua");
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_mou()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
$companyID = $prm["company_id"];
|
||||
|
||||
$sql = "SELECT
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
M_MouM_CompanyID
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouM_CompanyID = ?
|
||||
AND M_MouName LIKE ?
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsMcu = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, array($companyID, $qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select mou error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_MouID" => 0, "M_MouName" => "Semua", "M_MouM_CompanyID" => 0);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookup()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
$mouID = $prm["mou_id"];
|
||||
|
||||
$where_company = "";
|
||||
|
||||
$companyid = $prm['companyid'];
|
||||
if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
$companyid = $prm['companyid'];
|
||||
$where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
}
|
||||
if (isset($prm['mou_id'])) {
|
||||
# code...
|
||||
if (
|
||||
$mouID != "" || $mouID != 0 || $mouID != "0"
|
||||
) {
|
||||
$mouID = $prm['mou_id'];
|
||||
$where_company .= " AND M_MouID = $mouID";
|
||||
}
|
||||
}
|
||||
|
||||
$where = "";
|
||||
$date = $prm['date'];
|
||||
|
||||
$start_date = $date . " 00:00:00";
|
||||
$end_date = $date . " 23:59:59";
|
||||
|
||||
// $filter_date = " DATE(T_OrderHeaderDate) = '{$date}'";
|
||||
// if ($date != '') {
|
||||
// $where = "$filter_date ";
|
||||
// }
|
||||
|
||||
if ($search != '') {
|
||||
$where .= " WHERE ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' ) ";
|
||||
}
|
||||
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '),M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join so_testtemplate
|
||||
ON T_OrderDetailT_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
AND So_TemplateID IN (6,8,9)
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join so_testtemplate
|
||||
ON T_OrderDetailT_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
AND So_TemplateID IN (6,8,9)
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
|
||||
$query_filter = $this->db_onedev->query($sql_filter);
|
||||
// $last_qry = $this->db_onedev->last_query();
|
||||
// print_r($last_qry);
|
||||
// exit;
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_data = "SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join so_testtemplate
|
||||
ON T_OrderDetailT_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
AND So_TemplateID IN (6,8,9)
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join so_testtemplate
|
||||
ON T_OrderDetailT_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
AND So_TemplateID IN (6,8,9)
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db_onedev->query($sql_data);
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test,
|
||||
So_TemplateName
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
join so_testtemplate
|
||||
ON T_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
AND So_TemplateID IN (6,8,9)
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db_onedev->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query(),
|
||||
"sql_data" => ($sql_data),
|
||||
"sql_filter" => ($sql_filter)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function confirm()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$orderheaderID = $prm["orderheaderID"];
|
||||
|
||||
$sql = "INSERT INTO log_confirm_eform(
|
||||
LogConfirmEformT_OrderHeaderID,
|
||||
LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
LogConfirmEformCreated,
|
||||
LogConfirmEformLastUpdated,
|
||||
LogConfirmEformUserID) VALUES(?,?,?,NOW(),NOW(),?)";
|
||||
$qry = $this->db_onedev->query($sql, array($orderheaderID, "C", "0", $userID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function reupload()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$logconfirmeformID = $prm["logconfirmeformID"];
|
||||
|
||||
$sql = "UPDATE log_confirm_eform
|
||||
SET LogConfirmEformStatus = ?,
|
||||
LogConfirmEformRetry = ?,
|
||||
LogConfirmEformLastUpdated = NOW(),
|
||||
LogConfirmEformUserID = ?
|
||||
WHERE LogConfirmEformID = ?";
|
||||
$qry = $this->db_onedev->query($sql, array("R", "0", $userID, $logconfirmeformID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "update log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,470 @@
|
||||
<?php
|
||||
class Confirmeformx extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "API CONFIRM EFORM";
|
||||
// $cek = $this->db_onedev->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
}
|
||||
|
||||
function search_company()
|
||||
{
|
||||
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
|
||||
$sql = "SELECT M_CompanyID, M_CompanyName
|
||||
FROM m_company
|
||||
WHERE M_CompanyName LIKE ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName DESC";
|
||||
$query = $this->db_onedev->query($sql, array($qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select company error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua");
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_mou()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
$companyID = $prm["company_id"];
|
||||
|
||||
$sql = "SELECT
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
M_MouM_CompanyID
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouM_CompanyID = ?
|
||||
AND M_MouName LIKE ?
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsMcu = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, array($companyID, $qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select mou error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_MouID" => 0, "M_MouName" => "Semua", "M_MouM_CompanyID" => 0);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookup()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
$mouID = $prm["mou_id"];
|
||||
|
||||
$where_company = "";
|
||||
|
||||
$companyid = $prm['companyid'];
|
||||
if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
$companyid = $prm['companyid'];
|
||||
$where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
}
|
||||
if (isset($prm['mou_id'])) {
|
||||
# code...
|
||||
if (
|
||||
$mouID != "" || $mouID != 0 || $mouID != "0"
|
||||
) {
|
||||
$mouID = $prm['mou_id'];
|
||||
$where_company .= " AND M_MouID = $mouID";
|
||||
}
|
||||
}
|
||||
|
||||
$where = "";
|
||||
$date = $prm['date'];
|
||||
|
||||
$start_date = $date . " 00:00:00";
|
||||
$end_date = $date . " 23:59:59";
|
||||
|
||||
// $filter_date = " DATE(T_OrderHeaderDate) = '{$date}'";
|
||||
// if ($date != '') {
|
||||
// $where = "$filter_date ";
|
||||
// }
|
||||
|
||||
if ($search != '') {
|
||||
$where .= " WHERE ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' ) ";
|
||||
}
|
||||
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '),M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
|
||||
$query_filter = $this->db_onedev->query($sql_filter);
|
||||
// $last_qry = $this->db_onedev->last_query();
|
||||
// print_r($last_qry);
|
||||
// exit;
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_data = "SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db_onedev->query($sql_data);
|
||||
// echo $this->db_onedev->last_query();
|
||||
// exit;
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db_onedev->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query(),
|
||||
"sql_data" => ($sql_data),
|
||||
"sql_filter" => ($sql_filter)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function confirm()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$orderheaderID = $prm["orderheaderID"];
|
||||
|
||||
$sql = "INSERT INTO log_confirm_eform(
|
||||
LogConfirmEformT_OrderHeaderID,
|
||||
LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
LogConfirmEformCreated,
|
||||
LogConfirmEformLastUpdated,
|
||||
LogConfirmEformUserID) VALUES(?,?,?,NOW(),NOW(),?)";
|
||||
$qry = $this->db_onedev->query($sql, array($orderheaderID, "C", "0", $userID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function reupload()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$logconfirmeformID = $prm["logconfirmeformID"];
|
||||
|
||||
$sql = "UPDATE log_confirm_eform
|
||||
SET LogConfirmEformStatus = ?,
|
||||
LogConfirmEformRetry = ?,
|
||||
LogConfirmEformLastUpdated = NOW(),
|
||||
LogConfirmEformUserID = ?
|
||||
WHERE LogConfirmEformID = ?";
|
||||
$qry = $this->db_onedev->query($sql, array("R", "0", $userID, $logconfirmeformID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "update log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,477 @@
|
||||
<?php
|
||||
class Confirmeformx_mike extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "API CONFIRM EFORM";
|
||||
// $cek = $this->db_onedev->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
}
|
||||
|
||||
function search_company()
|
||||
{
|
||||
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
|
||||
$sql = "SELECT M_CompanyID, M_CompanyName
|
||||
FROM m_company
|
||||
WHERE M_CompanyName LIKE ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName DESC";
|
||||
$query = $this->db_onedev->query($sql, array($qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select company error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua");
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_mou()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
$companyID = $prm["company_id"];
|
||||
|
||||
$sql = "SELECT
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
M_MouM_CompanyID
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouM_CompanyID = ?
|
||||
AND M_MouName LIKE ?
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsMcu = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, array($companyID, $qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select mou error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_MouID" => 0, "M_MouName" => "Semua", "M_MouM_CompanyID" => 0);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookup()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
$mouID = $prm["mou_id"];
|
||||
|
||||
$where_company = "";
|
||||
|
||||
$companyid = $prm['companyid'];
|
||||
if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
$companyid = $prm['companyid'];
|
||||
$where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
}
|
||||
if (isset($prm['mou_id'])) {
|
||||
# code...
|
||||
if (
|
||||
$mouID != "" || $mouID != 0 || $mouID != "0"
|
||||
) {
|
||||
$mouID = $prm['mou_id'];
|
||||
$where_company .= " AND M_MouID = $mouID";
|
||||
}
|
||||
}
|
||||
|
||||
$where = "";
|
||||
$date = $prm['date'];
|
||||
|
||||
$start_date = $date . " 00:00:00";
|
||||
$end_date = $date . " 23:59:59";
|
||||
|
||||
// $filter_date = " DATE(T_OrderHeaderDate) = '{$date}'";
|
||||
// if ($date != '') {
|
||||
// $where = "$filter_date ";
|
||||
// }
|
||||
|
||||
if ($search != '') {
|
||||
$where .= " WHERE ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' ) ";
|
||||
}
|
||||
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '),M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
|
||||
$query_filter = $this->db_onedev->query($sql_filter);
|
||||
// $last_qry = $this->db_onedev->last_query();
|
||||
// print_r($last_qry);
|
||||
// exit;
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_data = "SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db_onedev->query($sql_data);
|
||||
// echo $this->db_onedev->last_query();
|
||||
// exit;
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test,
|
||||
So_TemplateID,
|
||||
So_TemplateName
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
left join so_testtemplate
|
||||
ON T_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
left join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db_onedev->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query(),
|
||||
"sql_data" => ($sql_data),
|
||||
"sql_filter" => ($sql_filter)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function confirm()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$orderheaderID = $prm["orderheaderID"];
|
||||
|
||||
$sql = "INSERT INTO log_confirm_eform(
|
||||
LogConfirmEformT_OrderHeaderID,
|
||||
LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
LogConfirmEformCreated,
|
||||
LogConfirmEformLastUpdated,
|
||||
LogConfirmEformUserID) VALUES(?,?,?,NOW(),NOW(),?)";
|
||||
$qry = $this->db_onedev->query($sql, array($orderheaderID, "C", "0", $userID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function reupload()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$logconfirmeformID = $prm["logconfirmeformID"];
|
||||
|
||||
$sql = "UPDATE log_confirm_eform
|
||||
SET LogConfirmEformStatus = ?,
|
||||
LogConfirmEformRetry = ?,
|
||||
LogConfirmEformLastUpdated = NOW(),
|
||||
LogConfirmEformUserID = ?
|
||||
WHERE LogConfirmEformID = ?";
|
||||
$qry = $this->db_onedev->query($sql, array("R", "0", $userID, $logconfirmeformID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "update log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,470 @@
|
||||
<?php
|
||||
class Confirmeformx_second extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "API CONFIRM EFORM";
|
||||
// $cek = $this->db_onedev->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
}
|
||||
|
||||
function search_company()
|
||||
{
|
||||
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
|
||||
$sql = "SELECT M_CompanyID, M_CompanyName
|
||||
FROM m_company
|
||||
WHERE M_CompanyName LIKE ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName DESC";
|
||||
$query = $this->db_onedev->query($sql, array($qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select company error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_CompanyID" => 0, "M_CompanyName" => "Semua");
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_mou()
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$qry = "%" . $prm["search"] . '%';
|
||||
$companyID = $prm["company_id"];
|
||||
|
||||
$sql = "SELECT
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
M_MouM_CompanyID
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouM_CompanyID = ?
|
||||
AND M_MouName LIKE ?
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsMcu = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, array($companyID, $qry));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("select mou error", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
$rows = $query->result_array();
|
||||
$rows[] = array("M_MouID" => 0, "M_MouName" => "Semua", "M_MouM_CompanyID" => 0);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"data" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookup()
|
||||
{
|
||||
try {
|
||||
# cek token valid
|
||||
// if (!$this->isLogin) {
|
||||
// $this->sys_error("Invalid Token");
|
||||
// exit;
|
||||
// }
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = $prm["search"];
|
||||
$mouID = $prm["mou_id"];
|
||||
|
||||
$where_company = "";
|
||||
|
||||
$companyid = $prm['companyid'];
|
||||
if ($companyid != "" || $companyid != 0 || $companyid != "0") {
|
||||
$companyid = $prm['companyid'];
|
||||
$where_company = "AND M_MouM_CompanyID = $companyid";
|
||||
}
|
||||
if (isset($prm['mou_id'])) {
|
||||
# code...
|
||||
if (
|
||||
$mouID != "" || $mouID != 0 || $mouID != "0"
|
||||
) {
|
||||
$mouID = $prm['mou_id'];
|
||||
$where_company .= " AND M_MouID = $mouID";
|
||||
}
|
||||
}
|
||||
|
||||
$where = "";
|
||||
$date = $prm['date'];
|
||||
|
||||
$start_date = $date . " 00:00:00";
|
||||
$end_date = $date . " 23:59:59";
|
||||
|
||||
// $filter_date = " DATE(T_OrderHeaderDate) = '{$date}'";
|
||||
// if ($date != '') {
|
||||
// $where = "$filter_date ";
|
||||
// }
|
||||
|
||||
if ($search != '') {
|
||||
$where .= " WHERE ( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' OR T_OrderHeaderLabNumberExt LIKE '%{$search}%' ) ";
|
||||
}
|
||||
|
||||
$number_limit = 20;
|
||||
// $number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$number_offset = 0;
|
||||
if ($prm['current_page'] > 0) {
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_filter = "SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '),M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
) x";
|
||||
|
||||
$query_filter = $this->db_onedev->query($sql_filter);
|
||||
// $last_qry = $this->db_onedev->last_query();
|
||||
// print_r($last_qry);
|
||||
// exit;
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query_filter) {
|
||||
$tot_count = $query_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_data = "SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
LogConfirmEformID,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
DATE_FORMAT(LogConfirmEformCreated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformCreated,
|
||||
DATE_FORMAT(LogConfirmEformLastUpdated, '%d-%m-%Y %H:%i:%s') AS LogConfirmEformLastUpdated,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientHP,
|
||||
'' as test,
|
||||
M_MouName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderDate >= '{$start_date}'
|
||||
AND T_OrderHeaderDate <= '{$end_date}'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
$where_company
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
$where
|
||||
group by T_OrderHeaderID
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
// $sql_param = array($search);
|
||||
$query_data = $this->db_onedev->query($sql_data);
|
||||
// echo $this->db_onedev->last_query();
|
||||
// exit;
|
||||
|
||||
if ($query_data) {
|
||||
$rows = $query_data->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$sql_dt = "";
|
||||
foreach ($rows as $k => $v) {
|
||||
$order_id = $v['T_OrderHeaderID'];
|
||||
$dt_test = [];
|
||||
$sql_dt = "SELECT T_OrderDetailT_TestName as x_test
|
||||
from t_orderdetail
|
||||
join t_test
|
||||
ON T_OrderDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $order_id
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_TestIsPrice = 'Y'
|
||||
";
|
||||
|
||||
// echo $sql_dt;
|
||||
$xdt_test = $this->db_onedev->query($sql_dt);
|
||||
// print_r($xdt_test);
|
||||
if (!$xdt_test) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("order detail");
|
||||
exit;
|
||||
} else {
|
||||
$testArr = $xdt_test->result_array();
|
||||
$rows[$k]['test'] = $testArr;
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("eform select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_all" => $tot_count,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query(),
|
||||
"sql_data" => ($sql_data),
|
||||
"sql_filter" => ($sql_filter)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function confirm()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$orderheaderID = $prm["orderheaderID"];
|
||||
|
||||
$sql = "INSERT INTO log_confirm_eform(
|
||||
LogConfirmEformT_OrderHeaderID,
|
||||
LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
LogConfirmEformCreated,
|
||||
LogConfirmEformLastUpdated,
|
||||
LogConfirmEformUserID) VALUES(?,?,?,NOW(),NOW(),?)";
|
||||
$qry = $this->db_onedev->query($sql, array($orderheaderID, "C", "0", $userID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "insert log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function reupload()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userID = $this->sys_user['M_UserID'];
|
||||
$logconfirmeformID = $prm["logconfirmeformID"];
|
||||
|
||||
$sql = "UPDATE log_confirm_eform
|
||||
SET LogConfirmEformStatus = ?,
|
||||
LogConfirmEformRetry = ?,
|
||||
LogConfirmEformLastUpdated = NOW(),
|
||||
LogConfirmEformUserID = ?
|
||||
WHERE LogConfirmEformID = ?";
|
||||
$qry = $this->db_onedev->query($sql, array("R", "0", $userID, $logconfirmeformID));
|
||||
|
||||
if (!$qry) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db(["status" => "ERR", "message" => "update log_confirm_eform | " .
|
||||
$this->db_onedev->error()["message"], "debug" => $this->db_onedev->last_query()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
###
|
||||
POST http://{{host}}/confirm_eform/getorder/listpatient
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
###
|
||||
POST http://{{host}}/confirm_eform/getorder/update_status
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"id": "132199",
|
||||
"status": "E"
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
class Getorder extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
echo "GET LIST PATIENT";
|
||||
}
|
||||
|
||||
public function listpatient()
|
||||
{
|
||||
try {
|
||||
|
||||
$sql = "SELECT
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumberExt,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
So_TemplateName
|
||||
FROM t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join so_testtemplate
|
||||
ON T_OrderDetailT_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
AND So_TemplateID IN (6,8,9)
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
AND M_MouIsBill = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
AND (M_PatientIDNumber <> '' AND M_PatientIDNumber IS NOT NULL)
|
||||
AND (M_PatientHP <> '' AND M_PatientHP IS NOT NULL AND M_PatientHP <> '-')
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
WHERE (LogConfirmEformStatus = 'C' OR LogConfirmEformStatus = 'R' OR LogConfirmEformStatus = 'E') AND LogConfirmEformRetry <= 5
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumberExt,
|
||||
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
||||
M_PatientIDNumber,
|
||||
M_PatientHP,
|
||||
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
||||
LogConfirmEformRetry,
|
||||
So_TemplateName
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join so_testtemplate
|
||||
ON T_OrderDetailT_TestID = So_TestTemplateT_TestID
|
||||
AND So_TestTemplateIsActive = 'Y'
|
||||
join so_template
|
||||
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
||||
AND So_TemplateIsActive = 'Y'
|
||||
AND So_TemplateID IN (6,8,9)
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsMcu = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
AND (M_PatientIDNumber <> '' AND M_PatientIDNumber IS NOT NULL)
|
||||
AND (M_PatientHP <> '' AND M_PatientHP IS NOT NULL AND M_PatientHP <> '-')
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
left join log_confirm_eform
|
||||
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
||||
AND LogConfirmEformIsActive = 'Y'
|
||||
WHERE (LogConfirmEformStatus = 'C' OR LogConfirmEformStatus = 'R' OR LogConfirmEformStatus = 'E') AND LogConfirmEformRetry <= 5
|
||||
group by T_OrderHeaderID";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
$last_query = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_query
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$this->sys_ok($rows);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function update_status()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
$id = 0;
|
||||
if (isset($prm['id'])) {
|
||||
$id = trim($prm["id"]);
|
||||
$id = $prm['id'];
|
||||
}
|
||||
$status = "A";
|
||||
if (isset($prm['status'])) {
|
||||
$status = trim($prm["status"]);
|
||||
$status = $prm['status'];
|
||||
}
|
||||
|
||||
if ($id == 0) {
|
||||
$this->sys_error("ID mandatory !");
|
||||
exit;
|
||||
}
|
||||
if ($status == "A") {
|
||||
$this->sys_error("status mandatory !");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_retry = "SELECT LogConfirmEformRetry
|
||||
FROM log_confirm_eform
|
||||
WHERE LogConfirmEformT_OrderHeaderID = ?";
|
||||
$qry_retry = $this->db->query($sql_retry, [$id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$last_qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$retry = intval($qry_retry->result_array()[0]["LogConfirmEformRetry"]) + 1;
|
||||
|
||||
if (count($qry_retry->result_array()) > 0) {
|
||||
if ($status == "E") {
|
||||
$sql = "UPDATE log_confirm_eform SET
|
||||
LogConfirmEformStatus = 'E',
|
||||
LogConfirmEformRetry = ?,
|
||||
LogConfirmEformLastUpdated = ?
|
||||
WHERE LogConfirmEformT_OrderHeaderID = ?";
|
||||
|
||||
$qry = $this->db->query($sql, [$retry, date("Y-m-d H:i:s"), $id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
} else if ($status == "S") {
|
||||
$sql = "UPDATE log_confirm_eform SET
|
||||
LogConfirmEformStatus = 'S',
|
||||
LogConfirmEformLastUpdated = ?
|
||||
WHERE LogConfirmEformT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, [date("Y-m-d H:i:s"), $id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = array(
|
||||
"message" => "ID not found",
|
||||
);
|
||||
$this->sys_error($error);
|
||||
exit;
|
||||
}
|
||||
$this->sys_ok("OK");
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
POST http://{{host}}/confirm_eform/send_wa/index
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
###
|
||||
POST http://{{host}}/confirm_eform/send_wa/send
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"nohp": "082142459585",
|
||||
"numberlabext": "ADXM001",
|
||||
"sotemplate": "Fisik umum"
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
class Send_wa extends MY_Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
echo "API SEND WA";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library("Wa_krmv3");
|
||||
}
|
||||
|
||||
public function send()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$orderheaderid = $prm["orderheaderid"];
|
||||
$nomorlab = $prm["nomorlab"];
|
||||
$namapasien = $prm["namapasien"];
|
||||
$sotemplate = $prm["sotemplate"];
|
||||
$nohp = $prm["nohp"];
|
||||
$numberlabext = $prm["numberlabext"];
|
||||
|
||||
$sql_branch = "SELECT M_BranchID,
|
||||
M_BranchCode,
|
||||
M_BranchName
|
||||
FROM m_branch
|
||||
WHERE M_BranchIsDefault = 'Y'";
|
||||
$qry_branch = $this->db->query($sql_branch);
|
||||
if ($qry_branch) {
|
||||
$rowCode = $qry_branch->result_array()[0]["M_BranchCode"];
|
||||
} else {
|
||||
$this->db->sys_error_db("select branch error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = $this->wa_krmv3->send_eform($nohp, $rowCode, $numberlabext, $sotemplate);
|
||||
if ($result["code"] == 200) {
|
||||
//
|
||||
$resp = array(
|
||||
"status" => "OK",
|
||||
"message" => "Pesan berhasil di kirimkan"
|
||||
);
|
||||
|
||||
echo json_encode($resp);
|
||||
} else {
|
||||
//
|
||||
$resp = array(
|
||||
"status" => "ERR",
|
||||
"message" => $result
|
||||
);
|
||||
|
||||
echo json_encode($resp);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
948
application/controllers/corp/Request.php
Normal file
948
application/controllers/corp/Request.php
Normal file
@@ -0,0 +1,948 @@
|
||||
<?php
|
||||
|
||||
class Request extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "BRANCH API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookuppgbankbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$pgbank = $prm['branch'];
|
||||
$all = $prm['all'];
|
||||
$startdate = $prm["startdate"];
|
||||
$enddate = $prm["enddate"];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
from one_rekap.request
|
||||
JOIN m_company ON M_CompanyID = requestM_CompanyID
|
||||
WHERE
|
||||
(M_CompanyNumber LIKE CONCAT('%','{$pgbank}','%') OR
|
||||
M_CompanyName LIKE CONCAT('%','{$pgbank}','%'))
|
||||
-- AND ( requestStartDate = '{$startdate}' AND requestEndDate = '{$enddate}')
|
||||
";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
// echo $this->db_onedev->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("corp_upload count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select requestID as id,
|
||||
TypeID,
|
||||
TypeCode,
|
||||
TypeName,
|
||||
M_CompanyID,
|
||||
M_CompanyName,
|
||||
DATE_FORMAT(requestCreated,'%d-%m-%Y %h:%i:%s') as waktuupload,
|
||||
CONCAT(DATE_FORMAT(requestStartDate,'%d-%m-%Y'),' sampai ', DATE_FORMAT(requestEndDate,'%d-%m-%Y')) as periode,
|
||||
CASE
|
||||
WHEN requestStatus = 'N' THEN 'Baru'
|
||||
WHEN requestStatus = 'P' THEN 'Proses'
|
||||
WHEN requestStatus = 'Y' THEN 'Selesai'
|
||||
WHEN requestStatus = 'F' THEN 'Gagal'
|
||||
END as status,
|
||||
request.*
|
||||
from one_rekap.request
|
||||
JOIN m_company ON M_CompanyID = requestM_CompanyID
|
||||
JOIN one_rekap.type ON TypeCode = requestType
|
||||
WHERE
|
||||
(M_CompanyNumber LIKE CONCAT('%','{$pgbank}','%') OR
|
||||
M_CompanyName LIKE CONCAT('%','{$pgbank}','%'))
|
||||
-- AND ( requestStartDate = '{$startdate}' AND requestEndDate = '{$enddate}')
|
||||
GROUP BY requestID
|
||||
ORDER BY requestID DESC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
// echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("corp_upload select");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows,"reports" => '');
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add_regtime(){
|
||||
$query =" SELECT corp_report.*,'N' as isregtime, 0 as xid
|
||||
FROM corp_report
|
||||
WHERE Corp_ReportIsActive = 'Y'
|
||||
ORDER BY Corp_ReportCode ASC";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if(!$rows)
|
||||
$rows = array();
|
||||
return $rows;
|
||||
}
|
||||
public function lookupregionalbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$regional = $prm['regional'];
|
||||
$pgbank = $prm['pgbank'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *
|
||||
from s_regional
|
||||
LEFT JOIN corp_upload ON S_RegionalID = Corp_UploadS_RegionalID AND Corp_UploadIsActive = 'Y'
|
||||
where
|
||||
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(Corp_UploadName,'') LIKE CONCAT('%','{$pgbank}','%') AND
|
||||
S_RegionalIsActive = 'Y'
|
||||
GROUP BY S_RegionalID) a";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("s_regional count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select S_RegionalID as id,
|
||||
S_RegionalName as name,
|
||||
S_RegionalName as namex,
|
||||
s_regional.*
|
||||
from s_regional
|
||||
LEFT JOIN corp_upload ON S_RegionalID = Corp_UploadS_RegionalID AND Corp_UploadIsActive = 'Y'
|
||||
where
|
||||
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(Corp_UploadName,'') LIKE CONCAT('%','{$pgbank}','%') AND
|
||||
S_RegionalIsActive = 'Y'
|
||||
GROUP BY S_RegionalID
|
||||
ORDER BY S_RegionalName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("s_regional select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function addnewregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$sql = "insert into s_regional(
|
||||
S_RegionalName,
|
||||
S_RegionalCreated,
|
||||
S_RegionalLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("s_regional insert");
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sqlcompany = "update s_regional SET
|
||||
S_RegionalName = ?,
|
||||
S_RegionalLastUpdated = now()
|
||||
where
|
||||
S_RegionalID = ?
|
||||
";
|
||||
$querycompany = $this->db_onedev->query($sqlcompany,
|
||||
array(
|
||||
$name,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("s_regional update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function addnewpgbank()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$type = $prm['type'];
|
||||
$startdate = $prm['startdateform'];
|
||||
$enddate = $prm['enddateform'];
|
||||
$companyid = $prm['companyid'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
|
||||
if($prm['xid'] == 0){
|
||||
$sql = "insert into one_rekap.request(
|
||||
requestType,
|
||||
requestM_CompanyID,
|
||||
requestStartDate,
|
||||
requestEndDate,
|
||||
requestCreated,
|
||||
requestLasUpdated,
|
||||
requestUserID)
|
||||
values(?,?,?,?,now(),now(),?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$type,
|
||||
$companyid,
|
||||
$startdate,
|
||||
$enddate,
|
||||
$userid)
|
||||
);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("corp_upload insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update s_regional SET
|
||||
S_RegionalIsActive = 'N',
|
||||
S_RegionalLastUpdated = now()
|
||||
WHERE
|
||||
S_RegionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("s_regional delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update corp_upload SET
|
||||
Corp_UploadIsActive = 'N',
|
||||
Corp_UploadLastUpdated = now()
|
||||
WHERE
|
||||
Corp_UploadS_RegionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("corp_upload delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function deletepgbank()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update corp_upload SET
|
||||
Corp_UploadIsActive = 'N',
|
||||
Corp_UploadLastUpdated = now()
|
||||
WHERE
|
||||
Corp_UploadID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("corp_upload delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchakun(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['tes'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['tes']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouNumber like ?
|
||||
AND M_MouIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT M_MouID,CONCAT(M_MouName, ' [',M_MouNumber,'] ') as M_MouNumber
|
||||
FROM m_mou
|
||||
|
||||
JOIN m_company ON M_CompanyID = M_MouM_CompanyID
|
||||
WHERE
|
||||
CONCAT(M_MouName, ' [',M_MouNumber,'] ') like ?
|
||||
AND M_MouIsActive = 'Y'
|
||||
ORDER BY M_MouName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function selectpaymenttype(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_paymenttype
|
||||
WHERE
|
||||
M_PaymentTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['paymenttypes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
function searchregionalbyname(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM s_regional
|
||||
WHERE
|
||||
S_RegionalName like ?
|
||||
AND S_RegionalIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("s_regional count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT S_RegionalID, S_RegionalName
|
||||
FROM s_regional
|
||||
WHERE
|
||||
S_RegionalName like ?
|
||||
AND S_RegionalIsActive = 'Y'
|
||||
ORDER BY S_RegionalName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("s_regional rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchpaymenttype(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_paymenttype
|
||||
WHERE
|
||||
M_PaymentTypeName like ?
|
||||
AND M_PaymentTypeIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("t_subcategory count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT M_PaymentTypeID, M_PaymentTypeName
|
||||
FROM m_paymenttype
|
||||
WHERE
|
||||
M_PaymentTypeName like ?
|
||||
AND M_PaymentTypeIsActive = 'Y'
|
||||
ORDER BY M_PaymentTypeName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("t_subcategory rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function searchdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictT_SubCategoryID = '{$id}'
|
||||
AND M_DistrictIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictT_SubCategoryID = '{$id}'
|
||||
AND M_DistrictIsActive = 'Y'
|
||||
ORDER BY M_DistrictName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = 'Y'
|
||||
ORDER BY M_KelurahanName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcompany(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['tes'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['tes']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchmou(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM one_rekap.type
|
||||
WHERE
|
||||
TypeName like ?
|
||||
AND TypeIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM one_rekap.type
|
||||
WHERE
|
||||
TypeName like ?
|
||||
AND TypeIsActive = 'Y'
|
||||
ORDER BY TypeName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
// echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_doctor count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?
|
||||
GROUP BY M_DoctorID
|
||||
ORDER BY M_DoctorName ASC";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_doctor rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function selectaddressdoctor(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$rows = [];
|
||||
$query ="SELECT M_DoctorAddressID,
|
||||
CONCAT(M_DoctorAddressNote, ': ',M_DoctorAddressDescription) as M_DoctorAddressNote
|
||||
FROM
|
||||
m_doctoraddress
|
||||
WHERE M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = '{$id}'";
|
||||
//echo $query;
|
||||
$rows['addressdoctors'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
935
application/controllers/corp/Upload.php
Normal file
935
application/controllers/corp/Upload.php
Normal file
@@ -0,0 +1,935 @@
|
||||
<?php
|
||||
|
||||
class Upload extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "BRANCH API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookuppgbankbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$pgbank = $prm['branch'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
from corp_upload
|
||||
JOIN m_mou ON M_MouID = Corp_UploadM_MouID
|
||||
WHERE
|
||||
(M_MouNumber LIKE CONCAT('%','{$pgbank}','%') OR
|
||||
M_MouName LIKE CONCAT('%','{$pgbank}','%')) AND
|
||||
Corp_UploadIsActive = 'Y'";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
// echo $this->db_onedev->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("corp_upload count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Corp_UploadID as id,
|
||||
M_MouID,
|
||||
CONCAT(M_MouName,' [',M_MouNumber,'] ') M_MouNumber,
|
||||
M_MouName,
|
||||
M_CompanyID,
|
||||
M_CompanyName,
|
||||
DATE_FORMAT(Corp_UploadSentDate,'%d-%m-%Y %h:%i:%s') as waktuupload,
|
||||
CASE
|
||||
WHEN Corp_UploadStatus = 'N' THEN 'Baru'
|
||||
WHEN Corp_UploadStatus = 'P' THEN 'Proses'
|
||||
WHEN Corp_UploadStatus = 'D' THEN 'Selesai'
|
||||
WHEN Corp_UploadStatus = 'F' THEN 'Gagal'
|
||||
END as status,
|
||||
corp_upload.*
|
||||
from corp_upload
|
||||
JOIN m_mou ON M_MouID = Corp_UploadM_MouID
|
||||
JOIN m_company ON M_CompanyID = M_MouM_CompanyID
|
||||
WHERE
|
||||
(M_MouNumber LIKE CONCAT('%','{$pgbank}','%') OR
|
||||
M_MouName LIKE CONCAT('%','{$pgbank}','%')) AND
|
||||
Corp_UploadIsActive = 'Y'
|
||||
GROUP BY Corp_UploadID
|
||||
ORDER BY M_MouName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("corp_upload select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function lookupregionalbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$regional = $prm['regional'];
|
||||
$pgbank = $prm['pgbank'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *
|
||||
from s_regional
|
||||
LEFT JOIN corp_upload ON S_RegionalID = Corp_UploadS_RegionalID AND Corp_UploadIsActive = 'Y'
|
||||
where
|
||||
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(Corp_UploadName,'') LIKE CONCAT('%','{$pgbank}','%') AND
|
||||
S_RegionalIsActive = 'Y'
|
||||
GROUP BY S_RegionalID) a";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("s_regional count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select S_RegionalID as id,
|
||||
S_RegionalName as name,
|
||||
S_RegionalName as namex,
|
||||
s_regional.*
|
||||
from s_regional
|
||||
LEFT JOIN corp_upload ON S_RegionalID = Corp_UploadS_RegionalID AND Corp_UploadIsActive = 'Y'
|
||||
where
|
||||
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(Corp_UploadName,'') LIKE CONCAT('%','{$pgbank}','%') AND
|
||||
S_RegionalIsActive = 'Y'
|
||||
GROUP BY S_RegionalID
|
||||
ORDER BY S_RegionalName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("s_regional select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function addnewregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$sql = "insert into s_regional(
|
||||
S_RegionalName,
|
||||
S_RegionalCreated,
|
||||
S_RegionalLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("s_regional insert");
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sqlcompany = "update s_regional SET
|
||||
S_RegionalName = ?,
|
||||
S_RegionalLastUpdated = now()
|
||||
where
|
||||
S_RegionalID = ?
|
||||
";
|
||||
$querycompany = $this->db_onedev->query($sqlcompany,
|
||||
array(
|
||||
$name,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("s_regional update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function addnewpgbank()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$Corp_UploadM_MouID = $prm['mouid'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
|
||||
if($prm['xid'] == 0){
|
||||
$sql = "insert into corp_upload(
|
||||
Corp_UploadM_MouID,
|
||||
Corp_UploadCreated,
|
||||
Corp_UploadLastUpdated,
|
||||
Corp_UploadUserID)
|
||||
values(?,now(),now(),?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$Corp_UploadM_MouID,
|
||||
$userid)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("corp_upload insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
}else{
|
||||
$sql = "UPDATE corp_upload SET Corp_UploadStatus = 'N',
|
||||
Corp_UploadRetry = Corp_UploadRetry + 1,
|
||||
Corp_UploadUserID = '{$userid}',
|
||||
Corp_UploadLastUpdated = now()
|
||||
WHERE Corp_UploadID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update s_regional SET
|
||||
S_RegionalIsActive = 'N',
|
||||
S_RegionalLastUpdated = now()
|
||||
WHERE
|
||||
S_RegionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("s_regional delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update corp_upload SET
|
||||
Corp_UploadIsActive = 'N',
|
||||
Corp_UploadLastUpdated = now()
|
||||
WHERE
|
||||
Corp_UploadS_RegionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("corp_upload delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function deletepgbank()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update corp_upload SET
|
||||
Corp_UploadIsActive = 'N',
|
||||
Corp_UploadLastUpdated = now()
|
||||
WHERE
|
||||
Corp_UploadID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("corp_upload delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchakun(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['tes'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['tes']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouNumber like ?
|
||||
AND M_MouIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT M_MouID,CONCAT(M_MouName, ' [',M_MouNumber,'] ') as M_MouNumber
|
||||
FROM m_mou
|
||||
|
||||
JOIN m_company ON M_CompanyID = M_MouM_CompanyID
|
||||
WHERE
|
||||
CONCAT(M_MouName, ' [',M_MouNumber,'] ') like ?
|
||||
AND M_MouIsActive = 'Y'
|
||||
ORDER BY M_MouName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function selectpaymenttype(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_paymenttype
|
||||
WHERE
|
||||
M_PaymentTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['paymenttypes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
function searchregionalbyname(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM s_regional
|
||||
WHERE
|
||||
S_RegionalName like ?
|
||||
AND S_RegionalIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("s_regional count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT S_RegionalID, S_RegionalName
|
||||
FROM s_regional
|
||||
WHERE
|
||||
S_RegionalName like ?
|
||||
AND S_RegionalIsActive = 'Y'
|
||||
ORDER BY S_RegionalName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("s_regional rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchpaymenttype(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_paymenttype
|
||||
WHERE
|
||||
M_PaymentTypeName like ?
|
||||
AND M_PaymentTypeIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("t_subcategory count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT M_PaymentTypeID, M_PaymentTypeName
|
||||
FROM m_paymenttype
|
||||
WHERE
|
||||
M_PaymentTypeName like ?
|
||||
AND M_PaymentTypeIsActive = 'Y'
|
||||
ORDER BY M_PaymentTypeName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("t_subcategory rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function searchdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictT_SubCategoryID = '{$id}'
|
||||
AND M_DistrictIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictT_SubCategoryID = '{$id}'
|
||||
AND M_DistrictIsActive = 'Y'
|
||||
ORDER BY M_DistrictName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = 'Y'
|
||||
ORDER BY M_KelurahanName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcompany(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['tes'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['tes']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchmou(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = 'Y'
|
||||
ORDER BY M_MouName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
// echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_doctor count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?
|
||||
GROUP BY M_DoctorID
|
||||
ORDER BY M_DoctorName ASC";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_doctor rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function selectaddressdoctor(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$rows = [];
|
||||
$query ="SELECT M_DoctorAddressID,
|
||||
CONCAT(M_DoctorAddressNote, ': ',M_DoctorAddressDescription) as M_DoctorAddressNote
|
||||
FROM
|
||||
m_doctoraddress
|
||||
WHERE M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = '{$id}'";
|
||||
//echo $query;
|
||||
$rows['addressdoctors'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
974
application/controllers/corp/Upload_v2.php
Normal file
974
application/controllers/corp/Upload_v2.php
Normal file
@@ -0,0 +1,974 @@
|
||||
<?php
|
||||
|
||||
class Upload_v2 extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "BRANCH API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookuppgbankbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$pgbank = $prm['branch'];
|
||||
$all = $prm['all'];
|
||||
$startdate = $prm["startdate"];
|
||||
$enddate = $prm["enddate"];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
from corp_upload
|
||||
JOIN m_mou ON M_MouID = Corp_UploadM_MouID
|
||||
WHERE
|
||||
(M_MouNumber LIKE CONCAT('%','{$pgbank}','%') OR
|
||||
M_MouName LIKE CONCAT('%','{$pgbank}','%')) AND
|
||||
Corp_UploadIsActive = 'Y' AND
|
||||
( Corp_UploadCreated BETWEEN '{$startdate} 00:00:00' AND '{$enddate} 23:59:59' )";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
// echo $this->db_onedev->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("corp_upload count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Corp_UploadID as id,
|
||||
M_MouID,
|
||||
CONCAT(M_MouName,' [',M_MouNumber,'] ', '<br>', 'Cetak Hasil : ',GROUP_CONCAT(CONCAT(Corp_ReportCode,'-',Corp_ReportName) SEPARATOR ', ')) as M_MouNumber,
|
||||
M_MouName,
|
||||
M_CompanyID,
|
||||
M_CompanyName,
|
||||
DATE_FORMAT(Corp_UploadSentDate,'%d-%m-%Y %h:%i:%s') as waktuupload,
|
||||
CASE
|
||||
WHEN Corp_UploadStatus = 'N' THEN 'Baru'
|
||||
WHEN Corp_UploadStatus = 'P' THEN 'Proses'
|
||||
WHEN Corp_UploadStatus = 'D' THEN 'Selesai'
|
||||
WHEN Corp_UploadStatus = 'F' THEN 'Gagal'
|
||||
END as status,
|
||||
'xxx' as regtimes,
|
||||
corp_upload.*
|
||||
from corp_upload
|
||||
JOIN m_mou ON M_MouID = Corp_UploadM_MouID
|
||||
JOIN m_company ON M_CompanyID = M_MouM_CompanyID
|
||||
JOIN corp_uploaderdetail ON Corp_UploaderDetailCorp_UploadID = Corp_UploadID AND Corp_UploaderDetailIsActive = 'Y'
|
||||
JOIN corp_report ON Corp_ReportID = Corp_UploaderDetailCorp_ReportID
|
||||
WHERE
|
||||
(M_MouNumber LIKE CONCAT('%','{$pgbank}','%') OR
|
||||
M_MouName LIKE CONCAT('%','{$pgbank}','%')) AND
|
||||
Corp_UploadIsActive = 'Y' AND
|
||||
( Corp_UploadCreated BETWEEN '{$startdate} 00:00:00' AND '{$enddate} 23:59:59' )
|
||||
GROUP BY Corp_UploadID
|
||||
ORDER BY Corp_UploadID DESC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("corp_upload select");
|
||||
exit;
|
||||
}
|
||||
$sqlreport = "SELECT corp_report.*,'Y' as isregtime, 0 as xid
|
||||
FROM corp_report
|
||||
WHERE Corp_ReportIsActive = 'Y'
|
||||
ORDER BY Corp_ReportCode ASC";
|
||||
$queryreport = $this->db_onedev->query($sqlreport)->result_array();
|
||||
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows,"reports" => $queryreport);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add_regtime(){
|
||||
$query =" SELECT corp_report.*,'N' as isregtime, 0 as xid
|
||||
FROM corp_report
|
||||
WHERE Corp_ReportIsActive = 'Y'
|
||||
ORDER BY Corp_ReportCode ASC";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if(!$rows)
|
||||
$rows = array();
|
||||
return $rows;
|
||||
}
|
||||
public function lookupregionalbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$regional = $prm['regional'];
|
||||
$pgbank = $prm['pgbank'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *
|
||||
from s_regional
|
||||
LEFT JOIN corp_upload ON S_RegionalID = Corp_UploadS_RegionalID AND Corp_UploadIsActive = 'Y'
|
||||
where
|
||||
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(Corp_UploadName,'') LIKE CONCAT('%','{$pgbank}','%') AND
|
||||
S_RegionalIsActive = 'Y'
|
||||
GROUP BY S_RegionalID) a";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("s_regional count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select S_RegionalID as id,
|
||||
S_RegionalName as name,
|
||||
S_RegionalName as namex,
|
||||
s_regional.*
|
||||
from s_regional
|
||||
LEFT JOIN corp_upload ON S_RegionalID = Corp_UploadS_RegionalID AND Corp_UploadIsActive = 'Y'
|
||||
where
|
||||
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(Corp_UploadName,'') LIKE CONCAT('%','{$pgbank}','%') AND
|
||||
S_RegionalIsActive = 'Y'
|
||||
GROUP BY S_RegionalID
|
||||
ORDER BY S_RegionalName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("s_regional select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function addnewregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$sql = "insert into s_regional(
|
||||
S_RegionalName,
|
||||
S_RegionalCreated,
|
||||
S_RegionalLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("s_regional insert");
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sqlcompany = "update s_regional SET
|
||||
S_RegionalName = ?,
|
||||
S_RegionalLastUpdated = now()
|
||||
where
|
||||
S_RegionalID = ?
|
||||
";
|
||||
$querycompany = $this->db_onedev->query($sqlcompany,
|
||||
array(
|
||||
$name,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("s_regional update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function addnewpgbank()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$Corp_UploadM_MouID = $prm['mouid'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
|
||||
if($prm['xid'] == 0){
|
||||
$sql = "insert into corp_upload(
|
||||
Corp_UploadM_MouID,
|
||||
Corp_UploadCreated,
|
||||
Corp_UploadLastUpdated,
|
||||
Corp_UploadUserID)
|
||||
values(?,now(),now(),?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$Corp_UploadM_MouID,
|
||||
$userid)
|
||||
);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
foreach($prm['reports'] as $k=>$v){
|
||||
if($v['isregtime'] === 'Y'){
|
||||
$xreportid = $v['Corp_ReportID'];
|
||||
$query = "INSERT INTO corp_uploaderdetail(
|
||||
Corp_UploaderDetailCorp_UploadID,
|
||||
Corp_UploaderDetailCorp_ReportID,
|
||||
Corp_UploaderDetailUserID,
|
||||
Corp_UploaderDetailCreated,
|
||||
Corp_UploaderDetailLastUpdated
|
||||
)
|
||||
VALUES(?,?,?,now(),now())";
|
||||
$insert_detail = $this->db_onedev->query($query,array($last_id,$xreportid,$userid));
|
||||
}
|
||||
}
|
||||
if (!$query) {
|
||||
$this->sys_error_db("corp_upload insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
}else{
|
||||
$sql = "UPDATE corp_upload SET Corp_UploadStatus = 'N',
|
||||
Corp_UploadRetry = Corp_UploadRetry + 1,
|
||||
Corp_UploadUserID = '{$userid}',
|
||||
Corp_UploadLastUpdated = now()
|
||||
WHERE Corp_UploadID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteregional()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update s_regional SET
|
||||
S_RegionalIsActive = 'N',
|
||||
S_RegionalLastUpdated = now()
|
||||
WHERE
|
||||
S_RegionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("s_regional delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update corp_upload SET
|
||||
Corp_UploadIsActive = 'N',
|
||||
Corp_UploadLastUpdated = now()
|
||||
WHERE
|
||||
Corp_UploadS_RegionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("corp_upload delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function deletepgbank()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update corp_upload SET
|
||||
Corp_UploadIsActive = 'N',
|
||||
Corp_UploadLastUpdated = now()
|
||||
WHERE
|
||||
Corp_UploadID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("corp_upload delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchakun(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['tes'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['tes']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouNumber like ?
|
||||
AND M_MouIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT M_MouID,CONCAT(M_MouName, ' [',M_MouNumber,'] ') as M_MouNumber
|
||||
FROM m_mou
|
||||
|
||||
JOIN m_company ON M_CompanyID = M_MouM_CompanyID
|
||||
WHERE
|
||||
CONCAT(M_MouName, ' [',M_MouNumber,'] ') like ?
|
||||
AND M_MouIsActive = 'Y'
|
||||
ORDER BY M_MouName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function selectpaymenttype(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_paymenttype
|
||||
WHERE
|
||||
M_PaymentTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['paymenttypes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
function searchregionalbyname(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM s_regional
|
||||
WHERE
|
||||
S_RegionalName like ?
|
||||
AND S_RegionalIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("s_regional count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT S_RegionalID, S_RegionalName
|
||||
FROM s_regional
|
||||
WHERE
|
||||
S_RegionalName like ?
|
||||
AND S_RegionalIsActive = 'Y'
|
||||
ORDER BY S_RegionalName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("s_regional rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchpaymenttype(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_paymenttype
|
||||
WHERE
|
||||
M_PaymentTypeName like ?
|
||||
AND M_PaymentTypeIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("t_subcategory count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT M_PaymentTypeID, M_PaymentTypeName
|
||||
FROM m_paymenttype
|
||||
WHERE
|
||||
M_PaymentTypeName like ?
|
||||
AND M_PaymentTypeIsActive = 'Y'
|
||||
ORDER BY M_PaymentTypeName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("t_subcategory rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function searchdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictT_SubCategoryID = '{$id}'
|
||||
AND M_DistrictIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictT_SubCategoryID = '{$id}'
|
||||
AND M_DistrictIsActive = 'Y'
|
||||
ORDER BY M_DistrictName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = 'Y'
|
||||
ORDER BY M_KelurahanName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcompany(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['tes'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['tes']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *, CONCAT(M_CompanyName,' [',M_CompanyNumber,']') as M_CompanyName
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchmou(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *, CONCAT(M_MouName,' [',M_MouNumber,']') as M_MouName
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = 'Y'
|
||||
ORDER BY M_MouName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
// echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_doctor count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?
|
||||
GROUP BY M_DoctorID
|
||||
ORDER BY M_DoctorName ASC";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_doctor rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function selectaddressdoctor(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$rows = [];
|
||||
$query ="SELECT M_DoctorAddressID,
|
||||
CONCAT(M_DoctorAddressNote, ': ',M_DoctorAddressDescription) as M_DoctorAddressNote
|
||||
FROM
|
||||
m_doctoraddress
|
||||
WHERE M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = '{$id}'";
|
||||
//echo $query;
|
||||
$rows['addressdoctors'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
996
application/controllers/corporate/Uploader.php
Normal file
996
application/controllers/corporate/Uploader.php
Normal file
@@ -0,0 +1,996 @@
|
||||
<?php
|
||||
class Uploader extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function get_param()
|
||||
{
|
||||
$raw = file_get_contents("php://input");
|
||||
return json_decode($raw, true);
|
||||
}
|
||||
function get_company($companyID)
|
||||
{
|
||||
$sql = "select M_CompanyID, M_CompanyOldID, M_BranchID M_CompanyM_BranchID, M_CompanyName, M_CompanyNumber,
|
||||
M_CompanyIDParent, M_CompanyM_CompanyTypeID, M_CompanyM_CompanyBusinessID,
|
||||
M_CompanyM_ProvinceID, M_CompanyM_CityID, M_CompanyM_DistrictID, M_CompanyM_KelurahanID,
|
||||
M_CompanyAddress, M_CompanyPhone, M_CompanyFax, M_CompanyEmail, M_CompanyPIC,
|
||||
M_CompanyM_StaffID, M_CompanyNat_CompanyLevelID, M_CompanyNat_HierarchyID,
|
||||
M_CompanyIsLabFrom, M_CompanyIsLabTo, M_CompanyIsDefault, M_CompanyM_DoctorID,
|
||||
M_CompanyCreated, M_CompanyLastUpdated, M_CompanyIsActive, M_CompanyAddressLocation,
|
||||
M_CompanyHp, M_CompanyPrivateRequest
|
||||
from m_company
|
||||
join m_branch on M_CompanyID = ?
|
||||
and M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'";
|
||||
$qry = $this->db->query($sql, [$companyID]);
|
||||
if (!$qry) {
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
])
|
||||
);
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "OK",
|
||||
"data" => $rows,
|
||||
])
|
||||
);
|
||||
}
|
||||
function update_upload_mou()
|
||||
{
|
||||
$param = $this->get_param();
|
||||
$uploadID = $param["uploadID"];
|
||||
$status = $param["status"];
|
||||
$sql = "update corp_upload set Corp_UploadStatus = ?
|
||||
, Corp_UploadRetry = Corp_UploadRetry+1
|
||||
, Corp_UploadSentDate = now()
|
||||
where Corp_UploadID = ?
|
||||
";
|
||||
$qry = $this->db->query($sql, [$status, $uploadID]);
|
||||
if (!$qry) {
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
])
|
||||
);
|
||||
}
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "OK",
|
||||
"message" => "",
|
||||
])
|
||||
);
|
||||
}
|
||||
function get_upload_mou()
|
||||
{
|
||||
//Hardcode 1st
|
||||
//2277,2278,2279,2613
|
||||
list($branchID, $branchCode) = $this->get_branch();
|
||||
$sql = "select Corp_UploadID, Corp_UploadM_MouID M_MouID,
|
||||
M_MouM_CompanyID
|
||||
from corp_upload
|
||||
join m_mou on Corp_UploadM_MouID = M_MouID
|
||||
where
|
||||
Corp_UploadStatus <> 'Y'
|
||||
and
|
||||
Corp_UploadIsActive = 'Y'
|
||||
and Corp_UploadRetry < 5
|
||||
limit 0,10
|
||||
";
|
||||
$resp = $this->get_rows($sql);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz($resp["message"]);
|
||||
}
|
||||
$result = [];
|
||||
foreach ($resp["data"] as $idx => $r) {
|
||||
$result[] = $r;
|
||||
}
|
||||
$data = json_encode(["status" => "OK", "data" => $result]);
|
||||
$this->reply_gz($data);
|
||||
}
|
||||
function mou_order($mouID)
|
||||
{
|
||||
list($branchID, $branchCode) = $this->get_branch();
|
||||
// get order | pasien
|
||||
$sql = "select T_OrderHeaderID,T_OrderHeaderDate,T_OrderHeaderLabNumber,T_OrderHeaderLabNumberExt,
|
||||
T_OrderHeaderLastUpdated, max(ifnull(T_OrderDetailValDate,'1971-01-01 00:01:01')) LastValidationDate,
|
||||
max(ifnull(T_OrderDetailVerDate,'1971-01-01 00:01:01')) LastVerifDate,
|
||||
$branchID M_BranchID, '$branchCode' M_BranchCode, T_OrderHeaderM_PatientID,
|
||||
JSON_UNQUOTE( JSON_EXTRACT(fn_get_patient_atribute(T_OrderHeaderM_PatientID),'$.patient_fullname')) FullName,
|
||||
JSON_UNQUOTE( JSON_EXTRACT(fn_get_patient_atribute(T_OrderHeaderM_PatientID),'$.M_PatientName')) M_PatientName,
|
||||
T_OrderHeaderM_CompanyID M_CompanyID, M_CompanyNumber,
|
||||
T_OrderHeaderM_MouID M_MouID,
|
||||
M_PatientNIK, M_PatientJabatan, M_PatientKedudukan, M_PatientLocation, M_PatientJob
|
||||
from
|
||||
t_orderheader
|
||||
join t_orderheaderaddon on
|
||||
T_OrderHeaderM_MouID = ?
|
||||
and T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
-- and T_OrderHeaderAddOnValidationDone = 'Y'
|
||||
join m_company on M_CompanyID = T_OrderHeaderM_CompanyID
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
join t_orderdetail
|
||||
on T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
group by T_OrderHeaderID";
|
||||
$resp = $this->get_rows($sql, [$mouID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz(
|
||||
"Err Get Order for MOU ID : $mouID | " . $resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
$orders = $resp["data"];
|
||||
echo $this->reply_gz(
|
||||
json_encode(["status" => "OK", "data" => $orders])
|
||||
);
|
||||
}
|
||||
|
||||
//Get Detail Mou
|
||||
function mou_detail($mouID)
|
||||
{
|
||||
list($branchID, $branchCode) = $this->get_branch();
|
||||
$sql = "select $branchID Corp_M_BranchID , '$branchCode' Corp_M_BranchCode,
|
||||
M_MouID, M_MouName, M_MouNote , M_CompanyNumber M_MouM_CompanyNumber,
|
||||
M_MouM_CompanyID , M_MouRefNumber ,
|
||||
M_MouNumber , M_MouStartDate , M_MouEndDate , M_MouBase,
|
||||
M_MouM_OmzetTypeID , M_MouIsReleased , M_MouReleaseDate ,
|
||||
M_MouReleaseUserID , M_MouCreated , M_MouLastUpdated ,
|
||||
M_MouIsActive, M_MouUserID
|
||||
from m_mou
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where M_MouID = ?";
|
||||
$resp = $this->get_row($sql, [$mouID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz($resp["message"]);
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
$this->error_reply_gz("Mou ID $mouID not found.");
|
||||
}
|
||||
$result = $resp["data"];
|
||||
$this->reply_gz(
|
||||
json_encode(["status" => "OK", "data" => $resp["data"]])
|
||||
);
|
||||
}
|
||||
function reply_gz($resp)
|
||||
{
|
||||
echo gzcompress($resp);
|
||||
exit();
|
||||
}
|
||||
function get_branch()
|
||||
{
|
||||
$sql =
|
||||
"select M_BranchID,M_BranchCode from m_branch where M_BranchIsActive='Y' and M_BranchIsDefault ='Y'";
|
||||
$resp = $this->get_row($sql);
|
||||
if ($resp["status"] != 1) {
|
||||
echo json_encode($resp);
|
||||
exit();
|
||||
}
|
||||
return [$resp["data"]["M_BranchID"], $resp["data"]["M_BranchCode"]];
|
||||
}
|
||||
function log($msg)
|
||||
{
|
||||
$dt = date("Y-m-d H:i:s");
|
||||
echo "$dt $msg\n";
|
||||
}
|
||||
function error_reply_gz($msg)
|
||||
{
|
||||
echo gzcompress(json_encode(["status" => "ERR", "message" => $msg]));
|
||||
}
|
||||
function reply($resp, $type = 1)
|
||||
{
|
||||
echo json_encode($resp);
|
||||
}
|
||||
function error_reply($msg)
|
||||
{
|
||||
echo json_encode(["status" => "ERR", "message" => $msg]);
|
||||
}
|
||||
function get_mou_param($mouID)
|
||||
{
|
||||
$sql = "select M_MouM_CompanyID, M_MouStartDate, M_MouEndDate
|
||||
from m_mou
|
||||
where M_MouID = ?";
|
||||
$resp = $this->get_row($sql, [$mouID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply(
|
||||
"Err Get Mou Param from $mouID : " . $resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
return [0, "1971-01-01", "1971-01-01"];
|
||||
}
|
||||
$r = $resp["data"];
|
||||
return [
|
||||
$r["M_MouM_CompanyID"],
|
||||
$r["M_MouStartDate"],
|
||||
$r["M_MouEndDate"],
|
||||
];
|
||||
}
|
||||
function getCompanyNumber($companyID)
|
||||
{
|
||||
$sql = "select M_CompanyNumber from m_company where M_CompanyID = ?";
|
||||
$resp = $this->get_row($sql, [$companyID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply(
|
||||
"Err Get Company from $companyID: " . $resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
return "";
|
||||
}
|
||||
$r = $resp["data"];
|
||||
return $r["M_CompanyNumber"];
|
||||
}
|
||||
//
|
||||
function do_global($mouID)
|
||||
{
|
||||
list($branchID, $branchCode) = $this->get_branch();
|
||||
$arr_sp = ["sp_rpt_nl_001_v2", "sp_rpt_nl_002_v2", "sp_rpt_nl_003_v2"];
|
||||
list($companyID, $startDate, $endDate) = $this->get_mou_param($mouID);
|
||||
$companyNumber = $this->getCompanyNumber($companyID);
|
||||
|
||||
$result = [];
|
||||
for ($idx = 0; $idx < 3; $idx++) {
|
||||
$sp = $arr_sp[$idx];
|
||||
$key = str_replace("sp_", "", $sp);
|
||||
$key = str_replace("_v2", "", $key);
|
||||
|
||||
$sql = "call {$sp}(?,?,?,?,'admin')";
|
||||
$resp = $this->get_sp($sql, [
|
||||
$startDate,
|
||||
$endDate,
|
||||
$companyID,
|
||||
$mouID,
|
||||
]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz("Err $sp : " . $resp["message"]);
|
||||
exit();
|
||||
}
|
||||
$xresult = [];
|
||||
foreach ($resp["data"] as $r) {
|
||||
$r["M_CompanyNumber"] = $companyNumber;
|
||||
$r["M_BranchID"] = $branchID;
|
||||
$r["M_BranchCode"] = $branchCode;
|
||||
$xresult[] = $r;
|
||||
}
|
||||
$result[$key] = $xresult;
|
||||
}
|
||||
echo $this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "OK",
|
||||
"branchID" => $branchID,
|
||||
"branchCode" => $branchCode,
|
||||
"companyID" => $companyID,
|
||||
"result" => $result,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
function get_resume_id($headerID)
|
||||
{
|
||||
$sql = "select Mcu_ResumeID from mcu_resume
|
||||
where Mcu_ResumeT_OrderHeaderID = ?
|
||||
and Mcu_ResumeIsActive = 'Y'
|
||||
order by Mcu_ResumeID desc
|
||||
limit 0,1";
|
||||
$resp = $this->get_row($sql, [$headerID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply(
|
||||
"Err Get ResumeID from T_OrderHeaderID $headerID : " .
|
||||
$resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
return 0;
|
||||
}
|
||||
return $resp["data"]["Mcu_ResumeID"];
|
||||
}
|
||||
function json_get_so_id($headerID, $so = "")
|
||||
{
|
||||
echo json_encode($this->get_so_result_entry_id($headerID, $so));
|
||||
}
|
||||
function get_so_result_entry_id($headerID, $so = "", $debug = "")
|
||||
{
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 4
|
||||
and T_TestIsNonLab = 'FISIK UMUM'
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
|
||||
if ($so == "audio") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 2
|
||||
and T_TestIsNonLab = 'AUDIOMETRY'
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "ecg") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 2
|
||||
and T_TestIsNonLab = 'ELECTROMEDIS'
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "treadmill") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 2
|
||||
and T_TestIsNonLab = 'TREADMILL'
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "elmd") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 2
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "usg") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 3
|
||||
and T_TestNat_SubGroupID = 22
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "manthoux") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 1
|
||||
and T_TestNat_SubGroupID = 10
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "pajanan") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 4
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
and So_ResultEntrySo_TemplateName = 'FISIK UMUM K3'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "fisik") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 4
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
and So_ResultEntrySo_TemplateName in ('FISIK UMUM',
|
||||
'FISIK UMUM KONSUL' )
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
}
|
||||
$resp = $this->get_row($sql, [$headerID]);
|
||||
if ($debug != "") {
|
||||
echo $this->db->last_query();
|
||||
}
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply(
|
||||
"Err Get ResumeID from T_OrderHeaderID $headerID : " .
|
||||
$resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
return 0;
|
||||
}
|
||||
if ($debug != "") {
|
||||
echo json_encode($resp);
|
||||
}
|
||||
return $resp["data"]["So_ResultEntryID"];
|
||||
}
|
||||
|
||||
// Hasil lab per individu
|
||||
// Hasil Non Lab per individu
|
||||
// Hasil Resume Individu
|
||||
// by T_OrderHeaderID
|
||||
function get_report($uploadID, $debug = "")
|
||||
{
|
||||
$sql = "select Corp_ReportCode
|
||||
from
|
||||
corp_report
|
||||
join corp_uploaderdetail on
|
||||
Corp_UploaderDetailCorp_ReportID = Corp_ReportID
|
||||
and Corp_UploaderDetailCorp_UploadID = ?";
|
||||
$qry = $this->db->query($sql, [$uploadID]);
|
||||
if (!$qry) {
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "ERR",
|
||||
"message" =>
|
||||
"Error get Reports : " . $this->db->error()["message"],
|
||||
])
|
||||
);
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$result = [];
|
||||
//pasti ikut
|
||||
$result[] = "sp_rpt_t_hasil_sampling";
|
||||
$result[] = "sp_rpt_t_hasil_sampling_eng";
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
foreach ($rows as $r) {
|
||||
$rpt_code = $r["Corp_ReportCode"];
|
||||
switch ($rpt_code) {
|
||||
case "001":
|
||||
if (!in_array("sp_rpt_t_hasil2", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil2";
|
||||
}
|
||||
break;
|
||||
case "002":
|
||||
if (!in_array("sp_rpt_t_hasil_eng", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_eng";
|
||||
}
|
||||
break;
|
||||
case "003":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_t_hasil_so_xray", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so_xray";
|
||||
}
|
||||
break;
|
||||
case "004":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_t_hasil_so_elmd", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so_elmd";
|
||||
}
|
||||
break;
|
||||
case "005":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r_eng", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r_eng";
|
||||
}
|
||||
break;
|
||||
case "006":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r_eng", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r_eng";
|
||||
}
|
||||
break;
|
||||
case "007":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r_eng", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r_eng";
|
||||
}
|
||||
break;
|
||||
case "008":
|
||||
case "009":
|
||||
if (!in_array("riw", $result)) {
|
||||
$result[] = "sp_dummy_fisik";
|
||||
}
|
||||
break;
|
||||
|
||||
case "010": //audio
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_t_hasil_so_elmd-audio", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so_elmd-audio";
|
||||
}
|
||||
break;
|
||||
case "011": //ecg
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_t_hasil_so_elmd-ecg", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so_elmd-ecg";
|
||||
}
|
||||
break;
|
||||
case "012": //treadmill
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (
|
||||
!in_array("sp_rpt_t_hasil_so_elmd-treadmill", $result)
|
||||
) {
|
||||
$result[] = "sp_rpt_t_hasil_so_elmd-treadmill";
|
||||
}
|
||||
break;
|
||||
case "013": //pajanan
|
||||
if (!in_array("sp_dummy_pajanan", $result)) {
|
||||
$result[] = "sp_dummy_pajanan";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($debug != "") {
|
||||
print_r($result);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function individu($headerID, $uploadID, $debug = "")
|
||||
{
|
||||
$arr_sp = $this->get_report($uploadID);
|
||||
$result = [];
|
||||
foreach ($arr_sp as $sp) {
|
||||
$key = str_replace("sp_", "", $sp);
|
||||
$sql = "call {$sp}(?,'admin')";
|
||||
|
||||
if ($sp == "sp_rpt_mcu_resume_cp_r") {
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resumeID = $this->get_resume_id($headerID);
|
||||
$resp = $this->get_sp($sql, [$resumeID]);
|
||||
} elseif ($sp == "sp_rpt_mcu_resume_cp_r_eng") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resumeID = $this->get_resume_id($headerID);
|
||||
$resp = $this->get_sp($sql, [$resumeID]);
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id($headerID);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_bdm") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_elmd") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"elmd"
|
||||
);
|
||||
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_elmd-audio") {
|
||||
$xsp = "sp_rpt_t_hasil_so_elmd";
|
||||
$sql = "call {$xsp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"audio"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$xsp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_elmd-ecg") {
|
||||
$xsp = "sp_rpt_t_hasil_so_elmd";
|
||||
$sql = "call {$xsp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"ecg"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$xsp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_elmd-treadmill") {
|
||||
$xsp = "sp_rpt_t_hasil_so_elmd";
|
||||
$sql = "call {$xsp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"treadmill"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$xsp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_dummy_pajanan") {
|
||||
$arr_sub_url = [
|
||||
"pribadi",
|
||||
"faktor_ergonomi",
|
||||
"faktor_biologi",
|
||||
"faktor_fisik",
|
||||
"faktor_kimia",
|
||||
"faktor_psikologi",
|
||||
];
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"pajanan"
|
||||
);
|
||||
$new_data = ["pajanan" => []];
|
||||
|
||||
if ($resultEntryID > 0) {
|
||||
foreach ($arr_sub_url as $s_url) {
|
||||
$new_data["pajanan"][$s_url] = $this->get_fisik_pajanan(
|
||||
$s_url,
|
||||
$resultEntryID,
|
||||
"k3"
|
||||
);
|
||||
}
|
||||
}
|
||||
$arr_sub_url = [
|
||||
"pribadi",
|
||||
"keluhan_saat_ini_new",
|
||||
"riwayat_phobia",
|
||||
"riwayat_obat",
|
||||
"riwayat_penyakit",
|
||||
"riwayat_hidup",
|
||||
"riwayat_keluarga",
|
||||
"tanda_vital",
|
||||
"status_gizi",
|
||||
"keadaan_umum",
|
||||
"mulut",
|
||||
"gigi",
|
||||
"visus",
|
||||
"kepala_wajah",
|
||||
"mata",
|
||||
"telinga",
|
||||
"thorax",
|
||||
"paru",
|
||||
"jantung",
|
||||
"integumen",
|
||||
"sistem",
|
||||
"anggota",
|
||||
"genitourinaria",
|
||||
"perut",
|
||||
"leher",
|
||||
"hidung",
|
||||
"persepsi_warna",
|
||||
];
|
||||
$new_data["fisik"] = [];
|
||||
$new_data["riwayat"] = [];
|
||||
if ($resultEntryID > 0) {
|
||||
foreach ($arr_sub_url as $s_url) {
|
||||
$new_data["fisik"][$s_url] = $this->get_fisik(
|
||||
$s_url,
|
||||
$resultEntryID,
|
||||
"fisik"
|
||||
);
|
||||
$new_data["riwayat"][$s_url] = $this->get_fisik(
|
||||
$s_url,
|
||||
$resultEntryID,
|
||||
"riwayat"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$resp = ["data" => $new_data, "status" => 0];
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_layanan") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"layanan"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_manthoux") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"manthoux"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_manthoux_sampling") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"manthoux"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_usg") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"usg"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_xray") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_dummy_fisik") {
|
||||
$arr_sub_url = [
|
||||
"pribadi",
|
||||
"keluhan_saat_ini_new",
|
||||
"riwayat_phobia",
|
||||
"riwayat_obat",
|
||||
"riwayat_penyakit",
|
||||
"riwayat_hidup",
|
||||
"riwayat_keluarga",
|
||||
"tanda_vital",
|
||||
"status_gizi",
|
||||
"keadaan_umum",
|
||||
"mulut",
|
||||
"gigi",
|
||||
"visus",
|
||||
"kepala_wajah",
|
||||
"mata",
|
||||
"telinga",
|
||||
"thorax",
|
||||
"paru",
|
||||
"jantung",
|
||||
"integumen",
|
||||
"sistem",
|
||||
"anggota",
|
||||
"genitourinaria",
|
||||
"perut",
|
||||
"leher",
|
||||
"hidung",
|
||||
"persepsi_warna",
|
||||
];
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"fisik"
|
||||
);
|
||||
$new_data = ["fisik" => [], "riwayat" => []];
|
||||
if ($resultEntryID > 0) {
|
||||
foreach ($arr_sub_url as $s_url) {
|
||||
$new_data["fisik"][$s_url] = $this->get_fisik(
|
||||
$s_url,
|
||||
$resultEntryID,
|
||||
"fisik"
|
||||
);
|
||||
$new_data["riwayat"][$s_url] = $this->get_fisik(
|
||||
$s_url,
|
||||
$resultEntryID,
|
||||
"riwayat"
|
||||
);
|
||||
}
|
||||
}
|
||||
$resp = ["data" => $new_data, "status" => 0];
|
||||
} else {
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
}
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz("Err $sp : " . $resp["message"]);
|
||||
exit();
|
||||
}
|
||||
$result[$key] = $resp["data"];
|
||||
if ($key == "dummy_pajanan") {
|
||||
$result["dummy_fisik"] = $resp["data"];
|
||||
}
|
||||
}
|
||||
if ($debug != "") {
|
||||
echo json_encode(["status" => "OK", "result" => $result]);
|
||||
exit();
|
||||
}
|
||||
echo $this->reply_gz(
|
||||
json_encode(["status" => "OK", "result" => $result])
|
||||
);
|
||||
}
|
||||
function get_fisik_pajanan($param, $result_entry_id, $type, $lang_id = 1)
|
||||
{
|
||||
$url = "http://localhost/one-api/v1/report/fisik/$param/$result_entry_id/$lang_id/$type/k3";
|
||||
$resp = $this->get($url);
|
||||
return json_decode($resp, true);
|
||||
}
|
||||
function get_fisik($param, $result_entry_id, $type, $lang_id = 1)
|
||||
{
|
||||
$url = "http://localhost/one-api/v1/report/fisik/$param/$result_entry_id/$lang_id/$type";
|
||||
$resp = $this->get($url);
|
||||
return json_decode($resp, true);
|
||||
}
|
||||
function get($url, $timeout = 60, $c_timeout = 5)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $c_timeout);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$result = curl_exec($ch);
|
||||
$err_msg = curl_error($ch);
|
||||
if ($err_msg != "") {
|
||||
return json_encode(["status" => "ERR", "message" => $err_msg]);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function get_sp($sql, $param = false)
|
||||
{
|
||||
$resp = $this->get_rows($sql, $param);
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
return $resp;
|
||||
}
|
||||
function get_mou($companyID)
|
||||
{
|
||||
$sql = "select M_MouID,M_MouName, M_MouNumber
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y' and M_MouM_CompanyID = ?";
|
||||
$resp = $this->get_rows($sql, [$companyID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply("Error Get MOU by Company $companyID");
|
||||
exit();
|
||||
}
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"data" => $resp["data"],
|
||||
]);
|
||||
}
|
||||
function step_debug($rows)
|
||||
{
|
||||
print_r($rows);
|
||||
exit();
|
||||
}
|
||||
function get_rows($sql, $param = false)
|
||||
{
|
||||
if ($param) {
|
||||
$qry = $this->db->query($sql, $param);
|
||||
} else {
|
||||
$qry = $this->db->query($sql);
|
||||
}
|
||||
if (!$qry) {
|
||||
return [
|
||||
"status" => -1,
|
||||
"message" =>
|
||||
$this->db->last_query() .
|
||||
"|" .
|
||||
$this->db->error()["message"],
|
||||
];
|
||||
}
|
||||
return ["status" => 0, "data" => $qry->result_array()];
|
||||
}
|
||||
function get_row($sql, $param = false)
|
||||
{
|
||||
$resp = $this->get_rows($sql, $param);
|
||||
if ($resp["status"] == -1) {
|
||||
return $resp;
|
||||
}
|
||||
if (count($resp["data"]) == 0) {
|
||||
return ["status" => 0, "message" => "Not found."];
|
||||
}
|
||||
return ["status" => 1, "data" => $resp["data"][0]];
|
||||
}
|
||||
}
|
||||
907
application/controllers/corporate/Uploader_dbg.php
Normal file
907
application/controllers/corporate/Uploader_dbg.php
Normal file
@@ -0,0 +1,907 @@
|
||||
<?php
|
||||
class Uploader_dbg extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function get_param()
|
||||
{
|
||||
$raw = file_get_contents("php://input");
|
||||
return json_decode($raw, true);
|
||||
}
|
||||
function get_company($companyID)
|
||||
{
|
||||
$sql = "select M_CompanyID, M_CompanyOldID, M_BranchID M_CompanyM_BranchID, M_CompanyName, M_CompanyNumber,
|
||||
M_CompanyIDParent, M_CompanyM_CompanyTypeID, M_CompanyM_CompanyBusinessID,
|
||||
M_CompanyM_ProvinceID, M_CompanyM_CityID, M_CompanyM_DistrictID, M_CompanyM_KelurahanID,
|
||||
M_CompanyAddress, M_CompanyPhone, M_CompanyFax, M_CompanyEmail, M_CompanyPIC,
|
||||
M_CompanyM_StaffID, M_CompanyNat_CompanyLevelID, M_CompanyNat_HierarchyID,
|
||||
M_CompanyIsLabFrom, M_CompanyIsLabTo, M_CompanyIsDefault, M_CompanyM_DoctorID,
|
||||
M_CompanyCreated, M_CompanyLastUpdated, M_CompanyIsActive, M_CompanyAddressLocation,
|
||||
M_CompanyHp, M_CompanyPrivateRequest
|
||||
from m_company
|
||||
join m_branch on M_CompanyID = ?
|
||||
and M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'";
|
||||
$qry = $this->db->query($sql, [$companyID]);
|
||||
if (!$qry) {
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
])
|
||||
);
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "OK",
|
||||
"data" => $rows,
|
||||
])
|
||||
);
|
||||
}
|
||||
function update_upload_mou()
|
||||
{
|
||||
$param = $this->get_param();
|
||||
$uploadID = $param["uploadID"];
|
||||
$status = $param["status"];
|
||||
$sql = "update corp_upload set Corp_UploadStatus = ?
|
||||
, Corp_UploadRetry = Corp_UploadRetry+1
|
||||
, Corp_UploadSentDate = now()
|
||||
where Corp_UploadID = ?
|
||||
";
|
||||
$qry = $this->db->query($sql, [$status, $uploadID]);
|
||||
if (!$qry) {
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
])
|
||||
);
|
||||
}
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "OK",
|
||||
"message" => "",
|
||||
])
|
||||
);
|
||||
}
|
||||
function get_upload_mou()
|
||||
{
|
||||
//Hardcode 1st
|
||||
//2277,2278,2279,2613
|
||||
list($branchID, $branchCode) = $this->get_branch();
|
||||
$sql = "select Corp_UploadID, Corp_UploadM_MouID M_MouID,
|
||||
M_MouM_CompanyID
|
||||
from corp_upload
|
||||
join m_mou on Corp_UploadM_MouID = M_MouID
|
||||
where
|
||||
Corp_UploadStatus <> 'Y'
|
||||
and
|
||||
Corp_UploadIsActive = 'Y'
|
||||
and Corp_UploadRetry < 5
|
||||
limit 0,10
|
||||
";
|
||||
$resp = $this->get_rows($sql);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz($resp["message"]);
|
||||
}
|
||||
$result = [];
|
||||
foreach ($resp["data"] as $idx => $r) {
|
||||
$result[] = $r;
|
||||
}
|
||||
$data = json_encode(["status" => "OK", "data" => $result]);
|
||||
$this->reply_gz($data);
|
||||
}
|
||||
function mou_order($mouID)
|
||||
{
|
||||
list($branchID, $branchCode) = $this->get_branch();
|
||||
// get order | pasien
|
||||
$sql = "select T_OrderHeaderID,T_OrderHeaderDate,T_OrderHeaderLabNumber,T_OrderHeaderLabNumberExt,
|
||||
T_OrderHeaderLastUpdated, max(ifnull(T_OrderDetailValDate,'1971-01-01 00:01:01')) LastValidationDate,
|
||||
max(ifnull(T_OrderDetailVerDate,'1971-01-01 00:01:01')) LastVerifDate,
|
||||
$branchID M_BranchID, '$branchCode' M_BranchCode, T_OrderHeaderM_PatientID,
|
||||
JSON_UNQUOTE( JSON_EXTRACT(fn_get_patient_atribute(T_OrderHeaderM_PatientID),'$.patient_fullname')) FullName,
|
||||
JSON_UNQUOTE( JSON_EXTRACT(fn_get_patient_atribute(T_OrderHeaderM_PatientID),'$.M_PatientName')) M_PatientName,
|
||||
T_OrderHeaderM_CompanyID M_CompanyID, M_CompanyNumber,
|
||||
T_OrderHeaderM_MouID M_MouID,
|
||||
M_PatientNIK, M_PatientJabatan, M_PatientKedudukan, M_PatientLocation, M_PatientJob
|
||||
from
|
||||
t_orderheader
|
||||
join t_orderheaderaddon on
|
||||
T_OrderHeaderM_MouID = ?
|
||||
and T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
-- and T_OrderHeaderAddOnValidationDone = 'Y'
|
||||
join m_company on M_CompanyID = T_OrderHeaderM_CompanyID
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
join t_orderdetail
|
||||
on T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
group by T_OrderHeaderID";
|
||||
$resp = $this->get_rows($sql, [$mouID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz(
|
||||
"Err Get Order for MOU ID : $mouID | " . $resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
$orders = $resp["data"];
|
||||
echo $this->reply_gz(
|
||||
json_encode(["status" => "OK", "data" => $orders])
|
||||
);
|
||||
}
|
||||
|
||||
//Get Detail Mou
|
||||
function mou_detail($mouID)
|
||||
{
|
||||
list($branchID, $branchCode) = $this->get_branch();
|
||||
$sql = "select $branchID Corp_M_BranchID , '$branchCode' Corp_M_BranchCode,
|
||||
M_MouID, M_MouName, M_MouNote , M_CompanyNumber M_MouM_CompanyNumber,
|
||||
M_MouM_CompanyID , M_MouRefNumber ,
|
||||
M_MouNumber , M_MouStartDate , M_MouEndDate , M_MouBase,
|
||||
M_MouM_OmzetTypeID , M_MouIsReleased , M_MouReleaseDate ,
|
||||
M_MouReleaseUserID , M_MouCreated , M_MouLastUpdated ,
|
||||
M_MouIsActive, M_MouUserID
|
||||
from m_mou
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where M_MouID = ?";
|
||||
$resp = $this->get_row($sql, [$mouID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz($resp["message"]);
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
$this->error_reply_gz("Mou ID $mouID not found.");
|
||||
}
|
||||
$result = $resp["data"];
|
||||
$this->reply_gz(
|
||||
json_encode(["status" => "OK", "data" => $resp["data"]])
|
||||
);
|
||||
}
|
||||
function reply_gz($resp)
|
||||
{
|
||||
echo gzcompress($resp);
|
||||
exit();
|
||||
}
|
||||
function get_branch()
|
||||
{
|
||||
$sql =
|
||||
"select M_BranchID,M_BranchCode from m_branch where M_BranchIsActive='Y' and M_BranchIsDefault ='Y'";
|
||||
$resp = $this->get_row($sql);
|
||||
if ($resp["status"] != 1) {
|
||||
echo json_encode($resp);
|
||||
exit();
|
||||
}
|
||||
return [$resp["data"]["M_BranchID"], $resp["data"]["M_BranchCode"]];
|
||||
}
|
||||
function log($msg)
|
||||
{
|
||||
$dt = date("Y-m-d H:i:s");
|
||||
echo "$dt $msg\n";
|
||||
}
|
||||
function error_reply_gz($msg)
|
||||
{
|
||||
echo gzcompress(json_encode(["status" => "ERR", "message" => $msg]));
|
||||
}
|
||||
function reply($resp, $type = 1)
|
||||
{
|
||||
echo json_encode($resp);
|
||||
}
|
||||
function error_reply($msg)
|
||||
{
|
||||
echo json_encode(["status" => "ERR", "message" => $msg]);
|
||||
}
|
||||
function get_mou_param($mouID)
|
||||
{
|
||||
$sql = "select M_MouM_CompanyID, M_MouStartDate, M_MouEndDate
|
||||
from m_mou
|
||||
where M_MouID = ?";
|
||||
$resp = $this->get_row($sql, [$mouID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply(
|
||||
"Err Get Mou Param from $mouID : " . $resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
return [0, "1971-01-01", "1971-01-01"];
|
||||
}
|
||||
$r = $resp["data"];
|
||||
return [
|
||||
$r["M_MouM_CompanyID"],
|
||||
$r["M_MouStartDate"],
|
||||
$r["M_MouEndDate"],
|
||||
];
|
||||
}
|
||||
function getCompanyNumber($companyID)
|
||||
{
|
||||
$sql = "select M_CompanyNumber from m_company where M_CompanyID = ?";
|
||||
$resp = $this->get_row($sql, [$companyID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply(
|
||||
"Err Get Company from $companyID: " . $resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
return "";
|
||||
}
|
||||
$r = $resp["data"];
|
||||
return $r["M_CompanyNumber"];
|
||||
}
|
||||
//
|
||||
function do_global($mouID)
|
||||
{
|
||||
list($branchID, $branchCode) = $this->get_branch();
|
||||
$arr_sp = ["sp_rpt_nl_001_v2", "sp_rpt_nl_002_v2", "sp_rpt_nl_003_v2"];
|
||||
list($companyID, $startDate, $endDate) = $this->get_mou_param($mouID);
|
||||
$companyNumber = $this->getCompanyNumber($companyID);
|
||||
|
||||
$result = [];
|
||||
for ($idx = 0; $idx < 3; $idx++) {
|
||||
$sp = $arr_sp[$idx];
|
||||
$key = str_replace("sp_", "", $sp);
|
||||
$key = str_replace("_v2", "", $key);
|
||||
|
||||
$sql = "call {$sp}(?,?,?,?,'admin')";
|
||||
$resp = $this->get_sp($sql, [
|
||||
$startDate,
|
||||
$endDate,
|
||||
$companyID,
|
||||
$mouID,
|
||||
]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz("Err $sp : " . $resp["message"]);
|
||||
exit();
|
||||
}
|
||||
$xresult = [];
|
||||
foreach ($resp["data"] as $r) {
|
||||
$r["M_CompanyNumber"] = $companyNumber;
|
||||
$r["M_BranchID"] = $branchID;
|
||||
$r["M_BranchCode"] = $branchCode;
|
||||
$xresult[] = $r;
|
||||
}
|
||||
$result[$key] = $xresult;
|
||||
}
|
||||
echo $this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "OK",
|
||||
"branchID" => $branchID,
|
||||
"branchCode" => $branchCode,
|
||||
"companyID" => $companyID,
|
||||
"result" => $result,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
function get_resume_id($headerID)
|
||||
{
|
||||
$sql = "select Mcu_ResumeID from mcu_resume
|
||||
where Mcu_ResumeT_OrderHeaderID = ?
|
||||
and Mcu_ResumeIsActive = 'Y'
|
||||
order by Mcu_ResumeID desc
|
||||
limit 0,1";
|
||||
$resp = $this->get_row($sql, [$headerID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply(
|
||||
"Err Get ResumeID from T_OrderHeaderID $headerID : " .
|
||||
$resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
return 0;
|
||||
}
|
||||
return $resp["data"]["Mcu_ResumeID"];
|
||||
}
|
||||
function json_get_so_id($headerID, $so = "")
|
||||
{
|
||||
echo json_encode($this->get_so_result_entry_id($headerID, $so));
|
||||
}
|
||||
function get_so_result_entry_id($headerID, $so = "")
|
||||
{
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 4
|
||||
and T_TestIsNonLab = 'FISIK UMUM'
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
|
||||
|
||||
if ($so == "audio") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 2
|
||||
and T_TestIsNonLab = 'AUDIOMETRY'
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "ecg") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 2
|
||||
and T_TestIsNonLab = 'ELECTROMEDIS'
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "treadmill") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 2
|
||||
and T_TestIsNonLab = 'TREADMILL'
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "elmd") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 2
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "usg") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 3
|
||||
and T_TestNat_SubGroupID = 22
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
} elseif ($so == "manthoux") {
|
||||
$sql = "select So_ResultEntryID
|
||||
from so_resultentry
|
||||
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestNat_GroupID = 1
|
||||
and T_TestNat_SubGroupID = 10
|
||||
where So_ResultEntryT_OrderHeaderID = ?
|
||||
and So_ResultentryIsActive = 'Y'
|
||||
order by So_ResultEntryID desc
|
||||
limit 0,1";
|
||||
}
|
||||
$resp = $this->get_row($sql, [$headerID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply(
|
||||
"Err Get ResumeID from T_OrderHeaderID $headerID : " .
|
||||
$resp["message"]
|
||||
);
|
||||
exit();
|
||||
}
|
||||
if ($resp["status"] == 0) {
|
||||
return 0;
|
||||
}
|
||||
return $resp["data"]["So_ResultEntryID"];
|
||||
}
|
||||
|
||||
// Hasil lab per individu
|
||||
// Hasil Non Lab per individu
|
||||
// Hasil Resume Individu
|
||||
// by T_OrderHeaderID
|
||||
function get_report($uploadID)
|
||||
{
|
||||
$sql = "select Corp_ReportCode
|
||||
from
|
||||
corp_report
|
||||
join corp_uploaderdetail on
|
||||
Corp_UploaderDetailCorp_ReportID = Corp_ReportID
|
||||
and Corp_UploaderDetailCorp_UploadID = ?";
|
||||
$qry = $this->db->query($sql, [$uploadID]);
|
||||
if (!$qry) {
|
||||
$this->reply_gz(
|
||||
json_encode([
|
||||
"status" => "ERR",
|
||||
"message" =>
|
||||
"Error get Reports : " . $this->db->error()["message"],
|
||||
])
|
||||
);
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$result = [];
|
||||
//pasti ikut
|
||||
$result[] = "sp_rpt_t_hasil_sampling";
|
||||
$result[] = "sp_rpt_t_hasil_sampling_eng";
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
foreach ($rows as $r) {
|
||||
$rpt_code = $r["Corp_ReportCode"];
|
||||
switch ($rpt_code) {
|
||||
case "001":
|
||||
if (!in_array("sp_rpt_t_hasil2", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil2";
|
||||
}
|
||||
break;
|
||||
case "002":
|
||||
if (!in_array("sp_rpt_t_hasil_eng", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_eng";
|
||||
}
|
||||
break;
|
||||
case "003":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_t_hasil_so_xray", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so_xray";
|
||||
}
|
||||
break;
|
||||
case "004":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_t_hasil_so_elmd", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so_elmd";
|
||||
}
|
||||
break;
|
||||
case "005":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r_eng", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r_eng";
|
||||
}
|
||||
break;
|
||||
case "006":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r_eng", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r_eng";
|
||||
}
|
||||
break;
|
||||
case "007":
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r";
|
||||
}
|
||||
if (!in_array("sp_rpt_mcu_resume_cp_r_eng", $result)) {
|
||||
$result[] = "sp_rpt_mcu_resume_cp_r_eng";
|
||||
}
|
||||
break;
|
||||
case "008":
|
||||
case "009":
|
||||
if (!in_array("riw", $result)) {
|
||||
$result[] = "sp_dummy_fisik";
|
||||
}
|
||||
break;
|
||||
|
||||
case "010": //audio
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_t_hasil_so_elmd-audio", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so_elmd-audio";
|
||||
}
|
||||
break;
|
||||
case "011": //ecg
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (!in_array("sp_rpt_t_hasil_so_elmd-ecg", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so_elmd-ecg";
|
||||
}
|
||||
break;
|
||||
case "012": //treadmill
|
||||
if (!in_array("sp_rpt_t_hasil_so", $result)) {
|
||||
$result[] = "sp_rpt_t_hasil_so";
|
||||
}
|
||||
if (
|
||||
!in_array("sp_rpt_t_hasil_so_elmd-treadmill", $result)
|
||||
) {
|
||||
$result[] = "sp_rpt_t_hasil_so_elmd-treadmill";
|
||||
}
|
||||
break;
|
||||
case "013": //pajanan
|
||||
if (!in_array("sp_dummy_pajanan", $result)) {
|
||||
$result[] = "sp_dummy_pajanan";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function individu($headerID, $uploadID)
|
||||
{
|
||||
$arr_sp = $this->get_report($uploadID);
|
||||
$result = [];
|
||||
foreach ($arr_sp as $sp) {
|
||||
$key = str_replace("sp_", "", $sp);
|
||||
$sql = "call {$sp}(?,'admin')";
|
||||
|
||||
if ($sp == "sp_rpt_mcu_resume_cp_r") {
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resumeID = $this->get_resume_id($headerID);
|
||||
$resp = $this->get_sp($sql, [$resumeID]);
|
||||
} elseif ($sp == "sp_rpt_mcu_resume_cp_r_eng") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resumeID = $this->get_resume_id($headerID);
|
||||
$resp = $this->get_sp($sql, [$resumeID]);
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id($headerID);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_bdm") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_elmd") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"elmd"
|
||||
);
|
||||
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_elmd-audio") {
|
||||
$xsp = "sp_rpt_t_hasil_so_elmd";
|
||||
$sql = "call {$xsp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"audio"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$xsp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_elmd-ecg") {
|
||||
$xsp = "sp_rpt_t_hasil_so_elmd";
|
||||
$sql = "call {$xsp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"ecg"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$xsp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_elmd-treadmill") {
|
||||
$xsp = "sp_rpt_t_hasil_so_elmd";
|
||||
$sql = "call {$xsp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"treadmill"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$xsp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_dummy_pajanan") {
|
||||
$arr_sub_url = [
|
||||
"pribadi",
|
||||
"faktor_biologi",
|
||||
"faktor_ergonomi",
|
||||
"faktor_fisik",
|
||||
"faktor_kimia",
|
||||
"faktor_psikologi",
|
||||
];
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"pajanan"
|
||||
);
|
||||
$new_data = ["pajanan" => []];
|
||||
|
||||
if ($resultEntryID > 0) {
|
||||
foreach ($arr_sub_url as $s_url) {
|
||||
$new_data["pajanan"][$s_url] = $this->get_fisik(
|
||||
$s_url,
|
||||
$resultEntryID,
|
||||
"k3"
|
||||
);
|
||||
}
|
||||
}
|
||||
$resp = ["data" => $new_data, "status" => 0];
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_layanan") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"layanan"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_manthoux") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"manthoux"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_manthoux_sampling") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"manthoux"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_usg") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"usg"
|
||||
);
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$resultEntryID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_rpt_t_hasil_so_xray") {
|
||||
$sql = "call {$sp}(?,2,'admin')";
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
$new_data = [];
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 2;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$sql = "call {$sp}(?,1,'admin')";
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
foreach ($resp["data"] as $d) {
|
||||
$d["M_LangID"] = 1;
|
||||
$new_data[] = $d;
|
||||
}
|
||||
$resp["data"] = $new_data;
|
||||
} elseif ($sp == "sp_dummy_fisik") {
|
||||
$arr_sub_url = [
|
||||
"pribadi",
|
||||
"keluhan_saat_ini_new",
|
||||
"riwayat_phobia",
|
||||
"riwayat_obat",
|
||||
"riwayat_penyakit",
|
||||
"riwayat_hidup",
|
||||
"riwayat_keluarga",
|
||||
"tanda_vital",
|
||||
"status_gizi",
|
||||
"keadaan_umum",
|
||||
"mulut",
|
||||
"gigi",
|
||||
"visus",
|
||||
"kepala_wajah",
|
||||
"mata",
|
||||
"telinga",
|
||||
"thorax",
|
||||
"paru",
|
||||
"jantung",
|
||||
"integumen",
|
||||
"sistem",
|
||||
"anggota",
|
||||
"genitourinaria",
|
||||
"perut",
|
||||
"leher",
|
||||
"hidung",
|
||||
"persepsi_warna",
|
||||
];
|
||||
$resultEntryID = $this->get_so_result_entry_id(
|
||||
$headerID,
|
||||
"fisik"
|
||||
);
|
||||
$new_data = ["fisik" => [], "riwayat" => []];
|
||||
if ($resultEntryID > 0) {
|
||||
foreach ($arr_sub_url as $s_url) {
|
||||
$new_data["fisik"][$s_url] = $this->get_fisik(
|
||||
$s_url,
|
||||
$resultEntryID,
|
||||
"fisik"
|
||||
);
|
||||
$new_data["riwayat"][$s_url] = $this->get_fisik(
|
||||
$s_url,
|
||||
$resultEntryID,
|
||||
"riwayat"
|
||||
);
|
||||
}
|
||||
}
|
||||
$resp = ["data" => $new_data, "status" => 0];
|
||||
} else {
|
||||
$resp = $this->get_sp($sql, [$headerID]);
|
||||
}
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply_gz("Err $sp : " . $resp["message"]);
|
||||
exit();
|
||||
}
|
||||
$result[$key] = $resp["data"];
|
||||
}
|
||||
echo $this->reply_gz(
|
||||
json_encode(["status" => "OK", "result" => $result])
|
||||
);
|
||||
}
|
||||
function get_fisik($param, $result_entry_id, $type, $lang_id = 1)
|
||||
{
|
||||
$url = "http://localhost/one-api/v1/report/fisik/$param/$result_entry_id/$lang_id/$type";
|
||||
$resp = $this->get($url);
|
||||
return json_decode($resp, true);
|
||||
}
|
||||
function get($url, $timeout = 60, $c_timeout = 5)
|
||||
{
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $c_timeout);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$result = curl_exec($ch);
|
||||
$err_msg = curl_error($ch);
|
||||
if ($err_msg != "") {
|
||||
return json_encode(["status" => "ERR", "message" => $err_msg]);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function get_sp($sql, $param = false)
|
||||
{
|
||||
$resp = $this->get_rows($sql, $param);
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
return $resp;
|
||||
}
|
||||
function get_mou($companyID)
|
||||
{
|
||||
$sql = "select M_MouID,M_MouName, M_MouNumber
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y' and M_MouM_CompanyID = ?";
|
||||
$resp = $this->get_rows($sql, [$companyID]);
|
||||
if ($resp["status"] == -1) {
|
||||
$this->error_reply("Error Get MOU by Company $companyID");
|
||||
exit();
|
||||
}
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"data" => $resp["data"],
|
||||
]);
|
||||
}
|
||||
function step_debug($rows)
|
||||
{
|
||||
print_r($rows);
|
||||
exit();
|
||||
}
|
||||
function get_rows($sql, $param = false)
|
||||
{
|
||||
if ($param) {
|
||||
$qry = $this->db->query($sql, $param);
|
||||
} else {
|
||||
$qry = $this->db->query($sql);
|
||||
}
|
||||
if (!$qry) {
|
||||
return [
|
||||
"status" => -1,
|
||||
"message" =>
|
||||
$this->db->last_query() .
|
||||
"|" .
|
||||
$this->db->error()["message"],
|
||||
];
|
||||
}
|
||||
return ["status" => 0, "data" => $qry->result_array()];
|
||||
}
|
||||
function get_row($sql, $param = false)
|
||||
{
|
||||
$resp = $this->get_rows($sql, $param);
|
||||
if ($resp["status"] == -1) {
|
||||
return $resp;
|
||||
}
|
||||
if (count($resp["data"]) == 0) {
|
||||
return ["status" => 0, "message" => "Not found."];
|
||||
}
|
||||
return ["status" => 1, "data" => $resp["data"][0]];
|
||||
}
|
||||
}
|
||||
?>
|
||||
31
application/controllers/cpone/Patient.http
Normal file
31
application/controllers/cpone/Patient.http
Normal file
@@ -0,0 +1,31 @@
|
||||
POST https://{{host}}/cpone/patient/index
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/patient/generate_adm_patient
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"date": "2023-07-11",
|
||||
"corporateID": 46
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/patient/insert_patient
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"patientoldID": "0001170402882"
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/patient/patientloop
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
377
application/controllers/cpone/Patient.php
Normal file
377
application/controllers/cpone/Patient.php
Normal file
@@ -0,0 +1,377 @@
|
||||
<?php
|
||||
class Patient extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("cpone", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "PATIENT GENERATE ADM API";
|
||||
}
|
||||
|
||||
public function generate_adm_patient()
|
||||
{
|
||||
try {
|
||||
// $this->db->trans_begin();
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//$date = $prm['date'];
|
||||
|
||||
$sql = "SELECT
|
||||
REG_DATE,
|
||||
REG_NO,
|
||||
PATIENT_ID,
|
||||
PATIENT_NAME,
|
||||
SEX_ID,
|
||||
DOB,
|
||||
AGE,
|
||||
NPK,
|
||||
JOB_TITLE,
|
||||
DEPT,
|
||||
DIVISION,
|
||||
LOCATION,
|
||||
AGREEMENT_NAME,
|
||||
OTHER_ID
|
||||
FROM x_adm_rekap_patient
|
||||
WHERE STAGE = '20'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select adm rekap patient error", $this->db);
|
||||
}
|
||||
|
||||
// print_r($rows);
|
||||
// exit;
|
||||
$count_m_patient = 1;
|
||||
$insert_query = [];
|
||||
foreach ($rows as $key => $value) {
|
||||
|
||||
// print_r($value['PATIENT_ID']);
|
||||
// exit;
|
||||
$timestamp = strtotime($value['DOB']);
|
||||
$pdob = date('Y-m-d', $timestamp);
|
||||
$p_name = addslashes($value['PATIENT_NAME']);
|
||||
$sql_check = "SELECT
|
||||
M_PatientID,
|
||||
M_PatientOldPID,
|
||||
M_PatientName
|
||||
FROM m_patient
|
||||
WHERE M_PatientIsActive = 'Y'
|
||||
AND
|
||||
(
|
||||
( M_PatientName = '{$p_name}' AND M_PatientDOB = '{$pdob}' AND '{$value['OTHER_ID']}' = '') OR
|
||||
('{$value['NPK']}' <> '' AND M_PatientNIP = '{$value['NPK']}' AND M_PatientDOB = M_PatientDOB = '{$pdob}' ) OR
|
||||
('{$value['OTHER_ID']}' <> '' AND M_PatientDOB = '{$pdob}' AND trim(M_PatientIdentifierValue) = '{$value['OTHER_ID']}')
|
||||
) ";
|
||||
$qry_check = $this->db->query($sql_check);
|
||||
|
||||
|
||||
if ($qry_check) {
|
||||
$rows_check = $qry_check->result_array();
|
||||
} else {
|
||||
/* $this->db->trans_rollback();
|
||||
$this->sys_error_db("select check patient error", $this->db);
|
||||
exit;*/
|
||||
}
|
||||
|
||||
// print_r(count($rows_check));
|
||||
// exit;
|
||||
|
||||
$title_id = 0;
|
||||
$gender = "";
|
||||
if (TRIM($value['SEX_ID']) == 'M') {
|
||||
$title_id = 1;
|
||||
$gender = "male";
|
||||
} else {
|
||||
$title_id = 3;
|
||||
$gender = "female";
|
||||
}
|
||||
|
||||
if (count($rows_check) == 0) {
|
||||
// print_r("insert");
|
||||
// exit;
|
||||
$p_name = addslashes($value['PATIENT_NAME']);
|
||||
$sql_insert = "INSERT INTO m_patient(
|
||||
M_PatientRegisteredByCorporateID,
|
||||
M_PatientOldPID,
|
||||
M_PatientNoReg,
|
||||
M_PatientM_TitleID,
|
||||
M_PatientName,
|
||||
M_PatientGender,
|
||||
M_PatientDOB,
|
||||
M_PatientNIP,
|
||||
M_PatientJob,
|
||||
M_PatientDivisi,
|
||||
M_PatientLocation,
|
||||
M_PatientDepartement,
|
||||
M_PatientCreated,
|
||||
M_PatientLastUpdated
|
||||
) VALUES(
|
||||
50,
|
||||
'{$value['PATIENT_ID']}',
|
||||
`fn_numbering_cpone`('P'),
|
||||
{$title_id},
|
||||
'{$p_name}',
|
||||
'{$gender}',
|
||||
'{$pdob}',
|
||||
'{$value['NPK']}',
|
||||
'{$value['JOB_TITLE']}',
|
||||
'{$value['DIVISION']}',
|
||||
'{$value['LOCATION']}',
|
||||
'{$value['DEPT']}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
$qry_insert = $this->db->query($sql_insert);
|
||||
$insert_query [] = $this->db->last_query();
|
||||
|
||||
/*if (!$qry_insert) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("insert m_patient error", $this->db);
|
||||
exit;
|
||||
}*/
|
||||
$count_m_patient = $count_m_patient +1;
|
||||
} else {
|
||||
$sql_select = "SELECT X_PatientM_PatientID,
|
||||
X_PatientM_PatientOldPID
|
||||
FROM x_patient
|
||||
WHERE X_PatientM_PatientID = {$rows_check[0]['M_PatientID']}";
|
||||
$qry_select = $this->db->query($sql_select);
|
||||
if ($qry_select) {
|
||||
$rows = $qry_select->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select x_patient", $this->db);
|
||||
}
|
||||
|
||||
|
||||
if (count($rows) == 0) {
|
||||
$sql = "UPDATE m_patient SET M_PatientOldPID = '{$value['PATIENT_ID']}'
|
||||
WHERE M_PatientID = {$rows_check[0]['M_PatientID']} ";
|
||||
$this->db->query($sql);
|
||||
if ($rows_check[0]['M_PatientOldPID'] == "") {
|
||||
$sql = "INSERT INTO x_patient(
|
||||
X_PatientM_PatientID,
|
||||
X_PatientM_PatientOldPID,
|
||||
X_PatientCreated) VALUES(
|
||||
'{$rows_check[0]['M_PatientID']}',
|
||||
'{$value['PATIENT_ID']}',
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db->query($sql);
|
||||
/*if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("insert m_patient error", $this->db);
|
||||
exit;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//$this->db->trans_commit();
|
||||
$result = array(
|
||||
"message" => "Pasien berhasil ditambahkan sebanyak ".$count_m_patient,
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"sql_insert"=> JOIN(";",$insert_query)
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
/* function patientloop()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$patientoldID = $prm['patientoldID'];
|
||||
$sql = "select *
|
||||
from x_adm_rekap_patient";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach ($rows as $key => $value) {
|
||||
$this->insert_patient($value['PATIENT_ID']);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"message" => "Selesai"
|
||||
]);
|
||||
} */
|
||||
|
||||
public function insert_patient()
|
||||
{
|
||||
try {
|
||||
|
||||
//$this->db->trans_begin();
|
||||
|
||||
$sql_adm = "SELECT REG_DATE,
|
||||
REG_NO,
|
||||
PATIENT_ID,
|
||||
PATIENT_NAME,
|
||||
AGE,
|
||||
top_patient.M_PatientID as m_patient_id
|
||||
FROM x_adm_rekap_patient
|
||||
JOIN m_patient as top_patient ON PATIENT_ID = top_patient.M_PatientOldPID
|
||||
WHERE
|
||||
STAGE = '20'";
|
||||
$qry_adm = $this->db->query($sql_adm);
|
||||
//echo $this->db->last_query();
|
||||
if (!$qry_adm) {
|
||||
//$this->db->trans_rollback();
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error_db('select x_adm_rekap_patient error', $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry_adm->result_array();
|
||||
//print_r($rows);
|
||||
// exit;
|
||||
$count_order = 1;
|
||||
foreach ($rows as $key => $row_adm) {
|
||||
$sql_check_order = "SELECT
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderOldLabNumber,
|
||||
T_OrderHeaderM_PatientID
|
||||
FROM x_t_orderheader
|
||||
WHERE T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderOldLabNumber = ?";
|
||||
$qry_check_order = $this->db->query($sql_check_order, array(
|
||||
$row_adm['REG_NO']
|
||||
));
|
||||
// echo $this->db->last_query();
|
||||
if ($qry_check_order) {
|
||||
$rows_check_order = $qry_check_order->result_array();
|
||||
} else {
|
||||
//$this->db->trans_rollback();
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error_db("select check t_orderheader", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$reg_date = $row_adm['REG_DATE'];
|
||||
$full_date = $reg_date . ' 12:00:00';
|
||||
|
||||
if (count($rows_check_order) == 0) {
|
||||
// print_r('belum ada');
|
||||
// exit;
|
||||
|
||||
$sql_insert_order = "INSERT INTO x_t_orderheader(
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderOldLabNumber,
|
||||
T_OrderHeaderM_PatientID,
|
||||
T_OrderHeaderCorporateID,
|
||||
T_OrderHeaderMgm_McuID,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
T_OrderHeaderCreated,
|
||||
T_OrderHeaderLastUpdated) VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
now(),
|
||||
now())";
|
||||
$qry_insert_order = $this->db->query($sql_insert_order, array(
|
||||
$full_date,
|
||||
$row_adm['REG_NO'],
|
||||
$row_adm['REG_NO'],
|
||||
$row_adm['m_patient_id'],
|
||||
77,
|
||||
0,
|
||||
$row_adm['AGE']
|
||||
));
|
||||
//echo $this->db->last_query();
|
||||
if (!$qry_insert_order) {
|
||||
//$this->db->trans_rollback();
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error_db("insert t_orderheader error", $this->db);
|
||||
exit;
|
||||
}
|
||||
$count_order = $count_order + 1;
|
||||
$insertid = $this->db->insert_id();
|
||||
|
||||
$sql_select_testid = "SELECT
|
||||
name,
|
||||
name_v,
|
||||
test_id
|
||||
FROM x_map_lab";
|
||||
$qry_select_testid = $this->db->query($sql_select_testid);
|
||||
//echo $this->db->last_query();
|
||||
if ($qry_select_testid) {
|
||||
$rows_test = $qry_select_testid->result_array();
|
||||
} else {
|
||||
//$this->db->trans_rollback;
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error_db("select x_map_lab", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// print_r($rows_test);
|
||||
// exit;
|
||||
foreach ($rows_test as $key => $value) {
|
||||
// print_r($value);
|
||||
// exit;
|
||||
$sql_insert_detail = "insert into x_t_orderdetail (
|
||||
T_OrderDetailT_OrderHeaderID,
|
||||
T_OrderDetailT_TestID,
|
||||
T_OrderDetailT_TestCode,
|
||||
T_OrderDetailT_TestSasCode,
|
||||
T_OrderDetailT_TestName,
|
||||
T_OrderDetailT_TestIsResult,
|
||||
T_OrderDetailT_TestIsPrice )
|
||||
SELECT
|
||||
?,
|
||||
T_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice
|
||||
FROM t_test
|
||||
WHERE T_TestID in (?)";
|
||||
$qry_insert_detail = $this->db->query($sql_insert_detail, array(
|
||||
$insertid,
|
||||
$value['test_id']
|
||||
));
|
||||
//echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry_insert_detail) {
|
||||
// $this->db->trans_rollback();
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error_db('insert t_orderdetail error', $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//$this->db->trans_commit();
|
||||
$result = array(
|
||||
"message" => "Berhasil",
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
368
application/controllers/cpone/Patient.php-minusnpk
Normal file
368
application/controllers/cpone/Patient.php-minusnpk
Normal file
@@ -0,0 +1,368 @@
|
||||
<?php
|
||||
class Patient extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("cpone", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "PATIENT GENERATE ADM API";
|
||||
}
|
||||
|
||||
public function generate_adm_patient()
|
||||
{
|
||||
try {
|
||||
// $this->db->trans_begin();
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//$date = $prm['date'];
|
||||
|
||||
$sql = "SELECT
|
||||
REG_DATE,
|
||||
REG_NO,
|
||||
PATIENT_ID,
|
||||
PATIENT_NAME,
|
||||
SEX_ID,
|
||||
DOB,
|
||||
AGE,
|
||||
NPK,
|
||||
JOB_TITLE,
|
||||
DEPT,
|
||||
DIVISION,
|
||||
LOCATION,
|
||||
AGREEMENT_NAME
|
||||
FROM x_adm_rekap_patient
|
||||
WHERE STAGE = '3'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select adm rekap patient error", $this->db);
|
||||
}
|
||||
|
||||
// print_r($rows);
|
||||
// exit;
|
||||
$count_m_patient = 1;
|
||||
foreach ($rows as $key => $value) {
|
||||
|
||||
// print_r($value['PATIENT_ID']);
|
||||
// exit;
|
||||
$timestamp = strtotime($value['DOB']);
|
||||
$pdob = date('Y-m-d', $timestamp);
|
||||
$p_name = addslashes($value['PATIENT_NAME']);
|
||||
$sql_check = "SELECT
|
||||
M_PatientID,
|
||||
M_PatientOldPID,
|
||||
M_PatientName
|
||||
FROM m_patient
|
||||
WHERE M_PatientIsActive = 'Y'
|
||||
AND M_PatientName = '{$p_name}'
|
||||
AND M_PatientDOB = '{$pdob}'
|
||||
AND M_PatientNIP = '{$value['NPK']}'";
|
||||
$qry_check = $this->db->query($sql_check);
|
||||
|
||||
if ($qry_check) {
|
||||
$rows_check = $qry_check->result_array();
|
||||
} else {
|
||||
/* $this->db->trans_rollback();
|
||||
$this->sys_error_db("select check patient error", $this->db);
|
||||
exit;*/
|
||||
}
|
||||
|
||||
// print_r(count($rows_check));
|
||||
// exit;
|
||||
|
||||
$title_id = 0;
|
||||
$gender = "";
|
||||
if (TRIM($value['SEX_ID']) == 'M') {
|
||||
$title_id = 1;
|
||||
$gender = "male";
|
||||
} else {
|
||||
$title_id = 3;
|
||||
$gender = "female";
|
||||
}
|
||||
|
||||
if (count($rows_check) == 0) {
|
||||
// print_r("insert");
|
||||
// exit;
|
||||
$p_name = addslashes($value['PATIENT_NAME']);
|
||||
$sql_insert = "INSERT INTO m_patient(
|
||||
M_PatientRegisteredByCorporateID,
|
||||
M_PatientOldPID,
|
||||
M_PatientNoReg,
|
||||
M_PatientM_TitleID,
|
||||
M_PatientName,
|
||||
M_PatientGender,
|
||||
M_PatientDOB,
|
||||
M_PatientNIP,
|
||||
M_PatientJob,
|
||||
M_PatientDivisi,
|
||||
M_PatientLocation,
|
||||
M_PatientDepartement,
|
||||
M_PatientCreated,
|
||||
M_PatientLastUpdated
|
||||
) VALUES(
|
||||
50,
|
||||
'{$value['PATIENT_ID']}',
|
||||
`fn_numbering_cpone`('P'),
|
||||
{$title_id},
|
||||
'{$p_name}',
|
||||
'{$gender}',
|
||||
'{$pdob}',
|
||||
'{$value['NPK']}',
|
||||
'{$value['JOB_TITLE']}',
|
||||
'{$value['DIVISION']}',
|
||||
'{$value['LOCATION']}',
|
||||
'{$value['DEPT']}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
$qry_insert = $this->db->query($sql_insert);
|
||||
//echo $this->db->last_query();
|
||||
/*if (!$qry_insert) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("insert m_patient error", $this->db);
|
||||
exit;
|
||||
}*/
|
||||
$count_m_patient = $count_m_patient +1;
|
||||
} else {
|
||||
$sql_select = "SELECT X_PatientM_PatientID,
|
||||
X_PatientM_PatientOldPID
|
||||
FROM x_patient
|
||||
WHERE X_PatientM_PatientID = {$rows_check[0]['M_PatientID']}";
|
||||
$qry_select = $this->db->query($sql_select);
|
||||
if ($qry_select) {
|
||||
$rows = $qry_select->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select x_patient", $this->db);
|
||||
}
|
||||
|
||||
|
||||
if (count($rows) == 0) {
|
||||
$sql = "UPDATE m_patient SET M_PatientOldPID = '{$value['PATIENT_ID']}'
|
||||
WHERE M_PatientID = {$rows_check[0]['M_PatientID']} ";
|
||||
$this->db->query($sql);
|
||||
if ($rows_check[0]['M_PatientOldPID'] == "") {
|
||||
$sql = "INSERT INTO x_patient(
|
||||
X_PatientM_PatientID,
|
||||
X_PatientM_PatientOldPID,
|
||||
X_PatientCreated) VALUES(
|
||||
'{$rows_check[0]['M_PatientID']}',
|
||||
'{$value['PATIENT_ID']}',
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db->query($sql);
|
||||
/*if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("insert m_patient error", $this->db);
|
||||
exit;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//$this->db->trans_commit();
|
||||
$result = array(
|
||||
"message" => "Pasien berhasil ditambahkan sebanyak ".$count_m_patient,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function patientloop()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$patientoldID = $prm['patientoldID'];
|
||||
$sql = "select *
|
||||
from x_adm_rekap_patient";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach ($rows as $key => $value) {
|
||||
$this->insert_patient($value['PATIENT_ID']);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"message" => "Selesai"
|
||||
]);
|
||||
}
|
||||
|
||||
public function insert_patient()
|
||||
{
|
||||
try {
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
$sql_adm = "SELECT REG_DATE,
|
||||
REG_NO,
|
||||
PATIENT_ID,
|
||||
PATIENT_NAME,
|
||||
AGE,
|
||||
top_patient.M_PatientID as m_patient_id
|
||||
FROM x_adm_rekap_patient
|
||||
JOIN m_patient as top_patient ON PATIENT_ID = top_patient.M_PatientOldPID
|
||||
WHERE
|
||||
STAGE = '2'";
|
||||
$qry_adm = $this->db->query($sql_adm);
|
||||
//echo $this->db->last_query();
|
||||
if (!$qry_adm) {
|
||||
$this->db->trans_rollback();
|
||||
//echo $this->db->last_query();
|
||||
$this->sys_error_db('select x_adm_rekap_patient error', $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry_adm->result_array();
|
||||
//print_r($rows);
|
||||
// exit;
|
||||
foreach ($rows as $key => $row_adm) {
|
||||
$sql_check_order = "SELECT
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderOldLabNumber,
|
||||
T_OrderHeaderM_PatientID
|
||||
FROM x_t_orderheader
|
||||
WHERE T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderOldLabNumber = ?";
|
||||
$qry_check_order = $this->db->query($sql_check_order, array(
|
||||
$row_adm['REG_NO']
|
||||
));
|
||||
// echo $this->db->last_query();
|
||||
if ($qry_check_order) {
|
||||
$rows_check_order = $qry_check_order->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
//echo $this->db->last_query();
|
||||
$this->sys_error_db("select check t_orderheader", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$reg_date = $row_adm['REG_DATE'];
|
||||
$full_date = $reg_date . ' 12:00:00';
|
||||
|
||||
if (count($rows_check_order) == 0) {
|
||||
// print_r('belum ada');
|
||||
// exit;
|
||||
|
||||
$sql_insert_order = "INSERT INTO x_t_orderheader(
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderOldLabNumber,
|
||||
T_OrderHeaderM_PatientID,
|
||||
T_OrderHeaderCorporateID,
|
||||
T_OrderHeaderMgm_McuID,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
T_OrderHeaderCreated,
|
||||
T_OrderHeaderLastUpdated) VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
now(),
|
||||
now())";
|
||||
$qry_insert_order = $this->db->query($sql_insert_order, array(
|
||||
$full_date,
|
||||
$row_adm['REG_NO'],
|
||||
$row_adm['REG_NO'],
|
||||
$row_adm['m_patient_id'],
|
||||
50,
|
||||
0,
|
||||
$row_adm['AGE']
|
||||
));
|
||||
//echo $this->db->last_query();
|
||||
if (!$qry_insert_order) {
|
||||
$this->db->trans_rollback();
|
||||
//echo $this->db->last_query();
|
||||
$this->sys_error_db("insert t_orderheader error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$insertid = $this->db->insert_id();
|
||||
|
||||
$sql_select_testid = "SELECT
|
||||
name,
|
||||
name_v,
|
||||
test_id
|
||||
FROM x_map_lab";
|
||||
$qry_select_testid = $this->db->query($sql_select_testid);
|
||||
//echo $this->db->last_query();
|
||||
if ($qry_select_testid) {
|
||||
$rows_test = $qry_select_testid->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback;
|
||||
//echo $this->db->last_query();
|
||||
$this->sys_error_db("select x_map_lab", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// print_r($rows_test);
|
||||
// exit;
|
||||
foreach ($rows_test as $key => $value) {
|
||||
// print_r($value);
|
||||
// exit;
|
||||
$sql_insert_detail = "insert into x_t_orderdetail (
|
||||
T_OrderDetailT_OrderHeaderID,
|
||||
T_OrderDetailT_TestID,
|
||||
T_OrderDetailT_TestCode,
|
||||
T_OrderDetailT_TestSasCode,
|
||||
T_OrderDetailT_TestName,
|
||||
T_OrderDetailT_TestIsResult,
|
||||
T_OrderDetailT_TestIsPrice )
|
||||
SELECT
|
||||
?,
|
||||
T_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice
|
||||
FROM t_test
|
||||
WHERE T_TestID in (?)";
|
||||
$qry_insert_detail = $this->db->query($sql_insert_detail, array(
|
||||
$insertid,
|
||||
$value['test_id']
|
||||
));
|
||||
//echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry_insert_detail) {
|
||||
$this->db->trans_rollback();
|
||||
// echo $this->db->last_query();
|
||||
$this->sys_error_db('insert t_orderdetail error', $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"message" => "Berhasil",
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
35
application/controllers/cpone/Result.http
Normal file
35
application/controllers/cpone/Result.http
Normal file
@@ -0,0 +1,35 @@
|
||||
POST https://{{host}}/cpone/result/index
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/result/get_branch
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/result/search
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"date": "2024-03-08",
|
||||
"branchCode": "W001",
|
||||
"search": "",
|
||||
"current_page": 1,
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/result/getlistlogapi
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"resultID": 23,
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
169
application/controllers/cpone/Result.php
Normal file
169
application/controllers/cpone/Result.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
class Result extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("cpone", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "RESULT API";
|
||||
}
|
||||
|
||||
function get_branch()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT M_BranchID as branchID,
|
||||
M_BranchCode,
|
||||
M_BranchName,
|
||||
M_BranchAddress
|
||||
FROM m_branch
|
||||
WHERE M_BranchIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("branch select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
}
|
||||
$test_name = "";
|
||||
if (isset($prm['test_name'])) {
|
||||
$test_name = trim($prm["test_name"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_tot = "SELECT COUNT(*) AS total FROM(
|
||||
SELECT api_result.*, IF(Nat_TestName IS NULL, 'Belum Mapping', Nat_TestName) AS Nat_TestName
|
||||
FROM api_result
|
||||
LEFT JOIN nat_testmap ON Nat_TestMapCode = api_ResultTestCode
|
||||
LEFT JOIN nat_test ON Nat_TestMapNat_TestID = Nat_TestID
|
||||
WHERE `api_ResultNolab` = ? AND (`api_ResultTestName` LIKE CONCAT('%', ?, '%') OR api_ResultTestCode LIKE CONCAT('%', ?, '%'))
|
||||
) x";
|
||||
$qry_tot = $this->db->query($sql_tot, [ $search, $test_name, $test_name]);
|
||||
//echo $this->db->last_query();
|
||||
//exit;
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_tot) {
|
||||
$tot_count = $qry_tot->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("result count error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT api_result.*, IF(Nat_TestName IS NULL, 'Belum Mapping', Nat_TestName) AS Nat_TestName, IF(Nat_TestCode IS NULL, '', Nat_TestCode) AS Nat_TestCode
|
||||
FROM api_result
|
||||
LEFT JOIN nat_testmap ON Nat_TestMapCode = api_ResultTestCode
|
||||
LEFT JOIN nat_test ON Nat_TestMapNat_TestID = Nat_TestID
|
||||
WHERE `api_ResultNolab` = ? AND (`api_ResultTestName` LIKE CONCAT('%', ?, '%') OR api_ResultTestCode LIKE CONCAT('%', ?, '%'))
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [ $search, $test_name, $test_name,$number_limit, $number_offset]);
|
||||
//echo $this->db->last_query();
|
||||
//exit;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select result error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getlistlogapi()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$resultID = $prm["resultID"];
|
||||
|
||||
$sql = "SELECT log_ApiID,
|
||||
log_ApiDate,
|
||||
log_ApiM_BranchCode,
|
||||
log_ApiEndpoint,
|
||||
log_ApiParam,
|
||||
log_ApiResponse,
|
||||
log_ApiType,
|
||||
log_ApiIsParsed
|
||||
FROM cpone_log.log_api
|
||||
JOIN api_result ON log_ApiID = api_ResultLog_ApiID
|
||||
WHERE api_ResultID = ?";
|
||||
$qry = $this->db->query($sql, [$resultID]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select log_api error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key]["log_ApiParam"] = json_encode(json_decode($value["log_ApiParam"]), JSON_PRETTY_PRINT);
|
||||
}
|
||||
$result = array(
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
169
application/controllers/cpone/Result.php--050325
Normal file
169
application/controllers/cpone/Result.php--050325
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
class Result extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("cpone", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "RESULT API";
|
||||
}
|
||||
|
||||
function get_branch()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT M_BranchID as branchID,
|
||||
M_BranchCode,
|
||||
M_BranchName,
|
||||
M_BranchAddress
|
||||
FROM m_branch
|
||||
WHERE M_BranchIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("branch select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
}
|
||||
$test_name = "";
|
||||
if (isset($prm['test_name'])) {
|
||||
$test_name = trim($prm["test_name"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_tot = "SELECT COUNT(*) AS total FROM(
|
||||
SELECT api_result.*, IF(Nat_TestName IS NULL, 'Belum Mapping', Nat_TestName) AS Nat_TestName
|
||||
FROM api_result
|
||||
LEFT JOIN nat_testmap ON Nat_TestMapCode = api_ResultTestCode
|
||||
LEFT JOIN nat_test ON Nat_TestMapNat_TestID = Nat_TestID
|
||||
WHERE `api_ResultNolab` = ? AND (`api_ResultTestName` LIKE CONCAT('%', ?, '%') OR api_ResultTestCode LIKE CONCAT('%', ?, '%'))
|
||||
) x";
|
||||
$qry_tot = $this->db->query($sql_tot, [ $search, $test_name, $test_name]);
|
||||
//echo $this->db->last_query();
|
||||
//exit;
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_tot) {
|
||||
$tot_count = $qry_tot->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("result count error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT api_result.*, IF(Nat_TestName IS NULL, 'Belum Mapping', Nat_TestName) AS Nat_TestName
|
||||
FROM api_result
|
||||
LEFT JOIN nat_testmap ON Nat_TestMapCode = api_ResultTestCode
|
||||
LEFT JOIN nat_test ON Nat_TestMapNat_TestID = Nat_TestID
|
||||
WHERE `api_ResultNolab` = ? AND (`api_ResultTestName` LIKE CONCAT('%', ?, '%') OR api_ResultTestCode LIKE CONCAT('%', ?, '%'))
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [ $search, $test_name, $test_name,$number_limit, $number_offset]);
|
||||
//echo $this->db->last_query();
|
||||
//exit;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select result error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getlistlogapi()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$resultID = $prm["resultID"];
|
||||
|
||||
$sql = "SELECT log_ApiID,
|
||||
log_ApiDate,
|
||||
log_ApiM_BranchCode,
|
||||
log_ApiEndpoint,
|
||||
log_ApiParam,
|
||||
log_ApiResponse,
|
||||
log_ApiType,
|
||||
log_ApiIsParsed
|
||||
FROM cpone_log.log_api
|
||||
JOIN api_result ON log_ApiID = api_ResultLog_ApiID
|
||||
WHERE api_ResultID = ?";
|
||||
$qry = $this->db->query($sql, [$resultID]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select log_api error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key]["log_ApiParam"] = json_encode(json_decode($value["log_ApiParam"]), JSON_PRETTY_PRINT);
|
||||
}
|
||||
$result = array(
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
2907
application/controllers/cpone/inject/Corporate.php
Normal file
2907
application/controllers/cpone/inject/Corporate.php
Normal file
File diff suppressed because it is too large
Load Diff
2907
application/controllers/cpone/inject/Preregisterv2.php
Normal file
2907
application/controllers/cpone/inject/Preregisterv2.php
Normal file
File diff suppressed because it is too large
Load Diff
15
application/controllers/cpone/masterdata/Fisiktemplate.http
Normal file
15
application/controllers/cpone/masterdata/Fisiktemplate.http
Normal file
@@ -0,0 +1,15 @@
|
||||
POST https://{{host}}/cpone/masterdata/fisiktemplate/index
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/masterdata/fisiktemplate/lookupfisikbyname
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"lookupfisikbyname": "",
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
906
application/controllers/cpone/masterdata/Fisiktemplate.php
Normal file
906
application/controllers/cpone/masterdata/Fisiktemplate.php
Normal file
@@ -0,0 +1,906 @@
|
||||
<?php
|
||||
|
||||
class Fisiktemplate extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "PATIENT API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookupfisikbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$fisikname = $prm['fisikname'];
|
||||
$filter = '';
|
||||
if (isset($sexid)) {
|
||||
$filter .= "AND ($sexid = 0 or ($sexid > 0 and Nat_SexID = $sexid)) ";
|
||||
}
|
||||
if (isset($flagid)) {
|
||||
$filter .= "AND ($flagid = 0 or ($flagid > 0 and Nat_FlagID = $flagid))";
|
||||
}
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "SELECT COUNT(*) as total FROM
|
||||
(SELECT *
|
||||
FROM fisik_template_mapping
|
||||
WHERE FisikTemplateMappingIsActive = 'Y' AND
|
||||
FisikTemplateMappingName LIKE '%{$fisikname}%'
|
||||
GROUP BY FisikTemplateMappingID) x";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("fisik_template_mapping count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT FisikTemplateMappingID as id,
|
||||
FisikTemplateMappingID,
|
||||
FisikTemplateMappingName
|
||||
FROM fisik_template_mapping
|
||||
WHERE FisikTemplateMappingIsActive = 'Y' AND
|
||||
FisikTemplateMappingName LIKE '%{$fisikname}%'
|
||||
GROUP BY FisikTemplateMappingID
|
||||
ORDER BY FisikTemplateMappingName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
// $sql_param = array($search);
|
||||
$query = $this->db->query($sql);
|
||||
// echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("fisik_template_mapping select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function addfisik()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO fisik_template_mapping(
|
||||
FisikTemplateMappingName,
|
||||
FisikTemplateMappingCreated,
|
||||
FisikTemplateMappingCreatedUserID,
|
||||
FisikTemplateMappingLastUpdated
|
||||
) VALUES(?,NOW(),?,NOW())";
|
||||
$qry = $this->db->query($sql, array($name, $userid));
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("save fisik_template_mapping error", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookupfisikdetailbyid()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$all = $prm['all'];
|
||||
// $filter = '';
|
||||
// if ($status != 'A') {
|
||||
// $filter .= "AND status = '{$status}' ";
|
||||
// } else {
|
||||
// $filter .= "";
|
||||
// }
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "SELECT COUNT(*) as total
|
||||
FROM (
|
||||
SELECT *, IF(IFNULL(FisikTemplateMappingDetailID, 0) > 0, 'Y', 'N') AS status
|
||||
FROM fisik_template
|
||||
LEFT JOIN fisik_template_mapping_detail ON FisikTemplateID = FisikTemplateMappingDetailFisikTemplateID
|
||||
AND FisikTemplateMappingDetailFisikTemplateMappingID = $id AND FisikTemplateMappingDetailIsActive = 'Y'
|
||||
) x
|
||||
WHERE
|
||||
FisikTemplateCode LIKE '%{$code}%' AND
|
||||
FisikTemplateTitle LIKE '%{$name}%'";
|
||||
// $total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("fisik_template count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT FisikTemplateID as id,
|
||||
FisikTemplateJSON as xjson,
|
||||
FisikTemplateID,
|
||||
FisikTemplateType,
|
||||
FisikTemplateCode,
|
||||
FisikTemplateTableName,
|
||||
FisikTemplateTitle,
|
||||
FisikTemplateMappingDetailID,
|
||||
FisikTemplateMappingDetailFisikTemplateMappingID,
|
||||
FisikTemplateMappingDetailFisikTemplateID,
|
||||
FisikTemplateIsActive,
|
||||
IF(IFNULL(FisikTemplateMappingDetailID, 0) > 0, 'Y', 'N') AS status
|
||||
FROM fisik_template
|
||||
LEFT JOIN fisik_template_mapping_detail ON FisikTemplateID = FisikTemplateMappingDetailFisikTemplateID
|
||||
AND FisikTemplateMappingDetailFisikTemplateMappingID = $id AND FisikTemplateMappingDetailIsActive = 'Y'
|
||||
WHERE FisikTemplateIsActive = 'Y' AND
|
||||
FisikTemplateCode LIKE '%{$code}%' AND
|
||||
FisikTemplateTitle LIKE '%{$name}%'
|
||||
|
||||
|
||||
GROUP BY FisikTemplateID
|
||||
ORDER BY FisikTemplateCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key]['xjson'] = json_decode($value['xjson']);
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("fisik_template select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function saveaddeditfisikdetail()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$mappingdetailid = $prm['FisikTemplateMappingDetailID'];
|
||||
$templatemappingID = $prm['templatemappingID'];
|
||||
$templateID = $prm['FisikTemplateID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($status == 'Y') {
|
||||
$sql = "INSERT INTO fisik_template_mapping_detail(
|
||||
FisikTemplateMappingDetailFisikTemplateMappingID,
|
||||
FisikTemplateMappingDetailFisikTemplateID,
|
||||
FisikTemplateMappingDetailCreated,
|
||||
FisikTemplateMappingDetailCreatedUserID,
|
||||
FisikTemplateMappingDetailLastUpdated) VALUES(?,?,NOW(),?,NOW())";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$templatemappingID,
|
||||
$templateID,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fisik_template_mapping_detail insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE fisik_template_mapping_detail SET
|
||||
FisikTemplateMappingDetailIsActive = 'N',
|
||||
FisikTemplateMappingDetailLastUpdated = NOW(),
|
||||
FisikTemplateMappingDetailLastUpdatedUserID = ?
|
||||
WHERE FisikTemplateMappingDetailID = ?";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$userid,
|
||||
$mappingdetailid,
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fisik_template_mapping_detail insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookupuserbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$groupname = $prm['groupname'];
|
||||
$filter = '';
|
||||
if (isset($sexid)) {
|
||||
$filter .= "AND ($sexid = 0 or ($sexid > 0 and Nat_SexID = $sexid)) ";
|
||||
}
|
||||
if (isset($flagid)) {
|
||||
$filter .= "AND ($flagid = 0 or ($flagid > 0 and Nat_FlagID = $flagid))";
|
||||
}
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *
|
||||
from m_usergroup
|
||||
WHERE
|
||||
M_UserGroupIsActive = 'Y' AND
|
||||
M_UserGroupName like '%{$groupname}%'
|
||||
$filter GROUP BY M_UserGroupID) a";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("m_usergroup count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT m_usergroup.*,
|
||||
M_UserGroupID as id,
|
||||
M_UserGroupID,
|
||||
M_UserGroupName
|
||||
FROM m_usergroup
|
||||
WHERE
|
||||
M_UserGroupIsActive = 'Y' AND
|
||||
M_UserGroupName like '%{$groupname}%'
|
||||
$filter
|
||||
GROUP BY M_UserGroupID
|
||||
ORDER BY M_UserGroupName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
// echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_usergroup select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function lookupreportbyid()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$reportgroup = $prm['reportgroup'];
|
||||
$reportcode = $prm['reportcode'];
|
||||
$reportname = $prm['reportname'];
|
||||
$status = $prm['status'];
|
||||
$all = $prm['all'];
|
||||
$filter = '';
|
||||
if ($status != 'A') {
|
||||
$filter .= "AND status = '{$status}' ";
|
||||
} else {
|
||||
$filter .= "";
|
||||
}
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *, IF(IFNULL(UserGroupReportID,0) > 0 , 'Y', 'N') as status
|
||||
from r_report
|
||||
LEFT JOIN usergroup_report ON R_ReportID = UserGroupReportR_ReportID AND UserGroupReportM_UserGroupID = $id AND UserGroupReportIsActive = 'Y'
|
||||
LEFT JOIN m_usergroup ON UserGroupReportM_UserGroupID = M_UserGroupID AND M_UserGroupIsActive = 'Y'
|
||||
LEFT JOIN r_reportgroup ON R_ReportR_ReportGroupID = R_ReportGroupID
|
||||
WHERE
|
||||
R_ReportIsActive = 'Y') a
|
||||
WHERE
|
||||
R_ReportGroupName like '%{$reportgroup}%' AND
|
||||
R_ReportCode like '%{$reportcode}%' AND
|
||||
R_ReportName like '%{$reportname}%' $filter";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("r_report count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(select R_ReportID as id,
|
||||
R_ReportID,
|
||||
R_ReportCode,
|
||||
R_ReportName,
|
||||
R_ReportGroupName,
|
||||
UserGroupReportID,
|
||||
UserGroupReportM_UserGroupID,
|
||||
UserGroupReportR_ReportID,
|
||||
IF(IFNULL(UserGroupReportID,0) > 0 , 'Y', 'N') as status
|
||||
from r_report
|
||||
LEFT JOIN usergroup_report ON R_ReportID = UserGroupReportR_ReportID AND UserGroupReportM_UserGroupID = $id AND UserGroupReportIsActive = 'Y'
|
||||
LEFT JOIN m_usergroup ON UserGroupReportM_UserGroupID = M_UserGroupID AND M_UserGroupIsActive = 'Y'
|
||||
LEFT JOIN r_reportgroup ON R_ReportR_ReportGroupID = R_ReportGroupID
|
||||
WHERE
|
||||
R_ReportIsActive = 'Y') a
|
||||
WHERE
|
||||
R_ReportGroupName like '%{$reportgroup}%' AND
|
||||
R_ReportCode like '%{$reportcode}%' AND
|
||||
R_ReportName like '%{$reportname}%' $filter
|
||||
GROUP BY R_ReportID
|
||||
ORDER BY R_ReportGroupName ASC, R_ReportName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("r_report select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function getsexreg()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query = "
|
||||
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
|
||||
UNION
|
||||
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
|
||||
UNION
|
||||
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getstatus()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
|
||||
$query = "
|
||||
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
|
||||
UNION
|
||||
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
|
||||
UNION
|
||||
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
public function addnewreport()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $prm['userid'];
|
||||
$reportcode = $prm['reportcode'];
|
||||
$reportname = $prm['reportname'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into r_report(
|
||||
R_ReportCode,
|
||||
R_ReportName,
|
||||
R_ReportUserID,
|
||||
R_ReportCreated,
|
||||
R_ReportLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$reportcode,
|
||||
$reportname,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_usergroup insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function saveaddeditreport()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$usergroupid = $prm['userid'];
|
||||
$reportid = $prm['R_ReportID'];
|
||||
$reportuserid = $prm['UserGroupReportID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($status == 'Y') {
|
||||
$sql = "insert into usergroup_report(
|
||||
UserGroupReportM_UserGroupID,
|
||||
UserGroupReportR_ReportID,
|
||||
UserGroupUserID,
|
||||
UserGroupReportCreated,
|
||||
UserGroupReportLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$usergroupid,
|
||||
$reportid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("usergroup_report insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE usergroup_report SET
|
||||
UserGroupReportIsActive = 'N',
|
||||
UserGroupUserID = ?,
|
||||
UserGroupReportCreated = now(),
|
||||
UserGroupReportLastUpdated = now()
|
||||
WHERE UserGroupReportID = ?";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$userid,
|
||||
$reportuserid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("usergroup_report insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function saveallreport()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$details = $prm['details'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
foreach ($details as $k => $v) {
|
||||
$query = "UPDATE usergroup_report SET
|
||||
UserGroupReportM_UserGroupID = '{$v['UserGroupReportM_UserGroupID']}',
|
||||
UserGroupReportAdviceIna = '{$v['UserGroupReportAdviceIna']}',
|
||||
UserGroupReportAdviceEng = '{$v['UserGroupReportAdviceEng']}',
|
||||
UserGroupReportUserID = {$userid},
|
||||
UserGroupReportCreated = now(),
|
||||
UserGroupReportLastUpdated = now()
|
||||
WHERE UserGroupReportID = {$v['UserGroupReportID']}";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
|
||||
if ($action) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function deleteuser()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update nat_methode SET
|
||||
Nat_MethodeIsActive = 'N'
|
||||
WHERE
|
||||
Nat_MethodeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_methode delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update m_usergroup SET
|
||||
M_UserGroupIsActive = 'N'
|
||||
WHERE
|
||||
M_UserGroupNat_MethodeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_usergroup delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function deletereport()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update m_usergroup SET
|
||||
M_UserGroupIsActive = 'N'
|
||||
WHERE
|
||||
M_UserGroupID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_usergroup delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchuser()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchuserbyname()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchtest()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestName like ?
|
||||
AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("t_test count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestName like ?
|
||||
AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'
|
||||
ORDER BY T_TestName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("t_test rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
application/controllers/cpone/masterdata/Nattestmap.http
Normal file
16
application/controllers/cpone/masterdata/Nattestmap.http
Normal file
@@ -0,0 +1,16 @@
|
||||
POST https://{{host}}/cpone/masterdata/nattestmap/index
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/masterdata/nattestmap/search
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"search":"",
|
||||
"current_page":1,
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
300
application/controllers/cpone/masterdata/Nattestmap.php
Normal file
300
application/controllers/cpone/masterdata/Nattestmap.php
Normal file
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
class Nattestmap extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "NAT TEST MAP API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$status = $prm['status'];
|
||||
// $all = $prm['all'];
|
||||
$filter = '';
|
||||
if ($status != 'A') {
|
||||
$filter .= "AND status = '{$status}' ";
|
||||
} else {
|
||||
$filter .= "";
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$total_result = 0;
|
||||
$total_belum_result = 0;
|
||||
$total_price = 0;
|
||||
$total_belum_price = 0;
|
||||
$sql_result = "SELECT COUNT(*) AS total FROM
|
||||
(SELECT
|
||||
IF(ISNULL(Nat_TestMapID),'N','Y') as status,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestMapID,
|
||||
Nat_TestMapNat_TestID,
|
||||
Nat_TestMapCode,
|
||||
IFNULL(Nat_TestMapCode, '') AS TestMapCode
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_testmap ON Nat_TestID = Nat_TestMapNat_TestID
|
||||
AND Nat_TestMapIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestIsResult = 'Y') x";
|
||||
$qry_result = $this->db->query($sql_result);
|
||||
if ($qry_result) {
|
||||
$total_result = $qry_result->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_test count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_belum_result = "SELECT COUNT(*) AS total FROM
|
||||
(SELECT
|
||||
IF(ISNULL(Nat_TestMapID),'N','Y') as status,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestMapID,
|
||||
Nat_TestMapNat_TestID,
|
||||
Nat_TestMapCode,
|
||||
IFNULL(Nat_TestMapCode, '') AS TestMapCode
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_testmap ON Nat_TestID = Nat_TestMapNat_TestID
|
||||
AND Nat_TestMapIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestIsResult = 'Y') x
|
||||
WHERE status = 'N'";
|
||||
$qry_belum_result = $this->db->query($sql_belum_result);
|
||||
if ($qry_belum_result) {
|
||||
$total_belum_result = $qry_belum_result->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_test count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_price = "SELECT COUNT(*) AS total FROM
|
||||
(SELECT
|
||||
IF(ISNULL(Nat_TestMapID),'N','Y') as status,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestMapID,
|
||||
Nat_TestMapNat_TestID,
|
||||
Nat_TestMapCode,
|
||||
IFNULL(Nat_TestMapCode, '') AS TestMapCode
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_testmap ON Nat_TestID = Nat_TestMapNat_TestID
|
||||
AND Nat_TestMapIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestIsPrice = 'Y') x";
|
||||
$qry_price = $this->db->query($sql_price);
|
||||
if ($qry_price) {
|
||||
$total_price = $qry_price->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_test count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_belum_price = "SELECT COUNT(*) AS total FROM
|
||||
(SELECT
|
||||
IF(ISNULL(Nat_TestMapID),'N','Y') as status,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestMapID,
|
||||
Nat_TestMapNat_TestID,
|
||||
Nat_TestMapCode,
|
||||
IFNULL(Nat_TestMapCode, '') AS TestMapCode
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_testmap ON Nat_TestID = Nat_TestMapNat_TestID
|
||||
AND Nat_TestMapIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestIsPrice = 'Y') x
|
||||
WHERE status = 'N'";
|
||||
$qry_belum_price = $this->db->query($sql_belum_price);
|
||||
if ($qry_belum_price) {
|
||||
$total_belum_price = $qry_belum_price->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_test count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql_tot = "SELECT COUNT(*) AS total FROM
|
||||
(SELECT
|
||||
IF(ISNULL(Nat_TestMapID),'N','Y') as status,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestMapID,
|
||||
Nat_TestMapNat_TestID,
|
||||
Nat_TestMapCode,
|
||||
IFNULL(Nat_TestMapCode, '') AS TestMapCode
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_testmap ON Nat_TestID = Nat_TestMapNat_TestID
|
||||
AND Nat_TestMapIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND (Nat_TestIsResult = 'Y'
|
||||
OR Nat_TestIsPrice = 'Y')) x
|
||||
WHERE (Nat_TestCode LIKE ? OR Nat_TestName LIKE ? OR TestMapCode LIKE ?) $filter
|
||||
";
|
||||
$qry_tot = $this->db->query($sql_tot, [$search, $search, $search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_tot) {
|
||||
$tot_count = $qry_tot->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("nat_test count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM
|
||||
(SELECT
|
||||
IF(ISNULL(Nat_TestMapID),'N','Y') as status,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestMapID,
|
||||
Nat_TestMapNat_TestID,
|
||||
Nat_TestMapCode,
|
||||
IFNULL(Nat_TestMapCode, '') AS TestMapCode
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_testmap ON Nat_TestID = Nat_TestMapNat_TestID
|
||||
AND Nat_TestMapIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND (Nat_TestIsResult = 'Y'
|
||||
OR Nat_TestIsPrice = 'Y')) x
|
||||
WHERE (Nat_TestCode LIKE ? OR Nat_TestName LIKE ? OR TestMapCode LIKE ?)
|
||||
$filter
|
||||
ORDER BY Nat_TestCode ASC
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [$search, $search, $search, $number_limit, $number_offset]);
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select nat_test error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_result" => $total_result,
|
||||
"total_belum_result" => $total_belum_result,
|
||||
"total_price" => $total_price,
|
||||
"total_belum_price" => $total_belum_price,
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saverow()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if ($prm["Nat_TestMapID"]) {
|
||||
// print_r("sudah ada sample id");
|
||||
// exit;
|
||||
$sql = "UPDATE nat_testmap SET
|
||||
Nat_TestMapCode = '{$prm["codeMapping"]}',
|
||||
Nat_TestMapLastUpdated = NOW(),
|
||||
Nat_TestMapUserID = '{$userid}'
|
||||
WHERE Nat_TestMapID = {$prm["Nat_TestMapID"]}";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("update nat_testmap error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_selec_del = "SELECT Nat_TestMapID,
|
||||
Nat_TestMapCode
|
||||
FROM nat_testmap
|
||||
WHERE Nat_TestMapIsActive = 'Y'
|
||||
AND Nat_TestMapID = {$prm["Nat_TestMapID"]}";
|
||||
$row = $this->db->query($sql_selec_del)->row_array();
|
||||
|
||||
if ($row["Nat_TestMapCode"] == "") {
|
||||
$sql_del = "DELETE FROM nat_testmap
|
||||
WHERE Nat_TestMapID = {$prm["Nat_TestMapID"]}";
|
||||
$qry_del = $this->db->query($sql_del);
|
||||
if (!$qry_del) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("delete nat_testmap error", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// print_r("belum ada sample id");
|
||||
// exit;
|
||||
$sql = "INSERT INTO nat_testmap(
|
||||
Nat_TestMapNat_TestID,
|
||||
Nat_TestMapCode,
|
||||
Nat_TestMapCreated,
|
||||
Nat_TestMapLastUpdated,
|
||||
Nat_TestMapUserID
|
||||
) VALUES(
|
||||
{$prm["Nat_TestID"]},
|
||||
'{$prm["codeMapping"]}',
|
||||
NOW(),
|
||||
NOW(),
|
||||
{$userid})";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("nat_testmap insert error", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array("xid" => 0)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
application/controllers/cpone/masterdata/Nonlabtemplate.http
Normal file
19
application/controllers/cpone/masterdata/Nonlabtemplate.http
Normal file
@@ -0,0 +1,19 @@
|
||||
POST https://{{host}}/cpone/masterdata/nonlabtemplate/search
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"search":"",
|
||||
"current_page":1,
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/masterdata/nonlabtemplate/searchdetail
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"nonlabID": 2,
|
||||
"search":"",
|
||||
"current_page":1,
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
486
application/controllers/cpone/masterdata/Nonlabtemplate.php
Normal file
486
application/controllers/cpone/masterdata/Nonlabtemplate.php
Normal file
@@ -0,0 +1,486 @@
|
||||
<?php
|
||||
class Nonlabtemplate extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "NON LAN TEMPLATE API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_tot = "SELECT COUNT(*) as total
|
||||
FROM nonlab_template
|
||||
WHERE NonlabTemplateIsActive = 'Y'
|
||||
AND (NonlabTemplateName LIKE ?)";
|
||||
$qry_tot = $this->db->query($sql_tot, [$search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_tot) {
|
||||
$tot_count = $qry_tot->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
NonlabTemplateID,
|
||||
NonlabTemplateName,
|
||||
NonlabTemplateFlagOther,
|
||||
NonlabTemplateIsActive,
|
||||
NonlabTemplateCreated,
|
||||
NonlabTemplateLastUpdated
|
||||
FROM nonlab_template
|
||||
WHERE NonlabTemplateIsActive = 'Y'
|
||||
AND (NonlabTemplateName LIKE ?)
|
||||
ORDER BY NonlabTemplateID ASC
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [$search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select nonlab template", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function addnonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$isfisik = "";
|
||||
if (isset($prm["isfisik"])) {
|
||||
$isfisik = trim($prm["isfisik"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO nonlab_template(
|
||||
NonlabTemplateName,
|
||||
NonlabTemplateFlagOther,
|
||||
NonlabTemplateCreated,
|
||||
NonlabTemplateCreatedUserID,
|
||||
NonlabTemplateLastUpdated,
|
||||
NonlabTemplateLastUpdatedUserID
|
||||
) VALUES(?,?,NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$name,
|
||||
$isfisik,
|
||||
$userid,
|
||||
$userid
|
||||
));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function editnonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$isfisik = "";
|
||||
if (isset($prm["isfisik"])) {
|
||||
$isfisik = trim($prm["isfisik"]);
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template
|
||||
SET NonlabTemplateName = ?,
|
||||
NonlabTemplateFlagOther = ?,
|
||||
NonlabTemplateLastUpdated = NOW(),
|
||||
NonlabTemplateLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateID = ?";
|
||||
$qry = $this->db->query($sql, array($name, $isfisik, $userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletenonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template
|
||||
SET NonlabTemplateIsActive = 'N',
|
||||
NonlabTemplateDelete = NOW(),
|
||||
NonlabTemplateDeleteUserID = ?
|
||||
WHERE NonlabTemplateID = ?";
|
||||
$qry = $this->db->query($sql, array($userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchdetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$nonlabID = $prm["nonlabID"];
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_total = "SELECT COUNT(*) as total
|
||||
FROM nonlab_template_detail
|
||||
WHERE NonlabTemplateDetailNonlabTemplateID = ?
|
||||
AND NonlabTemplateDetailIsActive = 'Y'
|
||||
AND (NonlabTemplateDetailCode LIKE ? OR NonlabTemplateDetailName LIKE ?)";
|
||||
$qry_total = $this->db->query($sql_total, [$nonlabID, $search, $search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_total) {
|
||||
$tot_count = $qry_total->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template detail count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
NonlabTemplateDetailID,
|
||||
NonlabTemplateDetailNonlabTemplateID,
|
||||
NonlabTemplateDetailCode,
|
||||
NonlabTemplateDetailName,
|
||||
NonlabTemplateDetaiNat_UnitID,
|
||||
NonlabTemplateDetailFlagActive,
|
||||
NonlabTemplateDetaiM_LangID,
|
||||
NonlabTemplateDetailIsActive
|
||||
FROM nonlab_template_detail
|
||||
WHERE NonlabTemplateDetailNonlabTemplateID = ?
|
||||
AND NonlabTemplateDetailIsActive = 'Y'
|
||||
AND (NonlabTemplateDetailCode LIKE ? OR NonlabTemplateDetailName LIKE ?)
|
||||
limit ? offset ?";
|
||||
$qry = $this->db->query($sql, [$nonlabID, $search, $search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select nonlab template detail", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function adddetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$code = "";
|
||||
if (isset($prm["code"])) {
|
||||
$code = trim($prm["code"]);
|
||||
}
|
||||
$nonlabid = "";
|
||||
if (isset($prm["nonlabid"])) {
|
||||
$nonlabid = trim($prm["nonlabid"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO nonlab_template_detail(
|
||||
NonlabTemplateDetailNonlabTemplateID,
|
||||
NonlabTemplateDetailCode,
|
||||
NonlabTemplateDetailName,
|
||||
NonlabTemplateDetailCreated,
|
||||
NonlabTemplateDetailCreatedUserID,
|
||||
NonlabTemplateDetailLastUpdated,
|
||||
NonlabTemplateDetailLastUpdatedUserID
|
||||
) VALUES(?,?,?,NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$nonlabid,
|
||||
$code,
|
||||
$name,
|
||||
$userid,
|
||||
$userid
|
||||
));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletedetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailIsActive = 'N',
|
||||
NonlabTemplateDetailDelete = NOW(),
|
||||
NonlabTemplateDetailDeleteUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array($userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveeditflag()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$flagstatus = $prm['flagstatus'];
|
||||
$templatedetailid = $prm['templatedetailid'];
|
||||
|
||||
if ($flagstatus == "Y") {
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailFlagActive = 'Y',
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$templatedetailid
|
||||
));
|
||||
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail avtive", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailFlagActive = 'N',
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$templatedetailid
|
||||
));
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail no avtive", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
716
application/controllers/cpone/masterdata/Nonlabtemplatev2.php
Normal file
716
application/controllers/cpone/masterdata/Nonlabtemplatev2.php
Normal file
@@ -0,0 +1,716 @@
|
||||
<?php
|
||||
class Nonlabtemplatev2 extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "NON LAN TEMPLATE API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_tot = "SELECT COUNT(*) as total
|
||||
FROM nonlab_template
|
||||
WHERE NonlabTemplateIsActive = 'Y'
|
||||
AND (NonlabTemplateName LIKE ?)";
|
||||
$qry_tot = $this->db->query($sql_tot, [$search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_tot) {
|
||||
$tot_count = $qry_tot->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
NonlabTemplateID,
|
||||
NonlabTemplateName,
|
||||
NonlabTemplateFlagOther,
|
||||
NonlabTemplateIsActive,
|
||||
NonlabTemplateCreated,
|
||||
NonlabTemplateLastUpdated
|
||||
FROM nonlab_template
|
||||
WHERE NonlabTemplateIsActive = 'Y'
|
||||
AND (NonlabTemplateName LIKE ?)
|
||||
ORDER BY NonlabTemplateID ASC
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [$search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select nonlab template", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function addnonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$isfisik = "";
|
||||
if (isset($prm["isfisik"])) {
|
||||
$isfisik = trim($prm["isfisik"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO nonlab_template(
|
||||
NonlabTemplateName,
|
||||
NonlabTemplateFlagOther,
|
||||
NonlabTemplateCreated,
|
||||
NonlabTemplateCreatedUserID,
|
||||
NonlabTemplateLastUpdated,
|
||||
NonlabTemplateLastUpdatedUserID
|
||||
) VALUES(?,?,NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$name,
|
||||
$isfisik,
|
||||
$userid,
|
||||
$userid
|
||||
));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function editnonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$isfisik = "";
|
||||
if (isset($prm["isfisik"])) {
|
||||
$isfisik = trim($prm["isfisik"]);
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template
|
||||
SET NonlabTemplateName = ?,
|
||||
NonlabTemplateFlagOther = ?,
|
||||
NonlabTemplateLastUpdated = NOW(),
|
||||
NonlabTemplateLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateID = ?";
|
||||
$qry = $this->db->query($sql, array($name, $isfisik, $userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletenonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template
|
||||
SET NonlabTemplateIsActive = 'N',
|
||||
NonlabTemplateDelete = NOW(),
|
||||
NonlabTemplateDeleteUserID = ?
|
||||
WHERE NonlabTemplateID = ?";
|
||||
$qry = $this->db->query($sql, array($userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchdetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$nonlabID = $prm["nonlabID"];
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_total = "SELECT COUNT(*) as total
|
||||
FROM nonlab_template_detail
|
||||
WHERE NonlabTemplateDetailNonlabTemplateID = ?
|
||||
AND NonlabTemplateDetailIsActive = 'Y'
|
||||
AND (NonlabTemplateDetailCode LIKE ? OR NonlabTemplateDetailName LIKE ?)";
|
||||
$qry_total = $this->db->query($sql_total, [$nonlabID, $search, $search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_total) {
|
||||
$tot_count = $qry_total->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template detail count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
NonlabTemplateDetailID,
|
||||
NonlabTemplateDetailNonlabTemplateID,
|
||||
NonlabTemplateDetailCode,
|
||||
NonlabTemplateDetailName,
|
||||
NonlabTemplateDetaiNat_UnitID,
|
||||
NonlabTemplateDetailFlagActive,
|
||||
NonlabTemplateDetaiM_LangID,
|
||||
NonlabTemplateDetailIsActive
|
||||
FROM nonlab_template_detail
|
||||
WHERE NonlabTemplateDetailNonlabTemplateID = ?
|
||||
AND NonlabTemplateDetailIsActive = 'Y'
|
||||
AND (NonlabTemplateDetailCode LIKE ? OR NonlabTemplateDetailName LIKE ?)
|
||||
limit ? offset ?";
|
||||
$qry = $this->db->query($sql, [$nonlabID, $search, $search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select nonlab template detail", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function adddetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$nonlabid = intval($prm["nonlabid"]);
|
||||
|
||||
if ($nonlabid === 0) {
|
||||
$this->sys_error("Anda belum memilih nonlab template, silahkan pilih nonlab template dulu");
|
||||
exit;
|
||||
}
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$code = "";
|
||||
if (isset($prm["code"])) {
|
||||
$code = trim($prm["code"]);
|
||||
}
|
||||
// $nonlabid = "";
|
||||
// if (isset($prm["nonlabid"])) {
|
||||
// $nonlabid = trim($prm["nonlabid"]);
|
||||
// }
|
||||
|
||||
$sql = "INSERT INTO nonlab_template_detail(
|
||||
NonlabTemplateDetailNonlabTemplateID,
|
||||
NonlabTemplateDetailCode,
|
||||
NonlabTemplateDetailName,
|
||||
NonlabTemplateDetailCreated,
|
||||
NonlabTemplateDetailCreatedUserID,
|
||||
NonlabTemplateDetailLastUpdated,
|
||||
NonlabTemplateDetailLastUpdatedUserID
|
||||
) VALUES(?,?,?,NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$nonlabid,
|
||||
$code,
|
||||
$name,
|
||||
$userid,
|
||||
$userid
|
||||
));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletedetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailIsActive = 'N',
|
||||
NonlabTemplateDetailDelete = NOW(),
|
||||
NonlabTemplateDetailDeleteUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array($userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveeditflag()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$flagstatus = $prm['flagstatus'];
|
||||
$templatedetailid = $prm['templatedetailid'];
|
||||
|
||||
if ($flagstatus == "Y") {
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailFlagActive = 'Y',
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$templatedetailid
|
||||
));
|
||||
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail avtive", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailFlagActive = 'N',
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$templatedetailid
|
||||
));
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail no avtive", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function editdetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$code = "";
|
||||
if (isset($prm["code"])) {
|
||||
$code = trim($prm["code"]);
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template_detail SET
|
||||
NonlabTemplateDetailCode = ?,
|
||||
NonlabTemplateDetailName = ?,
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array($code, $name, $userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookuptest()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm["search"])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = "%" . $prm["search"] . "%";
|
||||
} else {
|
||||
$search = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$nonlabtemplate_id = 0;
|
||||
if (isset($prm['nonlabtemplate_id'])) {
|
||||
$nonlabtemplate_id = trim($prm["nonlabtemplate_id"]);
|
||||
}
|
||||
$status = $prm['status'];
|
||||
$filter = '';
|
||||
if ($status == 'Y') {
|
||||
$filter .= "AND ntm.NonlabTemplateMappingNonlabTemplateID IS NOT NULL ";
|
||||
} else {
|
||||
if ($status == 'N') {
|
||||
$filter .= "AND ntm.NonlabTemplateMappingNonlabTemplateID IS NULL ";
|
||||
} else {
|
||||
$filter .= "";
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_dasar = "SELECT
|
||||
n.Nat_TestID,
|
||||
IF(ntm.NonlabTemplateMappingNonlabTemplateID IS NULL, 'N', 'Y') AS status,
|
||||
ntm.NonlabTemplateMappingNat_TestID,
|
||||
n.Nat_TestCode,
|
||||
n.Nat_TestName,
|
||||
n.Nat_TestShortName
|
||||
FROM nat_test as n
|
||||
LEFT JOIN nonlab_template_mapping as ntm ON n.Nat_TestID = ntm.NonlabTemplateMappingNat_TestID
|
||||
AND ntm.NonlabTemplateMappingIsActive = 'Y'
|
||||
LEFT JOIN nonlab_template as nt ON ntm.NonlabTemplateMappingNonlabTemplateID = nt.NonlabTemplateID
|
||||
AND nt.NonlabTemplateIsActive = 'Y'
|
||||
WHERE n.Nat_TestIsActive = 'Y'
|
||||
AND n.Nat_TestIsNonLab <> ''
|
||||
AND n.Nat_TestIsResult = 'Y'
|
||||
AND (n.Nat_TestCode LIKE '{$search}' OR n.Nat_TestName LIKE '{$search}')
|
||||
AND (nt.NonlabTemplateID = {$nonlabtemplate_id} OR nt.NonlabTemplateID IS NULL)
|
||||
$filter";
|
||||
|
||||
$qry_filter = "SELECT COUNT(*) as total FROM ($sql_dasar) as x";
|
||||
|
||||
$qry_filter = $this->db->query($qry_filter);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_filter) {
|
||||
$tot_count = $qry_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("test count error", $this->db);
|
||||
}
|
||||
|
||||
$sql = $sql_dasar . " ORDER BY n.Nat_TestCode LIMIT $number_limit OFFSET $number_offset";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("test select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveedittestmap()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$nonlabtemplate_id = 0;
|
||||
if (isset($prm['nonlabtemplate_id'])) {
|
||||
$nonlabtemplate_id = trim($prm["nonlabtemplate_id"]);
|
||||
}
|
||||
$test_id = 0;
|
||||
if (isset($prm['test_id'])) {
|
||||
$test_id = trim($prm["test_id"]);
|
||||
}
|
||||
|
||||
$status = $prm["status"];
|
||||
|
||||
$sql = "SELECT NonlabTemplateMappingID,
|
||||
NonlabTemplateMappingNonlabTemplateID,
|
||||
NonlabTemplateMappingNat_TestID
|
||||
FROM nonlab_template_mapping
|
||||
WHERE NonlabTemplateMappingNonlabTemplateID = ?
|
||||
AND NonlabTemplateMappingNat_TestID = ?";
|
||||
$qry = $this->db->query($sql, [$nonlabtemplate_id, $test_id]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$nonlabtemplatemapid = $rows[0]["NonlabTemplateMappingID"];
|
||||
$sql_update = "UPDATE nonlab_template_mapping SET
|
||||
NonlabTemplateMappingLastUpdated = NOW(),
|
||||
NonlabTemplateMappingLastUpdatedUserID = ?,
|
||||
NonlabTemplateMappingDeleted = NOW(),
|
||||
NonlabTemplateMappingIsActive = ?
|
||||
WHERE NonlabTemplateMappingID = ?";
|
||||
$qry_update = $this->db->query($sql_update, [$userid, $status, $nonlabtemplatemapid]);
|
||||
if (!$qry_update) {
|
||||
$this->sys_error_db("map test update", $this->db);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql_insert = "INSERT INTO nonlab_template_mapping(
|
||||
NonlabTemplateMappingNonlabTemplateID,
|
||||
NonlabTemplateMappingNat_TestID,
|
||||
NonlabTemplateMappingCreated,
|
||||
NonlabTemplateMappingCreatedUserID,
|
||||
NonlabTemplateMappingIsActive) VALUES(?,?,NOW(),?,'Y')";
|
||||
$qry_insert = $this->db->query($sql_insert, [$nonlabtemplate_id, $test_id, $userid]);
|
||||
if (!$qry_insert) {
|
||||
$this->sys_error_db("nonlab_template_mapping test insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
879
application/controllers/cpone/masterdata/Nonlabtemplatev3.php
Normal file
879
application/controllers/cpone/masterdata/Nonlabtemplatev3.php
Normal file
@@ -0,0 +1,879 @@
|
||||
<?php
|
||||
class Nonlabtemplatev3 extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "NON LAN TEMPLATE API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_tot = "SELECT COUNT(*) as total
|
||||
FROM nonlab_template
|
||||
WHERE NonlabTemplateIsActive = 'Y'
|
||||
AND (NonlabTemplateName LIKE ?)";
|
||||
$qry_tot = $this->db->query($sql_tot, [$search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_tot) {
|
||||
$tot_count = $qry_tot->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
NonlabTemplateID,
|
||||
NonlabTemplateName,
|
||||
NonlabTemplateFlagOther,
|
||||
NonlabTemplateIsActive,
|
||||
NonlabTemplateCreated,
|
||||
NonlabTemplateLastUpdated
|
||||
FROM nonlab_template
|
||||
WHERE NonlabTemplateIsActive = 'Y'
|
||||
AND (NonlabTemplateName LIKE ?)
|
||||
ORDER BY NonlabTemplateID ASC
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [$search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select nonlab template", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function addnonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$isfisik = "";
|
||||
if (isset($prm["isfisik"])) {
|
||||
$isfisik = trim($prm["isfisik"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO nonlab_template(
|
||||
NonlabTemplateName,
|
||||
NonlabTemplateFlagOther,
|
||||
NonlabTemplateCreated,
|
||||
NonlabTemplateCreatedUserID,
|
||||
NonlabTemplateLastUpdated,
|
||||
NonlabTemplateLastUpdatedUserID
|
||||
) VALUES(?,?,NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$name,
|
||||
$isfisik,
|
||||
$userid,
|
||||
$userid
|
||||
));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function editnonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$isfisik = "";
|
||||
if (isset($prm["isfisik"])) {
|
||||
$isfisik = trim($prm["isfisik"]);
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template
|
||||
SET NonlabTemplateName = ?,
|
||||
NonlabTemplateFlagOther = ?,
|
||||
NonlabTemplateLastUpdated = NOW(),
|
||||
NonlabTemplateLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateID = ?";
|
||||
$qry = $this->db->query($sql, array($name, $isfisik, $userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletenonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template
|
||||
SET NonlabTemplateIsActive = 'N',
|
||||
NonlabTemplateDelete = NOW(),
|
||||
NonlabTemplateDeleteUserID = ?
|
||||
WHERE NonlabTemplateID = ?";
|
||||
$qry = $this->db->query($sql, array($userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchdetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$nonlabID = $prm["nonlabID"];
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_total = "SELECT COUNT(*) as total
|
||||
FROM nonlab_template_detail
|
||||
WHERE NonlabTemplateDetailNonlabTemplateID = ?
|
||||
AND NonlabTemplateDetailIsActive = 'Y'
|
||||
AND (NonlabTemplateDetailCode LIKE ? OR NonlabTemplateDetailName LIKE ?)";
|
||||
$qry_total = $this->db->query($sql_total, [$nonlabID, $search, $search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_total) {
|
||||
$tot_count = $qry_total->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template detail count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
NonlabTemplateDetailID,
|
||||
NonlabTemplateDetailNonlabTemplateID,
|
||||
NonlabTemplateDetailCode,
|
||||
NonlabTemplateDetailGender,
|
||||
CASE
|
||||
WHEN NonlabTemplateDetailGender = 'male' THEN 'Laki-laki'
|
||||
WHEN NonlabTemplateDetailGender = 'female' THEN 'Perempuan'
|
||||
ELSE 'Semua'
|
||||
END AS NonlabTemplateDetailGenderText,
|
||||
NonlabTemplateDetailName,
|
||||
IFNULL(NonlabTemplateDetailLangName, NonlabTemplateDetailName) AS NonlabTemplateDetailNameLangEng,
|
||||
NonlabTemplateDetaiNat_UnitID as unit_id,
|
||||
unit.Nat_UnitName as unit_name,
|
||||
IFNULL(NonlabTemplateDetailLangNat_UnitID,0) as unit_eng_id,
|
||||
uniteng.Nat_UnitName AS unit_eng_name,
|
||||
NonlabTemplateDetailFlagActive,
|
||||
NonlabTemplateDetaiM_LangID,
|
||||
NonlabTemplateDetailIsActive
|
||||
FROM nonlab_template_detail
|
||||
LEFT JOIN nonlab_template_detail_lang ON NonlabTemplateDetailLangNonlabTemplateDetailID = NonlabTemplateDetailID AND
|
||||
NonlabTemplateDetailLangM_LangID = '2' AND NonlabTemplateDetailLangIsActive = 'Y'
|
||||
LEFT JOIN nat_unit unit ON unit.Nat_UnitID = NonlabTemplateDetaiNat_UnitID AND unit.Nat_UnitIsActive = 'Y'
|
||||
LEFT JOIN nat_unit uniteng ON uniteng.Nat_UnitID = NonlabTemplateDetailLangNat_UnitID AND uniteng.Nat_UnitIsActive = 'Y'
|
||||
WHERE NonlabTemplateDetailNonlabTemplateID = ?
|
||||
AND NonlabTemplateDetailIsActive = 'Y'
|
||||
AND (NonlabTemplateDetailCode LIKE ? OR NonlabTemplateDetailName LIKE ?)
|
||||
limit ? offset ?";
|
||||
$qry = $this->db->query($sql, [$nonlabID, $search, $search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select nonlab template detail", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getunits()
|
||||
{
|
||||
try {
|
||||
$rst = array(
|
||||
array('id' => '0', 'value' => 'Tanpa Satuan'),
|
||||
);
|
||||
$sql = "SELECT Nat_UnitID, Nat_UnitName FROM nat_unit WHERE Nat_UnitIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $row) {
|
||||
$rst[] = array('id' => $row['Nat_UnitID'], 'value' => $row['Nat_UnitName']);
|
||||
}
|
||||
$this->sys_ok($rst);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function adddetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$nonlabid = intval($prm["nonlabid"]);
|
||||
|
||||
if ($nonlabid === 0) {
|
||||
$this->sys_error("Anda belum memilih nonlab template, silahkan pilih nonlab template dulu");
|
||||
exit;
|
||||
}
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
if($name == ""){
|
||||
$this->sys_error("Anda belum mengisi nama");
|
||||
exit;
|
||||
}
|
||||
|
||||
$name_eng = "";
|
||||
if (isset($prm["name_eng"])) {
|
||||
$name_eng = trim($prm["name_eng"]);
|
||||
}
|
||||
$code = "";
|
||||
if (isset($prm["code"])) {
|
||||
$code = trim($prm["code"]);
|
||||
}
|
||||
if($code == ""){
|
||||
$this->sys_error("Anda belum mengisi kode");
|
||||
exit;
|
||||
}
|
||||
|
||||
$gender = "";
|
||||
if (isset($prm["gender"])) {
|
||||
$gender = trim($prm["gender"]);
|
||||
}
|
||||
if($gender == ""){
|
||||
$this->sys_error("Anda belum mengisi gender");
|
||||
exit;
|
||||
}
|
||||
|
||||
$unit = "";
|
||||
if (isset($prm["unit"])) {
|
||||
$unit = trim($prm["unit"]);
|
||||
}
|
||||
|
||||
$uniteng = "";
|
||||
if (isset($prm["uniteng"])) {
|
||||
$uniteng = trim($prm["uniteng"]);
|
||||
}
|
||||
// $nonlabid = "";
|
||||
// if (isset($prm["nonlabid"])) {
|
||||
// $nonlabid = trim($prm["nonlabid"]);
|
||||
// }
|
||||
|
||||
$sql = "INSERT INTO nonlab_template_detail(
|
||||
NonlabTemplateDetailNonlabTemplateID,
|
||||
NonlabTemplateDetailGender,
|
||||
NonlabTemplateDetaiNat_UnitID,
|
||||
NonlabTemplateDetailCode,
|
||||
NonlabTemplateDetailName,
|
||||
NonlabTemplateDetailCreated,
|
||||
NonlabTemplateDetailCreatedUserID,
|
||||
NonlabTemplateDetailLastUpdated,
|
||||
NonlabTemplateDetailLastUpdatedUserID
|
||||
) VALUES(?,?,?,?,?,NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$nonlabid,
|
||||
$gender,
|
||||
$unit,
|
||||
$code,
|
||||
$name,
|
||||
$userid,
|
||||
$userid
|
||||
));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$last_id = $this->db->insert_id();
|
||||
|
||||
$sql_lang = "INSERT INTO nonlab_template_detail_lang(
|
||||
NonlabTemplateDetailLangNonlabTemplateDetailID,
|
||||
NonlabTemplateDetailLangGender,
|
||||
NonlabTemplateDetailLangM_LangID,
|
||||
NonlabTemplateDetailLangName,
|
||||
NonlabTemplateDetailLangNat_UnitID,
|
||||
NonlabTemplateDetailLangCreated,
|
||||
NonlabTemplateDetailLangCreatedUserID,
|
||||
NonlabTemplateDetailLangLastUpdated,
|
||||
NonlabTemplateDetailLangLastUpdatedUserID
|
||||
) VALUES(?,?,?,?,?,NOW(),?,NOW(),?)";
|
||||
$qry_lang = $this->db->query($sql_lang, array(
|
||||
$last_id,
|
||||
$gender,
|
||||
"2",
|
||||
$name_eng,
|
||||
$uniteng,
|
||||
$userid,
|
||||
$userid
|
||||
));
|
||||
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletedetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailIsActive = 'N',
|
||||
NonlabTemplateDetailDelete = NOW(),
|
||||
NonlabTemplateDetailDeleteUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array($userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveeditflag()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$flagstatus = $prm['flagstatus'];
|
||||
$templatedetailid = $prm['templatedetailid'];
|
||||
|
||||
if ($flagstatus == "Y") {
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailFlagActive = 'Y',
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$templatedetailid
|
||||
));
|
||||
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail avtive", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailFlagActive = 'N',
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$templatedetailid
|
||||
));
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail no avtive", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function editdetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
if($name == ""){
|
||||
$this->sys_error("Anda belum mengisi nama");
|
||||
exit;
|
||||
}
|
||||
$name_eng = "";
|
||||
if (isset($prm["name_eng"])) {
|
||||
$name_eng = trim($prm["name_eng"]);
|
||||
}
|
||||
if($name_eng == ""){
|
||||
$this->sys_error("Anda belum mengisi nama inggris");
|
||||
exit;
|
||||
}
|
||||
$code = "";
|
||||
if (isset($prm["code"])) {
|
||||
$code = trim($prm["code"]);
|
||||
}
|
||||
if($code == ""){
|
||||
$this->sys_error("Anda belum mengisi kode");
|
||||
exit;
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
$gender = "";
|
||||
if (isset($prm["gender"])) {
|
||||
$gender = trim($prm["gender"]);
|
||||
}
|
||||
if($gender == ""){
|
||||
$this->sys_error("Anda belum mengisi gender");
|
||||
exit;
|
||||
}
|
||||
$unit = "";
|
||||
if (isset($prm["unit"])) {
|
||||
$unit = trim($prm["unit"]);
|
||||
}
|
||||
|
||||
$uniteng = "";
|
||||
if (isset($prm["uniteng"])) {
|
||||
$uniteng = trim($prm["uniteng"]);
|
||||
}
|
||||
|
||||
|
||||
$sql = "UPDATE nonlab_template_detail SET
|
||||
NonlabTemplateDetailGender = ?,
|
||||
NonlabTemplateDetaiNat_UnitID = ?,
|
||||
NonlabTemplateDetailCode = ?,
|
||||
NonlabTemplateDetailName = ?,
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array($gender, $unit, $code, $name, $userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT NonlabTemplateDetailLangID
|
||||
FROM nonlab_template_detail_lang
|
||||
WHERE
|
||||
NonlabTemplateDetailLangNonlabTemplateDetailID = ?
|
||||
AND NonlabTemplateDetailLangM_LangID = '2' AND
|
||||
NonlabTemplateDetailLangIsActive = 'Y'
|
||||
";
|
||||
$qry = $this->db->query($sql, array($id));
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail lang", $this->db);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$langid = $rows[0]["NonlabTemplateDetailLangID"];
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template_detail_lang SET
|
||||
NonlabTemplateDetailLangGender = ?,
|
||||
NonlabTemplateDetailLangNat_UnitID = ?,
|
||||
NonlabTemplateDetailLangName = ?,
|
||||
NonlabTemplateDetailLangLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLangLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailLangID = ?";
|
||||
$qry = $this->db->query($sql, array($gender, $uniteng, $name_eng, $userid, $langid));
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail lang", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookuptest()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm["search"])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = "%" . $prm["search"] . "%";
|
||||
} else {
|
||||
$search = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$nonlabtemplate_id = 0;
|
||||
if (isset($prm['nonlabtemplate_id'])) {
|
||||
$nonlabtemplate_id = trim($prm["nonlabtemplate_id"]);
|
||||
}
|
||||
$status = $prm['status'];
|
||||
$filter = '';
|
||||
if ($status == 'Y') {
|
||||
$filter .= "AND ntm.NonlabTemplateMappingNonlabTemplateID IS NOT NULL ";
|
||||
} else {
|
||||
if ($status == 'N') {
|
||||
$filter .= "AND ntm.NonlabTemplateMappingNonlabTemplateID IS NULL ";
|
||||
} else {
|
||||
$filter .= "";
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_dasar = "SELECT
|
||||
n.Nat_TestID,
|
||||
IF(ntm.NonlabTemplateMappingNonlabTemplateID IS NULL, 'N', 'Y') AS status,
|
||||
ntm.NonlabTemplateMappingNat_TestID,
|
||||
n.Nat_TestCode,
|
||||
n.Nat_TestName,
|
||||
n.Nat_TestShortName
|
||||
FROM nat_test as n
|
||||
LEFT JOIN nonlab_template_mapping as ntm ON n.Nat_TestID = ntm.NonlabTemplateMappingNat_TestID
|
||||
AND ntm.NonlabTemplateMappingIsActive = 'Y'
|
||||
LEFT JOIN nonlab_template as nt ON ntm.NonlabTemplateMappingNonlabTemplateID = nt.NonlabTemplateID
|
||||
AND nt.NonlabTemplateIsActive = 'Y'
|
||||
WHERE n.Nat_TestIsActive = 'Y'
|
||||
AND n.Nat_TestIsNonLab <> ''
|
||||
AND n.Nat_TestIsResult = 'Y'
|
||||
AND (n.Nat_TestCode LIKE '{$search}' OR n.Nat_TestName LIKE '{$search}')
|
||||
AND (nt.NonlabTemplateID = {$nonlabtemplate_id} OR nt.NonlabTemplateID IS NULL)
|
||||
$filter";
|
||||
|
||||
$qry_filter = "SELECT COUNT(*) as total FROM ($sql_dasar) as x";
|
||||
|
||||
$qry_filter = $this->db->query($qry_filter);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_filter) {
|
||||
$tot_count = $qry_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("test count error", $this->db);
|
||||
}
|
||||
|
||||
$sql = $sql_dasar . " ORDER BY n.Nat_TestCode LIMIT $number_limit OFFSET $number_offset";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("test select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveedittestmap()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$nonlabtemplate_id = 0;
|
||||
if (isset($prm['nonlabtemplate_id'])) {
|
||||
$nonlabtemplate_id = trim($prm["nonlabtemplate_id"]);
|
||||
}
|
||||
$test_id = 0;
|
||||
if (isset($prm['test_id'])) {
|
||||
$test_id = trim($prm["test_id"]);
|
||||
}
|
||||
|
||||
$status = $prm["status"];
|
||||
|
||||
$sql = "SELECT NonlabTemplateMappingID,
|
||||
NonlabTemplateMappingNonlabTemplateID,
|
||||
NonlabTemplateMappingNat_TestID
|
||||
FROM nonlab_template_mapping
|
||||
WHERE NonlabTemplateMappingNonlabTemplateID = ?
|
||||
AND NonlabTemplateMappingNat_TestID = ?";
|
||||
$qry = $this->db->query($sql, [$nonlabtemplate_id, $test_id]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$nonlabtemplatemapid = $rows[0]["NonlabTemplateMappingID"];
|
||||
$sql_update = "UPDATE nonlab_template_mapping SET
|
||||
NonlabTemplateMappingLastUpdated = NOW(),
|
||||
NonlabTemplateMappingLastUpdatedUserID = ?,
|
||||
NonlabTemplateMappingDeleted = NOW(),
|
||||
NonlabTemplateMappingIsActive = ?
|
||||
WHERE NonlabTemplateMappingID = ?";
|
||||
$qry_update = $this->db->query($sql_update, [$userid, $status, $nonlabtemplatemapid]);
|
||||
if (!$qry_update) {
|
||||
$this->sys_error_db("map test update", $this->db);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql_insert = "INSERT INTO nonlab_template_mapping(
|
||||
NonlabTemplateMappingNonlabTemplateID,
|
||||
NonlabTemplateMappingNat_TestID,
|
||||
NonlabTemplateMappingCreated,
|
||||
NonlabTemplateMappingCreatedUserID,
|
||||
NonlabTemplateMappingIsActive) VALUES(?,?,NOW(),?,'Y')";
|
||||
$qry_insert = $this->db->query($sql_insert, [$nonlabtemplate_id, $test_id, $userid]);
|
||||
if (!$qry_insert) {
|
||||
$this->sys_error_db("nonlab_template_mapping test insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
1028
application/controllers/cpone/masterdata/Requirement.php
Normal file
1028
application/controllers/cpone/masterdata/Requirement.php
Normal file
File diff suppressed because it is too large
Load Diff
1029
application/controllers/cpone/masterdata/Requirementv2.php
Normal file
1029
application/controllers/cpone/masterdata/Requirementv2.php
Normal file
File diff suppressed because it is too large
Load Diff
924
application/controllers/cpone/mcuoffline/Packetcpone.php
Normal file
924
application/controllers/cpone/mcuoffline/Packetcpone.php
Normal file
@@ -0,0 +1,924 @@
|
||||
<?php
|
||||
class Packetcpone extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function savesetupv0()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$T_PacketName = strtoupper($prm['namapacket']);
|
||||
$T_PriceHeaderID = $prm['priceheader']['T_PriceHeaderID'];
|
||||
$T_PacketType = $prm['jenispacket'];
|
||||
$T_PacketPrice = $prm['T_PacketPrice'];
|
||||
$T_PacketOriginalPrice = $prm['T_PacketOriginalPrice'];
|
||||
$T_PacketSasCode = "";
|
||||
$T_PacketOriginalBruto = 0;
|
||||
$detail_packet = $prm['detailpacket'];
|
||||
// $act = $prm['act'];
|
||||
|
||||
if($prm["act"] == 'new'){
|
||||
// check paket exists or not
|
||||
$sqlCheck = "SELECT *
|
||||
FROM t_packet
|
||||
WHERE T_PacketIsActive = 'Y'
|
||||
AND T_PacketName = '$T_PacketName'";
|
||||
|
||||
$qryCheck = $this->db_onedev->query($sqlCheck);
|
||||
|
||||
if(!$qryCheck){
|
||||
$this->sys_error_db("t_packet check", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rowCheck = $qryCheck->result_array();
|
||||
|
||||
if(count($rowCheck) > 0){
|
||||
$this->sys_error("Data dengan nama paket ".$T_PacketName." Sudah Ada");
|
||||
exit;
|
||||
} else {
|
||||
// get numbering
|
||||
$sql_get_numbering = "SELECT fn_numbering_cpone('PC') as numberx";
|
||||
$qry_get_numbering = $this->db_onedev->query($sql_get_numbering);
|
||||
if(!$qry_get_numbering){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("packet numbering cpone", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data_numbering = $qry_get_numbering->result_array();
|
||||
|
||||
$T_PacketSasCode = $data_numbering[0]['numberx'];
|
||||
|
||||
// insert t_packet
|
||||
$sql_insert = "INSERT INTO t_packet
|
||||
(
|
||||
T_PacketT_PriceHeaderID,
|
||||
T_PacketType,
|
||||
T_PacketName,
|
||||
T_PacketPrice,
|
||||
T_PacketOriginalPrice,
|
||||
T_PacketSasCode,
|
||||
T_PacketIsActive,
|
||||
T_PacketCreated,
|
||||
T_PacketOriginalBruto
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
$T_PriceHeaderID, -- T_PacketT_PriceHeaderID
|
||||
'$T_PacketType', -- T_PacketType (assuming 'PR' for Profile)
|
||||
'$T_PacketName', -- T_PacketName
|
||||
$T_PacketPrice, -- T_PacketPrice
|
||||
$T_PacketOriginalPrice, -- T_PacketOriginalPrice
|
||||
'$T_PacketSasCode', -- T_PacketSasCode
|
||||
'Y', -- T_PacketIsActive
|
||||
NOW(), -- T_PacketCreated
|
||||
$T_PacketOriginalBruto -- T_PacketOriginalBruto (can be NULL)
|
||||
)";
|
||||
|
||||
$qryInsert = $this->db_onedev->query($sql_insert);
|
||||
if(!$qryInsert){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packet insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
// insert t_packetdetail
|
||||
if(count($detail_packet) > 0) {
|
||||
foreach($detail_packet as $k => $v){
|
||||
$T_PriceTotalPacket = $v['T_PriceTotalPacket'];
|
||||
|
||||
// bisa berubah ubah kalau PN
|
||||
if($T_PacketType == "PN"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $T_PriceTotalPacket;
|
||||
}
|
||||
|
||||
if($T_PacketType == "PR"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $v['T_PriceTotal'];
|
||||
}
|
||||
|
||||
$T_PacketDetailPriceAmount = 0;
|
||||
$T_PacketDetailPriceDisc = 0;
|
||||
$T_PacketDetailPriceDiscRp = 0;
|
||||
$T_PacketDetailPriceSubTotal = 0;
|
||||
|
||||
if(!empty($v['T_PriceAmount'])){
|
||||
$T_PacketDetailPriceAmount = $v['T_PriceAmount'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDisc'])){
|
||||
$T_PacketDetailPriceDisc = $v['T_PriceDisc'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDiscRp'])){
|
||||
$T_PacketDetailPriceDiscRp = $v['T_PriceDiscRp'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceSubTotal'])){
|
||||
$T_PacketDetailPriceSubTotal = $v['T_PriceSubTotal'];
|
||||
}
|
||||
|
||||
$sql_insert_detail = "INSERT INTO t_packetdetail
|
||||
(
|
||||
T_PacketDetailT_PacketID,
|
||||
T_PacketDetailT_TestID,
|
||||
T_PacketDetailOriginalPrice,
|
||||
T_PacketDetailPrice,
|
||||
T_PacketDetailIsActive,
|
||||
T_PacketDetailCreated,
|
||||
T_PacketDetailPriceAmount,
|
||||
T_PacketDetailPriceDisc,
|
||||
T_PacketDetailPriceDiscRp,
|
||||
T_PacketDetailPriceSubTotal
|
||||
) VALUES (
|
||||
$last_id, -- T_PacketDetailT_PacketID
|
||||
{$v['T_TestID']}, -- T_PacketDetailT_TestID
|
||||
{$T_PacketDetailOriginalPrice}, -- T_PacketDetailOriginalPrice
|
||||
{$T_PacketDetailPrice}, -- T_PacketDetailPrice
|
||||
'Y', -- T_PacketDetailIsActive
|
||||
NOW(), -- T_PacketDetailCreated
|
||||
{$T_PacketDetailPriceAmount}, -- T_PacketDetailPriceAmount
|
||||
{$T_PacketDetailPriceDisc}, -- T_PacketDetailPriceDisc
|
||||
{$T_PacketDetailPriceDiscRp}, -- T_PacketDetailPriceDiscRp
|
||||
{$T_PacketDetailPriceSubTotal} -- T_PacketDetailPriceSubTotal
|
||||
)";
|
||||
|
||||
$qry_detail = $this->db_onedev->query($sql_insert_detail);
|
||||
if(!$qry_detail) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT T_PacketName as xnumber
|
||||
FROM t_packet
|
||||
WHERE T_PacketID = {$last_id}";
|
||||
|
||||
//echo $sql;
|
||||
$row = $this->db_onedev->query($sql)->row_array();
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $row,
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
} else{
|
||||
// check paket exists or not
|
||||
$sqlCheck = "SELECT *
|
||||
FROM t_packet
|
||||
WHERE T_PacketIsActive = 'Y'
|
||||
AND T_PacketName = '$T_PacketName'
|
||||
AND T_PacketID <> {$prm["xid"]}";
|
||||
|
||||
$qryCheck = $this->db_onedev->query($sqlCheck);
|
||||
|
||||
if(!$qryCheck){
|
||||
$this->sys_error_db("t_packet check", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rowCheck = $qryCheck->result_array();
|
||||
if(count($rowCheck) > 0){
|
||||
// echo $sqlCheck;
|
||||
// exit;
|
||||
$this->sys_error("Data dengan nama paket ".$T_PacketName." Sudah Ada");
|
||||
exit;
|
||||
} else {
|
||||
// update t_packet
|
||||
$sql_update = "UPDATE t_packet
|
||||
SET
|
||||
T_PacketT_PriceHeaderID = $T_PriceHeaderID,
|
||||
T_PacketType = '$T_PacketType',
|
||||
T_PacketName = '$T_PacketName',
|
||||
T_PacketPrice = $T_PacketPrice,
|
||||
T_PacketOriginalPrice = $T_PacketOriginalPrice,
|
||||
T_PacketIsActive = 'Y',
|
||||
T_PacketLastUpdated = NOW(),
|
||||
T_PacketOriginalBruto = $T_PacketOriginalBruto
|
||||
WHERE
|
||||
T_PacketID = {$prm["xid"]}";
|
||||
|
||||
$qryUpdate = $this->db_onedev->query($sql_update);
|
||||
if(!$qryUpdate){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("error t_packet update", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$last_id = $prm["xid"];
|
||||
|
||||
// // update detail packet
|
||||
// // update isActive N kan semua
|
||||
$sqlUpdatePacket = "UPDATE t_packetdetail
|
||||
SET
|
||||
T_PacketDetailIsActive = 'N',
|
||||
T_PacketDetailLastUpdated = NOW()
|
||||
WHERE T_PacketDetailT_PacketID = $last_id";
|
||||
|
||||
// echo $sqlUpdatePacket;
|
||||
|
||||
$qry_mgm_update_tpacketdetails = $this->db_onedev->query($sqlUpdatePacket);
|
||||
if(!$qry_mgm_update_tpacketdetails){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail update", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// insert t_packetdetail
|
||||
if(count($detail_packet) > 0) {
|
||||
foreach($detail_packet as $k => $v){
|
||||
$T_PriceTotalPacket = $v['T_PriceTotalPacket'];
|
||||
|
||||
// bisa berubah ubah kalau PN
|
||||
if($T_PacketType == "PN"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $T_PriceTotalPacket;
|
||||
}
|
||||
|
||||
if($T_PacketType == "PR"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $v['T_PriceTotal'];
|
||||
}
|
||||
|
||||
$T_PacketDetailPriceAmount = 0;
|
||||
$T_PacketDetailPriceDisc = 0;
|
||||
$T_PacketDetailPriceDiscRp = 0;
|
||||
$T_PacketDetailPriceSubTotal = 0;
|
||||
|
||||
if(!empty($v['T_PriceAmount'])){
|
||||
$T_PacketDetailPriceAmount = $v['T_PriceAmount'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDisc'])){
|
||||
$T_PacketDetailPriceDisc = $v['T_PriceDisc'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDiscRp'])){
|
||||
$T_PacketDetailPriceDiscRp = $v['T_PriceDiscRp'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceSubTotal'])){
|
||||
$T_PacketDetailPriceSubTotal = $v['T_PriceSubTotal'];
|
||||
}
|
||||
|
||||
$sql_insert_detail = "INSERT INTO t_packetdetail
|
||||
(
|
||||
T_PacketDetailT_PacketID,
|
||||
T_PacketDetailT_TestID,
|
||||
T_PacketDetailOriginalPrice,
|
||||
T_PacketDetailPrice,
|
||||
T_PacketDetailIsActive,
|
||||
T_PacketDetailCreated,
|
||||
T_PacketDetailPriceAmount,
|
||||
T_PacketDetailPriceDisc,
|
||||
T_PacketDetailPriceDiscRp,
|
||||
T_PacketDetailPriceSubTotal
|
||||
) VALUES (
|
||||
$last_id, -- T_PacketDetailT_PacketID
|
||||
{$v['T_TestID']}, -- T_PacketDetailT_TestID
|
||||
{$T_PacketDetailOriginalPrice}, -- T_PacketDetailOriginalPrice
|
||||
{$T_PacketDetailPrice}, -- T_PacketDetailPrice
|
||||
'Y', -- T_PacketDetailIsActive
|
||||
NOW(), -- T_PacketDetailCreated
|
||||
{$T_PacketDetailPriceAmount}, -- T_PacketDetailPriceAmount
|
||||
{$T_PacketDetailPriceDisc}, -- T_PacketDetailPriceDisc
|
||||
{$T_PacketDetailPriceDiscRp}, -- T_PacketDetailPriceDiscRp
|
||||
{$T_PacketDetailPriceSubTotal} -- T_PacketDetailPriceSubTotal
|
||||
)";
|
||||
|
||||
$qry_detail = $this->db_onedev->query($sql_insert_detail);
|
||||
if(!$qry_detail) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT T_PacketName as xnumber
|
||||
FROM t_packet
|
||||
WHERE T_PacketID = {$last_id}";
|
||||
|
||||
//echo $sql;
|
||||
$row = $this->db_onedev->query($sql)->row_array();
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $row,
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletev0(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// packet
|
||||
$query_t_packet = $this->db_onedev->query("UPDATE t_packet SET
|
||||
T_PacketIsActive = 'N',
|
||||
T_PacketLastUpdated = NOW()
|
||||
WHERE
|
||||
T_PacketID = '{$prm['id']}'
|
||||
");
|
||||
|
||||
if (!$query_t_packet) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packet update error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// packet details
|
||||
$query_t_packetdetail = $this->db_onedev->query("UPDATE t_packetdetail SET
|
||||
T_PacketDetailIsActive = 'N',
|
||||
T_PacketDetailLastUpdated = NOW()
|
||||
WHERE
|
||||
T_PacketDetailT_PacketID = '{$prm['id']}'
|
||||
");
|
||||
|
||||
if (!$query_t_packetdetail) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail update error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $rows = $this->db_onedev->query($query_mgmmcu);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getTTestByTPriceHeaderCurrent()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// $search_kode = $prm['searchKode'];
|
||||
// $search_nama = $prm['searchNama'];
|
||||
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
|
||||
$natsubgroup = "";
|
||||
$sql_where_natsubgroup = "";
|
||||
|
||||
if(isset($prm['natsubgroup']) && !empty($prm['natsubgroup']) && $prm['natsubgroup'] != "All"){
|
||||
$natsubgroup = $prm['natsubgroup'];
|
||||
$sql_where_natsubgroup = " AND Nat_SubGroupID = $natsubgroup";
|
||||
}
|
||||
|
||||
// if($natsubgroup != "All"){
|
||||
// $sql_where_natsubgroup = " AND Nat_SubGroupID = $natsubgroup";
|
||||
// }
|
||||
|
||||
$tpriceheader = $prm['tpriceheader'];
|
||||
$sql_where_tpriceheader = "";
|
||||
|
||||
if(isset($prm['tpriceheader']) && !empty($prm['tpriceheader'])){
|
||||
$sql_where_tpriceheader = " AND ph.T_PriceHeaderID = $tpriceheader";
|
||||
}
|
||||
|
||||
$sqlSearch = "T_TestName LIKE '%%' AND T_TestCode LIKE '%%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
|
||||
if(isset($prm['searchKode']) && !empty($prm['searchKode'])){
|
||||
$sqlSearch = " T_TestCode LIKE '%{$prm['searchKode']}%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
}
|
||||
|
||||
if(isset($prm['searchNama']) && !empty($prm['searchNama'])){
|
||||
$sqlSearch = " T_TestName LIKE '%{$prm['searchNama']}%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
}
|
||||
|
||||
if(
|
||||
((isset($prm['searchKode']) && !empty($prm['searchKode'])))
|
||||
&& (isset($prm['searchNama']) && !empty($prm['searchNama']))
|
||||
){
|
||||
$sqlSearch = " T_TestName LIKE '%{$prm['searchNama']}%' AND T_TestCode LIKE '%{$prm['searchKode']}%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
}
|
||||
|
||||
$sql_where = "
|
||||
WHERE (
|
||||
".$sqlSearch."
|
||||
)";
|
||||
|
||||
|
||||
|
||||
// $sql_where = "
|
||||
// WHERE (
|
||||
// T_TestCode LIKE '%{$prm['searchKode']}%'
|
||||
// OR T_TestName LIKE '%{$prm['searchNama']}%'
|
||||
// )";
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT
|
||||
IFNULL(p.T_PriceID, 0) AS T_PriceID
|
||||
FROM
|
||||
t_price p
|
||||
JOIN
|
||||
t_priceheader ph
|
||||
ON
|
||||
p.T_PriceT_PriceHeaderID = ph.T_PriceHeaderID
|
||||
AND p.T_PriceIsActive = 'Y'
|
||||
AND ph.T_PriceHeaderIsActive = 'Y'
|
||||
JOIN
|
||||
t_test testx
|
||||
ON p.T_PriceT_TestID = testx.T_TestID
|
||||
AND testx.T_TestIsActive = 'Y'
|
||||
LEFT JOIN nat_subgroup
|
||||
ON T_TestNat_SubgroupID = Nat_SubgroupID
|
||||
AND Nat_SubGroupIsActive = 'Y'
|
||||
$sql_where
|
||||
) x";
|
||||
|
||||
$sql_param = array();
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("tprice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT
|
||||
ROW_NUMBER() OVER (ORDER BY T_PriceID) AS RowNum,
|
||||
IFNULL(p.T_PriceTotal, 0) AS T_PriceTotalPacket,
|
||||
IFNULL(p.T_PriceID, 0) AS T_PriceID,
|
||||
IFNULL(p.T_PriceT_PriceHeaderID, 0) AS T_PriceT_PriceHeaderID,
|
||||
IFNULL(p.T_PriceT_TestID, 0) AS T_PriceT_TestID,
|
||||
IFNULL(p.T_PriceIsCito, 'N') AS T_PriceIsCito,
|
||||
IFNULL(p.T_PricePriority, 1) AS T_PricePriority,
|
||||
IFNULL(p.T_PriceAmount, 0) AS T_PriceAmount,
|
||||
IFNULL(p.T_PriceDisc, 0) AS T_PriceDisc,
|
||||
IFNULL(p.T_PriceDiscRp, 0) AS T_PriceDiscRp,
|
||||
IFNULL(p.T_PriceSubTotal, 0) AS T_PriceSubTotal,
|
||||
IFNULL(p.T_PriceOther, 0) AS T_PriceOther,
|
||||
IFNULL(p.T_PriceTotal, 0) AS T_PriceTotal,
|
||||
IFNULL(p.T_PriceIsActive, 'Y') AS T_PriceIsActive,
|
||||
IFNULL(p.T_PriceCreated, '0000-00-00') AS T_PriceCreated,
|
||||
IFNULL(p.T_PriceLastUpdated, '0000-00-00') AS T_PriceLastUpdated,
|
||||
IFNULL(p.T_PriceUserID, 0) AS T_PriceUserID,
|
||||
IFNULL(ph.T_PriceHeaderID, 0) AS T_PriceHeaderID,
|
||||
IFNULL(ph.T_PriceHeaderName, '') AS T_PriceHeaderName,
|
||||
IFNULL(ph.T_PriceHeaderStartDate, '0000-00-00') AS T_PriceHeaderStartDate,
|
||||
IFNULL(ph.T_PriceHeaderEndDate, '0000-00-00') AS T_PriceHeaderEndDate,
|
||||
IFNULL(ph.T_PriceHeaderIsActive, 'Y') AS T_PriceHeaderIsActive,
|
||||
IFNULL(ph.T_PriceHeaderUserID, 0) AS T_PriceHeaderUserID,
|
||||
IFNULL(ph.T_PriceHeaderCreated, '0000-00-00 00:00:00') AS T_PriceHeaderCreated,
|
||||
IFNULL(ph.T_PriceHeaderCraetdUserID, 0) AS T_PriceHeaderCraetdUserID,
|
||||
IFNULL(ph.T_PriceHeaderLastUpdated, '0000-00-00 00:00:00') AS T_PriceHeaderLastUpdated,
|
||||
IFNULL(ph.T_PriceHeaderLastUpdatedUserID, 0) AS T_PriceHeaderLastUpdatedUserID,
|
||||
IFNULL(ph.T_PriceHeaderDeleted, '0000-00-00 00:00:00') AS T_PriceHeaderDeleted,
|
||||
IFNULL(ph.T_PriceHeaderDeletedUserID, 0) AS T_PriceHeaderDeletedUserID,
|
||||
IFNULL(testx.T_TestID, 0) AS T_TestID,
|
||||
IFNULL(testx.T_TestCode, '') AS T_TestCode,
|
||||
IFNULL(testx.T_TestName, '') AS T_TestName
|
||||
FROM
|
||||
t_price p
|
||||
JOIN
|
||||
t_priceheader ph
|
||||
ON
|
||||
p.T_PriceT_PriceHeaderID = ph.T_PriceHeaderID
|
||||
AND p.T_PriceIsActive = 'Y'
|
||||
AND ph.T_PriceHeaderIsActive = 'Y'
|
||||
JOIN
|
||||
t_test testx
|
||||
ON p.T_PriceT_TestID = testx.T_TestID
|
||||
AND testx.T_TestIsActive = 'Y'
|
||||
LEFT JOIN nat_subgroup
|
||||
ON T_TestNat_SubgroupID = Nat_SubgroupID
|
||||
AND Nat_SubGroupIsActive = 'Y'
|
||||
$sql_where
|
||||
ORDER BY p.T_PriceID DESC
|
||||
limit $number_limit offset $number_offset
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
if ($query === false) {
|
||||
// If query failed, log the error and exit
|
||||
$this->sys_error_db("select t_price data", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getTPriceHeader()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_priceheader
|
||||
WHERE T_PriceHeaderIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("t_priceheader select error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$new_entry = array(
|
||||
'T_PriceHeaderID' => 'All',
|
||||
'T_PriceHeaderName' => 'All',
|
||||
'T_PriceHeaderStartDate' => "",
|
||||
'T_PriceHeaderEndDate' => "",
|
||||
'T_PriceHeaderIsActive' => "",
|
||||
'T_PriceHeaderUserID' => "",
|
||||
'T_PriceHeaderCreated' => "",
|
||||
'T_PriceHeaderCraetdUserID' => "",
|
||||
'T_PriceHeaderLastUpdated' => "",
|
||||
'T_PriceHeaderLastUpdatedUserID' => "",
|
||||
'T_PriceHeaderDeleted' => "",
|
||||
'T_PriceHeaderDeletedUserID' => ""
|
||||
);
|
||||
|
||||
array_unshift($rows, $new_entry);
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getTPriceHeaderCurrent()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT
|
||||
IFNULL(T_PriceHeaderID, 0) AS T_PriceHeaderID,
|
||||
IFNULL(T_PriceHeaderName, '') AS T_PriceHeaderName,
|
||||
IFNULL(T_PriceHeaderStartDate, '0000-00-00') AS T_PriceHeaderStartDate,
|
||||
IFNULL(T_PriceHeaderEndDate, '0000-00-00') AS T_PriceHeaderEndDate,
|
||||
IFNULL(T_PriceHeaderIsActive, 'Y') AS T_PriceHeaderIsActive,
|
||||
IFNULL(T_PriceHeaderUserID, 0) AS T_PriceHeaderUserID,
|
||||
IFNULL(T_PriceHeaderCreated, '0000-00-00 00:00:00') AS T_PriceHeaderCreated,
|
||||
IFNULL(T_PriceHeaderCraetdUserID, 0) AS T_PriceHeaderCraetdUserID,
|
||||
IFNULL(T_PriceHeaderLastUpdated, '0000-00-00 00:00:00') AS T_PriceHeaderLastUpdated,
|
||||
IFNULL(T_PriceHeaderLastUpdatedUserID, 0) AS T_PriceHeaderLastUpdatedUserID,
|
||||
IFNULL(T_PriceHeaderDeleted, '0000-00-00 00:00:00') AS T_PriceHeaderDeleted,
|
||||
IFNULL(T_PriceHeaderDeletedUserID, 0) AS T_PriceHeaderDeletedUserID
|
||||
FROM
|
||||
t_priceheader
|
||||
WHERE T_PriceHeaderIsActive = 'Y'
|
||||
AND CURDATE() BETWEEN T_PriceHeaderStartDate AND T_PriceHeaderEndDate";
|
||||
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("t_priceheader select error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function searchv0()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
// $search = $prm['search'];
|
||||
// if (isset($prm['search'])) {
|
||||
// $search = trim($prm["search"]);
|
||||
// if ($search != "") {
|
||||
// $search = '%' . $prm['search'] . '%';
|
||||
// }else{
|
||||
// $search = '%%';
|
||||
// }
|
||||
// }
|
||||
|
||||
// $limit = '';
|
||||
// $filter_paket = $prm['searchPacket'];
|
||||
// if($all == 'N'){
|
||||
// $limit = ' LIMIT 10';
|
||||
// }
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
// $sql_where = " (
|
||||
// T_PacketName LIKE '%{$prm['search']}%'
|
||||
// OR T_PacketType LIKE '%{$prm['search']}%'
|
||||
// ) AND T_PacketIsActive = 'Y'";
|
||||
|
||||
$sql_where_tpriceheader = "";
|
||||
$tpriceheader = "";
|
||||
|
||||
|
||||
if(isset($prm['tpriceheader'])){
|
||||
$tpriceheader = $prm['tpriceheader'];
|
||||
}
|
||||
|
||||
if($tpriceheader != "All"){
|
||||
$sql_where_tpriceheader = " AND T_PacketT_PriceHeaderID = $tpriceheader";
|
||||
}
|
||||
|
||||
$sql_where = " (
|
||||
T_PacketName LIKE '%{$prm['search']}%'
|
||||
) AND T_PacketIsActive = 'Y'
|
||||
$sql_where_tpriceheader";
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_packet
|
||||
WHERE $sql_where
|
||||
";
|
||||
|
||||
$sql_param = array();
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("t_packet count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT
|
||||
IFNULL(T_PacketID, 0) AS T_PacketID,
|
||||
IFNULL(T_PacketT_PriceHeaderID, 0) AS T_PacketT_PriceHeaderID,
|
||||
IFNULL(T_PacketType,'') AS T_PacketType,
|
||||
IFNULL(T_PacketName,'') AS T_PacketName,
|
||||
IFNULL(T_PacketPrice,0) AS T_PacketPrice,
|
||||
IFNULL(T_PacketOriginalPrice,0) AS T_PacketOriginalPrice,
|
||||
IFNULL(T_PacketSasCode,'') AS T_PacketSasCode,
|
||||
IFNULL(T_PacketIsActive,'') AS T_PacketIsActive,
|
||||
IFNULL(T_PacketCreated,'') AS T_PacketCreated,
|
||||
IFNULL(T_PacketLastUpdated,'') AS T_PacketLastUpdated
|
||||
FROM t_packet
|
||||
WHERE $sql_where
|
||||
GROUP BY T_PacketID
|
||||
ORDER BY T_PacketID DESC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
if ($query === false) {
|
||||
// If query failed, log the error and exit
|
||||
$this->sys_error_db("select t_packet data", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"records" => $rows,
|
||||
"sql"=> $this->db_onedev->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function getPaketById()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = $prm['T_PacketID'];
|
||||
|
||||
$sql_paket = "SELECT
|
||||
T_PacketID,
|
||||
T_PacketName,
|
||||
T_PriceHeaderID,
|
||||
T_PriceHeaderName,
|
||||
T_PacketType,
|
||||
'' as detailpackets
|
||||
FROM t_packet
|
||||
JOIN t_priceheader
|
||||
ON T_PacketT_PriceHeaderID = T_PriceHeaderID
|
||||
AND T_PacketIsActive = 'Y'
|
||||
AND T_PriceHeaderIsActive = 'Y'
|
||||
AND T_PacketID = $id
|
||||
JOIN t_packetdetail
|
||||
ON T_PacketID = T_PacketDetailT_PacketID
|
||||
AND T_PacketDetailIsActive = 'Y'
|
||||
GROUP BY T_PacketID";
|
||||
|
||||
$qry = $this->db_onedev->query($sql_paket);
|
||||
if(!$qry){
|
||||
$this->sys_error_db("t_packet count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $key => $vx) {
|
||||
$sql_detail = "SELECT
|
||||
T_PacketDetailID,
|
||||
T_PacketDetailT_PacketID,
|
||||
T_PacketDetailT_TestID,
|
||||
T_PacketDetailOriginalPrice as T_PriceTotal,
|
||||
T_PacketDetailPrice as T_PriceTotalPacket,
|
||||
T_PacketDetailIsActive,
|
||||
T_PacketDetailCreated,
|
||||
T_PacketDetailLastUpdated,
|
||||
T_PacketDetailPriceAmount,
|
||||
T_PacketDetailPriceDisc,
|
||||
T_PacketDetailPriceDiscRp,
|
||||
T_PacketDetailPriceSubTotal,
|
||||
T_TestID,
|
||||
T_TestName
|
||||
FROM t_packetdetail
|
||||
JOIN t_test
|
||||
ON T_PacketDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
AND T_PacketDetailIsActive = 'Y'
|
||||
AND T_PacketDetailT_PacketID = $id";
|
||||
|
||||
$qry_detail = $this->db_onedev->query($sql_detail);
|
||||
if(!$qry_detail){
|
||||
$this->sys_error_db("t_packetdetail count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rowdet = $qry_detail->result_array();
|
||||
$rows[$key]['sumhargaawal'] = 0;
|
||||
$rows[$key]['sumhargapaket'] = 0;
|
||||
$rows[$key]['detailpackets'] = $rowdet;
|
||||
|
||||
foreach($rowdet as $k => $vk){
|
||||
$rows[$key]['sumhargaawal'] += $vk['T_PriceTotal'];
|
||||
$rows[$key]['sumhargapaket'] += $vk['T_PriceTotalPacket'];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
$result = array(
|
||||
// "total" => $tot_page,
|
||||
"records" => $rows,
|
||||
"sql"=> $this->db_onedev->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
public function getGroupPemeriksaan() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT
|
||||
Nat_SubGroupID,
|
||||
Nat_SubGroupNat_GroupID,
|
||||
Nat_SubGroupCode,
|
||||
Nat_SubGroupName,
|
||||
Nat_SubGroupLangName,
|
||||
Nat_SubGroupIsResult,
|
||||
Nat_SubGroupReportTitle,
|
||||
Nat_SubGroupCreated,
|
||||
Nat_SubGroupLastUpdated,
|
||||
Nat_SubGroupIsActive
|
||||
FROM
|
||||
nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nat_subgroup select error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$new_entry = array(
|
||||
"Nat_SubGroupID" => "All",
|
||||
"Nat_SubGroupNat_GroupID" => "",
|
||||
"Nat_SubGroupCode" => "",
|
||||
"Nat_SubGroupName" => "All",
|
||||
"Nat_SubGroupLangName" => "",
|
||||
"Nat_SubGroupIsResult" => "",
|
||||
"Nat_SubGroupReportTitle" => "",
|
||||
"Nat_SubGroupCreated"=> "",
|
||||
"Nat_SubGroupLastUpdated"=> "",
|
||||
"Nat_SubGroupIsActive"=> ""
|
||||
);
|
||||
|
||||
array_unshift($rows, $new_entry);
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
62
application/controllers/cpone/mcuoffline/Preregister.http
Normal file
62
application/controllers/cpone/mcuoffline/Preregister.http
Normal file
@@ -0,0 +1,62 @@
|
||||
POST https://{{host}}/cpone/mcuoffline/preregister/index
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/mcuoffline/preregister/getmgmmcu
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/mcuoffline/preregister/savecsv
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"xid": "1",
|
||||
"corporateID": "1",
|
||||
"data": [
|
||||
{
|
||||
"PID": "23232333",
|
||||
"NAMA": "Yacoba",
|
||||
"TANGGAL_LAHIR": "5/12/95",
|
||||
"JENIS_KELAMIN": "L",
|
||||
"NIK": "13211313",
|
||||
"KTP": 3131323433444,
|
||||
"JABATAN": "IT",
|
||||
"EMAIL": "coba@gmail.com",
|
||||
"HP": "4536634666",
|
||||
"LOKASI": "Klodran",
|
||||
"JOB": "IT"
|
||||
},
|
||||
{
|
||||
"PID": "325452",
|
||||
"NAMA": "Coba",
|
||||
"TANGGAL_LAHIR": "5/2/99",
|
||||
"JENIS_KELAMIN": "P",
|
||||
"NIK": "445353",
|
||||
"KTP": 32424422444,
|
||||
"JABATAN": "Marketing",
|
||||
"EMAIL": "cobaa@gmail.com",
|
||||
"HP": "43242424",
|
||||
"LOKASI": "Solo",
|
||||
"JOB": "Marketing"
|
||||
}
|
||||
],
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/mcuoffline/preregister/search
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"search":"",
|
||||
"current_page":1,
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
1272
application/controllers/cpone/mcuoffline/Preregister.php
Normal file
1272
application/controllers/cpone/mcuoffline/Preregister.php
Normal file
File diff suppressed because it is too large
Load Diff
1248
application/controllers/cpone/mcuoffline/Preregister.php--100924
Normal file
1248
application/controllers/cpone/mcuoffline/Preregister.php--100924
Normal file
File diff suppressed because it is too large
Load Diff
1536
application/controllers/cpone/mcuoffline/Preregisterv2.php
Normal file
1536
application/controllers/cpone/mcuoffline/Preregisterv2.php
Normal file
File diff suppressed because it is too large
Load Diff
1329
application/controllers/cpone/mcuoffline/Preregisterv2.php--120425
Normal file
1329
application/controllers/cpone/mcuoffline/Preregisterv2.php--120425
Normal file
File diff suppressed because it is too large
Load Diff
2409
application/controllers/cpone/mcuoffline/Setupmcucpone.php
Normal file
2409
application/controllers/cpone/mcuoffline/Setupmcucpone.php
Normal file
File diff suppressed because it is too large
Load Diff
1290
application/controllers/cpone/mcuoffline/corporate/Corporate.php
Normal file
1290
application/controllers/cpone/mcuoffline/corporate/Corporate.php
Normal file
File diff suppressed because it is too large
Load Diff
1293
application/controllers/cpone/mcuoffline/corporate/Corporatev2.php
Normal file
1293
application/controllers/cpone/mcuoffline/corporate/Corporatev2.php
Normal file
File diff suppressed because it is too large
Load Diff
2402
application/controllers/cpone/mcuoffline/doctor/Doctor.php
Normal file
2402
application/controllers/cpone/mcuoffline/doctor/Doctor.php
Normal file
File diff suppressed because it is too large
Load Diff
2424
application/controllers/cpone/mcuoffline/doctor/Doctorv2.php
Normal file
2424
application/controllers/cpone/mcuoffline/doctor/Doctorv2.php
Normal file
File diff suppressed because it is too large
Load Diff
194
application/controllers/cpone/mcuoffline/doctor/Photo.php
Normal file
194
application/controllers/cpone/mcuoffline/doctor/Photo.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Photo extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Photo API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
$this->load->library('ImageManipulator');
|
||||
}
|
||||
|
||||
public function upload()
|
||||
{
|
||||
$inp = $this->sys_input;
|
||||
|
||||
$home_dir = "/home/one/project/one/";
|
||||
$target_dir = $home_dir . "one-media/one-photo/doctor/" . date("Y") . "/";
|
||||
$y = $this->regenerateOldPhoto($home_dir, $inp['id']);
|
||||
|
||||
// get patient mr
|
||||
// $p = $this->db_smartone->select("M_DoctorCode")
|
||||
// ->where("M_DoctorID", $inp['id'])
|
||||
// ->get('m_doctor')
|
||||
// ->row();
|
||||
|
||||
$sql = "SELECT M_DoctorCode FROM m_doctor WHERE M_DoctorID = {$inp['id']}";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
|
||||
if(!$qry){
|
||||
$this->sys_error_db("doctor select error", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$p = $qry->row();
|
||||
|
||||
if (!file_exists($target_dir)) {
|
||||
mkdir($target_dir, 0755, true);
|
||||
}
|
||||
|
||||
$target_path = $target_dir . $p->M_DoctorCode . ".jpg";
|
||||
$this->base64_to_jpeg($inp['data'], $target_path);
|
||||
|
||||
// CROP Image
|
||||
$im = new ImageManipulator($target_path);
|
||||
$w = $im->getWidth();
|
||||
$h = $im->getHeight();
|
||||
|
||||
$mw = ceil(3 * $h / 4);
|
||||
if ($w <= $mw)
|
||||
{
|
||||
$x1 = 0;
|
||||
$y1 = 0;
|
||||
$x2 = $w;
|
||||
$y2 = $h;
|
||||
}
|
||||
else
|
||||
{
|
||||
$x1 = floor(($w - $mw) / 2);
|
||||
$y1 = 0;
|
||||
$x2 = ceil($w - (($w - $mw) / 2));
|
||||
$y2 = $h;
|
||||
}
|
||||
|
||||
$im->crop($x1, $y1, $x2, $y2); // takes care of out of boundary conditions automatically
|
||||
$im->save($target_path);
|
||||
|
||||
$x = $this->generateThumbnail($target_path, 75, 100);
|
||||
|
||||
// Save to DB
|
||||
// $this->db_smartone->set("M_DoctorPhoto", "/" . str_replace($home_dir, "", $target_path))
|
||||
// ->set("M_DoctorPhotoThumb", "/" . str_replace($home_dir, "", $x))
|
||||
// ->set('M_DoctorPhotoCounter', '`M_DoctorPhotoCounter` + 1', false)
|
||||
// ->where('M_DoctorID', $inp['id'])
|
||||
// ->update('m_doctor');
|
||||
|
||||
$M_DoctorPhoto = "/" . str_replace($home_dir, "", $target_path);
|
||||
$M_DoctorPhotoThumb = "/" . str_replace($home_dir, "", $x);
|
||||
$M_DoctorID = $inp['id'];
|
||||
|
||||
$sql = "UPDATE m_doctor
|
||||
SET
|
||||
M_DoctorPhoto = '$M_DoctorPhoto',
|
||||
M_DoctorPhotoThumb = '$M_DoctorPhotoThumb',
|
||||
M_DoctorPhotoCounter = '`M_DoctorPhotoCounter` + 1',
|
||||
M_DoctorPhotoLastUpdated = NOW()
|
||||
WHERE M_DoctorID = $M_DoctorID";
|
||||
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
|
||||
if(!$qry){
|
||||
$this->sys_error_db("doctor update photo error", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
// LOGGING
|
||||
// $code = $y ? "PHOTO.PATIENT.EDIT" : "PHOTO.PATIENT.ADD";
|
||||
// $one_log = $this->load->database('onelog', true);
|
||||
// $one_log->set('Log_PhotoCode', $code)
|
||||
// ->set('Log_PhotoM_PatientID', $inp['id'])
|
||||
// ->set('Log_PhotoUrl', $y ? $y : "/" . str_replace($home_dir, "", $target_path))
|
||||
// ->insert('log_photo');
|
||||
|
||||
$this->sys_ok(
|
||||
[
|
||||
"rename"=>$y,
|
||||
"patient_id"=>$inp['id'],
|
||||
"patient_mr"=>$p->M_DoctorCode,
|
||||
"photo_url"=>"http://" . $_SERVER['SERVER_NAME'] . "/" . str_replace($home_dir, "", $target_path) . "?d=" . date("YmdHis")
|
||||
]);
|
||||
}
|
||||
|
||||
function base64_to_jpeg($base64_string, $output_file) {
|
||||
// open the output file for writing
|
||||
$ifp = fopen( $output_file, 'wb' );
|
||||
|
||||
// split the string on commas
|
||||
// $data[ 0 ] == "data:image/png;base64"
|
||||
// $data[ 1 ] == <actual base64 string>
|
||||
$data = explode( ',', $base64_string );
|
||||
|
||||
// we could add validation here with ensuring count( $data ) > 1
|
||||
fwrite( $ifp, base64_decode( $data[ 1 ] ) );
|
||||
|
||||
// clean up the file resource
|
||||
fclose( $ifp );
|
||||
|
||||
return $output_file;
|
||||
}
|
||||
|
||||
function generateThumbnail($img, $width, $height, $quality = 90)
|
||||
{
|
||||
if (is_file($img)) {
|
||||
$imagick = new Imagick(realpath($img));
|
||||
$imagick->setImageFormat('jpeg');
|
||||
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
||||
$imagick->setImageCompressionQuality($quality);
|
||||
$imagick->thumbnailImage($width, $height, false, false);
|
||||
$filename_no_ext = reset(explode('.', $img));
|
||||
if (file_put_contents($filename_no_ext . '_thumb' . '.jpg', $imagick) === false) {
|
||||
throw new Exception("Could not put contents.");
|
||||
}
|
||||
return $filename_no_ext . '_thumb' . '.jpg';
|
||||
}
|
||||
else {
|
||||
throw new Exception("No valid image provided with {$img}.");
|
||||
}
|
||||
}
|
||||
|
||||
function regenerateOldPhoto($home_dir, $id)
|
||||
{
|
||||
// $r = $this->db_smartone->select('m_doctorphoto, m_doctorphotocounter', false)
|
||||
// ->where('m_doctorid', $id)
|
||||
// ->get('m_doctor')
|
||||
// ->row();
|
||||
|
||||
// $r = $this->db_smartone->select('M_DoctorPhoto, M_DoctorPhotoCounter', false)
|
||||
// ->where('M_DoctorID', $id)
|
||||
// ->get('m_doctor')
|
||||
// ->row();
|
||||
|
||||
$sql = "SELECT * FROM m_doctor WHERE M_DoctorID = $id";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
|
||||
if(!$qry){
|
||||
$this->sys_error_db("doctor select error", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$r = $qry->row();
|
||||
|
||||
if ($r->M_DoctorPhoto != null && $r->M_DoctorPhotoCounter > 0) {
|
||||
$full_path = substr_replace($home_dir ,"", -1) . $r->M_DoctorPhoto;
|
||||
$path_parts = pathinfo($full_path);
|
||||
|
||||
$rename = $path_parts['dirname'] . '/' . $path_parts['filename'] . '-' . $r->M_DoctorPhotoCounter . '.' . $path_parts['extension'];
|
||||
rename($full_path, $rename);
|
||||
// echo $path_parts['dirname'], "\n";
|
||||
// echo $path_parts['extension'], "\n";
|
||||
// echo $path_parts['filename'], "\n";
|
||||
|
||||
return "/" . str_replace($home_dir, "", $rename);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,946 @@
|
||||
<?php
|
||||
class Packetcponev2 extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function savesetupv0()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$T_PacketName = strtoupper($prm['namapacket']);
|
||||
$T_PriceHeaderID = $prm['priceheader']['T_PriceHeaderID'];
|
||||
$T_PacketType = $prm['jenispacket'];
|
||||
$T_PacketPrice = $prm['T_PacketPrice'];
|
||||
$T_PacketOriginalPrice = $prm['T_PacketOriginalPrice'];
|
||||
$T_PacketSasCode = "";
|
||||
$T_PacketOriginalBruto = 0;
|
||||
$detail_packet = $prm['detailpacket'];
|
||||
$T_PacketStartDate = date('Y-m-d',strtotime($prm["T_PacketStartDate"]));
|
||||
$T_PacketEndDate = date('Y-m-d',strtotime($prm["T_PacketEndDate"]));
|
||||
// $act = $prm['act'];
|
||||
|
||||
if($prm["act"] == 'new'){
|
||||
// check paket exists or not
|
||||
$sqlCheck = "SELECT *
|
||||
FROM t_packet
|
||||
WHERE T_PacketIsActive = 'Y'
|
||||
AND T_PacketName = '$T_PacketName'";
|
||||
|
||||
$qryCheck = $this->db_onedev->query($sqlCheck);
|
||||
|
||||
if(!$qryCheck){
|
||||
$this->sys_error_db("t_packet check", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rowCheck = $qryCheck->result_array();
|
||||
|
||||
if(count($rowCheck) > 0){
|
||||
$this->sys_error("Data dengan nama paket ".$T_PacketName." Sudah Ada");
|
||||
exit;
|
||||
} else {
|
||||
// get numbering
|
||||
$sql_get_numbering = "SELECT fn_numbering_cpone('PCPN') as numberx";
|
||||
if($T_PacketType == 'PR'){
|
||||
$sql_get_numbering = "SELECT fn_numbering_cpone('PCPR') as numberx";
|
||||
}
|
||||
|
||||
$qry_get_numbering = $this->db_onedev->query($sql_get_numbering);
|
||||
if(!$qry_get_numbering){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("packet numbering cpone", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data_numbering = $qry_get_numbering->result_array();
|
||||
|
||||
$T_PacketSasCode = $data_numbering[0]['numberx'];
|
||||
|
||||
// insert t_packet
|
||||
$sql_insert = "INSERT INTO t_packet
|
||||
(
|
||||
T_PacketT_PriceHeaderID,
|
||||
T_PacketType,
|
||||
T_PacketName,
|
||||
T_PacketPrice,
|
||||
T_PacketOriginalPrice,
|
||||
T_PacketSasCode,
|
||||
T_PacketIsActive,
|
||||
T_PacketCreated,
|
||||
T_PacketOriginalBruto,
|
||||
T_PacketStartDate,
|
||||
T_PacketEndDate
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
$T_PriceHeaderID, -- T_PacketT_PriceHeaderID
|
||||
'$T_PacketType', -- T_PacketType (assuming 'PR' for Profile)
|
||||
'$T_PacketName', -- T_PacketName
|
||||
$T_PacketPrice, -- T_PacketPrice
|
||||
$T_PacketOriginalPrice, -- T_PacketOriginalPrice
|
||||
'$T_PacketSasCode', -- T_PacketSasCode
|
||||
'Y', -- T_PacketIsActive
|
||||
NOW(), -- T_PacketCreated
|
||||
$T_PacketOriginalBruto, -- T_PacketOriginalBruto (can be NULL)
|
||||
'$T_PacketStartDate',
|
||||
'$T_PacketEndDate'
|
||||
)";
|
||||
|
||||
$qryInsert = $this->db_onedev->query($sql_insert);
|
||||
if(!$qryInsert){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packet insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
// insert t_packetdetail
|
||||
if(count($detail_packet) > 0) {
|
||||
foreach($detail_packet as $k => $v){
|
||||
$T_PriceTotalPacket = $v['T_PriceTotalPacket'];
|
||||
|
||||
// bisa berubah ubah kalau PN
|
||||
if($T_PacketType == "PN"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $T_PriceTotalPacket;
|
||||
}
|
||||
|
||||
if($T_PacketType == "PR"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $v['T_PriceTotal'];
|
||||
}
|
||||
|
||||
$T_PacketDetailPriceAmount = 0;
|
||||
$T_PacketDetailPriceDisc = 0;
|
||||
$T_PacketDetailPriceDiscRp = 0;
|
||||
$T_PacketDetailPriceSubTotal = 0;
|
||||
|
||||
if(!empty($v['T_PriceAmount'])){
|
||||
$T_PacketDetailPriceAmount = $v['T_PriceAmount'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDisc'])){
|
||||
$T_PacketDetailPriceDisc = $v['T_PriceDisc'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDiscRp'])){
|
||||
$T_PacketDetailPriceDiscRp = $v['T_PriceDiscRp'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceSubTotal'])){
|
||||
$T_PacketDetailPriceSubTotal = $v['T_PriceSubTotal'];
|
||||
}
|
||||
|
||||
$sql_insert_detail = "INSERT INTO t_packetdetail
|
||||
(
|
||||
T_PacketDetailT_PacketID,
|
||||
T_PacketDetailT_TestID,
|
||||
T_PacketDetailOriginalPrice,
|
||||
T_PacketDetailPrice,
|
||||
T_PacketDetailIsActive,
|
||||
T_PacketDetailCreated,
|
||||
T_PacketDetailPriceAmount,
|
||||
T_PacketDetailPriceDisc,
|
||||
T_PacketDetailPriceDiscRp,
|
||||
T_PacketDetailPriceSubTotal
|
||||
) VALUES (
|
||||
$last_id, -- T_PacketDetailT_PacketID
|
||||
{$v['T_TestID']}, -- T_PacketDetailT_TestID
|
||||
{$T_PacketDetailOriginalPrice}, -- T_PacketDetailOriginalPrice
|
||||
{$T_PacketDetailPrice}, -- T_PacketDetailPrice
|
||||
'Y', -- T_PacketDetailIsActive
|
||||
NOW(), -- T_PacketDetailCreated
|
||||
{$T_PacketDetailPriceAmount}, -- T_PacketDetailPriceAmount
|
||||
{$T_PacketDetailPriceDisc}, -- T_PacketDetailPriceDisc
|
||||
{$T_PacketDetailPriceDiscRp}, -- T_PacketDetailPriceDiscRp
|
||||
{$T_PacketDetailPriceSubTotal} -- T_PacketDetailPriceSubTotal
|
||||
)";
|
||||
|
||||
$qry_detail = $this->db_onedev->query($sql_insert_detail);
|
||||
if(!$qry_detail) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT T_PacketName as xnumber
|
||||
FROM t_packet
|
||||
WHERE T_PacketID = {$last_id}";
|
||||
|
||||
//echo $sql;
|
||||
$row = $this->db_onedev->query($sql)->row_array();
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $row,
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
} else{
|
||||
// check paket exists or not
|
||||
$sqlCheck = "SELECT *
|
||||
FROM t_packet
|
||||
WHERE T_PacketIsActive = 'Y'
|
||||
AND T_PacketName = '$T_PacketName'
|
||||
AND T_PacketID <> {$prm["xid"]}";
|
||||
|
||||
// echo $sqlCheck;
|
||||
// exit;
|
||||
|
||||
$qryCheck = $this->db_onedev->query($sqlCheck);
|
||||
|
||||
if(!$qryCheck){
|
||||
$this->sys_error_db("t_packet check", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rowCheck = $qryCheck->result_array();
|
||||
if(count($rowCheck) > 0){
|
||||
// echo $sqlCheck;
|
||||
// exit;
|
||||
$this->sys_error("Data dengan nama paket ".$T_PacketName." Sudah Ada", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
// update t_packet
|
||||
$sql_update = "UPDATE t_packet
|
||||
SET
|
||||
T_PacketT_PriceHeaderID = $T_PriceHeaderID,
|
||||
T_PacketType = '$T_PacketType',
|
||||
T_PacketName = '$T_PacketName',
|
||||
T_PacketPrice = $T_PacketPrice,
|
||||
T_PacketOriginalPrice = $T_PacketOriginalPrice,
|
||||
T_PacketIsActive = 'Y',
|
||||
T_PacketLastUpdated = NOW(),
|
||||
T_PacketOriginalBruto = $T_PacketOriginalBruto,
|
||||
T_PacketStartDate = '$T_PacketStartDate',
|
||||
T_PacketEndDate = '$T_PacketEndDate'
|
||||
WHERE
|
||||
T_PacketID = {$prm["xid"]}";
|
||||
|
||||
$qryUpdate = $this->db_onedev->query($sql_update);
|
||||
if(!$qryUpdate){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("error t_packet update", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$last_id = $prm["xid"];
|
||||
|
||||
// // update detail packet
|
||||
// // update isActive N kan semua
|
||||
$sqlUpdatePacket = "UPDATE t_packetdetail
|
||||
SET
|
||||
T_PacketDetailIsActive = 'N',
|
||||
T_PacketDetailLastUpdated = NOW()
|
||||
WHERE T_PacketDetailT_PacketID = $last_id";
|
||||
|
||||
// echo $sqlUpdatePacket;
|
||||
|
||||
$qry_mgm_update_tpacketdetails = $this->db_onedev->query($sqlUpdatePacket);
|
||||
if(!$qry_mgm_update_tpacketdetails){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail update", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// insert t_packetdetail
|
||||
if(count($detail_packet) > 0) {
|
||||
foreach($detail_packet as $k => $v){
|
||||
$T_PriceTotalPacket = $v['T_PriceTotalPacket'];
|
||||
|
||||
// bisa berubah ubah kalau PN
|
||||
if($T_PacketType == "PN"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $T_PriceTotalPacket;
|
||||
}
|
||||
|
||||
if($T_PacketType == "PR"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $v['T_PriceTotal'];
|
||||
}
|
||||
|
||||
$T_PacketDetailPriceAmount = 0;
|
||||
$T_PacketDetailPriceDisc = 0;
|
||||
$T_PacketDetailPriceDiscRp = 0;
|
||||
$T_PacketDetailPriceSubTotal = 0;
|
||||
|
||||
if(!empty($v['T_PriceAmount'])){
|
||||
$T_PacketDetailPriceAmount = $v['T_PriceAmount'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDisc'])){
|
||||
$T_PacketDetailPriceDisc = $v['T_PriceDisc'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDiscRp'])){
|
||||
$T_PacketDetailPriceDiscRp = $v['T_PriceDiscRp'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceSubTotal'])){
|
||||
$T_PacketDetailPriceSubTotal = $v['T_PriceSubTotal'];
|
||||
}
|
||||
|
||||
$sql_insert_detail = "INSERT INTO t_packetdetail
|
||||
(
|
||||
T_PacketDetailT_PacketID,
|
||||
T_PacketDetailT_TestID,
|
||||
T_PacketDetailOriginalPrice,
|
||||
T_PacketDetailPrice,
|
||||
T_PacketDetailIsActive,
|
||||
T_PacketDetailCreated,
|
||||
T_PacketDetailPriceAmount,
|
||||
T_PacketDetailPriceDisc,
|
||||
T_PacketDetailPriceDiscRp,
|
||||
T_PacketDetailPriceSubTotal
|
||||
) VALUES (
|
||||
$last_id, -- T_PacketDetailT_PacketID
|
||||
{$v['T_TestID']}, -- T_PacketDetailT_TestID
|
||||
{$T_PacketDetailOriginalPrice}, -- T_PacketDetailOriginalPrice
|
||||
{$T_PacketDetailPrice}, -- T_PacketDetailPrice
|
||||
'Y', -- T_PacketDetailIsActive
|
||||
NOW(), -- T_PacketDetailCreated
|
||||
{$T_PacketDetailPriceAmount}, -- T_PacketDetailPriceAmount
|
||||
{$T_PacketDetailPriceDisc}, -- T_PacketDetailPriceDisc
|
||||
{$T_PacketDetailPriceDiscRp}, -- T_PacketDetailPriceDiscRp
|
||||
{$T_PacketDetailPriceSubTotal} -- T_PacketDetailPriceSubTotal
|
||||
)";
|
||||
|
||||
$qry_detail = $this->db_onedev->query($sql_insert_detail);
|
||||
if(!$qry_detail) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT T_PacketName as xnumber
|
||||
FROM t_packet
|
||||
WHERE T_PacketID = {$last_id}";
|
||||
|
||||
//echo $sql;
|
||||
$row = $this->db_onedev->query($sql)->row_array();
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $row,
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletev0(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// packet
|
||||
$query_t_packet = $this->db_onedev->query("UPDATE t_packet SET
|
||||
T_PacketIsActive = 'N',
|
||||
T_PacketLastUpdated = NOW()
|
||||
WHERE
|
||||
T_PacketID = '{$prm['id']}'
|
||||
");
|
||||
|
||||
if (!$query_t_packet) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packet update error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// packet details
|
||||
$query_t_packetdetail = $this->db_onedev->query("UPDATE t_packetdetail SET
|
||||
T_PacketDetailIsActive = 'N',
|
||||
T_PacketDetailLastUpdated = NOW()
|
||||
WHERE
|
||||
T_PacketDetailT_PacketID = '{$prm['id']}'
|
||||
");
|
||||
|
||||
if (!$query_t_packetdetail) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail update error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $rows = $this->db_onedev->query($query_mgmmcu);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getTTestByTPriceHeaderCurrent()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// $search_kode = $prm['searchKode'];
|
||||
// $search_nama = $prm['searchNama'];
|
||||
|
||||
$number_limit = 30;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
|
||||
$natsubgroup = "";
|
||||
$sql_where_natsubgroup = "";
|
||||
|
||||
if(isset($prm['natsubgroup']) && !empty($prm['natsubgroup']) && $prm['natsubgroup'] != "All"){
|
||||
$natsubgroup = $prm['natsubgroup'];
|
||||
$sql_where_natsubgroup = " AND Nat_SubGroupID = $natsubgroup";
|
||||
}
|
||||
|
||||
// if($natsubgroup != "All"){
|
||||
// $sql_where_natsubgroup = " AND Nat_SubGroupID = $natsubgroup";
|
||||
// }
|
||||
|
||||
$tpriceheader = $prm['tpriceheader'];
|
||||
$sql_where_tpriceheader = "";
|
||||
|
||||
if(isset($prm['tpriceheader']) && !empty($prm['tpriceheader'])){
|
||||
$sql_where_tpriceheader = " AND ph.T_PriceHeaderID = $tpriceheader";
|
||||
}
|
||||
|
||||
$sqlSearch = "T_TestName LIKE '%%' AND T_TestCode LIKE '%%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
|
||||
if(isset($prm['searchKode']) && !empty($prm['searchKode'])){
|
||||
$sqlSearch = " T_TestCode LIKE '%{$prm['searchKode']}%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
}
|
||||
|
||||
if(isset($prm['searchNama']) && !empty($prm['searchNama'])){
|
||||
$sqlSearch = " T_TestName LIKE '%{$prm['searchNama']}%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
}
|
||||
|
||||
if(
|
||||
((isset($prm['searchKode']) && !empty($prm['searchKode'])))
|
||||
&& (isset($prm['searchNama']) && !empty($prm['searchNama']))
|
||||
){
|
||||
$sqlSearch = " T_TestName LIKE '%{$prm['searchNama']}%' AND T_TestCode LIKE '%{$prm['searchKode']}%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
}
|
||||
|
||||
$sql_where = "
|
||||
WHERE (
|
||||
".$sqlSearch."
|
||||
)";
|
||||
|
||||
|
||||
|
||||
// $sql_where = "
|
||||
// WHERE (
|
||||
// T_TestCode LIKE '%{$prm['searchKode']}%'
|
||||
// OR T_TestName LIKE '%{$prm['searchNama']}%'
|
||||
// )";
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT
|
||||
IFNULL(p.T_PriceID, 0) AS T_PriceID
|
||||
FROM
|
||||
t_price p
|
||||
JOIN
|
||||
t_priceheader ph
|
||||
ON
|
||||
p.T_PriceT_PriceHeaderID = ph.T_PriceHeaderID
|
||||
AND p.T_PriceIsActive = 'Y'
|
||||
AND ph.T_PriceHeaderIsActive = 'Y'
|
||||
JOIN
|
||||
t_test testx
|
||||
ON p.T_PriceT_TestID = testx.T_TestID
|
||||
AND testx.T_TestIsActive = 'Y'
|
||||
LEFT JOIN nat_subgroup
|
||||
ON T_TestNat_SubgroupID = Nat_SubgroupID
|
||||
AND Nat_SubGroupIsActive = 'Y'
|
||||
$sql_where
|
||||
) x";
|
||||
|
||||
$sql_param = array();
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("tprice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT
|
||||
ROW_NUMBER() OVER (ORDER BY T_PriceID) AS RowNum,
|
||||
IFNULL(p.T_PriceTotal, 0) AS T_PriceTotalPacket,
|
||||
IFNULL(p.T_PriceID, 0) AS T_PriceID,
|
||||
IFNULL(p.T_PriceT_PriceHeaderID, 0) AS T_PriceT_PriceHeaderID,
|
||||
IFNULL(p.T_PriceT_TestID, 0) AS T_PriceT_TestID,
|
||||
IFNULL(p.T_PriceIsCito, 'N') AS T_PriceIsCito,
|
||||
IFNULL(p.T_PricePriority, 1) AS T_PricePriority,
|
||||
IFNULL(p.T_PriceAmount, 0) AS T_PriceAmount,
|
||||
IFNULL(p.T_PriceDisc, 0) AS T_PriceDisc,
|
||||
IFNULL(p.T_PriceDiscRp, 0) AS T_PriceDiscRp,
|
||||
IFNULL(p.T_PriceSubTotal, 0) AS T_PriceSubTotal,
|
||||
IFNULL(p.T_PriceOther, 0) AS T_PriceOther,
|
||||
IFNULL(p.T_PriceTotal, 0) AS T_PriceTotal,
|
||||
IFNULL(p.T_PriceIsActive, 'Y') AS T_PriceIsActive,
|
||||
IFNULL(p.T_PriceCreated, '0000-00-00') AS T_PriceCreated,
|
||||
IFNULL(p.T_PriceLastUpdated, '0000-00-00') AS T_PriceLastUpdated,
|
||||
IFNULL(p.T_PriceUserID, 0) AS T_PriceUserID,
|
||||
IFNULL(ph.T_PriceHeaderID, 0) AS T_PriceHeaderID,
|
||||
IFNULL(ph.T_PriceHeaderName, '') AS T_PriceHeaderName,
|
||||
IFNULL(ph.T_PriceHeaderStartDate, '0000-00-00') AS T_PriceHeaderStartDate,
|
||||
IFNULL(ph.T_PriceHeaderEndDate, '0000-00-00') AS T_PriceHeaderEndDate,
|
||||
IFNULL(ph.T_PriceHeaderIsActive, 'Y') AS T_PriceHeaderIsActive,
|
||||
IFNULL(ph.T_PriceHeaderUserID, 0) AS T_PriceHeaderUserID,
|
||||
IFNULL(ph.T_PriceHeaderCreated, '0000-00-00 00:00:00') AS T_PriceHeaderCreated,
|
||||
IFNULL(ph.T_PriceHeaderCraetdUserID, 0) AS T_PriceHeaderCraetdUserID,
|
||||
IFNULL(ph.T_PriceHeaderLastUpdated, '0000-00-00 00:00:00') AS T_PriceHeaderLastUpdated,
|
||||
IFNULL(ph.T_PriceHeaderLastUpdatedUserID, 0) AS T_PriceHeaderLastUpdatedUserID,
|
||||
IFNULL(ph.T_PriceHeaderDeleted, '0000-00-00 00:00:00') AS T_PriceHeaderDeleted,
|
||||
IFNULL(ph.T_PriceHeaderDeletedUserID, 0) AS T_PriceHeaderDeletedUserID,
|
||||
IFNULL(testx.T_TestID, 0) AS T_TestID,
|
||||
IFNULL(testx.T_TestCode, '') AS T_TestCode,
|
||||
IFNULL(testx.T_TestName, '') AS T_TestName
|
||||
FROM
|
||||
t_price p
|
||||
JOIN
|
||||
t_priceheader ph
|
||||
ON
|
||||
p.T_PriceT_PriceHeaderID = ph.T_PriceHeaderID
|
||||
AND p.T_PriceIsActive = 'Y'
|
||||
AND ph.T_PriceHeaderIsActive = 'Y'
|
||||
JOIN
|
||||
t_test testx
|
||||
ON p.T_PriceT_TestID = testx.T_TestID
|
||||
AND testx.T_TestIsActive = 'Y'
|
||||
LEFT JOIN nat_subgroup
|
||||
ON T_TestNat_SubgroupID = Nat_SubgroupID
|
||||
AND Nat_SubGroupIsActive = 'Y'
|
||||
$sql_where
|
||||
ORDER BY p.T_PriceID DESC
|
||||
limit $number_limit offset $number_offset
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
if ($query === false) {
|
||||
// If query failed, log the error and exit
|
||||
$this->sys_error_db("select t_price data", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getTPriceHeader()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_priceheader
|
||||
WHERE T_PriceHeaderIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("t_priceheader select error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$new_entry = array(
|
||||
'T_PriceHeaderID' => 'All',
|
||||
'T_PriceHeaderName' => 'All',
|
||||
'T_PriceHeaderStartDate' => "",
|
||||
'T_PriceHeaderEndDate' => "",
|
||||
'T_PriceHeaderIsActive' => "",
|
||||
'T_PriceHeaderUserID' => "",
|
||||
'T_PriceHeaderCreated' => "",
|
||||
'T_PriceHeaderCraetdUserID' => "",
|
||||
'T_PriceHeaderLastUpdated' => "",
|
||||
'T_PriceHeaderLastUpdatedUserID' => "",
|
||||
'T_PriceHeaderDeleted' => "",
|
||||
'T_PriceHeaderDeletedUserID' => ""
|
||||
);
|
||||
|
||||
array_unshift($rows, $new_entry);
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getTPriceHeaderCurrent()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT
|
||||
IFNULL(T_PriceHeaderID, 0) AS T_PriceHeaderID,
|
||||
IFNULL(T_PriceHeaderName, '') AS T_PriceHeaderName,
|
||||
IFNULL(T_PriceHeaderStartDate, '0000-00-00') AS T_PriceHeaderStartDate,
|
||||
IFNULL(T_PriceHeaderEndDate, '0000-00-00') AS T_PriceHeaderEndDate,
|
||||
IFNULL(T_PriceHeaderIsActive, 'Y') AS T_PriceHeaderIsActive,
|
||||
IFNULL(T_PriceHeaderUserID, 0) AS T_PriceHeaderUserID,
|
||||
IFNULL(T_PriceHeaderCreated, '0000-00-00 00:00:00') AS T_PriceHeaderCreated,
|
||||
IFNULL(T_PriceHeaderCraetdUserID, 0) AS T_PriceHeaderCraetdUserID,
|
||||
IFNULL(T_PriceHeaderLastUpdated, '0000-00-00 00:00:00') AS T_PriceHeaderLastUpdated,
|
||||
IFNULL(T_PriceHeaderLastUpdatedUserID, 0) AS T_PriceHeaderLastUpdatedUserID,
|
||||
IFNULL(T_PriceHeaderDeleted, '0000-00-00 00:00:00') AS T_PriceHeaderDeleted,
|
||||
IFNULL(T_PriceHeaderDeletedUserID, 0) AS T_PriceHeaderDeletedUserID,
|
||||
T_PriceHeaderIsGenerated
|
||||
FROM
|
||||
t_priceheader
|
||||
WHERE T_PriceHeaderIsActive = 'Y'";
|
||||
// -- AND CURDATE() BETWEEN T_PriceHeaderStartDate AND T_PriceHeaderEndDate";
|
||||
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("t_priceheader select error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function searchv0()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
// $search = $prm['search'];
|
||||
// if (isset($prm['search'])) {
|
||||
// $search = trim($prm["search"]);
|
||||
// if ($search != "") {
|
||||
// $search = '%' . $prm['search'] . '%';
|
||||
// }else{
|
||||
// $search = '%%';
|
||||
// }
|
||||
// }
|
||||
|
||||
// $limit = '';
|
||||
// $filter_paket = $prm['searchPacket'];
|
||||
// if($all == 'N'){
|
||||
// $limit = ' LIMIT 10';
|
||||
// }
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
// $sql_where = " (
|
||||
// T_PacketName LIKE '%{$prm['search']}%'
|
||||
// OR T_PacketType LIKE '%{$prm['search']}%'
|
||||
// ) AND T_PacketIsActive = 'Y'";
|
||||
|
||||
$sql_where_tpriceheader = "";
|
||||
$tpriceheader = "";
|
||||
|
||||
|
||||
if(isset($prm['tpriceheader'])){
|
||||
$tpriceheader = $prm['tpriceheader'];
|
||||
}
|
||||
|
||||
if($tpriceheader != "All"){
|
||||
$sql_where_tpriceheader = " AND T_PacketT_PriceHeaderID = $tpriceheader";
|
||||
}
|
||||
|
||||
$sql_where = " (
|
||||
T_PacketName LIKE '%{$prm['search']}%'
|
||||
) AND T_PacketIsActive = 'Y'
|
||||
$sql_where_tpriceheader";
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_packet
|
||||
WHERE $sql_where
|
||||
";
|
||||
|
||||
$sql_param = array();
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("t_packet count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT
|
||||
IFNULL(T_PacketID, 0) AS T_PacketID,
|
||||
IFNULL(T_PacketT_PriceHeaderID, 0) AS T_PacketT_PriceHeaderID,
|
||||
IFNULL(T_PacketType,'') AS T_PacketType,
|
||||
IFNULL(T_PacketName,'') AS T_PacketName,
|
||||
IFNULL(T_PacketPrice,0) AS T_PacketPrice,
|
||||
IFNULL(T_PacketOriginalPrice,0) AS T_PacketOriginalPrice,
|
||||
IFNULL(T_PacketSasCode,'') AS T_PacketSasCode,
|
||||
IFNULL(T_PacketIsActive,'') AS T_PacketIsActive,
|
||||
IFNULL(T_PacketCreated,'') AS T_PacketCreated,
|
||||
IFNULL(T_PacketLastUpdated,'') AS T_PacketLastUpdated,
|
||||
IFNULL(T_PacketStartDate, '0000-00-00 00:00:00') AS T_PacketStartDate,
|
||||
IFNULL(T_PacketEndDate, '0000-00-00 00:00:00') AS T_PacketEndDate,
|
||||
T_PacketIsGenerated,
|
||||
T_PacketGeneratedDate
|
||||
FROM t_packet
|
||||
WHERE $sql_where
|
||||
GROUP BY T_PacketID
|
||||
ORDER BY T_PacketID DESC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
if ($query === false) {
|
||||
// If query failed, log the error and exit
|
||||
$this->sys_error_db("select t_packet data", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"records" => $rows,
|
||||
"sql"=> $this->db_onedev->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function getPaketById()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = $prm['T_PacketID'];
|
||||
|
||||
$sql_paket = "SELECT
|
||||
T_PacketID,
|
||||
T_PacketName,
|
||||
T_PriceHeaderID,
|
||||
T_PriceHeaderName,
|
||||
T_PacketType,
|
||||
IFNULL(T_PacketStartDate, '0000-00-00 00:00:00') AS T_PacketStartDate,
|
||||
IFNULL(T_PacketEndDate, '0000-00-00 00:00:00') AS T_PacketEndDate,
|
||||
'' as detailpackets
|
||||
FROM t_packet
|
||||
JOIN t_priceheader
|
||||
ON T_PacketT_PriceHeaderID = T_PriceHeaderID
|
||||
AND T_PacketIsActive = 'Y'
|
||||
AND T_PriceHeaderIsActive = 'Y'
|
||||
AND T_PacketID = $id
|
||||
JOIN t_packetdetail
|
||||
ON T_PacketID = T_PacketDetailT_PacketID
|
||||
AND T_PacketDetailIsActive = 'Y'
|
||||
GROUP BY T_PacketID";
|
||||
|
||||
$qry = $this->db_onedev->query($sql_paket);
|
||||
if(!$qry){
|
||||
$this->sys_error_db("t_packet count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $key => $vx) {
|
||||
$sql_detail = "SELECT
|
||||
T_PacketDetailID,
|
||||
T_PacketDetailT_PacketID,
|
||||
T_PacketDetailT_TestID,
|
||||
T_PacketDetailOriginalPrice as T_PriceTotal,
|
||||
T_PacketDetailPrice as T_PriceTotalPacket,
|
||||
T_PacketDetailIsActive,
|
||||
T_PacketDetailCreated,
|
||||
T_PacketDetailLastUpdated,
|
||||
T_PacketDetailPriceAmount,
|
||||
T_PacketDetailPriceDisc,
|
||||
T_PacketDetailPriceDiscRp,
|
||||
T_PacketDetailPriceSubTotal,
|
||||
T_TestID,
|
||||
T_TestName
|
||||
FROM t_packetdetail
|
||||
JOIN t_test
|
||||
ON T_PacketDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
AND T_PacketDetailIsActive = 'Y'
|
||||
AND T_PacketDetailT_PacketID = $id";
|
||||
|
||||
$qry_detail = $this->db_onedev->query($sql_detail);
|
||||
if(!$qry_detail){
|
||||
$this->sys_error_db("t_packetdetail count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rowdet = $qry_detail->result_array();
|
||||
$rows[$key]['sumhargaawal'] = 0;
|
||||
$rows[$key]['sumhargapaket'] = 0;
|
||||
$rows[$key]['detailpackets'] = $rowdet;
|
||||
|
||||
foreach($rowdet as $k => $vk){
|
||||
$rows[$key]['sumhargaawal'] += $vk['T_PriceTotal'];
|
||||
$rows[$key]['sumhargapaket'] += $vk['T_PriceTotalPacket'];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
$result = array(
|
||||
// "total" => $tot_page,
|
||||
"records" => $rows,
|
||||
"sql"=> $this->db_onedev->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
public function getGroupPemeriksaan() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT
|
||||
Nat_SubGroupID,
|
||||
Nat_SubGroupNat_GroupID,
|
||||
Nat_SubGroupCode,
|
||||
Nat_SubGroupName,
|
||||
Nat_SubGroupLangName,
|
||||
Nat_SubGroupIsResult,
|
||||
Nat_SubGroupReportTitle,
|
||||
Nat_SubGroupCreated,
|
||||
Nat_SubGroupLastUpdated,
|
||||
Nat_SubGroupIsActive
|
||||
FROM
|
||||
nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nat_subgroup select error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$new_entry = array(
|
||||
"Nat_SubGroupID" => "All",
|
||||
"Nat_SubGroupNat_GroupID" => "",
|
||||
"Nat_SubGroupCode" => "",
|
||||
"Nat_SubGroupName" => "All",
|
||||
"Nat_SubGroupLangName" => "",
|
||||
"Nat_SubGroupIsResult" => "",
|
||||
"Nat_SubGroupReportTitle" => "",
|
||||
"Nat_SubGroupCreated"=> "",
|
||||
"Nat_SubGroupLastUpdated"=> "",
|
||||
"Nat_SubGroupIsActive"=> ""
|
||||
);
|
||||
|
||||
array_unshift($rows, $new_entry);
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
1155
application/controllers/cpone/mcuoffline/packet/Packetcponev3.php
Normal file
1155
application/controllers/cpone/mcuoffline/packet/Packetcponev3.php
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1273
application/controllers/cpone/mcuoffline/packet/Packetcponev4.php
Normal file
1273
application/controllers/cpone/mcuoffline/packet/Packetcponev4.php
Normal file
File diff suppressed because it is too large
Load Diff
2329
application/controllers/cpone/mcuoffline/patient/Patient.php
Normal file
2329
application/controllers/cpone/mcuoffline/patient/Patient.php
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user