Initial import

This commit is contained in:
sas.fajri
2026-05-25 20:01:37 +07:00
commit 710d7c1b97
10371 changed files with 2381698 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
<?php
class Adhoc extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database('regional', true);
}
function status($branchCode) {
$sql = "select * from req_rerun where Req_ReRunM_BranchCode = '{$branchCode}' AND Req_ReRunStatus = 'N'";
$qry = $this->db->query($sql);
$rows = $qry->result_array();
foreach($rows as $idx => $r ) {
echo $r["Req_ReRunDateSchedule"] . " ";
}
}
function update() {
$prm = $this->sys_input;
$branchCode = $prm['branch'];
$date = explode("^", $prm['date']);
foreach($date as $r) {
$sql = "UPDATE req_rerun SET Req_ReRunStatus = 'Y', Req_ReRunRetry = Req_ReRunRetry + 1 where Req_ReRunM_BranchCode = '{$branchCode}' AND Req_ReRunDateSchedule = '{$r}'";
$qry = $this->db->query($sql);
if (! $qry) {
print_r($this->db->error());
}else{
echo $branchCode . " ". $r ." telah di download ". "\n";
}
}
}
}

View File

@@ -0,0 +1,77 @@
<?php
class Replication extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
}
function index() {
echo "Replication API";
}
function monitor() {
//master
$sql = "show master status";
$qry = $this->db->query($sql);
if (! $qry) {
echo json_encode( array("status" => "ERR" , "message" => "Errror Master Status : " . print_r($this->db->error(),true) ) );
exit;
}
$rows = $qry->result_array();
$master = array();
$master["status"] = "Running";
$master["file"] = $rows[0]["File"];
$master["position"] = $rows[0]["Position"];
$sql = "select * from m_branch where m_branchIsActive = 'Y'";
$qry = $this->db->query($sql);
if (! $qry ) {
echo json_encode( array("status" => "ERR" , "message" => "Error M_Branch : " . print_r($this->db->error(),true) ) );
exit;
}
$rows = $qry->result_array();
$slave = array();
foreach($rows as $r) {
$branchCode = $r["M_BranchCode"];
$branchName = $r["M_BranchName"];
$branchIP = $r["M_BranchIPAddress"];
$slave[] = array("code" => $branchCode, "name" => $branchName );
$idx = count($slave) - 1;
$url = "http://$branchIP/one-api/tools/replication/slave";
$get_rst = $this->get($url);
$rst = json_decode($get_rst,true);
if ($rst["status"] == "ERR" || ! $rst) {
$slave[$idx] = array_merge($slave[$idx], array("status"=>"Connection Issue (" . $rst["message"] . ")",
"Behind" => -1, "Table" => array(), "MasterLogFile"=> "", "ReadPosition" => 0 ));
} else {
$slave[$idx] = array_merge($slave[$idx], $rst);
}
}
$result = array( "status" => "OK" , "master" => $master , "slave" => $slave) ;
echo json_encode($result);
}
function get($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
if ( curl_error($ch) != "" ) {
$result = json_encode(array("status" => "ERR", "message" => curl_error($ch) ));
}
curl_close($ch);
return $result;
}
function post($url,$data) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data))
);
$result = curl_exec($ch);
return $result;
}
}

View File

@@ -0,0 +1,24 @@
<?php
class Mou extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
}
function fix_id($mouID) {
$this->load->library("SsPriceMou");
$rst = $this->sspricemou->create($mouID);
print_r($rst);
echo "\n";
}
function fix_all() {
$this->load->library("SsPriceMouPx");
$sql = "select * from m_mou where M_MouIsActive = 'Y' ";
$qry = $this->db->query($sql);
$rows = $qry->result_array();
foreach($rows as $idx => $r ) {
echo "$idx. Proses : " . $r["M_MouName"] . "\n";
$this->sspricemoupx->create($r["M_MouID"]);
}
}
}

View File

@@ -0,0 +1,24 @@
<?php
class MouPx extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
}
function fix_id($mouID) {
$this->load->library("SsPriceMouPx");
$rst = $this->sspricemoupx->create($mouID);
print_r($rst);
echo "\n";
}
function fix_all() {
$this->load->library("SsPriceMouPx");
$sql = "select * from m_mou where M_MouIsActive = 'Y' ";
$qry = $this->db->query($sql);
$rows = $qry->result_array();
foreach($rows as $idx => $r ) {
echo "$idx. Proses : " . $r["M_MouName"] . "\n";
$this->sspricemoupx->create($r["M_MouID"]);
}
}
}

View File

@@ -0,0 +1,3 @@
<?php
?>

View File

@@ -0,0 +1,149 @@
<?php
class R_insentive extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
}
function rekap() {
$md5 = $this->sys_input["md5"];
$jdata = $this->sys_input["data"];
$l_md5 = md5($jdata);
if ($md5 != $l_md5) {
echo json_encode( array( "status" => "ERR",
"message" => "$md5 <> local $l_md5"));
exit;
}
$rows = json_decode($jdata,true);
if (count($rows) == 0 ) {
echo json_encode( array("status" => "OK", "message" => "No Data uploaded." ));
exit;
}
$d_where = "";
foreach($rows as $r) {
$branchCode = $r["SsrMrInsentiveRkM_BranchCode"];
$month= $r["SsrMrInsentiveRkMonth"];
$year= $r["SsrMrInsentiveRkYear"];
$staffNIK= $r["SsrMrInsentiveRkStaffNIK"];
if ($d_where != "" ) $d_where .= " or ";
$d_where .= " ( SsrMrInsentiveRkM_BranchCode = '$branchCode' and SsrMrInsentiveRkMonth = $month
and SsrMrInsentiveRkYear = $year and ( SsrMrInsentiveRkStaffNIK = '$staffNIK' or SsrMrInsentiveRkStaffNIK is null) ) ";
}
if ($d_where != "" ) {
$sql = "delete from ssr_mr_insentive_rk where $d_where";
$qry = $this->db->query($sql);
if (! $qry ) {
echo json_encode( array("status" => "ERR", "message" => print_r($this->db->error(),true)));
exit;
}
}
$qry = $this->db->insert_batch("ssr_mr_insentive_rk", $rows);
if (! $qry ) {
echo json_encode( array("status" => "ERR", "message" => print_r($this->db->error(),true)));
exit;
}
echo json_encode( array("status" => "OK", "message" => ""));
}
function cur() {
$md5 = $this->sys_input["md5"];
$jdata = $this->sys_input["data"];
$l_md5 = md5($jdata);
if ($md5 != $l_md5) {
echo json_encode( array( "status" => "ERR",
"message" => "$md5 <> local $l_md5"));
exit;
}
$rows = json_decode($jdata,true);
if (count($rows) == 0 ) {
echo json_encode( array("status" => "OK", "message" => "No Data uploaded." ));
exit;
}
$d_where = "";
foreach($rows as $r) {
$branchCode = $r["SsrMrInsentiveM_BranchCode"];
$month= $r["SsrMrInsentiveMonth"];
$year= $r["SsrMrInsentiveYear"];
$staffNIK= $r["SsrMrInsentiveStaffNIK"];
if ($d_where != "" ) $d_where .= " or ";
$d_where .= " ( SsrMrInsentiveM_BranchCode = '$branchCode' and SsrMrInsentiveMonth = $month
and SsrMrInsentiveYear = $year and ( SsrMrInsentiveStaffNIK = '$staffNIK' or SsrMrInsentiveStaffNIK is null) ) ";
}
if ($d_where != "" ) {
$sql = "delete from ssr_mr_insentive where $d_where";
$qry = $this->db->query($sql);
if (! $qry ) {
echo json_encode( array("status" => "ERR", "message" => print_r($this->db->error(),true)));
exit;
}
}
$qry = $this->db->insert_batch("ssr_mr_insentive", $rows);
if (! $qry ) {
echo json_encode( array("status" => "ERR", "message" => print_r($this->db->error(),true)));
exit;
}
echo json_encode( array("status" => "OK", "message" => ""));
}
function index() {
$md5 = $this->sys_input["md5"];
$jdata = $this->sys_input["data"];
$l_md5 = md5($jdata);
if ($md5 != $l_md5) {
echo json_encode( array( "status" => "ERR",
"message" => "$md5 <> local $l_md5"));
exit;
}
$data = json_decode($jdata,true);
$status = array();
$d_sql = "delete from ssr_mr01 where SsrMr01M_BranchCode = ? and
SsrMr01T_OrderHeaderID = ? and SsrMr01T_TestID = ?";
$sql = "insert into ssr_mr01(SsrMr01M_BranchCode, SsrMr01M_PatientName, SsrMr01T_OrderHeaderDate, SsrMr01T_OrderHeaderLabNumberExt,
SsrMr01T_OrderHeaderID , SsrMr01M_DoctorOldCode , SsrMr01T_TestID , SsrMr01Total,
SsrMr01Nat_JPADetailDiscount, SsrMr01JpaGroupName,
SsrMr01Jpa, SsrMr01Nat_JpaGroupMaxJpaDisc, SsrMr01Bruto,
SsrMr01M_CompanyID, SsrMr01M_DoctorAddressOldCode, SsrMr01M_DoctorID, SsrMr01M_DoctorAddressID)
values(?,?,?,?, ?,?,?,?, ?,?, ?,?,?, ?,?, ?,?)";
foreach($data as $d) {
$SsrMr01M_BranchCode = $d["SsrMr01M_BranchCode"];
$SsrMr01M_PatientName =$d["SsrMr01M_PatientName"];
$SsrMr01T_OrderHeaderID = $d["SsrMr01T_OrderHeaderID"];
$SsrMr01T_OrderHeaderDate =$d["SsrMr01T_OrderHeaderDate"];
$SsrMr01T_OrderHeaderLabNumberExt =$d["SsrMr01T_OrderHeaderLabNumberExt"];
$SsrMr01M_DoctorOldCode =$d["SsrMr01M_DoctorOldCode"];
$SsrMr01T_TestID = $d["SsrMr01T_TestID"];
$SsrMr01Total = $d["SsrMr01Total"];
$SsrMr01Nat_JPADetailDiscount = $d["SsrMr01Nat_JPADetailDiscount"];
$SsrMr01JpaGroupName = $d["SsrMr01JpaGroupName"];
$SsrMr01Jpa = $d["SsrMr01Jpa"];
$SsrMr01Nat_JpaGroupMaxJpaDisc = $d["SsrMr01Nat_JpaGroupMaxJpaDisc"];
$SsrMr01Bruto = $d["SsrMr01Bruto"];
$SsrMr01M_CompanyID =$d["SsrMr01M_CompanyID"];
$SsrMr01M_DoctorAddressOldCode =$d["SsrMr01M_DoctorAddressOldCode"];
$SsrMr01M_DoctorID =$d["SsrMr01M_DoctorID"];
$SsrMr01M_DoctorAddressID =$d["SsrMr01M_DoctorAddressID"];
try{
$qry = $this->db->query($d_sql, array($SsrMr01M_BranchCode, $SsrMr01T_OrderHeaderID,$SsrMr01T_TestID));
if ($qry) {
$qry = $this->db->query($sql,array( $SsrMr01M_BranchCode, $SsrMr01M_PatientName,
$SsrMr01T_OrderHeaderDate, $SsrMr01T_OrderHeaderLabNumberExt,
$SsrMr01T_OrderHeaderID , $SsrMr01M_DoctorOldCode , $SsrMr01T_TestID , $SsrMr01Total,
$SsrMr01Nat_JPADetailDiscount, $SsrMr01JpaGroupName,
$SsrMr01Jpa, $SsrMr01Nat_JpaGroupMaxJpaDisc, $SsrMr01Bruto,
$SsrMr01M_CompanyID,$SsrMr01M_DoctorAddressOldCode, $SsrMr01M_DoctorID, $SsrMr01M_DoctorAddressID));
if($qry) {
$status[] = $d["SsrMr01ID"];
}else {
print_r($this->db->error());
}
} else {
print_r($this->db->error());
}
} catch(Exception $e) {
print_r($this->db->error());
}
}
echo json_encode( array("status" => "OK" , "SsrMr01ID" => $status));
}
}

View File

