Batch 6f: application controller leftovers
This commit is contained in:
6
application/.htaccess
Executable file
6
application/.htaccess
Executable file
@@ -0,0 +1,6 @@
|
||||
<IfModule authz_core_module>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
<IfModule !authz_core_module>
|
||||
Deny from all
|
||||
</IfModule>
|
||||
BIN
application/controllers/Arial_Narrow.ttf
Normal file
BIN
application/controllers/Arial_Narrow.ttf
Normal file
Binary file not shown.
131
application/controllers/Auth_placeholder.php
Normal file
131
application/controllers/Auth_placeholder.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
class Auth_placeholder extends CI_Controller {
|
||||
var $SECRET_KEY = "--one_api-secret-2019-04-01";
|
||||
public function index()
|
||||
{
|
||||
echo "AUTH API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function corss() {
|
||||
global $_SERVER;
|
||||
if (isset($_SERVER["HTTP_ORIGIN"])) {
|
||||
header('Access-Control-Allow-Origin: ' . $_SERVER["HTTP_ORIGIN"]);
|
||||
} else {
|
||||
header('Access-Control-Allow-Origin: */*' );
|
||||
}
|
||||
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization');
|
||||
if ( isset($_SERVER["REQUEST_METHOD"]) && $_SERVER["REQUEST_METHOD"] == "OPTIONS") {
|
||||
http_response_code(200);
|
||||
echo json_encode("OK");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function menu() {
|
||||
$this->corss();
|
||||
$rst = [];
|
||||
$rst[] = [
|
||||
"privilege" => "Admin Lab",
|
||||
"menus" => [
|
||||
["title" => "Pasien", "path" => "/masterdata/pasien" ],
|
||||
["title" => "Pemeriksaan", "path" => "/masterdata/px" ],
|
||||
]
|
||||
];
|
||||
$rst[] = [
|
||||
"privilege" => "Keu",
|
||||
"menus" => [
|
||||
["title" => "Company", "path" => "/masterdata/company" ],
|
||||
["title" => "Agreement", "path" => "/masterdata/agreement" ],
|
||||
]
|
||||
];
|
||||
echo json_encode(["status" => "OK", "data" => $rst]);
|
||||
}
|
||||
function old_menu() {
|
||||
//for preflight
|
||||
$this->corss();
|
||||
$rst = [
|
||||
["id"=>1,"icon" => "SendIcon","label" => "Menu 01", "target" => "url:/other_module" , "level" => 1],
|
||||
["id"=>2,"icon" => "DrafsIcon","label" => "Menu 02", "target" => "", "level" => 1,
|
||||
"children" => [
|
||||
["id"=>3,"icon" => "DrafsIcon","label" => "Sub Menu 0201", "target" => "link:/def", "level" => 2,],
|
||||
["id"=>4,"icon" => "StarIcon","label" => "Sub Menu 0202", "target" => "link:/def", "level" => 2],
|
||||
["id"=>5,"icon" => "InboxIcon","label" => "Sub Menu 0203", "target" => "link:/def", "level" => 2],
|
||||
["id"=>6,"icon" => "","label" => "Sub Menu 0204", "target" => "link:/def", "level" => 2,
|
||||
"children" => [
|
||||
["id"=>7,"icon" => "DrafsIcon","label" => "Sub Menu 020401", "target" => "link:/def", "level" => 3],
|
||||
["id"=>8,"icon" => "StarIcon","label" => "Sub Menu 020402", "target" => "link:/def", "level" => 3],
|
||||
["id"=>9,"icon" => "InboxIcon","label" => "Sub Menu 020403", "target" => "link:/def", "level" => 3],
|
||||
["id"=>10,"icon" => "","label" => "Sub Menu 020404", "target" => "link:/def" , "level" => 3],
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
["id"=>11,"icon" => "InboxIcon","label" => "Menu 03", "target" => "url:/other_module", "level" => 1 ],
|
||||
["id"=>12,"icon" => "StarIcon","label" => "Menu 04", "target" => "url:/other_module", "level" => 1 ],
|
||||
["id"=>13,"icon" => "SendIcon","label" => "Menu 05", "target" => "url:/other_module" , "level" => 1],
|
||||
];
|
||||
echo json_encode(["status"=>"OK","records" => $rst ]);
|
||||
}
|
||||
function check_token() {
|
||||
$req_headers = $headers = array_change_key_case(getallheaders(), CASE_LOWER);
|
||||
$isLogin = false;
|
||||
$user = [];
|
||||
if (isset($req_headers["authorization"])) {
|
||||
//have bearer
|
||||
list($bearer, $token) = explode(" ", trim($req_headers["authorization"]));
|
||||
$user =JWT::decode($token,$this->SECRET_KEY);
|
||||
$isLogin = true;
|
||||
}
|
||||
return [$isLogin,$user];
|
||||
}
|
||||
function info() {
|
||||
list($isLogin,$user) = $this->check_token();
|
||||
echo json_encode(["isLogin" => $isLogin,"user" => $user]);
|
||||
}
|
||||
|
||||
function refresh_token () {
|
||||
list($isLogin,$user) = $this->check_token();
|
||||
if (! $isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
} else {
|
||||
$token_expire = date("Y-m-d H:i:s",strtotime("now + 5 minute"));
|
||||
$user["token_expire"] = $token_expire;
|
||||
$token = JWT::encode($user,$this->SECRET_KEY);
|
||||
$data = array(
|
||||
"status" => "OK",
|
||||
"user" => $user,
|
||||
"token" => $token,
|
||||
"token_expire" => $token_expire
|
||||
);
|
||||
echo json_encode($data);
|
||||
}
|
||||
}
|
||||
function login() {
|
||||
$this->corss();
|
||||
$prm = json_decode(file_get_contents("php://input"),true);
|
||||
if ($prm["username"] =="admin" && $prm["password"] == "123") {
|
||||
$token_expire = date("Y-m-d H:i:s",strtotime("now + 5 minute"));
|
||||
$user = ["name" => "The Admin" , "level" => "Admin", "expire" => $token_expire];
|
||||
$this->load->library("Jwt");
|
||||
$token = JWT::encode($user,$this->SECRET_KEY);
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"token" => $token,
|
||||
"token_expire" => $token_expire,
|
||||
"redirect" => "/xinfo",
|
||||
"user" => $user
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
echo json_encode(["status" => "ERR" , "message" => "Invalid username/password"]);
|
||||
}
|
||||
|
||||
function logout()
|
||||
{
|
||||
echo json_encode(["status" => "OK" , "message" => ""]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
92
application/controllers/Auth_placeholder_v2.php
Normal file
92
application/controllers/Auth_placeholder_v2.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
class Auth_placeholder_v2 extends CI_Controller {
|
||||
var $CHALENGE_KEY = "--njw-chalenge-321";
|
||||
var $TOKEN_KEY = "--njw-token-321";
|
||||
public function index()
|
||||
{
|
||||
echo "AUTH API V2";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library("Jwt");
|
||||
}
|
||||
function chalenge() {
|
||||
$this->corss();
|
||||
$param_chalenge = date("YmdHis");
|
||||
$ckey = JWT::encode($param_chalenge,$this->CHALENGE_KEY);
|
||||
echo json_encode(["status" => "OK", "chalenge" => $ckey]);
|
||||
}
|
||||
function get_param() {
|
||||
$sparam = file_get_contents("php://input");
|
||||
$jparam = json_decode($sparam,true);
|
||||
return $jparam;
|
||||
}
|
||||
function auth() {
|
||||
$param = $this->get_param();
|
||||
$username = $param["username"];
|
||||
$chalenge = $param["chalenge"];
|
||||
$password = $param["password"];
|
||||
$date = JWT::decode($chalenge,$this->CHALENGE_KEY);
|
||||
$xdate = date("YmdHis",strtotime("now - 1 minute"));
|
||||
$is_expired = $date < $xdate;
|
||||
echo "chalenge date : $date | last 1 minute $xdate => " . ( $is_expired ? " Valid " : "Expired");
|
||||
echo "\n\n";
|
||||
$x_pw = hash_hmac("sha512","admin123",$chalenge);
|
||||
echo "pw : $password | $x_pw => " . ( $password == $x_pw ? " OK " : " Not OK");
|
||||
}
|
||||
function corss() {
|
||||
global $_SERVER;
|
||||
if (isset($_SERVER["HTTP_ORIGIN"])) {
|
||||
header('Access-Control-Allow-Origin: ' . $_SERVER["HTTP_ORIGIN"]);
|
||||
} else {
|
||||
header('Access-Control-Allow-Origin: */*' );
|
||||
}
|
||||
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization');
|
||||
if ( isset($_SERVER["REQUEST_METHOD"]) && $_SERVER["REQUEST_METHOD"] == "OPTIONS") {
|
||||
http_response_code(200);
|
||||
echo json_encode("OK");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function check_token() {
|
||||
$req_headers = $headers = array_change_key_case(getallheaders(), CASE_LOWER);
|
||||
$isLogin = false;
|
||||
$user = [];
|
||||
if (isset($req_headers["authorization"])) {
|
||||
//have bearer
|
||||
list($bearer, $token) = explode(" ", trim($req_headers["authorization"]));
|
||||
$user =JWT::decode($token,$this->SECRET_KEY);
|
||||
$isLogin = true;
|
||||
}
|
||||
return [$isLogin,$user];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
var enc = new TextEncoder("utf-8");
|
||||
|
||||
window.crypto.subtle.importKey(
|
||||
"raw", // raw format of the key - should be Uint8Array
|
||||
enc.encode("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.IjIwMjIwNDExMDUxOTE1Ig.gn7rkM_UAluoChLQWxJ5ZSqp0mxpekK_5Ex18kEM1fI"),
|
||||
{ // algorithm details
|
||||
name: "HMAC",
|
||||
hash: {name: "SHA-512"}
|
||||
},
|
||||
false, // export = false
|
||||
["sign", "verify"] // what this key can do
|
||||
).then( key => {
|
||||
window.crypto.subtle.sign(
|
||||
"HMAC",
|
||||
key,
|
||||
enc.encode("admin123")
|
||||
).then(signature => {
|
||||
var b = new Uint8Array(signature);
|
||||
var str = Array.prototype.map.call(b, x => ('00'+x.toString(16)).slice(-2)).join("")
|
||||
console.log(str);
|
||||
});
|
||||
});
|
||||
|
||||
*/
|
||||
?>
|
||||
375
application/controllers/Diagnosticreport.php
Normal file
375
application/controllers/Diagnosticreport.php
Normal file
@@ -0,0 +1,375 @@
|
||||
<?php
|
||||
class Diagnosticreport extends MY_Controller{
|
||||
var $db;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('Satusehat');
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
echo "Satu Sehat Diagnostic Report";
|
||||
}
|
||||
|
||||
function getdiagnosticreport()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$orderheaderID = $prm['orderheaderID'];
|
||||
|
||||
//cek db one_health diagnostic report sudah ada atau belum
|
||||
|
||||
|
||||
|
||||
// get organization
|
||||
$sql = "SELECT organizationID
|
||||
FROM one_health.organization
|
||||
WHERE organizationIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql, []);
|
||||
$last_qry = $this->db->last_query();
|
||||
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
$organizationID = $qry->result_array()[0]['organizationID'];
|
||||
|
||||
|
||||
|
||||
$sql_data_diagnostic_report = "SELECT T_OrderHeaderID,T_OrderHeaderLabNumber,
|
||||
IFNULL(OHPatientMapIHSNumber,'') as OHPatientMapIHSNumber,
|
||||
IFNULL(OHDoctorMapIHSNumber,'') as doctor_ihsnumber,
|
||||
EncounterUUID, T_TestName,
|
||||
IFNULL(Nat_TestLoincCode,'') as code_loinc,
|
||||
IFNULL(Nat_TestLoincDisplay,'') as code_display,
|
||||
ServiceRequestUUID,
|
||||
ServiceRequestID
|
||||
FROM one_health.service_request
|
||||
JOIN t_orderheader ON ServiceRequestT_OrderHeaderID = ? AND
|
||||
ServiceRequestT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON M_PatientID = T_OrderHeaderM_PatientID
|
||||
JOIN t_orderdetail ON ServiceRequestT_OrderDetailID = T_OrderDetailID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
|
||||
LEFT JOIN nat_test_loinc ON Nat_TestLoincNat_TestID = T_TestNat_TestID
|
||||
LEFT JOIN one_health.oh_patient_map ON OHPatientMapM_PatientID = M_PatientID
|
||||
AND OHPatientMapIsActive = 'Y'
|
||||
LEFT JOIN one_health.oh_doctor_map ON OHDoctorMapM_DoctorID = T_OrderHeaderPjM_DoctorID
|
||||
LEFT JOIN one_health.encounter ON EncounterT_orderHeaderID = T_orderHeaderID
|
||||
AND EncounterIsActive= 'Y'
|
||||
WHERE
|
||||
ServiceRequestIsActive = 'Y'";
|
||||
|
||||
$qry_data_diagnostic_report = $this->db->query($sql_data_diagnostic_report,[$orderheaderID]);
|
||||
|
||||
if (!$qry_data_diagnostic_report) {
|
||||
$last_qry = $this->db->last_query();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
$ddr = $qry_data_diagnostic_report->result_array();
|
||||
$results = [];
|
||||
|
||||
foreach ($ddr as $k_sr => $rdr) {
|
||||
$sql = "SELECT *
|
||||
FROM one_health.diagnostic_report
|
||||
WHERE DiagnosticReportT_orderHeaderID = ?
|
||||
AND DiagnosticReportServiceRequestID = ?
|
||||
AND DiagnosticReportIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql, [
|
||||
$orderheaderID,
|
||||
$rdr['ServiceRequestID']
|
||||
]);
|
||||
|
||||
|
||||
$last_qry = $this->db->last_query();
|
||||
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
$exist_data = $qry->result_array();
|
||||
|
||||
if(count($exist_data) == 0){
|
||||
$diagnosticreport_uuid = $this->satusehat->gen_uuid();
|
||||
$result["fullUrl"] = "urn:uuid:".$diagnosticreport_uuid;
|
||||
$data_result['resourceType'] = "DiagnosticReport";
|
||||
$data_result['identifier'] = array(
|
||||
array(
|
||||
"system" => "http://sys-ids.kemkes.go.id/observation/".$organizationID,
|
||||
"value" => $rdr['T_OrderHeaderLabNumber']
|
||||
)
|
||||
);
|
||||
$data_result['status'] = "final";
|
||||
$data_result['category'] = array(
|
||||
array(
|
||||
"coding" => array(
|
||||
array(
|
||||
"system" => "http://terminology.hl7.org/CodeSystem/v2-0074",
|
||||
"code" => "CH",
|
||||
"display" => "Chemistry"
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$sql = "SELECT T_OrderDetailValDate
|
||||
FROM t_orderdetail
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $orderheaderID AND
|
||||
T_OrderDetailIsActive = 'Y' AND
|
||||
T_OrderDetailT_TestIsResult = 'Y'
|
||||
ORDER BY T_OrderDetailValDate ASC
|
||||
LIMIT 1";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if(!$query){
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error("error get t_orderdetail");
|
||||
exit;
|
||||
}
|
||||
|
||||
$data_validdate = $query->row()->T_OrderDetailValDate;
|
||||
$efectiveDate = $data_validdate;
|
||||
$issuedDate = $data_validdate;
|
||||
|
||||
$coding[] = [
|
||||
"system" => "http://loinc.org",
|
||||
"code" => $rdr['code_loinc'],
|
||||
"display" => $rdr['T_TestName']
|
||||
];
|
||||
|
||||
$data_result['code'] = array(
|
||||
"coding" => $coding
|
||||
);
|
||||
$data_result['subject'] = array(
|
||||
"reference" => "Patient/".$rdr['OHPatientMapIHSNumber']
|
||||
);
|
||||
$data_result['encounter'] = array(
|
||||
'reference' => "Encounter/".$rdr['EncounterUUID']
|
||||
);
|
||||
$data_result['effectiveDateTime'] = date('c', strtotime($efectiveDate));
|
||||
$data_result['issued'] = date('c', strtotime($issuedDate));
|
||||
$data_result['performer'] = array(
|
||||
array(
|
||||
'reference' => "Practitioner/".$rdr['doctor_ihsnumber']
|
||||
),
|
||||
array(
|
||||
'reference' => "Organization/".$organizationID
|
||||
)
|
||||
);
|
||||
|
||||
$sql = "SELECT IFNULL(OHStaffMapIhsNumber,'') as staff_ihsnumber
|
||||
FROM t_orderdetail
|
||||
JOIN m_user ON T_OrderDetailValUserID = M_UserID
|
||||
JOIN m_staff ON M_UserM_StaffID = M_StaffID
|
||||
LEFT JOIN one_health.oh_staff_map ON OHStaffMapM_StaffNIK = M_StaffNIK
|
||||
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $orderheaderID AND
|
||||
T_OrderDetailIsActive = 'Y' AND
|
||||
T_OrderDetailT_TestIsResult = 'Y'
|
||||
ORDER BY T_OrderDetailValDate DESC
|
||||
LIMIT 1";
|
||||
$query = $this->db->query($sql);
|
||||
if(!$query){
|
||||
// echo $this->db->last_query();
|
||||
$this->sys_error("error get t_orderdetail");
|
||||
exit;
|
||||
}
|
||||
|
||||
$r_validator = $query->row_array();
|
||||
|
||||
$data_result['performer'] = array(
|
||||
array(
|
||||
'reference' => "Practitioner/".$r_validator['staff_ihsnumber']
|
||||
),
|
||||
array(
|
||||
'reference' => "Organization/".$organizationID
|
||||
)
|
||||
);
|
||||
|
||||
$sql = "SELECT observationUUID
|
||||
FROM t_orderdetail
|
||||
JOIN one_health.observation ON observationT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
observationT_TestID = T_OrderDetailT_TestID AND
|
||||
observationIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = $orderheaderID AND
|
||||
T_OrderDetailIsActive = 'Y' AND
|
||||
T_OrderDetailT_TestIsResult = 'Y'";
|
||||
$query = $this->db->query($sql);
|
||||
if(!$query){
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error("error get t_orderdetail observation");
|
||||
exit;
|
||||
}
|
||||
|
||||
$r_observations = $query->result_array();
|
||||
|
||||
$rst_result = [];
|
||||
foreach ($r_observations as $idx => $val) {
|
||||
$idnew = $idx+1;
|
||||
$rst_result[] = array(
|
||||
"id" => "{$idnew}",
|
||||
"reference" => "Observation/".$val['observationUUID']
|
||||
);
|
||||
}
|
||||
$data_result['result'] = $rst_result;
|
||||
|
||||
$sql = "SELECT SpecimenUUID
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_ordersample ON T_OrderSampleT_SampleTypeID = T_TestT_SampleTypeID AND
|
||||
T_OrderSampleT_OrderHeaderID = {$prm['orderheaderID']} AND T_OrderSampleIsActive = 'Y'
|
||||
JOIN one_health.specimen ON SpecimentT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
SpecimentT_OrderSampleID = T_OrderSampleID AND
|
||||
SpecimenIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$prm['orderheaderID']} AND
|
||||
T_OrderDetailIsActive = 'Y' AND
|
||||
T_OrderDetailT_TestIsResult = 'Y'
|
||||
GROUP BY T_OrderSampleID";
|
||||
$query = $this->db->query($sql);
|
||||
if(!$query){
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error("error get specimen uuid");
|
||||
exit;
|
||||
}
|
||||
|
||||
$r_specimens = $query->result_array();
|
||||
|
||||
$rst_specimen = [];
|
||||
foreach ($r_specimens as $idxx => $vall) {
|
||||
$idnew = $idxx+1;
|
||||
$rst_specimen[] = array(
|
||||
"id" => "{$idnew}",
|
||||
"reference" => "Specimen/".$vall['SpecimenUUID']
|
||||
);
|
||||
}
|
||||
$data_result['specimen'] = $rst_specimen;
|
||||
|
||||
$data_result['basedOn'] = array(
|
||||
array(
|
||||
"reference" => "urn:uuid:".$rdr['ServiceRequestUUID']
|
||||
)
|
||||
);
|
||||
$data_result["conclusion"] = "";
|
||||
$result["resource"] = $data_result;
|
||||
$result["request"] = array("method" => "POST", "url" => "DiagnosticReport");
|
||||
|
||||
$sql = "INSERT INTO one_health.diagnostic_report
|
||||
(
|
||||
DiagnosticReportUUID,
|
||||
DiagnosticReportT_orderHeaderID,
|
||||
DiagnosticReportServiceRequestID,
|
||||
DiagnosticReportJSON,
|
||||
DiagnosticReportCreated
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db->query($sql, [
|
||||
$diagnosticreport_uuid,
|
||||
$orderheaderID,
|
||||
$rdr['ServiceRequestID'],
|
||||
json_encode($result)
|
||||
]);
|
||||
$last_qry = $this->db->last_query();
|
||||
|
||||
if (!$qry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
$results[] = $result;
|
||||
}else{
|
||||
//echo "Y";
|
||||
//print_r($exist_data);
|
||||
$results[] = json_decode($exist_data[0]['DiagnosticReportJSON']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
echo json_encode($results);
|
||||
}
|
||||
|
||||
function getcategorydiagnosticreport() {
|
||||
$prm = $this->sys_input;
|
||||
$orderheaderID = $prm['orderheaderID'];
|
||||
|
||||
$sql_category = "SELECT DiagnosticReportJSON
|
||||
From one_health.diagnostic_report
|
||||
WHERE DiagnosticReportT_orderHeaderID = ?
|
||||
AND DiagnosticReportIsActive = 'Y'
|
||||
";
|
||||
|
||||
$sql_category_report = $this->db->query($sql_category,[$orderheaderID]);
|
||||
if (!$sql_category_report) {
|
||||
$last_qry = $this->db->last_query();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$exist_datas = $sql_category_report->result_array();
|
||||
// echo json_encode($exist_data);
|
||||
|
||||
$exist_data = json_decode($exist_datas, true);
|
||||
|
||||
// Loop through each object in the array
|
||||
foreach ($exist_data as $data) {
|
||||
// Extract the DiagnosticReportJSON string
|
||||
$diagnosticReportJSON = $data['DiagnosticReportJSON'];
|
||||
|
||||
// Parse the DiagnosticReportJSON string
|
||||
$diagnosticReport = json_decode($diagnosticReportJSON, true);
|
||||
|
||||
// Access properties within the DiagnosticReportJSON
|
||||
$fullUrl = $diagnosticReport['fullUrl'];
|
||||
$resourceType = $diagnosticReport['resource']['resourceType'];
|
||||
// ... access other properties as needed
|
||||
|
||||
// Print or use the extracted data
|
||||
echo "Full URL: $fullUrl, Resource Type: $resourceType <br>";
|
||||
}
|
||||
// for ($i=0; $i < count($exist_data); $i++) {
|
||||
// $datas = json_decode(json_encode($exist_data[$i]['DiagnosticReportJSON']));
|
||||
// $encode = $datas;
|
||||
// $referenceValue = $datas['resource']['basedOn']['reference'];
|
||||
// }
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
17
application/controllers/Dummy_login.php
Normal file
17
application/controllers/Dummy_login.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
class Dummy_login extends MY_Controller {
|
||||
function login() {
|
||||
$prm = $this->sys_input;
|
||||
if ($prm["companyID"]== 100 && $prm["username"] =="admin" && $prm["password"] == "123" ) {
|
||||
echo json_encode([
|
||||
"status" =>"OK",
|
||||
"data" => [
|
||||
"token"=>"token1231231231321",
|
||||
"name"=>"Administrator",
|
||||
"userID"=>121,
|
||||
]]);
|
||||
exit;
|
||||
}
|
||||
echo json_encode(["status" => "ERR", "message" => "Invalid Login"]);
|
||||
}
|
||||
}
|
||||
237
application/controllers/Ext_rspad.php
Normal file
237
application/controllers/Ext_rspad.php
Normal file
@@ -0,0 +1,237 @@
|
||||
<?php
|
||||
|
||||
class Ext_rspad extends MY_CONTROLLER
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function wa($target = "slave_rspad", $last_minute = 15)
|
||||
{
|
||||
$sql = "select * from ext_rspad.slave_log
|
||||
where
|
||||
target = ? and
|
||||
(
|
||||
Last_IO_Errno <> 0 or Last_Errno <> 0
|
||||
or Last_SQL_Errno <> 0
|
||||
)
|
||||
and date + interval ? minute > now()
|
||||
order by id desc";
|
||||
$qry = $this->db->query($sql, [$target, $last_minute]);
|
||||
if (!$qry) {
|
||||
echo "<p>";
|
||||
print_r($this->db->error());
|
||||
echo "</p>";
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "No Error in Last 15 minutes\n";
|
||||
exit;
|
||||
}
|
||||
$msg = "*Last $last_minute minute Error*:\n";
|
||||
if (count($rows) > 0) {
|
||||
foreach ($rows as $r) {
|
||||
$msg .= "Date: \t" . $r["date"] . "\n";
|
||||
if ($r["Last_IO_Errno"] > 0) {
|
||||
$msg .= "IO Err: \t" . $r["Last_IO_Error"] . "\n";
|
||||
}
|
||||
if ($r["Last_Errno"] > 0) {
|
||||
$msg .= "Gen Err: \t" . $r["Last_Error"] . "\n";
|
||||
}
|
||||
if ($r["Last_SQL_Errno"] > 0) {
|
||||
$msg .= "SQL Err: \t" . $r["Last_SQL_Error"] . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$msg .= "Last Status: https://devone.aplikasi.web.id/one-api/ext_rspad/show";
|
||||
$this->load->library("Wa_sas");
|
||||
$hp = "081339692415";
|
||||
$resp = $this->wa_sas->send_message($hp, $msg, false);
|
||||
echo json_encode($resp);
|
||||
}
|
||||
function wa_sum($target = "slave_rspad")
|
||||
{
|
||||
$sql = "select * from ext_rspad.slave_log
|
||||
where
|
||||
target = ? and
|
||||
(
|
||||
Last_IO_Errno <> 0 or Last_Errno <> 0
|
||||
or Last_SQL_Errno <> 0
|
||||
)
|
||||
and date + interval 3 day > now()
|
||||
order by id desc limit 0,3";
|
||||
$qry = $this->db->query($sql, [$target]);
|
||||
if (!$qry) {
|
||||
echo "<p>";
|
||||
print_r($this->db->error());
|
||||
echo "</p>";
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$msg = "";
|
||||
if (count($rows) > 0) {
|
||||
$msg = "*Last 3 Error (last 3 day)*:\n";
|
||||
foreach ($rows as $r) {
|
||||
$msg .= "Date: \t" . $r["date"] . "\n";
|
||||
if ($r["Last_IO_Errno"] > 0) {
|
||||
$msg .= "IO Err: \t" . $r["Last_IO_Error"] . "\n";
|
||||
}
|
||||
if ($r["Last_Errno"] > 0) {
|
||||
$msg .= "Gen Err: \t" . $r["Last_Error"] . "\n";
|
||||
}
|
||||
if ($r["Last_SQL_Errno"] > 0) {
|
||||
$msg .= "SQL Err: \t" . $r["Last_SQL_Error"] . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql = "select * from ext_rspad.slave_log
|
||||
where target = ?
|
||||
order by id desc limit 0,3";
|
||||
$qry = $this->db->query($sql, [$target]);
|
||||
if (!$qry) {
|
||||
echo "<p>";
|
||||
print_r($this->db->error());
|
||||
echo "</p>";
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$msg .= "*Last 3 status*:\n";
|
||||
if (count($rows) > 0) {
|
||||
foreach ($rows as $r) {
|
||||
$msg .= "Date: \t" . $r["date"] . "\n";
|
||||
if ($r["Last_IO_Errno"] > 0) {
|
||||
$msg .= "IO Err: \t" . $r["Last_IO_Error"] . "\n";
|
||||
}
|
||||
if ($r["Last_Errno"] > 0) {
|
||||
$msg .= "Gen Err: \t" . $r["Last_Error"] . "\n";
|
||||
}
|
||||
if ($r["Last_SQL_Errno"] > 0) {
|
||||
$msg .= "SQL Err: \t" . $r["Last_SQL_Error"] . "\n";
|
||||
}
|
||||
$msg .= "IO State:\t" . $r["Slave_IO_State"] . "\n";
|
||||
$msg .= "IO Running:\t" . $r["Slave_IO_Running"] . "\n";
|
||||
$msg .= "Sql State:\t" . $r["Slave_SQL_Running_State"] . "\n";
|
||||
$msg .= "Sql Running:\t" . $r["Slave_SQL_Running"] . "\n";
|
||||
$msg .= "Behind Master:\t" . $r["Seconds_Behind_Master"] . "\n";
|
||||
$msg .= "\n";
|
||||
}
|
||||
} else {
|
||||
$msg .= "Tidak ada\n";
|
||||
}
|
||||
$msg .= "Last Status: https://devone.aplikasi.web.id/one-api/ext_rspad/show";
|
||||
$this->load->library("Wa_sas");
|
||||
$hp = "081339692415";
|
||||
$resp = $this->wa_sas->send_message($hp, $msg, false);
|
||||
echo json_encode($resp);
|
||||
}
|
||||
function show($target = "slave_rspad")
|
||||
{
|
||||
$sql = "select
|
||||
date as TrxDate, Slave_IO_Running, Slave_IO_State, Seconds_Behind_Master,
|
||||
Last_Errno, Last_Error, Last_SQL_Errno, Last_SQL_Error,
|
||||
Last_IO_Errno, Last_IO_Error
|
||||
from ext_rspad.slave_log
|
||||
where target =? order by id desc limit 0,20";
|
||||
$qry = $this->db->query($sql, [$target]);
|
||||
echo "<h5>Log for $target <h5>";
|
||||
if (!$qry) {
|
||||
echo "<p>";
|
||||
print_r($this->db->error());
|
||||
echo "</p>";
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$this->print_table_style();
|
||||
$this->print_table($rows, array_keys($rows[0]));
|
||||
}
|
||||
function slave()
|
||||
{
|
||||
$sql = "INSERT INTO ext_rspad.slave_log (
|
||||
target,
|
||||
`Slave_IO_State`,`Master_Host`,`Master_User`,
|
||||
`Master_Port`,`Connect_Retry`,`Master_Log_File`,
|
||||
`Read_Master_Log_Pos`,`Relay_Log_File`,`Relay_Log_Pos`,
|
||||
`Relay_Master_Log_File`,`Slave_IO_Running`,`Slave_SQL_Running`,
|
||||
`Replicate_Do_DB`,`Replicate_Ignore_DB`,`Replicate_Do_Table`,
|
||||
`Replicate_Ignore_Table`,`Replicate_Wild_Do_Table`,`Replicate_Wild_Ignore_Table`,
|
||||
`Last_Errno`,`Last_Error`,`Skip_Counter`,
|
||||
`Exec_Master_Log_Pos`,`Relay_Log_Space`,`Until_Condition`,
|
||||
`Until_Log_File`,`Until_Log_Pos`,`Master_SSL_Allowed`,
|
||||
`Master_SSL_CA_File`,`Master_SSL_CA_Path`,`Master_SSL_Cert`,
|
||||
`Master_SSL_Cipher`,`Master_SSL_Key`,`Seconds_Behind_Master`,
|
||||
`Master_SSL_Verify_Server_Cert`,`Last_IO_Errno`,`Last_IO_Error`,
|
||||
`Last_SQL_Errno`,`Last_SQL_Error`,`Replicate_Ignore_Server_Ids`,
|
||||
`Master_Server_Id`,`Master_SSL_Crl`,`Master_SSL_Crlpath`,
|
||||
`Using_Gtid`,`Gtid_IO_Pos`,`Replicate_Do_Domain_Ids`,
|
||||
`Replicate_Ignore_Domain_Ids`,`Parallel_Mode`,`SQL_Delay`,
|
||||
`SQL_Remaining_Delay`,`Slave_SQL_Running_State`,`Slave_DDL_Groups`,
|
||||
`Slave_Non_Transactional_Groups`,`Slave_Transactional_Groups`)
|
||||
values(?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,? ) ";
|
||||
$body = file_get_contents("php://input");
|
||||
$prm = json_decode($body, true, 2048);
|
||||
$qry = $this->db->query($sql, [
|
||||
$prm["target"],
|
||||
$prm["Slave_IO_State"], $prm["Master_Host"], $prm["Master_User"],
|
||||
$prm["Master_Port"], $prm["Connect_Retry"], $prm["Master_Log_File"],
|
||||
$prm["Read_Master_Log_Pos"], $prm["Relay_Log_File"], $prm["Relay_Log_Pos"],
|
||||
$prm["Relay_Master_Log_File"], $prm["Slave_IO_Running"], $prm["Slave_SQL_Running"],
|
||||
$prm["Replicate_Do_DB"], $prm["Replicate_Ignore_DB"], $prm["Replicate_Do_Table"],
|
||||
$prm["Replicate_Ignore_Table"], $prm["Replicate_Wild_Do_Table"], $prm["Replicate_Wild_Ignore_Table"],
|
||||
$prm["Last_Errno"], $prm["Last_Error"], $prm["Skip_Counter"],
|
||||
$prm["Exec_Master_Log_Pos"], $prm["Relay_Log_Space"], $prm["Until_Condition"],
|
||||
$prm["Until_Log_File"], $prm["Until_Log_Pos"], $prm["Master_SSL_Allowed"],
|
||||
$prm["Master_SSL_CA_File"], $prm["Master_SSL_CA_Path"], $prm["Master_SSL_Cert"],
|
||||
$prm["Master_SSL_Cipher"], $prm["Master_SSL_Key"], $prm["Seconds_Behind_Master"],
|
||||
$prm["Master_SSL_Verify_Server_Cert"], $prm["Last_IO_Errno"], $prm["Last_IO_Error"],
|
||||
$prm["Last_SQL_Errno"], $prm["Last_SQL_Error"], $prm["Replicate_Ignore_Server_Ids"],
|
||||
$prm["Master_Server_Id"], $prm["Master_SSL_Crl"], $prm["Master_SSL_Crlpath"],
|
||||
$prm["Using_Gtid"], $prm["Gtid_IO_Pos"], $prm["Replicate_Do_Domain_Ids"],
|
||||
$prm["Replicate_Ignore_Domain_Ids"], $prm["Parallel_Mode"], $prm["SQL_Delay"],
|
||||
$prm["SQL_Remaining_Delay"], $prm["Slave_SQL_Running_State"], $prm["Slave_DDL_Groups"],
|
||||
$prm["Slave_Non_Transactional_Groups"], $prm["Slave_Transactional_Groups"]
|
||||
]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"error" => $this->db->error()
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
echo json_encode(["status" => "OK", "error" => []]);
|
||||
}
|
||||
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table($rows, $keys)
|
||||
{
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
496
application/controllers/File_upload.php
Normal file
496
application/controllers/File_upload.php
Normal file
@@ -0,0 +1,496 @@
|
||||
<?php
|
||||
/*
|
||||
create table fpp (
|
||||
fppID int not null auto_increment primary key,
|
||||
fppT_OrderHeaderID int,
|
||||
fppUrl varchar(300),
|
||||
fppIsActive varchar(1) default 'Y',
|
||||
fppUserID int,
|
||||
fppCreated datetime default current_timestamp(),
|
||||
fppLastUpdated datetime default current_timestamp() on update current_timestamp(),
|
||||
key(fppT_OrderHeaderID),
|
||||
key(fppUserID),
|
||||
key(fppIsActive)
|
||||
);
|
||||
*/
|
||||
class File_upload extends MY_Controller
|
||||
{
|
||||
function corss()
|
||||
{
|
||||
global $_SERVER;
|
||||
if (isset($_SERVER["HTTP_ORIGIN"])) {
|
||||
header("Access-Control-Allow-Origin: " . $_SERVER["HTTP_ORIGIN"]);
|
||||
} else {
|
||||
header("Access-Control-Allow-Origin: */*");
|
||||
}
|
||||
header("Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS");
|
||||
header(
|
||||
"Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization"
|
||||
);
|
||||
if (
|
||||
isset($_SERVER["REQUEST_METHOD"]) &&
|
||||
$_SERVER["REQUEST_METHOD"] == "OPTIONS"
|
||||
) {
|
||||
http_response_code(200);
|
||||
echo json_encode("OK");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
function get_param()
|
||||
{
|
||||
return json_decode(file_get_contents("php://input"), true);
|
||||
}
|
||||
function update_fpp()
|
||||
{
|
||||
$this->corss();
|
||||
$param = $this->get_param();
|
||||
$param["url"] = $param["url"];
|
||||
$userID = $this->sys_user["M_UserID"];
|
||||
if ($param["cmd"] == "replace") {
|
||||
$sql = "update fpp set fppUrl = ?, fppUserID = ?
|
||||
where fppT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$param["url"],
|
||||
$userID,
|
||||
$param["orderHeaderID"],
|
||||
]);
|
||||
} else {
|
||||
$sql =
|
||||
" insert into fpp (fppUrl, fppUserID, fppT_OrderHeaderID) values(?,?,?)";
|
||||
$qry = $this->db->query($sql, [
|
||||
$param["url"],
|
||||
$userID,
|
||||
$param["orderHeaderID"],
|
||||
]);
|
||||
}
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
echo json_encode(["status" => "OK", "message" => ""]);
|
||||
}
|
||||
function get_fpp($orderHeaderID)
|
||||
{
|
||||
$sql = "select fppUrl from fpp
|
||||
where fppT_OrderHeaderID = ? and fppIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode(["status" => "OK", "rows" => $rows]);
|
||||
}
|
||||
function view_fpp($orderHeaderID)
|
||||
{
|
||||
$sql = "select fppUrl from fpp
|
||||
where fppT_OrderHeaderID = ? and fppIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
echo "<div> Error : " . $this->db->error()["message"] . "</div>";
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "<div> Belum ada FPP </div>";
|
||||
exit();
|
||||
}
|
||||
$view = "";
|
||||
foreach ($rows as $r) {
|
||||
$pi = pathinfo($r["fppUrl"]);
|
||||
if ($pi["extenstion"] != "pdf") {
|
||||
$view .=
|
||||
"<img src='" .
|
||||
$r["fppUrl"] .
|
||||
"' style='width:800px' /> <br/>";
|
||||
} else {
|
||||
$view .= "<a href='" . $r["fppUrl"] . "' > View FPP PDF </a>";
|
||||
}
|
||||
}
|
||||
echo "<div> $view </div>";
|
||||
}
|
||||
function upload_v2()
|
||||
{
|
||||
$this->corss();
|
||||
$file = $_FILES["file"];
|
||||
$host = "http://devone.aplikasi.web.id";
|
||||
$fpp_folder = "/data-fpp/";
|
||||
$param = $this->get_param();
|
||||
$userID = $this->sys_user["M_UserID"];
|
||||
if (!($userID > 0)) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Authorization error",
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$nolab = $_POST["nolab"];
|
||||
$orderHeaderID = $_POST["orderHeaderID"];
|
||||
$sql = "select fppID from fpp where fppT_OrderHeaderID=?
|
||||
and fppIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$fppID = 0;
|
||||
if (count($rows) > 0) {
|
||||
$fppID = $rows[0]["fppID"];
|
||||
}
|
||||
if (file_exists($file["tmp_name"])) {
|
||||
$tmpName = tempnam($fpp_folder, "fpp-") . "-{$nolab}.pdf";
|
||||
$xname = substr($tmpName, strlen($fpp_folder));
|
||||
$upload_status = file_put_contents(
|
||||
$tmpName,
|
||||
file_get_contents($file["tmp_name"])
|
||||
);
|
||||
if (!$upload_status) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Error Upload File",
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$url = $host . "/one-api/file_upload/dlv2/" . $xname;
|
||||
if ($fppID == 0) {
|
||||
$sql = "insert into fpp (fppUrl, fppUserID, fppT_OrderHeaderID) values(?,?,?)";
|
||||
$qry = $this->db->query($sql, [$url, $userID, $orderHeaderID]);
|
||||
} else {
|
||||
$sql = "update fpp set fppUrl = ?, fppUserID = ?
|
||||
where fppID = ?";
|
||||
$qry = $this->db->query($sql, [$url, $userID, $orderHeaderID]);
|
||||
}
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"url" => $url,
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Failed upload file",
|
||||
]);
|
||||
}
|
||||
function index()
|
||||
{
|
||||
$this->corss();
|
||||
$file = $_FILES["file"];
|
||||
$host = "";
|
||||
if (file_exists($file["tmp_name"])) {
|
||||
$tmpName = tempnam("/xtmp/", "fpp-") . $file["name"];
|
||||
$xname = substr($tmpName, 6);
|
||||
file_put_contents($tmpName, file_get_contents($file["tmp_name"]));
|
||||
$nolab = pathinfo($file["name"])["filename"];
|
||||
$order = $this->get_order($nolab);
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"order" => $order,
|
||||
"name" => $file["name"],
|
||||
"url" => $host . "/one-api/file_upload/dl/" . $xname,
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Failed upload file",
|
||||
]);
|
||||
}
|
||||
function get_order_by_id($headerID)
|
||||
{
|
||||
$sql = "select T_OrderHeaderID, T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber, T_OrderHeaderLabNumberExt,
|
||||
T_OrderHeaderM_PatientID, T_OrderHeaderSenderM_DoctorID ,
|
||||
T_OrderHeaderSenderM_DoctorAddressID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderID = ?
|
||||
and T_OrderHeaderIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$headerID]);
|
||||
$result = [];
|
||||
if (!$qry) {
|
||||
$result["status"] = "ERR";
|
||||
$result["message"] = $this->db->error()["message"];
|
||||
echo json_encode($result);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
$result["status"] = "ERR";
|
||||
$result["message"] = "Order Lab tidak ada";
|
||||
echo json_encode($result);
|
||||
exit();
|
||||
}
|
||||
$orderHeaderID = $rows[0]["T_OrderHeaderID"];
|
||||
$orderDate = $rows[0]["T_OrderHeaderDate"];
|
||||
$labNo = $rows[0]["T_OrderHeaderLabNumber"];
|
||||
$labNoExt = $rows[0]["T_OrderHeaderLabNumberExt"];
|
||||
$doctorID = $rows[0]["T_OrderHeaderSenderM_DoctorID"];
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$addressID = $rows[0]["T_OrderHeaderSenderM_DoctorAddressID"];
|
||||
|
||||
$sql = "select fn_get_doctor_fullname(?) doctor,
|
||||
fn_get_patient_atribute(?) patient,
|
||||
M_DoctorAddressDescription
|
||||
from m_doctoraddress
|
||||
where M_DoctorAddressID = ?";
|
||||
$qry = $this->db->query($sql, [$doctorID, $patientID, $addressID]);
|
||||
if (!$qry) {
|
||||
$result["status"] = "ERR";
|
||||
$result["message"] = $this->db->error()["message"];
|
||||
echo json_encode($result);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
$result["status"] = "ERR";
|
||||
$result["message"] = "Alamat Dokter pengirim tidak ada";
|
||||
echo json_encode($result);
|
||||
exit();
|
||||
}
|
||||
$doctor = $rows[0]["doctor"];
|
||||
$address = $rows[0]["M_DoctorAddressDescrtiption"];
|
||||
$jpatient = json_decode($rows[0]["patient"], true);
|
||||
$patient = $jpatient["patient_fullname"];
|
||||
$sql = "select T_TestName
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
order by T_TestSasCode ";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
$result["status"] = "ERR";
|
||||
$result["message"] = $this->db->error()["message"];
|
||||
echo json_encode($result);
|
||||
exit();
|
||||
}
|
||||
$tests = $qry->result_array();
|
||||
$sql = "select fppUrl from fpp where fppT_OrderHeaderID=?";
|
||||
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
$result["status"] = "ERR";
|
||||
$result["message"] = $this->db->error()["message"];
|
||||
echo json_encode($result);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$existingFpp = [];
|
||||
foreach ($rows as $r) {
|
||||
$existingFpp[] = $r["fppUrl"];
|
||||
}
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"data" => [
|
||||
"orderHeaderID" => $orderHeaderID,
|
||||
"labNo" => $labNo,
|
||||
"labNoExt" => $labNoExt,
|
||||
"date" => $orderDate,
|
||||
"doctor" => $doctor,
|
||||
"address" => $address,
|
||||
"patient" => $patient,
|
||||
"test" => $tests,
|
||||
"status" => "OK",
|
||||
"haveExisting" => count($existingFpp) > 0,
|
||||
"existing" => $existingFpp,
|
||||
"message" => "",
|
||||
],
|
||||
]);
|
||||
}
|
||||
function get_order($nolab)
|
||||
{
|
||||
$sql = "select T_OrderHeaderID, T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber, T_OrderHeaderLabNumberExt,
|
||||
T_OrderHeaderM_PatientID, T_OrderHeaderSenderM_DoctorID ,
|
||||
T_OrderHeaderSenderM_DoctorAddressID
|
||||
from t_orderheader
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
or T_OrderHeaderLabNumberExt like ?
|
||||
and T_OrderHeaderIsActive = 'Y'";
|
||||
$param = "%" . $nolab;
|
||||
$qry = $this->db->query($sql, [$param, $param]);
|
||||
$result = [];
|
||||
if (!$qry) {
|
||||
$result["status"] = "ERR";
|
||||
$result["message"] = $this->db->error()["message"];
|
||||
return $result;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
$result["status"] = "ERR";
|
||||
$result["message"] = "Order dengan No. Lab $nolab tidak ada";
|
||||
return $result;
|
||||
}
|
||||
$orderHeaderID = $rows[0]["T_OrderHeaderID"];
|
||||
$orderDate = $rows[0]["T_OrderHeaderDate"];
|
||||
$labNo = $rows[0]["T_OrderHeaderLabNumber"];
|
||||
$labNoExt = $rows[0]["T_OrderHeaderLabNumberExt"];
|
||||
$doctorID = $rows[0]["T_OrderHeaderSenderM_DoctorID"];
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$addressID = $rows[0]["T_OrderHeaderSenderM_DoctorAddressID"];
|
||||
|
||||
$sql = "select fn_get_doctor_fullname(?) doctor,
|
||||
fn_get_patient_atribute(?) patient,
|
||||
M_DoctorAddressDescription
|
||||
from m_doctoraddress
|
||||
where M_DoctorAddressID = ?";
|
||||
$qry = $this->db->query($sql, [$doctorID, $patientID, $addressID]);
|
||||
if (!$qry) {
|
||||
$result["status"] = "ERR";
|
||||
$result["message"] = $this->db->error()["message"];
|
||||
return $result;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
$result["status"] = "ERR";
|
||||
$result["message"] = "Alamat Dokter pengirim tidak ada";
|
||||
return $result;
|
||||
}
|
||||
$doctor = $rows[0]["doctor"];
|
||||
$address = $rows[0]["M_DoctorAddressDescrtiption"];
|
||||
$jpatient = json_decode($rows[0]["patient"], true);
|
||||
$patient = $jpatient["patient_fullname"];
|
||||
$sql = "select T_TestName
|
||||
from t_orderdetail
|
||||
join t_test on T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
order by T_TestSasCode ";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
$result["status"] = "ERR";
|
||||
$result["message"] = $this->db->error()["message"];
|
||||
return $result;
|
||||
}
|
||||
$tests = $qry->result_array();
|
||||
$sql = "select fppUrl from fpp where fppT_OrderHeaderID=?";
|
||||
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
$result["status"] = "ERR";
|
||||
$result["message"] = $this->db->error()["message"];
|
||||
return $result;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$existingFpp = [];
|
||||
foreach ($rows as $r) {
|
||||
$existingFpp[] = $r["fppUrl"];
|
||||
}
|
||||
return [
|
||||
"orderHeaderID" => $orderHeaderID,
|
||||
"labNo" => $labNo,
|
||||
"labNoExt" => $labNoExt,
|
||||
"date" => $orderDate,
|
||||
"doctor" => $doctor,
|
||||
"address" => $address,
|
||||
"patient" => $patient,
|
||||
"test" => $tests,
|
||||
"status" => "OK",
|
||||
"haveExisting" => count($existingFpp) > 0,
|
||||
"existing" => $existingFpp,
|
||||
"message" => "",
|
||||
];
|
||||
}
|
||||
function dl($xname)
|
||||
{
|
||||
$fpath = "/xtmp/" . $xname;
|
||||
header("Content-type: " . $this->get_mime_type($fpath));
|
||||
echo file_get_contents($fpath);
|
||||
}
|
||||
function dlv2($xname)
|
||||
{
|
||||
$fpath = "/data-fpp/" . $xname;
|
||||
header("Content-type: " . $this->get_mime_type($fpath));
|
||||
echo file_get_contents($fpath);
|
||||
}
|
||||
|
||||
function get_mime_type($filename)
|
||||
{
|
||||
$idx = explode(".", $filename);
|
||||
$count_explode = count($idx);
|
||||
$idx = strtolower($idx[$count_explode - 1]);
|
||||
|
||||
$mimet = [
|
||||
"txt" => "text/plain",
|
||||
"htm" => "text/html",
|
||||
"html" => "text/html",
|
||||
"php" => "text/html",
|
||||
"css" => "text/css",
|
||||
"js" => "application/javascript",
|
||||
"json" => "application/json",
|
||||
"xml" => "application/xml",
|
||||
"swf" => "application/x-shockwave-flash",
|
||||
"flv" => "video/x-flv",
|
||||
|
||||
// images
|
||||
"png" => "image/png",
|
||||
"jpe" => "image/jpeg",
|
||||
"jpeg" => "image/jpeg",
|
||||
"jpg" => "image/jpeg",
|
||||
"gif" => "image/gif",
|
||||
"bmp" => "image/bmp",
|
||||
"ico" => "image/vnd.microsoft.icon",
|
||||
"tiff" => "image/tiff",
|
||||
"tif" => "image/tiff",
|
||||
"svg" => "image/svg+xml",
|
||||
"svgz" => "image/svg+xml",
|
||||
|
||||
// archives
|
||||
"zip" => "application/zip",
|
||||
"rar" => "application/x-rar-compressed",
|
||||
"exe" => "application/x-msdownload",
|
||||
"msi" => "application/x-msdownload",
|
||||
"cab" => "application/vnd.ms-cab-compressed",
|
||||
|
||||
// audio/video
|
||||
"mp3" => "audio/mpeg",
|
||||
"qt" => "video/quicktime",
|
||||
"mov" => "video/quicktime",
|
||||
|
||||
// adobe
|
||||
"pdf" => "application/pdf",
|
||||
"psd" => "image/vnd.adobe.photoshop",
|
||||
"ai" => "application/postscript",
|
||||
"eps" => "application/postscript",
|
||||
"ps" => "application/postscript",
|
||||
|
||||
// ms office
|
||||
"doc" => "application/msword",
|
||||
"rtf" => "application/rtf",
|
||||
"xls" => "application/vnd.ms-excel",
|
||||
"ppt" => "application/vnd.ms-powerpoint",
|
||||
"docx" => "application/msword",
|
||||
"xlsx" => "application/vnd.ms-excel",
|
||||
"pptx" => "application/vnd.ms-powerpoint",
|
||||
|
||||
// open office
|
||||
"odt" => "application/vnd.oasis.opendocument.text",
|
||||
"ods" => "application/vnd.oasis.opendocument.spreadsheet",
|
||||
];
|
||||
|
||||
if (isset($mimet[$idx])) {
|
||||
return $mimet[$idx];
|
||||
} else {
|
||||
return "application/octet-stream";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
39
application/controllers/Imgtoken.php
Normal file
39
application/controllers/Imgtoken.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
class Imgtoken extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function show($number)
|
||||
{
|
||||
|
||||
header('Content-Type: image/png');
|
||||
|
||||
// Create the image
|
||||
$im = imagecreatetruecolor(200, 100);
|
||||
|
||||
// Create some colors
|
||||
$black = imagecolorallocate($im, 0, 0, 0);
|
||||
$white = imagecolorallocate($im, 255, 255, 255);
|
||||
|
||||
// Draw the background rectangles
|
||||
imagefilledrectangle($im, 0, 0, 200, 50, $black);
|
||||
imagefilledrectangle($im, 0, 50, 200, 100, $white);
|
||||
|
||||
// Set the text colors
|
||||
$text_color_white = $white;
|
||||
$text_color_black = $black;
|
||||
|
||||
// Set the path to the font you want to use
|
||||
$font_path = APPPATH . 'controllers/Arial_Narrow.ttf'; // Make sure this path is correct
|
||||
|
||||
// Add the text
|
||||
imagettftext($im, 20, 0, 50, 30, $text_color_white, $font_path, 'Token Anda');
|
||||
imagettftext($im, 20, 0, 70, 80, $text_color_black, $font_path, $number);
|
||||
|
||||
// Using imagepng() results in clearer text compared with imagejpeg()
|
||||
imagepng($im);
|
||||
imagedestroy($im);
|
||||
}
|
||||
}
|
||||
22
application/controllers/Info.php
Normal file
22
application/controllers/Info.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
class Info extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function x($param = "")
|
||||
{
|
||||
print_r($_GET);
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo json_encode($this->sys_input);
|
||||
}
|
||||
function convert()
|
||||
{
|
||||
$resp = file_get_contents("php://input");
|
||||
echo $resp;
|
||||
}
|
||||
}
|
||||
233
application/controllers/Json_placeholder.php
Normal file
233
application/controllers/Json_placeholder.php
Normal file
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
class Json_placeholder extends CI_Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
echo "AUTH API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function corss()
|
||||
{
|
||||
global $_SERVER;
|
||||
if (isset($_SERVER["HTTP_ORIGIN"])) {
|
||||
header("Access-Control-Allow-Origin: " . $_SERVER["HTTP_ORIGIN"]);
|
||||
} else {
|
||||
header("Access-Control-Allow-Origin: */*");
|
||||
}
|
||||
header("Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS");
|
||||
header(
|
||||
"Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization"
|
||||
);
|
||||
if (
|
||||
isset($_SERVER["REQUEST_METHOD"]) &&
|
||||
$_SERVER["REQUEST_METHOD"] == "OPTIONS"
|
||||
) {
|
||||
http_response_code(200);
|
||||
echo json_encode("OK");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
function search_allergy() {
|
||||
$this->corss();
|
||||
$this->load->database("default");
|
||||
$max_result = 30;
|
||||
$param = $this->get_param();
|
||||
if ($param["search"] == "") {
|
||||
$sql = "select * from place_holder.drug_allergy limit 0,$max_result";
|
||||
$qry = $this->db->query($sql);
|
||||
} else {
|
||||
$param["search"] = "%" . $param["search"] . "%";
|
||||
$sql = "select * from place_holder.drug_allergy
|
||||
where CODE like ? or STR like ?
|
||||
limit 0,$max_result";
|
||||
$qry = $this->db->query($sql,[$param["search"]]);
|
||||
}
|
||||
if ($qry) {
|
||||
echo json_encode(["status"=>"ERR","message" => $this->db->error()["message"]]);
|
||||
exit;
|
||||
}
|
||||
echo json_encode(["status"=>"OK","rows"=>$this->db->result_array()]);
|
||||
}
|
||||
function search_location()
|
||||
{
|
||||
// metode search : 1. search kelurahan ( limit 20) , jika < 20 search kecamatan limit 20 - hasil kelurahan, jika < 20 search city dst
|
||||
$max_result = 30;
|
||||
$param = $this->get_param();
|
||||
$param["search"] = "%" . $param["search"] . "%";
|
||||
$a_loc = [];
|
||||
if ($param["queryLoc"] != "") {
|
||||
$a_loc = explode(",",$param["queryLoc"]);
|
||||
}
|
||||
$filter_loc = "";
|
||||
if (count($a_loc) > 0) {
|
||||
if (count($a_loc) == 1) {
|
||||
$filter_loc = " and M_ProvinceName = '" . $a_loc[0] . "'";
|
||||
}
|
||||
if (count($a_loc) == 2) {
|
||||
$filter_loc = " and M_CityName = '" . $a_loc[1] . "'";
|
||||
}
|
||||
if (count($a_loc) == 3) {
|
||||
$filter_loc = " and M_DistrictName= '" . $a_loc[2] . "'";
|
||||
}
|
||||
}
|
||||
$this->load->database("default");
|
||||
$this->corss();
|
||||
$sql = "select M_KelurahanID,M_KelurahanName,
|
||||
M_DistrictID, M_DistrictName,
|
||||
M_CityID, M_CityName,
|
||||
M_ProvinceID, M_ProvinceName
|
||||
from m_kelurahan
|
||||
join m_district on M_KelurahanName like ?
|
||||
and M_KelurahanIsActive='Y'
|
||||
and M_DistrictID = M_KelurahanM_DistrictID
|
||||
join m_city on M_CityID = M_DistrictM_CityID
|
||||
and M_CityIsActive = 'Y'
|
||||
join m_province on M_CityM_ProvinceID = M_ProvinceID
|
||||
and M_ProvinceIsActive = 'Y'
|
||||
$filter_loc
|
||||
limit 0,$max_result";
|
||||
$qry = $this->db->query($sql, [$param["search"]]);
|
||||
if (!$qry) {
|
||||
echo json_encode(["status"=>"ERR","message"=>$this->db->error()["message"]]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$result = [];
|
||||
foreach ($rows as $r) {
|
||||
$result[] = $r;
|
||||
$idx = count($result) - 1;
|
||||
$result[$idx]["tag"] = [
|
||||
$r["M_ProvinceName"],
|
||||
$r["M_CityName"],
|
||||
$r["M_DistrictName"],
|
||||
$r["M_KelurahanName"],
|
||||
];
|
||||
$result[$idx]["level"] = 1;
|
||||
}
|
||||
if (count($rows) < $max_result) {
|
||||
$max_result = $max_result - count($rows);
|
||||
$sql = "select
|
||||
M_DistrictID, M_DistrictName,
|
||||
M_CityID, M_CityName,
|
||||
M_ProvinceID, M_ProvinceName
|
||||
from m_district
|
||||
join m_city on M_DistrictName like ?
|
||||
and M_DistrictIsActive ='Y'
|
||||
and M_DistrictM_CityID = M_CityID
|
||||
and M_CityIsActive = 'Y'
|
||||
join m_province on M_CityM_ProvinceID = M_ProvinceID
|
||||
and M_ProvinceIsActive = 'Y'
|
||||
$filter_loc
|
||||
limit 0,$max_result";
|
||||
$qry = $this->db->query($sql, [$param["search"]]);
|
||||
if (!$qry) {
|
||||
echo json_encode(["status"=>"ERR","message"=>$this->db->error()["message"]]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
$result[] = $r;
|
||||
$idx = count($result) - 1;
|
||||
$result[$idx]["tag"] = [
|
||||
$r["M_ProvinceName"],
|
||||
$r["M_CityName"],
|
||||
$r["M_DistrictName"],
|
||||
];
|
||||
$result[$idx]["level"] = 2;
|
||||
}
|
||||
|
||||
if (count($rows) < $max_result) {
|
||||
$max_result = $max_result - count($rows);
|
||||
$x_loc = $filter_loc ;
|
||||
if(count($a_loc) > 2) $x_loc = "";
|
||||
$sql = "select
|
||||
M_CityID, M_CityName,
|
||||
M_ProvinceID, M_ProvinceName
|
||||
from m_city
|
||||
join m_province on M_CityName like ?
|
||||
and M_CityIsActive = 'Y'
|
||||
and M_CityM_ProvinceID= M_ProvinceID
|
||||
and M_ProvinceIsActive= 'Y'
|
||||
$x_loc
|
||||
limit 0,$max_result";
|
||||
$qry = $this->db->query($sql, [$param["search"]]);
|
||||
if (!$qry) {
|
||||
echo json_encode(["status"=>"ERR","message"=>$this->db->error()["message"]]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
$result[] = $r;
|
||||
$idx = count($result) - 1;
|
||||
$result[$idx]["tag"] = [
|
||||
$r["M_ProvinceName"],
|
||||
$r["M_CityName"],
|
||||
];
|
||||
$result[$idx]["level"] = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"rows" => $result
|
||||
]);
|
||||
}
|
||||
function get_param()
|
||||
{
|
||||
$sbody = file_get_contents("php://input");
|
||||
return json_decode($sbody, true);
|
||||
}
|
||||
function search_patient()
|
||||
{
|
||||
$this->corss();
|
||||
$ch = curl_init(
|
||||
"http://devone.aplikasi.web.id/one-api/mockup/fo/registration_v11/patient/search"
|
||||
);
|
||||
$param = $this->get_param();
|
||||
$payload = json_encode([
|
||||
"noreg" => "",
|
||||
"search" => $param["search"],
|
||||
"current_page" => 1,
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type:application/json"]);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$resp = curl_exec($ch);
|
||||
$error = curl_errno($ch);
|
||||
$error_msg = curl_error($ch);
|
||||
if ($error != 0) {
|
||||
echo json_encode(["status" => "ERR", "message" => $error_msg]);
|
||||
exit();
|
||||
}
|
||||
echo $resp;
|
||||
}
|
||||
function lookup($param = "")
|
||||
{
|
||||
$this->corss();
|
||||
$result = [
|
||||
"status" => "OK",
|
||||
"data" => [
|
||||
["id" => 1, "name" => "Satu"],
|
||||
["id" => 2, "name" => "Dua"],
|
||||
["id" => 3, "name" => "Tiga"],
|
||||
["id" => 4, "name" => "Empat"],
|
||||
["id" => 5, "name" => "Lima"],
|
||||
["id" => 6, "name" => "Enam"],
|
||||
["id" => 7, "name" => "Tujuh"],
|
||||
["id" => 8, "name" => "Delapan"],
|
||||
["id" => 9, "name" => "Sembilan"],
|
||||
],
|
||||
];
|
||||
if ($param != "") {
|
||||
$data = array_filter($result["data"], function ($r) use ($param) {
|
||||
return strpos($r["name"], $param) >= 0;
|
||||
});
|
||||
$result["data"] = $data;
|
||||
}
|
||||
echo json_encode($result);
|
||||
}
|
||||
}
|
||||
?>
|
||||
531
application/controllers/Merge_rpt.php
Normal file
531
application/controllers/Merge_rpt.php
Normal file
@@ -0,0 +1,531 @@
|
||||
<?php
|
||||
class Merge_rpt extends MY_Controller
|
||||
{
|
||||
function corss()
|
||||
{
|
||||
global $_SERVER;
|
||||
if (isset($_SERVER["HTTP_ORIGIN"])) {
|
||||
header("Access-Control-Allow-Origin: " . $_SERVER["HTTP_ORIGIN"]);
|
||||
} else {
|
||||
header("Access-Control-Allow-Origin: */*");
|
||||
}
|
||||
header("Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS");
|
||||
header(
|
||||
"Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization"
|
||||
);
|
||||
if (
|
||||
isset($_SERVER["REQUEST_METHOD"]) &&
|
||||
$_SERVER["REQUEST_METHOD"] == "OPTIONS"
|
||||
) {
|
||||
http_response_code(200);
|
||||
echo json_encode("OK");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
function get_report($orderID, $username = "admin")
|
||||
{
|
||||
$rpt_lab =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_test_email.rptdesign";
|
||||
$rpt_lab_en =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_test_eng_email.rptdesign";
|
||||
|
||||
$rpt_xray =
|
||||
"/birt/run?__report=report/one/lab/rpt_hasil_so_xray_email.rptdesign";
|
||||
$rpt_xray_en =
|
||||
"/birt/run?__report=report/one/lab/rpt_hasil_so_xray_eng_email.rptdesign";
|
||||
$rpt_xray_v2 =
|
||||
"/birt/run?__report=report/one/lab/rpt_hasil_so_xray_2_email.rptdesign";
|
||||
$rpt_xray_v2_en =
|
||||
"/birt/run?__report=report/one/lab/rpt_hasil_so_xray_2_eng_email.rptdesign";
|
||||
|
||||
$rpt_elmd =
|
||||
"/birt/run?__report=report/one/lab/rpt_hasil_so_elmd_email.rptdesign";
|
||||
$rpt_elmd_en =
|
||||
"/birt/run?__report=report/one/lab/rpt_hasil_so_elmd_eng_email.rptdesign";
|
||||
|
||||
$rpt_elmd_v2 =
|
||||
"/birt/run?__report=report/one/lab/rpt_hasil_so_elmd_2_email.rptdesign";
|
||||
$rpt_elmd_v2_en =
|
||||
"/birt/run?__report=report/one/lab/rpt_hasil_so_elmd_2_eng_email.rptdesign";
|
||||
|
||||
$rpt_fisik_riwayat =
|
||||
"/birt/run?__report=report/one/mcu/mcu_riwayat.rptdesign";
|
||||
$rpt_fisik = "/birt/run?__report=report/one/mcu/mcu_fisik.rptdesign";
|
||||
|
||||
$rpt_mcu_resume =
|
||||
"/birt/frameset?__report=report/one/mcu/rpt_mcu_resume_cp.rptdesign";
|
||||
$rpt_mcu_resume_v2 =
|
||||
"/birt/frameset?__report=report/one/mcu/rpt_mcu_resume_p.rptdesign";
|
||||
$rpt_mcu_resume_v3 =
|
||||
"/birt/frameset?__report=report/one/mcu/rpt_mcu_resume_cpp.rptdesign";
|
||||
$rpt_mcu_resume_v4 =
|
||||
"/birt/frameset?__report=report/one/mcu/rpt_mcu_resume_pp.rptdesign";
|
||||
$rpt_mcu_resume_v5 =
|
||||
"/birt/frameset?__report=report/one/mcu/rpt_mcu_resume_cp1.rptdesign";
|
||||
$rpt_mcu_resume_v6 =
|
||||
"/birt/frameset?__report=report/one/mcu/rpt_mcu_resume_p1.rptdesign";
|
||||
$rpt_mcu_resume_v7 =
|
||||
"/birt/frameset?__report=report/one/mcu/rpt_mcu_resume_cpp1.rptdesign";
|
||||
$rpt_mcu_resume_v8 =
|
||||
"/birt/frameset?__report=report/one/mcu/rpt_mcu_resume_pp1.rptdesign";
|
||||
$rpt_mcu_resume_v9 =
|
||||
"/birt/frameset?__report=report/one/mcu/rpt_mcu_resume_cpp_tp.rptdesign";
|
||||
$rpt_mcu_resume_v10 =
|
||||
"/birt/frameset?__report=report/one/mcu/rpt_mcu_resume_cpp_tp_1.rptdesign";
|
||||
|
||||
$this->corss();
|
||||
$sql = "select T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderAddOnSecondM_LangID,
|
||||
T_OrderHeaderM_LangID,
|
||||
fn_get_patient_atribute(T_OrderHeaderM_PatientID) patient
|
||||
from t_orderheader
|
||||
join t_orderheaderaddon on T_OrderHeaderID = ?
|
||||
and T_OrderHeaderID = T_OrderHeaderAddonT_OrderHeaderID";
|
||||
$qry = $this->db->query($sql, [$orderID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["message"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$reports = [];
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Order Not Found",
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$labNo = $rows[0]["T_OrderHeaderLabNumber"];
|
||||
$jpat = json_decode($rows[0]["patient"], true);
|
||||
$pname = str_replace(" ", "_", $jpat["patient_fullname"]);
|
||||
$ts = "&ts=" . date("Ymdhis");
|
||||
$reports[] = [
|
||||
"name" => "Hasil Lab",
|
||||
"url" => "{$rpt_lab}&__format=pdf&username={$username}&PID={$orderID}&ts={$ts}",
|
||||
];
|
||||
$haveSecondLang = false;
|
||||
if (
|
||||
$rows[0]["T_OrderHeaderAddOnSecondM_LangID"] > 0 &&
|
||||
$rows[0]["T_OrderHeaderAddOnSecondM_LangID"] !=
|
||||
$rows["T_OrderHeaderM_LangID"]
|
||||
) {
|
||||
$haveSecondLang = true;
|
||||
$reports[] = [
|
||||
"name" => "Hasil Lab (Inggris)",
|
||||
"url" => "{$rpt_lab_en}&__format=pdf&username={$username}&PID={$orderID}&ts={$ts}",
|
||||
];
|
||||
}
|
||||
//Xray
|
||||
$reports[] = [
|
||||
"name" => "Rontgen",
|
||||
"url" => "{$rpt_xray}&__format=pdf&username={$username}&PID={$orderID}&PLang=1&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "Rontgen (v2)",
|
||||
"url" => "{$rpt_xray_v2}&__format=pdf&username={$username}&PID={$orderID}&PLang=1&ts={$ts}",
|
||||
];
|
||||
|
||||
if (false && $haveSecondLang) {
|
||||
$reports[] = [
|
||||
"name" => "Rontgen (Inggris)",
|
||||
"url" => "{$rpt_xray_en}&__format=pdf&username={$username}&PID={$orderID}&PLang=1&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "Rontgen (Inggris v2)",
|
||||
"url" => "{$rpt_xray_v2_en}&__format=pdf&username={$username}&PID={$orderID}&PLang=1&ts={$ts}",
|
||||
];
|
||||
}
|
||||
$sql = "select * from so_resultentry where So_ResultEntryT_OrderHeaderID=? and So_ResultEntrySo_TemplateName='ECG'
|
||||
and So_ResultEntryIsActive='Y'";
|
||||
$qry = $this->db->query($sql, [$orderID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["messaga"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
$soID = $r["So_ResultEntryID"];
|
||||
$langID = $r["So_ResultEntryM_LangID"];
|
||||
if ($langID == 1) {
|
||||
$name = "Elektromedik";
|
||||
$reports[] = [
|
||||
"name" => $name,
|
||||
"url" => "{$rpt_elmd}&__format=pdf&username={$username}&PID={$soID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "$name (v2)",
|
||||
"url" => "{$rpt_elmd_v2}&__format=pdf&username={$username}&PID={$soID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
} else {
|
||||
continue;
|
||||
$name = "Elektromedik (Inggris)";
|
||||
$reports[] = [
|
||||
"name" => $name,
|
||||
"url" => "{$rpt_elmd_en}&__format=pdf&username={$username}&PID={$soID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "Elektromedik (Inggris v2)",
|
||||
"url" => "{$rpt_elmd_v2_en}&__format=pdf&username={$username}&PID={$soID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
}
|
||||
}
|
||||
//FISIK UMUM
|
||||
$sql = "select * from so_resultentry where So_ResultEntryT_OrderHeaderID=? and So_ResultEntrySo_TemplateName='FISIK UMUM'
|
||||
and So_ResultEntryIsActive='Y'";
|
||||
$qry = $this->db->query($sql, [$orderID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["messaga"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
$soID = $r["So_ResultEntryID"];
|
||||
$langID = $r["So_ResultEntryM_LangID"];
|
||||
if ($langID == 1) {
|
||||
$reports[] = [
|
||||
"name" => "Fisik (riwayat)",
|
||||
"url" => "{$rpt_fisik_riwayat}&__format=pdf&PType=riwayat&username={$username}&PID={$soID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "Fisik",
|
||||
"url" => "{$rpt_fisik}&__format=pdf&PType=fisik&username={$username}&PID={$soID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
} else {
|
||||
continue;
|
||||
$name = "Elektromedik (Inggris)";
|
||||
$reports[] = [
|
||||
"name" => $name,
|
||||
"url" => "{$rpt_elmd_en}&__format=pdf&username={$username}&PID={$soID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "Elektromedik (Inggris v2)",
|
||||
"url" => "{$rpt_elmd_v2_en}&__format=pdf&username={$username}&PID={$soID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
}
|
||||
}
|
||||
//FISIK UMUM
|
||||
$sql =
|
||||
"select * from mcu_resume where Mcu_ResumeT_OrderHeaderID=? and Mcu_ResumeIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$orderID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()["messaga"],
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
$mcuResumeID = $r["Mcu_ResumeID"];
|
||||
$langID = $r["Mcu_ResumeM_LangID"];
|
||||
if ($langID == 1) {
|
||||
$reports[] = [
|
||||
"name" => "MCU Resume",
|
||||
"url" => "{$rpt_mcu_resume}&__format=pdf&username={$username}&PID={$mcuResumeID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "MCU Resume (v2)",
|
||||
"url" => "{$rpt_mcu_resume_v2}&__format=pdf&username={$username}&PID={$mcuResumeID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "MCU Resume (v3)",
|
||||
"url" => "{$rpt_mcu_resume_v3}&__format=pdf&username={$username}&PID={$mcuResumeID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "MCU Resume (v4)",
|
||||
"url" => "{$rpt_mcu_resume_v4}&__format=pdf&username={$username}&PID={$mcuResumeID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "MCU Resume (v5)",
|
||||
"url" => "{$rpt_mcu_resume_v5}&__format=pdf&username={$username}&PID={$mcuResumeID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "MCU Resume (v6)",
|
||||
"url" => "{$rpt_mcu_resume_v6}&__format=pdf&username={$username}&PID={$mcuResumeID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "MCU Resume (v7)",
|
||||
"url" => "{$rpt_mcu_resume_v7}&__format=pdf&username={$username}&PID={$mcuResumeID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "MCU Resume (v8)",
|
||||
"url" => "{$rpt_mcu_resume_v8}&__format=pdf&username={$username}&PID={$mcuResumeID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "MCU Resume (v9)",
|
||||
"url" => "{$rpt_mcu_resume_v9}&__format=pdf&username={$username}&PID={$mcuResumeID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
$reports[] = [
|
||||
"name" => "MCU Resume v10",
|
||||
"url" => "{$rpt_mcu_resume_v10}&__format=pdf&username={$username}&PID={$mcuResumeID}&PLang={$langID}&ts={$ts}",
|
||||
];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"status" => "OK",
|
||||
"data" => $reports,
|
||||
"labNo" => $labNo,
|
||||
"name" => $pname,
|
||||
]);
|
||||
}
|
||||
function download_pdf()
|
||||
{
|
||||
$this->corss();
|
||||
$orderHeaderID = $this->sys_input["headerId"];
|
||||
$output_file_name = $orderHeaderID . "-" . "merge" . ".pdf";
|
||||
$urls = $this->sys_input["urls"];
|
||||
$target = tempnam("/xtmp", uniqid("target", true)) . ".pdf";
|
||||
$merge_cmd = "/usr/bin/pdfunite";
|
||||
$base_url = "http://localhost/";
|
||||
$fnames_del = [];
|
||||
foreach ($urls as $url) {
|
||||
$fname = tempnam("/xtmp", uniqid("src", true)) . ".pdf";
|
||||
$rpt_data = file_get_contents($base_url . $url);
|
||||
file_put_contents($fname, $rpt_data);
|
||||
$merge_cmd .= " $fname ";
|
||||
$fnames_del[] = $fname;
|
||||
}
|
||||
$merge_cmd .= " $target";
|
||||
$output = [];
|
||||
exec($merge_cmd, $output);
|
||||
header("Content-type: application/pdf");
|
||||
header("Content-Disposition: inline");
|
||||
/*
|
||||
header(
|
||||
'Content-Disposition: inline; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
*/
|
||||
echo file_get_contents($target);
|
||||
foreach ($fnames_del as $fdel) {
|
||||
unlink($fdel);
|
||||
}
|
||||
if (file_exists($target)) {
|
||||
unlink($target);
|
||||
}
|
||||
}
|
||||
function get_pdf($orderID)
|
||||
{
|
||||
$sql = "select distinct
|
||||
Group_ResultID,Group_ResultName,
|
||||
Group_ResultFlagNonLab,IFNULL(T_EmailNonLabUrl,'-') EmailNonLabUrl,
|
||||
IF(T_EmailNonLabUrl IS NULL AND Group_ResultFlagNonLab = 'Y',' [Belum Pilih Format Hasil]','') temail
|
||||
from
|
||||
t_orderdetail
|
||||
join group_resultdetail
|
||||
on Group_ResultDetailT_TestID = T_OrderDetailT_TestID
|
||||
and T_OrderDetailIsActive = 'Y' and Group_ResultDetailIsActive = 'Y'
|
||||
and T_OrderDetailT_OrderHeaderID = ?
|
||||
join group_result
|
||||
on Group_ResultDetailGroup_ResultID = Group_ResultID
|
||||
and Group_ResultIsActive = 'Y'
|
||||
LEFT JOIN t_email_nonlab ON T_EmailNonLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_EmailNonLabType LIKE CONCAT('%',REPLACE(Group_ResultName, 'Elektromedik', 'electromedis'),'%')";
|
||||
$query = $this->db->query($sql, [$orderID]);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$ts = "&ts=" . date("Ymdhis");
|
||||
foreach ($rows as $r) {
|
||||
$xname = $r["Group_ResultName"];
|
||||
$gid = $r["Group_ResultID"];
|
||||
$emailnonlaburl = str_replace(" ", "", $r["EmailNonLabUrl"]);
|
||||
if (strpos($emailnonlaburl, "fisik") > 0) {
|
||||
continue;
|
||||
}
|
||||
$report = "";
|
||||
switch ($gid) {
|
||||
case 1:
|
||||
$report =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_test_email.rptdesign&__format=pdf&username=admin&PID=" .
|
||||
$orderID .
|
||||
$ts;
|
||||
break;
|
||||
case 2:
|
||||
$report =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_hasil_papsmear_email.rptdesign&__format=pdf&username=admin&PID=" .
|
||||
$orderID .
|
||||
$ts;
|
||||
break;
|
||||
case 3:
|
||||
$report =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_hasil_fna_email.rptdesign&__format=pdf&username=admin&PID=" .
|
||||
$orderID .
|
||||
$ts;
|
||||
break;
|
||||
case 4:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 5:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 6:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 7:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 8:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 9:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 10:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 11:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 12:
|
||||
$report =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_hasil_lcprep_email.rptdesign&__format=pdf&username=admin&PID=" .
|
||||
$orderID .
|
||||
$ts;
|
||||
break;
|
||||
case 13:
|
||||
$report =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_test_mikro_email.rptdesign&__format=pdf&username=admin&PID=" .
|
||||
$orderID .
|
||||
$ts;
|
||||
break;
|
||||
case 14:
|
||||
$report =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_hasil_cytologi_email.rptdesign&__format=pdf&username=admin&PID=" .
|
||||
$orderID .
|
||||
$ts;
|
||||
break;
|
||||
case 15:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 16:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 17:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 19:
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
}
|
||||
if ($report != "-") {
|
||||
$result[] = [
|
||||
"name" => $xname,
|
||||
"groupID" => $gid,
|
||||
"url" => $report,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode(["status" => "OK", "data" => $result]);
|
||||
}
|
||||
|
||||
function merge($orderHeaderID, $lang = 1, $rpt = "lab")
|
||||
{
|
||||
$sql = "select T_OrderHeaderLabNumber,T_OrderHeaderLabNumberExt,M_PatientName
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderID = ?
|
||||
and T_OrderHeaderM_PatientID = M_PatientID";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
$output_file_name = $orderHeaderID . "-" . $rpt . ".pdf";
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$output_file_name =
|
||||
$rows[0]["T_OrderHeaderLabNumberExt"] . "-" . $rpt . ".pdf";
|
||||
}
|
||||
}
|
||||
$fnames = [];
|
||||
$target = tempnam("/xtmp", uniqid("target", true)) . ".pdf";
|
||||
$merge_cmd = "/usr/bin/pdfunite";
|
||||
$base_url = "http://localhost/";
|
||||
$fnames_del = [];
|
||||
if (strpos($rpt, "lab") !== false) {
|
||||
$fname = tempnam("/xtmp", uniqid("src", true)) . ".pdf";
|
||||
$url =
|
||||
$base_url .
|
||||
"/birt/frameset?__report=report/one/lab/rpt_test_email.rptdesign&__format=pdf&username=Administrator&PID=" .
|
||||
$orderHeaderID .
|
||||
"&tm=" .
|
||||
date("Ymdhnis");
|
||||
$rpt_data = file_get_contents($url);
|
||||
file_put_contents($fname, $rpt_data);
|
||||
$merge_cmd .= " $fname ";
|
||||
$fnames_del[] = $fname;
|
||||
}
|
||||
if (strpos($rpt, "xray") !== false) {
|
||||
$fname = tempnam("/xtmp", uniqid("src", true)) . ".pdf";
|
||||
$url =
|
||||
$base_url .
|
||||
"/birt/run?__report=report/one/lab/rpt_hasil_so_xray_email.rptdesign&__format=pdf&username=Administrator&PID=" .
|
||||
$orderHeaderID .
|
||||
"&PLang=" .
|
||||
$lang .
|
||||
"&tm=" .
|
||||
date("Ymdhnis");
|
||||
$rpt_data = file_get_contents($url);
|
||||
file_put_contents($fname, $rpt_data);
|
||||
$merge_cmd .= " $fname ";
|
||||
$fnames_del[] = $fname;
|
||||
}
|
||||
if (strpos($rpt, "ecg") !== false) {
|
||||
$ecgID = 0;
|
||||
$sql = "select * from so_resultentry
|
||||
where So_ResultEntryT_OrderHeaderID=?
|
||||
and So_ResultEntryIsActive = 'Y'
|
||||
and So_ResultEntrySo_TemplateName = 'ECG'";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$ecgID = $rows[0]["So_ResultEntryID"];
|
||||
}
|
||||
}
|
||||
if ($ecgID > 0) {
|
||||
$fname = tempnam("/xtmp", uniqid("src", true)) . ".pdf";
|
||||
$url =
|
||||
$base_url .
|
||||
"/birt/run?__report=report/one/lab/rpt_hasil_so_elmd_email.rptdesign&__format=pdf&username=Administrator&PID=" .
|
||||
$ecgID .
|
||||
"&PLang=" .
|
||||
$lang .
|
||||
"&tm=" .
|
||||
date("Ymdhnis");
|
||||
$rpt_data = file_get_contents($url);
|
||||
file_put_contents($fname, $rpt_data);
|
||||
$merge_cmd .= " $fname ";
|
||||
$fnames_del[] = $fname;
|
||||
}
|
||||
}
|
||||
$merge_cmd .= " $target";
|
||||
$output = [];
|
||||
exec($merge_cmd, $output);
|
||||
header("Content-type: application/pdf");
|
||||
header(
|
||||
'Content-Disposition: attachment; filename="' .
|
||||
$output_file_name .
|
||||
'"'
|
||||
);
|
||||
echo file_get_contents($target);
|
||||
foreach ($fnames_del as $fdel) {
|
||||
unlink($fdel);
|
||||
}
|
||||
if (file_exists($target)) {
|
||||
unlink($target);
|
||||
}
|
||||
exit();
|
||||
}
|
||||
}
|
||||
?>
|
||||
644
application/controllers/Odoo.php
Normal file
644
application/controllers/Odoo.php
Normal file
@@ -0,0 +1,644 @@
|
||||
<?php
|
||||
require FCPATH . "vendor/ripcord/ripcord.php";
|
||||
require FCPATH . "vendor/ripcord/ripcord_client.php";
|
||||
|
||||
class Odoo extends MY_Controller
|
||||
{
|
||||
var $db_odoo, $url, $username, $uid, $model, $password, $common;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->url = "https://odoo.sismedika.online";
|
||||
$this->db_odoo = "odoo16_sismedika";
|
||||
$this->username = "admin@sismedika.com";
|
||||
$this->password = "duD#Z36qH5ctmRRD";
|
||||
$this->common = ripcord::client("{$this->url}/xmlrpc/2/common");
|
||||
$this->uid = $this->common->authenticate($this->db_odoo, $this->username, $this->password, array());
|
||||
$this->model = ripcord::client("{$this->url}/xmlrpc/2/object");
|
||||
$this->db->query("use one_support");
|
||||
}
|
||||
function update_task($client_id = 2)
|
||||
{
|
||||
//last 60 days
|
||||
$sql = "select TicketingID,TicketingDescription,TicketingCreated,TicketingNumber
|
||||
from one_support.ticketing
|
||||
where TicketingClientID = ?
|
||||
and TicketingCreated + interval 7 day > now()
|
||||
and (
|
||||
TicketingOdooTaskID = 0
|
||||
or
|
||||
TicketingDoneDate is null
|
||||
)
|
||||
";
|
||||
$qry = $this->db->query($sql, [$client_id]);
|
||||
if (!$qry) {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
$no = $r["TicketingNumber"];
|
||||
$id = $r["TicketingID"];
|
||||
$desc = $r["TicketingDescription"];
|
||||
$taskDate = $r["TicketingCreated"];
|
||||
|
||||
$taskID = $this->task_by_tag($no);
|
||||
echo "Get Odoo TaskID $taskDate : $no => $taskID\n";
|
||||
// echo "\t$desc\n";
|
||||
if ($taskID > 0) {
|
||||
$sql = "update one_support.ticketing
|
||||
set TicketingOdooTaskID = ?
|
||||
where TicketingID = ?";
|
||||
}
|
||||
list($date, $staff) = $this->get_done($taskID);
|
||||
echo "\tDone by $staff at $date\n";
|
||||
if ($date != "") {
|
||||
$sql = "update one_support.ticketing
|
||||
set TicketingOdooTaskID = ?
|
||||
, TicketingDoneDate = ?,
|
||||
TicketingDoneStaff=?
|
||||
where TicketingID = ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$taskID,
|
||||
$date, $staff, $id
|
||||
]);
|
||||
} else {
|
||||
$qry = $this->db->query($sql, [
|
||||
$taskID,
|
||||
$id
|
||||
]);
|
||||
}
|
||||
if (!$qry) {
|
||||
echo "\tERR : " . print_r($this->db->error()) . "\n";
|
||||
}
|
||||
sleep(1);
|
||||
$date = "";
|
||||
$staff = "";
|
||||
}
|
||||
}
|
||||
function task_by_tag($tag, $project_id = 123)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_URL, "http://odoo.sismedika.online/web/dataset/call_kw/project.task/web_search_read");
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
"Cookie: frontend_lang=en_us; td_id=669b47846b8437b163a9c8d43a16c42cae2bc609; session_id=e1c224f95431fc75271cf484260586408c0757d4; cids=1; tz=asia/jakarta",
|
||||
"User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
|
||||
]);
|
||||
$param = [
|
||||
"jsonrpc" => "2.0",
|
||||
"method" => "call",
|
||||
"params" => [
|
||||
"model" => "project.task",
|
||||
"method" => "web_search_read",
|
||||
"args" => [],
|
||||
"kwargs" => [
|
||||
"limit" => 80,
|
||||
"offset" => 0,
|
||||
"order" => "",
|
||||
"context" => [
|
||||
"lang" => "en_US",
|
||||
"tz" => "Asia/Jakarta",
|
||||
"uid" => 39,
|
||||
// "allowed_company_ids" => [
|
||||
// 1
|
||||
// ],
|
||||
"bin_size" => true,
|
||||
"active_model" => "project.project",
|
||||
"active_id" => $project_id,
|
||||
"active_ids" => [
|
||||
$project_id
|
||||
],
|
||||
"default_project_id" => $project_id,
|
||||
"show_project_update" => true,
|
||||
"create" => true,
|
||||
"active_test" => true
|
||||
],
|
||||
"count_limit" => 81,
|
||||
"domain" => [
|
||||
"&",
|
||||
[
|
||||
"display_project_id",
|
||||
"=",
|
||||
$project_id
|
||||
],
|
||||
"|",
|
||||
[
|
||||
"name",
|
||||
"ilike",
|
||||
"$tag"
|
||||
],
|
||||
[
|
||||
"id",
|
||||
"ilike",
|
||||
"$tag"
|
||||
]
|
||||
],
|
||||
"fields" => [
|
||||
"name",
|
||||
"project_id",
|
||||
"tag_ids"
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($param));
|
||||
$response = curl_exec($ch);
|
||||
$taskID = 0;
|
||||
if (curl_errno($ch)) {
|
||||
echo json_encode(["status" => "ERR", "message" => curl_error($ch)]);
|
||||
} else {
|
||||
$resp = json_decode($response, true);
|
||||
if ($resp["result"]["length"] > 0) {
|
||||
$taskID = $resp["result"]["records"][0]["id"];
|
||||
}
|
||||
}
|
||||
curl_close($ch);
|
||||
return $taskID;
|
||||
}
|
||||
function get_done($task_id)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_URL, "http://odoo.sismedika.online/mail/thread/messages");
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
"Cookie: frontend_lang=en_us; td_id=669b47846b8437b163a9c8d43a16c42cae2bc609; session_id=e1c224f95431fc75271cf484260586408c0757d4; cids=1; tz=asia/jakarta",
|
||||
"User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
|
||||
]);
|
||||
$data = [
|
||||
"jsonrpc" => "2.0",
|
||||
"method" => "call",
|
||||
"params" => [
|
||||
"thread_id" => $task_id,
|
||||
"thread_model" => "project.task",
|
||||
"limit" => 30
|
||||
]
|
||||
];
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
return ["", ""];
|
||||
echo json_encode(["status" => "ERR", "message" => curl_error($ch)]);
|
||||
} else {
|
||||
$resp = json_decode($response, true);
|
||||
$date = "";
|
||||
$staff = "";
|
||||
foreach ($resp["result"] as $r) {
|
||||
foreach ($r["trackingValues"] as $t) {
|
||||
if ($t["changedField"] == "Stage") {
|
||||
if ($t["newValue"]["value"] == "IMPLEMENTATION") {
|
||||
$date = $r["date"];
|
||||
$staff = $r["email_from"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($date != "") break;
|
||||
}
|
||||
}
|
||||
if ($date != "") {
|
||||
// echo json_encode(["status" => "OK", "date" => $date, "by" => $staff]);
|
||||
return [$date, $staff];
|
||||
exit;
|
||||
}
|
||||
return ["", ""];
|
||||
echo $response;
|
||||
}
|
||||
curl_close($ch);
|
||||
}
|
||||
function test_implementation($project_id = 70)
|
||||
{
|
||||
$sdate = "2024-07-03 00:00:00";
|
||||
$edate = "2024-07-03 23:59:59";
|
||||
$arg = array();
|
||||
$kwarg = array(
|
||||
"limit" => 10,
|
||||
"offset" => 0,
|
||||
"order" => "",
|
||||
"count_limit" => 11,
|
||||
"fields" => [
|
||||
"id",
|
||||
"name",
|
||||
"description",
|
||||
],
|
||||
//"domain"=>[["stage_id","ilike","implementation"]]
|
||||
// "domain"
|
||||
);
|
||||
$resp = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
"project.task",
|
||||
"web_search_read",
|
||||
array(array(
|
||||
"&",
|
||||
["display_project_id", "=", $project_id],
|
||||
"&",
|
||||
["date_last_stage_update", ">=", $sdate],
|
||||
"&",
|
||||
["date_last_stage_update", "<=", $edate],
|
||||
["stage_id", "ilike", "implementation"]
|
||||
)),
|
||||
$kwarg
|
||||
);
|
||||
echo "$sdate : $edate\n";
|
||||
print_r($resp);
|
||||
}
|
||||
function get_implementation_v2($project_id = 70, $stage = "", $date = "")
|
||||
{
|
||||
if ($date == "") $date = date("Y-m-d");
|
||||
$sdate = $date . " 00:00:00";
|
||||
$edate = $date . " 23:59:59";
|
||||
if ($stage == "") $date = "x";
|
||||
if ($date == "x") {
|
||||
$sdate = "2024-01-01 00:00:00";
|
||||
$edate = "2024-08-07 23:59:59";
|
||||
}
|
||||
$arg = array();
|
||||
$kwarg = array(
|
||||
"limit" => 10,
|
||||
"offset" => 0,
|
||||
"order" => "",
|
||||
"count_limit" => 11,
|
||||
"fields" => [
|
||||
"id",
|
||||
"name",
|
||||
"description",
|
||||
],
|
||||
//"domain"=>[["stage_id","ilike","implementation"]]
|
||||
// "domain"
|
||||
);
|
||||
if ($stage == "") {
|
||||
echo "$sdate | $edate | $project_id\n";
|
||||
$resp = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
"project.task",
|
||||
"web_search_read",
|
||||
array(array(
|
||||
"&",
|
||||
["display_project_id", "=", intval($project_id)],
|
||||
"&",
|
||||
["date_last_stage_update", ">=", $sdate],
|
||||
["date_last_stage_update", "<=", $edate]
|
||||
)),
|
||||
$kwarg
|
||||
);
|
||||
} else {
|
||||
$resp = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
"project.task",
|
||||
"web_search_read",
|
||||
array(array(
|
||||
"&",
|
||||
["display_project_id", "=", intval($project_id)],
|
||||
"&",
|
||||
["date_last_stage_update", ">=", $sdate],
|
||||
"&",
|
||||
["date_last_stage_update", "<=", $edate],
|
||||
["stage_id", "ilike", $stage]
|
||||
)),
|
||||
$kwarg
|
||||
);
|
||||
}
|
||||
print_r($resp);
|
||||
exit;
|
||||
$arr_ticket = [];
|
||||
if (isset($resp["records"])) {
|
||||
foreach ($resp["records"] as $r) {
|
||||
$desc = $r["description"];
|
||||
$name = $r["name"];
|
||||
$id = $r["id"];
|
||||
$tiket = "";
|
||||
if (preg_match("/ No. Tiket : <b>(.+)<\/b><br> Cabang/", $desc, $match)) {
|
||||
$tiket = $match[1];
|
||||
if (in_array($tiket, $arr_ticket)) {
|
||||
echo date("Y-m-d H:i:s") . " Ticket # $tiket duplicate \n";
|
||||
continue;
|
||||
}
|
||||
$arr_ticket[] = $tiket;
|
||||
}
|
||||
if ($tiket != "") {
|
||||
$rec = $this->get_ticketing($tiket);
|
||||
if ($rec["TicketingStatus"] != "IMPLEMENTATION") {
|
||||
$ticketID = $rec["TicketingID"];
|
||||
$sender = $rec["TicketingSender"];
|
||||
$cabang = $rec["M_BranchName"];
|
||||
$hasil = "";
|
||||
if (preg_match("/(Hasil.*:.+)/", $desc, $match)) {
|
||||
$hasil = strip_tags($match[1]);
|
||||
$hasil = str_replace(" ", "", $hasil);
|
||||
}
|
||||
$impl_msg = "
|
||||
Pengirim : $sender
|
||||
No. Tiket : $tiket
|
||||
Issue : $name
|
||||
Cabang : $cabang
|
||||
Status : Selesai
|
||||
$hasil
|
||||
|
||||
Silahkan di cek kembali
|
||||
Terima Kasih\n";
|
||||
echo date("Y-m-d H:i:s") . " Done Ticket # $tiket from $sender \n";
|
||||
$this->wa_to_sasone_done($impl_msg, $project_id);
|
||||
$this->update_ticketing($ticketID, "IMPLEMENTATION", $ticketID);
|
||||
sleep(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function get_implementation($project_id = 70, $date = "")
|
||||
{
|
||||
if ($date == "" || $date = "-") $date = date("Y-m-d");
|
||||
$sdate = $date . " 00:00:00";
|
||||
$edate = $date . " 23:59:59";
|
||||
$arg = array();
|
||||
$project_id = intval($project_id);
|
||||
$kwarg = array(
|
||||
"limit" => 10,
|
||||
"offset" => 0,
|
||||
"order" => "",
|
||||
"count_limit" => 11,
|
||||
"fields" => [
|
||||
"id",
|
||||
"name",
|
||||
"description",
|
||||
],
|
||||
//"domain"=>[["stage_id","ilike","implementation"]]
|
||||
// "domain"
|
||||
);
|
||||
$resp = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
"project.task",
|
||||
"web_search_read",
|
||||
array(array(
|
||||
"&",
|
||||
["display_project_id", "=", $project_id],
|
||||
"&",
|
||||
["date_last_stage_update", ">=", $sdate],
|
||||
"&",
|
||||
["date_last_stage_update", "<=", $edate],
|
||||
["stage_id", "ilike", "implementation"]
|
||||
)),
|
||||
$kwarg
|
||||
);
|
||||
$arr_ticket = [];
|
||||
if (isset($resp["records"])) {
|
||||
foreach ($resp["records"] as $r) {
|
||||
$desc = $r["description"];
|
||||
$name = $r["name"];
|
||||
$id = $r["id"];
|
||||
$tiket = "";
|
||||
if (preg_match("/ No. Tiket : <b>(.+)<\/b><br> Cabang/", $desc, $match)) {
|
||||
$tiket = $match[1];
|
||||
if (in_array($tiket, $arr_ticket)) {
|
||||
echo date("Y-m-d H:i:s") . " Ticket # $tiket duplicate \n";
|
||||
continue;
|
||||
}
|
||||
$arr_ticket[] = $tiket;
|
||||
}
|
||||
if ($tiket != "") {
|
||||
$rec = $this->get_ticketing($tiket);
|
||||
if ($rec["TicketingStatus"] != "IMPLEMENTATION") {
|
||||
$ticketID = $rec["TicketingID"];
|
||||
$sender = $rec["TicketingSender"];
|
||||
$cabang = $rec["M_BranchName"];
|
||||
$hasil = "";
|
||||
if (preg_match("/(Hasil.*:.+)/", $desc, $match)) {
|
||||
$hasil = strip_tags($match[1]);
|
||||
$hasil = str_replace(" ", "", $hasil);
|
||||
}
|
||||
$impl_msg = "
|
||||
Pengirim : $sender
|
||||
No. Tiket : $tiket
|
||||
Issue : $name
|
||||
Cabang : $cabang
|
||||
Status : Selesai
|
||||
$hasil
|
||||
|
||||
Silahkan di cek kembali
|
||||
Terima Kasih\n";
|
||||
echo date("Y-m-d H:i:s") . " Done Ticket # $tiket from $sender \n";
|
||||
$this->wa_to_sasone_done($impl_msg, $project_id);
|
||||
$this->update_ticketing($ticketID, "IMPLEMENTATION", $ticketID);
|
||||
sleep(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function get_message($taskID)
|
||||
{
|
||||
$arg = [
|
||||
"thread_id" => $taskID,
|
||||
"thread_model" => "project_task",
|
||||
"limit" => 30
|
||||
];
|
||||
$resp = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
"mail.thread",
|
||||
"read",
|
||||
array($arg)
|
||||
);
|
||||
print_r($resp);
|
||||
}
|
||||
function wa_to_sasone_done(
|
||||
$msg,
|
||||
$project_id = 70
|
||||
) {
|
||||
$this->load->library("Wa_sas");
|
||||
//$hp = "6287823783747";
|
||||
//$hp="6282113702602-1584412485@g.us";
|
||||
//bisone supporter
|
||||
$hp = "6281328282909-1583223560@g.us";
|
||||
if ($project_id != 70) {
|
||||
//sasone
|
||||
//6282113702602-1584412485
|
||||
$hp = "6282113702602-1584412485@g.us";
|
||||
if ($project_id == 123) {
|
||||
//hore
|
||||
$hp = "120363280846797029@g.us";
|
||||
}
|
||||
}
|
||||
$resp = $this->wa_sas->send_message($hp, $msg, true);
|
||||
// print_r($resp);
|
||||
}
|
||||
function update_ticketing($ticketID, $status, $taskID)
|
||||
{
|
||||
$sql = "update ticketing set TicketingStatus = ?,
|
||||
TicketingOdooTaskID=?
|
||||
where ticketingID = ?";
|
||||
$qry = $this->db->query($sql, [$status, $taskID, $taskID]);
|
||||
if (!$qry) {
|
||||
echo "Error update ticketing $ticketID\n";
|
||||
exit;
|
||||
}
|
||||
echo $this->db->last_query() . "\n";
|
||||
}
|
||||
function get_ticketing($tiket)
|
||||
{
|
||||
$sql = "select TicketingID,TicketingStatus ,
|
||||
M_BranchName, TicketingSender
|
||||
from
|
||||
ticketing
|
||||
join m_branch on TicketingM_BranchCode = M_BranchCode
|
||||
and TicketingNumber = ?
|
||||
";
|
||||
$qry = $this->db->query($sql, [$tiket]);
|
||||
if (!$qry) {
|
||||
echo "Error get ticketing $tiket\n";
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "Error get ticketing $tiket\n";
|
||||
exit;
|
||||
}
|
||||
return $rows[0];
|
||||
}
|
||||
function create_ts()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$date = $prm["date"];
|
||||
$time = $prm["time"];
|
||||
$employee_id = $prm["employee_id"];
|
||||
$task_id = $prm["task_id"];
|
||||
$project_id = $prm["project_id"];
|
||||
$description = $prm["description"];
|
||||
|
||||
$arg = array(
|
||||
"name" => $description,
|
||||
"date" => $date,
|
||||
"unit_amount" => $time,
|
||||
"user_id" => $this->uid,
|
||||
"task_id" => $task_id,
|
||||
"project_id" => $project_id,
|
||||
"employee_id" => $employee_id
|
||||
);
|
||||
|
||||
$resp = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
"account.analytic.line",
|
||||
"create",
|
||||
array($arg)
|
||||
);
|
||||
print_r($resp);
|
||||
if (!is_numeric($resp)) {
|
||||
echo json_encode(["status" => "ERR", "message" => json_encode($resp)]);
|
||||
} else {
|
||||
echo json_encode(
|
||||
[
|
||||
"status" => "OK",
|
||||
"ts_id" => $resp
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
function create_task()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$title = $prm["title"];
|
||||
$description = $prm["description"];
|
||||
$project_id = $prm["project_id"];
|
||||
if ($project_id == "") $project_id = 70;
|
||||
$images = $prm["images"];
|
||||
if (is_array($images)) {
|
||||
foreach ($images as $img) {
|
||||
$description .= "<br/>" .
|
||||
"<img class=\"img-fluid\" src=\"$img\">";
|
||||
}
|
||||
}
|
||||
$users = $prm["users"];
|
||||
if ($users == "") {
|
||||
$users = [
|
||||
44,
|
||||
41,
|
||||
42
|
||||
];
|
||||
}
|
||||
$arg = array(
|
||||
"sun" => $this->bool_day("sun"),
|
||||
"mon" => $this->bool_day("mon"),
|
||||
"tue" => $this->bool_day("tue"),
|
||||
"wed" => $this->bool_day("wed"),
|
||||
"thu" => $this->bool_day("thu"),
|
||||
"fri" => $this->bool_day("fri"),
|
||||
"sat" => $this->bool_day("sat"),
|
||||
"recurrence_id" => false,
|
||||
"parent_id" => false,
|
||||
"company_id" => 1,
|
||||
"stage_id" => 443,
|
||||
"personal_stage_type_id" => false,
|
||||
"recurrence_update" => "this",
|
||||
"priority" => "0",
|
||||
"name" => "$title",
|
||||
"kanban_state" => "normal",
|
||||
"project_id" => $project_id,
|
||||
"display_project_id" => false,
|
||||
"milestone_id" => false,
|
||||
"user_ids" => [
|
||||
[
|
||||
6,
|
||||
false,
|
||||
$users
|
||||
]
|
||||
],
|
||||
"active" => true,
|
||||
"partner_id" => false,
|
||||
"partner_phone" => false,
|
||||
"date_deadline" => false,
|
||||
"tag_ids" => [
|
||||
[
|
||||
6,
|
||||
false,
|
||||
[]
|
||||
]
|
||||
],
|
||||
"task_properties" => [],
|
||||
"description" => $description,
|
||||
"planned_hours" => 0,
|
||||
"timesheet_ids" => [],
|
||||
"child_ids" => [],
|
||||
);
|
||||
$resp = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
"project.task",
|
||||
"create",
|
||||
array($arg)
|
||||
);
|
||||
if (!is_numeric($resp)) {
|
||||
echo json_encode(["status" => "ERR", "message" => json_encode($resp)]);
|
||||
} else {
|
||||
echo json_encode(
|
||||
[
|
||||
"status" => "OK",
|
||||
"task_id" => $resp
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
function bool_day($inp_dow)
|
||||
{
|
||||
$dow = strtolower(date("D", strtotime("now")));
|
||||
if ($inp_dow == $dow) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
26
application/controllers/Or_dummy.php
Normal file
26
application/controllers/Or_dummy.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
class Or_dummy extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function svc()
|
||||
{
|
||||
$data = $this->sys_input;
|
||||
$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" => ""]);
|
||||
}
|
||||
}
|
||||
100
application/controllers/PushOrder.http
Normal file
100
application/controllers/PushOrder.http
Normal file
@@ -0,0 +1,100 @@
|
||||
POST https://devone.aplikasi.web.id/one-api/PushOrder
|
||||
|
||||
{
|
||||
"CorporateID": "46",
|
||||
"CorporateName": "PT Astra Daihatsu Motor",
|
||||
"outletId": "I",
|
||||
"BranchCode": "00000619",
|
||||
"BranchName": "Westerindo Cikarang",
|
||||
"PatientCode": "CP2407270280",
|
||||
"PatientName": "Ibu Adela Nurpadilah ",
|
||||
"PatientSexCode": "F",
|
||||
"PatientSexName": "Female",
|
||||
"PatientDOB": "2001\/08\/05",
|
||||
"PatientAdress": "CpOne Address",
|
||||
"OrderNumber": "I2410180003",
|
||||
"OrderDateTime": "2024\/10\/18 14:40:52",
|
||||
"DoctorOrderCode": "CpOne001",
|
||||
"DoctorOrderName": "Dr CpOne",
|
||||
"GuarantorID": "00000619",
|
||||
"GuarantorName": "Westerindo Cikarang",
|
||||
"AgreementID": "Cp001",
|
||||
"AgreementName": "CpOne",
|
||||
"ReceivedFlag": false,
|
||||
"LabRegNo": null,
|
||||
"ReceivedDateTime": null,
|
||||
"OrderedItems": [
|
||||
{
|
||||
"itemCode": "00000250",
|
||||
"itemName": "Glukosa Darah Puasa"
|
||||
},
|
||||
{
|
||||
"itemCode": "00000506",
|
||||
"itemName": "Urine Lengkap"
|
||||
},
|
||||
{
|
||||
"itemCode": "00000686",
|
||||
"itemName": "Hematologi Lengkap"
|
||||
},
|
||||
{
|
||||
"itemCode": "00001598",
|
||||
"itemName": "Panel Creatinin"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
### Error orderNumber mengandung 3
|
||||
POST https://devone.aplikasi.web.id/one-api/PushOrder
|
||||
|
||||
{
|
||||
"outletId": "02",
|
||||
"orderNumber": "131112^02",
|
||||
"orderDT": "2022/04/14 01:01:01",
|
||||
"visitNumber": "111111^02",
|
||||
"patientId": "00-01-02-03",
|
||||
"patientName": "Tn. COBA",
|
||||
"sexId": "1",
|
||||
"sexName": "Male",
|
||||
"dob": "2019/01/23",
|
||||
"addressName": "Mid o Nowhere 23, Neverland",
|
||||
"cityId": "0001",
|
||||
"cityName": "Neverland",
|
||||
"mobileNumber": "+6281818181818",
|
||||
"phoneNumber": "+62212345678",
|
||||
"faxNumber": "",
|
||||
"email": "coba@gmail.com",
|
||||
"idNIK": "31750000000000005",
|
||||
"idSIM": "",
|
||||
"idPassport": "",
|
||||
"physicianId": "02-ZZA",
|
||||
"physicianName": "Dr. Stein",
|
||||
"isCito": "0",
|
||||
"diagnoseId": "Z0101",
|
||||
"diagnoseName": "Nama Diagnosa",
|
||||
"guarantorId": "GG",
|
||||
"guarantorName": "PRIVATE",
|
||||
"agreementId": "X01",
|
||||
"agreementName": "InsuranceX VIP",
|
||||
"serviceUnitId": "OP",
|
||||
"serviceUnitName": "Out Patient",
|
||||
"wardPoliId": "P01",
|
||||
"wardPoliName": "Poli Umum",
|
||||
"roomId": "R01",
|
||||
"roomName": "Ruang Alamanda",
|
||||
"bedId": "B01",
|
||||
"bedName": "Bed 01",
|
||||
"classId": "0001",
|
||||
"className": "VIP Class",
|
||||
"regUserId": "S1234",
|
||||
"regUserName": "Rafaela",
|
||||
"orderItemList": [
|
||||
{
|
||||
"OrderItemId": "2792",
|
||||
"OrderItemName": "PCR SARS-COV-2 H+1 B2C"
|
||||
},
|
||||
{
|
||||
"OrderItemId": "2234",
|
||||
"OrderItemName": "Glukosa sewaktu"
|
||||
}
|
||||
]
|
||||
}
|
||||
44
application/controllers/PushOrder.php
Normal file
44
application/controllers/PushOrder.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
class PushOrder extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function index()
|
||||
{
|
||||
$body = file_get_contents("php://input");
|
||||
$sql = "insert into xone.cpone_order(date,data) values(now(),?)";
|
||||
$qry = $this->db->query($sql, [$body]);
|
||||
$jbody = json_decode($body, true);
|
||||
//print_r($jbody);
|
||||
//exit;
|
||||
$outletId = $jbody["outletId"];
|
||||
$nolab = $jbody["OrderNumber"];
|
||||
// echo $nolab;
|
||||
|
||||
|
||||
$receivedDT = Date("Y/m/d h:i:s");
|
||||
if (strpos($nolab, "3") !== false) {
|
||||
$resp = [
|
||||
"status" => 1,
|
||||
"message" => "ERROR",
|
||||
"outletId" => $outletId,
|
||||
"orderNumber" => $nolab,
|
||||
"lisRegNo" => "x-lis-" . $nolab,
|
||||
"receivedDT" => $receivedDT
|
||||
];
|
||||
} else {
|
||||
|
||||
$resp = [
|
||||
"status" => 0,
|
||||
"message" => "SUCCESS",
|
||||
"outletId" => $outletId,
|
||||
"orderNumber" => $nolab,
|
||||
"lisRegNo" => "x-lis-" . $nolab,
|
||||
"receivedDT" => $receivedDT
|
||||
];
|
||||
}
|
||||
echo json_encode($resp);
|
||||
}
|
||||
}
|
||||
42
application/controllers/Random_saran.php
Normal file
42
application/controllers/Random_saran.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
class Random_saran extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function upload()
|
||||
{
|
||||
//upload ke s3
|
||||
global $_FILES;
|
||||
$name = $_FILES["file"]["name"];
|
||||
$type = $_FILES["file"]["type"];
|
||||
$xid = $_POST["xid"];
|
||||
$tmp_name = $_FILES["file"]["tmp_name"];
|
||||
$a_ext = explode("\\", $type);
|
||||
$ext = "ogg";
|
||||
if (count($a_ext) > 1) {
|
||||
$ext = $a_ext[1];
|
||||
}
|
||||
$fname = "$xid.$ext";
|
||||
$this->load->library("Sas_s3");
|
||||
$resp = $this->sas_s3->upload("audio-sample", "$xid.{$ext}", $type, file_get_contents($tmp_name));
|
||||
if ($resp['@metadata']['statusCode'] == 200) {
|
||||
echo json_encode(["status" => "OK", "result" => "file $name of $type ulded to s3 $xid.ogg "]);
|
||||
};
|
||||
}
|
||||
function index()
|
||||
{
|
||||
$sql = "select concat(Mcu_ResumeKesimpulan, ' Untuk itu disarankan ',
|
||||
Mcu_ResumeSaran) text
|
||||
from
|
||||
mcu_resume
|
||||
where length(Mcu_ResumeSaran) > 20
|
||||
and length(Mcu_ResumeSaran) > 20
|
||||
order by rand()
|
||||
limit 0, 1 ";
|
||||
$qry = $this->db->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode(["status" => "OK", "data" => $rows]);
|
||||
}
|
||||
}
|
||||
856
application/controllers/Search.php
Normal file
856
application/controllers/Search.php
Normal file
@@ -0,0 +1,856 @@
|
||||
<?php
|
||||
class Search extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo "Api: Training Playground";
|
||||
}
|
||||
|
||||
function instrument_byname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$param = $this->sys_input;
|
||||
$page = $param["page"];
|
||||
|
||||
// check input parameter
|
||||
$control = "";
|
||||
if (isset($param['control'])) {
|
||||
$control = trim($param["control"]);
|
||||
if ($control != "") {
|
||||
$control = '%' . $param['control'] . '%';
|
||||
}
|
||||
}
|
||||
$test = "";
|
||||
if (isset($param['test'])) {
|
||||
$test = trim($param["test"]);
|
||||
if ($test != "") {
|
||||
$test = '%' . $param['test'] . '%';
|
||||
}
|
||||
}
|
||||
$instrument = trim($param['instrument']);
|
||||
$instrument = "%" . $instrument . "%";
|
||||
|
||||
// hitung start_offset
|
||||
$ROW_PER_PAGE = 10;
|
||||
$start_offset = 0;
|
||||
if (isset($param["page"])) {
|
||||
if (is_numeric((int)$param["page"]) && $param["page"] > 0) {
|
||||
$start_offset = ($page - 1) * $ROW_PER_PAGE;
|
||||
}
|
||||
}
|
||||
//query
|
||||
if (
|
||||
$control == "" && $test == ""
|
||||
) {
|
||||
$sql = "select distinct Nat_InstrumentID, Nat_InstrumentName
|
||||
from
|
||||
nat_instrument
|
||||
join t_instrument_local on Nat_InstrumentID = T_InstrumentLocalNat_InstrumentID
|
||||
and Nat_InstrumentIsActive = 'Y' and T_InstrumentLocalIsActive = 'Y'
|
||||
and Nat_InstrumentName like ?
|
||||
join nat_qc on Nat_instrumentID = Nat_QcNat_InstrumentID
|
||||
and Nat_QcIsActive = 'Y'
|
||||
limit 10 offset ?";
|
||||
$qry = $this->db->query($sql, [$instrument, $start_offset]);
|
||||
$last_qry = $this->db->last_query();
|
||||
$count = "select count(distinct Nat_InstrumentID) as total
|
||||
from
|
||||
nat_instrument
|
||||
join t_instrument_local on Nat_InstrumentID = T_InstrumentLocalNat_InstrumentID
|
||||
and Nat_InstrumentIsActive = 'Y' and T_InstrumentLocalIsActive = 'Y'
|
||||
and Nat_InstrumentName like ?
|
||||
join nat_qc on Nat_instrumentID = Nat_QcNat_InstrumentID
|
||||
and Nat_QcIsActive = 'Y'";
|
||||
$qry_total_filter = $this->db->query($count, [$instrument]);
|
||||
$last_qry_total_filter = $this->db->last_query();
|
||||
} else if (
|
||||
$control != "" && $test == ""
|
||||
) {
|
||||
$sql = "select distinct Nat_InstrumentID, Nat_InstrumentName
|
||||
from nat_instrument
|
||||
join t_instrument_local on Nat_InstrumentID = T_InstrumentLocalNat_InstrumentID
|
||||
and Nat_InstrumentIsActive = 'Y'
|
||||
and T_InstrumentLocalIsActive = 'Y'
|
||||
and Nat_InstrumentName like ?
|
||||
join nat_qc on Nat_instrumentID = Nat_QcNat_InstrumentID
|
||||
and Nat_QcIsActive = 'Y'
|
||||
join nat_qc_control on Nat_QcNat_QcControlID = Nat_QcControlID
|
||||
and Nat_QcControlIsActive = 'Y'
|
||||
and Nat_QcControlName like ?
|
||||
limit 10 offset ?";
|
||||
$qry = $this->db->query($sql, [$instrument, $control, $start_offset]);
|
||||
$last_qry = $this->db->last_query();
|
||||
$count = "select count(distinct Nat_InstrumentID) as total
|
||||
from nat_instrument
|
||||
join t_instrument_local on Nat_InstrumentID = T_InstrumentLocalNat_InstrumentID
|
||||
and Nat_InstrumentIsActive = 'Y'
|
||||
and T_InstrumentLocalIsActive = 'Y'
|
||||
and Nat_InstrumentName like ?
|
||||
join nat_qc on Nat_instrumentID = Nat_QcNat_InstrumentID
|
||||
and Nat_QcIsActive = 'Y'
|
||||
join nat_qc_control on Nat_QcNat_QcControlID = Nat_QcControlID
|
||||
and Nat_QcControlIsActive = 'Y'
|
||||
and Nat_QcControlName like ?
|
||||
";
|
||||
$qry_total_filter = $this->db->query($count, [$instrument, $control]);
|
||||
$last_qry_total_filter = $this->db->last_query();
|
||||
} else if (
|
||||
$control == "" && $test != ""
|
||||
) {
|
||||
$sql = "select distinct Nat_InstrumentID, Nat_InstrumentName
|
||||
from nat_instrument
|
||||
join t_instrument_local on Nat_InstrumentID = T_InstrumentLocalNat_InstrumentID
|
||||
and Nat_InstrumentIsActive = 'Y'
|
||||
and T_InstrumentLocalIsActive = 'Y'
|
||||
and Nat_InstrumentName like ?
|
||||
join nat_qc on Nat_instrumentID = Nat_QcNat_InstrumentID
|
||||
and Nat_QcIsActive = 'Y'
|
||||
join nat_test on Nat_TestID = Nat_QcNat_TestID
|
||||
and Nat_TestName like ?
|
||||
limit 10 offset ?";
|
||||
$qry =
|
||||
$this->db->query($sql, [$instrument, $test, $start_offset]);
|
||||
$last_qry = $this->db->last_query();
|
||||
$count = "select count(distinct Nat_InstrumentID) as total
|
||||
from nat_instrument
|
||||
join t_instrument_local on Nat_InstrumentID = T_InstrumentLocalNat_InstrumentID
|
||||
and Nat_InstrumentIsActive = 'Y'
|
||||
and T_InstrumentLocalIsActive = 'Y'
|
||||
and Nat_InstrumentName like ?
|
||||
join nat_qc on Nat_instrumentID = Nat_QcNat_InstrumentID
|
||||
and Nat_QcIsActive = 'Y'
|
||||
join nat_test on Nat_TestID = Nat_QcNat_TestID
|
||||
and Nat_TestName like ?
|
||||
";
|
||||
$qry_total_filter = $this->db->query($count, [$instrument, $test]);
|
||||
$last_qry_total_filter = $this->db->last_query();
|
||||
} else {
|
||||
$sql = "select distinct Nat_InstrumentID, Nat_InstrumentName
|
||||
from nat_instrument
|
||||
join t_instrument_local on Nat_InstrumentID = T_InstrumentLocalNat_InstrumentID
|
||||
and Nat_InstrumentIsActive = 'Y'
|
||||
and T_InstrumentLocalIsActive = 'Y'
|
||||
and Nat_InstrumentName like ?
|
||||
join nat_qc on Nat_instrumentID = Nat_QcNat_InstrumentID
|
||||
and Nat_QcIsActive = 'Y'
|
||||
join nat_test on Nat_TestID = Nat_QcNat_TestID
|
||||
and Nat_TestName like ?
|
||||
join nat_qc_control on Nat_QcNat_QcControlID = Nat_QcControlID
|
||||
and Nat_QcControlIsActive = 'Y'
|
||||
and Nat_QcControlName like ?
|
||||
limit 10 offset ?";
|
||||
$qry = $this->db->query($sql, [$instrument, $test, $control, $start_offset]);
|
||||
$last_qry = $this->db->last_query();
|
||||
$count = "select count(distinct Nat_InstrumentID) as total
|
||||
from nat_instrument
|
||||
join t_instrument_local on Nat_InstrumentID = T_InstrumentLocalNat_InstrumentID
|
||||
and Nat_InstrumentIsActive = 'Y'
|
||||
and T_InstrumentLocalIsActive = 'Y'
|
||||
and Nat_InstrumentName like ?
|
||||
join nat_qc on Nat_instrumentID = Nat_QcNat_InstrumentID
|
||||
and Nat_QcIsActive = 'Y'
|
||||
join nat_test on Nat_TestID = Nat_QcNat_TestID
|
||||
and Nat_TestName like ?
|
||||
join nat_qc_control on Nat_QcNat_QcControlID = Nat_QcControlID
|
||||
and Nat_QcControlIsActive = 'Y'
|
||||
and Nat_QcControlName like ?
|
||||
";
|
||||
|
||||
$qry_total_filter = $this->db->query($count, [$instrument, $test, $control]);
|
||||
$last_qry_total_filter = $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);
|
||||
exit;
|
||||
}
|
||||
if (!$qry_total_filter) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry_total_filter
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$total_filter = (int)$qry_total_filter->result_array()[0]["total"];
|
||||
|
||||
$total = ceil($total_filter / $ROW_PER_PAGE);
|
||||
$result = array(
|
||||
"total" => $total,
|
||||
"total_filter" => $total_filter,
|
||||
"records" => $rows,
|
||||
"sql" => $last_qry,
|
||||
"count" => $last_qry_total_filter
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function qc_byname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$param = $this->sys_input;
|
||||
|
||||
$page = $param["page"];
|
||||
$control = "%%";
|
||||
if (isset($param['control'])) {
|
||||
$control = trim($param["control"]);
|
||||
|
||||
if ($control != "") {
|
||||
$control = '%' . $param['control'] . '%';
|
||||
}
|
||||
}
|
||||
$instrument = "%%";
|
||||
if (isset($param['instrument'])) {
|
||||
$instrument = trim($param["instrument"]);
|
||||
if ($instrument != "") {
|
||||
$instrument = '%' . $param['instrument'] . '%';
|
||||
}
|
||||
}
|
||||
$test = "%%";
|
||||
if (isset($param['test'])) {
|
||||
$test = trim($param["test"]);
|
||||
if ($test != "") {
|
||||
$test = '%' . $param['test'] . '%';
|
||||
}
|
||||
}
|
||||
$sdate = "";
|
||||
if (isset($param['sdate'])) {
|
||||
$sdate = trim($param["sdate"]);
|
||||
if ($sdate != "") {
|
||||
$sdate = $param['sdate'];
|
||||
}
|
||||
}
|
||||
$ROW_PER_PAGE = 10;
|
||||
$start_offset = 0;
|
||||
if (isset($param["page"])) {
|
||||
if (
|
||||
is_numeric($param["page"]) && $param["page"] > 0
|
||||
) {
|
||||
$start_offset = ($page - 1) * $ROW_PER_PAGE;
|
||||
}
|
||||
}
|
||||
$sql = "select distinct M_QcID, M_QcStatMean, M_QcStatSd, M_QcStatTea,
|
||||
M_QcResultID, M_QcResultValue, M_QcResultIsInstrument , M_QcResultDate,
|
||||
Nat_QcControlID , Nat_QcControlName , Nat_InstrumentID, Nat_InstrumentName, Nat_TestID , Nat_TestName
|
||||
from m_qc_result
|
||||
join m_qc on M_QcResultM_QcID = M_QcID
|
||||
and M_QcResultDate = ?
|
||||
and M_QcResultIsActive ='Y'
|
||||
join nat_qc on M_QcNat_QcID = Nat_QcID
|
||||
and Nat_QcIsActive = 'Y'
|
||||
join nat_qc_control on Nat_QcNat_QcControlID =Nat_QcControlID
|
||||
and Nat_QcControlName like ?
|
||||
and Nat_QcControlIsActive = 'Y'
|
||||
join nat_instrument on Nat_QcNat_InstrumentID = Nat_InstrumentID
|
||||
and Nat_InstrumentName like ?
|
||||
and Nat_InstrumentIsActive = 'Y'
|
||||
join nat_test on Nat_QcNat_TestID = Nat_TestID
|
||||
and Nat_TestName like ?
|
||||
and Nat_TestIsActive = 'Y' limit 10 offset ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$sdate, $control, $instrument, $test, $start_offset
|
||||
]);
|
||||
$last_qry = $this->db->last_query();
|
||||
$count =
|
||||
"select count(distinct M_QcID) as total
|
||||
from m_qc_result
|
||||
join m_qc on M_QcResultM_QcID = M_QcID
|
||||
and M_QcResultDate = ?
|
||||
and M_QcResultIsActive ='Y'
|
||||
join nat_qc on M_QcNat_QcID = Nat_QcID
|
||||
and Nat_QcIsActive = 'Y'
|
||||
join nat_qc_control on Nat_QcNat_QcControlID =Nat_QcControlID
|
||||
and Nat_QcControlName like ?
|
||||
and Nat_QcControlIsActive = 'Y'
|
||||
join nat_instrument on Nat_QcNat_InstrumentID = Nat_InstrumentID
|
||||
and Nat_InstrumentName like ?
|
||||
and Nat_InstrumentIsActive = 'Y'
|
||||
join nat_test on Nat_QcNat_TestID = Nat_TestID
|
||||
and Nat_TestName like ?
|
||||
and Nat_TestIsActive = 'Y' ";
|
||||
$qry_total_filter =
|
||||
$this->db->query($count, [
|
||||
$sdate, $control, $instrument, $test
|
||||
]);
|
||||
$last_qry_total_filter = $this->db->last_query();
|
||||
if ($sdate == "" or $test == "") {
|
||||
echo json_encode([
|
||||
"status" => "ERR", "message" => 'test and sdate is mandatory',
|
||||
|
||||
]);
|
||||
} else {
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
if (!$qry_total_filter) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry_total_filter
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$total_filter = (int)$qry_total_filter->result_array()[0]["total"];
|
||||
|
||||
$total = ceil($total_filter / $ROW_PER_PAGE);
|
||||
$result = array(
|
||||
"total" => $total,
|
||||
"total_filter" => $total_filter,
|
||||
"records" => $rows,
|
||||
"sql" => $last_qry,
|
||||
"count" => $last_qry_total_filter
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function qc_byid()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$param = $this->sys_input;
|
||||
$page = $param["page"];
|
||||
$controlid = "";
|
||||
$instrumentid = "";
|
||||
$ROW_PER_PAGE = 10;
|
||||
$start_offset = 0;
|
||||
if (isset($param["page"])) {
|
||||
if (is_numeric($param["page"]) && $param["page"] > 0) {
|
||||
$start_offset = ($page - 1) * $ROW_PER_PAGE;
|
||||
}
|
||||
}
|
||||
if (isset($param["controlid"])) {
|
||||
if (is_numeric($param["controlid"])) {
|
||||
$controlid = $param["controlid"];
|
||||
}
|
||||
}
|
||||
if (isset($param["instrumentid"])) {
|
||||
if (is_numeric($param["instrumentid"])) {
|
||||
$instrumentid = $param["instrumentid"];
|
||||
}
|
||||
}
|
||||
$sdate = "";
|
||||
if (isset($param['sdate'])) {
|
||||
$sdate = trim($param["sdate"]);
|
||||
if ($sdate != "") {
|
||||
$sdate = $param['sdate'];
|
||||
}
|
||||
}
|
||||
$test = "%%";
|
||||
if (isset($param['test'])) {
|
||||
$test = trim($param["test"]);
|
||||
if ($test != "") {
|
||||
$test = '%' . $param['test'] . '%';
|
||||
}
|
||||
}
|
||||
$sql = "select distinct M_QcID, M_QcStatMean, M_QcStatSd, M_QcStatTea,
|
||||
M_QcResultID, M_QcResultValue, M_QcResultIsInstrument , M_QcResultDate,
|
||||
Nat_QcControlID , Nat_QcControlName , Nat_InstrumentID, Nat_InstrumentName, Nat_TestID , Nat_TestName
|
||||
from m_qc_result
|
||||
join m_qc on M_QcResultM_QcID = M_QcID
|
||||
and M_QcResultDate = ? and M_QcResultIsActive ='Y'
|
||||
join nat_qc on M_QcNat_QcID = Nat_QcID
|
||||
and Nat_QcIsActive = 'Y'
|
||||
join nat_qc_control on Nat_QcNat_QcControlID =Nat_QcControlID
|
||||
and Nat_QcControlID = ?
|
||||
and Nat_QcControlIsActive = 'Y'
|
||||
join nat_instrument on Nat_QcNat_InstrumentID = Nat_InstrumentID
|
||||
and Nat_InstrumentID = ?
|
||||
and Nat_InstrumentIsActive = 'Y'
|
||||
join nat_test on Nat_QcNat_TestID = Nat_TestID
|
||||
and Nat_TestName like ?
|
||||
and Nat_TestIsActive = 'Y' limit 10 offset ?";
|
||||
$qry = $this->db->query($sql, [$sdate, $controlid, $instrumentid, $test, $start_offset]);
|
||||
$last_qry = $this->db->last_query();
|
||||
$count = "select count(distinct M_QcID) as total
|
||||
from m_qc_result
|
||||
join m_qc on M_QcResultM_QcID = M_QcID
|
||||
and M_QcResultDate = ? and M_QcResultIsActive ='Y'
|
||||
join nat_qc on M_QcNat_QcID = Nat_QcID
|
||||
and Nat_QcIsActive = 'Y'
|
||||
join nat_qc_control on Nat_QcNat_QcControlID =Nat_QcControlID
|
||||
and Nat_QcControlID = ?
|
||||
and Nat_QcControlIsActive = 'Y'
|
||||
join nat_instrument on Nat_QcNat_InstrumentID = Nat_InstrumentID
|
||||
and Nat_InstrumentID = ?
|
||||
and Nat_InstrumentIsActive = 'Y'
|
||||
join nat_test on Nat_QcNat_TestID = Nat_TestID
|
||||
and Nat_TestName like ?
|
||||
and Nat_TestIsActive = 'Y'";
|
||||
$qry_total_filter = $this->db->query($count, [$sdate, $controlid, $instrumentid, $test]);
|
||||
$last_qry_total_filter = $this->db->last_query();
|
||||
if ($controlid == "" or $instrumentid == "" or $sdate == "") {
|
||||
echo json_encode([
|
||||
"status" => "ERR", "message" => 'control, instrument, and sdate is mandatory',
|
||||
]);
|
||||
} else {
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$qry_total_filter) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry_total_filter
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$total_filter = (int)$qry_total_filter->result_array()[0]["total"];
|
||||
|
||||
$total = ceil($total_filter / $ROW_PER_PAGE);
|
||||
$result = array(
|
||||
"total" => $total,
|
||||
"total_filter" => $total_filter,
|
||||
"records" => $rows,
|
||||
"sql" => $last_qry,
|
||||
"count" => $last_qry_total_filter
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function control_byname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$param = $this->sys_input;
|
||||
// $page = 0;
|
||||
$page = $param['page'];
|
||||
|
||||
// check input parameter
|
||||
|
||||
// mandatory
|
||||
$control = trim($param['control']);
|
||||
$control = "%" . $control . "%";
|
||||
|
||||
// tidak mandatory
|
||||
$instrument = "";
|
||||
if (isset($param['instrument'])) {
|
||||
$instrument = trim($param["instrument"]);
|
||||
if ($instrument != "") {
|
||||
$instrument = '%' . $param['instrument'] . '%';
|
||||
}
|
||||
}
|
||||
$test = "";
|
||||
if (isset($param['test'])) {
|
||||
$test = trim($param["test"]);
|
||||
if ($test != "") {
|
||||
$test = '%' . $param['test'] . '%';
|
||||
}
|
||||
}
|
||||
|
||||
// hitung start_offset
|
||||
$ROW_PER_PAGE = 10;
|
||||
$start_offset = 0;
|
||||
if (isset($param["page"])) {
|
||||
if (is_numeric($param["page"]) && $param['page'] > 0) {
|
||||
$start_offset = ($page - 1) * $ROW_PER_PAGE;
|
||||
}
|
||||
}
|
||||
|
||||
// query
|
||||
if ($instrument == "" && $test == "") {
|
||||
$sql = "select
|
||||
distinct Nat_QcControlID,
|
||||
Nat_QcControlName,
|
||||
Nat_QcControlLotNumber,
|
||||
Nat_QcControlExpired,
|
||||
Nat_QcLevelID,
|
||||
Nat_QcLevelName
|
||||
from nat_qc_control
|
||||
join nat_qc_level
|
||||
ON Nat_QcControlNat_QcLevelID = Nat_QcLevelID
|
||||
AND Nat_QcControlIsActive = 'Y'
|
||||
AND Nat_QcLevelIsActive = 'Y'
|
||||
AND Nat_QcControlName like ?
|
||||
limit 10 offset ?";
|
||||
$qry = $this->db->query($sql, [$control, $start_offset]);
|
||||
$last_query = $this->db->last_query();
|
||||
|
||||
$sql_total_filter = "select
|
||||
count(distinct Nat_QcControlID,
|
||||
Nat_QcControlName,
|
||||
Nat_QcControlLotNumber,
|
||||
Nat_QcControlExpired,
|
||||
Nat_QcLevelID,
|
||||
Nat_QcLevelName) as total_filter
|
||||
from nat_qc_control
|
||||
join nat_qc_level
|
||||
ON Nat_QcControlNat_QcLevelID = Nat_QcLevelID
|
||||
AND Nat_QcControlIsActive = 'Y'
|
||||
AND Nat_QcLevelIsActive = 'Y'
|
||||
AND Nat_QcControlName like ?";
|
||||
$qry_total_filter = $this->db->query($sql_total_filter, [$control]);
|
||||
$last_query_total_filter = $this->db->last_query();
|
||||
} else if ($instrument !== "" && $test == "") {
|
||||
// instrument terisi dan tes kosong
|
||||
$sql = "select
|
||||
distinct Nat_QcControlID,
|
||||
Nat_QcControlName,
|
||||
Nat_QcControlLotNumber,
|
||||
Nat_QcControlExpired,
|
||||
Nat_QcLevelID,
|
||||
Nat_QcLevelName
|
||||
from nat_qc_control
|
||||
join nat_qc_level
|
||||
ON Nat_QcControlNat_QcLevelID = Nat_QcLevelID
|
||||
AND Nat_QcControlIsActive = 'Y'
|
||||
AND Nat_QcLevelIsActive = 'Y'
|
||||
AND Nat_QcControlName like ?
|
||||
join nat_qc
|
||||
ON Nat_QcControlID = Nat_QcNat_QcControlID
|
||||
AND Nat_QcIsActive = 'Y'
|
||||
join nat_instrument
|
||||
ON Nat_QcNat_InstrumentID = Nat_InstrumentID
|
||||
AND Nat_InstrumentIsActive = 'Y'
|
||||
AND Nat_InstrumentName like ?
|
||||
limit 10 offset ?";
|
||||
$qry = $this->db->query($sql, [$control, $instrument, $start_offset]);
|
||||
$last_query = $this->db->last_query();
|
||||
|
||||
$sql_total_filter = "select
|
||||
count(distinct Nat_QcControlID,
|
||||
Nat_QcControlName,
|
||||
Nat_QcControlLotNumber,
|
||||
Nat_QcControlExpired,
|
||||
Nat_QcLevelID,
|
||||
Nat_QcLevelName) as total_filter
|
||||
from nat_qc_control
|
||||
join nat_qc_level
|
||||
ON Nat_QcControlNat_QcLevelID = Nat_QcLevelID
|
||||
AND Nat_QcControlIsActive = 'Y'
|
||||
AND Nat_QcLevelIsActive = 'Y'
|
||||
AND Nat_QcControlName like ?
|
||||
join nat_qc
|
||||
ON Nat_QcControlID = Nat_QcNat_QcControlID
|
||||
AND Nat_QcIsActive = 'Y'
|
||||
join nat_instrument
|
||||
ON Nat_QcNat_InstrumentID = Nat_InstrumentID
|
||||
AND Nat_InstrumentIsActive = 'Y'
|
||||
AND Nat_InstrumentName like ?";
|
||||
$qry_total_filter = $this->db->query($sql_total_filter, [$control, $instrument]);
|
||||
$last_query_total_filter = $this->db->last_query();
|
||||
} else if ($instrument == "" && $test !== "") {
|
||||
// instrument kosong dan tes terisi
|
||||
$sql = "select
|
||||
distinct Nat_QcControlID,
|
||||
Nat_QcControlName,
|
||||
Nat_QcControlLotNumber,
|
||||
Nat_QcControlExpired,
|
||||
Nat_QcLevelID,
|
||||
Nat_QcLevelName
|
||||
from nat_qc_control
|
||||
join nat_qc_level
|
||||
ON Nat_QcControlNat_QcLevelID = Nat_QcLevelID
|
||||
AND Nat_QcControlIsActive = 'Y'
|
||||
AND Nat_QcLevelIsActive = 'Y'
|
||||
AND Nat_QcControlName like ?
|
||||
join nat_qc
|
||||
ON Nat_QcControlID = Nat_QcNat_QcControlID
|
||||
AND Nat_QcIsActive = 'Y'
|
||||
join nat_test
|
||||
ON Nat_QcNat_TestID = Nat_TestID
|
||||
AND Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestName like ?
|
||||
limit 10 offset ?";
|
||||
$qry = $this->db->query($sql, [$control, $test, $start_offset]);
|
||||
$last_query = $this->db->last_query();
|
||||
|
||||
$sql_total_filter = "select
|
||||
count(distinct Nat_QcControlID,
|
||||
Nat_QcControlName,
|
||||
Nat_QcControlLotNumber,
|
||||
Nat_QcControlExpired,
|
||||
Nat_QcLevelID,
|
||||
Nat_QcLevelName) as total_filter
|
||||
from nat_qc_control
|
||||
join nat_qc_level
|
||||
ON Nat_QcControlNat_QcLevelID = Nat_QcLevelID
|
||||
AND Nat_QcControlIsActive = 'Y'
|
||||
AND Nat_QcLevelIsActive = 'Y'
|
||||
AND Nat_QcControlName like ?
|
||||
join nat_qc
|
||||
ON Nat_QcControlID = Nat_QcNat_QcControlID
|
||||
AND Nat_QcIsActive = 'Y'
|
||||
join nat_test
|
||||
ON Nat_QcNat_TestID = Nat_TestID
|
||||
AND Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestName like ?";
|
||||
$qry_total_filter = $this->db->query($sql_total_filter, [$control, $test]);
|
||||
$last_query_total_filter = $this->db->last_query();
|
||||
} else {
|
||||
// instrument dan test terisi
|
||||
$sql = "select
|
||||
distinct Nat_QcControlID,
|
||||
Nat_QcControlName,
|
||||
Nat_QcControlLotNumber,
|
||||
Nat_QcControlExpired,
|
||||
Nat_QcLevelID,
|
||||
Nat_QcLevelName
|
||||
from nat_qc_control
|
||||
join nat_qc_level
|
||||
ON Nat_QcControlNat_QcLevelID = Nat_QcLevelID
|
||||
AND Nat_QcControlIsActive = 'Y'
|
||||
AND Nat_QcLevelIsActive = 'Y'
|
||||
AND Nat_QcControlName like ?
|
||||
join nat_qc
|
||||
ON Nat_QcControlID = Nat_QcNat_QcControlID
|
||||
AND Nat_QcIsActive = 'Y'
|
||||
join nat_instrument
|
||||
ON Nat_QcNat_InstrumentID = Nat_InstrumentID
|
||||
AND Nat_InstrumentIsActive = 'Y'
|
||||
AND Nat_InstrumentName like ?
|
||||
join nat_test
|
||||
ON Nat_QcNat_TestID = Nat_TestID
|
||||
AND Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestName like ?
|
||||
limit 10 offset ?";
|
||||
$qry = $this->db->query($sql, [$control, $instrument, $test, $start_offset]);
|
||||
$last_query = $this->db->last_query();
|
||||
|
||||
$sql_total_filter = "select
|
||||
count(distinct Nat_QcControlID,
|
||||
Nat_QcControlName,
|
||||
Nat_QcControlLotNumber,
|
||||
Nat_QcControlExpired,
|
||||
Nat_QcLevelID,
|
||||
Nat_QcLevelName) as total_filter
|
||||
from nat_qc_control
|
||||
join nat_qc_level
|
||||
ON Nat_QcControlNat_QcLevelID = Nat_QcLevelID
|
||||
AND Nat_QcControlIsActive = 'Y'
|
||||
AND Nat_QcLevelIsActive = 'Y'
|
||||
AND Nat_QcControlName like ?
|
||||
join nat_qc
|
||||
ON Nat_QcControlID = Nat_QcNat_QcControlID
|
||||
AND Nat_QcIsActive = 'Y'
|
||||
join nat_instrument
|
||||
ON Nat_QcNat_InstrumentID = Nat_InstrumentID
|
||||
AND Nat_InstrumentIsActive = 'Y'
|
||||
AND Nat_InstrumentName like ?
|
||||
join nat_test
|
||||
ON Nat_QcNat_TestID = Nat_TestID
|
||||
AND Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestName like ?";
|
||||
$qry_total_filter = $this->db->query($sql_total_filter, [$control, $instrument, $test]);
|
||||
$last_query_total_filter = $this->db->last_query();
|
||||
}
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_query
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$qry_total_filter) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_query_total_filter
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
$rows_total_filter = $qry_total_filter->result_array();
|
||||
$total = ceil($rows_total_filter[0]["total_filter"] / $ROW_PER_PAGE);
|
||||
$result = array(
|
||||
"total" => $total,
|
||||
"total_filter" => (int)$rows_total_filter[0]["total_filter"],
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function control_byid()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$param = $this->sys_input;
|
||||
$page = $param['page'];
|
||||
|
||||
// check input parameter
|
||||
|
||||
// mandatory
|
||||
$id = 0;
|
||||
if (isset($param['id'])) {
|
||||
if (is_numeric($param['id'])) {
|
||||
$id = $param['id'];
|
||||
}
|
||||
}
|
||||
|
||||
// hitung start_offset
|
||||
$ROW_PER_PAGE = 10;
|
||||
$start_offset = 0;
|
||||
if (isset($param["page"])) {
|
||||
if (is_numeric($param["page"]) && $param['page'] > 0) {
|
||||
$start_offset = ($page - 1) * $ROW_PER_PAGE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sql = "select
|
||||
distinct Nat_QcControlID,
|
||||
Nat_QcControlName,
|
||||
Nat_QcControlLotNumber,
|
||||
Nat_QcControlExpired,
|
||||
Nat_QcLevelID,
|
||||
Nat_QcLevelName,
|
||||
Nat_InstrumentID,
|
||||
Nat_InstrumentName,
|
||||
Nat_TestID,
|
||||
Nat_TestName
|
||||
from nat_qc_control
|
||||
join nat_qc_level
|
||||
ON Nat_QcControlNat_QcLevelID = Nat_QcLevelID
|
||||
AND Nat_QcControlIsActive = 'Y'
|
||||
AND Nat_QcLevelIsActive = 'Y'
|
||||
join nat_qc
|
||||
ON Nat_QcControlID = Nat_QcNat_QcControlID
|
||||
AND Nat_QcIsActive = 'Y'
|
||||
join nat_instrument
|
||||
ON Nat_QcNat_InstrumentID = Nat_InstrumentID
|
||||
AND Nat_InstrumentIsActive = 'Y'
|
||||
AND Nat_InstrumentID = ?
|
||||
join nat_test
|
||||
ON Nat_QcNat_TestID = Nat_TestID
|
||||
AND Nat_TestIsActive = 'Y'
|
||||
limit 10 offset ?";
|
||||
$qry = $this->db->query($sql, [$id, $start_offset]);
|
||||
$last_query = $this->db->last_query();
|
||||
|
||||
$sql_total_filter = "select
|
||||
count(distinct Nat_QcControlID,
|
||||
Nat_QcControlName,
|
||||
Nat_QcControlLotNumber,
|
||||
Nat_QcControlExpired,
|
||||
Nat_QcLevelID,
|
||||
Nat_QcLevelName,
|
||||
Nat_InstrumentID,
|
||||
Nat_InstrumentName,
|
||||
Nat_TestID,
|
||||
Nat_TestName) as total_filter
|
||||
from nat_qc_control
|
||||
join nat_qc_level
|
||||
ON Nat_QcControlNat_QcLevelID = Nat_QcLevelID
|
||||
AND Nat_QcControlIsActive = 'Y'
|
||||
AND Nat_QcLevelIsActive = 'Y'
|
||||
join nat_qc
|
||||
ON Nat_QcControlID = Nat_QcNat_QcControlID
|
||||
AND Nat_QcIsActive = 'Y'
|
||||
join nat_instrument
|
||||
ON Nat_QcNat_InstrumentID = Nat_InstrumentID
|
||||
AND Nat_InstrumentIsActive = 'Y'
|
||||
AND Nat_InstrumentID = ?
|
||||
join nat_test
|
||||
ON Nat_QcNat_TestID = Nat_TestID
|
||||
AND Nat_TestIsActive = 'Y'";
|
||||
$qry_total_filter = $this->db->query($sql_total_filter, [$id]);
|
||||
$last_query_total_filter = $this->db->last_query();
|
||||
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_query
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$qry_total_filter) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_query_total_filter
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
$rows_total_filter = $qry_total_filter->result_array();
|
||||
$total = ceil($rows_total_filter[0]["total_filter"] / $ROW_PER_PAGE);
|
||||
|
||||
$result = array(
|
||||
"total" => $total,
|
||||
"total_filter" => (int)$rows_total_filter[0]["total_filter"],
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
479
application/controllers/Station.php
Normal file
479
application/controllers/Station.php
Normal file
@@ -0,0 +1,479 @@
|
||||
<?php
|
||||
class Station extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "STATION API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
function lookupbahan(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select T_BahanID as id,
|
||||
T_BahanT_SampleStationID as usergroupid,
|
||||
T_BahanCode as code,
|
||||
T_BahanName As name,
|
||||
'xxx' as action
|
||||
from t_bahan
|
||||
join t_samplestation oN T_BahanT_SampleStationID = T_SampleStationID
|
||||
where
|
||||
T_BahanT_SampleStationID = {$id} AND T_BahanIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from t_samplestation
|
||||
where
|
||||
T_SampleStationIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select T_SampleStationID as id,
|
||||
T_SampleStationCode as code,
|
||||
T_SampleStationName as name,
|
||||
T_SampleStationIsNonLab as isnonlab, T_SampleStationName as description , 'xxx' as usergrouptype
|
||||
from t_samplestation
|
||||
where
|
||||
T_SampleStationName LIKE CONCAT('%','{$search}','%') AND
|
||||
T_SampleStationIsActive = 'Y' $limit";
|
||||
$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("t_samplestation select",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewstation()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$name_station = $prm['name'];
|
||||
$code_station = $prm['code'];
|
||||
$isnonlab_station = $prm['isnonlab'];
|
||||
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM t_samplestation WHERE T_SampleStationIsActive = 'Y' AND T_SampleStationName = '{$name_station}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
|
||||
//echo $exist_name;
|
||||
if($exist_name == 0 ){
|
||||
$sql = "insert into t_samplestation(
|
||||
T_SampleStationCode,
|
||||
T_SampleStationName,
|
||||
T_SampleStationIsNonLab,
|
||||
T_SampleStationCreated,
|
||||
T_SampleStationLastUpdated
|
||||
)
|
||||
values( ?, ?, ?,now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_station,
|
||||
$code_station,
|
||||
$isnonlab_station
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_samplestation insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else{
|
||||
$errors = array();
|
||||
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada '));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editstation()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_station = $prm['id'];
|
||||
$code_station = $prm['code'];
|
||||
$name_station = $prm['name'];
|
||||
$isnonlab_station = $prm['isnonlab'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM t_samplestation WHERE T_SampleStationIsActive = 'Y' AND T_SampleStationName = '{$name_station}'
|
||||
AND T_SampleStationID <> {$id_station} ";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
|
||||
if($exist_name == 0){
|
||||
|
||||
$sql = "update t_samplestation SET
|
||||
T_SampleStationCode = ?,
|
||||
T_SampleStationName = ?,
|
||||
T_SampleStationIsNonLab = ?,
|
||||
T_SampleStationLastUpdated = now()
|
||||
where
|
||||
T_SampleStationID = ?
|
||||
";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code_station,
|
||||
$name_station,
|
||||
$isnonlab_station,
|
||||
$id_station
|
||||
)
|
||||
);
|
||||
//file_put_contents("/tmp/adi-update-user.sql",$this->db_onedev->last_query());
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_samplestation update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_station));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
|
||||
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function editbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$bahanid = $prm['xid'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$xstationname = $prm['xstationname'];
|
||||
|
||||
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}'
|
||||
and T_BahanID <> $bahanid ";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
|
||||
$sql = "update m_user SET
|
||||
T_BahanCode = ?,
|
||||
T_BahanName = ?,
|
||||
T_BahanT_SampleStationID = ?,
|
||||
T_BahanLastUpdated = now()
|
||||
where T_BahanID = ? ";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$xstationname["T_SampleStationID"],
|
||||
$bahanid
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan update",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $bahanid));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$errors = array();
|
||||
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function addnewbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$stationid = $prm['stationid'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
|
||||
if($prm['xid'] == 0){
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
$sql = "insert into t_bahan(
|
||||
T_BahanT_SampleStationID,
|
||||
T_BahanCode,
|
||||
T_BahanName,
|
||||
T_BahanCreated,
|
||||
T_BahanLastUpdated
|
||||
)
|
||||
values( ?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$stationid,
|
||||
$code,
|
||||
$name
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}else{
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}' AND T_BahanID <> {$prm['xid']}";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
//echo $query;
|
||||
|
||||
//echo $query;
|
||||
if($exist_name == 0 ){
|
||||
$sql = "UPDATE t_bahan SET T_BahanName = '{$name}', T_BahanCode = '{$code}' WHERE T_BahanID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'name sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function deletebahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update t_bahan SET
|
||||
T_BahanIsActive = 'N',
|
||||
T_BahanLastUpdated = now()
|
||||
WHERE
|
||||
T_BahanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan 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 deleteselect()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update t_samplestation SET
|
||||
T_SampleStationIsActive = 'N',
|
||||
T_SampleStationLastUpdated = now()
|
||||
WHERE
|
||||
T_SampleStationID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_samplestation delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE m_user SET
|
||||
M_UserIsActive = 'N',
|
||||
M_UserLastUpdated = now()
|
||||
WHERE
|
||||
M_UserM_UserGroupID = ?
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_user delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
18
application/controllers/Test_api.php
Normal file
18
application/controllers/Test_api.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
class Test_api extends MY_Controller {
|
||||
function get_param() {
|
||||
$body = file_get_contents("php://input");
|
||||
return json_decode($body,true);
|
||||
}
|
||||
function index() {
|
||||
//print param
|
||||
//pritn headers
|
||||
echo "post : ";
|
||||
print_r($_POST);
|
||||
echo "param: ";
|
||||
print_r($this->get_param());
|
||||
echo "header : ";
|
||||
print_r(getallheaders());
|
||||
}
|
||||
}
|
||||
18
application/controllers/Test_rpt.php
Normal file
18
application/controllers/Test_rpt.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
class Test_rpt extends MY_Controller {
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
function index() {
|
||||
$headers = getallheaders();
|
||||
$token = "";
|
||||
if (in_array('Authorization', array_keys($headers))) {
|
||||
$token = $headers['Authorization'];
|
||||
}
|
||||
$data = file_get_contents("php://input");
|
||||
$resp = json_decode($data,true);
|
||||
$v_data = print_r($resp,true);
|
||||
echo "Helo $token \n $v_data";
|
||||
}
|
||||
|
||||
}
|
||||
343
application/controllers/Timesheet.php
Normal file
343
application/controllers/Timesheet.php
Normal file
@@ -0,0 +1,343 @@
|
||||
<?php
|
||||
require FCPATH . "vendor/ripcord/ripcord.php";
|
||||
require FCPATH . "vendor/ripcord/ripcord_client.php";
|
||||
|
||||
class Timesheet extends MY_Controller
|
||||
{
|
||||
var $db_odoo, $url, $username, $uid, $model, $password, $common;
|
||||
var $teams;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->url = "http://odoo.sismedika.com:8070";
|
||||
$this->db_odoo = "odoo16_sismedika";
|
||||
$this->username = "admin@sismedika.com";
|
||||
$this->password = "duD#Z36qH5ctmRRD";
|
||||
$this->common = ripcord::client("{$this->url}/xmlrpc/2/common");
|
||||
$this->uid = $this->common->authenticate($this->db_odoo, $this->username, $this->password, array());
|
||||
$this->model = ripcord::client("{$this->url}/xmlrpc/2/object");
|
||||
$this->db->query("use one_support");
|
||||
$this->teams = [3, 22, 18, 21, 24, 15, 49, 34];
|
||||
}
|
||||
|
||||
function external_by_date($date = "")
|
||||
{
|
||||
if ($date == "") $date = date("Y-m-d");
|
||||
$startDate = "$date 00:00:00";
|
||||
$endDate = "$date 23:59:59";
|
||||
// Define domain for search
|
||||
$domain = [
|
||||
"&",
|
||||
['project_id', '!=', false],
|
||||
"&",
|
||||
['project_id', '!=', "HISv3"],
|
||||
"&",
|
||||
['employee_id', 'in', $this->teams],
|
||||
"&",
|
||||
['date', '>=', $startDate],
|
||||
['date', '<=', $endDate]
|
||||
];
|
||||
$kwarg = array(
|
||||
"limit" => 1000,
|
||||
"offset" => 0,
|
||||
"order" => "user_id",
|
||||
'fields' => array(
|
||||
'name', 'date', 'project_id', 'task_id',
|
||||
'unit_amount', 'user_id'
|
||||
)
|
||||
);
|
||||
// Search for timesheet entries
|
||||
$timesheets = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
'account.analytic.line',
|
||||
'web_search_read',
|
||||
array($domain),
|
||||
$kwarg
|
||||
);
|
||||
$total_hours = 0;
|
||||
$result = [];
|
||||
foreach ($timesheets["records"] as $r) {
|
||||
$name = $r["name"];
|
||||
$date = $r["date"];
|
||||
$project = $r["project_id"][1];
|
||||
$hour = $r["unit_amount"];
|
||||
$date = $r["date"];
|
||||
$user = $r["user_id"][1];
|
||||
$total_hours += $hour;
|
||||
|
||||
if (!isset($result[$user])) {
|
||||
$result[$user] = [];
|
||||
}
|
||||
if (!isset($result[$user][$project])) {
|
||||
$result[$user][$project] = $hour;
|
||||
} else {
|
||||
$result[$user][$project] += $hour;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function sas_one($date = "")
|
||||
{
|
||||
$sas_teams = [34, 36, 37, 38, 39, 40, 41, 42, 43, 44];
|
||||
if ($date == "") $date = date("Y-m-d");
|
||||
$startDate = "$date 00:00:00";
|
||||
$endDate = "$date 23:59:59";
|
||||
// Define domain for search
|
||||
$domain = [
|
||||
"&",
|
||||
['project_id', '!=', false],
|
||||
"&",
|
||||
['employee_id', 'in', $sas_teams],
|
||||
"&",
|
||||
['date', '>=', $startDate],
|
||||
['date', '<=', $endDate]
|
||||
];
|
||||
$kwarg = array(
|
||||
"limit" => 1000,
|
||||
"offset" => 0,
|
||||
"order" => "user_id",
|
||||
'fields' => array(
|
||||
'name', 'date', 'project_id', 'task_id',
|
||||
'unit_amount', 'user_id'
|
||||
)
|
||||
);
|
||||
// Search for timesheet entries
|
||||
$timesheets = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
'account.analytic.line',
|
||||
'web_search_read',
|
||||
array($domain),
|
||||
$kwarg
|
||||
);
|
||||
$total_hours = 0;
|
||||
$result = [];
|
||||
foreach ($timesheets["records"] as $r) {
|
||||
$name = $r["name"];
|
||||
$date = $r["date"];
|
||||
$project = $r["project_id"][1];
|
||||
$task = $r["task_id"][1];
|
||||
$hour = $r["unit_amount"];
|
||||
$date = $r["date"];
|
||||
$user = $r["user_id"][1];
|
||||
$total_hours += $hour;
|
||||
$total_hours += $hour;
|
||||
$result[$user][] = [
|
||||
"project" => $project,
|
||||
"task" => $task,
|
||||
"date" => $date,
|
||||
"desc" => $name,
|
||||
"hour" => $hour
|
||||
];
|
||||
}
|
||||
$table = "@startuml\n ";
|
||||
$total_staff = 0;
|
||||
$prev_user = "";
|
||||
$table .= "object Timesheet { \n";
|
||||
$table .= "<HEADER--xx>\n";
|
||||
foreach ($result as $user => $data) {
|
||||
if ($prev_user != $user) {
|
||||
$table .= "$user\n";
|
||||
$table .= "<#lightblue,#black>|= Project |= Task |= Desc |= Hour |\n";
|
||||
$total_staff++;
|
||||
$prev_user = $user;
|
||||
}
|
||||
foreach ($data as $d) {
|
||||
$xdesc = $d["desc"];
|
||||
if (strlen($xdesc) > 30) {
|
||||
$xdesc = substr($xdesc, 0, 26) . "...";
|
||||
}
|
||||
$table .= "<#white>| {$d["project"]}| {$d["task"]}| {$xdesc}| {$d["hour"]}|\n";
|
||||
}
|
||||
}
|
||||
$msg = "Collection Date : " . date("Y-m-d H:i:s") . "\n";
|
||||
$msg .= "Total Hour : " . $total_hours . "\n";
|
||||
$msg .= "Total Staff: " . $total_staff . "\n";
|
||||
$msg .= "---\n";
|
||||
$table = str_replace("<HEADER--xx>", $msg, $table);
|
||||
if ($prev_user != "") {
|
||||
$table .= "}\n\n";
|
||||
}
|
||||
$table .= "@enduml";
|
||||
$img = $this->puml_post($table);
|
||||
$url = "https://puml.sismedika.online/png/$img";
|
||||
$this->wa_to_sasone($url);
|
||||
}
|
||||
|
||||
function by_project_date($project, $date = "")
|
||||
{
|
||||
if ($date == "") $date = date("Y-m-d");
|
||||
$startDate = "$date 00:00:00";
|
||||
$endDate = "$date 23:59:59";
|
||||
// Define domain for search
|
||||
$domain = [
|
||||
"&",
|
||||
['project_id', '!=', false],
|
||||
"&",
|
||||
['project_id', 'ilike', "$project"],
|
||||
"&",
|
||||
['date', '>=', $startDate],
|
||||
['date', '<=', $endDate]
|
||||
];
|
||||
|
||||
$kwarg = array(
|
||||
"limit" => 1000,
|
||||
"offset" => 0,
|
||||
"order" => "user_id",
|
||||
'fields' => array(
|
||||
'name', 'date', 'task_id',
|
||||
'unit_amount', 'user_id'
|
||||
)
|
||||
);
|
||||
// Search for timesheet entries
|
||||
$timesheets = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
'account.analytic.line',
|
||||
'web_search_read',
|
||||
array($domain),
|
||||
$kwarg
|
||||
);
|
||||
$total_hours = 0;
|
||||
$result = [];
|
||||
foreach ($timesheets["records"] as $r) {
|
||||
$name = $r["name"];
|
||||
$date = $r["date"];
|
||||
$task = $r["task_id"][1];
|
||||
$hour = $r["unit_amount"];
|
||||
$date = $r["date"];
|
||||
$user = $r["user_id"][1];
|
||||
$total_hours += $hour;
|
||||
$result[$user][] = [
|
||||
"task" => $task,
|
||||
"date" => $date,
|
||||
"desc" => $name,
|
||||
"hour" => $hour
|
||||
];
|
||||
}
|
||||
$table = "@startuml\n ";
|
||||
$msg = "Collection Date : " . date("Y-m-d H:i:s") . "\n";
|
||||
$msg .= "Total Hour : " . $total_hours . "\n";
|
||||
$total_staff = 0;
|
||||
$prev_user = "";
|
||||
$table .= "object Timesheet { \n";
|
||||
$table .= "<HEADER--xx>\n";
|
||||
foreach ($result as $user => $data) {
|
||||
if ($prev_user != $user) {
|
||||
$table .= "$user\n";
|
||||
$table .= "<#lightblue,#black>|= Date |= Task |= Desc |= Hour |\n";
|
||||
$total_staff++;
|
||||
$prev_user = $user;
|
||||
}
|
||||
foreach ($data as $d) {
|
||||
$xdesc = $d["desc"];
|
||||
if (strlen($xdesc) > 50) {
|
||||
$xdesc = substr($xdesc, 0, 46) . "...";
|
||||
}
|
||||
$table .= "<#white>| {$d["date"]}| {$d["task"]}| {$xdesc}| {$d["hour"]}|\n";
|
||||
}
|
||||
}
|
||||
$msg .= "Total Staff: " . $total_staff . "\n";
|
||||
$msg .= "---\n";
|
||||
$table = str_replace("<HEADER--xx>", $msg, $table);
|
||||
$result = $this->external_by_date($date);
|
||||
$have_ext = false;
|
||||
if (count($result) > 0) {
|
||||
$have_ext = true;
|
||||
$table .= "\n\n\n";
|
||||
$table .= "Non HIS V3\n";
|
||||
$table .= "<#lightblue,#black>|= User|= Project|= Hour |\n";
|
||||
$total_hours = 0;
|
||||
foreach ($result as $u => $r) {
|
||||
foreach ($r as $prj => $hour) {
|
||||
$table .= "<#white>| {$u}| {$prj}| {$hour}|\n";
|
||||
$total_hours += $hour;
|
||||
}
|
||||
}
|
||||
echo "\n";
|
||||
$table .= "Total Hour: " . $total_hours . "\n";
|
||||
}
|
||||
if ($prev_user != "" || $have_ext) {
|
||||
$table .= "}\n\n";
|
||||
}
|
||||
$table .= "@enduml";
|
||||
$img = $this->puml_post($table);
|
||||
$url = "https://puml.sismedika.online/png/$img";
|
||||
//echo $url;
|
||||
$this->wa_to_group($url);
|
||||
}
|
||||
function wa_to_sasone(
|
||||
$url
|
||||
) {
|
||||
$this->load->library("Wa_sas");
|
||||
$hp = "6282113702602-1584412485@g.us";
|
||||
$resp = $this->wa_sas->send_image(
|
||||
$hp,
|
||||
"Timesheet Summary",
|
||||
$url,
|
||||
"image/png",
|
||||
"sasone-status",
|
||||
"png",
|
||||
true
|
||||
);
|
||||
print_r($resp);
|
||||
}
|
||||
|
||||
function wa_to_group(
|
||||
$url
|
||||
) {
|
||||
$this->load->library("Wa_sas");
|
||||
//$hp = "6287823783747";
|
||||
//group set to true
|
||||
$hp = "120363194169273747@g.us";
|
||||
//$resp = $this->wa_sas->send_message($hp, $msg,true);
|
||||
// print_r($resp);
|
||||
$resp = $this->wa_sas->send_image(
|
||||
$hp,
|
||||
"Timesheet Summary",
|
||||
$url,
|
||||
"image/png",
|
||||
"hisv3-status",
|
||||
"png",
|
||||
true
|
||||
);
|
||||
print_r($resp);
|
||||
}
|
||||
function wa_to_sasone_done(
|
||||
$msg
|
||||
) {
|
||||
$this->load->library("Wa_sas");
|
||||
$hp = "6287823783747";
|
||||
//$hp="6282113702602-1584412485@g.us";
|
||||
//bisone supporter
|
||||
//$hp = "6281328282909-1583223560@g.us";
|
||||
$resp = $this->wa_sas->send_message($hp, $msg, true);
|
||||
}
|
||||
|
||||
function puml_post($data)
|
||||
{
|
||||
$url = "https://puml.sismedika.online/coder";
|
||||
$ch = curl_init($url);
|
||||
$payload = $data;
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
|
||||
# Return response instead of printing.
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
# Send request.
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
function bool_day($inp_dow)
|
||||
{
|
||||
$dow = strtolower(date("D", strtotime("now")));
|
||||
if ($inp_dow == $dow) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
575
application/controllers/Timesheet_v2.php
Normal file
575
application/controllers/Timesheet_v2.php
Normal file
@@ -0,0 +1,575 @@
|
||||
<?php
|
||||
require FCPATH . "vendor/ripcord/ripcord.php";
|
||||
require FCPATH . "vendor/ripcord/ripcord_client.php";
|
||||
|
||||
class Timesheet_v2 extends MY_Controller
|
||||
{
|
||||
var $db_odoo, $url, $username, $uid, $model, $password, $common;
|
||||
var $teams;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->url = "http://odoo.sismedika.com:8070";
|
||||
$this->db_odoo = "odoo16_sismedika";
|
||||
$this->username = "admin@sismedika.com";
|
||||
$this->password = "duD#Z36qH5ctmRRD";
|
||||
$this->common = ripcord::client("{$this->url}/xmlrpc/2/common");
|
||||
$this->uid = $this->common->authenticate($this->db_odoo, $this->username, $this->password, array());
|
||||
$this->model = ripcord::client("{$this->url}/xmlrpc/2/object");
|
||||
$this->db->query("use one_support");
|
||||
$this->teams = [3, 22, 18, 21, 24, 15, 49, 34];
|
||||
}
|
||||
|
||||
// --- v2
|
||||
//
|
||||
function mobile($date = "")
|
||||
{
|
||||
$teams = [30, 32, 29, 27, 43];
|
||||
if ($date == "") $date = date("Y-m-d");
|
||||
$startDate = "$date 00:00:00";
|
||||
$endDate = "$date 23:59:59";
|
||||
// Define domain for search
|
||||
$domain = [
|
||||
"&",
|
||||
['project_id', '!=', false],
|
||||
"&",
|
||||
['employee_id', 'in', $teams],
|
||||
"&",
|
||||
['date', '>=', $startDate],
|
||||
['date', '<=', $endDate]
|
||||
];
|
||||
$kwarg = array(
|
||||
"limit" => 1000,
|
||||
"offset" => 0,
|
||||
"order" => "user_id",
|
||||
'fields' => array(
|
||||
'name', 'date', 'project_id', 'task_id',
|
||||
'unit_amount', 'user_id'
|
||||
)
|
||||
);
|
||||
// Search for timesheet entries
|
||||
$timesheets = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
'account.analytic.line',
|
||||
'web_search_read',
|
||||
array($domain),
|
||||
$kwarg
|
||||
);
|
||||
$total_hours = 0;
|
||||
$result = [];
|
||||
foreach ($timesheets["records"] as $r) {
|
||||
$name = $r["name"];
|
||||
$date = $r["date"];
|
||||
$project = $r["project_id"][1];
|
||||
$task = $r["task_id"][1];
|
||||
$hour = round($r["unit_amount"], 1);
|
||||
$date = $r["date"];
|
||||
$user = $r["user_id"][1];
|
||||
$total_hours += $hour;
|
||||
$total_hours += $hour;
|
||||
$result[$user][] = [
|
||||
"project" => $project,
|
||||
"task" => $task,
|
||||
"date" => $date,
|
||||
"desc" => $name,
|
||||
"hour" => $hour
|
||||
];
|
||||
}
|
||||
$table = "@startuml\n ";
|
||||
$total_staff = 0;
|
||||
$prev_user = "";
|
||||
$table .= "object Timesheet { \n";
|
||||
$table .= "<HEADER--xx>\n";
|
||||
foreach ($result as $user => $data) {
|
||||
if ($prev_user != $user) {
|
||||
$table .= "$user\n";
|
||||
$table .= "<#lightblue,#black>|= Project |= Task |= Desc |= Hour |\n";
|
||||
$total_staff++;
|
||||
$prev_user = $user;
|
||||
}
|
||||
foreach ($data as $d) {
|
||||
$xdesc = $d["desc"];
|
||||
if (strlen($xdesc) > 30) {
|
||||
$xdesc = substr($xdesc, 0, 26) . "...";
|
||||
}
|
||||
$table .= "<#white>| {$d["project"]}| {$d["task"]}| {$xdesc}| {$d["hour"]}|\n";
|
||||
}
|
||||
}
|
||||
$msg = "Collection Date : " . date("Y-m-d H:i:s") . "\n";
|
||||
$msg .= "Total Hour : " . $total_hours . "\n";
|
||||
$msg .= "Total Staff: " . $total_staff . "\n";
|
||||
$msg .= "---\n";
|
||||
$table = str_replace("<HEADER--xx>", $msg, $table);
|
||||
if ($prev_user != "") {
|
||||
$table .= "}\n\n";
|
||||
}
|
||||
$table .= "@enduml";
|
||||
$img = $this->puml_post($table);
|
||||
$url = "https://puml.sismedika.online/png/$img";
|
||||
$this->wa_to_mobile($url);
|
||||
}
|
||||
function wa_to_mobile(
|
||||
$url
|
||||
) {
|
||||
$this->load->library("Wa_sas");
|
||||
$hp = "120363166799845051@g.us";
|
||||
$resp = $this->wa_sas->send_image(
|
||||
$hp,
|
||||
"Timesheet Summary",
|
||||
$url,
|
||||
"image/png",
|
||||
"dev.backend-status",
|
||||
"png",
|
||||
true
|
||||
);
|
||||
print_r($resp);
|
||||
}
|
||||
|
||||
function ais($date = "")
|
||||
{
|
||||
$teams = [19, 28, 47, 31, 44];
|
||||
if ($date == "") $date = date("Y-m-d");
|
||||
$startDate = "$date 00:00:00";
|
||||
$endDate = "$date 23:59:59";
|
||||
// Define domain for search
|
||||
$domain = [
|
||||
"&",
|
||||
['project_id', '!=', false],
|
||||
"&",
|
||||
['employee_id', 'in', $teams],
|
||||
"&",
|
||||
['date', '>=', $startDate],
|
||||
['date', '<=', $endDate]
|
||||
];
|
||||
$kwarg = array(
|
||||
"limit" => 1000,
|
||||
"offset" => 0,
|
||||
"order" => "user_id",
|
||||
'fields' => array(
|
||||
'name', 'date', 'project_id', 'task_id',
|
||||
'unit_amount', 'user_id'
|
||||
)
|
||||
);
|
||||
// Search for timesheet entries
|
||||
$timesheets = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
'account.analytic.line',
|
||||
'web_search_read',
|
||||
array($domain),
|
||||
$kwarg
|
||||
);
|
||||
$total_hours = 0;
|
||||
$result = [];
|
||||
foreach ($timesheets["records"] as $r) {
|
||||
$name = $r["name"];
|
||||
$date = $r["date"];
|
||||
$project = $r["project_id"][1];
|
||||
$task = $r["task_id"][1];
|
||||
$hour = round($r["unit_amount"], 1);
|
||||
$date = $r["date"];
|
||||
$user = $r["user_id"][1];
|
||||
$total_hours += $hour;
|
||||
$total_hours += $hour;
|
||||
$result[$user][] = [
|
||||
"project" => $project,
|
||||
"task" => $task,
|
||||
"date" => $date,
|
||||
"desc" => $name,
|
||||
"hour" => $hour
|
||||
];
|
||||
}
|
||||
$table = "@startuml\n ";
|
||||
$total_staff = 0;
|
||||
$prev_user = "";
|
||||
$table .= "object Timesheet { \n";
|
||||
$table .= "<HEADER--xx>\n";
|
||||
foreach ($result as $user => $data) {
|
||||
if ($prev_user != $user) {
|
||||
$table .= "$user\n";
|
||||
$table .= "<#lightblue,#black>|= Project |= Task |= Desc |= Hour |\n";
|
||||
$total_staff++;
|
||||
$prev_user = $user;
|
||||
}
|
||||
foreach ($data as $d) {
|
||||
$xdesc = $d["desc"];
|
||||
if (strlen($xdesc) > 30) {
|
||||
$xdesc = substr($xdesc, 0, 26) . "...";
|
||||
}
|
||||
$table .= "<#white>| {$d["project"]}| {$d["task"]}| {$xdesc}| {$d["hour"]}|\n";
|
||||
}
|
||||
}
|
||||
$msg = "Collection Date : " . date("Y-m-d H:i:s") . "\n";
|
||||
$msg .= "Total Hour : " . $total_hours . "\n";
|
||||
$msg .= "Total Staff: " . $total_staff . "\n";
|
||||
$msg .= "---\n";
|
||||
$table = str_replace("<HEADER--xx>", $msg, $table);
|
||||
if ($prev_user != "") {
|
||||
$table .= "}\n\n";
|
||||
}
|
||||
$table .= "@enduml";
|
||||
$img = $this->puml_post($table);
|
||||
$url = "https://puml.sismedika.online/png/$img";
|
||||
$this->wa_to_ais($url);
|
||||
}
|
||||
function wa_to_ais(
|
||||
$url
|
||||
) {
|
||||
$this->load->library("Wa_sas");
|
||||
$hp = "120363185074039892@g.us";
|
||||
$resp = $this->wa_sas->send_image(
|
||||
$hp,
|
||||
"Timesheet Summary",
|
||||
$url,
|
||||
"image/png",
|
||||
"dev.backend-status",
|
||||
"png",
|
||||
true
|
||||
);
|
||||
print_r($resp);
|
||||
}
|
||||
function wa_to_me(
|
||||
$url
|
||||
) {
|
||||
$this->load->library("Wa_sas");
|
||||
$hp = "6287823783747";
|
||||
$resp = $this->wa_sas->send_image(
|
||||
$hp,
|
||||
"Timesheet Summary",
|
||||
$url,
|
||||
"image/png",
|
||||
"ais-status",
|
||||
"png"
|
||||
);
|
||||
print_r($resp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function external_by_date($date = "")
|
||||
{
|
||||
if ($date == "") $date = date("Y-m-d");
|
||||
$startDate = "$date 00:00:00";
|
||||
$endDate = "$date 23:59:59";
|
||||
// Define domain for search
|
||||
$domain = [
|
||||
"&",
|
||||
['project_id', '!=', false],
|
||||
"&",
|
||||
['project_id', '!=', "HISv3"],
|
||||
"&",
|
||||
['employee_id', 'in', $this->teams],
|
||||
"&",
|
||||
['date', '>=', $startDate],
|
||||
['date', '<=', $endDate]
|
||||
];
|
||||
$kwarg = array(
|
||||
"limit" => 1000,
|
||||
"offset" => 0,
|
||||
"order" => "user_id",
|
||||
'fields' => array(
|
||||
'name', 'date', 'project_id', 'task_id',
|
||||
'unit_amount', 'user_id'
|
||||
)
|
||||
);
|
||||
// Search for timesheet entries
|
||||
$timesheets = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
'account.analytic.line',
|
||||
'web_search_read',
|
||||
array($domain),
|
||||
$kwarg
|
||||
);
|
||||
$total_hours = 0;
|
||||
$result = [];
|
||||
foreach ($timesheets["records"] as $r) {
|
||||
$name = $r["name"];
|
||||
$date = $r["date"];
|
||||
$project = $r["project_id"][1];
|
||||
$hour = round($r["unit_amount"], 1);
|
||||
$date = $r["date"];
|
||||
$user = $r["user_id"][1];
|
||||
$total_hours += $hour;
|
||||
|
||||
if (!isset($result[$user])) {
|
||||
$result[$user] = [];
|
||||
}
|
||||
if (!isset($result[$user][$project])) {
|
||||
$result[$user][$project] = $hour;
|
||||
} else {
|
||||
$result[$user][$project] += $hour;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function sas_one($date = "")
|
||||
{
|
||||
$sas_teams = [34, 36, 37, 38, 39, 40, 41, 42, 43, 44];
|
||||
if ($date == "") $date = date("Y-m-d");
|
||||
$startDate = "$date 00:00:00";
|
||||
$endDate = "$date 23:59:59";
|
||||
// Define domain for search
|
||||
$domain = [
|
||||
"&",
|
||||
['project_id', '!=', false],
|
||||
"&",
|
||||
['employee_id', 'in', $sas_teams],
|
||||
"&",
|
||||
['date', '>=', $startDate],
|
||||
['date', '<=', $endDate]
|
||||
];
|
||||
$kwarg = array(
|
||||
"limit" => 1000,
|
||||
"offset" => 0,
|
||||
"order" => "user_id",
|
||||
'fields' => array(
|
||||
'name', 'date', 'project_id', 'task_id',
|
||||
'unit_amount', 'user_id'
|
||||
)
|
||||
);
|
||||
// Search for timesheet entries
|
||||
$timesheets = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
'account.analytic.line',
|
||||
'web_search_read',
|
||||
array($domain),
|
||||
$kwarg
|
||||
);
|
||||
$total_hours = 0;
|
||||
$result = [];
|
||||
foreach ($timesheets["records"] as $r) {
|
||||
$name = $r["name"];
|
||||
$date = $r["date"];
|
||||
$project = $r["project_id"][1];
|
||||
$task = $r["task_id"][1];
|
||||
$hour = round($r["unit_amount"], 1);
|
||||
$date = $r["date"];
|
||||
$user = $r["user_id"][1];
|
||||
$total_hours += $hour;
|
||||
$total_hours += $hour;
|
||||
$result[$user][] = [
|
||||
"project" => $project,
|
||||
"task" => $task,
|
||||
"date" => $date,
|
||||
"desc" => $name,
|
||||
"hour" => $hour
|
||||
];
|
||||
}
|
||||
$table = "@startuml\n ";
|
||||
$total_staff = 0;
|
||||
$prev_user = "";
|
||||
$table .= "object Timesheet { \n";
|
||||
$table .= "<HEADER--xx>\n";
|
||||
foreach ($result as $user => $data) {
|
||||
if ($prev_user != $user) {
|
||||
$table .= "$user\n";
|
||||
$table .= "<#lightblue,#black>|= Project |= Task |= Desc |= Hour |\n";
|
||||
$total_staff++;
|
||||
$prev_user = $user;
|
||||
}
|
||||
foreach ($data as $d) {
|
||||
$xdesc = $d["desc"];
|
||||
if (strlen($xdesc) > 30) {
|
||||
$xdesc = substr($xdesc, 0, 26) . "...";
|
||||
}
|
||||
$table .= "<#white>| {$d["project"]}| {$d["task"]}| {$xdesc}| {$d["hour"]}|\n";
|
||||
}
|
||||
}
|
||||
$msg = "Collection Date : " . date("Y-m-d H:i:s") . "\n";
|
||||
$msg .= "Total Hour : " . $total_hours . "\n";
|
||||
$msg .= "Total Staff: " . $total_staff . "\n";
|
||||
$msg .= "---\n";
|
||||
$table = str_replace("<HEADER--xx>", $msg, $table);
|
||||
if ($prev_user != "") {
|
||||
$table .= "}\n\n";
|
||||
}
|
||||
$table .= "@enduml";
|
||||
$img = $this->puml_post($table);
|
||||
$url = "https://puml.sismedika.online/png/$img";
|
||||
$this->wa_to_sasone($url);
|
||||
}
|
||||
|
||||
function by_project_date($project, $date = "")
|
||||
{
|
||||
if ($date == "") $date = date("Y-m-d");
|
||||
$startDate = "$date 00:00:00";
|
||||
$endDate = "$date 23:59:59";
|
||||
// Define domain for search
|
||||
$domain = [
|
||||
"&",
|
||||
['project_id', '!=', false],
|
||||
"&",
|
||||
['project_id', 'ilike', "$project"],
|
||||
"&",
|
||||
['date', '>=', $startDate],
|
||||
['date', '<=', $endDate]
|
||||
];
|
||||
|
||||
$kwarg = array(
|
||||
"limit" => 1000,
|
||||
"offset" => 0,
|
||||
"order" => "user_id",
|
||||
'fields' => array(
|
||||
'name', 'date', 'task_id',
|
||||
'unit_amount', 'user_id'
|
||||
)
|
||||
);
|
||||
// Search for timesheet entries
|
||||
$timesheets = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
'account.analytic.line',
|
||||
'web_search_read',
|
||||
array($domain),
|
||||
$kwarg
|
||||
);
|
||||
$total_hours = 0;
|
||||
$result = [];
|
||||
foreach ($timesheets["records"] as $r) {
|
||||
$name = $r["name"];
|
||||
$date = $r["date"];
|
||||
$task = $r["task_id"][1];
|
||||
$hour = round($r["unit_amount"], 1);
|
||||
$date = $r["date"];
|
||||
$user = $r["user_id"][1];
|
||||
$total_hours += $hour;
|
||||
$result[$user][] = [
|
||||
"task" => $task,
|
||||
"date" => $date,
|
||||
"desc" => $name,
|
||||
"hour" => $hour
|
||||
];
|
||||
}
|
||||
$table = "@startuml\n ";
|
||||
$msg = "Collection Date : " . date("Y-m-d H:i:s") . "\n";
|
||||
$msg .= "Total Hour : " . $total_hours . "\n";
|
||||
$total_staff = 0;
|
||||
$prev_user = "";
|
||||
$table .= "object Timesheet { \n";
|
||||
$table .= "<HEADER--xx>\n";
|
||||
foreach ($result as $user => $data) {
|
||||
if ($prev_user != $user) {
|
||||
$table .= "$user\n";
|
||||
$table .= "<#lightblue,#black>|= Date |= Task |= Desc |= Hour |\n";
|
||||
$total_staff++;
|
||||
$prev_user = $user;
|
||||
}
|
||||
foreach ($data as $d) {
|
||||
$xdesc = $d["desc"];
|
||||
if (strlen($xdesc) > 50) {
|
||||
$xdesc = substr($xdesc, 0, 46) . "...";
|
||||
}
|
||||
$table .= "<#white>| {$d["date"]}| {$d["task"]}| {$xdesc}| {$d["hour"]}|\n";
|
||||
}
|
||||
}
|
||||
$msg .= "Total Staff: " . $total_staff . "\n";
|
||||
$msg .= "---\n";
|
||||
$table = str_replace("<HEADER--xx>", $msg, $table);
|
||||
$result = $this->external_by_date($date);
|
||||
$have_ext = false;
|
||||
if (count($result) > 0) {
|
||||
$have_ext = true;
|
||||
$table .= "\n\n\n";
|
||||
$table .= "Non HIS V3\n";
|
||||
$table .= "<#lightblue,#black>|= User|= Project|= Hour |\n";
|
||||
$total_hours = 0;
|
||||
foreach ($result as $u => $r) {
|
||||
foreach ($r as $prj => $hour) {
|
||||
$table .= "<#white>| {$u}| {$prj}| {$hour}|\n";
|
||||
$total_hours += $hour;
|
||||
}
|
||||
}
|
||||
echo "\n";
|
||||
$table .= "Total Hour: " . $total_hours . "\n";
|
||||
}
|
||||
if ($prev_user != "" || $have_ext) {
|
||||
$table .= "}\n\n";
|
||||
}
|
||||
$table .= "@enduml";
|
||||
$img = $this->puml_post($table);
|
||||
$url = "https://puml.sismedika.online/png/$img";
|
||||
//echo $url;
|
||||
$this->wa_to_group($url);
|
||||
}
|
||||
function wa_to_sasone(
|
||||
$url
|
||||
) {
|
||||
$this->load->library("Wa_sas");
|
||||
$hp = "6282113702602-1584412485@g.us";
|
||||
$resp = $this->wa_sas->send_image(
|
||||
$hp,
|
||||
"Timesheet Summary",
|
||||
$url,
|
||||
"image/png",
|
||||
"sasone-status",
|
||||
"png",
|
||||
true
|
||||
);
|
||||
print_r($resp);
|
||||
}
|
||||
|
||||
function wa_to_group(
|
||||
$url
|
||||
) {
|
||||
$this->load->library("Wa_sas");
|
||||
//$hp = "6287823783747";
|
||||
//group set to true
|
||||
$hp = "120363194169273747@g.us";
|
||||
//$resp = $this->wa_sas->send_message($hp, $msg,true);
|
||||
// print_r($resp);
|
||||
$resp = $this->wa_sas->send_image(
|
||||
$hp,
|
||||
"Timesheet Summary",
|
||||
$url,
|
||||
"image/png",
|
||||
"hisv3-status",
|
||||
"png",
|
||||
true
|
||||
);
|
||||
print_r($resp);
|
||||
}
|
||||
function wa_to_sasone_done(
|
||||
$msg
|
||||
) {
|
||||
$this->load->library("Wa_sas");
|
||||
$hp = "6287823783747";
|
||||
//$hp="6282113702602-1584412485@g.us";
|
||||
//bisone supporter
|
||||
//$hp = "6281328282909-1583223560@g.us";
|
||||
$resp = $this->wa_sas->send_message($hp, $msg, true);
|
||||
}
|
||||
|
||||
function puml_post($data)
|
||||
{
|
||||
$url = "https://puml.sismedika.online/coder";
|
||||
$ch = curl_init($url);
|
||||
$payload = $data;
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
|
||||
# Return response instead of printing.
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
# Send request.
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
function bool_day($inp_dow)
|
||||
{
|
||||
$dow = strtolower(date("D", strtotime("now")));
|
||||
if ($inp_dow == $dow) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
189
application/controllers/Timesheet_v3.php
Normal file
189
application/controllers/Timesheet_v3.php
Normal file
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
require FCPATH . "vendor/ripcord/ripcord.php";
|
||||
require FCPATH . "vendor/ripcord/ripcord_client.php";
|
||||
|
||||
class Timesheet_v3 extends MY_Controller
|
||||
{
|
||||
var $db_odoo, $url, $username, $uid, $model, $password, $common;
|
||||
var $teams;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->url = "http://odoo.sismedika.com:8070";
|
||||
$this->db_odoo = "odoo16_sismedika";
|
||||
$this->username = "admin@sismedika.com";
|
||||
$this->password = "duD#Z36qH5ctmRRD";
|
||||
$this->common = ripcord::client("{$this->url}/xmlrpc/2/common");
|
||||
$this->uid = $this->common->authenticate($this->db_odoo, $this->username, $this->password, array());
|
||||
$this->model = ripcord::client("{$this->url}/xmlrpc/2/object");
|
||||
$this->db->query("use one_support");
|
||||
$this->teams = [3, 22, 18, 21, 24, 15, 49, 34];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// sismedika
|
||||
// 1. Design: Inggrit, Ira, Nana, Zalfa
|
||||
//2. HIS 2: Heri, Bagas,Febio, Domi, Morris, Putri
|
||||
//3. App: Tb,Rajif, Pajri, Hanif, Adib
|
||||
//4. Backoffice: Gifari, Ivan, Moko, Akbar, Stephen
|
||||
//5. LIS: Fajri, Hanan, Fitri,Andi, Sindhu
|
||||
//6. HIS 3: Suritno, Ramdhan, Fajar, Rubi
|
||||
//7. Suppport : Yulius, Jafar, Ahmad fadil, Andreas, Ainun, Indra Waskito
|
||||
//8. Document : Fardil, Ari Antoni, Heru
|
||||
function ts_all($date = "")
|
||||
{
|
||||
$design_teams = [14, 36, 15, 16];
|
||||
$this->ts_team("Design Timesheet", $design_teams, $date);
|
||||
$hisv2_teams = [17, 24, 26, 25, 23, 11];
|
||||
$this->ts_team("HISv2 Timesheet", $hisv2_teams, $date);
|
||||
$app_teams = [30, 29, 32, 27, 43];
|
||||
$this->ts_team("App Timesheet", $app_teams, $date);
|
||||
$backoffice_teams = [19, 28, 47, 31, 44];
|
||||
$this->ts_team("Backoffice Timesheet", $backoffice_teams, $date);
|
||||
$lis_teams = [37, 39, 40, 41, 42];
|
||||
$this->ts_team("LIS Timesheet", $lis_teams, $date);
|
||||
$hisv3_teams = [18, 21, 20, 22];
|
||||
$this->ts_team("HIS v3 Timesheet", $hisv3_teams, $date);
|
||||
$support_teams = [5, 7, 45, 4, 9, 8, 10];
|
||||
$this->ts_team("Support Timesheet", $support_teams, $date);
|
||||
$doc_teams = [13, 38, 12];
|
||||
$this->ts_team("Doc Timesheet", $doc_teams, $date);
|
||||
}
|
||||
function ts_team($title, $teams, $date = "")
|
||||
{
|
||||
if ($date == "") $date = date("Y-m-d");
|
||||
if ($date == "ytd") {
|
||||
$date = date("Y-m-d", strtotime("now - 1 day"));
|
||||
}
|
||||
$startDate = "$date 00:00:00";
|
||||
$endDate = "$date 23:59:59";
|
||||
// Define domain for search
|
||||
$domain = [
|
||||
"&",
|
||||
['project_id', '!=', false],
|
||||
"&",
|
||||
['employee_id', 'in', $teams],
|
||||
"&",
|
||||
['date', '>=', $startDate],
|
||||
['date', '<=', $endDate]
|
||||
];
|
||||
$kwarg = array(
|
||||
"limit" => 1000,
|
||||
"offset" => 0,
|
||||
"order" => "user_id",
|
||||
'fields' => array(
|
||||
'name', 'date', 'project_id', 'task_id',
|
||||
'unit_amount', 'user_id'
|
||||
)
|
||||
);
|
||||
// Search for timesheet entries
|
||||
$timesheets = $this->model->execute_kw(
|
||||
$this->db_odoo,
|
||||
$this->uid,
|
||||
$this->password,
|
||||
'account.analytic.line',
|
||||
'web_search_read',
|
||||
array($domain),
|
||||
$kwarg
|
||||
);
|
||||
$total_hours = 0;
|
||||
$result = [];
|
||||
foreach ($timesheets["records"] as $r) {
|
||||
$name = $r["name"];
|
||||
$date = $r["date"];
|
||||
$project = $r["project_id"][1];
|
||||
$task = $r["task_id"][1];
|
||||
$hour = round($r["unit_amount"], 1);
|
||||
$date = $r["date"];
|
||||
$user = $r["user_id"][1];
|
||||
$total_hours += $hour;
|
||||
$total_hours += $hour;
|
||||
$result[$user][] = [
|
||||
"project" => $project,
|
||||
"task" => $task,
|
||||
"date" => $date,
|
||||
"desc" => $name,
|
||||
"hour" => $hour
|
||||
];
|
||||
}
|
||||
$table = "@startuml\n ";
|
||||
$total_staff = 0;
|
||||
$prev_user = "";
|
||||
$table .= "object Timesheet { \n";
|
||||
$table .= "<HEADER--xx>\n";
|
||||
foreach ($result as $user => $data) {
|
||||
if ($prev_user != $user) {
|
||||
$table .= "$user\n";
|
||||
$table .= "<#lightblue,#black>|= Project |= Task |= Desc |= Hour |\n";
|
||||
$total_staff++;
|
||||
$prev_user = $user;
|
||||
}
|
||||
foreach ($data as $d) {
|
||||
$xdesc = $d["desc"];
|
||||
if (strlen($xdesc) > 30) {
|
||||
$xdesc = substr($xdesc, 0, 26) . "...";
|
||||
}
|
||||
$table .= "<#white>| {$d["project"]}| {$d["task"]}| {$xdesc}| {$d["hour"]}|\n";
|
||||
}
|
||||
}
|
||||
$msg = "Collection Date : " . date("Y-m-d H:i:s") . "\n";
|
||||
$msg .= "Timesheet Date : " . $date . "\n";
|
||||
$msg .= "Total Hour : " . $total_hours . "\n";
|
||||
$msg .= "Total Staff: " . $total_staff . "\n";
|
||||
$msg .= "---\n";
|
||||
$table = str_replace("<HEADER--xx>", $msg, $table);
|
||||
if ($prev_user != "") {
|
||||
$table .= "}\n\n";
|
||||
}
|
||||
$table .= "@enduml";
|
||||
$img = $this->puml_post($table);
|
||||
$url = "https://puml.sismedika.online/png/$img";
|
||||
$this->wa_to_me($url, $title);
|
||||
}
|
||||
// dev team wa group
|
||||
// 120363267858371806
|
||||
function wa_to_me(
|
||||
$url,
|
||||
$title
|
||||
) {
|
||||
$this->load->library("Wa_sas");
|
||||
$hp = "120363267858371806@g.us";
|
||||
$resp = $this->wa_sas->send_image(
|
||||
$hp,
|
||||
"$title",
|
||||
$url,
|
||||
"image/png",
|
||||
"$title",
|
||||
"png",
|
||||
true
|
||||
);
|
||||
print_r($resp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function puml_post($data)
|
||||
{
|
||||
$url = "https://puml.sismedika.online/coder";
|
||||
$ch = curl_init($url);
|
||||
$payload = $data;
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
|
||||
# Return response instead of printing.
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
# Send request.
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
function bool_day($inp_dow)
|
||||
{
|
||||
$dow = strtolower(date("D", strtotime("now")));
|
||||
if ($inp_dow == $dow) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
47
application/controllers/Ttv_dummy.php
Normal file
47
application/controllers/Ttv_dummy.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
class Ttv_dummy extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function svc()
|
||||
{
|
||||
$a_data = $this->sys_input;
|
||||
foreach ($a_data as $d) {
|
||||
$d["obv_json"] = json_encode($d["obv"]);
|
||||
unset($d["obv"]);
|
||||
$qry = $this->db->insert("ttv_dummy.incoming", $d);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Err incoming " . $this->db->error()["message"]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
echo json_encode(["status" => "OK", "message" => ""]);
|
||||
}
|
||||
function qry()
|
||||
{
|
||||
$data = $this->sys_input;
|
||||
$medrec = $data["medrec"];
|
||||
$sql = "select * from ttv_dummy.xorder where medrec = ?";
|
||||
$qry = $this->db->query($sql,[$medrec]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => "Err incoming " . $this->db->error()["message"]
|
||||
]);
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo json_encode([
|
||||
"status" => "E01",
|
||||
"message" => "Patient not found"
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
echo json_encode(["status"=>"OK", "data"=> $rows[0]]);
|
||||
}
|
||||
}
|
||||
58
application/controllers/Wa_webhook.php
Normal file
58
application/controllers/Wa_webhook.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
class Wa_webhook extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function hook()
|
||||
{
|
||||
$bd = file_get_contents("php://input");
|
||||
file_put_contents("/xtmp/webhook-raw", $bd);
|
||||
header("Content-type: application/json");
|
||||
$json = json_decode($bd, true);
|
||||
if ($json) {
|
||||
$message = $json["message"]["text"];
|
||||
if (strpos($message, "#ts") !== false) {
|
||||
file_put_contents("/xtmp/webhook-raw", "\npost to json\n", FILE_APPEND);
|
||||
$this->post($json);
|
||||
} else {
|
||||
file_put_contents("/xtmp/webhook-raw", "\nno tag : $message\n", FILE_APPEND);
|
||||
}
|
||||
} else {
|
||||
file_put_contents("/xtmp/webhook-raw", "\ninvalid json\n", FILE_APPEND);
|
||||
}
|
||||
echo json_encode(["status" => "OK"]);
|
||||
}
|
||||
function post($json)
|
||||
{
|
||||
//$url = 'http://10.9.10.205:5678/webhook-test/aea7f5ff-f24d-4afe-a52e-8b12d328a3b5';
|
||||
$url = "http://10.9.10.205:5678/webhook/428e0945-f0fc-4dce-a043-2f789a0cafda";
|
||||
$jsonData = json_encode($json);
|
||||
|
||||
// Initialize cURL
|
||||
$ch = curl_init($url);
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($jsonData)
|
||||
]);
|
||||
|
||||
// Execute request and capture response
|
||||
$response = curl_exec($ch);
|
||||
|
||||
// Check for errors
|
||||
if (curl_errno($ch)) {
|
||||
$c_msg = 'cURL error: ' . curl_error($ch);
|
||||
} else {
|
||||
$c_msg = 'Response: ' . $response;
|
||||
}
|
||||
file_put_contents("/xtmp/webhook-raw", "\n$c_msg\n", FILE_APPEND);
|
||||
// Close cURL
|
||||
curl_close($ch);
|
||||
}
|
||||
}
|
||||
25
application/controllers/Welcome.php
Executable file
25
application/controllers/Welcome.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Welcome extends CI_Controller {
|
||||
|
||||
/**
|
||||
* Index Page for this controller.
|
||||
*
|
||||
* Maps to the following URL
|
||||
* http://example.com/index.php/welcome
|
||||
* - or -
|
||||
* http://example.com/index.php/welcome/index
|
||||
* - or -
|
||||
* Since this controller is set as the default controller in
|
||||
* config/routes.php, it's displayed at http://example.com/
|
||||
*
|
||||
* So any other public methods not prefixed with an underscore will
|
||||
* map to /index.php/welcome/<method_name>
|
||||
* @see https://codeigniter.com/user_guide/general/urls.html
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
echo(".:: -- ::.");
|
||||
}
|
||||
}
|
||||
13
application/controllers/Xraw.php
Normal file
13
application/controllers/Xraw.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
class Xraw extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function index()
|
||||
{
|
||||
$headers = getallheaders();
|
||||
echo json_encode($headers);
|
||||
}
|
||||
}
|
||||
11
application/controllers/index.html
Executable file
11
application/controllers/index.html
Executable file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
1145
application/controllers/mockup/Subgroup.php
Normal file
1145
application/controllers/mockup/Subgroup.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user