Initial import
This commit is contained in:
60
application/controllers/tools/monitoring/Editpx.php
Normal file
60
application/controllers/tools/monitoring/Editpx.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
class Editpx extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index() {
|
||||
$sql = "select * from m_branch where M_BranchIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
$branchName = "";
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$branchName = $rows[0]["M_BranchName"];
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
if ($branchName == "" ) {
|
||||
echo "No Branch";
|
||||
}
|
||||
$date = date("Y-m-d");
|
||||
$s_date = "$date 06:00:00";
|
||||
$e_date = "$date 23:59:59";
|
||||
$sql ="select T_OrderHeaderLabNumber,
|
||||
order_px.*
|
||||
from order_px
|
||||
join t_orderheader on OrderPxCreated >= '$s_date' and OrderPxCreated < '$e_date'
|
||||
and OrderPxT_OrderHeaderID = T_OrderHeaderID";
|
||||
$qry = $this->db->query($sql);
|
||||
if (! $qry) {
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$msg ="";
|
||||
foreach($rows as $r) {
|
||||
try {
|
||||
$a_json = json_decode($r["OrderPxJson"],true);
|
||||
$px_msg = "";
|
||||
foreach($a_json as $json) {
|
||||
if ($json["action"] == "delete" ) {
|
||||
if ($px_msg != "" ) $px_msg .= "\n";
|
||||
$px_msg .= " D [" . $json["pxsascode"] . "] " . $json["pxname"];
|
||||
}
|
||||
if ($json["action"] == "add" ) {
|
||||
if ($px_msg != "" ) $px_msg .= "\n";
|
||||
$px_msg .= " A [" . $json["pxsascode"] . "] " . $json["pxname"];
|
||||
}
|
||||
}
|
||||
if ($px_msg != "") {
|
||||
if ($msg != "" ) $msg .= "\n";
|
||||
$msg .= $r["T_OrderHeaderLabNumber"] . ":\n" ;
|
||||
$msg .= $px_msg;
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
}
|
||||
echo $msg ."\n";
|
||||
}
|
||||
}
|
||||
94
application/controllers/tools/monitoring/Hasil.php
Normal file
94
application/controllers/tools/monitoring/Hasil.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
class Hasil extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index() {
|
||||
$this->nilai_normal(true);
|
||||
}
|
||||
function clean_up_message($msg) {
|
||||
$msg = str_replace("-","\-",$msg);
|
||||
$msg = str_replace("(","\(",$msg);
|
||||
$msg = str_replace(")","\)",$msg);
|
||||
$msg = str_replace(".","\.",$msg);
|
||||
$msg = str_replace("[","\[",$msg);
|
||||
$msg = str_replace("]","\]",$msg);
|
||||
$msg = str_replace("|","\|",$msg);
|
||||
return $msg;
|
||||
}
|
||||
|
||||
function nilai_normal($do_send=false,$date = "") {
|
||||
$sql = "select distinct Nat_NormalValueNat_TestID
|
||||
from nat_normalvalue
|
||||
where Nat_NormalValueIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
$s_nat_ids = "0";
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$s_ids .= "," . $r["Nat_NormalValueNat_TestID"];
|
||||
}
|
||||
}
|
||||
if ($date == "" ) $date = Date("Y-m-d");
|
||||
$sql = "select T_OrderHeaderLabNumber, T_OrderHeaderM_PatientAge,
|
||||
concat( substring(group_concat(T_OrderDetailT_TestName),1,200), ' ...') TestName
|
||||
from
|
||||
t_orderdetail
|
||||
join t_orderheader on T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
and date(T_OrderHeaderDate) = '$date'
|
||||
and T_OrderDetailNat_NormalValueID = 0 and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailLastUpdated > T_OrderDetailCreated + interval 30 MINUTE
|
||||
and T_OrderDetailResult <> ''
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID and T_TestIsResult = 'Y'
|
||||
and T_TestNat_TestID in ( $s_nat_ids )
|
||||
group by T_OrderHeaderLabNumber
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$msg = "";
|
||||
$counter = 0;
|
||||
foreach($rows as $r) {
|
||||
$msg .= "*" . $r["T_OrderHeaderLabNumber"] . "* ( " . $r["T_OrderHeaderM_PatientAge"] . " ) :";
|
||||
$msg .= "\n\t " . $r["TestName"] . "\n";
|
||||
$counter++;
|
||||
if ($counter >= 10 ) {
|
||||
if ($do_send === true ) {
|
||||
$msg = "Hasil tanpa Nilai Normal:\n$msg";
|
||||
$msg = $this->clean_up_message($msg);
|
||||
$this->sasone($msg);
|
||||
$msg = "";
|
||||
$counter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($msg != "" ) {
|
||||
$msg = "Hasil tanpa Nilai Normal:\n$msg";
|
||||
if ($do_send === true ) {
|
||||
$msg = $this->clean_up_message($msg);
|
||||
$this->sasone($msg);
|
||||
} else {
|
||||
echo $msg;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
}
|
||||
function sasone($msg) {
|
||||
$url = "http://bandungraya.aplikasi.web.id/one-api/tgram/xone/sasone";
|
||||
$data = json_encode( array("text" => $msg ));
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
echo $result;
|
||||
}
|
||||
}
|
||||
190
application/controllers/tools/monitoring/Morning.php
Normal file
190
application/controllers/tools/monitoring/Morning.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
class Morning extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
function test() {
|
||||
$this->sasone("Testing");
|
||||
}
|
||||
function index() {
|
||||
$this->log("Start Monitoring Pagi");
|
||||
$sql = "select * from m_branch where M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'";
|
||||
$branchName = "No Branch";
|
||||
$branchCode = "";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$branchName = $rows[0]["M_BranchName"];
|
||||
$branchCode = $rows[0]["M_BranchCode"];
|
||||
} else {
|
||||
$this->log("Error Pending Merujuk : " . $this->db->error()["message"]);
|
||||
}
|
||||
$msg_service = $this->service();
|
||||
$msg = "[ $branchCode | $branchName]\n";
|
||||
$msg .= " DATE : " . date("Y-m-d H:i:s") . "\n";
|
||||
$msg .= " UP : " . $this->uptime();
|
||||
$msg .= " ----------\n";
|
||||
$msg .= " Service : \n";
|
||||
$msg .= $msg_service;
|
||||
$msg .= " ----------\n";
|
||||
$msg .= " Resource : \n";
|
||||
$msg .= $this->resource();
|
||||
$msg .= " ----------\n";
|
||||
$msg .= " Connectivity:\n";
|
||||
$msg .= $this->connectivity();
|
||||
$msg .= " Backup:\n";
|
||||
$msg .= $this->backup();
|
||||
$this->log($msg);
|
||||
$this->sasone($msg,$branchCode);
|
||||
$this->log("End Monitoring Pagi");
|
||||
}
|
||||
function uptime() {
|
||||
exec("uptime", $output, $return);
|
||||
$s_output = preg_split("/\s+/", $output[0]);
|
||||
if (count($s_output) >= 5) {
|
||||
$msg = "";
|
||||
for($i=3;$i<=5; $i++) {
|
||||
$msg .= $s_output[$i] . " ";
|
||||
}
|
||||
if ( !strpos($s_output[5],":") ) {
|
||||
$msg .= $s_output[6];
|
||||
}
|
||||
return $msg . "\n";
|
||||
}
|
||||
return $output . "\n";
|
||||
}
|
||||
function service() {
|
||||
exec("pgrep apache2", $output, $return);
|
||||
$result = "";
|
||||
if ($return == 0) {
|
||||
$result .= " Web Server running\n";
|
||||
} else {
|
||||
$result .= " Web Server NOT RUNNING\n";
|
||||
}
|
||||
exec("ps -ef | grep tomcat | grep java | awk ' { print $2 } '",$output,$return);
|
||||
if ($return == 0) {
|
||||
$result .= " Report Server running\n";
|
||||
} else {
|
||||
$result .= " Report Server NOT RUNNING\n";
|
||||
}
|
||||
exec("pgrep mysqld", $output, $return);
|
||||
if ($return == 0) {
|
||||
$result .= " MariaDB Server running\n";
|
||||
} else {
|
||||
$result .= " MariaDB Server NOT RUNNING\n";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function resource() {
|
||||
$df = exec("df -h",$output,$return);
|
||||
$result = "";
|
||||
$is_pac = false;
|
||||
$pac_tgt ="";
|
||||
foreach($output as $line){
|
||||
$parts =preg_split("/\s+/",$line);
|
||||
$mount = $parts[5];
|
||||
if ($mount == "/" || $mount == "/var") {
|
||||
$result .= " folder $mount sisa " . $parts[3] . "\n";
|
||||
}
|
||||
if ($mount == "/data-pacs") {
|
||||
$is_pac = true;
|
||||
$pac_tgt = $parts[0];
|
||||
}
|
||||
}
|
||||
if ($is_pac) {
|
||||
$result .= " Pacs /data-pacs => $pac_tgt \n";
|
||||
$folder = "/data-pacs/" . Date("Ymd",strtotime("now - 1 day"));
|
||||
if ( file_exists($folder)) {
|
||||
$result .= " $folder exists\n";
|
||||
} else {
|
||||
$result .= " $folder not exists\n";
|
||||
}
|
||||
$folder = "/data-pacs/" . Date("Ymd",strtotime("now - 2 day"));
|
||||
if ( file_exists($folder)) {
|
||||
$result .= " $folder exists\n";
|
||||
} else {
|
||||
$result .= " $folder not exists\n";
|
||||
}
|
||||
} else {
|
||||
$result .= " Pacs not mounted \n";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function backup() {
|
||||
$msg = "";
|
||||
$dow = date("w");
|
||||
$file = "/var/backup-data/db/one/daily/backup_one_dow_${dow}.sql";
|
||||
$stat = stat($file);
|
||||
$msg .= " " . str_pad(basename($file),30," ") . round($stat["size"] / ( 1024 * 1024 * 1024),1) . "G"
|
||||
. " " . date("Y-m-d H:i",$stat["ctime"]) . "\n";
|
||||
$file = "/var/backup-data/db/one_log/daily/backup_one_log_dow_${dow}.sql";
|
||||
$stat = stat($file);
|
||||
$msg .= " " . str_pad(basename($file),30," ") . round($stat["size"] / ( 1024 * 1024 * 1024),1) . "G"
|
||||
. " " . date("Y-m-d H:i",$stat["ctime"]) . "\n";
|
||||
return $msg;
|
||||
}
|
||||
function connectivity() {
|
||||
$regionalIP = trim($this->getRegionalIP());
|
||||
$regonlineIP = "mobile.pramita.co.id";
|
||||
$email = "email.pramita.co.id";
|
||||
$result = "result.pramita.co.id";
|
||||
$msg = "";
|
||||
$msg .= $this->ping($regionalIP,80,5,true);
|
||||
$msg .= $this->ping($regonlineIP,443,5);
|
||||
$msg .= $this->ping($email,587,5);
|
||||
$msg .= $this->ping($result,443,5);
|
||||
return $msg;
|
||||
}
|
||||
function ping($host, $port, $timeout, $is_reg = false)
|
||||
{
|
||||
$tB = microtime(true);
|
||||
$fP = fSockOpen($host, $port, $errno, $errstr, $timeout);
|
||||
$s_target = "$host:$port";
|
||||
if ($is_reg) $s_target = "[Reg]$s_target";
|
||||
$s_target = str_pad($s_target,38," ");
|
||||
if (!$fP) {
|
||||
return " $s_target down ( connect timeout in $timeout s)\n";
|
||||
}
|
||||
$tA = microtime(true);
|
||||
return " $s_target " . round((($tA - $tB) * 1000), 0)." ms\n";
|
||||
}
|
||||
function log($msg) {
|
||||
$sdate = Date("Y-m-d H:i:s");
|
||||
echo "$sdate $msg\n";
|
||||
}
|
||||
function getRegionalIP() {
|
||||
$sql = "select S_SystemIPAddressRegional from conf_systems";
|
||||
$qry = $this->db->query($sql);
|
||||
if (! $qry ) {
|
||||
return "devone.aplikasi.web.id";
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) return $rows[0]["S_SystemIPAddressRegional"];
|
||||
return "devone.aplikasi.web.id";
|
||||
}
|
||||
function clean_up_message($msg) {
|
||||
return $msg;
|
||||
}
|
||||
function sasone($msg,$branchCode) {
|
||||
$url = "http://bandungraya.aplikasi.web.id/one-api/tgram/xone_bot/chat_id_v2";
|
||||
// chat id upgraded to -1001166991228
|
||||
$data = json_encode( array(
|
||||
"type"=>"monitoring.pagi",
|
||||
"branchCode" => $branchCode,
|
||||
"text" => $msg,
|
||||
"id" => "-1001166991228"
|
||||
));
|
||||
$z_data = gzdeflate($data,9);
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $z_data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($z_data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
echo $result;
|
||||
}
|
||||
}
|
||||
117
application/controllers/tools/monitoring/Queue.php
Normal file
117
application/controllers/tools/monitoring/Queue.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
class Queue extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index() {
|
||||
$sql = "select * from m_branch where M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'";
|
||||
$branchName = "No Branch";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$branchName = $rows[0]["M_BranchName"];
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
$LIMIT_TIME = 600; // 200s
|
||||
$sql ="select count(*) tot from INFORMATION_SCHEMA.processlist
|
||||
where USER <> 'system user' and TIME >= $LIMIT_TIME and INFO is not null";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$tot_ovr = $rows[0]["tot"];
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
$sql ="select count(*) tot from INFORMATION_SCHEMA.processlist";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$tot= $rows[0]["tot"];
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
if ($tot_ovr > 0 ) {
|
||||
$msg = "* [$branchName] Mysql Long Process \\> $LIMIT_TIME s $tot_ovr, from $tot process *, Top 3 query :\n";
|
||||
$sql = "select substr(INFO,1,500) info from INFORMATION_SCHEMA.processlist
|
||||
where USER <> 'system user' and TIME >= $LIMIT_TIME order by TIME desc limit 0,3";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r ) {
|
||||
$query = $r["info"];
|
||||
$msg .= "\n```python
|
||||
$query
|
||||
```";
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
$this->sasone($msg);
|
||||
}
|
||||
}
|
||||
|
||||
function cek() {
|
||||
$sql = "select * from m_branch where M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'";
|
||||
$branchName = "No Branch";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$branchName = $rows[0]["M_BranchName"];
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
$LIMIT_TIME = 300; // 200s
|
||||
$sql ="select count(*) tot from INFORMATION_SCHEMA.processlist
|
||||
where USER <> 'system user' and TIME >= $LIMIT_TIME and INFO is not null";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$tot_ovr = $rows[0]["tot"];
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
$sql ="select count(*) tot from INFORMATION_SCHEMA.processlist";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$tot= $rows[0]["tot"];
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
if ($tot_ovr > 0 ) {
|
||||
$msg = "* [$branchName] Mysql Long Process \\> $LIMIT_TIME s $tot_ovr, from $tot process *, Top 3 query :\n";
|
||||
$sql = "select substr(INFO,1,500) info from INFORMATION_SCHEMA.processlist
|
||||
where USER <> 'system user' and TIME >= $LIMIT_TIME order by TIME desc limit 0,3";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r ) {
|
||||
$query = $r["info"];
|
||||
$msg .= "\n```python
|
||||
$query
|
||||
```";
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
echo $msg . "\n";
|
||||
}
|
||||
}
|
||||
function sasone($msg) {
|
||||
$url = "http://bandungraya.aplikasi.web.id/one-api/tgram/xone/sasone";
|
||||
$data = json_encode( array("text" => $msg ));
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
echo $result;
|
||||
}
|
||||
}
|
||||
283
application/controllers/tools/monitoring/Rujukan.php
Normal file
283
application/controllers/tools/monitoring/Rujukan.php
Normal file
@@ -0,0 +1,283 @@
|
||||
<?php
|
||||
class rujukan extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index() {
|
||||
$this->cek(true);
|
||||
$this->cek_order(true);
|
||||
$this->cek_validasi(true);
|
||||
}
|
||||
function clean_up_message($msg) {
|
||||
$msg = str_replace("-","\-",$msg);
|
||||
$msg = str_replace("(","\(",$msg);
|
||||
$msg = str_replace(")","\)",$msg);
|
||||
$msg = str_replace(".","\.",$msg);
|
||||
$msg = str_replace("[","\[",$msg);
|
||||
$msg = str_replace("]","\]",$msg);
|
||||
$msg = str_replace("|","\|",$msg);
|
||||
return $msg;
|
||||
}
|
||||
|
||||
function cek_validasi($do_send=false,$date = "") {
|
||||
if ($date == "" ) {
|
||||
$xdate = new DateTime();
|
||||
$xdate->sub(new DateInterval('P1D'));
|
||||
$date = $xdate->format('Y-m-d');
|
||||
}
|
||||
$sql = "select tx_branch_status.*
|
||||
from tx_branch_status
|
||||
where date(TxBranchStatusCreated) >= '$date'
|
||||
and TxBranchStatusRetry > 10 ";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$ids = "0";
|
||||
$child_ids ="0";
|
||||
foreach($rows as $r) {
|
||||
if($r["TxBranchStatusStage"] == "VALIDATION" ) {
|
||||
//print_r($r);
|
||||
if ($r["TxBranchStatusIsSent"] == "Y") continue;
|
||||
$json = json_decode($r["TxBranchStatusJson"],true);
|
||||
foreach($json as $j) {
|
||||
if ($j["incomingRefDetailID"] == "") {
|
||||
continue;
|
||||
}
|
||||
$ids .= "," . $j["incomingRefDetailID"];
|
||||
}
|
||||
foreach($json as $j) {
|
||||
if ($j["incomingRefChildID"] == "") {
|
||||
continue;
|
||||
}
|
||||
$child_ids .= "," . $j["incomingRefChildID"];
|
||||
}
|
||||
}
|
||||
}
|
||||
if($ids != "0" || $child_ids != "0" ) {
|
||||
$sql = "select T_OrderHeaderLabNumber, T_OrderHeaderAddOnLabNumberOrigin,
|
||||
group_concat(incomingRefDetailT_TestName) TestName
|
||||
from
|
||||
incoming_ref_detail
|
||||
join t_orderheader on incomingRefDetailID in ( $ids ) and incomingRefDetailNewT_OrderHeaderID = T_OrderHeaderID
|
||||
join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
union
|
||||
select T_OrderHeaderLabNumber, T_OrderHeaderAddOnLabNumberOrigin,
|
||||
group_concat(incomingRefChildT_TestName) TestName
|
||||
from
|
||||
incoming_ref_child
|
||||
join t_orderheader on incomingRefChildID in ( $child_ids ) and incomingRefChildNewT_OrderHeaderID = T_OrderHeaderID
|
||||
join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
group by T_OrderHeaderID
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
if($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$msg = "";
|
||||
foreach($rows as $r) {
|
||||
$msg .= $r["T_OrderHeaderLabNumber"] . "|*" . $r["T_OrderHeaderAddOnLabNumberOrigin"] . "*";
|
||||
$msg .= "\n\t " . $r["TestName"] . "\n";
|
||||
}
|
||||
if ($msg != "" ) {
|
||||
$msg = "Pending Hasil ke perujuk :\n$msg";
|
||||
$msg = $this->clean_up_message($msg);
|
||||
if ($do_send ) {
|
||||
$this->sasone($msg);
|
||||
} else {
|
||||
echo $msg . "\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function order() {
|
||||
$this->cek_order(true);
|
||||
}
|
||||
function cek_barcode($do_send = false, $date = "") {
|
||||
$w_date = "AND date(incomingRefDetailLastUpdated) = date(now())";
|
||||
if ($date != "" ) {
|
||||
$w_date = "AND date(incomingRefDetailLastUpdated) = '$date' ";
|
||||
}
|
||||
$sql = "select
|
||||
incomingRefDetailLastUpdated,incomingRefOriginM_BranchCode, incomingRefT_RefDeliveryOrderNumber, incomingRefDetailT_OrderHeaderLabNumber, incomingRefDetailT_TestID, incomingRefDetailT_TestName
|
||||
from incoming_ref_detail
|
||||
JOIN incoming_ref ON incomingRefDetailIncomingRefID = incomingRefID
|
||||
JOIN t_orderheader ON incomingRefDetailNewT_OrderHeaderID = T_OrderHeaderID AND T_OrderHeaderIsActive = 'Y'
|
||||
$w_date
|
||||
left join t_barcodelab on T_OrderHeaderID = T_BarcodeLabT_OrderHeaderID
|
||||
where T_BarcodeLabID IS NULL AND
|
||||
((TIME_TO_SEC(time(now())) - TIME_TO_SEC(time(incomingRefDetailLastUpdated)))/60) > 5;
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$tot_pending_barcode = 0;
|
||||
$no_msg = "";
|
||||
foreach($rows as $r ) {
|
||||
if ($no_msg != "" ) $no_msg .= "\n ";
|
||||
$no_msg .= $r["incomingRefOriginM_BranchCode"] . " \| " . $r["incomingRefT_RefDeliveryOrderNumber"]
|
||||
. " \| " . $r["incomingRefDetailT_OrderHeaderLabNumber"] . " \| " . $r["incomingRefDetailT_TestName"];
|
||||
$tot_pending_barcode++;
|
||||
}
|
||||
$msg = "Pending Create Barcode : * $tot_pending_barcode *,\n" . $no_msg ;
|
||||
if ($tot_pending_barcode> 0 ) {
|
||||
if ($do_send) {
|
||||
$this->sasone($msg);
|
||||
} else {
|
||||
echo $msg . "\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
function cek_order($do_send = false ) {
|
||||
$sql = "select * from m_branch where M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'";
|
||||
$branchName = "No Branch";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$branchName = $rows[0]["M_BranchName"];
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
$sql ="
|
||||
SELECT
|
||||
incomingRefID,
|
||||
incomingRefT_RefDeliveryOrderDate,
|
||||
incomingRefT_RefDeliveryOrderNumber,
|
||||
incomingRefOriginM_BranchCode,
|
||||
M_BranchName,
|
||||
incomingRefDetailID,
|
||||
incomingRefDetailT_OrderHeaderID,
|
||||
incomingRefDetailT_OrderHeaderLabNumber,
|
||||
incomingRefDetailM_PatientName,
|
||||
incomingRefDetailFoNote,
|
||||
incomingRefDetailVefificationNote,
|
||||
incomingRefDetailSamplingNote,
|
||||
incomingRefDetailT_TestID,
|
||||
incomingRefDetailT_TestName,
|
||||
incomingRefDetailT_OrderPromiseDateTime,
|
||||
incomingRefDetailT_OrderDetailID,
|
||||
incomingRefDetailT_BarcodeLabBarcode,
|
||||
incomingRefDetailPatient
|
||||
FROM incoming_ref_detail
|
||||
JOIN incoming_ref ON incomingRefDetailIncomingRefID = incomingRefID
|
||||
JOIN m_branch ON incomingRefOriginM_BranchCode = M_BranchCode
|
||||
WHERE incomingRefDetailStatus = 'Y'
|
||||
AND incomingRefDetailNewT_OrderHeaderID IS NULL
|
||||
AND date(incomingRefDetailLastUpdated) = date(now())
|
||||
AND ((TIME_TO_SEC(time(now())) - TIME_TO_SEC(time(incomingRefDetailLastUpdated)))/60) > 5;
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$tot_pending_kirim = 0;
|
||||
$no_msg = "";
|
||||
foreach($rows as $r ) {
|
||||
if ($no_msg != "" ) $no_msg .= "\n ";
|
||||
$no_msg .= $r["incomingRefDetailT_OrderHeaderLabNumber"] . " \| " . $r["incomingRefDetailT_TestName"];
|
||||
$tot_pending_kirim++;
|
||||
}
|
||||
$msg = "Pending Create Order \[* $branchName \] : $tot_pending_kirim *,\n" . $no_msg ;
|
||||
if ($tot_pending_kirim > 0 ) {
|
||||
if ($do_send) {
|
||||
$this->sasone($msg);
|
||||
} else {
|
||||
echo $msg . "\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
}
|
||||
function cek($do_send = false) {
|
||||
$sql = "select * from m_branch where M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'";
|
||||
$branchName = "No Branch";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$branchName = $rows[0]["M_BranchName"];
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
$sql = "SELECT distinct * FROM
|
||||
(SELECT T_RefDeliveryOrderID,
|
||||
T_RefDeliveryOrderNumber,
|
||||
T_RefDeliveryOrderDate,
|
||||
b.M_BranchID as cabang_asal_id,
|
||||
b.M_BranchName as cabang_asal,
|
||||
d.M_BranchID as cabang_tujuan_id,
|
||||
d.M_BranchName as cabang_tujuan
|
||||
FROM t_ref_deliveryorder
|
||||
LEFT JOIN m_branch b ON T_RefDeliveryOrderM_BranchID = b.M_BranchID
|
||||
LEFT JOIN m_branch d ON T_RefDeliveryOrderM_DestinationID = d.M_BranchID
|
||||
WHERE
|
||||
T_RefDeliveryOrderIsActive = 'Y' AND
|
||||
T_RefDeliveryOrderIsConfirm = 'Y' AND
|
||||
T_RefDeliveryOrderIsExternal = 'N' AND
|
||||
date(T_RefDeliveryOrderLastUpdated) = date(now()) AND
|
||||
((TIME_TO_SEC(time(now())) - TIME_TO_SEC(time(T_RefDeliveryOrderLastUpdated)))/60) > 5
|
||||
|
||||
UNION
|
||||
SELECT T_RefDeliveryOrderID,
|
||||
T_RefDeliveryOrderNumber,
|
||||
T_RefDeliveryOrderDate,
|
||||
M_BranchID as cabang_asal_id,
|
||||
M_BranchName as cabang_asal,
|
||||
M_LabReferenceID as cabang_tujuan_id,
|
||||
M_LabReferenceName as cabang_tujuan
|
||||
FROM t_ref_deliveryorder
|
||||
LEFT JOIN m_branch ON T_RefDeliveryOrderM_BranchID = M_BranchID
|
||||
LEFT JOIN m_labreference d ON T_RefDeliveryOrderM_DestinationID = M_LabReferenceID
|
||||
WHERE
|
||||
T_RefDeliveryOrderIsActive = 'Y' AND
|
||||
T_RefDeliveryOrderIsConfirm = 'Y' AND
|
||||
T_RefDeliveryOrderIsExternal = 'Y' AND
|
||||
date(T_RefDeliveryOrderLastUpdated) = date(now()) AND
|
||||
((TIME_TO_SEC(time(now())) - TIME_TO_SEC(time(T_RefDeliveryOrderLastUpdated)))/60) > 5
|
||||
) x
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$tot_pending_kirim = 0;
|
||||
$no_msg = "";
|
||||
foreach($rows as $r ) {
|
||||
if ($no_msg != "" ) $no_msg .= ", ";
|
||||
$no_msg .= $r["T_RefDeliveryOrderNumber"];
|
||||
$tot_pending_kirim++;
|
||||
}
|
||||
$msg = "Pending Rujukan \[* $branchName \] : $tot_pending_kirim *,\n" . $no_msg ;
|
||||
if ($tot_pending_kirim > 0 ) {
|
||||
if ($do_send) {
|
||||
$this->sasone($msg);
|
||||
} else {
|
||||
echo $msg . "\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
}
|
||||
function sasone($msg) {
|
||||
$url = "http://bandungraya.aplikasi.web.id/one-api/tgram/xone/sasone";
|
||||
$data = json_encode( array("text" => $msg ));
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
echo $result;
|
||||
}
|
||||
}
|
||||
301
application/controllers/tools/monitoring/Rujukan_v2.php
Normal file
301
application/controllers/tools/monitoring/Rujukan_v2.php
Normal file
@@ -0,0 +1,301 @@
|
||||
<?php
|
||||
class Rujukan_v2 extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
function index() {
|
||||
$this->log("Start Monitoring Rujukan");
|
||||
$this->cek(true);
|
||||
$this->cek_order(true);
|
||||
$this->cek_validasi(true);
|
||||
}
|
||||
function test() {
|
||||
$msg = "Testing Telegram group baru 2021-02-22 10:00:02 Pending Rujukan [* Pramita Martadinata ] : 1 *";
|
||||
$msg = $this->clean_up_message($msg);
|
||||
echo "$msg \n";
|
||||
$this->sasone($msg);
|
||||
}
|
||||
function log($msg) {
|
||||
$sdate = Date("Y-m-d H:i:s");
|
||||
echo "$sdate $msg\n";
|
||||
}
|
||||
function clean_up_message($msg) {
|
||||
return $msg;
|
||||
$msg = str_replace("-","\-",$msg);
|
||||
$msg = str_replace("(","\(",$msg);
|
||||
$msg = str_replace(")","\)",$msg);
|
||||
$msg = str_replace(".","\.",$msg);
|
||||
$msg = str_replace("[","\[",$msg);
|
||||
$msg = str_replace("]","\]",$msg);
|
||||
$msg = str_replace("|","\|",$msg);
|
||||
return $msg;
|
||||
}
|
||||
|
||||
function cek_validasi($do_send=false,$date = "") {
|
||||
if ($date == "" ) {
|
||||
$xdate = new DateTime();
|
||||
$xdate->sub(new DateInterval('P1D'));
|
||||
$date = $xdate->format('Y-m-d');
|
||||
}
|
||||
$sql = "select tx_branch_status.*
|
||||
from tx_branch_status
|
||||
where date(TxBranchStatusCreated) >= '$date'
|
||||
and TxBranchStatusRetry > 10 ";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$ids = "0";
|
||||
$child_ids ="0";
|
||||
foreach($rows as $r) {
|
||||
if($r["TxBranchStatusStage"] == "VALIDATION" ) {
|
||||
//print_r($r);
|
||||
if ($r["TxBranchStatusIsSent"] == "Y") continue;
|
||||
$json = json_decode($r["TxBranchStatusJson"],true);
|
||||
foreach($json as $j) {
|
||||
if ($j["incomingRefDetailID"] == "") {
|
||||
continue;
|
||||
}
|
||||
$ids .= "," . $j["incomingRefDetailID"];
|
||||
}
|
||||
foreach($json as $j) {
|
||||
if ($j["incomingRefChildID"] == "") {
|
||||
continue;
|
||||
}
|
||||
$child_ids .= "," . $j["incomingRefChildID"];
|
||||
}
|
||||
}
|
||||
}
|
||||
if($ids != "0" || $child_ids != "0" ) {
|
||||
$sql = "select T_OrderHeaderLabNumber, T_OrderHeaderAddOnLabNumberOrigin,
|
||||
group_concat(incomingRefDetailT_TestName) TestName
|
||||
from
|
||||
incoming_ref_detail
|
||||
join t_orderheader on incomingRefDetailID in ( $ids ) and incomingRefDetailNewT_OrderHeaderID = T_OrderHeaderID
|
||||
join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
union
|
||||
select T_OrderHeaderLabNumber, T_OrderHeaderAddOnLabNumberOrigin,
|
||||
group_concat(incomingRefChildT_TestName) TestName
|
||||
from
|
||||
incoming_ref_child
|
||||
join t_orderheader on incomingRefChildID in ( $child_ids ) and incomingRefChildNewT_OrderHeaderID = T_OrderHeaderID
|
||||
join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
group by T_OrderHeaderID
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
if($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$msg = "";
|
||||
foreach($rows as $r) {
|
||||
$msg .= $r["T_OrderHeaderLabNumber"] . "|*" . $r["T_OrderHeaderAddOnLabNumberOrigin"] . "*";
|
||||
$msg .= "\n\t " . $r["TestName"] . "\n";
|
||||
}
|
||||
if ($msg != "" ) {
|
||||
$msg = "Pending Hasil ke perujuk :\n$msg";
|
||||
if ($do_send ) {
|
||||
$this->sasone($msg);
|
||||
} else {
|
||||
echo $msg . "\n";
|
||||
}
|
||||
$this->log($msg);
|
||||
} else {
|
||||
$this->log("Error Hasil Ke Perujuk : " . $this->db->error()["message"]);
|
||||
}
|
||||
} else {
|
||||
$this->log("Error Hasil ke Perujuk : " . $this->db->error()["message"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function order() {
|
||||
$this->cek_order(true);
|
||||
}
|
||||
|
||||
function cek_barcode($do_send = false, $date = "") {
|
||||
$w_date = "AND date(incomingRefDetailLastUpdated) = date(now())";
|
||||
if ($date != "" ) {
|
||||
$w_date = "AND date(incomingRefDetailLastUpdated) = '$date' ";
|
||||
}
|
||||
$sql = "select
|
||||
incomingRefDetailLastUpdated,incomingRefOriginM_BranchCode, incomingRefT_RefDeliveryOrderNumber, incomingRefDetailT_OrderHeaderLabNumber, incomingRefDetailT_TestID, incomingRefDetailT_TestName
|
||||
from incoming_ref_detail
|
||||
JOIN incoming_ref ON incomingRefDetailIncomingRefID = incomingRefID
|
||||
JOIN t_orderheader ON incomingRefDetailNewT_OrderHeaderID = T_OrderHeaderID AND T_OrderHeaderIsActive = 'Y'
|
||||
$w_date
|
||||
left join t_barcodelab on T_OrderHeaderID = T_BarcodeLabT_OrderHeaderID
|
||||
where T_BarcodeLabID IS NULL AND
|
||||
((TIME_TO_SEC(time(now())) - TIME_TO_SEC(time(incomingRefDetailLastUpdated)))/60) > 5;
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$tot_pending_barcode = 0;
|
||||
$no_msg = "";
|
||||
foreach($rows as $r ) {
|
||||
if ($no_msg != "" ) $no_msg .= "\n ";
|
||||
$no_msg .= $r["incomingRefOriginM_BranchCode"] . " \| " . $r["incomingRefT_RefDeliveryOrderNumber"]
|
||||
. " \| " . $r["incomingRefDetailT_OrderHeaderLabNumber"] . " \| " . $r["incomingRefDetailT_TestName"];
|
||||
$tot_pending_barcode++;
|
||||
}
|
||||
$msg = "Pending Create Barcode : * $tot_pending_barcode *,\n" . $no_msg ;
|
||||
if ($tot_pending_barcode> 0 ) {
|
||||
if ($do_send) {
|
||||
$this->sasone($msg);
|
||||
} else {
|
||||
echo $msg . "\n";
|
||||
}
|
||||
$this->log($msg);
|
||||
}
|
||||
} else {
|
||||
$this->log("Error Create Barcode : " . $this->db->error()["message"]);
|
||||
}
|
||||
|
||||
}
|
||||
function cek_order($do_send = false ) {
|
||||
$sql = "select * from m_branch where M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'";
|
||||
$branchName = "No Branch";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$branchName = $rows[0]["M_BranchName"];
|
||||
} else {
|
||||
$this->log("Error Branch : " . $this->db->error()["message"]);
|
||||
}
|
||||
$sql ="
|
||||
SELECT
|
||||
incomingRefID,
|
||||
incomingRefT_RefDeliveryOrderDate,
|
||||
incomingRefT_RefDeliveryOrderNumber,
|
||||
incomingRefOriginM_BranchCode,
|
||||
M_BranchName,
|
||||
incomingRefDetailID,
|
||||
incomingRefDetailT_OrderHeaderID,
|
||||
incomingRefDetailT_OrderHeaderLabNumber,
|
||||
incomingRefDetailM_PatientName,
|
||||
incomingRefDetailFoNote,
|
||||
incomingRefDetailVefificationNote,
|
||||
incomingRefDetailSamplingNote,
|
||||
incomingRefDetailT_TestID,
|
||||
incomingRefDetailT_TestName,
|
||||
incomingRefDetailT_OrderPromiseDateTime,
|
||||
incomingRefDetailT_OrderDetailID,
|
||||
incomingRefDetailT_BarcodeLabBarcode,
|
||||
incomingRefDetailPatient
|
||||
FROM incoming_ref_detail
|
||||
JOIN incoming_ref ON incomingRefDetailIncomingRefID = incomingRefID
|
||||
JOIN m_branch ON incomingRefOriginM_BranchCode = M_BranchCode
|
||||
WHERE incomingRefDetailStatus = 'Y'
|
||||
AND incomingRefDetailNewT_OrderHeaderID IS NULL
|
||||
AND date(incomingRefDetailLastUpdated) = date(now())
|
||||
AND ((TIME_TO_SEC(time(now())) - TIME_TO_SEC(time(incomingRefDetailLastUpdated)))/60) > 5;
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$tot_pending_kirim = 0;
|
||||
$no_msg = "";
|
||||
foreach($rows as $r ) {
|
||||
if ($no_msg != "" ) $no_msg .= "\n ";
|
||||
$no_msg .= $r["incomingRefDetailT_OrderHeaderLabNumber"] . " \| " . $r["incomingRefDetailT_TestName"];
|
||||
$tot_pending_kirim++;
|
||||
}
|
||||
$msg = "Pending Create Order \[* $branchName \] : $tot_pending_kirim *,\n" . $no_msg ;
|
||||
if ($tot_pending_kirim > 0 ) {
|
||||
if ($do_send) {
|
||||
$this->sasone($msg);
|
||||
} else {
|
||||
echo $msg . "\n";
|
||||
}
|
||||
$this->log($msg);
|
||||
}
|
||||
} else {
|
||||
$this->log("Error Create Order : " . $this->db->error()["message"]);
|
||||
}
|
||||
}
|
||||
|
||||
function cek($do_send = false) {
|
||||
$sql = "select * from m_branch where M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'";
|
||||
$branchName = "No Branch";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$branchName = $rows[0]["M_BranchName"];
|
||||
} else {
|
||||
$this->log("Error Pending Merujuk : " . $this->db->error()["message"]);
|
||||
}
|
||||
$sql = "SELECT distinct * FROM
|
||||
(SELECT T_RefDeliveryOrderID,
|
||||
T_RefDeliveryOrderNumber,
|
||||
T_RefDeliveryOrderDate,
|
||||
b.M_BranchID as cabang_asal_id,
|
||||
b.M_BranchName as cabang_asal,
|
||||
d.M_BranchID as cabang_tujuan_id,
|
||||
d.M_BranchName as cabang_tujuan
|
||||
FROM t_ref_deliveryorder
|
||||
LEFT JOIN m_branch b ON T_RefDeliveryOrderM_BranchID = b.M_BranchID
|
||||
LEFT JOIN m_branch d ON T_RefDeliveryOrderM_DestinationID = d.M_BranchID
|
||||
WHERE
|
||||
T_RefDeliveryOrderIsActive = 'Y' AND
|
||||
T_RefDeliveryOrderIsConfirm = 'Y' AND
|
||||
T_RefDeliveryOrderIsExternal = 'N' AND
|
||||
date(T_RefDeliveryOrderLastUpdated) = date(now()) AND
|
||||
((TIME_TO_SEC(time(now())) - TIME_TO_SEC(time(T_RefDeliveryOrderLastUpdated)))/60) > 5
|
||||
|
||||
UNION
|
||||
SELECT T_RefDeliveryOrderID,
|
||||
T_RefDeliveryOrderNumber,
|
||||
T_RefDeliveryOrderDate,
|
||||
M_BranchID as cabang_asal_id,
|
||||
M_BranchName as cabang_asal,
|
||||
M_LabReferenceID as cabang_tujuan_id,
|
||||
M_LabReferenceName as cabang_tujuan
|
||||
FROM t_ref_deliveryorder
|
||||
LEFT JOIN m_branch ON T_RefDeliveryOrderM_BranchID = M_BranchID
|
||||
LEFT JOIN m_labreference d ON T_RefDeliveryOrderM_DestinationID = M_LabReferenceID
|
||||
WHERE
|
||||
T_RefDeliveryOrderIsActive = 'Y' AND
|
||||
T_RefDeliveryOrderIsConfirm = 'Y' AND
|
||||
T_RefDeliveryOrderIsExternal = 'Y' AND
|
||||
date(T_RefDeliveryOrderLastUpdated) = date(now()) AND
|
||||
((TIME_TO_SEC(time(now())) - TIME_TO_SEC(time(T_RefDeliveryOrderLastUpdated)))/60) > 5
|
||||
) x
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$tot_pending_kirim = 0;
|
||||
$no_msg = "";
|
||||
foreach($rows as $r ) {
|
||||
if ($no_msg != "" ) $no_msg .= ", ";
|
||||
$no_msg .= $r["T_RefDeliveryOrderNumber"];
|
||||
$tot_pending_kirim++;
|
||||
}
|
||||
$msg = "Pending Rujukan \[* $branchName \] : $tot_pending_kirim *,\n" . $no_msg ;
|
||||
if ($tot_pending_kirim > 0 ) {
|
||||
if ($do_send) {
|
||||
$this->sasone($msg);
|
||||
} else {
|
||||
echo $msg . "\n";
|
||||
}
|
||||
$this->log($msg);
|
||||
}
|
||||
} else {
|
||||
$this->log("Error Pending Merujuk : " . $this->db->error()["message"]);
|
||||
}
|
||||
}
|
||||
function sasone($msg) {
|
||||
$url = "http://bandungraya.aplikasi.web.id/one-api/tgram/xone_bot/chat_id";
|
||||
$data = json_encode( array("text" => $msg, "id" => "-1001299107569" ));
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
echo $result;
|
||||
}
|
||||
}
|
||||
84
application/controllers/tools/monitoring/Specimenlocal.php
Normal file
84
application/controllers/tools/monitoring/Specimenlocal.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
class Specimenlocal extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index() {
|
||||
$this->cek(true);
|
||||
}
|
||||
function clean_up_message($msg) {
|
||||
$msg = str_replace("-","\-",$msg);
|
||||
$msg = str_replace("(","\(",$msg);
|
||||
$msg = str_replace(")","\)",$msg);
|
||||
$msg = str_replace(".","\.",$msg);
|
||||
$msg = str_replace("[","\[",$msg);
|
||||
$msg = str_replace("]","\]",$msg);
|
||||
$msg = str_replace("|","\|",$msg);
|
||||
return $msg;
|
||||
}
|
||||
function cek($do_send=false,$date = "") {
|
||||
if ($date == "" ) $date = Date("Y-m-d");
|
||||
$sql = "select
|
||||
distinct T_OrderHeaderID, T_OrderHeaderLabNumber, concat(T_TestName) testName
|
||||
from
|
||||
t_orderheader
|
||||
join t_orderdetail on T_OrderHeaderIsActive = 'Y' and date(T_OrderHeaderDate) = ?
|
||||
and T_OrderDetailIsActive = 'Y' and T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID and T_TestIsActive = 'Y' and T_TestT_SampleTypeID > 0
|
||||
join t_specimenlocal on T_TestNat_TestID = T_SpecimenLocalNat_TestID and T_SpecimenLocalIsActive = 'Y'
|
||||
and T_TestT_SampleTypeID <> T_SpecimenLocalT_SampletypeID
|
||||
group by T_OrderHeaderLabNumber";
|
||||
$qry = $this->db->query($sql,array($date));
|
||||
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$msg = "";
|
||||
foreach($rows as $r) {
|
||||
$id = $r["T_OrderHeaderID"];
|
||||
if ( ! $this->is_worklist_receive($id) ) {
|
||||
$msg .= $r["T_OrderHeaderLabNumber"] . " : " . $r["testName"] . "\n";
|
||||
}
|
||||
}
|
||||
if($msg != "" ) {
|
||||
$msg = "Order Specimen Local:\n$msg";
|
||||
if ($do_send === true ) {
|
||||
$msg = $this->clean_up_message($msg);
|
||||
$this->sasone($msg);
|
||||
} else {
|
||||
echo $msg;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
}
|
||||
function is_worklist_receive($id) {
|
||||
$sql = "select count(*) total from t_ordersample where T_OrderSampleT_OrderHeaderID = ? and T_OrderSampleIsActive = 'Y'
|
||||
and T_OrderSampleWorklistReceive = 'Y'";
|
||||
$qry = $this->db->query($sql,array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
if ( $rows[0]["total"] > 0 ) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function sasone($msg) {
|
||||
$url = "http://bandungraya.aplikasi.web.id/one-api/tgram/xone/sasone";
|
||||
$data = json_encode( array("text" => $msg ));
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
echo $result;
|
||||
}
|
||||
}
|
||||
312
application/controllers/tools/monitoring/Wa.php
Normal file
312
application/controllers/tools/monitoring/Wa.php
Normal file
@@ -0,0 +1,312 @@
|
||||
<?php
|
||||
class Wa extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index() {
|
||||
$this->cek(true);
|
||||
}
|
||||
function get_pdf($id,$noreg,$pname) {
|
||||
$pname = str_replace(" ","-",$pname);
|
||||
$pname = str_replace(".","_",$pname);
|
||||
|
||||
$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,array($id));
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$ts = "&ts=" . date("Ymdhis");
|
||||
foreach($rows as $r) {
|
||||
$name = $r["Group_ResultName"];
|
||||
$gid = $r["Group_ResultID"];
|
||||
$temail = $r["temail"];
|
||||
$isnonlab = $r["Group_ResultFlagNonLab"];
|
||||
$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=" . $id . $ts;
|
||||
break;
|
||||
case 2 :
|
||||
$report = "/birt/frameset?__report=report/one/lab/rpt_hasil_papsmear_email.rptdesign&__format=pdf&username=admin&PID=" . $id . $ts;
|
||||
break;
|
||||
case 3 :
|
||||
$report = "/birt/frameset?__report=report/one/lab/rpt_hasil_fna_email.rptdesign&__format=pdf&username=admin&PID=" . $id . $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=" . $id . $ts;
|
||||
break;
|
||||
case 13 :
|
||||
$report = "/birt/frameset?__report=report/one/lab/rpt_test_mikro_email.rptdesign&__format=pdf&username=admin&PID=" . $id . $ts;
|
||||
break;
|
||||
case 14 :
|
||||
$report = "/birt/frameset?__report=report/one/lab/rpt_hasil_cytologi_email.rptdesign&__format=pdf&username=admin&PID=" . $id . $ts;
|
||||
break;
|
||||
case 15 :
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 16 :
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
case 17 :
|
||||
$report = $emailnonlaburl;
|
||||
break;
|
||||
}
|
||||
if ($report != "-") {
|
||||
$result[] = array(
|
||||
"name" => $name,
|
||||
"groupID" => $gid,
|
||||
"fname" => $noreg . "-" . $pname . "-" . $name . ".pdf",
|
||||
"url" => $report);
|
||||
}else{
|
||||
$result[] = array(
|
||||
"name" => $name . "*". $temail ."*",
|
||||
"fname" => "File tidak ditemukan",
|
||||
"url" => "");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
function clean_up_message($msg) {
|
||||
$msg = str_replace("=","\=",$msg);
|
||||
$msg = str_replace("-","\-",$msg);
|
||||
$msg = str_replace("(","\(",$msg);
|
||||
$msg = str_replace(")","\)",$msg);
|
||||
$msg = str_replace(".","\.",$msg);
|
||||
$msg = str_replace("[","\[",$msg);
|
||||
$msg = str_replace("]","\]",$msg);
|
||||
$msg = str_replace("|","\|",$msg);
|
||||
$msg = str_replace("_","\_",$msg);
|
||||
return $msg;
|
||||
}
|
||||
function cek_terkirim($d) {
|
||||
foreach($d as $x ) {
|
||||
$json = json_decode($x["Tx_WhatsappJson"],true);
|
||||
$rst = array();
|
||||
foreach($json as $j) {
|
||||
$doc = $j["data"]["message"];
|
||||
$ext = pathinfo($doc, PATHINFO_EXTENSION);
|
||||
if ($ext == "pdf" ) {
|
||||
$status = "";
|
||||
if($x["Tx_WhatsappDetailIsSend"] == "Y" ) $status = "K";
|
||||
if($x["Tx_WhatsappDetailIsReceive"] == "Y" ) $status .= "T";
|
||||
if($x["Tx_WhatsappDetailIsRead"] == "Y" ) $status = "B";
|
||||
$rst[$doc] = array("status" => $status, "message" => $j["message"] );
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rst;
|
||||
}
|
||||
function cek($debug=false) {
|
||||
echo "<pre>";
|
||||
$sql = "select * from m_branch where M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'";
|
||||
$branchName = "No Branch";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$branchName = $rows[0]["M_BranchName"];
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
$date = $this->sys_input["date"];
|
||||
if ($date == "" ) $date = date("Y-m-d");
|
||||
|
||||
$sql = "select group_concat(distinct T_OrderHeaderID) xids
|
||||
from
|
||||
t_orderheader
|
||||
join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID and T_OrderHeaderAddOnIsActive = 'Y'
|
||||
join result_processtooffice on Result_ProcessToOfficeT_OrderHeaderID= T_OrderHeaderID
|
||||
join t_orderdelivery on T_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
and (
|
||||
date(T_OrderHeaderDate) = ?
|
||||
or date(T_OrderHeaderDate + interval 1 day ) = ?
|
||||
or date(T_OrderDeliveryCreated) = ?
|
||||
or date(T_OrderDeliveryCreated + interval 1 day ) = ?
|
||||
or date(Result_ProcessToOfficeCreated) = ?
|
||||
)
|
||||
and T_OrderHeaderDate > '2020-09-27'
|
||||
and T_OrderDeliveryIsActive = 'Y'
|
||||
and T_OrderDeliveryM_DeliveryTypeID in ( 4 )
|
||||
";
|
||||
$ids = "";
|
||||
$query = $this->db->query($sql,array($date,$date,$date,$date,$date));
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) > 0 ) $ids = $rows[0]["xids"];
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
if ($ids == "") {
|
||||
echo "Zero";
|
||||
exit;
|
||||
}
|
||||
// populate tx_whatsapp status
|
||||
$sql = "select *
|
||||
from tx_whatsapp
|
||||
join tx_whatsappdetail on Tx_WhatsappID = Tx_WhatsappDetailTx_WhatsappID
|
||||
where Tx_WhatsappT_OrderHeaderID in ( $ids )
|
||||
and Tx_WhatsappIsSent = 'Y'";
|
||||
$query = $this->db->query($sql);
|
||||
$tx_whatsapp = array();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $r) {
|
||||
$headerID = $r["Tx_WhatsappT_OrderHeaderID"];
|
||||
$groupResultID = $r["Tx_WhatsappGroup_ResultID"];
|
||||
$deliveryID = $r["Tx_WhatsappM_DeliveryID"];
|
||||
$idx = "$headerID-$deliveryID-$groupResultID";
|
||||
if (! isset($tx_whatsapp[$idx]) ) $tx_whatsapp[$idx] = array();
|
||||
$tx_whatsapp[$idx][] = $r;
|
||||
}
|
||||
|
||||
} else {
|
||||
echo json_encode( array("status"=> "ERR" ,
|
||||
"message" => print_r($this->db->error(),true)
|
||||
));
|
||||
}
|
||||
$sql = "select distinct T_OrderHeaderID, T_OrderHeaderLabNumber, T_OrderHeaderLabNumberExt,
|
||||
M_DeliveryID, M_DeliveryName, M_DeliverySource, T_OrderDeliveryDestination,
|
||||
T_OrderHeaderDate, fn_get_patient_atribute(T_OrderHeaderM_PatientID) PatientName,
|
||||
fn_global_doctor_name(T_OrderHeaderSenderM_DoctorID) DoctorName,
|
||||
IF(M_MouIsBill = 'Y','Y',ifnull(Last_StatusPaymentIsLunas,'N')) IsLunas,
|
||||
date_format(T_OrderHeaderDate,'%d %M %Y') xdate,
|
||||
fn_global_doctor_name(T_OrderHeaderSenderM_DoctorID) DoctorName,
|
||||
M_DoctorHP,
|
||||
T_OrderHeaderAddOnReadyPrint, Result_ProcessToOfficeStatus
|
||||
from t_orderheader
|
||||
join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
join m_doctor on T_OrderHeaderSenderM_DoctorID = M_DoctorID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
join t_orderdelivery on T_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID and T_OrderDeliveryIsActive = 'Y'
|
||||
and T_OrderDeliveryM_DeliveryTypeID in ( 4 )
|
||||
join result_processtooffice on Result_ProcessToOfficeT_OrderHeaderID= T_OrderHeaderID
|
||||
and Result_ProcessToOfficeT_OrderDeliveryID = T_OrderDeliveryID
|
||||
and Result_ProcessToOfficeStatus = 'S' and Result_ProcessToOfficeIsActive ='Y'
|
||||
join m_delivery on T_OrderDeliveryM_DeliveryID = M_DeliveryID
|
||||
left join last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
|
||||
where T_OrderHeaderID in ( $ids )
|
||||
order by IsLunas desc, T_OrderHeaderID
|
||||
limit 0,2000";
|
||||
$query = $this->db->query($sql);
|
||||
$ready_print =0;
|
||||
$ready_report=0;
|
||||
$queue = 0;
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$list_result = array();
|
||||
$counter_list = 0;
|
||||
$terkirim = array();
|
||||
foreach($rows as $idx => $r) {
|
||||
$headerID = $r["T_OrderHeaderID"];
|
||||
$deliveryID = $r["M_DeliveryID"];
|
||||
$j_pasien = json_decode($r["PatientName"],true);
|
||||
$xname = $j_pasien["patient_fullname"];
|
||||
$x_reports = $this->get_pdf($r["T_OrderHeaderID"], $r["T_OrderHeaderLabNumber"], $xname);
|
||||
$reports = array();
|
||||
foreach($x_reports as $xr) {
|
||||
$groupResultID = $xr["groupID"];
|
||||
$wa_idx = "$headerID-$deliveryID-$groupResultID";
|
||||
if (isset($tx_whatsapp[$wa_idx])) {
|
||||
$terkirim[$headerID] = array(
|
||||
"nolab" => $r["T_OrderHeaderLabNumber"],
|
||||
"date" => substr($r["T_OrderHeaderDate"],0,10),
|
||||
"hp" => $r["T_OrderDeliveryDestination"],
|
||||
"pasien" => $xname,
|
||||
"status" => $this->cek_terkirim($tx_whatsapp[$wa_idx])
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if ($groupResultID == 1 && $r["T_OrderHeaderAddOnReadyPrint"] == "N" ) {
|
||||
$ready_print++;
|
||||
continue;
|
||||
}
|
||||
$xr["Result_ProcessToOfficeStatus"] = $r["Result_ProcessToOfficeStatus"];
|
||||
$reports[] = $xr;
|
||||
}
|
||||
if ( count($reports) == 0 ) {
|
||||
unset($rows[$idx]);
|
||||
$ready_report++;
|
||||
continue;
|
||||
}
|
||||
$queue++;
|
||||
}
|
||||
$total_issue = 0;
|
||||
foreach($terkirim as $k) {
|
||||
$is_false = false;
|
||||
foreach($k["status"] as $doc => $s) {
|
||||
if ($s["status"] == "" ) $is_false = true;
|
||||
}
|
||||
if ($is_false) {
|
||||
$total_issue++;
|
||||
echo "{$k['date']} {$k['nolab']} : [{$k['hp']}] : {$k['pasien']} => ";
|
||||
foreach($k["status"] as $doc => $s) {
|
||||
echo "{$doc} : {$s['status']}, ";
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
echo "\nTotal terkirim ke Provider , belum terima notifikasi KTB : $total_issue\n";
|
||||
exit;
|
||||
} else {
|
||||
echo "Err: " . print_r($this->db->error(),true);
|
||||
}
|
||||
}
|
||||
function print_chr($inp) {
|
||||
for($i=0;$i<strlen($inp);$i++) {
|
||||
$chr = substr($inp,$i,1);
|
||||
echo "$i\t$chr => " . ord($chr) . "\n";
|
||||
}
|
||||
}
|
||||
function sasone($msg) {
|
||||
$url = "http://bandungraya.aplikasi.web.id/one-api/tgram/xone/sasone";
|
||||
$data = json_encode( array("text" => $msg ));
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
echo $result;
|
||||
}
|
||||
}
|
||||
93
application/controllers/tools/monitoring/Xdb.php
Normal file
93
application/controllers/tools/monitoring/Xdb.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
class Xdb extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index() {
|
||||
$this->cek(true);
|
||||
}
|
||||
function clean_up_message($msg) {
|
||||
$msg = str_replace("-","\-",$msg);
|
||||
$msg = str_replace("(","\(",$msg);
|
||||
$msg = str_replace(")","\)",$msg);
|
||||
$msg = str_replace(".","\.",$msg);
|
||||
$msg = str_replace("[","\[",$msg);
|
||||
$msg = str_replace("]","\]",$msg);
|
||||
$msg = str_replace("|","\|",$msg);
|
||||
$msg = str_replace("_","\_",$msg);
|
||||
return $msg;
|
||||
}
|
||||
function replikasi($debug=false) {
|
||||
$sql = "select * from m_branch where M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'";
|
||||
$branchName = "No Branch";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$branchName = $rows[0]["M_BranchName"];
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
$sql = "show slave status";
|
||||
$qry = $this->db->query($sql);
|
||||
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$msg = "";
|
||||
if(count($rows) > 0 ) {
|
||||
$r = $rows[0];
|
||||
$prm = "Slave_IO_Running";
|
||||
$msg .= "$prm : " . $r[$prm] . "\n";
|
||||
$prm = "Slave_SQL_Running";
|
||||
$msg .= "$prm : " . $r[$prm] . "\n";
|
||||
$prm = "Seconds_Behind_Master";
|
||||
$msg .= "$prm : " . $r[$prm] . "\n";
|
||||
|
||||
$prm = "Last_Errno";
|
||||
$err_no = intval($r[$prm]);
|
||||
$msg .= "$prm : " . $r[$prm] . "\n";
|
||||
|
||||
if ($err_no > 0 ) {
|
||||
$prm = "Last_Error";
|
||||
$msg .= "$prm : " . $r[$prm] . "\n";
|
||||
}
|
||||
}
|
||||
if ($debug || $err_no > 0 ) {
|
||||
echo $msg;
|
||||
} else {
|
||||
echo "";
|
||||
}
|
||||
exit;
|
||||
if($msg != "" ) {
|
||||
$msg = "[REPLIKASI] $branchName :\n$msg";
|
||||
if ($debug || $err_no > 0 ) {
|
||||
$msg = $this->clean_up_message($msg);
|
||||
$this->sasone($msg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
}
|
||||
function print_chr($inp) {
|
||||
for($i=0;$i<strlen($inp);$i++) {
|
||||
$chr = substr($inp,$i,1);
|
||||
echo "$i\t$chr => " . ord($chr) . "\n";
|
||||
}
|
||||
}
|
||||
function sasone($msg) {
|
||||
$url = "http://bandungraya.aplikasi.web.id/one-api/tgram/xone/sasone";
|
||||
$data = json_encode( array("text" => $msg ));
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
echo $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user