@@ -0,0 +1,71 @@
<?php
class R_mr01 extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
}
function index() {
$md5 = $this->sys_input["md5"];
$jdata = $this->sys_input["data"];
$l_md5 = md5($jdata);
if ($md5 != $l_md5) {
echo json_encode( array( "status" => "ERR",
"message" => "$md5 <> local $l_md5"));
exit;
}
$data = json_decode($jdata,true);
$status = array();
$d_sql = "delete from ssr_mr01 where SsrMr01M_BranchCode = ? and
SsrMr01T_OrderHeaderID = ? and SsrMr01T_TestID = ?";
$sql = "insert into ssr_mr01(SsrMr01M_BranchCode, SsrMr01M_PatientName, SsrMr01T_OrderHeaderDate, SsrMr01T_OrderHeaderLabNumberExt,
SsrMr01T_OrderHeaderID , SsrMr01M_DoctorOldCode , SsrMr01T_TestID , SsrMr01Total,
SsrMr01Nat_JPADetailDiscount, SsrMr01JpaGroupName,
SsrMr01Jpa, SsrMr01Nat_JpaGroupMaxJpaDisc, SsrMr01Bruto,
SsrMr01M_CompanyID, SsrMr01M_DoctorAddressOldCode, SsrMr01M_DoctorID, SsrMr01M_DoctorAddressID)
values(?,?,?,?, ?,?,?,?, ?,?, ?,?,?, ?,?, ?,?)";
foreach($data as $d) {
$SsrMr01M_BranchCode = $d["SsrMr01M_BranchCode"];
$SsrMr01M_PatientName =$d["SsrMr01M_PatientName"];
$SsrMr01T_OrderHeaderID = $d["SsrMr01T_OrderHeaderID"];
$SsrMr01T_OrderHeaderDate =$d["SsrMr01T_OrderHeaderDate"];
$SsrMr01T_OrderHeaderLabNumberExt =$d["SsrMr01T_OrderHeaderLabNumberExt"];
$SsrMr01M_DoctorOldCode =$d["SsrMr01M_DoctorOldCode"];
$SsrMr01T_TestID = $d["SsrMr01T_TestID"];
$SsrMr01Total = $d["SsrMr01Total"];
$SsrMr01Nat_JPADetailDiscount = $d["SsrMr01Nat_JPADetailDiscount"];
$SsrMr01JpaGroupName = $d["SsrMr01JpaGroupName"];
$SsrMr01Jpa = $d["SsrMr01Jpa"];
$SsrMr01Nat_JpaGroupMaxJpaDisc = $d["SsrMr01Nat_JpaGroupMaxJpaDisc"];
$SsrMr01Bruto = $d["SsrMr01Bruto"];
$SsrMr01M_CompanyID =$d["SsrMr01M_CompanyID"];
$SsrMr01M_DoctorAddressOldCode =$d["SsrMr01M_DoctorAddressOldCode"];
$SsrMr01M_DoctorID =$d["SsrMr01M_DoctorID"];
$SsrMr01M_DoctorAddressID =$d["SsrMr01M_DoctorAddressID"];
try{
$qry = $this->db->query($d_sql, array($SsrMr01M_BranchCode, $SsrMr01T_OrderHeaderID,$SsrMr01T_TestID));
if ($qry) {
$qry = $this->db->query($sql,array( $SsrMr01M_BranchCode, $SsrMr01M_PatientName,
$SsrMr01T_OrderHeaderDate, $SsrMr01T_OrderHeaderLabNumberExt,
$SsrMr01T_OrderHeaderID , $SsrMr01M_DoctorOldCode , $SsrMr01T_TestID , $SsrMr01Total,
$SsrMr01Nat_JPADetailDiscount, $SsrMr01JpaGroupName,
$SsrMr01Jpa, $SsrMr01Nat_JpaGroupMaxJpaDisc, $SsrMr01Bruto,
$SsrMr01M_CompanyID,$SsrMr01M_DoctorAddressOldCode, $SsrMr01M_DoctorID, $SsrMr01M_DoctorAddressID));
if($qry) {
$status[] = $d["SsrMr01ID"];
}else {
print_r($this->db->error());
}
} else {
print_r($this->db->error());
}
} catch(Exception $e) {
print_r($this->db->error());
}
}
echo json_encode( array("status" => "OK" , "SsrMr01ID" => $status));
}
}

View File

@@ -0,0 +1,66 @@
<?php
class R_mr03 extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
}
function index() {
$md5 = $this->sys_input["md5"];
$jdata = $this->sys_input["data"];
$l_md5 = md5($jdata);
if ($md5 != $l_md5) {
echo json_encode( array( "status" => "ERR",
"message" => "$md5 <> local $l_md5"));
exit;
}
$data = json_decode($jdata,true);
$status = array();
$d_sql = "delete from ssr_mr03 where SsrMr03M_BranchCode = ? and
SsrMr03T_OrderHeaderID = ?";
$sql = "insert into ssr_mr03(SsrMr03T_OrderHeaderID, SsrMr03M_BranchCode,SsrMr03M_StaffNIK,
SsrMr03M_PatientName,SsrMr03M_CompanyID,SsrMr03M_DoctorOldCode,
SsrMr03T_OrderHeaderDate,SsrMr03T_OrderHeaderLabNumberExt, SsrMr03Total,
SsrMr03Reward,SsrMr03RoundReward,SsrMr03Nat_JpaGroupMaxJpaDisc,
SsrMr03M_No_FormRev, SsrMr03M_DoctorAddressOldCode, SsrMr03M_DoctorID, SsrMr03M_DoctorAddressID)
values(?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?, ?,?)";
foreach($data as $d) {
$SsrMr03T_OrderHeaderID = $d["SsrMr03T_OrderHeaderID"];
$SsrMr03M_BranchCode = $d["SsrMr03M_BranchCode"];
$SsrMr03M_StaffNIK = $d["SsrMr03M_StaffNIK"];
$SsrMr03M_PatientName =$d["SsrMr03M_PatientName"];
$SsrMr03M_CompanyID =$d["SsrMr03M_CompanyID"];
$SsrMr03M_DoctorOldCode =$d["SsrMr03M_DoctorOldCode"];
$SsrMr03T_OrderHeaderDate =$d["SsrMr03T_OrderHeaderDate"];
$SsrMr03T_OrderHeaderLabNumberExt =$d["SsrMr03T_OrderHeaderLabNumberExt"];
$SsrMr03Total = $d["SsrMr03Total"];
$SsrMr03Reward = $d["SsrMr03Reward"];
$SsrMr03RoundReward = $d["SsrMr03RoundReward"];
$SsrMr03Nat_JpaGroupMaxJpaDisc = $d["SsrMr03Nat_JpaGroupMaxJpaDisc"];
$SsrMr03M_No_FormRev = $d["SsrMr03M_No_FormRev"];
$SsrMr03M_DoctorAddressOldCode = $d["SsrMr03M_DoctorAddressOldCode"];
$SsrMr03M_DoctorID = $d["SsrMr03M_DoctorID"];
$SsrMr03M_DoctorAddressID = $d["SsrMr03M_DoctorAddressID"];
try{
$qry = $this->db->query($d_sql, array($SsrMr03M_BranchCode, $SsrMr03T_OrderHeaderID));
if ($qry) {
$qry = $this->db->query($sql,array($SsrMr03T_OrderHeaderID, $SsrMr03M_BranchCode,$SsrMr03M_StaffNIK,
$SsrMr03M_PatientName,$SsrMr03M_CompanyID,$SsrMr03M_DoctorOldCode,
$SsrMr03T_OrderHeaderDate,$SsrMr03T_OrderHeaderLabNumberExt,$SsrMr03Total,
$SsrMr03Reward,$SsrMr03RoundReward,$SsrMr03Nat_JpaGroupMaxJpaDisc, $SsrMr03M_No_FormRev, $SsrMr03M_DoctorAddressOldCode,
$SsrMr03M_DoctorID, $SsrMr03M_DoctorAddressID));
if($qry) {
$status[] = $d["SsrMr03ID"];
}else {
print_r($this->db->error());
}
} else {
print_r($this->db->error());
}
} catch(Exception $e) {
}
}
echo json_encode( array("status" => "OK" , "SsrMr03ID" => $status));
}
}

View File

@@ -0,0 +1,67 @@
<?php
class R_mr04 extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
}
function index() {
$md5 = $this->sys_input["md5"];
$jdata = $this->sys_input["data"];
$l_md5 = md5($jdata);
if ($md5 != $l_md5) {
echo json_encode( array( "status" => "ERR",
"message" => "$md5 <> local $l_md5"));
exit;
}
$data = json_decode($jdata,true);
$status = array();
$d_sql = "delete from ssr_mr04 where SsrMr04M_BranchCode = ? and
SsrMr04Date=?";
$sql = "insert into ssr_mr04(SsrMr04M_BranchCode, SsrMr04Date, SsrMr04PasienAps, SsrMr04Aps ,
SsrMr04PasienDokter , SsrMr04Dokter , SsrMr04PasienPerusahaan , SsrMr04Perusahaan ,
SsrMr04PasienRujukan , SsrMr04Rujukan , SsrMr04PasienAnakPerusahaan , SsrMr04AnakPerusahaan ,
SsrMr04PasienPenelitian , SsrMr04Penelitian , SsrMr04PasienRAP , SsrMr04RAP ,
SsrMr04TotalPasien , SsrMr04TotalOmzet) values(?,?,?,?, ?,?,?,?, ?,?,?,?, ?,?,?,? ,?,?)";
foreach($data as $d) {
$SsrMr04M_BranchCode = $d["SsrMr04M_BranchCode"];
$SsrMr04Date = $d["SsrMr04Date"];
$SsrMr04PasienAps =$d["SsrMr04PasienAps"];
$SsrMr04Aps =$d["SsrMr04Aps"];
$SsrMr04PasienDokter =$d["SsrMr04PasienDokter"];
$SsrMr04Dokter =$d["SsrMr04Dokter"];
$SsrMr04PasienPerusahaan =$d["SsrMr04PasienPerusahaan"];
$SsrMr04Perusahaan =$d["SsrMr04Perusahaan"];
$SsrMr04PasienRujukan =$d["SsrMr04PasienRujukan"];
$SsrMr04Rujukan =$d["SsrMr04Rujukan"];
$SsrMr04PasienAnakPerusahaan =$d["SsrMr04PasienAnakPerusahaan"];
$SsrMr04AnakPerusahaan =$d["SsrMr04AnakPerusahaan"];
$SsrMr04PasienPenelitian =$d["SsrMr04PasienPenelitian"];
$SsrMr04Penelitian =$d["SsrMr04Penelitian"];
$SsrMr04PasienRAP =$d["SsrMr04PasienRAP"];
$SsrMr04RAP =$d["SsrMr04RAP"];
$SsrMr04TotalPasien = $d["SsrMr04TotalPasien"];
$SsrMr04TotalOmzet = $d["SsrMr04TotalOmzet"];
try{
$qry = $this->db->query($d_sql, array($SsrMr04M_BranchCode, $SsrMr04Date));
if ($qry) {
$qry = $this->db->query($sql,array($SsrMr04M_BranchCode, $SsrMr04Date, $SsrMr04PasienAps, $SsrMr04Aps ,
$SsrMr04PasienDokter , $SsrMr04Dokter , $SsrMr04PasienPerusahaan , $SsrMr04Perusahaan ,
$SsrMr04PasienRujukan , $SsrMr04Rujukan , $SsrMr04PasienAnakPerusahaan , $SsrMr04AnakPerusahaan ,
$SsrMr04PasienPenelitian , $SsrMr04Penelitian , $SsrMr04PasienRAP , $SsrMr04RAP ,
$SsrMr04TotalPasien , $SsrMr04TotalOmzet));
if($qry) {
$status[] = $d["SsrMr04ID"];
}else {
print_r($this->db->error());
}
} else {
print_r($this->db->error());
}
} catch(Exception $e) {
}
}
echo json_encode( array("status" => "OK" , "SsrMr04ID" => $status));
}
}

View File

