237 lines
9.1 KiB
PHP
237 lines
9.1 KiB
PHP
<?php
|
|
class Apitat extends MY_Controller
|
|
{
|
|
var $db;
|
|
var $load;
|
|
var $IP_ADDRESS = "192.168.250.73";
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
function index()
|
|
{
|
|
// $cek = $this->db->query("select database() as current_db")->result();
|
|
// print_r($cek);
|
|
echo "API TAT";
|
|
}
|
|
|
|
function get_tat($date = '')
|
|
{
|
|
if ($date == '') {
|
|
$date = date('Y-m-d');
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
|
|
$sql = "SELECT M_BranchID, M_BranchCode
|
|
FROM m_branch
|
|
WHERE M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'";
|
|
$qry = $this->db->query($sql);
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
} else {
|
|
$this->db->trans_rollback();
|
|
$this->sys_error_db("select m_branch", $this->db);
|
|
exit;
|
|
}
|
|
|
|
foreach ($rows as $key => $value) {
|
|
$M_BranchID = $value['M_BranchID'];
|
|
$M_BranchCode = $value['M_BranchCode'];
|
|
}
|
|
|
|
$sql_tat_v2 = "SELECT SsTatV2ID, SsTatV2Date, SsTatV2Month,
|
|
SsTatV2FoTargetEntry, SsTatV2FoVerif, SsTatV2FoTotalData,
|
|
SsTatV2FoPctFo, SsTatV2FoPctVerif, SsTatV2SamplingData,
|
|
SsTatV2SamplingHasil, SsTatV2SamplingPct, SsTatV2VerifData,
|
|
SsTatV2VerifHasil, SsTatV2VerifPct, SsTatV2PengolahanData,
|
|
SsTatV2PengolahanHasil, SsTatV2PengolahanPct, SsTatV2ValidasiData,
|
|
SsTatV2ValidasiHasil, SsTatV2ValidasiPct, SsTatV2AdmLabData,
|
|
SsTatV2AdmLabHasil, SsTatV2AdmLabPct, SsTatV2FullLabData,
|
|
SsTatV2FullLabHasil, SsTatV2FullLabPct
|
|
FROM ss_tat_v2 WHERE (date(SsTatV2Date) = ?)";
|
|
$qry_tat_v2 = $this->db->query($sql_tat_v2, array($date));
|
|
if ($qry_tat_v2) {
|
|
$rows_tat_v2 = $qry_tat_v2->result_array();
|
|
} else {
|
|
$this->db->trans_rollback();
|
|
$this->sys_error_db("select ss_tat_v2", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$sql_tat_v2b = "SELECT SsTatV2bID,
|
|
SsTatV2bDate,
|
|
SsTatV2bNat_GroupID,
|
|
SsTatV2bT_SampleStationID,
|
|
SsTatV2bT_SampleStationName,
|
|
SsTatV2bTungguData,
|
|
SsTatV2bTunggu,
|
|
SsTatV2bTungguPct
|
|
FROM ss_tat_v2b WHERE (date(SsTatV2bDate) = ?)";
|
|
$qry_tat_v2b = $this->db->query($sql_tat_v2b, array($date));
|
|
if ($qry_tat_v2b) {
|
|
$rows_tat_v2b = $qry_tat_v2b->result_array();
|
|
} else {
|
|
$this->db->trans_rollback();
|
|
$this->sys_error_db("select ss_tat_v2b", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$sql_tat_v2b_n = "SELECT SsTatV2bID,
|
|
SsTatV2bDate,
|
|
SsTatV2bNat_GroupID,
|
|
SsTatV2bT_SampleStationID,
|
|
SsTatV2bT_SampleStationName,
|
|
SsTatV2bTungguData,
|
|
SsTatV2bTunggu,
|
|
SsTatV2bTungguPct
|
|
FROM ss_tat_v2b_n WHERE (date(SsTatV2bDate) = ?)";
|
|
$qry_tat_v2b_n = $this->db->query($sql_tat_v2b_n, array($date));
|
|
if ($qry_tat_v2b_n) {
|
|
$rows_tat_v2b_n = $qry_tat_v2b_n->result_array();
|
|
} else {
|
|
$this->db->trans_rollback();
|
|
$this->sys_error_db("select ss_tat_v2b_n", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$sql_tat_v2c = "SELECT SsTatV2cID,
|
|
SsTatV2cDate,
|
|
SsTatV2cNat_SubgroupID,
|
|
SsTatV2cNat_SubgroupName,
|
|
SsTatV2cVerifikasiData,
|
|
SsTatV2cVerifikasi,
|
|
SsTatV2cVerifikasiPct
|
|
FROM ss_tat_v2c WHERE (date(SsTatV2cDate) = ?)";
|
|
$qry_tat_v2c = $this->db->query($sql_tat_v2c, array($date));
|
|
if ($qry_tat_v2c) {
|
|
$rows_tat_v2c = $qry_tat_v2c->result_array();
|
|
} else {
|
|
$this->db->trans_rollback();
|
|
$this->sys_error_db("select ss_tat_v2c", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$sql_tat_v2c_n = "SELECT SsTatV2cID,
|
|
SsTatV2cDate,
|
|
SsTatV2cNat_SubgroupID,
|
|
SsTatV2cNat_SubgroupName,
|
|
SsTatV2cVerifikasiData,
|
|
SsTatV2cVerifikasi,
|
|
SsTatV2cVerifikasiPct
|
|
FROM ss_tat_v2c_n WHERE (date(SsTatV2cDate) = ?)";
|
|
$qry_tat_v2c_n = $this->db->query($sql_tat_v2c_n, array($date));
|
|
if ($qry_tat_v2c_n) {
|
|
$rows_tat_v2c_n = $qry_tat_v2c_n->result_array();
|
|
} else {
|
|
$this->db->trans_rollback();
|
|
$this->sys_error_db("select ss_tat_v2c_n", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$sql_tat_v2_n = "SELECT SsTatV2ID, SsTatV2Date,
|
|
SsTatV2Month, SsTatV2FoTargetEntry, SsTatV2FoVerif,
|
|
SsTatV2FoTotalData, SsTatV2FoPctFo, SsTatV2FoPctVerif,
|
|
SsTatV2SamplingData, SsTatV2SamplingHasil, SsTatV2SamplingPct,
|
|
SsTatV2VerifData, SsTatV2VerifHasil, SsTatV2VerifPct,
|
|
SsTatV2PengolahanData, SsTatV2PengolahanHasil,
|
|
SsTatV2PengolahanPct, SsTatV2ValidasiData, SsTatV2ValidasiHasil,
|
|
SsTatV2ValidasiPct, SsTatV2AdmLabData, SsTatV2AdmLabHasil,
|
|
SsTatV2AdmLabPct, SsTatV2FullLabData, SsTatV2FullLabHasil,
|
|
SsTatV2FullLabPct
|
|
FROM ss_tat_v2_n WHERE (date(SsTatV2Date) = ?)";
|
|
$qry_tat_v2_n = $this->db->query($sql_tat_v2_n, array($date));
|
|
if ($qry_tat_v2_n) {
|
|
$rows_tat_v2_n = $qry_tat_v2_n->result_array();
|
|
} else {
|
|
$this->db->trans_rollback();
|
|
$this->sys_error_db("select ss_tat_v2_n", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$sql_tat_v2_nonlab = "SELECT SsTatV2NonLabID,
|
|
SsTatV2NonLabDate, SsTatV2NonLabNat_GroupID,
|
|
SsTatV2NonLabNat_GroupName, SsTatV2NonLabHandlingData,
|
|
SsTatV2NonLabHandling, SsTatV2NonLabHandlingPct,
|
|
SsTatV2NonLabVerifikasiData, SsTatV2NonLabVerifikasi,
|
|
SsTatV2NonLabVerifikasiPct, SsTatV2NonLabHandlingImageData,
|
|
SsTatV2NonLabHandlingImage, SsTatV2NonLabHandlingImagePct,
|
|
SsTatV2NonLabValidasiData, SsTatV2NonLabValidasi,
|
|
SsTatV2NonLabValidasiPct, SsTatV2NonLabTerimaFoData,
|
|
SsTatV2NonLabTerimaFo, SsTatV2NonLabTerimaFoPct
|
|
FROM ss_tat_v2_nonlab WHERE (date(SsTatV2NonLabDate) = ?)";
|
|
$qry_tat_v2_nonlab = $this->db->query($sql_tat_v2_nonlab, array($date));
|
|
if ($qry_tat_v2_nonlab) {
|
|
$rows_tat_v2_nonlab = $qry_tat_v2_nonlab->result_array();
|
|
} else {
|
|
$this->db->trans_rollback();
|
|
$this->sys_error_db("select ss_tat_v2_nonlab", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$sql_tat_v2_nonlab_n = "SELECT SsTatV2NonLabID,
|
|
SsTatV2NonLabDate, SsTatV2NonLabNat_GroupID,
|
|
SsTatV2NonLabNat_GroupName, SsTatV2NonLabHandlingData,
|
|
SsTatV2NonLabHandling, SsTatV2NonLabHandlingPct,
|
|
SsTatV2NonLabVerifikasiData, SsTatV2NonLabVerifikasi,
|
|
SsTatV2NonLabVerifikasiPct, SsTatV2NonLabHandlingImageData,
|
|
SsTatV2NonLabHandlingImage, SsTatV2NonLabHandlingImagePct,
|
|
SsTatV2NonLabValidasiData, SsTatV2NonLabValidasi,
|
|
SsTatV2NonLabValidasiPct, SsTatV2NonLabTerimaFoData,
|
|
SsTatV2NonLabTerimaFo, SsTatV2NonLabTerimaFoPct
|
|
FROM ss_tat_v2_nonlab_n WHERE (date(SsTatV2NonLabDate) = ?)";
|
|
$qry_tat_v2_nonlab_n = $this->db->query($sql_tat_v2_nonlab_n, array($date));
|
|
if ($qry_tat_v2_nonlab_n) {
|
|
$rows_tat_v2_nonlab_n = $qry_tat_v2_nonlab_n->result_array();
|
|
} else {
|
|
$this->db->trans_rollback();
|
|
$this->sys_error_db("select ss_tat_v2_nonlab_n", $this->db);
|
|
exit;
|
|
}
|
|
|
|
$data = array(
|
|
"M_BranchID" => $M_BranchID,
|
|
"M_BranchCode" => $M_BranchCode,
|
|
"ss_tat_v2" => $rows_tat_v2,
|
|
"ss_tat_v2b" => $rows_tat_v2b,
|
|
"ss_tat_v2b_n" => $rows_tat_v2b_n,
|
|
"ss_tat_v2c" => $rows_tat_v2c,
|
|
"ss_tat_v2c_n" => $rows_tat_v2c_n,
|
|
"ss_tat_v2_n" => $rows_tat_v2_n,
|
|
"ss_tat_v2_nonlab" => $rows_tat_v2_nonlab,
|
|
"ss_tat_v2_nonlab_n" => $rows_tat_v2_nonlab_n
|
|
);
|
|
$json = json_encode($data);
|
|
return $json;
|
|
}
|
|
|
|
function r_upload_tat($date)
|
|
{
|
|
$jsondata = $this->get_tat($date);
|
|
$data = json_decode($jsondata, true);
|
|
$uploaddata = json_encode($data);
|
|
|
|
$url = "http://$this->IP_ADDRESS/one-api/one-dash/r_api_tat/upload";
|
|
|
|
$ch = curl_init();
|
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $uploaddata);
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
|
curl_setopt(
|
|
$ch,
|
|
CURLOPT_HTTPHEADER,
|
|
array(
|
|
'Content-Type: application/json',
|
|
'Content-Length: ' . strlen($uploaddata)
|
|
)
|
|
);
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
$result = curl_exec($ch);
|
|
curl_close($ch);
|
|
echo $result;
|
|
}
|
|
}
|