Compare commits
2 Commits
master
...
monitoring
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c63d678332 | ||
|
|
4a49c89a31 |
@@ -3,6 +3,7 @@ class Transactionv4 extends MY_Controller
|
||||
{
|
||||
|
||||
var $db_onedev;
|
||||
private $force_debug_ais_payload = false;
|
||||
public function index()
|
||||
{
|
||||
echo "Transaction API";
|
||||
@@ -63,6 +64,26 @@ class Transactionv4 extends MY_Controller
|
||||
return implode(' ', $parts);
|
||||
}
|
||||
|
||||
private function should_debug_ais_payload()
|
||||
{
|
||||
return $this->force_debug_ais_payload === true;
|
||||
}
|
||||
|
||||
private function debug_ais_payload_response($sourceEndpoint, $method, $url, $headers, $payload)
|
||||
{
|
||||
$this->sys_ok(array(
|
||||
'status' => 'debug',
|
||||
'message' => 'Debug payload only, request not sent to AIS',
|
||||
'source_endpoint' => $sourceEndpoint,
|
||||
'target_method' => $method,
|
||||
'target_url' => $url,
|
||||
'target_headers' => array_merge(array('Content-Type: application/json'), $headers),
|
||||
'target_payload' => $payload,
|
||||
'curl_command' => $this->build_curl_command($url, $payload, $headers, $method)
|
||||
));
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic POST request function
|
||||
* @param string $url API endpoint URL
|
||||
@@ -313,6 +334,16 @@ class Transactionv4 extends MY_Controller
|
||||
public function post_auth()
|
||||
{
|
||||
$dt_config = $this->get_config();
|
||||
if ($this->should_debug_ais_payload()) {
|
||||
return array(
|
||||
'success' => true,
|
||||
'debug' => true,
|
||||
'message' => 'Debug payload only, auth request not sent to AIS',
|
||||
'data' => array(
|
||||
'token' => $dt_config['AisConfigAuthToken'] ?? null
|
||||
)
|
||||
);
|
||||
}
|
||||
$baseUrl = $dt_config['AisConfigBaseUrl'];
|
||||
$url = $baseUrl . '/api/auth/auth.php';
|
||||
$headers = array(
|
||||
@@ -378,8 +409,9 @@ class Transactionv4 extends MY_Controller
|
||||
function post_transaction_daily_by_date($min_date = null, $max_date = null)
|
||||
{
|
||||
//echo "post_transaction_daily_by_date";
|
||||
$debugPayload = $this->should_debug_ais_payload();
|
||||
// Auth Login
|
||||
$login = $this->post_auth();
|
||||
$login = $debugPayload ? array('success' => true) : $this->post_auth();
|
||||
//echo json_encode($login);
|
||||
//exit;
|
||||
|
||||
@@ -542,7 +574,7 @@ class Transactionv4 extends MY_Controller
|
||||
}
|
||||
$raw_data = $qry->result_array();
|
||||
if (count($raw_data) == 0) {
|
||||
$errors = array('status' => 'error', 'message' => 'Data tidak ditemukan', 'query' => $this->db_onedev->last_query());
|
||||
$errors = array('status' => 'error', 'message' => 'Data reguler tidak ditemukan', 'query' => $this->db_onedev->last_query());
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
@@ -821,6 +853,28 @@ class Transactionv4 extends MY_Controller
|
||||
$get_transaction = $this->get_transaction_by_labnumber($row['RegID']);
|
||||
// echo json_encode($get_transaction);
|
||||
|
||||
if ($debugPayload) {
|
||||
$method = ($get_transaction && count($get_transaction) > 0) ? 'PUT' : 'POST';
|
||||
$step = $method === 'PUT' ? 'put_transaction' : 'post_transaction';
|
||||
echo json_encode(array(
|
||||
'status' => 'debug',
|
||||
'message' => 'Debug outbound AIS requests only, nothing sent',
|
||||
'source_endpoint' => 'transactionv4/post_transaction_daily_by_date',
|
||||
'transactions' => array(
|
||||
array(
|
||||
'RegID' => $row['RegID'],
|
||||
'step' => $step,
|
||||
'target_method' => $method,
|
||||
'target_url' => $url,
|
||||
'target_headers' => array_merge(array('Content-Type: application/json'), $headers),
|
||||
'target_payload' => $raw_data[$key],
|
||||
'curl_command' => $this->build_curl_command($url, $raw_data[$key], $headers, $method)
|
||||
)
|
||||
)
|
||||
));
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($get_transaction && count($get_transaction) > 0) {
|
||||
$result = $this->put_request($url, $raw_data[$key], $headers);
|
||||
} else {
|
||||
@@ -1085,7 +1139,7 @@ class Transactionv4 extends MY_Controller
|
||||
}
|
||||
$raw_data = $qry->result_array();
|
||||
if (count($raw_data) == 0) {
|
||||
$errors = array('status' => 'error', 'message' => 'Data tidak ditemukan');
|
||||
$errors = array('status' => 'error', 'message' => 'Data reguler tidak ditemukan');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
@@ -1736,9 +1790,20 @@ class Transactionv4 extends MY_Controller
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$labnum = $prm['labnumber'];
|
||||
$debugPayload = $this->should_debug_ais_payload();
|
||||
$dt_config = $this->get_config();
|
||||
$baseUrl = $dt_config['AisConfigBaseUrl'];
|
||||
$authUrl = $baseUrl . '/api/auth/auth.php';
|
||||
$authHeaders = array(
|
||||
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
|
||||
);
|
||||
$authPayload = array(
|
||||
'username' => $dt_config['AisConfigUsername'],
|
||||
'password' => $dt_config['AisConfigPassword']
|
||||
);
|
||||
|
||||
// Auth Login
|
||||
$login = $this->post_auth();
|
||||
$login = $debugPayload ? array('success' => true) : $this->post_auth();
|
||||
|
||||
if (!$login['success']) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($login)), 555);
|
||||
@@ -1746,9 +1811,6 @@ class Transactionv4 extends MY_Controller
|
||||
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(
|
||||
@@ -1881,7 +1943,7 @@ class Transactionv4 extends MY_Controller
|
||||
$raw_data = $qry->result_array();
|
||||
if (count($raw_data) == 0) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderheader select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
$errors = array('status' => 'error', 'message' => 'Data tidak ditemukan');
|
||||
$errors = array('status' => 'error', 'message' => 'Data reguler tidak ditemukan');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
@@ -2149,6 +2211,24 @@ class Transactionv4 extends MY_Controller
|
||||
$raw_data[$key]['PaketDispenser'] = null;
|
||||
$errors = [];
|
||||
//exit;
|
||||
if ($debugPayload) {
|
||||
echo json_encode(array(
|
||||
'status' => 'debug',
|
||||
'message' => 'Debug outbound AIS requests only, nothing sent',
|
||||
'source_endpoint' => 'transactionv4/post_transaction_by_labnumber',
|
||||
'debug_steps' => array(
|
||||
array(
|
||||
'step' => 'post_transaction',
|
||||
'target_method' => 'POST',
|
||||
'target_url' => $url,
|
||||
'target_headers' => array_merge(array('Content-Type: application/json'), $headers),
|
||||
'target_payload' => $raw_data[$key],
|
||||
'curl_command' => $this->build_curl_command($url, $raw_data[$key], $headers, 'POST')
|
||||
)
|
||||
)
|
||||
));
|
||||
exit;
|
||||
}
|
||||
$result = $this->post_request($url, $raw_data[$key], $headers);
|
||||
|
||||
|
||||
@@ -2238,17 +2318,25 @@ class Transactionv4 extends MY_Controller
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$labnum = $prm['labnumber'];
|
||||
$debugPayload = $this->should_debug_ais_payload();
|
||||
$dt_config = $this->get_config();
|
||||
$baseUrl = $dt_config['AisConfigBaseUrl'];
|
||||
$authUrl = $baseUrl . '/api/auth/auth.php';
|
||||
$authHeaders = array(
|
||||
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
|
||||
);
|
||||
$authPayload = array(
|
||||
'username' => $dt_config['AisConfigUsername'],
|
||||
'password' => $dt_config['AisConfigPassword']
|
||||
);
|
||||
// Auth Login
|
||||
$login = $this->post_auth();
|
||||
$login = $debugPayload ? array('success' => true) : $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(
|
||||
@@ -2378,7 +2466,7 @@ class Transactionv4 extends MY_Controller
|
||||
$raw_data = $qry->result_array();
|
||||
if (count($raw_data) == 0) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderheader select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
$errors = array('status' => 'error', 'message' => 'Data tidak ditemukan');
|
||||
$errors = array('status' => 'error', 'message' => 'Data reguler tidak ditemukan');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
@@ -3138,7 +3226,25 @@ class Transactionv4 extends MY_Controller
|
||||
|
||||
//echo json_encode($raw_data[$key]);
|
||||
//exit;
|
||||
$result = $this->post_request($url, $raw_data[$key], $headers);
|
||||
if ($debugPayload) {
|
||||
echo json_encode(array(
|
||||
'status' => 'debug',
|
||||
'message' => 'Debug outbound AIS requests only, nothing sent',
|
||||
'source_endpoint' => 'transactionv4/re_post_transaction_by_labnumber',
|
||||
'debug_steps' => array(
|
||||
array(
|
||||
'step' => 'put_transaction',
|
||||
'target_method' => 'PUT',
|
||||
'target_url' => $url,
|
||||
'target_headers' => array_merge(array('Content-Type: application/json'), $headers),
|
||||
'target_payload' => $raw_data[$key],
|
||||
'curl_command' => $this->build_curl_command($url, $raw_data[$key], $headers, 'PUT')
|
||||
)
|
||||
)
|
||||
));
|
||||
exit;
|
||||
}
|
||||
$result = $this->put_request($url, $raw_data[$key], $headers);
|
||||
|
||||
|
||||
if ($result['error'] != null) {
|
||||
@@ -3603,6 +3709,32 @@ class Transactionv4 extends MY_Controller
|
||||
'Authorization: Bearer ' . $dt_config['AisConfigAuthToken']
|
||||
);
|
||||
|
||||
$authUrl = $baseUrl . '/api/auth/auth.php';
|
||||
$authHeaders = array(
|
||||
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
|
||||
);
|
||||
$authPayload = array(
|
||||
'username' => $dt_config['AisConfigUsername'],
|
||||
'password' => $dt_config['AisConfigPassword']
|
||||
);
|
||||
if ($this->should_debug_ais_payload()) {
|
||||
echo json_encode(array(
|
||||
'status' => 'debug',
|
||||
'message' => 'Debug outbound AIS requests only, nothing sent',
|
||||
'source_endpoint' => 'transactionv4/delete_transaction_by_labnumber',
|
||||
'debug_steps' => array(
|
||||
array(
|
||||
'step' => 'delete_transaction',
|
||||
'target_method' => 'DELETE',
|
||||
'target_url' => $baseUrl . '/api/transaction_full/transaksi.php',
|
||||
'target_headers' => array_merge(array('Content-Type: application/json'), $headers),
|
||||
'target_payload' => array('RegID' => $labnumber),
|
||||
'curl_command' => $this->build_curl_command($baseUrl . '/api/transaction_full/transaksi.php', array('RegID' => $labnumber), $headers, 'DELETE')
|
||||
)
|
||||
)
|
||||
));
|
||||
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);
|
||||
@@ -3612,8 +3744,6 @@ class Transactionv4 extends MY_Controller
|
||||
}
|
||||
|
||||
$url = $baseUrl . '/api/transaction_full/transaksi.php';
|
||||
|
||||
|
||||
$result = $this->delete_request($url, ['RegID' => $labnumber], $headers);
|
||||
|
||||
//response {"success":true}
|
||||
@@ -3671,6 +3801,7 @@ class Transactionv4 extends MY_Controller
|
||||
b.M_BranchCode AS branch_code,
|
||||
b.M_BranchName AS branch_name,
|
||||
b.M_BranchCodeLab AS branch_code_lab,
|
||||
b.M_BranchIsSteemCell AS is_stemcell,
|
||||
oh.T_OrderHeaderTotal AS total,
|
||||
at.Ais_TransactionStatus AS Ais_TransactionStatus,
|
||||
c.CorporateID AS corporate_id,
|
||||
@@ -3697,6 +3828,7 @@ class Transactionv4 extends MY_Controller
|
||||
$corporate_id = $this->input->get('corporate_id');
|
||||
$lab_number = $this->input->get('lab_number');
|
||||
$patient_name = $this->input->get('patient_name');
|
||||
$is_stemcell = $this->input->get('is_stemcell');
|
||||
|
||||
// Pagination
|
||||
$page = $this->input->get('page') ? intval($this->input->get('page')) : 1;
|
||||
@@ -3733,6 +3865,11 @@ class Transactionv4 extends MY_Controller
|
||||
$params[] = "%$patient_name%";
|
||||
}
|
||||
|
||||
if ($is_stemcell !== null && $is_stemcell !== '' && $is_stemcell !== 'A') {
|
||||
$where_clauses[] = "b.M_BranchIsSteemCell = ?";
|
||||
$params[] = $is_stemcell;
|
||||
}
|
||||
|
||||
// Build WHERE
|
||||
$where_sql = "";
|
||||
if (!empty($where_clauses)) {
|
||||
@@ -3743,6 +3880,7 @@ class Transactionv4 extends MY_Controller
|
||||
$count_sql = "SELECT COUNT(DISTINCT oh.T_OrderHeaderID) as total
|
||||
FROM t_orderheader oh
|
||||
JOIN m_patient p ON p.M_PatientID = oh.T_OrderHeaderM_PatientID
|
||||
JOIN m_branch b ON b.M_BranchID = oh.T_OrderHeaderM_BranchID
|
||||
LEFT JOIN " . $this->db_log->database . ".ais_transaction at
|
||||
ON at.Ais_TransactionOrderHeaderLabNumber = oh.T_OrderHeaderLabNumber
|
||||
LEFT JOIN corporate c ON c.CorporateID = oh.T_OrderHeaderCorporateID
|
||||
|
||||
@@ -3,6 +3,7 @@ class Transactionv5 extends MY_Controller
|
||||
{
|
||||
|
||||
var $db_onedev;
|
||||
private $force_debug_ais_payload = false;
|
||||
public function index()
|
||||
{
|
||||
echo "Transaction API";
|
||||
@@ -63,6 +64,26 @@ class Transactionv5 extends MY_Controller
|
||||
return implode(' ', $parts);
|
||||
}
|
||||
|
||||
private function should_debug_ais_payload()
|
||||
{
|
||||
return $this->force_debug_ais_payload === true;
|
||||
}
|
||||
|
||||
private function debug_ais_payload_response($sourceEndpoint, $method, $url, $headers, $payload)
|
||||
{
|
||||
$this->sys_ok(array(
|
||||
'status' => 'debug',
|
||||
'message' => 'Debug payload only, request not sent to AIS',
|
||||
'source_endpoint' => $sourceEndpoint,
|
||||
'target_method' => $method,
|
||||
'target_url' => $url,
|
||||
'target_headers' => array_merge(array('Content-Type: application/json'), $headers),
|
||||
'target_payload' => $payload,
|
||||
'curl_command' => $this->build_curl_command($url, $payload, $headers, $method)
|
||||
));
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic POST request function
|
||||
* @param string $url API endpoint URL
|
||||
@@ -313,6 +334,16 @@ class Transactionv5 extends MY_Controller
|
||||
public function post_auth()
|
||||
{
|
||||
$dt_config = $this->get_config();
|
||||
if ($this->should_debug_ais_payload()) {
|
||||
return array(
|
||||
'success' => true,
|
||||
'debug' => true,
|
||||
'message' => 'Debug payload only, auth request not sent to AIS',
|
||||
'data' => array(
|
||||
'token' => $dt_config['AisConfigAuthToken'] ?? null
|
||||
)
|
||||
);
|
||||
}
|
||||
$baseUrl = $dt_config['AisConfigBaseUrl'];
|
||||
$url = $baseUrl . '/api/auth/auth.php';
|
||||
$headers = array(
|
||||
@@ -378,8 +409,9 @@ class Transactionv5 extends MY_Controller
|
||||
function post_transaction_daily_by_date($min_date = null, $max_date = null)
|
||||
{
|
||||
//echo "post_transaction_daily_by_date";
|
||||
$debugPayload = $this->should_debug_ais_payload();
|
||||
// Auth Login
|
||||
$login = $this->post_auth();
|
||||
$login = $debugPayload ? array('success' => true) : $this->post_auth();
|
||||
//echo json_encode($login);
|
||||
//exit;
|
||||
|
||||
@@ -542,7 +574,7 @@ class Transactionv5 extends MY_Controller
|
||||
}
|
||||
$raw_data = $qry->result_array();
|
||||
if (count($raw_data) == 0) {
|
||||
$errors = array('status' => 'error', 'message' => 'Data tidak ditemukan', 'query' => $this->db_onedev->last_query());
|
||||
$errors = array('status' => 'error', 'message' => 'Data stem cell tidak ditemukan', 'query' => $this->db_onedev->last_query());
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
@@ -821,6 +853,28 @@ class Transactionv5 extends MY_Controller
|
||||
$get_transaction = $this->get_transaction_by_labnumber($row['RegID']);
|
||||
// echo json_encode($get_transaction);
|
||||
|
||||
if ($debugPayload) {
|
||||
$method = ($get_transaction && count($get_transaction) > 0) ? 'PUT' : 'POST';
|
||||
$step = $method === 'PUT' ? 'put_transaction' : 'post_transaction';
|
||||
echo json_encode(array(
|
||||
'status' => 'debug',
|
||||
'message' => 'Debug outbound AIS requests only, nothing sent',
|
||||
'source_endpoint' => 'transactionv5/post_transaction_daily_by_date',
|
||||
'transactions' => array(
|
||||
array(
|
||||
'RegID' => $row['RegID'],
|
||||
'step' => $step,
|
||||
'target_method' => $method,
|
||||
'target_url' => $url,
|
||||
'target_headers' => array_merge(array('Content-Type: application/json'), $headers),
|
||||
'target_payload' => $raw_data[$key],
|
||||
'curl_command' => $this->build_curl_command($url, $raw_data[$key], $headers, $method)
|
||||
)
|
||||
)
|
||||
));
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($get_transaction && count($get_transaction) > 0) {
|
||||
$result = $this->put_request($url, $raw_data[$key], $headers);
|
||||
} else {
|
||||
@@ -1085,7 +1139,7 @@ class Transactionv5 extends MY_Controller
|
||||
}
|
||||
$raw_data = $qry->result_array();
|
||||
if (count($raw_data) == 0) {
|
||||
$errors = array('status' => 'error', 'message' => 'Data tidak ditemukan');
|
||||
$errors = array('status' => 'error', 'message' => 'Data stem cell tidak ditemukan');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
@@ -1736,9 +1790,20 @@ class Transactionv5 extends MY_Controller
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$labnum = $prm['labnumber'];
|
||||
$debugPayload = $this->should_debug_ais_payload();
|
||||
$dt_config = $this->get_config();
|
||||
$baseUrl = $dt_config['AisConfigBaseUrl'];
|
||||
$authUrl = $baseUrl . '/api/auth/auth.php';
|
||||
$authHeaders = array(
|
||||
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
|
||||
);
|
||||
$authPayload = array(
|
||||
'username' => $dt_config['AisConfigUsername'],
|
||||
'password' => $dt_config['AisConfigPassword']
|
||||
);
|
||||
|
||||
// Auth Login
|
||||
$login = $this->post_auth();
|
||||
$login = $debugPayload ? array('success' => true) : $this->post_auth();
|
||||
|
||||
if (!$login['success']) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 'failed auth', 'query' => '', 'json' => json_encode($login)), 555);
|
||||
@@ -1746,9 +1811,6 @@ class Transactionv5 extends MY_Controller
|
||||
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(
|
||||
@@ -1881,7 +1943,7 @@ class Transactionv5 extends MY_Controller
|
||||
$raw_data = $qry->result_array();
|
||||
if (count($raw_data) == 0) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderheader select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
$errors = array('status' => 'error', 'message' => 'Data tidak ditemukan');
|
||||
$errors = array('status' => 'error', 'message' => 'Data stem cell tidak ditemukan');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
@@ -2149,6 +2211,24 @@ class Transactionv5 extends MY_Controller
|
||||
$raw_data[$key]['PaketDispenser'] = null;
|
||||
$errors = [];
|
||||
//exit;
|
||||
if ($debugPayload) {
|
||||
echo json_encode(array(
|
||||
'status' => 'debug',
|
||||
'message' => 'Debug outbound AIS requests only, nothing sent',
|
||||
'source_endpoint' => 'transactionv5/post_transaction_by_labnumber',
|
||||
'debug_steps' => array(
|
||||
array(
|
||||
'step' => 'post_transaction',
|
||||
'target_method' => 'POST',
|
||||
'target_url' => $url,
|
||||
'target_headers' => array_merge(array('Content-Type: application/json'), $headers),
|
||||
'target_payload' => $raw_data[$key],
|
||||
'curl_command' => $this->build_curl_command($url, $raw_data[$key], $headers, 'POST')
|
||||
)
|
||||
)
|
||||
));
|
||||
exit;
|
||||
}
|
||||
$result = $this->post_request($url, $raw_data[$key], $headers);
|
||||
|
||||
|
||||
@@ -2238,17 +2318,28 @@ class Transactionv5 extends MY_Controller
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$labnum = $prm['labnumber'];
|
||||
// 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
|
||||
$debugPayload = true;
|
||||
$dt_config = $this->get_config();
|
||||
$baseUrl = $dt_config['AisConfigBaseUrl'];
|
||||
$authUrl = $baseUrl . '/api/auth/auth.php';
|
||||
$authHeaders = array(
|
||||
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
|
||||
);
|
||||
$authPayload = array(
|
||||
'username' => $dt_config['AisConfigUsername'],
|
||||
'password' => $dt_config['AisConfigPassword']
|
||||
);
|
||||
// Auth Login
|
||||
if (!$debugPayload) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
$url = $baseUrl . '/api/transaction_full/transaksi.php';
|
||||
|
||||
$headers = array(
|
||||
@@ -2378,7 +2469,7 @@ class Transactionv5 extends MY_Controller
|
||||
$raw_data = $qry->result_array();
|
||||
if (count($raw_data) == 0) {
|
||||
$this->error_log(array('fn_name' => 'post_transaction', 'message' => 't_orderheader select', 'query' => $this->db_onedev->last_query(), 'json' => ''), 999);
|
||||
$errors = array('status' => 'error', 'message' => 'Data tidak ditemukan');
|
||||
$errors = array('status' => 'error', 'message' => 'Data stem cell tidak ditemukan');
|
||||
echo json_encode($errors);
|
||||
exit;
|
||||
}
|
||||
@@ -2647,7 +2738,25 @@ class Transactionv5 extends MY_Controller
|
||||
$errors = [];
|
||||
|
||||
//echo json_encode($raw_data[$key]);
|
||||
//exit;
|
||||
//exit;
|
||||
if ($debugPayload) {
|
||||
echo json_encode(array(
|
||||
'status' => 'debug',
|
||||
'message' => 'Debug outbound AIS requests only, nothing sent',
|
||||
'source_endpoint' => 'transactionv5/re_post_transaction_by_labnumber',
|
||||
'debug_steps' => array(
|
||||
array(
|
||||
'step' => 'put_transaction',
|
||||
'target_method' => 'PUT',
|
||||
'target_url' => $url,
|
||||
'target_headers' => array_merge(array('Content-Type: application/json'), $headers),
|
||||
'target_payload' => $raw_data[$key],
|
||||
'curl_command' => $this->build_curl_command($url, $raw_data[$key], $headers, 'PUT')
|
||||
)
|
||||
)
|
||||
));
|
||||
exit;
|
||||
}
|
||||
$result = $this->put_request($url, $raw_data[$key], $headers);
|
||||
|
||||
|
||||
@@ -3138,6 +3247,32 @@ class Transactionv5 extends MY_Controller
|
||||
|
||||
//echo json_encode($raw_data[$key]);
|
||||
//exit;
|
||||
if ($debugPayload) {
|
||||
echo json_encode(array(
|
||||
'status' => 'debug',
|
||||
'message' => 'Debug outbound AIS requests only, nothing sent',
|
||||
'source_endpoint' => 'transactionv5/re_post_transaction_by_labnumber',
|
||||
'debug_steps' => array(
|
||||
array(
|
||||
'step' => 'auth_login',
|
||||
'target_method' => 'POST',
|
||||
'target_url' => $authUrl,
|
||||
'target_headers' => array_merge(array('Content-Type: application/json'), $authHeaders),
|
||||
'target_payload' => $authPayload,
|
||||
'curl_command' => $this->build_curl_command($authUrl, $authPayload, $authHeaders, 'POST')
|
||||
),
|
||||
array(
|
||||
'step' => 'post_transaction',
|
||||
'target_method' => 'POST',
|
||||
'target_url' => $url,
|
||||
'target_headers' => array_merge(array('Content-Type: application/json'), $headers),
|
||||
'target_payload' => $raw_data[$key],
|
||||
'curl_command' => $this->build_curl_command($url, $raw_data[$key], $headers, 'POST')
|
||||
)
|
||||
)
|
||||
));
|
||||
exit;
|
||||
}
|
||||
$result = $this->post_request($url, $raw_data[$key], $headers);
|
||||
|
||||
|
||||
@@ -3603,6 +3738,32 @@ class Transactionv5 extends MY_Controller
|
||||
'Authorization: Bearer ' . $dt_config['AisConfigAuthToken']
|
||||
);
|
||||
|
||||
$authUrl = $baseUrl . '/api/auth/auth.php';
|
||||
$authHeaders = array(
|
||||
'Header-Token: ' . $dt_config['AisConfigHeaderToken']
|
||||
);
|
||||
$authPayload = array(
|
||||
'username' => $dt_config['AisConfigUsername'],
|
||||
'password' => $dt_config['AisConfigPassword']
|
||||
);
|
||||
if ($this->should_debug_ais_payload()) {
|
||||
echo json_encode(array(
|
||||
'status' => 'debug',
|
||||
'message' => 'Debug outbound AIS requests only, nothing sent',
|
||||
'source_endpoint' => 'transactionv5/delete_transaction_by_labnumber',
|
||||
'debug_steps' => array(
|
||||
array(
|
||||
'step' => 'delete_transaction',
|
||||
'target_method' => 'DELETE',
|
||||
'target_url' => $baseUrl . '/api/transaction_full/transaksi.php',
|
||||
'target_headers' => array_merge(array('Content-Type: application/json'), $headers),
|
||||
'target_payload' => array('RegID' => $labnumber),
|
||||
'curl_command' => $this->build_curl_command($baseUrl . '/api/transaction_full/transaksi.php', array('RegID' => $labnumber), $headers, 'DELETE')
|
||||
)
|
||||
)
|
||||
));
|
||||
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);
|
||||
@@ -3612,8 +3773,6 @@ class Transactionv5 extends MY_Controller
|
||||
}
|
||||
|
||||
$url = $baseUrl . '/api/transaction_full/transaksi.php';
|
||||
|
||||
|
||||
$result = $this->delete_request($url, ['RegID' => $labnumber], $headers);
|
||||
|
||||
//response {"success":true}
|
||||
|
||||
Reference in New Issue
Block a user