@@ -0,0 +1,58 @@
<?php
class R_mr05 extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
}
function index() {
$md5 = $this->sys_input["md5"];
$jdata = $this->sys_input["data"];
$l_md5 = md5($jdata);
if ($md5 != $l_md5) {
echo json_encode( array( "status" => "ERR",
"message" => "$md5 <> local $l_md5"));
exit;
}
$data = json_decode($jdata,true);
$status = array();
$d_sql = "delete from ssr_mr05 where SsrMr05M_BranchCode = ? and
SsrMr05T_OrderHeaderID = ?";
$sql = "insert into ssr_mr05(SsrMr05M_BranchCode, SsrMr05M_StaffNIK,
SsrMr05T_OrderHeaderDate, SsrMr05T_OrderHeaderID, SsrMr05M_CompanyID, SsrMr05M_MouID, SsrMr05M_MouName,
SsrMr05M_OmzetTypeName, SsrMr05M_OmzetTypeID, SsrMr05Total, SsrMr05Payment, SsrMr05TotalPasien)
values(?,?, ?,?,?,?,?, ?,?,?,?,?)";
foreach($data as $d) {
$SsrMr05T_OrderHeaderID = $d["SsrMr05T_OrderHeaderID"];
$SsrMr05T_OrderHeaderDate = $d["SsrMr05T_OrderHeaderDate"];
$SsrMr05M_BranchCode = $d["SsrMr05M_BranchCode"];
$SsrMr05M_StaffNIK = $d["SsrMr05M_StaffNIK"];
$SsrMr05M_CompanyID =$d["SsrMr05M_CompanyID"];
$SsrMr05M_MouID =$d["SsrMr05M_MouID"];
$SsrMr05M_MouName=$d["SsrMr05M_MouName"];
$SsrMr05M_OmzetTypeName=$d["SsrMr05M_OmzetTypeName"];
$SsrMr05M_OmzetTypeID=$d["SsrMr05M_OmzetTypeID"];
$SsrMr05Total = $d["SsrMr05Total"];
$SsrMr05Payment = $d["SsrMr05Payment"];
$SsrMr05TotalPasien = $d["SsrMr05TotalPasien"];
try{
$qry = $this->db->query($d_sql, array($SsrMr05M_BranchCode, $SsrMr05T_OrderHeaderID));
if ($qry) {
$qry = $this->db->query($sql,array($SsrMr05M_BranchCode,$SsrMr05M_StaffNIK,
$SsrMr05T_OrderHeaderDate,$SsrMr05T_OrderHeaderID,$SsrMr05M_CompanyID,$SsrMr05M_MouID,$SsrMr05M_MouName,
$SsrMr05M_OmzetTypeName, $SsrMr05M_OmzetTypeID,$SsrMr05Total,$SsrMr05Payment, $SsrMr05TotalPasien));
if($qry) {
$status[] = $d["SsrMr05ID"];
}else {
print_r($this->db->error());
}
} else {
print_r($this->db->error());
}
} catch(Exception $e) {
}
}
echo json_encode( array("status" => "OK" , "SsrMr05ID" => $status));
}
}

View File

@@ -0,0 +1,104 @@
<?php
class R_mr05 extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
}
function index() {
$md5 = $this->sys_input["md5"];
$jdata = $this->sys_input["data"];
$l_md5 = md5($jdata);
if ($md5 != $l_md5) {
echo json_encode( array( "status" => "ERR",
"message" => "$md5 <> local $l_md5"));
exit;
}
$data = json_decode($jdata,true);
$status = array();
$d_sql = "delete from ssr_mr05 where SsrMr05M_BranchCode = ? and
SsrMr05T_OrderHeaderID = ?";
$sql = "insert into ssr_mr05(SsrMr05M_BranchCode, SsrMr05Date, SsrMr05M_StaffNIK,
SsrMr05T_OrderHeaderDate, SsrMr05T_OrderHeaderID, SsrMr05M_CompanyID, SsrMr05M_MouID, SsrMr05M_MouName,
SsrMr05M_OmzetTypeName, SsrMr05M_OmzetTypeID, SsrMr05Total, SsrMr05Payment, SsrMr05TotalPasien)
values(?,?,?, ?,?,?,?,?, ?,?,?,?,?)";
foreach($data as $d) {
$SsrMr05T_OrderHeaderID = $d["SsrMr05T_OrderHeaderID"];
$SsrMr05Date = $d["SsrMr05Date"];
$SsrMr05T_OrderHeaderDate = $d["SsrMr05T_OrderHeaderDate"];
$SsrMr05M_BranchCode = $d["SsrMr05M_BranchCode"];
$SsrMr05M_StaffNIK = $d["SsrMr05M_StaffNIK"];
$SsrMr05M_CompanyID =$d["SsrMr05M_CompanyID"];
$SsrMr05M_MouID =$d["SsrMr05M_MouID"];
$SsrMr05M_MouName=$d["SsrMr05M_MouName"];
$SsrMr05M_OmzetTypeName=$d["SsrMr05M_OmzetTypeName"];
$SsrMr05M_OmzetTypeID=$d["SsrMr05M_OmzetTypeID"];
$SsrMr05Total = $d["SsrMr05Total"];
$SsrMr05Payment = $d["SsrMr05Payment"];
$SsrMr05TotalPasien = $d["SsrMr05TotalPasien"];
try{
$qry = $this->db->query($d_sql, array($SsrMr05M_BranchCode, $SsrMr05T_OrderHeaderID));
if ($qry) {
$qry = $this->db->query($sql,array($SsrMr05M_BranchCode, $SsrMr05Date, $SsrMr05M_StaffNIK,
$SsrMr05T_OrderHeaderDate,$SsrMr05T_OrderHeaderID,$SsrMr05M_CompanyID,$SsrMr05M_MouID,$SsrMr05M_MouName,
$SsrMr05M_OmzetTypeName, $SsrMr05M_OmzetTypeID,$SsrMr05Total,$SsrMr05Payment, $SsrMr05TotalPasien));
if($qry) {
$status[] = $d["SsrMr05ID"];
}else {
print_r($this->db->error());
}
} else {
print_r($this->db->error());
}
} catch(Exception $e) {
}
}
echo json_encode( array("status" => "OK" , "SsrMr05ID" => $status));
}
function piutang() {
$md5 = $this->sys_input["md5"];
$jdata = $this->sys_input["data"];
$l_md5 = md5($jdata);
if ($md5 != $l_md5) {
echo json_encode( array( "status" => "ERR",
"message" => "$md5 <> local $l_md5"));
exit;
}
$data = json_decode($jdata,true);
$status = array();
$d_sql = "delete from ssr_mr05_piutang where
SsrMr05PiutangDate = ? and SsrMr05PiutangM_BranchCode = ? and SsrMr05PiutangM_CompanyID=?
and SsrMr05PiutangM_MouID = ? ";
$sql = "insert into ssr_mr05_piutang(SsrMr05PiutangDate, SsrMr05PiutangM_BranchCode, SsrMr05PiutangM_CompanyID,
SsrMr05PiutangM_MouID, SsrMr05PiutangSales, SsrMr05PiutangPayment )
values(?,?,?, ?,?,?)";
foreach($data as $d) {
$SsrMr05PiutangDate = $d["SsrMr05PiutangDate"];
$SsrMr05PiutangM_BranchCode = $d["SsrMr05PiutangM_BranchCode"];
$SsrMr05PiutangM_CompanyID =$d["SsrMr05PiutangM_CompanyID"];
$SsrMr05PiutangM_MouID =$d["SsrMr05PiutangM_MouID"];
$SsrMr05PiutangSales=$d["SsrMr05PiutangSales"];
$SsrMr05PiutangPayment=$d["SsrMr05PiutangPayment"];
try{
$qry = $this->db->query($d_sql, array($SsrMr05PiutangDate, $SsrMr05PiutangM_BranchCode,
$SsrMr05PiutangM_CompanyID, $SsrMr05PiutangM_MouID));
if ($qry) {
$qry = $this->db->query($sql,array($SsrMr05PiutangDate,
$SsrMr05PiutangM_BranchCode, $SsrMr05PiutangM_CompanyID,
$SsrMr05PiutangM_MouID, $SsrMr05PiutangSales, $SsrMr05PiutangPayment));
if($qry) {
$status[] = $d["SsrMr05PiutangID"];
}else {
print_r($this->db->error());
}
} else {
print_r($this->db->error());
}
} catch(Exception $e) {
}
}
echo json_encode( array("status" => "OK" , "SsrMr05PiutangID" => $status));
}
}

View File

@@ -0,0 +1,104 @@
<?php
class R_mr05 extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
}
function index() {
$md5 = $this->sys_input["md5"];
$jdata = $this->sys_input["data"];
$l_md5 = md5($jdata);
if ($md5 != $l_md5) {
echo json_encode( array( "status" => "ERR",
"message" => "$md5 <> local $l_md5"));
exit;
}
$data = json_decode($jdata,true);
$status = array();
$d_sql = "delete from ssr_mr05 where SsrMr05M_BranchCode = ? and
SsrMr05T_OrderHeaderID = ?";
$sql = "insert into ssr_mr05(SsrMr05M_BranchCode, SsrMr05Date, SsrMr05M_StaffNIK,
SsrMr05T_OrderHeaderDate, SsrMr05T_OrderHeaderID, SsrMr05M_CompanyID, SsrMr05M_MouID, SsrMr05M_MouName,
SsrMr05M_OmzetTypeName, SsrMr05M_OmzetTypeID, SsrMr05Total, SsrMr05Payment, SsrMr05TotalPasien)
values(?,?,?, ?,?,?,?,?, ?,?,?,?,?)";
foreach($data as $d) {
$SsrMr05T_OrderHeaderID = $d["SsrMr05T_OrderHeaderID"];
$SsrMr05Date = $d["SsrMr05Date"];
$SsrMr05T_OrderHeaderDate = $d["SsrMr05T_OrderHeaderDate"];
$SsrMr05M_BranchCode = $d["SsrMr05M_BranchCode"];
$SsrMr05M_StaffNIK = $d["SsrMr05M_StaffNIK"];
$SsrMr05M_CompanyID =$d["SsrMr05M_CompanyID"];
$SsrMr05M_MouID =$d["SsrMr05M_MouID"];
$SsrMr05M_MouName=$d["SsrMr05M_MouName"];
$SsrMr05M_OmzetTypeName=$d["SsrMr05M_OmzetTypeName"];
$SsrMr05M_OmzetTypeID=$d["SsrMr05M_OmzetTypeID"];
$SsrMr05Total = $d["SsrMr05Total"];
$SsrMr05Payment = $d["SsrMr05Payment"];
$SsrMr05TotalPasien = $d["SsrMr05TotalPasien"];
try{
$qry = $this->db->query($d_sql, array($SsrMr05M_BranchCode, $SsrMr05T_OrderHeaderID));
if ($qry) {
$qry = $this->db->query($sql,array($SsrMr05M_BranchCode, $SsrMr05Date, $SsrMr05M_StaffNIK,
$SsrMr05T_OrderHeaderDate,$SsrMr05T_OrderHeaderID,$SsrMr05M_CompanyID,$SsrMr05M_MouID,$SsrMr05M_MouName,
$SsrMr05M_OmzetTypeName, $SsrMr05M_OmzetTypeID,$SsrMr05Total,$SsrMr05Payment, $SsrMr05TotalPasien));
if($qry) {
$status[] = $d["SsrMr05ID"];
}else {
print_r($this->db->error());
}
} else {
print_r($this->db->error());
}
} catch(Exception $e) {
}
}
echo json_encode( array("status" => "OK" , "SsrMr05ID" => $status));
}
function piutang() {
$md5 = $this->sys_input["md5"];
$jdata = $this->sys_input["data"];
$l_md5 = md5($jdata);
if ($md5 != $l_md5) {
echo json_encode( array( "status" => "ERR",
"message" => "$md5 <> local $l_md5"));
exit;
}
$data = json_decode($jdata,true);
$status = array();
$d_sql = "delete from ssr_mr05_piutang where
SsrMr05PiutangDate = ? and SsrMr05PiutangM_BranchCode = ? and SsrMr05PiutangM_CompanyID=?
and SsrMr05PiutangM_MouID = ? ";
$sql = "insert into ssr_mr05_piutang(SsrMr05PiutangDate, SsrMr05PiutangM_BranchCode, SsrMr05PiutangM_CompanyID,
SsrMr05PiutangM_MouID, SsrMr05PiutangSales, SsrMr05PiutangPayment )
values(?,?,?, ?,?,?)";
foreach($data as $d) {
$SsrMr05PiutangDate = $d["SsrMr05PiutangDate"];
$SsrMr05PiutangM_BranchCode = $d["SsrMr05PiutangM_BranchCode"];
$SsrMr05PiutangM_CompanyID =$d["SsrMr05PiutangM_CompanyID"];
$SsrMr05PiutangM_MouID =$d["SsrMr05PiutangM_MouID"];
$SsrMr05PiutangSales=$d["SsrMr05PiutangSales"];
$SsrMr05PiutangPayment=$d["SsrMr05PiutangPayment"];
try{
$qry = $this->db->query($d_sql, array($SsrMr05PiutangDate, $SsrMr05PiutangM_BranchCode,
$SsrMr05PiutangM_CompanyID, $SsrMr05PiutangM_MouID));
if ($qry) {
$qry = $this->db->query($sql,array($SsrMr05PiutangDate,
$SsrMr05PiutangM_BranchCode, $SsrMr05PiutangM_CompanyID,
$SsrMr05PiutangM_MouID, $SsrMr05PiutangSales, $SsrMr05PiutangPayment));
if($qry) {
$status[] = $d["SsrMr05PiutangID"];
}else {
print_r($this->db->error());
}
} else {
print_r($this->db->error());
}
} catch(Exception $e) {
}
}
echo json_encode( array("status" => "OK" , "SsrMr05PiutangID" => $status));
}
}

View File

@@ -0,0 +1,69 @@
<?php
class R_mr07 extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
}
function index() {
$md5 = $this->sys_input["md5"];
$jdata = $this->sys_input["data"];
$l_md5 = md5($jdata);
if ($md5 != $l_md5) {
echo json_encode( array( "status" => "ERR",
"message" => "$md5 <> local $l_md5"));
exit;
}
$data = json_decode($jdata,true);
$status = array();
$d_sql = "delete from ssr_mr07 where SsrMr07M_BranchCode = ? and
SsrMr07T_OrderHeaderID = ? and SsrMr07JpaName = ?";
$sql = "insert into ssr_mr07(SsrMr07M_BranchCode, SsrMr07M_PatientName,
SsrMr07T_OrderHeaderID, SsrMr07T_OrderHeaderDate, SsrMr07T_OrderHeaderLabNumberExt,
SsrMr07M_CompanyID,SsrMr07M_MouID,SsrMr07M_OmzetTypeID,
SsrMr07Bruto, SsrMr07Netto,SsrMr07M_MouJpaIsNetto,
SsrMr07Price,SsrMr07M_StaffNIK, SsrMr07JpaName, SsrMr07JpaPercent,
SsrMr07Jpa, SsrMr07M_No_FormRev) values(?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?,?, ?,?)";
foreach($data as $d) {
$SsrMr07M_BranchCode = $d["SsrMr07M_BranchCode"];
$SsrMr07M_PatientName =$d["SsrMr07M_PatientName"];
$SsrMr07T_OrderHeaderID = $d["SsrMr07T_OrderHeaderID"];
$SsrMr07T_OrderHeaderDate =$d["SsrMr07T_OrderHeaderDate"];
$SsrMr07T_OrderHeaderLabNumberExt =$d["SsrMr07T_OrderHeaderLabNumberExt"];
$SsrMr07M_CompanyID =$d["SsrMr07M_CompanyID"];
$SsrMr07M_MouID =$d["SsrMr07M_MouID"];
$SsrMr07M_OmzetTypeID =$d["SsrMr07M_OmzetTypeID"];
$SsrMr07Bruto = $d["SsrMr07Bruto"];
$SsrMr07Netto = $d["SsrMr07Netto"];
$SsrMr07M_MouJpaIsNetto =$d["SsrMr07M_MouJpaIsNetto"];
$SsrMr07Price =$d["SsrMr07Price"];
$SsrMr07M_StaffNIK = $d["SsrMr07M_StaffNIK"];
$SsrMr07JpaName = $d["SsrMr07JpaName"];
$SsrMr07JpaPercent = $d["SsrMr07JpaPercent"];
$SsrMr07Jpa = $d["SsrMr07Jpa"];
$SsrMr07M_No_FormRev = $d["SsrMr07M_No_FormRev"];
try{
$qry = $this->db->query($d_sql, array($SsrMr07M_BranchCode, $SsrMr07T_OrderHeaderID,$SsrMr07JpaName));
if ($qry) {
$qry = $this->db->query($sql,array($SsrMr07M_BranchCode,$SsrMr07M_PatientName,
$SsrMr07T_OrderHeaderID, $SsrMr07T_OrderHeaderDate, $SsrMr07T_OrderHeaderLabNumberExt,
$SsrMr07M_CompanyID, $SsrMr07M_MouID, $SsrMr07M_OmzetTypeID,
$SsrMr07Bruto, $SsrMr07Netto, $SsrMr07M_MouJpaIsNetto,
$SsrMr07Price, $SsrMr07M_StaffNIK, $SsrMr07JpaName, $SsrMr07JpaPercent,
$SsrMr07Jpa, $SsrMr07M_No_FormRev));
if($qry) {
$status[] = $d["SsrMr07ID"];
}else {
print_r($this->db->error());
}
} else {
print_r($this->db->error());
}
} catch(Exception $e) {
}
}
echo json_encode( array("status" => "OK" , "SsrMr07ID" => $status));
}
}

View File

@@ -0,0 +1,77 @@
<?php
class R_mr09 extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
}
function index() {
$md5 = $this->sys_input["md5"];
$jdata = $this->sys_input["data"];
$l_md5 = md5($jdata);
if ($md5 != $l_md5) {
echo json_encode( array( "status" => "ERR",
"message" => "$md5 <> local $l_md5"));
exit;
}
$data = json_decode($jdata,true);
$status = array();
$d_sql = "delete from ssr_mr09 where SsrMr09M_BranchCode = ? and
SsrMr09Date= ? and SsrMr09M_PatientNoreg= ? and SsrMr09M_MouID=?";
$sql = "insert into ssr_mr09(SsrMr09M_BranchCode, SsrMr09Date, SsrMr09M_PatientNoreg, SsrMr09M_PatientName,
SsrMr09M_PatientDOB, SsrMr09M_PatientAge, SsrMr09M_PatientNIK, SsrMr09M_PatientJabatan,
SsrMr09M_PatientKedudukan, SsrMr09M_PatientPJ, SsrMr09M_PatientLocation, SsrMr09M_PatientJob,
SsrMr09Kedatangan, SsrMr09T_Test, SsrMr09JumlahTest, SsrMr09Bruto,
SsrMr09Total, SsrMr09Discount, SsrMr09Payment, SsrMr09M_CompanyID,
SsrMr09M_MouID, SsrMr09M_OmzetTypeID)
values(?,?,?,?, ?,?,?,?, ?,?,?,?, ?,?,?,?, ?,?,?,?, ?,?)";
foreach($data as $d) {
$SsrMr09M_BranchCode = $d["SsrMr09M_BranchCode"];
$SsrMr09Date =$d["SsrMr09Date"];
$SsrMr09M_PatientNoreg =$d["SsrMr09M_PatientNoreg"];
$SsrMr09M_PatientName =$d["SsrMr09M_PatientName"];
$SsrMr09M_PatientDOB =$d["SsrMr09M_PatientDOB"];
$SsrMr09M_PatientAge =$d["SsrMr09M_PatientAge"];
$SsrMr09M_PatientNIK =$d["SsrMr09M_PatientNIK"];
$SsrMr09M_PatientJabatan =$d["SsrMr09M_PatientJabatan"];
$SsrMr09M_PatientKedudukan =$d["SsrMr09M_PatientKedudukan"];
$SsrMr09M_PatientPJ =$d["SsrMr09M_PatientPJ"];
$SsrMr09M_PatientLocation =$d["SsrMr09M_PatientLocation"];
$SsrMr09M_PatientJob =$d["SsrMr09M_PatientJob"];
$SsrMr09Kedatangan =$d["SsrMr09Kedatangan"];
$SsrMr09T_Test =$d["SsrMr09T_Test"];
$SsrMr09JumlahTest =$d["SsrMr09JumlahTest"];
$SsrMr09Bruto =$d["SsrMr09Bruto"];
$SsrMr09Total =$d["SsrMr09Total"];
$SsrMr09Discount =$d["SsrMr09Discount"];
$SsrMr09Payment =$d["SsrMr09Payment"];
$SsrMr09M_CompanyID =$d["SsrMr09M_CompanyID"];
$SsrMr09M_MouID =$d["SsrMr09M_MouID"];
$SsrMr09M_OmzetTypeID =$d["SsrMr09M_OmzetTypeID"];
try{
$qry = $this->db->query($d_sql, array($SsrMr09M_BranchCode, $SsrMr09Date, $SsrMr09M_PatientNoreg,
$SsrMr09M_MouID));
if ($qry) {
$qry = $this->db->query($sql,array($SsrMr09M_BranchCode, $SsrMr09Date, $SsrMr09M_PatientNoreg, $SsrMr09M_PatientName,
$SsrMr09M_PatientDOB, $SsrMr09M_PatientAge, $SsrMr09M_PatientNIK, $SsrMr09M_PatientJabatan,
$SsrMr09M_PatientKedudukan, $SsrMr09M_PatientPJ, $SsrMr09M_PatientLocation, $SsrMr09M_PatientJob,
$SsrMr09Kedatangan, $SsrMr09T_Test, $SsrMr09JumlahTest, $SsrMr09Bruto,
$SsrMr09Total, $SsrMr09Discount, $SsrMr09Payment, $SsrMr09M_CompanyID,
$SsrMr09M_MouID, $SsrMr09M_OmzetTypeID ));
if($qry) {
$status[] = $d["SsrMr09ID"];
}else {
print_r($this->db->error());
}
} else {
print_r($this->db->error());
}
} catch(Exception $e) {
print_r($this->db->error());
}
}
echo json_encode( array("status" => "OK" , "SsrMr09ID" => $status));
}
}

View File

@@ -0,0 +1,71 @@
<?php
class R_mr11 extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
}
function index() {
$md5 = $this->sys_input["md5"];
$jdata = $this->sys_input["data"];
$l_md5 = md5($jdata);
if ($md5 != $l_md5) {
echo json_encode( array( "status" => "ERR",
"message" => "$md5 <> local $l_md5"));
exit;
}
$data = json_decode($jdata,true);
$status = array();
$d_sql = "delete from ssr_mr11 where SsrMr11M_BranchCode = ? and SsrMr11M_CompanyID = ? and
SsrMr11Date = ?";
$sql = "insert into ssr_mr11(
ssrMr11M_CompanyID, ssrMr11M_CompanyNumber, ssrMr11M_BranchCode,ssrMr11M_CompanyOldID,
ssrMr11M_CompanyName, ssrMr11M_MouTypeName, ssrMr11M_MouTypeID, ssrMr11KerjasamaLokal, ssrMr11KerjasamaNasional,
ssrMr11TagihanLokal, ssrMr11TagihanNasional, ssrMr11Date, ssrMr11Year, ssrMr11Month,
ssrMr11Total, ssrMr11TotalPasien)
values(?,?,?,?, ?,?,?,?,?, ?,?,?,?,?, ?,?)";
foreach($data as $d) {
$ssrMr11ID= $d["ssrMr11ID"];
$ssrMr11M_BranchCode = $d["ssrMr11M_BranchCode"];
$ssrMr11M_CompanyOldID= $d["ssrMr11M_CompanyOldID"];
$ssrMr11M_CompanyID = $d["ssrMr11M_CompanyID"];
$ssrMr11M_CompanyNumber = $d["ssrMr11M_CompanyNumber"];
$ssrMr11M_CompanyName = $d["ssrMr11M_CompanyName"];
$ssrMr11M_MouTypeName = $d["ssrMr11M_MouTypeName"];
$ssrMr11M_MouTypeID = $d["ssrMr11M_MouTypeID"];
$ssrMr11KerjasamaLokal = $d["ssrMr11KerjasamaLokal"];
$ssrMr11KerjasamaNasional = $d["ssrMr11KerjasamaNasional"];
$ssrMr11TagihanLokal = $d["ssrMr11TagihanLokal"];
$ssrMr11TagihanNasional = $d["ssrMr11TagihanNasional"];
$ssrMr11Date = $d["ssrMr11Date"];
$ssrMr11Year = $d["ssrMr11Year"];
$ssrMr11Month = $d["ssrMr11Month"];
$ssrMr11Total = $d["ssrMr11Total"];
$ssrMr11TotalPasien = $d["ssrMr11TotalPasien"];
try{
$qry = $this->db->query($d_sql, array($ssrMr11M_BranchCode, $ssrMr11M_CompanyID,
$ssrMr11Date));
if ($qry) {
$qry = $this->db->query($sql,array(
$ssrMr11M_CompanyID, $ssrMr11M_CompanyNumber, $ssrMr11M_BranchCode,$ssrMr11M_CompanyOldID,
$ssrMr11M_CompanyName, $ssrMr11M_MouTypeName, $ssrMr11M_MouTypeID, $ssrMr11KerjasamaLokal, $ssrMr11KerjasamaNasional,
$ssrMr11TagihanLokal, $ssrMr11TagihanNasional, $ssrMr11Date, $ssrMr11Year, $ssrMr11Month,
$ssrMr11Total, $ssrMr11TotalPasien
));
if($qry) {
$status[] = $ssrMr11ID;
}else {
print_r($this->db->error());
}
} else {
print_r($this->db->error());
}
} catch(Exception $e) {
print_r($this->db->error());
}
}
echo json_encode( array("status" => "OK" , "SsrMr11ID" => $status));
}
}

View File

@@ -0,0 +1,75 @@
<?php
class Cabang extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
}
function pingAddress($ip) {
$pingresult = exec("/bin/ping -c 3 $ip", $outcome, $status);
$i_status = $status;
if (0 == $status) {
$status = "alive";
} else {
$status = "dead";
}
return array($i_status, "The IP address, $ip, is ".$status ."\n" .
$pingresult . "\n");
}
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 index() {
$this->check();
}
function check($is_cek=false) {
$sql = "select m_branch.* from m_branch
join s_regional on M_BranchS_RegionalID = S_RegionalID and
S_RegionalIsActive = 'Y' and S_RegionalIsDefault = 'Y' and M_BranchIsActive = 'Y'";
$branchName = "No Branch";
$qry = $this->db->query($sql);
if ($qry) {
$rows = $qry->result_array();
$result = "";
$have_err = false;
foreach($rows as $r) {
$branchName = $r["M_BranchName"];
$branchIP = $r["M_BranchIPAddress"];
list($code,$xresult) = $this->pingAddress($branchIP);
if ($code != 0 ) $have_err = true;
$result .= "[$branchName]:\n" . $xresult . "\n";
}
if ($have_err || $is_cek) {
$this->sasone($result);
}
} else {
print_r($this->db->error());
}
}
function sasone($msg) {
$msg = $this->clean_up_message($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;
}
}

View File

@@ -0,0 +1,122 @@
<?php
class Xdb extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", 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 s_regional where S_RegionalIsActive = 'Y' and S_RegionalIsDefault = 'Y'";
$regionalName = "No Regional";
$regionalID = 0;
$qry = $this->db->query($sql);
if ($qry) {
$rows = $qry->result_array();
$regionalName = $rows[0]["S_RegionalName"];
$regionalID = $rows[0]["S_RegionalID"];
} else {
print_r($this->db->error());
}
$sql = "show slave status";
$qry = $this->db->query($sql);
$msg = "";
if ($qry) {
$rows = $qry->result_array();
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";
}
}
} else {
print_r($this->db->error());
}
//get per branch
$sql = "select * from m_branch where M_BranchS_RegionalID = ?";
$qry = $this->db->query($sql, array($regionalID)) ;
if ($qry) {
$rows = $qry->result_array( );
foreach($rows as $r) {
$name = $r["M_BranchName"];
$ip = $r["M_BranchIPAddress"];
$xdebug = "";
if($debug) $xdebug = "true";
$b_msg = $this->info($ip,$xdebug);
if ($b_msg != "" ) {
$msg .= "Cabang $name\n$b_msg\n";
}
}
} else {
print_r($this->db->error());
}
if($msg != "" ) {
$msg = "[REPLIKASI] $regionalName :\n$msg";
if ($debug || $err_no > 0 ) {
$msg = $this->clean_up_message($msg);
$this->sasone($msg);
}
}
}
function print_chr($inp) {
for($i=0;$i<strlen($inp);$i++) {
$chr = substr($inp,$i,1);
echo "$i\t$chr => " . ord($chr) . "\n";
}
}
function info($ip,$debug="") {
$url = "http://$ip/one-api/tools/monitoring/xdb/replikasi/$debug";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data))
);
$result = curl_exec($ch);
return $result;
}
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;
}
}

View File

@@ -0,0 +1,121 @@
<?php
class Ss extends CI_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database('regional', true);
}
function create($mouID) {
$sql = "select * from m_mou where M_MouID = ?";
$qry = $this->db->query($sql, array($mouID));
if (! $qry ) {
echo 'Err : ' . print_r($this->db->error(),true). '\n';
exit;
}
$rows = $qry->result_array();
if (count($rows) == 0 ) {
echo "Err : No Mou Found!";
exit;
}
$mouName = $rows[0]["M_MouName"];
//Test kecuali Profile
$sql = "select T_PriceM_MouID, T_TestID, T_TestName, 'N' IsFromPanel, Nat_TestID,
T_PriceT_TestID, T_PriceIsCito, T_PriceM_CompanyID, T_PriceM_MouID,
T_PricePriority, T_PriceAmount, T_PriceDisc, T_PriceDiscRp, T_PriceSubTotal,
T_PriceOther, T_PriceTotal, T_TestForceSell, 'N' is_packet, 0 packet_id,
'PX' px_type, '[]' nat_test, '[]' child_test, 'N' IsFavourite,
Nat_TestNat_TestTypeID, T_TestSasCode
from t_price
join t_test on T_PriceT_TestID = T_TestID
and T_PriceIsActive = 'Y' and T_TestIsActive = 'Y'
and T_TestIsPrice = 'Y'
join nat_test on T_TestNat_TestID = Nat_TestID
and Nat_TestIsActive = 'Y' and Nat_TestNat_TestTypeID <> 5
where T_PriceM_MouID = ?
and length(T_TestSasCode) = 8 ";
$qry = $this->db->query($sql, array($mouID));
if (! $qry ) {
echo 'Err : ' . print_r($this->db->error(),true). '\n';
exit;
}
$rows = $qry->result_array();
$flag_error = false;
foreach($rows as $idx => $r) {
$nat_testType = $r["Nat_TestNat_TestTypeID"];
switch($nat_testType) {
case 1: //Single
$rows[$idx]['nat_test'] = '[' . $r['Nat_TestID'] . ']';
break;
case 3: //Multi
case 4: //Panel
$sasCode = $r["T_TestSasCode"] . '%';
$sql = "select T_TestNat_TestID
from t_test
where T_TestIsResult = 'Y'
and T_TestSasCode like ?
and T_TestIsActive = 'Y'";
$qry = $this->db->query($sql,array($sasCode));
if (!$qry ) {
echo "Err : " . print_r($this->db->error(),true) . "\n";
$flag_error = true;
}
$nt_rows = $qry->result_array();
$t_rows = array();
foreach($nt_rows as $nr) {
$t_rows[] = $nr["T_TestNat_TestID"];
}
$rows[$idx]['nat_test'] = "[" . join($t_rows) . "]";
break;
}
}
print_r($rows);
}
function upload($prm_date) {
$sql = "select * from ssr_mr03
where date(SsrMr03T_OrderHeaderDate) = ?
and SsrMr03IsSent = 'N'
and SsrMr03Retry < 10";
$qry = $this->db->query($sql,array($prm_date));
if (! $qry) {
echo "Err : " . print_r($this->db->error(),true);
exit;
}
$rows = $qry->result_array();
$data = json_encode($rows);
$md5 = md5($data);
$param = array("data" => $data, "md5" => $md5);
$jparam = json_encode($param);
$url = "http://bandungraya.aplikasi.web.id/one-api/tools/marketing/r_mr03";
$url = "http://devbandungraya.aplikasi.web.id/one-api/tools/marketing/r_mr03";
echo "Uploading : $prm_date, total " . count($rows) . " records\n";
$j_result = $this->post($url,$jparam);
$result = json_decode($j_result,true);
$sql = "update ssr_mr03 set SsrMr03Retry = SsrMr03Retry + 1 where date(SsrMr03T_OrderHeaderDate) = ?";
$this->db->query($sql,array($prm_date));
if ($result["status"] == "OK") {
$sql = "update ssr_mr03 set SsrMr03IsSent = 'Y' where SsrMr03ID = ?";
foreach($result["SsrMr03ID"] as $id ) {
$this->db->query($sql, array($id));
}
echo $result["status"] . ", total " . count($result["SsrMr03ID"]) . "\n";
exit;
}
echo "ERR : " . $result["message"] . "\n";
}
function post($url,$data) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data))
);
$result = curl_exec($ch);
return $result;
}
}

View File

@@ -0,0 +1,161 @@
<?php
class Ss extends CI_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database('regional', true);
}
function create($mouID) {
$sql = "select * from m_mou where M_MouID = ?";
$qry = $this->db->query($sql, array($mouID));
if (! $qry ) {
echo 'Err : ' . print_r($this->db->error(),true). '\n';
exit;
}
$rows = $qry->result_array();
if (count($rows) == 0 ) {
echo "Err : No Mou Found!";
exit;
}
$mouName = $rows[0]["M_MouName"];
//Test kecuali Profile
$sql = "select T_PriceM_MouID, T_TestID, T_TestName, 'N' IsFromPanel, Nat_TestID,
T_PriceT_TestID, T_PriceIsCito, T_PriceM_CompanyID, T_PriceM_MouID,
T_PricePriority, T_PriceAmount, T_PriceDisc, T_PriceDiscRp, T_PriceSubTotal,
T_PriceOther, T_PriceTotal, T_TestForceSell, 'N' is_packet, 0 packet_id,
'PX' px_type, '[]' nat_test, '[]' child_test, 'N' IsFavourite,
Nat_TestNat_TestTypeID, T_TestSasCode
from t_price
join t_test on T_PriceT_TestID = T_TestID
and T_PriceIsActive = 'Y' and T_TestIsActive = 'Y'
and T_TestIsPrice = 'Y'
join nat_test on T_TestNat_TestID = Nat_TestID
and Nat_TestIsActive = 'Y' and Nat_TestNat_TestTypeID <> 5
where T_PriceM_MouID = ?
and length(T_TestSasCode) = 8 ";
$qry = $this->db->query($sql, array($mouID));
if (! $qry ) {
echo 'Err : ' . print_r($this->db->error(),true). '\n';
exit;
}
$rows = $qry->result_array();
$flag_error = false;
foreach($rows as $idx => $r) {
$nat_testType = $r["Nat_TestNat_TestTypeID"];
switch($nat_testType) {
case 1: //Single
$rows[$idx]['nat_test'] = '[' . $r['Nat_TestID'] . ']';
break;
case 3: //Multi
case 4: //Panel
$sasCode = $r["T_TestSasCode"] . '%';
$sql = "select T_TestNat_TestID
from t_test
where T_TestIsResult = 'Y'
and T_TestSasCode like ?
and T_TestIsActive = 'Y'";
$qry = $this->db->query($sql,array($sasCode));
if (!$qry ) {
echo "Err : " . print_r($this->db->error(),true) . "\n";
$flag_error = true;
}
$nt_rows = $qry->result_array();
$t_rows = array();
foreach($nt_rows as $nr) {
$t_rows[] = $nr["T_TestNat_TestID"];
}
$rows[$idx]['nat_test'] = "[" . join($t_rows) . "]";
break;
}
}
//print_r($rows);
//Test Profile
$sql = "select T_PriceM_MouID, T_TestID, T_TestName, 'N' IsFromPanel, Nat_TestID,
T_PriceT_TestID, T_PriceIsCito, T_PriceM_CompanyID, T_PriceM_MouID,
T_PricePriority, T_PriceAmount, T_PriceDisc, T_PriceDiscRp, T_PriceSubTotal,
T_PriceOther, T_PriceTotal, T_TestForceSell, 'N' is_packet, 0 packet_id,
'PX' px_type, '[]' nat_test, '[]' child_test, 'N' IsFavourite,
Nat_TestNat_TestTypeID, T_TestSasCode
from t_price
join t_test on T_PriceT_TestID = T_TestID
and T_PriceIsActive = 'Y' and T_TestIsActive = 'Y'
join nat_test on T_TestNat_TestID = Nat_TestID
and Nat_TestIsActive = 'Y' and Nat_TestNat_TestTypeID = 5
where T_PriceM_MouID = ?
and length(T_TestSasCode) = 8 ";
$qry = $this->db->query($sql, array($mouID));
if (! $qry ) {
echo 'Err : ' . print_r($this->db->error(),true). '\n';
exit;
}
$rows = $qry->result_array();
$flag_error = false;
foreach($rows as $idx => $r) {
$sasCode = $r["T_TestSasCode"] . '%';
$sql = "select T_TestNat_TestID
from t_test
where T_TestIsResult = 'Y'
and T_TestSasCode like ?
and T_TestIsActive = 'Y'";
$qry = $this->db->query($sql,array($sasCode));
if (!$qry ) {
echo "Err : " . print_r($this->db->error(),true) . "\n";
$flag_error = true;
}
$nt_rows = $qry->result_array();
$t_rows = array();
foreach($nt_rows as $nr) {
$t_rows[] = $nr["T_TestNat_TestID"];
}
$rows[$idx]['nat_test'] = "[" . join($t_rows) . "]";
}
}
function upload($prm_date) {
$sql = "select * from ssr_mr03
where date(SsrMr03T_OrderHeaderDate) = ?
and SsrMr03IsSent = 'N'
and SsrMr03Retry < 10";
$qry = $this->db->query($sql,array($prm_date));
if (! $qry) {
echo "Err : " . print_r($this->db->error(),true);
exit;
}
$rows = $qry->result_array();
$data = json_encode($rows);
$md5 = md5($data);
$param = array("data" => $data, "md5" => $md5);
$jparam = json_encode($param);
$url = "http://bandungraya.aplikasi.web.id/one-api/tools/marketing/r_mr03";
$url = "http://devbandungraya.aplikasi.web.id/one-api/tools/marketing/r_mr03";
echo "Uploading : $prm_date, total " . count($rows) . " records\n";
$j_result = $this->post($url,$jparam);
$result = json_decode($j_result,true);
$sql = "update ssr_mr03 set SsrMr03Retry = SsrMr03Retry + 1 where date(SsrMr03T_OrderHeaderDate) = ?";
$this->db->query($sql,array($prm_date));
if ($result["status"] == "OK") {
$sql = "update ssr_mr03 set SsrMr03IsSent = 'Y' where SsrMr03ID = ?";
foreach($result["SsrMr03ID"] as $id ) {
$this->db->query($sql, array($id));
}
echo $result["status"] . ", total " . count($result["SsrMr03ID"]) . "\n";
exit;
}
echo "ERR : " . $result["message"] . "\n";
}
function post($url,$data) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data))
);
$result = curl_exec($ch);
return $result;
}
}

View File

@@ -0,0 +1,157 @@
<?php
class Upl_mou extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database('regional', true);
}
function unrelease() {
$param = $this->sys_input["param"];
$j_param = json_encode($param);
$md5 = $this->sys_input["md5"];
$l_md5 = md5($j_param);
if ($md5 != $l_md5 ) {
$this->sys_error("Md5 $md5 <> $l_md5");
exit;
}
$mouID = $param["mouID"];
$staffNIK = $param["staffNIK"];
$branchCode = $param["branchCode"];
$ipAddress = $param["ipAddress"];
$staffName = $param["staffName"];
$jsonParam = json_encode(array("param" => $param, "md5" => $md5 ));
$data = array("TxMouReleaseM_MouID" => $mouID,
"TxMouReleaseIPAddress" => $ipAddress,
"TxMouReleaseM_BranchCode" => $branchCode,
"TxMouReleaseM_StaffNIK" => $staffNIK,
"TxMouReleaseM_StaffName" => $staffName,
"TxMouReleaseJson" => $jsonParam,
"TxMouReleaseStatus" => $param["status"]
);
$qry = $this->db->insert("tx_mou_release",$data);
if (!$qry ) {
$this->sys_error( print_r($this->db->error(),true));
exit;
}
$sql = "INSERT g_moustatuslog
(G_MouStatusLogDate,
G_MouStatusLogM_MouID,
G_MouStatusLogStatus,
G_MouStatusLogUserID,
G_MouStatusLogCreated,
G_MouStatusLogLastUpdated)
VALUES(
date(now()),
'{$mouID}',
'UR',
'3',
now(),
now())";
$qry = $this->db->query($sql);
if (!$qry ) {
$this->sys_error( print_r($this->db->error(),true));
exit;
}
$sql = "update m_mou SET
M_MouIsReleased = 'N',
M_MouStatus = 'UR',
M_MouAllowVerify = 'Y',
M_MouReleaseDate = now(),
M_MouReleaseUserID = 3,
M_MouIsApproved = 'Y',
M_MouLastUpdated = now()
WHERE
M_MouID = ?";
$qry = $this->db->query($sql,array($mouID));
if (!$qry ) {
$this->sys_error( print_r($this->db->error(),true));
exit;
}
$this->sys_ok( array("message" => "Un Release OK"));
}
function release() {
$param = $this->sys_input["param"];
$j_param = json_encode($param);
$md5 = $this->sys_input["md5"];
$l_md5 = md5($j_param);
if ($md5 != $l_md5 ) {
$this->sys_error("Md5 $md5 <> $l_md5");
exit;
}
$mouID = $param["mouID"];
$staffNIK = $param["staffNIK"];
$branchCode = $param["branchCode"];
$ipAddress = $param["ipAddress"];
$staffName = $param["staffName"];
$jsonParam = json_encode(array("param" => $param, "md5" => $md5 ));
$data = array("TxMouReleaseM_MouID" => $mouID,
"TxMouReleaseIPAddress" => $ipAddress,
"TxMouReleaseM_BranchCode" => $branchCode,
"TxMouReleaseM_StaffNIK" => $staffNIK,
"TxMouReleaseM_StaffName" => $staffName,
"TxMouReleaseJson" => $jsonParam,
"TxMouReleaseStatus" => $param["status"]
);
$qry = $this->db->insert("tx_mou_release",$data);
if (!$qry ) {
$this->sys_error( print_r($this->db->error(),true));
exit;
}
$sql = "INSERT g_moustatuslog
(G_MouStatusLogDate,
G_MouStatusLogM_MouID,
G_MouStatusLogStatus,
G_MouStatusLogUserID,
G_MouStatusLogCreated,
G_MouStatusLogLastUpdated)
VALUES(
date(now()),
'{$mouID}',
'R',
'3',
now(),
now())";
$qry = $this->db->query($sql);
if (!$qry ) {
$this->sys_error( " Insert MOU " . print_r($this->db->error(),true));
exit;
}
$sql = "update m_mou SET
M_MouIsReleased = 'Y',
M_MouStatus = 'R',
M_MouAllowVerify = 'N',
M_MouReleaseDate = now(),
M_MouReleaseUserID = 3,
M_MouIsApproved = 'Y',
M_MouLastUpdated = now()
WHERE
M_MouID = ?";
$qry = $this->db->query($sql,array($mouID));
if (!$qry ) {
$this->sys_error( print_r($this->db->error(),true));
exit;
}
$this->sys_ok( array("message" => "Release OK"));
}
function post($url,$data) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data))
);
$result = curl_exec($ch);
if (curl_errno($ch)){
return json_encode( array("status" => "ERR",
"message" => curl_error($ch)) );
}
curl_close($ch);
return $result;
}
}

View File

@@ -0,0 +1,205 @@
<?php
class Upl_mou_v2 extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database('regional', true);
}
function unrelease() {
$param = $this->sys_input["param"];
$j_param = json_encode($param);
$md5 = $this->sys_input["md5"];
$l_md5 = md5($j_param);
if ($md5 != $l_md5 ) {
$this->sys_error("Md5 $md5 <> $l_md5");
exit;
}
$mouID = $param["mouID"];
$staffNIK = $param["staffNIK"];
$branchCode = $param["branchCode"];
$ipAddress = $param["ipAddress"];
$staffName = $param["staffName"];
$jsonParam = json_encode(array("param" => $param, "md5" => $md5 ));
$data = array("TxMouReleaseM_MouID" => $mouID,
"TxMouReleaseIPAddress" => $ipAddress,
"TxMouReleaseM_BranchCode" => $branchCode,
"TxMouReleaseM_StaffNIK" => $staffNIK,
"TxMouReleaseM_StaffName" => $staffName,
"TxMouReleaseJson" => $jsonParam,
"TxMouReleaseStatus" => $param["status"]
);
$qry = $this->db->insert("tx_mou_release",$data);
if (!$qry ) {
$this->sys_error( print_r($this->db->error(),true));
exit;
}
$sql = "INSERT g_moustatuslog
(G_MouStatusLogDate,
G_MouStatusLogM_MouID,
G_MouStatusLogStatus,
G_MouStatusLogUserID,
G_MouStatusLogCreated,
G_MouStatusLogLastUpdated)
VALUES(
date(now()),
'{$mouID}',
'UR',
'3',
now(),
now())";
$qry = $this->db->query($sql);
if (!$qry ) {
$this->sys_error( "Log : " . print_r($this->db->error(),true));
exit;
}
$sql = "update m_mou SET
M_MouIsReleased = 'N',
M_MouStatus = 'UR',
M_MouAllowVerify = 'Y',
M_MouReleaseDate = now(),
M_MouReleaseUserID = 3,
M_MouIsApproved = 'Y',
M_MouLastUpdated = now()
WHERE
M_MouID = ?";
$qry = $this->db->query($sql,array($mouID));
if (!$qry ) {
$this->sys_error( "M_Mou : " . print_r($this->db->error(),true));
exit;
}
//insert into other branch unrelease
$data = array("M_MouID" => $mouID,
"M_StaffNIK" => $staffNIK,
"M_StaffName" => $staffName);
$md5 = md5( json_encode($data) );
$jsonParam = json_encode(array("md5" => $md5, "param" => $data));
$sql = "insert into tx_mou(TxMouM_MouID, TxMouT_TestID, TxMouM_BranchCode,
TxMouM_BranchIPAddress,TxMouJson)
select ?, -2, M_BranchCode, M_BranchIPAddress , ?
from m_branch
where M_BranchIsActive = 'Y' and M_BranchCode <> ? ";
$qry = $this->db->query($sql, array($mouID,$jsonParam,$branchCode));
if (!$qry ) {
$this->sys_error( "Tx Mou : " . print_r($this->db->error(),true));
exit;
}
$records = $this->db->affected_rows();
$sql = "select * from tx_mou where TxMouM_MouID = ?
and TxMouT_TestID = -2 and TxMouStatus = 'N'
order by TxMouID desc
limit 0,$records";
$qry = $this->db->query($sql, array($mouID));
if (!$qry ) {
$this->sys_error( "Sel tx Mou : " . print_r($this->db->error(),true));
exit;
}
$rows = $qry->result_array();
$flag_err = false;
$err_msg = array();
foreach($rows as $r) {
$data = $r["TxMouJson"];
$md5 = md5($data);
$ipAddress = $r["TxMouM_BranchIPAddress"];
$url = "http://$ipAddress/one-api/tools/price/r_mou/unrelease";
$post_rst = $this->post($url, $jsonParam);
$rst = json_decode($post_rst, true);
if ( $rst["status"] != "OK" ) {
$err_msg[] = $post_rst;
$flag_err = true;
}
}
if ($flag_err) {
$this->sys_error( join(",", $err_msg) );
exit;
}
$this->sys_ok( array("message" => "Un Release OK"));
}
function release() {
$param = $this->sys_input["param"];
$j_param = json_encode($param);
$md5 = $this->sys_input["md5"];
$l_md5 = md5($j_param);
if ($md5 != $l_md5 ) {
$this->sys_error("Md5 $md5 <> $l_md5");
exit;
}
$mouID = $param["mouID"];
$staffNIK = $param["staffNIK"];
$branchCode = $param["branchCode"];
$ipAddress = $param["ipAddress"];
$staffName = $param["staffName"];
$jsonParam = json_encode(array("param" => $param, "md5" => $md5 ));
$data = array("TxMouReleaseM_MouID" => $mouID,
"TxMouReleaseIPAddress" => $ipAddress,
"TxMouReleaseM_BranchCode" => $branchCode,
"TxMouReleaseM_StaffNIK" => $staffNIK,
"TxMouReleaseM_StaffName" => $staffName,
"TxMouReleaseJson" => $jsonParam,
"TxMouReleaseStatus" => $param["status"]
);
$qry = $this->db->insert("tx_mou_release",$data);
if (!$qry ) {
$this->sys_error( print_r($this->db->error(),true));
exit;
}
$sql = "INSERT g_moustatuslog
(G_MouStatusLogDate,
G_MouStatusLogM_MouID,
G_MouStatusLogStatus,
G_MouStatusLogUserID,
G_MouStatusLogCreated,
G_MouStatusLogLastUpdated)
VALUES(
date(now()),
'{$mouID}',
'R',
'3',
now(),
now())";
$qry = $this->db->query($sql);
if (!$qry ) {
$this->sys_error( " Insert MOU " . print_r($this->db->error(),true));
exit;
}
$sql = "update m_mou SET
M_MouIsReleased = 'Y',
M_MouStatus = 'R',
M_MouAllowVerify = 'N',
M_MouReleaseDate = now(),
M_MouReleaseUserID = 3,
M_MouIsApproved = 'Y',
M_MouLastUpdated = now()
WHERE
M_MouID = ?";
$qry = $this->db->query($sql,array($mouID));
if (!$qry ) {
$this->sys_error( print_r($this->db->error(),true));
exit;
}
$this->sys_ok( array("message" => "Release OK"));
}
function post($url,$data) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data))
);
$result = curl_exec($ch);
if (curl_errno($ch)){
return json_encode( array("status" => "ERR",
"message" => curl_error($ch)) );
}
curl_close($ch);
return $result;
}
}

View File

@@ -0,0 +1,215 @@
<?php
class Upl_mou_v2 extends MY_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database('regional', true);
}
function unrelease() {
$param = $this->sys_input["param"];
$j_param = json_encode($param);
$md5 = $this->sys_input["md5"];
$l_md5 = md5($j_param);
if ($md5 != $l_md5 ) {
$this->sys_error("Md5 $md5 <> $l_md5");
exit;
}
$mouID = $param["mouID"];
$staffNIK = $param["staffNIK"];
$branchCode = $param["branchCode"];
$ipAddress = $param["ipAddress"];
$staffName = $param["staffName"];
$jsonParam = json_encode(array("param" => $param, "md5" => $md5 ));
$data = array("TxMouReleaseM_MouID" => $mouID,
"TxMouReleaseIPAddress" => $ipAddress,
"TxMouReleaseM_BranchCode" => $branchCode,
"TxMouReleaseM_StaffNIK" => $staffNIK,
"TxMouReleaseM_StaffName" => $staffName,
"TxMouReleaseJson" => $jsonParam,
"TxMouReleaseStatus" => $param["status"]
);
$qry = $this->db->insert("tx_mou_release",$data);
if (!$qry ) {
$this->sys_error( print_r($this->db->error(),true));
exit;
}
$sql = "INSERT g_moustatuslog
(G_MouStatusLogDate,
G_MouStatusLogM_MouID,
G_MouStatusLogStatus,
G_MouStatusLogUserID,
G_MouStatusLogCreated,
G_MouStatusLogLastUpdated)
VALUES(
date(now()),
'{$mouID}',
'UR',
'3',
now(),
now())";
$qry = $this->db->query($sql);
if (!$qry ) {
$this->sys_error( "Log : " . print_r($this->db->error(),true));
exit;
}
$sql = "update m_mou SET
M_MouIsReleased = 'N',
M_MouStatus = 'UR',
M_MouAllowVerify = 'Y',
M_MouReleaseDate = now(),
M_MouReleaseUserID = 3,
M_MouIsApproved = 'Y',
M_MouLastUpdated = now()
WHERE
M_MouID = ?";
$qry = $this->db->query($sql,array($mouID));
if (!$qry ) {
$this->sys_error( "M_Mou : " . print_r($this->db->error(),true));
exit;
}
//insert into other branch unrelease
$data = array("M_MouID" => $mouID,
"M_StaffNIK" => $staffNIK,
"M_StaffName" => $staffName);
$md5 = md5( json_encode($data) );
$jsonParam = json_encode(array("md5" => $md5, "param" => $data));
$sql = "insert into tx_mou(TxMouM_MouID, TxMouT_TestID, TxMouM_BranchCode,
TxMouM_BranchIPAddress,TxMouJson)
select ?, -2, M_BranchCode, M_BranchIPAddress , ?
from m_branch
JOIN s_regional ON M_BranchS_RegionalID = S_RegionalID AND S_RegionalIsDefault = 'Y'
where M_BranchIsActive = 'Y' and M_BranchCode <> ? ";
$qry = $this->db->query($sql, array($mouID,$jsonParam,$branchCode));
if (!$qry ) {
$this->sys_error( "Tx Mou : " . print_r($this->db->error(),true));
exit;
}
$records = $this->db->affected_rows();
$sql = "select * from tx_mou where TxMouM_MouID = ?
and TxMouT_TestID = -2 and TxMouStatus = 'N'
order by TxMouID desc
limit 0,$records";
$qry = $this->db->query($sql, array($mouID));
if (!$qry ) {
$this->sys_error( "Sel tx Mou : " . print_r($this->db->error(),true));
exit;
}
$rows = $qry->result_array();
$flag_err = false;
$err_msg = array();
foreach($rows as $r) {
$data = $r["TxMouJson"];
$md5 = md5($data);
$ipAddress = $r["TxMouM_BranchIPAddress"];
$url = "http://$ipAddress/one-api/tools/price/r_mou/unrelease";
$post_rst = $this->post($url, $jsonParam);
$rst = json_decode($post_rst, true);
$txMouID = $r["TxMouID"];
if ( $rst["status"] != "OK" ) {
$err_msg[] = $post_rst;
$flag_err = true;
$sql = "update tx_mou set TxMouRetry = TxMouRetry + 1 where TxMouID = ?";
} else {
$sql = "update tx_mou set TxMouRetry = TxMouRetry + 1, TxMouStatus = 'Y' where TxMouID = ?";
}
$qry = $this->db->query($sql,array($txMouID));
if (! $qry ) {
$flag_err = true;
$err_msg[] = print_r($this->db->error(),true);
}
}
if ($flag_err) {
$this->sys_error( join(",", $err_msg) );
exit;
}
$this->sys_ok( array("message" => "Un Release OK"));
}
function release() {
$param = $this->sys_input["param"];
$j_param = json_encode($param);
$md5 = $this->sys_input["md5"];
$l_md5 = md5($j_param);
if ($md5 != $l_md5 ) {
$this->sys_error("Md5 $md5 <> $l_md5");
exit;
}
$mouID = $param["mouID"];
$staffNIK = $param["staffNIK"];
$branchCode = $param["branchCode"];
$ipAddress = $param["ipAddress"];
$staffName = $param["staffName"];
$jsonParam = json_encode(array("param" => $param, "md5" => $md5 ));
$data = array("TxMouReleaseM_MouID" => $mouID,
"TxMouReleaseIPAddress" => $ipAddress,
"TxMouReleaseM_BranchCode" => $branchCode,
"TxMouReleaseM_StaffNIK" => $staffNIK,
"TxMouReleaseM_StaffName" => $staffName,
"TxMouReleaseJson" => $jsonParam,
"TxMouReleaseStatus" => $param["status"]
);
$qry = $this->db->insert("tx_mou_release",$data);
if (!$qry ) {
$this->sys_error( print_r($this->db->error(),true));
exit;
}
$sql = "INSERT g_moustatuslog
(G_MouStatusLogDate,
G_MouStatusLogM_MouID,
G_MouStatusLogStatus,
G_MouStatusLogUserID,
G_MouStatusLogCreated,
G_MouStatusLogLastUpdated)
VALUES(
date(now()),
'{$mouID}',
'R',
'3',
now(),
now())";
$qry = $this->db->query($sql);
if (!$qry ) {
$this->sys_error( " Insert MOU " . print_r($this->db->error(),true));
exit;
}
$sql = "update m_mou SET
M_MouIsReleased = 'Y',
M_MouStatus = 'R',
M_MouAllowVerify = 'N',
M_MouReleaseDate = now(),
M_MouReleaseUserID = 3,
M_MouIsApproved = 'Y',
M_MouLastUpdated = now()
WHERE
M_MouID = ?";
$qry = $this->db->query($sql,array($mouID));
if (!$qry ) {
$this->sys_error( print_r($this->db->error(),true));
exit;
}
$this->sys_ok( array("message" => "Release OK"));
}
function post($url,$data) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data))
);
$result = curl_exec($ch);
if (curl_errno($ch)){
return json_encode( array("status" => "ERR",
"message" => curl_error($ch)) );
}
curl_close($ch);
return $result;
}
}

View File

@@ -0,0 +1,127 @@
<?php
class Xfer extends CI_Controller
{
function __construct() {
parent::__construct();
$this->db = $this->load->database("regional", true);
$this->db_regional = $this->load->database("regional", true);
}
function upload_mou($mouID,$branchCode) {
//upload aggrement , ss_price_mou
$sql = "select * from m_mou where M_MouID = ?";
$qry = $this->db_regional->query($sql, array($mouID));
if (! $qry) {
return array(false, print_r($this->db_regional->error(),true));
}
$rows = $qry->result_array();
if (count($rows) == 0) {
return array(false, "No MOU : " . $this->db_regional->last_query());
}
$mou = $rows[0];
$sql = "select * from m_company where M_CompanyID = ?";
$qry = $this->db_regional->query($sql, array($mou["M_MouM_CompanyID"]));
if (! $qry) {
return array(false, print_r($this->db_regional->error(),true));
}
$rows = $qry->result_array();
if (count($rows) == 0 ) {
return array(false, "No Company");
}
$company = $rows[0];
$sql = "select * from g_moustatuslog where G_MouStatusLogM_MouID = ?";
$qry = $this->db_regional->query($sql, array($mouID));
if (! $qry) {
return array(false, print_r($this->db_regional->error(),true));
}
$rows = $qry->result_array();
if (count($rows) == 0) {
return array(false, "No Log");
}
$logs = $rows;
$mou["M_MouUserID"] = 3; // set to 3
foreach($logs as $idx => $l ) {
$logs[$idx]["G_MouStatusLogUserID"] = 3;
}
$sql = "select * from ss_price_mou where Ss_PriceMouM_MouID= ?";
$qry = $this->db_regional->query($sql, array($mouID));
if (! $qry) {
return array(false, print_r($this->db_regional->error(),true));
}
$rows = $qry->result_array();
if (count($rows) == 0 ) {
return array(false, "No Ss Price Mou");
}
$sql = "select * from t_price where T_PriceM_MouID= ?";
$qry = $this->db_regional->query($sql, array($mouID));
if (! $qry) {
return array(false, print_r($this->db_regional->error(),true));
}
$t_rows = $qry->result_array();
$sql = "select * from t_packet where T_PacketM_MouID = ?";
$qry = $this->db_regional->query($sql, array($mouID));
if (! $qry) {
return array(false, print_r($this->db_regional->error(),true));
}
$pkt_rows = $qry->result_array();
$sql = "select t_packetdetail.*
from t_packet
join t_packetdetail on T_PacketDetailT_PacketID = T_PacketID
where T_PacketM_MouID = ?";
$qry = $this->db_regional->query($sql, array($mouID));
if (! $qry) {
return array(false, print_r($this->db_regional->error(),true));
}
$pd_rows = $qry->result_array();
$param = array (
"mou" => $mou,
"company" => $company,
"logs" => $logs,
"price_mou" => $rows,
"t_price" => $t_rows,
"packet" => $pkt_rows,
"packet_detail" => $pd_rows
);
$param_md5 = md5(json_encode($param));
$j_param = json_encode(array("param" => $param, "md5" => $param_md5 ));
$sql = "select * from m_branch where M_BranchIsActive = 'Y' and M_BranchCode=?";
$qry = $this->db_regional->query($sql, array($branchCode));
if (! $qry) {
return array(false, print_r($this->db_regional->error(),true));
}
$rows = $qry->result_array();
if (count($rows) == 0 ) {
return array(false, "No Ss Price Mou");
}
$sql = "insert into tx_mou(TxMouM_BranchIPAddress, TxMouM_BranchCode,TxMouM_MouID, TxMouJson,TxMouM_UserID )
values(?,?,?,?,?)";
$sql_del = "delete from tx_mou where TxMouM_MouID=? and TxMouM_BranchCode=?";
$flag_error = false;
$err_msg = array();
$userID = 3;
foreach($rows as $r ) {
$branchCode = $r["M_BranchCode"];
$ipAddress = $r["M_BranchIPAddress"];
$qry = $this->db_regional->query($sql_del, array($mouID,$branchCode));
if (! $qry) {
return array(false, print_r($this->db_regional->error(),true));
}
$qry = $this->db_regional->query($sql, array($ipAddress, $branchCode,$mouID,$j_param,$userID));
if (! $qry) {
return array(false, print_r($this->db_regional->error(),true));
}
}
if ( $flag_error) {
return array(false, join(",",$err_msg));
}
return array(true,"OK");
}
}

View File

@@ -0,0 +1,226 @@
<?php
class Category_packet_upload extends MY_Controller
{
var $url;
function __construct()
{
parent::__construct();
$this->url= "https://devregonline.pramita.co.id/one-api/tools/regonline/r_category_packet";
//$this->url_prod= "https://mobile.pramita.co.id/one-api/tools/regonline/r_category_packet";
}
function step_debug($rows)
{
print_r($rows);
exit();
}
function get_rows($sql, $prm = false)
{
if ($prm) {
$qry = $this->db->query($sql, $prm);
} else {
$qry = $this->db->query($sql);
}
if (!$qry) {
$msg = "Error Query : {$this->db->error()["message"]} | {$this->db->last_query()}\n";
return array("status"=>-1, "message" => $msg);
}
$rows = $qry->result_array();
return array("status" => 0, "data" => $rows);
}
function get_one_row($sql, $prm =false)
{
$resp = $this->get_rows($sql, $prm);
if ($resp["status"] == -1 ) return $resp;
if (count($resp["data"]) == 0) {
return array("status"=> 0, "message" => "No record.");
}
return array("status" => 1, "data" => $resp["data"][0]);
}
function get_max($table) {
$field = strtoupper($table);
$sql = "select max({$field}LastUpdated) LastUpdated, max({$field}Created) Created
from $table";
$resp = $this->get_one_row($sql);
if ($resp["status"] == -1) {
$this->log("Err get max $table |" . $resp["message"]);
exit;
}
if ($resp["status"] == 0) return "1971-01-01 00:00:01";
$max = $resp["data"]["LastUpdated"] > $resp["data"]["Created"] ? $resp["data"]["Created"] : $resp["data"]["LastUpdated"];
return $max;
}
function index() {
$regionalID = $this->get_regional();
$date = $this->get_heartbeat();
$max = $this->get_max("m_packetcategory");
$max2 = $this->get_max("m_packetcategorydetail");
$max = $max > $max2 ? $max : $max2;
$max2 = $this->get_max("m_packetcategorymou");
$max = $max > $max2 ? $max : $max2;
if ($max == "") $max = "1971-01-01 00:00:01";
if ($max < $date) {
$this->log("No Packet Category updated or created neeed to be uploaded");
exit;
}
$result = [];
$sql = "select m_packetcategory.*, $regionalID as M_PacketCategoryS_RegionalID
from m_packetcategory";
$resp = $this->get_rows($sql);
if ($resp["status"] == -1) {
$this->log("Err get m_packetcategory |" . $resp["message"]);
exit;
}
$result["m_packetcategory"] = $resp["data"];
$sql = "select m_packetcategorydetail.*, $regionalID as M_PacketCategoryDetailS_RegionalID
from m_packetcategorydetail";
$resp = $this->get_rows($sql);
if ($resp["status"] == -1) {
$this->log("Err get m_packetcategorydetail |" . $resp["message"]);
exit;
}
$result["m_packetcategorydetail"] = $resp["data"];
$sql = "select m_packetcategorymou.*, $regionalID as M_PacketCategoryMouS_RegionalID
from m_packetcategorymou";
$resp = $this->get_rows($sql);
if ($resp["status"] == -1) {
$this->log("Err get m_packetcategorymou |" . $resp["message"]);
exit;
}
$result["m_packetcategorymou"] = $resp["data"];
$counter_data =0;
$all_name = "";
$rows = $result["m_packetcategory"];
$data = [];
foreach($rows as $r) {
$order = $r["M_PacketCategoryOrder"];
$id = $r["M_PacketCategoryID"];
$name = sprintf("%02d",$order) . "-" . sprintf("%03d",$id) . "-" . $r["M_PacketCategoryImageUrl"];
$real_name = "/home/regional/project/regional/one-media/one-regonline/" . $r["M_PacketCategoryImageUrl"];
if(! file_exists($real_name)) {
$this->log("File $real_name not exists");
} else {
$all_name .= $name;
$data[] = array(
"name" => $name,
"regionalID" => $regionalID,
"categoryID" => $id,
"content" => base64_encode(file_get_contents($real_name))
);
$counter_data++;
}
}
$msg = "Uploaded {$counter_data} image.";
$j_data = json_encode(array(
"data" => $data,
"result" => $result,
"md5" => md5($all_name . $regionalID . "545123")
));
$j_resp = $this->post($this->url, $j_data);
echo "JRESP : $j_resp\n";
$resp = json_decode($j_resp,true);
$json_error = json_last_error_msg();
if (json_last_error() != 0) {
$msg .= " [JSON ERR] $json_error " ;
}
if($resp["status"] == "OK") {
$msg .= " [Success] ";
$this->update_heartbeat("OK","");
} else {
$msg .= " [ERR] " ;
if($resp["message"] != "") $msg .= " " . $resp["message"];
$this->update_heartbeat("ERR",$msg);
}
$this->log($msg);
}
function log($msg) {
$date = date("Y-m-d H:i:s");
echo "$date $msg\n";
}
function get_regional() {
$sql = "select S_RegionalID from s_regional where S_RegionalIsActive= 'Y' and S_RegionalIsDefault= 'Y'";
$resp = $this->get_one_row($sql);
if ($resp["status"] == -1) {
$this->log("Error get reginalID | " . $resp["message"]);
}
if ($resp["status"] == 0) {
$this->log("Error default regional not set.");
}
return $resp["data"]["S_RegionalID"];
}
function get_heartbeat() {
$sql="select * from regonline.heartbeat where heartbeatCode='PACKET_CATEGORY'";
$qry = $this->db->query($sql);
if (!$qry) {
echo date("Y-m-d H:i:s") .
" Err : " .
$this->db->error()["message"] .
"\n";
exit();
}
$rows = $qry->result_array();
if (count($rows) == 0) {
$sql = "insert into regonline.heartbeat(heartbeatCode,heartbeatStatus,heartbeatExecuted,heartbeatMessage)
values('PACKET_CATEGORY','OK','1971-01-01 00:00:01','')";
$qry = $this->db->query($sql);
if (!$qry) {
echo date("Y-m-d H:i:s") .
" Err : " .
$this->db->error()["message"] .
"\n";
exit();
}
return "1971-01-01 00:00:01";
}
return $rows[0]["heartbeatExecuted"];
}
function update_heartbeat( $status, $msg)
{
$type = "PACKET_CATEGORY";
if ($status == "OK") {
$sql = "update regonline.heartbeat set heartbeatExecuted = now(), heartbeatStatus = ? , heartbeatMessage = ?
where heartbeatCode = ?";
$qry = $this->db->query($sql, array($status, $msg, $type));
} else {
$sql = "update regonline.heartbeat set heartbeatStatus = ? , heartbeatMessage = ?
where heartbeatCode = ?";
$qry = $this->db->query($sql, array($status, $msg, $type));
}
if (!$qry) {
echo date("Y-m-d H:i:s") . " \t Error $type : {$this->db->error()['message']}\n";
}
}
function post($url, $data, $timeout = 60, $c_timeout = 5)
{
$zdata = gzcompress($data);
$this->log("Upload to $url : " . ( round(strlen($zdata) / 1024) ) . " kB");
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $c_timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_POSTFIELDS, $zdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/octet",
"Content-Length: " . strlen($zdata),
]);
$result = curl_exec($ch);
$err_msg = curl_error($ch);
if ($err_msg != "") {
return json_encode([
"status" => "ERR",
"message" => $err_msg,
"url" => $url,
"data" => json_decode($data, true),
]);
}
return $result;
}
}

View File

@@ -0,0 +1,225 @@
<?php
class Category_packet_upload extends MY_Controller
{
var $url;
function __construct()
{
parent::__construct();
$this->url= "https://devregonline.pramita.co.id/one-api/tools/regonline/r_category_packet";
}
function step_debug($rows)
{
print_r($rows);
exit();
}
function get_rows($sql, $prm = false)
{
if ($prm) {
$qry = $this->db->query($sql, $prm);
} else {
$qry = $this->db->query($sql);
}
if (!$qry) {
$msg = "Error Query : {$this->db->error()["message"]} | {$this->db->last_query()}\n";
return array("status"=>-1, "message" => $msg);
}
$rows = $qry->result_array();
return array("status" => 0, "data" => $rows);
}
function get_one_row($sql, $prm =false)
{
$resp = $this->get_rows($sql, $prm);
if ($resp["status"] == -1 ) return $resp;
if (count($resp["data"]) == 0) {
return array("status"=> 0, "message" => "No record.");
}
return array("status" => 1, "data" => $resp["data"][0]);
}
function get_max($table) {
$field = strtoupper($table);
$sql = "select max({$field}LastUpdated) LastUpdated, max({$field}Created) Created
from $table";
$resp = $this->get_one_row($sql);
if ($resp["status"] == -1) {
$this->log("Err get max $table |" . $resp["message"]);
exit;
}
if ($resp["status"] == 0) return "1971-01-01 00:00:01";
$max = $resp["data"]["LastUpdated"] > $resp["data"]["Created"] ? $resp["data"]["Created"] : $resp["data"]["LastUpdated"];
return $max;
}
function index() {
$regionalID = $this->get_regional();
$date = $this->get_heartbeat();
$max = $this->get_max("m_packetcategory");
$max2 = $this->get_max("m_packetcategorydetail");
$max = $max > $max2 ? $max : $max2;
$max2 = $this->get_max("m_packetcategorymou");
$max = $max > $max2 ? $max : $max2;
if ($max == "") $max = "1971-01-01 00:00:01";
if ($max < $date) {
$this->log("No Packet Category updated or created neeed to be uploaded");
exit;
}
$result = [];
$sql = "select m_packetcategory.*, $regionalID as M_PacketCategoryS_RegionalID
from m_packetcategory";
$resp = $this->get_rows($sql);
if ($resp["status"] == -1) {
$this->log("Err get m_packetcategory |" . $resp["message"]);
exit;
}
$result["m_packetcategory"] = $resp["data"];
$sql = "select m_packetcategorydetail.*, $regionalID as M_PacketCategoryDetailS_RegionalID
from m_packetcategorydetail";
$resp = $this->get_rows($sql);
if ($resp["status"] == -1) {
$this->log("Err get m_packetcategorydetail |" . $resp["message"]);
exit;
}
$result["m_packetcategorydetail"] = $resp["data"];
$sql = "select m_packetcategorymou.*, $regionalID as M_PacketCategoryMouS_RegionalID
from m_packetcategorymou";
$resp = $this->get_rows($sql);
if ($resp["status"] == -1) {
$this->log("Err get m_packetcategorymou |" . $resp["message"]);
exit;
}
$result["m_packetcategorymou"] = $resp["data"];
$counter_data =0;
$all_name = "";
$rows = $result["m_packetcategory"];
$data = [];
foreach($rows as $r) {
$order = $r["M_PacketCategoryOrder"];
$id = $r["M_PacketCategoryID"];
$name = sprintf("%02d",$order) . "-" . sprintf("%03d",$id) . "-" . $r["M_PacketCategoryImageUrl"];
$real_name = "/home/regional/project/regional/one-media/one-regonline/" . $r["M_PacketCategoryImageUrl"];
if(! file_exists($real_name)) {
$this->log("File $real_name not exists");
} else {
$all_name .= $name;
$data[] = array(
"name" => $name,
"regionalID" => $regionalID,
"categoryID" => $id,
"content" => base64_encode(file_get_contents($real_name))
);
$counter_data++;
}
}
$msg = "Uploaded {$counter_data} image.";
$j_data = json_encode(array(
"data" => $data,
"result" => $result,
"md5" => md5($all_name . $regionalID . "545123")
));
$j_resp = $this->post($this->url, $j_data);
echo "JRESP : $j_resp\n";
$resp = json_decode($j_resp,true);
$json_error = json_last_error_msg();
if (json_last_error() != 0) {
$msg .= " [JSON ERR] $json_error " ;
}
if($resp["status"] == "OK") {
$msg .= " [Success] ";
$this->update_heartbeat("OK","");
} else {
$msg .= " [ERR] " ;
if($resp["message"] != "") $msg .= " " . $resp["message"];
$this->update_heartbeat("ERR",$msg);
}
$this->log($msg);
}
function log($msg) {
$date = date("Y-m-d H:i:s");
echo "$date $msg\n";
}
function get_regional() {
$sql = "select S_RegionalID from s_regional where S_RegionalIsActive= 'Y' and S_RegionalIsDefault= 'Y'";
$resp = $this->get_one_row($sql);
if ($resp["status"] == -1) {
$this->log("Error get reginalID | " . $resp["message"]);
}
if ($resp["status"] == 0) {
$this->log("Error default regional not set.");
}
return $resp["data"]["S_RegionalID"];
}
function get_heartbeat() {
$sql="select * from regonline.heartbeat where heartbeatCode='PACKET_CATEGORY'";
$qry = $this->db->query($sql);
if (!$qry) {
echo date("Y-m-d H:i:s") .
" Err : " .
$this->db->error()["message"] .
"\n";
exit();
}
$rows = $qry->result_array();
if (count($rows) == 0) {
$sql = "insert into regonline.heartbeat(heartbeatCode,heartbeatStatus,heartbeatExecuted,heartbeatMessage)
values('PACKET_CATEGORY','OK','1971-01-01 00:00:01','')";
$qry = $this->db->query($sql);
if (!$qry) {
echo date("Y-m-d H:i:s") .
" Err : " .
$this->db->error()["message"] .
"\n";
exit();
}
return "1971-01-01 00:00:01";
}
return $rows[0]["heartbeatExecuted"];
}
function update_heartbeat( $status, $msg)
{
$type = "PACKET_CATEGORY";
if ($status == "OK") {
$sql = "update regonline.heartbeat set heartbeatExecuted = now(), heartbeatStatus = ? , heartbeatMessage = ?
where heartbeatCode = ?";
$qry = $this->db->query($sql, array($status, $msg, $type));
} else {
$sql = "update regonline.heartbeat set heartbeatStatus = ? , heartbeatMessage = ?
where heartbeatCode = ?";
$qry = $this->db->query($sql, array($status, $msg, $type));
}
if (!$qry) {
echo date("Y-m-d H:i:s") . " \t Error $type : {$this->db->error()['message']}\n";
}
}
function post($url, $data, $timeout = 60, $c_timeout = 5)
{
$zdata = gzcompress($data);
$this->log("Upload to $url : " . ( round(strlen($zdata) / 1024) ) . " kB");
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $c_timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_POSTFIELDS, $zdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/octet",
"Content-Length: " . strlen($zdata),
]);
$result = curl_exec($ch);
$err_msg = curl_error($ch);
if ($err_msg != "") {
return json_encode([
"status" => "ERR",
"message" => $err_msg,
"url" => $url,
"data" => json_decode($data, true),
]);
}
return $result;
}
}