Initial import
This commit is contained in:
BIN
application/controllers/fix/.Rujukan.php.swp
Normal file
BIN
application/controllers/fix/.Rujukan.php.swp
Normal file
Binary file not shown.
260
application/controllers/fix/Check_normal.php
Normal file
260
application/controllers/fix/Check_normal.php
Normal file
@@ -0,0 +1,260 @@
|
||||
<?php
|
||||
class Check_normal extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
function index() {
|
||||
echo "<pre>";
|
||||
|
||||
}
|
||||
function cek($order , $test , $instrumentID = 0) {
|
||||
$sql = "select T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber, M_PatientName, M_PatientM_SexID,
|
||||
fn_global_age_count_day(M_PatientDob,T_OrderHeaderDate) ageDay
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
where T_OrderHeaderLabNumber = ?";
|
||||
$qry = $this->db->query($sql, array($order));
|
||||
if (! $qry) {
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
echo "Order not found $order \n";
|
||||
exit;
|
||||
}
|
||||
$header = $rows[0];
|
||||
|
||||
$sql = "select T_TestName,T_TestID, T_TestNat_TestID ,
|
||||
T_OrderdetailNat_MethodeName, T_OrderDetailNat_NormalValueID,
|
||||
T_OrderDetailNormalValueNote, T_TestT_SampleTypeID
|
||||
from
|
||||
t_orderdetail
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, array($header["T_OrderHeaderID"]));
|
||||
|
||||
if (! $qry) {
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$detail = array();
|
||||
foreach($rows as $r) {
|
||||
$xpos = stripos($r["T_TestName"],$test);
|
||||
if ($xpos === FALSE ) {
|
||||
continue;
|
||||
}
|
||||
$detail = $r;
|
||||
$tOrderHeaderID = $header["T_OrderHeaderID"];
|
||||
$name = $header["M_PatientName"];
|
||||
$sexID = $header["M_PatientM_SexID"];
|
||||
$ageDay = $header["ageDay"];
|
||||
$natTestID = $detail["T_TestNat_TestID"];
|
||||
$testName = $detail["T_TestName"];
|
||||
$methode = $detail["T_OrderdetailNat_MethodeName"];
|
||||
$normalValue = $detail["T_OrderDetailNormalValueNote"];
|
||||
$sampleTypeID = $detail["T_TestT_SampleTypeID"];
|
||||
echo "<pre>";
|
||||
echo "Check Nilai Normal $testName, no lab. $order , $name , tanggal $tanggal : \n";
|
||||
echo "Pemeriksaan : $testName, Sample Type ID : $sampleTypeID \n";
|
||||
echo "Methode terpilih di orderdetail : $methode, NormalValue : $normalValue \n";
|
||||
echo "Umur in day $ageDay , Nat_TestID $natTestID\n";
|
||||
|
||||
$sql = "select distinct
|
||||
M_InstrumentMethodeNat_MethodeID, Nat_MethodeName, M_InstrumentMethodePriority,
|
||||
M_InstrumentMethodeCreated, M_InstrumentMethodeLastUpdated
|
||||
from m_instrumentmethode
|
||||
join nat_methode on M_InstrumentMethodeNat_MethodeID = Nat_MethodeID
|
||||
and Nat_MethodeIsActive = 'Y'
|
||||
join nat_instrument on M_InstrumentMethodeNat_InstrumentID = Nat_InstrumentID
|
||||
and Nat_InstrumentIsActive ='Y'
|
||||
where M_InstrumentMethodeNat_TestID = ?
|
||||
and M_InstrumentMethodeIsActive = 'Y'
|
||||
order by M_InstrumentMethodePriority desc";
|
||||
$qry = $this->db->query($sql, array($natTestID));
|
||||
if (! $qry) {
|
||||
print_r($this->db->error());
|
||||
continue;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
echo "Error Belum Ada Methode \n";
|
||||
continue;
|
||||
}
|
||||
$methodeID = 0;
|
||||
"Methode:\n";
|
||||
foreach($rows as $idx => $r) {
|
||||
$methodeID = $r["M_InstrumentMethodeNat_MethodeID"];
|
||||
$methodeName = $r["Nat_MethodeName"];
|
||||
$created= $r["M_InstrumentMethodeCreated"];
|
||||
echo "\n";
|
||||
echo "Priority: " . $r["M_InstrumentMethodePriority"] . " => " . $r["M_InstrumentMethodeNat_MethodeID"] . " | " . $r["Nat_MethodeName"] . "|$created";
|
||||
echo "\n";
|
||||
if ($methodeID == 0 ) {
|
||||
echo "Error Belum Ada Methode \n";
|
||||
continue;
|
||||
}
|
||||
//$sql = "select fn_sampling_get_normal(v_MethodeID, v_Nat_TestID, v_M_SexID, v_M_AgeInDay)";
|
||||
if ($instrumentID > 0 ) {
|
||||
$sql = "select fn_instrument_get_normal(?, ?, ?) as normalID";
|
||||
$qry = $this->db->query($sql, array($instrumentID, $natTestID, $tOrderHeaderID ));
|
||||
} else {
|
||||
$sql = "select fn_sampling_get_normal(?, ?, ?,?) as normalID";
|
||||
$qry = $this->db->query($sql, array($methodeID, $natTestID, $sexID, $ageDay));
|
||||
echo "--\n" . $this->db->last_query() . "\n---\n";
|
||||
}
|
||||
if (! $qry) {
|
||||
print_r($this->db->error());
|
||||
continue;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
echo "Nilai Normal Tidak Ketemu\n";
|
||||
continue;
|
||||
}
|
||||
$normalID = $rows[0]["normalID"];
|
||||
if ($normalID == 0 ) {
|
||||
echo "Nilai Normal Tidak Ketemu\n";
|
||||
continue;
|
||||
}
|
||||
$sql = "select * from nat_normalvalue where Nat_NormalValueID = ?";
|
||||
$qry = $this->db->query($sql, array($normalID));
|
||||
if (! $qry) {
|
||||
print_r($this->db->error());
|
||||
continue;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
print_r($rows);
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function all($order , $instrumentID = 0) {
|
||||
$sql = "select T_OrderHeaderID,T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber, M_PatientName, M_PatientM_SexID,
|
||||
fn_global_age_count_day(M_PatientDob,T_OrderHeaderDate) ageDay
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
where T_OrderHeaderLabNumber = ?";
|
||||
$qry = $this->db->query($sql, array($order));
|
||||
if (! $qry) {
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
echo "Order not found $order \n";
|
||||
exit;
|
||||
}
|
||||
$header = $rows[0];
|
||||
$sql = "select T_TestName,T_TestID, T_TestNat_TestID ,
|
||||
T_OrderdetailNat_MethodeName, T_OrderDetailNat_NormalValueID,
|
||||
T_OrderDetailNormalValueNote, T_TestT_SampleTypeID
|
||||
from
|
||||
t_orderdetail
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, array($header["T_OrderHeaderID"]));
|
||||
|
||||
if (! $qry) {
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$detail = array();
|
||||
$name = $header["M_PatientName"];
|
||||
$sexID = $header["M_PatientM_SexID"];
|
||||
$ageDay = $header["ageDay"];
|
||||
$tOrderHeaderID = $header["T_OrderHeaderID"];
|
||||
$tanggal = $header["T_OrderHeaderDate"];
|
||||
foreach($rows as $r) {
|
||||
$detail = $r;
|
||||
$natTestID = $detail["T_TestNat_TestID"];
|
||||
$testName = $detail["T_TestName"];
|
||||
$methode = $detail["T_OrderdetailNat_MethodeName"];
|
||||
$normalValue = $detail["T_OrderDetailNormalValueNote"];
|
||||
$sampleTypeID = $detail["T_TestT_SampleTypeID"];
|
||||
echo "<pre>";
|
||||
echo "Check Nilai Normal $testName, no lab. $order , $name , tanggal $tanggal : \n";
|
||||
echo "Pemeriksaan : $testName, Sample Type ID : $sampleTypeID \n";
|
||||
echo "Methode terpilih di orderdetail : $methode, NormalValue : $normalValue \n";
|
||||
echo "Umur in day $ageDay , Nat_TestID $natTestID\n";
|
||||
|
||||
$sql = "select distinct
|
||||
M_InstrumentMethodeNat_MethodeID, Nat_MethodeName, M_InstrumentMethodePriority
|
||||
from m_instrumentmethode
|
||||
join nat_methode on M_InstrumentMethodeNat_MethodeID = Nat_MethodeID
|
||||
and Nat_MethodeIsActive = 'Y'
|
||||
join nat_instrument on M_InstrumentMethodeNat_InstrumentID = Nat_InstrumentID
|
||||
and Nat_InstrumentIsActive ='Y'
|
||||
where M_InstrumentMethodeNat_TestID = ?
|
||||
and M_InstrumentMethodeIsActive = 'Y'
|
||||
order by M_InstrumentMethodePriority desc";
|
||||
$qry = $this->db->query($sql, array($natTestID));
|
||||
if (! $qry) {
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
echo "Error Belum Ada Methode \n";
|
||||
continue;
|
||||
}
|
||||
$methodeID = 0;
|
||||
"Methode:\n";
|
||||
foreach($rows as $idx => $r) {
|
||||
if ($idx == 0 ) {
|
||||
$methodeID = $r["M_InstrumentMethodeNat_MethodeID"];
|
||||
}
|
||||
$methodeName = $r["Nat_MethodeName"];
|
||||
echo "Priority : " . $r["M_InstrumentMethodePriority"] . " => |" . $r["M_InstrumentMethodeNat_MethodeID"] . " | " . $r["Nat_MethodeName"] ;
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
if ($methodeID == 0 ) {
|
||||
echo "Error Belum Ada Methode \n";
|
||||
exit;
|
||||
}
|
||||
//$sql = "select fn_sampling_get_normal(v_MethodeID, v_Nat_TestID, v_M_SexID, v_M_AgeInDay)";
|
||||
if ($instrumentID > 0 ) {
|
||||
$sql = "select fn_instrument_get_normal(?, ?, ?) as normalID";
|
||||
$qry = $this->db->query($sql, array($instrumentID, $natTestID, $tOrderHeaderID ));
|
||||
} else {
|
||||
$sql = "select fn_sampling_get_normal(?, ?, ?,?) as normalID";
|
||||
$qry = $this->db->query($sql, array($methodeID, $natTestID, $sexID, $ageDay));
|
||||
}
|
||||
if (! $qry) {
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
echo "Nilai Normal Tidak Ketemu\n";
|
||||
exit;
|
||||
}
|
||||
$normalID = $rows[0]["normalID"];
|
||||
if ($normalID == 0 ) {
|
||||
echo "Nilai Normal Tidak Ketemu\n";
|
||||
exit;
|
||||
}
|
||||
$sql = "select * from nat_normalvalue where Nat_NormalValueID = ?";
|
||||
$qry = $this->db->query($sql, array($normalID));
|
||||
if (! $qry) {
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
print_r($rows);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
174
application/controllers/fix/Check_result.php
Normal file
174
application/controllers/fix/Check_result.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
class Check_result extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
function index() {
|
||||
echo "<pre>";
|
||||
echo "id [NOMOR LAB]\n Untuk check T_OrderHeaderID dari nomorlab itu\n\n";
|
||||
echo "cek [T_OrderHeaderID]\n Untuk menampilkan sample dari T_OrderHeaderID yang terkait\n\n";
|
||||
echo "cek [T_OrderHeaderID] true\n Untuk menampilkan sample dari T_OrderHeaderID yang terkait termasuk yg IsActive N\n\n";
|
||||
echo "update_order_sample [T_OrderSampleID targetNya] [T_OrderSampleID sumbernya]\n Copy status T_OrderSample dari sumber ke target \n\n";
|
||||
}
|
||||
function update_order_sample($targetID, $sourceID) {
|
||||
$sql = "update t_ordersample target
|
||||
join t_ordersample source on
|
||||
target.T_OrderSampleID = ?
|
||||
and target.T_OrderSampleWorklistReceive = 'N'
|
||||
and source.T_OrderSampleID = ?
|
||||
set
|
||||
target.T_OrderSampleSampling = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSampling, source.T_OrderSampleSampling),
|
||||
target.T_OrderSampleSamplingDate = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSamplingDate, source.T_OrderSampleSamplingDate),
|
||||
target.T_OrderSampleSamplingTime = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSamplingTime, source.T_OrderSampleSamplingTime),
|
||||
target.T_OrderSampleSamplingUserID = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSamplingUserID, source.T_OrderSampleSamplingUserID),
|
||||
|
||||
target.T_OrderSampleReceive = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceive, source.T_OrderSampleReceive),
|
||||
target.T_OrderSampleReceiveDate = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceiveDate, source.T_OrderSampleReceiveDate),
|
||||
target.T_OrderSampleReceiveTime = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceiveTime, source.T_OrderSampleReceiveTime),
|
||||
target.T_OrderSampleReceiveUserID = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceiveUserID, source.T_OrderSampleReceiveUserID),
|
||||
|
||||
target.T_OrderSampleVerification = if(target.T_OrderSampleVerification='Y',target.T_OrderSampleVerification, source.T_OrderSampleVerification),
|
||||
target.T_OrderSampleVerificationDate =if(target.T_OrderSampleVerification='Y',target.T_OrderSampleVerificationDate, source.T_OrderSampleVerificationDate),
|
||||
target.T_OrderSampleVerificationTime =if(source.T_OrderSampleVerification='Y',target.T_OrderSampleVerificationTime, source.T_OrderSampleVerificationTime),
|
||||
target.T_OrderSampleVerificationUserID =if(source.T_OrderSampleVerification='Y',target.T_OrderSampleVerificationUserID, source.T_OrderSampleVerificationUserID),
|
||||
|
||||
target.T_OrderSampleProcessing = if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessing, source.T_OrderSampleProcessing),
|
||||
target.T_OrderSampleProcessingDate= if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessingDate, source.T_OrderSampleProcessingDate),
|
||||
target.T_OrderSampleProcessingTime= if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessingTime, source.T_OrderSampleProcessingTime),
|
||||
target.T_OrderSampleProcessingUserID= if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessingUserID, source.T_OrderSampleProcessingUserID),
|
||||
|
||||
target.T_OrderSampleReceiveHandling =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandling, source.T_OrderSampleReceiveHandling ),
|
||||
target.T_OrderSampleReceiveHandlingDate =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandlingDate, source.T_OrderSampleReceiveHandlingDate),
|
||||
target.T_OrderSampleReceiveHandlingTime =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandlingTime, source.T_OrderSampleReceiveHandlingTime),
|
||||
target.T_OrderSampleReceiveHandlingUserID =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandlingUserID, source.T_OrderSampleReceiveHandlingUserID),
|
||||
|
||||
target.T_OrderSampleHandling = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandling, source.T_OrderSampleHandling),
|
||||
target.T_OrderSampleHandlingDate = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandlingDate, source.T_OrderSampleHandlingDate),
|
||||
target.T_OrderSampleHandlingTime = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandlingTime, source.T_OrderSampleHandlingTime),
|
||||
target.T_OrderSampleHandlingUserID = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandlingUserID, source.T_OrderSampleHandlingUserID),
|
||||
|
||||
target.T_OrderSampleWorklistReceive = source.T_OrderSampleWorklistReceive,
|
||||
target.T_OrderSampleWorklistReceiveDatetime = source.T_OrderSampleWorklistReceiveDateTime,
|
||||
target.T_OrderSampleWorklistReceiveUserID = source.T_OrderSampleWorklistReceiveUserID
|
||||
";
|
||||
$qry = $this->db->query($sql,array($targetID,$sourceID));
|
||||
if(! $qry ) {
|
||||
echo json_encode(array( "status" => "ERR" , "message" => print_r($this->db->error(),true)));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function id($order) {
|
||||
echo "<pre>";
|
||||
$sql = "select t_orderheader.* from t_orderheader join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
where T_OrderHeaderLabNumber like ? or T_OrderHeaderAddonLabNumberOrigin like ?";
|
||||
$qry = $this->db->query($sql, array("%" . $order . "%", "%{$order}%"));
|
||||
if (! $qry) {
|
||||
echo "ERR : \n" ;
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
echo "{$r['T_OrderHeaderID']}\t{$r['T_OrderHeaderDate']}\t{$r['T_OrderHeaderLabNumber']}\n";
|
||||
}
|
||||
}
|
||||
function cek($headerID, $all=false) {
|
||||
echo "<pre>";
|
||||
$sql ="select *
|
||||
from t_ordersample
|
||||
join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID
|
||||
where T_OrderSampleIsActive = 'Y' and T_OrderSampleT_OrderHeaderID=? order by T_OrderSampleID";
|
||||
if ($all) {
|
||||
$sql ="select *
|
||||
from t_ordersample
|
||||
left join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID
|
||||
where T_OrderSampleT_OrderHeaderID=? order by T_OrderSampleID";
|
||||
}
|
||||
$qry = $this->db->query($sql,array($headerID));
|
||||
if (! $qry) {
|
||||
echo "ERR : \n" ;
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
echo "T_OrderSampleID\tT_OrderSampleBarcode\tT_SampleTypeName\tT_OrderSampleWorklistReceive\tWl RcvDate\Wl RcvTime\tIsActive\n";
|
||||
foreach($rows as $r) {
|
||||
echo "{$r['T_OrderSampleID']}\t{$r['T_OrderSampleBarcode']}\t{$r['T_SampleTypeName']}\t{$r['T_OrderSampleWorklistReceive']}\t" .
|
||||
"{$r['T_OrderSampleWorklistReceiveDatetime']}\t{$r['T_OrderSampleWorklistReceiveUserID']}\t{$r['T_OrderSampleIsActive']}\n";
|
||||
}
|
||||
}
|
||||
function preanalytic($headerID) {
|
||||
$sql ="select *
|
||||
from t_orderdetailaddon
|
||||
join t_orderdetail on T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailAddOnIsActive = 'Y' and T_OrderDetailT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql,array($headerID));
|
||||
if (! $qry) {
|
||||
echo "ERR : \n" ;
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
echo "T_OrderDetailID\tT_OrderDetailT_TestName\tT_OrderDetailAddOnPreAnalytic\tT_OrderDetailAddOnPreAnalyticDate\n";
|
||||
foreach($rows as $r) {
|
||||
echo "{$r['T_OrderDetailID']}\t{$r['T_OrderDetailT_TestName']}\t{$r['T_OrderDetailAddOnPreAnalytic']}\t{$r['T_OrderDetailAddOnPreAnalyticDate']}\n";
|
||||
}
|
||||
}
|
||||
function pre_copy_from_to($fromID,$toID) {
|
||||
$sql = "update
|
||||
t_orderdetailaddon a
|
||||
join t_orderdetailaddon b on a.T_OrderDetailAddOnT_OrderDetailID = ?
|
||||
and b.T_OrderDetailAddOnT_OrderDetailID = ?
|
||||
set b.T_OrderDetailAddOnPreAnalytic = a.T_OrderDetailAddOnPreAnalytic ,
|
||||
b.T_OrderDetailAddOnPreAnalyticDate = a.T_OrderDetailAddOnPreAnalyticDate
|
||||
";
|
||||
$qry = $this->db->query($sql, array($fromID,$toID));
|
||||
echo $this->db->last_query() . "\n";
|
||||
if (! $qry) {
|
||||
echo "ERR : \n" ;
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
echo "Pre Analytic Update";
|
||||
}
|
||||
function cek_kuning($headerID) {
|
||||
$sql ="select a.T_OrderSampleWorklistReceive , b.T_OrderSampleWorklistReceive bRcv,
|
||||
a.T_OrderSampleWorklistReceiveDatetime, b.T_OrderSampleWorklistReceiveDatetime bDate,
|
||||
a.T_OrderSampleWorklistReceiveUserID, b.T_OrderSampleWorklistReceiveUserID bUser
|
||||
from t_ordersample a
|
||||
join t_ordersample b on a.T_OrderSampleT_OrderHeaderID = b.T_OrderSampleT_OrderHeaderID
|
||||
and a.T_OrderSampleBarcode like '%SK%' and b.T_OrderSampleBarcode like '%SP%' and b.T_OrderSampleWorklistReceive = 'Y'
|
||||
and a.T_OrderSampleIsActive = 'Y' and b.T_OrderSampleIsActive = 'Y'
|
||||
and a.T_OrderSampleT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql,array($headerID));
|
||||
if (! $qry) {
|
||||
echo "ERR : \n" ;
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
print_r($rows);
|
||||
}
|
||||
|
||||
function update_kuning($headerID) {
|
||||
$sql = "update t_ordersample a
|
||||
join t_ordersample b on a.T_OrderSampleT_OrderHeaderID = b.T_OrderSampleT_OrderHeaderID
|
||||
and a.T_OrderSampleBarcode like '%SK%' and b.T_OrderSampleBarcode like '%SP%' and b.T_OrderSampleWorklistReceive = 'Y'
|
||||
and a.T_OrderSampleIsActive = 'Y' and b.T_OrderSampleIsActive = 'Y'
|
||||
and a.T_OrderSampleT_OrderHeaderID = ?
|
||||
set
|
||||
a.T_OrderSampleWorklistReceive = b.T_OrderSampleWorklistReceive ,
|
||||
a.T_OrderSampleWorklistReceiveDatetime = b.T_OrderSampleWorklistReceiveDatetime ,
|
||||
a.T_OrderSampleWorklistReceiveUserID = b.T_OrderSampleWorklistReceiveUserID
|
||||
";
|
||||
$qry = $this->db->query($sql,array($headerID));
|
||||
if (! $qry) {
|
||||
echo "ERR : \n" ;
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
echo "Serum Kuning di update";
|
||||
}
|
||||
}
|
||||
706
application/controllers/fix/Check_result_v2.php
Normal file
706
application/controllers/fix/Check_result_v2.php
Normal file
@@ -0,0 +1,706 @@
|
||||
<?php
|
||||
|
||||
class Check_result_v2 extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo '<pre>';
|
||||
echo "cek [NomorLab]\n Untuk menampilkan sample dari T_OrderHeaderID yang terkait termasuk yg IsActive N\n\n";
|
||||
echo "fix_sample [NomorLab] [SampleTypeID] \n Untuk copy status worklist receive dari worklist receive sampletype yg sama yg paling akhir\n\n";
|
||||
echo "update_order_sample [T_OrderSampleID targetNya] [T_OrderSampleID sumbernya]\n Copy status T_OrderSample dari sumber ke target \n\n";
|
||||
}
|
||||
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table($rows, $keys)
|
||||
{
|
||||
$this->print_table_style();
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
public function fix_verif_valid($ids) {
|
||||
$arr_id = explode("-",$ids);
|
||||
$str_ids = implode(",",$arr_id);
|
||||
$sql = "update t_orderdetail set T_OrderDetailValidation ='N' where T_OrderDetailID in ($str_ids)";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
echo "Updated OK";
|
||||
}
|
||||
public function cek_valid($nolab) {
|
||||
$sql = "select T_OrderDetailID,T_OrderDetailT_TestName, T_OrderDetailVerification,
|
||||
T_OrderDetailValidation
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
on T_OrderHeaderLabNumber = ?
|
||||
and T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
and T_OrderDetailT_TestIsResult = 'Y'
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
where
|
||||
T_OrderDetailValidation = 'Y' and T_OrderDetailVerification <> 'Y'";
|
||||
$qry = $this->db->query($sql,[$nolab]);
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo $this->db->last_query();
|
||||
echo "No record";
|
||||
exit;
|
||||
}
|
||||
$this->print_table_style();
|
||||
$ids = "0";
|
||||
foreach($rows as $r) {
|
||||
$ids .= "-" . $r["T_OrderDetailID"];
|
||||
}
|
||||
$this->print_table($rows,array_keys($rows[0]));
|
||||
$url_fix = "/one-api/fix/check_result_v2/fix_verif_valid/$ids";
|
||||
echo "<br/><button onClick=\"document.location.href='$url_fix'\">Fix Verif Valid Race</button>";
|
||||
}
|
||||
|
||||
public function get_detail($r)
|
||||
{
|
||||
$result = "<tr>";
|
||||
$result .= "<td> </td>";
|
||||
$result .= "<td>Sample Handling</td>";
|
||||
$result .= "<td>" . $r["T_OrderSampleHandling"] . "</td>";
|
||||
$result .= "<td>" . $r["T_OrderSampleHandlingDate"];
|
||||
$result .= " " . $r["T_OrderSampleHandlingTime"] . "</td>";
|
||||
$result .= "<td>" . $r["T_OrderSampleHandlingUserID"] . "</td>";
|
||||
$result .= "<td colspan=3> </td>";
|
||||
$result .= "<tr>";
|
||||
return $result;
|
||||
}
|
||||
public function cek_result($labNo) {
|
||||
$sql = "select T_OrderDetailID, T_OrderDetailT_TestSasCode SasCode,
|
||||
T_OrderDetailT_TestName T_TestName,T_OrderDetailT_TestIsResult IsResult, T_OrderDetailIsActive IsActive,
|
||||
'' Action
|
||||
from t_orderdetail
|
||||
join t_orderheader on T_OrderHeaderLabNumber = '$labNo' and T_OrderDetailT_OrderHeaderID = T_OrderHeaderID";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "Err : " . $this->db->error()["message"] . "\n";
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $idx => $r) {
|
||||
if ($r["IsResult"] == "") {
|
||||
$fix_url = "<a href='/one-api/fix/check_result_v2/fix_is_result/" . $r["T_OrderDetailID"] . "/" . $labNo . "'>Fix IsResult to Y </a>";
|
||||
$rows[$idx]["Action"] = $fix_url;
|
||||
} else {
|
||||
$rows[$idx]["Action"] = " ";
|
||||
}
|
||||
}
|
||||
$this->print_table_style();
|
||||
echo "<H5> Detail $labNo Px </h5>";
|
||||
$this->print_table($rows,array_keys($rows[0]));
|
||||
|
||||
}
|
||||
public function fix_is_result($detailID,$labNo) {
|
||||
$sql = "update t_orderdetail set T_OrderDetailT_TestIsResult = 'Y' where T_OrderDetailID = ?";
|
||||
$qry = $this->db->query($sql,[$detailID]);
|
||||
if(!$qry) {
|
||||
echo "Err : " . $this->db->error()["message"] . "\n";
|
||||
exit;
|
||||
}
|
||||
header("Location: /one-api/fix/check_result_v2/cek_result/$labNo");
|
||||
}
|
||||
public function cek($labNo, $all = false)
|
||||
{
|
||||
$sql = "select *
|
||||
from t_ordersample
|
||||
join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID
|
||||
join t_orderheader on T_OrderHeaderID = T_OrderSampleT_OrderHeaderID
|
||||
where T_OrderSampleIsActive = 'Y' and T_OrderHeaderLabNumber=? order by T_OrderSampleID";
|
||||
if ($all) {
|
||||
$sql = 'select *
|
||||
from t_ordersample
|
||||
join t_orderheader on T_OrderHeaderID = T_OrderSampleT_OrderHeaderID
|
||||
left join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID
|
||||
where T_OrderHeaderLabNumber=? order by T_OrderSampleID';
|
||||
}
|
||||
$qry = $this->db->query($sql, [$labNo]);
|
||||
if (!$qry) {
|
||||
echo "ERR : \n";
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
echo '<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
';
|
||||
echo '<table>';
|
||||
echo '<tr>';
|
||||
echo "<td>T_OrderSampleID</td> <td>T_OrderSampleBarcode</td> <td>T_SampleTypeName</td> <td>T_SampleTypeID</td> <td>T_OrderSampleWorklistReceive</td> <td>Wl RcvDate</td> <td>Wl RcvTime</td> <td>IsActive</td><td> </td>
|
||||
</tr>\n";
|
||||
$lastWlReceive = "";
|
||||
$lastRecord = array();
|
||||
$flagOnlySingle = false;
|
||||
if (count($rows) == 1) {
|
||||
$flagOnlySingle = true;
|
||||
}
|
||||
$flagNoReceiveYet = true;
|
||||
foreach ($rows as $r) {
|
||||
if ($r["T_OrderSampleWorklistReceive"] == "Y") $flagNoReceiveYet = false;
|
||||
}
|
||||
|
||||
foreach ($rows as $r) {
|
||||
echo '<tr>';
|
||||
echo "<td>{$r['T_OrderSampleID']} </td> <td>{$r['T_OrderSampleBarcode']}</td> <td>{$r['T_SampleTypeName']}</td> <td>{$r['T_SampleTypeID']}</td> <td>{$r['T_OrderSampleWorklistReceive']}</td> <td>" .
|
||||
"{$r['T_OrderSampleWorklistReceiveDatetime']}</td> <td>{$r['T_OrderSampleWorklistReceiveUserID']}</td> <td>{$r['T_OrderSampleIsActive']}</td>";
|
||||
|
||||
if ($r['T_OrderSampleWorklistReceiveDatetime'] != '') {
|
||||
$url_target = '/one-api/fix/check_result_v2/fix_sample/' . $r['T_OrderHeaderLabNumber'] . '/' . $r['T_SampleTypeID'];
|
||||
echo '<td>';
|
||||
echo "<a type='button' target=\"_blank\" href=\"$url_target\"> Fix " . $r['T_SampleTypeName'] . ' lainnya </a>';
|
||||
echo '</td>';
|
||||
if ($lastWlReceive < $r["T_OrderSampleWorklistReceiveDatetime"]) {
|
||||
$lastWlReceive = $r["T_OrderSampleWorklistReceiveDatetime"];
|
||||
$lastRecord = $r;
|
||||
}
|
||||
} else {
|
||||
//echo '<td> </td>';
|
||||
if ($lastWlReceive == "") {
|
||||
if ((true || $flagOnlySingle) && $r["T_OrderSampleHandling"] == "Y") {
|
||||
$url_target = '/one-api/fix/check_result_v2/fix_from_sampling/' . $r['T_OrderSampleID'];
|
||||
echo '<td>';
|
||||
echo "<a type='button' target=\"_blank\" href=\"$url_target\"> Fix from samplingtime </a>";
|
||||
|
||||
echo "</td>";
|
||||
} else {
|
||||
echo "<td> </td>";
|
||||
}
|
||||
} else {
|
||||
$url_target = '/one-api/fix/check_result_v2/fix_sample_one/' . $r['T_OrderSampleID'] . '/' . $lastRecord['T_SampleTypeID'];
|
||||
echo '<td>';
|
||||
echo "<a type='button' target=\"_blank\" href=\"$url_target\"> Fix copy dari " . $lastRecord['T_SampleTypeName'] . ' </a>';
|
||||
echo "</td>";
|
||||
}
|
||||
}
|
||||
// $x_note = "<pre>" . print_r($r, true) . "</pre>";
|
||||
// echo "<td>$x_note</td>";
|
||||
echo '</tr>';
|
||||
$detail_info = $this->get_detail($r);
|
||||
echo $detail_info;
|
||||
}
|
||||
}
|
||||
|
||||
public function fix_from_sampling($targetID)
|
||||
{
|
||||
$sql = "update t_ordersample target
|
||||
join t_ordersample source on
|
||||
target.T_OrderSampleID = $targetID
|
||||
and target.T_OrderSampleWorklistReceive = 'N'
|
||||
and source.T_OrderSampleID = $targetID
|
||||
set
|
||||
|
||||
target.T_OrderSampleWorklistReceive = source.T_OrderSampleHandling,
|
||||
target.T_OrderSampleWorklistReceiveDatetime = source.T_OrderSampleHandlingTime,
|
||||
target.T_OrderSampleWorklistReceiveUserID = source.T_OrderSampleHandlingUserID
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderSampleT_OrderHeaderID, T_OrderSampleT_SampleTypeID
|
||||
from t_ordersample where T_OrderSampleID=?";
|
||||
$qry = $this->db->query($sql, array($targetID));
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo $this->db->last_query();
|
||||
echo "No record";
|
||||
exit;
|
||||
}
|
||||
$headerID = $rows[0]["T_OrderSampleT_OrderHeaderID"];
|
||||
$sampleTypeID = $targetID;
|
||||
$sql = "
|
||||
update t_orderdetailaddon
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailAddOnT_OrderDetailID = T_OrderDetailID
|
||||
and T_OrderDetailAddOnPreAnalytic <> 'Y'
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestT_SampleTypeID = ?
|
||||
set T_OrderDetailAddOnPreAnalytic = 'Y'
|
||||
, T_OrderDetailAddOnPreAnalyticDate=now()";
|
||||
$qry = $this->db->query($sql, array($headerID, $sampleTypeID));
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
echo 'update OK';
|
||||
}
|
||||
|
||||
public function confirm_fix_sample_one($targetID, $sourceID)
|
||||
{
|
||||
$target_ids = " $targetID ";
|
||||
$sql = "update t_ordersample target
|
||||
join t_ordersample source on
|
||||
target.T_OrderSampleID in ($target_ids)
|
||||
and target.T_OrderSampleWorklistReceive = 'N'
|
||||
and source.T_OrderSampleID = ?
|
||||
set
|
||||
target.T_OrderSampleSampling = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSampling, source.T_OrderSampleSampling),
|
||||
target.T_OrderSampleSamplingDate = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSamplingDate, source.T_OrderSampleSamplingDate),
|
||||
target.T_OrderSampleSamplingTime = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSamplingTime, source.T_OrderSampleSamplingTime),
|
||||
target.T_OrderSampleSamplingUserID = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSamplingUserID, source.T_OrderSampleSamplingUserID),
|
||||
|
||||
target.T_OrderSampleReceive = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceive, source.T_OrderSampleReceive),
|
||||
target.T_OrderSampleReceiveDate = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceiveDate, source.T_OrderSampleReceiveDate),
|
||||
target.T_OrderSampleReceiveTime = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceiveTime, source.T_OrderSampleReceiveTime),
|
||||
target.T_OrderSampleReceiveUserID = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceiveUserID, source.T_OrderSampleReceiveUserID),
|
||||
|
||||
target.T_OrderSampleVerification = if(target.T_OrderSampleVerification='Y',target.T_OrderSampleVerification, source.T_OrderSampleVerification),
|
||||
target.T_OrderSampleVerificationDate =if(target.T_OrderSampleVerification='Y',target.T_OrderSampleVerificationDate, source.T_OrderSampleVerificationDate),
|
||||
target.T_OrderSampleVerificationTime =if(source.T_OrderSampleVerification='Y',target.T_OrderSampleVerificationTime, source.T_OrderSampleVerificationTime),
|
||||
target.T_OrderSampleVerificationUserID =if(source.T_OrderSampleVerification='Y',target.T_OrderSampleVerificationUserID, source.T_OrderSampleVerificationUserID),
|
||||
|
||||
target.T_OrderSampleProcessing = if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessing, source.T_OrderSampleProcessing),
|
||||
target.T_OrderSampleProcessingDate= if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessingDate, source.T_OrderSampleProcessingDate),
|
||||
target.T_OrderSampleProcessingTime= if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessingTime, source.T_OrderSampleProcessingTime),
|
||||
target.T_OrderSampleProcessingUserID= if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessingUserID, source.T_OrderSampleProcessingUserID),
|
||||
|
||||
target.T_OrderSampleReceiveHandling =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandling, source.T_OrderSampleReceiveHandling ),
|
||||
target.T_OrderSampleReceiveHandlingDate =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandlingDate, source.T_OrderSampleReceiveHandlingDate),
|
||||
target.T_OrderSampleReceiveHandlingTime =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandlingTime, source.T_OrderSampleReceiveHandlingTime),
|
||||
target.T_OrderSampleReceiveHandlingUserID =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandlingUserID, source.T_OrderSampleReceiveHandlingUserID),
|
||||
|
||||
target.T_OrderSampleHandling = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandling, source.T_OrderSampleHandling),
|
||||
target.T_OrderSampleHandlingDate = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandlingDate, source.T_OrderSampleHandlingDate),
|
||||
target.T_OrderSampleHandlingTime = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandlingTime, source.T_OrderSampleHandlingTime),
|
||||
target.T_OrderSampleHandlingUserID = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandlingUserID, source.T_OrderSampleHandlingUserID),
|
||||
|
||||
target.T_OrderSampleWorklistReceive = source.T_OrderSampleWorklistReceive,
|
||||
target.T_OrderSampleWorklistReceiveDatetime = source.T_OrderSampleWorklistReceiveDateTime,
|
||||
target.T_OrderSampleWorklistReceiveUserID = source.T_OrderSampleWorklistReceiveUserID
|
||||
";
|
||||
$qry = $this->db->query($sql, [$sourceID]);
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderSampleT_OrderHeaderID, T_OrderSampleT_SampleTypeID
|
||||
from t_ordersample where T_OrderSampleID=?";
|
||||
$qry = $this->db->query($sql, array($sourceID));
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo $this->db->last_query();
|
||||
echo "No record";
|
||||
exit;
|
||||
}
|
||||
$headerID = $rows[0]["T_OrderSampleT_OrderHeaderID"];
|
||||
$sampleTypeID = $targetID;
|
||||
$sql = "
|
||||
update t_orderdetailaddon
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailAddOnT_OrderDetailID = T_OrderDetailID
|
||||
and T_OrderDetailAddOnPreAnalytic <> 'Y'
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestT_SampleTypeID = ?
|
||||
set T_OrderDetailAddOnPreAnalytic = 'Y'
|
||||
, T_OrderDetailAddOnPreAnalyticDate=now()";
|
||||
$qry = $this->db->query($sql, array($headerID, $sampleTypeID));
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
echo 'update OK';
|
||||
}
|
||||
|
||||
|
||||
public function confirm_fix_sample($labNo, $sampleTypeID, $sourceID)
|
||||
{
|
||||
$sql = "select *
|
||||
from t_ordersample
|
||||
join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID
|
||||
join t_orderheader on T_OrderHeaderID = T_OrderSampleT_OrderHeaderID
|
||||
where T_OrderSampleIsActive = 'Y'
|
||||
and T_OrderHeaderLabNumber=?
|
||||
and T_SampleTypeID = ?
|
||||
and T_OrderSampleWorklistReceive <> 'Y'
|
||||
and T_OrderSampleID <> ?
|
||||
";
|
||||
$qry = $this->db->query($sql, [$labNo, $sampleTypeID, $sourceID]);
|
||||
if (!$qry) {
|
||||
echo 'Error ' . $this->db->error()['message'] . ' | ' . $this->db->last_query();
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$target_ids = '0';
|
||||
foreach ($rows as $r) {
|
||||
$target_ids .= ',' . $r['T_OrderSampleID'];
|
||||
}
|
||||
$sql = "update t_ordersample target
|
||||
join t_ordersample source on
|
||||
target.T_OrderSampleID in ($target_ids)
|
||||
and target.T_OrderSampleWorklistReceive = 'N'
|
||||
and source.T_OrderSampleID = ?
|
||||
set
|
||||
target.T_OrderSampleSampling = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSampling, source.T_OrderSampleSampling),
|
||||
target.T_OrderSampleSamplingDate = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSamplingDate, source.T_OrderSampleSamplingDate),
|
||||
target.T_OrderSampleSamplingTime = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSamplingTime, source.T_OrderSampleSamplingTime),
|
||||
target.T_OrderSampleSamplingUserID = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSamplingUserID, source.T_OrderSampleSamplingUserID),
|
||||
|
||||
target.T_OrderSampleReceive = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceive, source.T_OrderSampleReceive),
|
||||
target.T_OrderSampleReceiveDate = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceiveDate, source.T_OrderSampleReceiveDate),
|
||||
target.T_OrderSampleReceiveTime = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceiveTime, source.T_OrderSampleReceiveTime),
|
||||
target.T_OrderSampleReceiveUserID = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceiveUserID, source.T_OrderSampleReceiveUserID),
|
||||
|
||||
target.T_OrderSampleVerification = if(target.T_OrderSampleVerification='Y',target.T_OrderSampleVerification, source.T_OrderSampleVerification),
|
||||
target.T_OrderSampleVerificationDate =if(target.T_OrderSampleVerification='Y',target.T_OrderSampleVerificationDate, source.T_OrderSampleVerificationDate),
|
||||
target.T_OrderSampleVerificationTime =if(source.T_OrderSampleVerification='Y',target.T_OrderSampleVerificationTime, source.T_OrderSampleVerificationTime),
|
||||
target.T_OrderSampleVerificationUserID =if(source.T_OrderSampleVerification='Y',target.T_OrderSampleVerificationUserID, source.T_OrderSampleVerificationUserID),
|
||||
|
||||
target.T_OrderSampleProcessing = if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessing, source.T_OrderSampleProcessing),
|
||||
target.T_OrderSampleProcessingDate= if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessingDate, source.T_OrderSampleProcessingDate),
|
||||
target.T_OrderSampleProcessingTime= if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessingTime, source.T_OrderSampleProcessingTime),
|
||||
target.T_OrderSampleProcessingUserID= if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessingUserID, source.T_OrderSampleProcessingUserID),
|
||||
|
||||
target.T_OrderSampleReceiveHandling =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandling, source.T_OrderSampleReceiveHandling ),
|
||||
target.T_OrderSampleReceiveHandlingDate =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandlingDate, source.T_OrderSampleReceiveHandlingDate),
|
||||
target.T_OrderSampleReceiveHandlingTime =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandlingTime, source.T_OrderSampleReceiveHandlingTime),
|
||||
target.T_OrderSampleReceiveHandlingUserID =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandlingUserID, source.T_OrderSampleReceiveHandlingUserID),
|
||||
|
||||
target.T_OrderSampleHandling = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandling, source.T_OrderSampleHandling),
|
||||
target.T_OrderSampleHandlingDate = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandlingDate, source.T_OrderSampleHandlingDate),
|
||||
target.T_OrderSampleHandlingTime = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandlingTime, source.T_OrderSampleHandlingTime),
|
||||
target.T_OrderSampleHandlingUserID = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandlingUserID, source.T_OrderSampleHandlingUserID),
|
||||
|
||||
target.T_OrderSampleWorklistReceive = source.T_OrderSampleWorklistReceive,
|
||||
target.T_OrderSampleWorklistReceiveDatetime = source.T_OrderSampleWorklistReceiveDateTime,
|
||||
target.T_OrderSampleWorklistReceiveUserID = source.T_OrderSampleWorklistReceiveUserID
|
||||
";
|
||||
$qry = $this->db->query($sql, [$sourceID]);
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select *
|
||||
from t_ordersample
|
||||
join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID
|
||||
join t_orderheader on T_OrderHeaderID = T_OrderSampleT_OrderHeaderID
|
||||
where T_OrderSampleIsActive = 'Y'
|
||||
and T_OrderHeaderLabNumber= ?
|
||||
and T_SampleTypeID = ?
|
||||
";
|
||||
$qry = $this->db->query($sql, [$labNo, $sampleTypeID]);
|
||||
if (!$qry) {
|
||||
echo 'Error ' . $this->db->error()['message'] . ' | ' . $this->db->last_query();
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$target_header_ids = "0";
|
||||
// echo "<pre>" . $this->db->last_query() . "</pre>";
|
||||
foreach ($rows as $r) {
|
||||
$target_header_ids .= ',' . $r['T_OrderSampleT_OrderHeaderID'];
|
||||
}
|
||||
|
||||
$sql = "
|
||||
update t_orderdetailaddon
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID in ( $target_header_ids )
|
||||
and T_OrderDetailAddOnT_OrderDetailID = T_OrderDetailID
|
||||
and T_OrderDetailAddOnPreAnalytic <> 'Y'
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestT_SampleTypeID = ?
|
||||
set T_OrderDetailAddOnPreAnalytic = 'Y'
|
||||
, T_OrderDetailAddOnPreAnalyticDate=now()";
|
||||
$qry = $this->db->query($sql, array($sampleTypeID));
|
||||
// echo "<pre>" . $this->db->last_query() . "</pre>";
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo 'update OK';
|
||||
}
|
||||
|
||||
public function fix_sample_one($targetID, $sampleTypeID)
|
||||
{
|
||||
//get worklist receive terakhir
|
||||
//one target
|
||||
$sql = "select *
|
||||
from t_ordersample
|
||||
join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID
|
||||
join t_orderheader on T_OrderHeaderID = T_OrderSampleT_OrderHeaderID
|
||||
where T_OrderSampleIsActive = 'Y'
|
||||
and T_OrderSampleID = ?
|
||||
order by T_OrderSampleWorklistReceiveDatetime desc
|
||||
limit 0,1";
|
||||
|
||||
$qry = $this->db->query($sql, [$targetID]);
|
||||
if (!$qry) {
|
||||
echo 'Error : ' . $this->db->error()['message'] . ' | ' . $this->db->last_query();
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "Target Sample tidak ketemu : $targetID";
|
||||
exit;
|
||||
}
|
||||
$labNo = $rows[0]["T_OrderHeaderLabNumber"];
|
||||
$targetSampleType = $rows[0]["T_SampleTypeName"];
|
||||
|
||||
$sql = "select *
|
||||
from t_ordersample
|
||||
join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID
|
||||
join t_orderheader on T_OrderHeaderID = T_OrderSampleT_OrderHeaderID
|
||||
where T_OrderSampleIsActive = 'Y'
|
||||
and T_OrderHeaderLabNumber=?
|
||||
and T_SampleTypeID = ?
|
||||
and T_OrderSampleWorklistReceive = 'Y'
|
||||
order by T_OrderSampleWorklistReceiveDatetime desc
|
||||
limit 0,1";
|
||||
$qry = $this->db->query($sql, [$labNo, $sampleTypeID]);
|
||||
if (!$qry) {
|
||||
echo 'Error : ' . $this->db->error()['message'] . ' | ' . $this->db->last_query();
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "Belum ada worklist receive utk sample type id $sampleTypeID";
|
||||
exit;
|
||||
}
|
||||
$r = $rows[0];
|
||||
$sourceID = $r['T_OrderSampleID'];
|
||||
echo '<pre>';
|
||||
echo "Update Status utk sample {$targetSampleType} - {$labNo}: \n";
|
||||
echo "dari : " . $r["T_SampleTypeName"] . "\n";
|
||||
echo "Worklist Receive : {$r['T_OrderSampleWorklistReceiveDatetime']}\n";
|
||||
echo '</pre>';
|
||||
|
||||
echo "<button onClick=\"location.href='/one-api/fix/check_result_v2/confirm_fix_sample_one/$targetID/$sourceID'\">Confirm</button>";
|
||||
}
|
||||
|
||||
public function fix_sample($labNo, $sampleTypeID)
|
||||
{
|
||||
//get worklist receive terakhir
|
||||
$sql = "select *
|
||||
from t_ordersample
|
||||
join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID
|
||||
join t_orderheader on T_OrderHeaderID = T_OrderSampleT_OrderHeaderID
|
||||
where T_OrderSampleIsActive = 'Y'
|
||||
and T_OrderHeaderLabNumber=?
|
||||
and T_SampleTypeID = ?
|
||||
and T_OrderSampleWorklistReceive = 'Y'
|
||||
order by T_OrderSampleWorklistReceiveDatetime desc
|
||||
limit 0,1";
|
||||
$qry = $this->db->query($sql, [$labNo, $sampleTypeID]);
|
||||
if (!$qry) {
|
||||
echo 'Error : ' . $this->db->error()['message'] . ' | ' . $this->db->last_query();
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "Belum ada worklist receive utk sample type id $sampleTypeID";
|
||||
exit;
|
||||
}
|
||||
$r = $rows[0];
|
||||
$sourceID = $r['T_OrderSampleID'];
|
||||
echo '<pre>';
|
||||
echo "Update Status utk sample {$r['T_SampleTypeName']} - {$labNo}: \n";
|
||||
echo "Worklist Receive : {$r['T_OrderSampleWorklistReceiveDatetime']}\n";
|
||||
echo '</pre>';
|
||||
|
||||
echo "<button onClick=\"location.href='/one-api/fix/check_result_v2/confirm_fix_sample/$labNo/$sampleTypeID/$sourceID'\">Confirm</button>";
|
||||
}
|
||||
|
||||
public function update_order_sample($targetID, $sourceID)
|
||||
{
|
||||
$sql = "update t_ordersample target
|
||||
join t_ordersample source on
|
||||
target.T_OrderSampleID = ?
|
||||
and target.T_OrderSampleWorklistReceive = 'N'
|
||||
and source.T_OrderSampleID = ?
|
||||
set
|
||||
target.T_OrderSampleSampling = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSampling, source.T_OrderSampleSampling),
|
||||
target.T_OrderSampleSamplingDate = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSamplingDate, source.T_OrderSampleSamplingDate),
|
||||
target.T_OrderSampleSamplingTime = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSamplingTime, source.T_OrderSampleSamplingTime),
|
||||
target.T_OrderSampleSamplingUserID = if(target.T_OrderSampleSampling='Y',target.T_OrderSampleSamplingUserID, source.T_OrderSampleSamplingUserID),
|
||||
|
||||
target.T_OrderSampleReceive = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceive, source.T_OrderSampleReceive),
|
||||
target.T_OrderSampleReceiveDate = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceiveDate, source.T_OrderSampleReceiveDate),
|
||||
target.T_OrderSampleReceiveTime = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceiveTime, source.T_OrderSampleReceiveTime),
|
||||
target.T_OrderSampleReceiveUserID = if(target.T_OrderSampleReceive='Y',target.T_OrderSampleReceiveUserID, source.T_OrderSampleReceiveUserID),
|
||||
|
||||
target.T_OrderSampleVerification = if(target.T_OrderSampleVerification='Y',target.T_OrderSampleVerification, source.T_OrderSampleVerification),
|
||||
target.T_OrderSampleVerificationDate =if(target.T_OrderSampleVerification='Y',target.T_OrderSampleVerificationDate, source.T_OrderSampleVerificationDate),
|
||||
target.T_OrderSampleVerificationTime =if(source.T_OrderSampleVerification='Y',target.T_OrderSampleVerificationTime, source.T_OrderSampleVerificationTime),
|
||||
target.T_OrderSampleVerificationUserID =if(source.T_OrderSampleVerification='Y',target.T_OrderSampleVerificationUserID, source.T_OrderSampleVerificationUserID),
|
||||
|
||||
target.T_OrderSampleProcessing = if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessing, source.T_OrderSampleProcessing),
|
||||
target.T_OrderSampleProcessingDate= if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessingDate, source.T_OrderSampleProcessingDate),
|
||||
target.T_OrderSampleProcessingTime= if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessingTime, source.T_OrderSampleProcessingTime),
|
||||
target.T_OrderSampleProcessingUserID= if(target.T_OrderSampleProcessing='Y',target.T_OrderSampleProcessingUserID, source.T_OrderSampleProcessingUserID),
|
||||
|
||||
target.T_OrderSampleReceiveHandling =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandling, source.T_OrderSampleReceiveHandling ),
|
||||
target.T_OrderSampleReceiveHandlingDate =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandlingDate, source.T_OrderSampleReceiveHandlingDate),
|
||||
target.T_OrderSampleReceiveHandlingTime =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandlingTime, source.T_OrderSampleReceiveHandlingTime),
|
||||
target.T_OrderSampleReceiveHandlingUserID =if(target.T_OrderSampleReceiveHandling='Y',target.T_OrderSampleReceiveHandlingUserID, source.T_OrderSampleReceiveHandlingUserID),
|
||||
|
||||
target.T_OrderSampleHandling = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandling, source.T_OrderSampleHandling),
|
||||
target.T_OrderSampleHandlingDate = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandlingDate, source.T_OrderSampleHandlingDate),
|
||||
target.T_OrderSampleHandlingTime = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandlingTime, source.T_OrderSampleHandlingTime),
|
||||
target.T_OrderSampleHandlingUserID = if(target.T_OrderSampleHandling='Y',target.T_OrderSampleHandlingUserID, source.T_OrderSampleHandlingUserID),
|
||||
|
||||
target.T_OrderSampleWorklistReceive = source.T_OrderSampleWorklistReceive,
|
||||
target.T_OrderSampleWorklistReceiveDatetime = source.T_OrderSampleWorklistReceiveDateTime,
|
||||
target.T_OrderSampleWorklistReceiveUserID = source.T_OrderSampleWorklistReceiveUserID
|
||||
";
|
||||
$qry = $this->db->query($sql, [$targetID, $sourceID]);
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function id($order)
|
||||
{
|
||||
echo '<pre>';
|
||||
$sql = 'select t_orderheader.* from t_orderheader join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
where T_OrderHeaderLabNumber like ? or T_OrderHeaderAddonLabNumberOrigin like ?';
|
||||
$qry = $this->db->query($sql, ['%' . $order . '%', "%{$order}%"]);
|
||||
if (!$qry) {
|
||||
echo "ERR : \n";
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $r) {
|
||||
echo "{$r['T_OrderHeaderID']}\t{$r['T_OrderHeaderDate']}\t{$r['T_OrderHeaderLabNumber']}\n";
|
||||
}
|
||||
}
|
||||
|
||||
public function preanalytic($headerID)
|
||||
{
|
||||
$sql = "select *
|
||||
from t_orderdetailaddon
|
||||
join t_orderdetail on T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailAddOnIsActive = 'Y' and T_OrderDetailT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, [$headerID]);
|
||||
if (!$qry) {
|
||||
echo "ERR : \n";
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
echo "<pre>";
|
||||
$rows = $qry->result_array();
|
||||
echo "T_OrderDetailID\tT_OrderDetailT_TestName\tT_OrderDetailAddOnPreAnalytic\tT_OrderDetailAddOnPreAnalyticDate\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "{$r['T_OrderDetailID']}\t{$r['T_OrderDetailT_TestName']}\t{$r['T_OrderDetailAddOnPreAnalytic']}\t{$r['T_OrderDetailAddOnPreAnalyticDate']}\n";
|
||||
}
|
||||
}
|
||||
|
||||
public function pre_copy_from_to($fromID, $toID)
|
||||
{
|
||||
$sql = 'update
|
||||
t_orderdetailaddon a
|
||||
join t_orderdetailaddon b on a.T_OrderDetailAddOnT_OrderDetailID = ?
|
||||
and b.T_OrderDetailAddOnT_OrderDetailID = ?
|
||||
set b.T_OrderDetailAddOnPreAnalytic = a.T_OrderDetailAddOnPreAnalytic ,
|
||||
b.T_OrderDetailAddOnPreAnalyticDate = a.T_OrderDetailAddOnPreAnalyticDate
|
||||
';
|
||||
$qry = $this->db->query($sql, [$fromID, $toID]);
|
||||
echo $this->db->last_query() . "\n";
|
||||
if (!$qry) {
|
||||
echo "ERR : \n";
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
echo 'Pre Analytic Update';
|
||||
}
|
||||
|
||||
public function cek_kuning($headerID)
|
||||
{
|
||||
$sql = "select a.T_OrderSampleWorklistReceive , b.T_OrderSampleWorklistReceive bRcv,
|
||||
a.T_OrderSampleWorklistReceiveDatetime, b.T_OrderSampleWorklistReceiveDatetime bDate,
|
||||
a.T_OrderSampleWorklistReceiveUserID, b.T_OrderSampleWorklistReceiveUserID bUser
|
||||
from t_ordersample a
|
||||
join t_ordersample b on a.T_OrderSampleT_OrderHeaderID = b.T_OrderSampleT_OrderHeaderID
|
||||
and a.T_OrderSampleBarcode like '%SK%' and b.T_OrderSampleBarcode like '%SP%' and b.T_OrderSampleWorklistReceive = 'Y'
|
||||
and a.T_OrderSampleIsActive = 'Y' and b.T_OrderSampleIsActive = 'Y'
|
||||
and a.T_OrderSampleT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, [$headerID]);
|
||||
if (!$qry) {
|
||||
echo "ERR : \n";
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
print_r($rows);
|
||||
}
|
||||
|
||||
public function update_kuning($headerID)
|
||||
{
|
||||
$sql = "update t_ordersample a
|
||||
join t_ordersample b on a.T_OrderSampleT_OrderHeaderID = b.T_OrderSampleT_OrderHeaderID
|
||||
and a.T_OrderSampleBarcode like '%SK%' and b.T_OrderSampleBarcode like '%SP%' and b.T_OrderSampleWorklistReceive = 'Y'
|
||||
and a.T_OrderSampleIsActive = 'Y' and b.T_OrderSampleIsActive = 'Y'
|
||||
and a.T_OrderSampleT_OrderHeaderID = ?
|
||||
set
|
||||
a.T_OrderSampleWorklistReceive = b.T_OrderSampleWorklistReceive ,
|
||||
a.T_OrderSampleWorklistReceiveDatetime = b.T_OrderSampleWorklistReceiveDatetime ,
|
||||
a.T_OrderSampleWorklistReceiveUserID = b.T_OrderSampleWorklistReceiveUserID
|
||||
";
|
||||
$qry = $this->db->query($sql, [$headerID]);
|
||||
if (!$qry) {
|
||||
echo "ERR : \n";
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
echo 'Serum Kuning di update';
|
||||
}
|
||||
}
|
||||
1624
application/controllers/fix/E_result.php
Normal file
1624
application/controllers/fix/E_result.php
Normal file
File diff suppressed because it is too large
Load Diff
887
application/controllers/fix/Fix_future.php
Normal file
887
application/controllers/fix/Fix_future.php
Normal file
@@ -0,0 +1,887 @@
|
||||
<?php
|
||||
|
||||
class Fix_future extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->PJ_DOCTOR_ID = 0;
|
||||
$this->SENDER_DOCTOR_ID = 0;
|
||||
$this->SENDER_ADDRESS_ID = 0;
|
||||
$this->ONLINE_USER_ID = 1500;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Fixing snapshot ss_piutang_test";
|
||||
}
|
||||
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 [false, $msg];
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
return [true, $rows];
|
||||
}
|
||||
function get_one_row($sql, $prm)
|
||||
{
|
||||
list($status, $msg) = $this->get_rows($sql, $prm);
|
||||
if ($status !== true) {
|
||||
return [$status, $msg];
|
||||
}
|
||||
if (count($msg) == 0) {
|
||||
return [false, "Record not found. | " . $msg];
|
||||
}
|
||||
return [true, $msg[0]];
|
||||
}
|
||||
|
||||
function now()
|
||||
{
|
||||
return Date("Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
public function fix($futureNo)
|
||||
{
|
||||
$sql = "select FutureOrderID,
|
||||
FutureOrderNumber, FutureOrderDateBooking, FutureOrderIsActive,
|
||||
JSON_EXTRACT( fn_get_patient_atribute(FutureOrderM_PatientID) , '$.patient_fullname' )
|
||||
PatientName,
|
||||
JSON_EXTRACT( fn_get_patient_atribute(FutureOrderM_PatientID) , '$.M_PatientHP' )
|
||||
PatientHP,
|
||||
ifnull(T_OrderHeaderLabNumber,'Pending') LabNumber ,
|
||||
if(FutureOrderDateBooking > date(now()), 'Y', 'N') inFuture,
|
||||
if(FutureMapT_OrderHeaderID is not null, 'Y', 'N') isMapped
|
||||
from future_order
|
||||
left join future_map on FutureOrderID = FutureMapFutureOrderID
|
||||
left join t_orderheader on FutureMapT_OrderHeaderID = T_OrderHeaderID
|
||||
where FutureOrderNumber = ?
|
||||
";
|
||||
list($status, $row) = $this->get_one_row($sql, [$futureNo]);
|
||||
if ($status === false) {
|
||||
echo "ERR get Future Order: $row";
|
||||
exit();
|
||||
}
|
||||
$this->print_table([$row], array_keys($row));
|
||||
if ($row["inFuture"] == "Y") {
|
||||
echo "<h4> Booking masa depan </h4>";
|
||||
exit();
|
||||
}
|
||||
if ($row["FutureOrderIsActive"] == "N") {
|
||||
echo "<h4> Booking dihapus </h4>";
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($row["isMapped"] == "Y") {
|
||||
echo "<h4> Sudah Tercreate ORDER {$row["LabNumber"]} </h4>";
|
||||
exit();
|
||||
}
|
||||
|
||||
$url_fix =
|
||||
"/one-api/fix/fix_future/do_fix/" .
|
||||
$row["FutureOrderID"] .
|
||||
"/" .
|
||||
md5($row["FutureOrderNumber"]);
|
||||
echo "<div>
|
||||
<button onClick=\"document.location.href='{$url_fix}'\"
|
||||
style='padding:5px; color:white; border: solid 0px; border-radius: 5px;
|
||||
background-color:blue; margin-top:20px; display:block;' >Generate Order</button> </div>\n";
|
||||
}
|
||||
|
||||
function do_fix($futureOrderID, $md5Future)
|
||||
{
|
||||
$sql = "select FutureOrderNumber,
|
||||
if(FutureOrderDateBooking > date(now()) , 'Y' , 'N') inFuture,
|
||||
if(FutureMapID is not null,'Y','N') isMapped,
|
||||
FutureMapT_OrderHeaderID
|
||||
from
|
||||
future_order
|
||||
left join future_map on FutureOrderID = FutureMapFutureOrderID and FutureMapIsActive ='Y'
|
||||
where FutureOrderID = ?
|
||||
and FutureOrderIsActive = 'Y' ";
|
||||
list($status, $msg) = $this->get_one_row($sql, [$futureOrderID]);
|
||||
if ($status === false) {
|
||||
echo $msg;
|
||||
exit();
|
||||
}
|
||||
$row = $msg;
|
||||
$futureOrderNumber = $row["FutureOrderNumber"];
|
||||
if (md5($row["FutureOrderNumber"]) != $md5Future) {
|
||||
echo "Invalid Redirect Link";
|
||||
exit();
|
||||
}
|
||||
if ($row["inFuture"] == "Y") {
|
||||
echo "Booking Masa depan > hari ini";
|
||||
exit();
|
||||
}
|
||||
if ($row["inMapped"] == "Y") {
|
||||
echo "Booking sudah ada";
|
||||
exit();
|
||||
}
|
||||
|
||||
ob_start();
|
||||
echo "<H5>Generate Order</H5>";
|
||||
$this->generate_order($futureOrderID);
|
||||
$result = ob_get_contents();
|
||||
ob_end_clean();
|
||||
echo "<div style='padding:10px; border-radius:10px; border:solid 1px #383838'>
|
||||
<pre>$result</pre>
|
||||
</div>";
|
||||
|
||||
$url_fix = "/one-ui/test/vuex/one-fo-cashier-new-payment-v4/";
|
||||
|
||||
echo "<div>
|
||||
<button onClick=\"document.location.href='{$url_fix}'\"
|
||||
style='padding:5px; color:white; border: solid 0px; border-radius: 5px;
|
||||
background-color:blue; margin-top:20px; display:block;' >Kasir</button> </div>\n";
|
||||
}
|
||||
|
||||
|
||||
public function fix_debug($futureNo)
|
||||
{
|
||||
$sql = "select FutureOrderID,
|
||||
FutureOrderNumber, FutureOrderDateBooking, FutureOrderIsActive,
|
||||
JSON_EXTRACT( fn_get_patient_atribute(FutureOrderM_PatientID) , '$.patient_fullname' )
|
||||
PatientName,
|
||||
JSON_EXTRACT( fn_get_patient_atribute(FutureOrderM_PatientID) , '$.M_PatientHP' )
|
||||
PatientHP,
|
||||
ifnull(T_OrderHeaderLabNumber,'Pending') LabNumber ,
|
||||
if(FutureOrderDateBooking > date(now()), 'Y', 'N') inFuture,
|
||||
if(FutureMapT_OrderHeaderID is not null, 'Y', 'N') isMapped
|
||||
from future_order
|
||||
left join future_map on FutureOrderID = FutureMapFutureOrderID
|
||||
left join t_orderheader on FutureMapT_OrderHeaderID = T_OrderHeaderID
|
||||
where FutureOrderNumber = ?
|
||||
";
|
||||
list($status, $row) = $this->get_one_row($sql, [$futureNo]);
|
||||
if ($status === false) {
|
||||
echo "ERR get Future Order: $row";
|
||||
exit();
|
||||
}
|
||||
$this->print_table([$row], array_keys($row));
|
||||
if ($row["inFuture"] == "Y") {
|
||||
echo "<h4> Booking masa depan </h4>";
|
||||
exit();
|
||||
}
|
||||
if ($row["FutureOrderIsActive"] == "N") {
|
||||
echo "<h4> Booking dihapus </h4>";
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($row["isMapped"] == "Y") {
|
||||
echo "<h4> Sudah Tercreate ORDER {$row["LabNumber"]} </h4>";
|
||||
exit();
|
||||
}
|
||||
|
||||
$url_fix =
|
||||
"/one-api/fix/fix_future/do_fix_debug/" .
|
||||
$row["FutureOrderID"] .
|
||||
"/" .
|
||||
md5($row["FutureOrderNumber"]);
|
||||
echo "<div>
|
||||
<button onClick=\"document.location.href='{$url_fix}'\"
|
||||
style='padding:5px; color:white; border: solid 0px; border-radius: 5px;
|
||||
background-color:blue; margin-top:20px; display:block;' >Generate Order</button> </div>\n";
|
||||
}
|
||||
|
||||
function do_fix_debug($futureOrderID, $md5Future)
|
||||
{
|
||||
$sql = "select FutureOrderNumber,
|
||||
if(FutureOrderDateBooking > date(now()) , 'Y' , 'N') inFuture,
|
||||
if(FutureMapID is not null,'Y','N') isMapped,
|
||||
FutureMapT_OrderHeaderID
|
||||
from
|
||||
future_order
|
||||
left join future_map on FutureOrderID = FutureMapFutureOrderID and FutureMapIsActive ='Y'
|
||||
where FutureOrderID = ?
|
||||
and FutureOrderIsActive = 'Y' ";
|
||||
list($status, $msg) = $this->get_one_row($sql, [$futureOrderID]);
|
||||
if ($status === false) {
|
||||
echo $msg;
|
||||
exit();
|
||||
}
|
||||
$row = $msg;
|
||||
$futureOrderNumber = $row["FutureOrderNumber"];
|
||||
if (md5($row["FutureOrderNumber"]) != $md5Future) {
|
||||
echo "Invalid Redirect Link";
|
||||
exit();
|
||||
}
|
||||
if ($row["inFuture"] == "Y") {
|
||||
echo "Booking Masa depan > hari ini";
|
||||
exit();
|
||||
}
|
||||
if ($row["inMapped"] == "Y") {
|
||||
echo "Booking sudah ada";
|
||||
exit();
|
||||
}
|
||||
|
||||
ob_start();
|
||||
echo "<H5>Generate Order</H5>";
|
||||
$this->generate_order_debug($futureOrderID);
|
||||
$result = ob_get_contents();
|
||||
ob_end_clean();
|
||||
echo "<div style='padding:10px; border-radius:10px; border:solid 1px #383838'>
|
||||
<pre>$result</pre>
|
||||
</div>";
|
||||
|
||||
$url_fix = "/one-ui/test/vuex/one-fo-cashier-new-payment-v4/";
|
||||
|
||||
echo "<div>
|
||||
<button onClick=\"document.location.href='{$url_fix}'\"
|
||||
style='padding:5px; color:white; border: solid 0px; border-radius: 5px;
|
||||
background-color:blue; margin-top:20px; display:block;' >Kasir</button> </div>\n";
|
||||
}
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
|
||||
public function print_table($rows, $keys)
|
||||
{
|
||||
$this->print_table_style();
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
public function get_branch_default()
|
||||
{
|
||||
$sql =
|
||||
"select * from m_branch where M_BranchIsDefault = 'Y' and M_BranchIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "{$this->now()} ERR : {$this->db->error()["message"]}\n";
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "{$this->now()} ERR Get Default Branch: {$this->db->error()["message"]}\n";
|
||||
exit();
|
||||
}
|
||||
$branchKelurahanID = $rows[0]["M_BranchM_KelurahanID"];
|
||||
$this->SENDER_DOCTOR_ID = $rows[0]["M_BranchM_DoctorID"];
|
||||
$this->SENDER_ADDRESS_ID = $rows[0]["M_BranchM_DoctorAddressID"];
|
||||
|
||||
$sql =
|
||||
"select * from m_doctorpj where M_DoctorPjIsActive = 'Y' and M_DoctorPjIsDefaultPJ='Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "{$this->now()} ERR : {$this->db->error()["message"]}\n";
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "{$this->now()} ERR Get Default PJ: {$this->db->error()["message"]}\n";
|
||||
exit();
|
||||
}
|
||||
$this->PJ_DOCTOR_ID = $rows[0]["M_DoctorPjM_DoctorID"];
|
||||
|
||||
return [$branchKelurahanID];
|
||||
}
|
||||
|
||||
public function do_pelunasan(
|
||||
$headerID,
|
||||
$bankAccountID,
|
||||
$paymentTypeID,
|
||||
$paymentNote,
|
||||
$amount
|
||||
) {
|
||||
$paymentTotal = $amount;
|
||||
$paymentDate = date("Y-m-d H:i:s");
|
||||
$arr = [
|
||||
"F_PaymentT_OrderHeaderID" => $headerID,
|
||||
"F_PaymentDate" => $paymentDate,
|
||||
"F_PaymentNote" => $paymentNote,
|
||||
"F_PaymentTotal" => $paymentTotal,
|
||||
"F_PaymentM_UserID" => $this->ONLINE_USER_ID,
|
||||
];
|
||||
$qry = $this->db->insert("f_payment", $arr);
|
||||
if (!$qry) {
|
||||
echo "{$this->now()} ERR Get Total Order: {$this->db->error()["message"]} | {$this->db->last_query()}\n";
|
||||
return false;
|
||||
}
|
||||
$paymentID = $this->db->insert_id();
|
||||
$detailNote = "";
|
||||
|
||||
$arr = [
|
||||
"F_PaymentDetailF_PaymentID" => $paymentID,
|
||||
"F_PaymentDetailM_PaymentTypeID" => $paymentTypeID,
|
||||
"F_PaymentDetailEDCNat_BankID" => 0,
|
||||
"F_PaymentDetailCardNat_BankID" => 0,
|
||||
"F_PaymentDetailM_BankAccountID" => $bankAccountID,
|
||||
"F_PaymentDetailNote" => $paymentNote,
|
||||
"F_PaymentDetailAmount" => $paymentTotal,
|
||||
"F_PaymentDetailActual" => $paymentTotal,
|
||||
"F_PaymentDetailChange" => 0,
|
||||
];
|
||||
$qry = $this->db->insert("f_paymentdetail", $arr);
|
||||
if (!$qry) {
|
||||
echo "{$this->now()} ERR Pelunasan: {$this->db->error()["message"]} | {$this->db->last_query()}\n";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function add_delivery_note($orderHeaderID, $delivery_note)
|
||||
{
|
||||
$rst_id = $orderHeaderID;
|
||||
$db_msg = "";
|
||||
foreach ($delivery_note as $k => $v) {
|
||||
if ($v["noteplus"] != "") {
|
||||
if (
|
||||
$v["delivery_code"] == "EMAIL" ||
|
||||
$v["delivery_code"] == "WHATSAPP" ||
|
||||
$v["delivery_code"] == "TELEGRAM"
|
||||
) {
|
||||
$sql = "UPDATE t_orderdelivery SET T_OrderDeliveryDestination = '{$v["noteplus"]}'
|
||||
WHERE
|
||||
T_OrderDeliveryT_OrderHeaderID = {$rst_id} AND
|
||||
T_OrderDeliveryM_DeliveryID = {$v["delivery_id"]} AND
|
||||
T_OrderDeliveryM_DeliveryTypeID = {$v["delivery_type_id"]} AND
|
||||
T_OrderDeliveryAddressID = {$v["address_id"]} AND
|
||||
T_OrderDeliveryIsActive = 'Y'";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if (!$qry) {
|
||||
$db_msg .=
|
||||
"ERR : Update T_orderDelivery " .
|
||||
$this->db->error()["message"] .
|
||||
" | " .
|
||||
$$this->db->last_query();
|
||||
$db_msg .= "\n";
|
||||
}
|
||||
} else {
|
||||
$sql = "SELECT T_OrderDeliveryID as xdel_id
|
||||
FROM t_orderdelivery
|
||||
WHERE
|
||||
T_OrderDeliveryT_OrderHeaderID = {$rst_id} AND
|
||||
T_OrderDeliveryM_DeliveryID = {$v["delivery_id"]} AND
|
||||
T_OrderDeliveryM_DeliveryTypeID = {$v["delivery_type_id"]} AND
|
||||
T_OrderDeliveryAddressID = {$v["address_id"]} AND
|
||||
T_OrderDeliveryIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if (!$qry) {
|
||||
$db_msg .=
|
||||
"ERR : Get T_orderDelivery for XDel " .
|
||||
$this->db->error()["message"] .
|
||||
" | " .
|
||||
$$this->db->last_query();
|
||||
$db_msg .= "\n";
|
||||
}
|
||||
$xdel_id = $qry->row()->xdel_id;
|
||||
|
||||
$sql = "INSERT INTO t_orderdeliverynote(
|
||||
T_OrderDeliveryNoteT_OrderDeliveryID,
|
||||
T_OrderDeliveryNoteValue,
|
||||
T_OrderDeliveryNoteCreated,
|
||||
T_OrderDeliveryNoteUserID
|
||||
)
|
||||
VALUES(
|
||||
{$xdel_id},
|
||||
'{$v["noteplus"]}',
|
||||
NOW(),
|
||||
{$this->sys_user["M_UserID"]}
|
||||
)";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if (!$qry) {
|
||||
$db_msg .=
|
||||
"ERR : Update T_orderDelivery " .
|
||||
$this->db->error()["message"] .
|
||||
" | " .
|
||||
$$this->db->last_query();
|
||||
$db_msg .= "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $db_msg;
|
||||
}
|
||||
|
||||
public function generate_order_debug($futureOrderID)
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
$this->get_branch_default();
|
||||
|
||||
$sql = "select future_order.*,
|
||||
if(FutureMapIsActive is null , 'N', 'Y') isMapped
|
||||
from future_order
|
||||
left join future_map
|
||||
on FutureOrderID = FutureMapFutureOrderID
|
||||
where FutureOrderID = ?
|
||||
";
|
||||
$qry = $this->db->query($sql, [$futureOrderID]);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err GetFutureOrder {$this->db->error()["message"]} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err GetFutureOrder not found | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
if ($rows[0]["isMapped"] == "Y") {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Order sudah di future_map | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$futureOrder = $rows[0];
|
||||
echo "{$this->now()} Create Order from {$futureOrder["FutureOrderNumber"]} \n";
|
||||
$x_header = ($futureOrder["FutureOrderJSONHeader"]);
|
||||
echo "$x_header\n";
|
||||
$x_header = preg_replace('/[[:^print:]]/', '', $x_header);
|
||||
$header = json_decode($x_header,true);
|
||||
echo "HEADER : ". $x_header;
|
||||
echo "JSON LAST ERR : " . json_last_error_msg() . "\n";
|
||||
print_r($header);
|
||||
echo "<br/><br/>";
|
||||
$header["date"] = date("Y-m-d H:i:s");
|
||||
echo "New Header: " ;
|
||||
print_r($header);
|
||||
$t_header = json_encode($header);
|
||||
echo "XXX Header : $t_header | " . json_last_error_msg();
|
||||
echo "<br/><br/>";
|
||||
|
||||
|
||||
$x_delivery = $futureOrder["FutureOrderJSONDelivery"];
|
||||
$x_delivery = str_replace("\n","",$x_delivery);
|
||||
|
||||
$delivery = json_decode($x_delivery, true);
|
||||
echo "Raw Delivery :<br/> $x_delivery <br/>";
|
||||
echo "Decode Delivery Json : " . json_last_error_msg() . "<br/>";
|
||||
|
||||
$delivery_note = json_decode(
|
||||
$futureOrder["FutureOrderJSONDeliveryNote"],
|
||||
true
|
||||
);
|
||||
$req = json_decode($futureOrder["FutureOrderJSONReq"], true);
|
||||
$detail = json_decode($futureOrder["FutureOrderJSONDetail"], true);
|
||||
$header_json = addslashes(
|
||||
str_replace('\n', '\\\n', json_encode($header))
|
||||
);
|
||||
$detail_json = str_replace('\n', '\\\n', json_encode($detail));
|
||||
$delivery_json = addslashes(
|
||||
str_replace('\n', '\\\n', json_encode($delivery))
|
||||
);
|
||||
|
||||
echo "<br/>";
|
||||
echo "Delivery String:<br/> ";
|
||||
echo $delivery;
|
||||
echo "<br/>";
|
||||
$req_json = json_encode($req);
|
||||
echo "<br/>";
|
||||
print_r($header_json);
|
||||
echo "<br/>";
|
||||
print_r($detail_json);
|
||||
echo "<br/>";
|
||||
echo "Delivery JSON:";
|
||||
print_r($delivery_json);
|
||||
|
||||
$sql = "CALL sp_fo_register_save_online_debug(0, '{$header_json}', '{$delivery_json}',
|
||||
'{$detail_json}', '{$req_json}', '3');";
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Create Order : {$this->db->error()["message"]} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
|
||||
$this->db->trans_rollback();
|
||||
$rst_data = json_decode($rows[0]["data"]);
|
||||
$rst_id = $rst_data->id;
|
||||
if ($rows[0]["status"] == "ERR") {
|
||||
echo "ERR CALL sp_fo_register_save_online_debug| ";
|
||||
echo "<br/>";
|
||||
print_r($rows);
|
||||
$this->db->trans_rollback();
|
||||
return;
|
||||
}
|
||||
$this->db->trans_rollback();
|
||||
echo "DEBUG ONLY";
|
||||
return;
|
||||
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
|
||||
$orderHeaderID = $rst_id;
|
||||
|
||||
if ($orderHeaderID == 0) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Generate Order | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$orderHeaderNo = $rst->data->number;
|
||||
|
||||
$db_msg = $this->add_delivery_note($orderHeaderID, $delivery_note);
|
||||
if ($db_msg != "") {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Add Delivery Note $db_msg\n";
|
||||
return;
|
||||
}
|
||||
|
||||
//Doctor Alias
|
||||
$sql = "UPDATE t_orderheaderaddon
|
||||
SET T_OrderHeaderAddOnAliasDoctorName = '{$futureOrder["FutureOrderDoctorAlias"]}',
|
||||
T_OrderHeaderAddOnAliasDoctorAddress = '{$futureOrder["FutureOrderDoctorAddress"]}',
|
||||
T_OrderHeaderAddOnFoTimeStart = '{$futureOrder["FutureOrderFoTimeStart"]}',
|
||||
T_OrderHeaderAddOnFoTimeEnd = '{$futureOrder["FutureOrderFoTimeEnd"]}'
|
||||
WHERE
|
||||
T_OrderHeaderAddOnT_OrderHeaderID = '{$orderHeaderID}'";
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Create Order : {$this->db->error()["message"]} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// futtureMap
|
||||
$arr = [
|
||||
"FutureMapT_OrderHeaderID" => $orderHeaderID,
|
||||
"FutureMapFutureOrderID" => $futureOrderID,
|
||||
];
|
||||
$qry = $this->db->insert("future_map", $arr);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Future Map: {$this->db->error()["message"]} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
//
|
||||
// Down payment
|
||||
//
|
||||
$sql = "select group_concat(FutureDownpaymentNumber) as dpNo,
|
||||
sum(FutureDownpaymentTotal) dpTotal
|
||||
from future_downpayment
|
||||
where FutureDownpaymentFutureOrderID = ?
|
||||
and FutureDownpaymentIsActive='Y'";
|
||||
|
||||
$query = $this->db->query($sql, $futureOrderID);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Get DownPaymentNumber : {$this->db->error()["message"]} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$dpTotal = 0;
|
||||
$dpNo = "";
|
||||
if (count($rows) > 0) {
|
||||
$dpTotal = $rows[0]["dpTotal"];
|
||||
$dpNo = $rows[0]["dpNo"];
|
||||
}
|
||||
|
||||
if ($dpTotal > 0) {
|
||||
$bankAccountID = 0;
|
||||
$paymentTypeID = 10;
|
||||
$paymentNote = "DP : $dpNo";
|
||||
$rst_payment = $this->do_pelunasan(
|
||||
$orderHeaderID,
|
||||
$bankAccountID,
|
||||
$paymentTypeID,
|
||||
$paymentNote,
|
||||
$dpTotal
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->db->trans_status === false) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} ERR : {$db_msg}\n";
|
||||
} else {
|
||||
$this->db->trans_commit();
|
||||
echo "{$this->now()} $orderHeaderNo [Success]\n";
|
||||
}
|
||||
}
|
||||
public function generate_order($futureOrderID)
|
||||
{
|
||||
$this->db->trans_begin();
|
||||
$this->get_branch_default();
|
||||
|
||||
$sql = "select future_order.*,
|
||||
if(FutureMapIsActive is null , 'N', 'Y') isMapped
|
||||
from future_order
|
||||
left join future_map
|
||||
on FutureOrderID = FutureMapFutureOrderID
|
||||
where FutureOrderID = ?
|
||||
";
|
||||
$qry = $this->db->query($sql, [$futureOrderID]);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err GetFutureOrder {$this->db->error()["message"]} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err GetFutureOrder not found | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
if ($rows[0]["isMapped"] == "Y") {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Order sudah di future_map | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$futureOrder = $rows[0];
|
||||
echo "{$this->now()} Create Order from {$futureOrder["FutureOrderNumber"]} \n";
|
||||
|
||||
$x_header = ($futureOrder["FutureOrderJSONHeader"]);
|
||||
$x_header = preg_replace('/[[:^print:]]/', '', $x_header);
|
||||
$header = json_decode($x_header,true);
|
||||
$header["date"] = date("Y-m-d H:i:s");
|
||||
|
||||
$x_delivery = $futureOrder["FutureOrderJSONDelivery"];
|
||||
$x_delivery = str_replace("\n","",$x_delivery);
|
||||
|
||||
$delivery = json_decode($x_delivery, true);
|
||||
|
||||
$delivery_note = json_decode(
|
||||
$futureOrder["FutureOrderJSONDeliveryNote"],
|
||||
true
|
||||
);
|
||||
$req = json_decode($futureOrder["FutureOrderJSONReq"], true);
|
||||
$detail = json_decode($futureOrder["FutureOrderJSONDetail"], true);
|
||||
$header_json = addslashes(
|
||||
str_replace('\n', '\\\n', json_encode($header))
|
||||
);
|
||||
$detail_json = str_replace('\n', '\\\n', json_encode($detail));
|
||||
$delivery_json = addslashes(
|
||||
str_replace('\n', '\\\n', json_encode($delivery))
|
||||
);
|
||||
|
||||
$req_json = json_encode($req);
|
||||
$sql = "CALL sp_fo_register_save_online(0, '{$header_json}', '{$delivery_json}',
|
||||
'{$detail_json}', '{$req_json}', '3');";
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Create Order : {$this->db->error()["message"]} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$rst = $query->row();
|
||||
$rst->data = json_decode($rst->data);
|
||||
$rst_id = $rst->data->id;
|
||||
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
|
||||
$orderHeaderID = $rst_id;
|
||||
|
||||
if ($orderHeaderID == 0) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Generate Order | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$orderHeaderNo = $rst->data->number;
|
||||
|
||||
$db_msg = $this->add_delivery_note($orderHeaderID, $delivery_note);
|
||||
if ($db_msg != "") {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Add Delivery Note $db_msg\n";
|
||||
return;
|
||||
}
|
||||
|
||||
//Doctor Alias
|
||||
$sql = "UPDATE t_orderheaderaddon
|
||||
SET T_OrderHeaderAddOnAliasDoctorName = '{$futureOrder["FutureOrderDoctorAlias"]}',
|
||||
T_OrderHeaderAddOnAliasDoctorAddress = '{$futureOrder["FutureOrderDoctorAddress"]}',
|
||||
T_OrderHeaderAddOnFoTimeStart = '{$futureOrder["FutureOrderFoTimeStart"]}',
|
||||
T_OrderHeaderAddOnFoTimeEnd = '{$futureOrder["FutureOrderFoTimeEnd"]}'
|
||||
WHERE
|
||||
T_OrderHeaderAddOnT_OrderHeaderID = '{$orderHeaderID}'";
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Create Order : {$this->db->error()["message"]} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// futtureMap
|
||||
$arr = [
|
||||
"FutureMapT_OrderHeaderID" => $orderHeaderID,
|
||||
"FutureMapFutureOrderID" => $futureOrderID,
|
||||
];
|
||||
$qry = $this->db->insert("future_map", $arr);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Future Map: {$this->db->error()["message"]} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
//
|
||||
// Down payment
|
||||
//
|
||||
$sql = "select group_concat(FutureDownpaymentNumber) as dpNo,
|
||||
sum(FutureDownpaymentTotal) dpTotal
|
||||
from future_downpayment
|
||||
where FutureDownpaymentFutureOrderID = ?
|
||||
and FutureDownpaymentIsActive='Y'";
|
||||
|
||||
$query = $this->db->query($sql, $futureOrderID);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} Err Get DownPaymentNumber : {$this->db->error()["message"]} | {$this->db->last_query()}\n";
|
||||
return;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$dpTotal = 0;
|
||||
$dpNo = "";
|
||||
if (count($rows) > 0) {
|
||||
$dpTotal = $rows[0]["dpTotal"];
|
||||
$dpNo = $rows[0]["dpNo"];
|
||||
}
|
||||
|
||||
if ($dpTotal > 0) {
|
||||
$bankAccountID = 0;
|
||||
$paymentTypeID = 10;
|
||||
$paymentNote = "DP : $dpNo";
|
||||
$rst_payment = $this->do_pelunasan(
|
||||
$orderHeaderID,
|
||||
$bankAccountID,
|
||||
$paymentTypeID,
|
||||
$paymentNote,
|
||||
$dpTotal
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->db->trans_status === false) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} ERR : {$db_msg}\n";
|
||||
} else {
|
||||
$this->db->trans_commit();
|
||||
echo "{$this->now()} $orderHeaderNo [Success]\n";
|
||||
}
|
||||
}
|
||||
|
||||
function do_order_log($orderHeaderID, $delivery)
|
||||
{
|
||||
$rst_id = $$orderHeaderID;
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON M_PatientID = T_OrderHeaderM_PatientID
|
||||
WHERE
|
||||
T_OrderHeaderID = {$rst_id}";
|
||||
//echo $sql;
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
echo "{$this->now()} ERR : {$db_msg}\n";
|
||||
return false;
|
||||
}
|
||||
$x_header = $qry->row_array();
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_orderdetail
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$rst_id} AND
|
||||
T_OrderDetailT_TestIsPrice = 'Y' AND
|
||||
T_OrderDetailIsActive = 'Y'";
|
||||
|
||||
$x_details = $this->db_smartone->query($sql)->result_array();
|
||||
$x_details = json_encode($x_details);
|
||||
$x_deliveries = json_encode($delivery);
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_orderpromise
|
||||
WHERE
|
||||
T_OrderPromiseT_OrderHeaderID = {$rst_id} AND T_OrderPromiseIsActive = 'Y'";
|
||||
$x_promises = $this->db_smartone->query($sql)->result_array();
|
||||
$x_promises = json_encode($x_promises);
|
||||
|
||||
$sql = "INSERT INTO order_log(
|
||||
OrderLogT_OrderHeaderID,
|
||||
OrderLogM_PatientDOB,
|
||||
OrderLogM_CompanyID,
|
||||
OrderLogM_MouID,
|
||||
OrderLogM_DoctorSenderID,
|
||||
OrderLogM_DoctorSenderAddressID,
|
||||
orderLogT_OrderHeaderAddOnAliasDoctorName,
|
||||
orderLogT_OrderHeaderAddOnAliasDoctorAddress,
|
||||
OrderLogAge,
|
||||
OrderLogFoNote,
|
||||
OrderLogSubtotal,
|
||||
OrderLogTotal,
|
||||
OrderLogUserID,
|
||||
OrderLogDetails,
|
||||
OrderLogDeliveries,
|
||||
OrderLogPromises
|
||||
)
|
||||
VALUES(
|
||||
{$rst_id},
|
||||
'{$x_header["M_PatientDOB"]}',
|
||||
{$x_header["T_OrderHeaderM_CompanyID"]},
|
||||
{$x_header["T_OrderHeaderM_MouID"]},
|
||||
{$x_header["T_OrderHeaderSenderM_DoctorID"]},
|
||||
{$x_header["T_OrderHeaderSenderM_DoctorAddressID"]},
|
||||
'{$hdr["alias_doctor"]}',
|
||||
'{$hdr["alias_doctor_address"]}',
|
||||
'{$x_header["T_OrderHeaderM_PatientAge"]}',
|
||||
'{$x_header["T_OrderHeaderFoNote"]}',
|
||||
'{$x_header["T_OrderHeaderSubTotal"]}',
|
||||
'{$x_header["T_OrderHeaderTotal"]}',
|
||||
{$this->sys_user["M_UserID"]},
|
||||
'{$x_details}',
|
||||
'{$x_deliveries}',
|
||||
'{$x_promises}'
|
||||
)";
|
||||
$this->db->query($sql);
|
||||
}
|
||||
public function update_delivery($orderID, $deliveries)
|
||||
{
|
||||
$db_msg = "";
|
||||
$sql = "update t_orderdelivery set T_OrderDeliveryIsActive = 'N'
|
||||
where T_OrderDeliveryT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql, [$orderID]);
|
||||
if (!$qry) {
|
||||
return "ERR Update Delivery | " .
|
||||
$this->db->error()["message"] .
|
||||
"|" .
|
||||
$this->db->last_query();
|
||||
}
|
||||
foreach ($deliveries as $d) {
|
||||
$arr = [
|
||||
"T_OrderDeliveryT_OrderHeaderID" => $orderID,
|
||||
"T_OrderDeliveryM_DeliveryID" =>
|
||||
$d["T_OrderDeliveriesM_DeliveryID"],
|
||||
"T_OrderDeliveryM_DeliveryTypeID" =>
|
||||
$d["T_OrderDeliveriesM_DeliveryTypeID"],
|
||||
"T_OrderDeliveryDestination" =>
|
||||
$d["T_OrderDeliveriesDestination"],
|
||||
];
|
||||
$qry = $this->db->insert("t_orderdelivery", $arr);
|
||||
if (!$qry) {
|
||||
$db_msg .=
|
||||
"ERR Update Delivery | " .
|
||||
$this->db->error()["message"] .
|
||||
"|" .
|
||||
$this->db->last_query() .
|
||||
"\n";
|
||||
}
|
||||
}
|
||||
return $db_msg;
|
||||
}
|
||||
}
|
||||
457
application/controllers/fix/Fix_rujukan_pasien.php
Normal file
457
application/controllers/fix/Fix_rujukan_pasien.php
Normal file
@@ -0,0 +1,457 @@
|
||||
<?php
|
||||
|
||||
class Fix_rujukan_pasien extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
//Create table mapping pasien result
|
||||
public function db_error()
|
||||
{
|
||||
$date = date("Y-m-d H:i:s");
|
||||
echo "$date Err : " . $this->db->error()['message'] . "\n";
|
||||
echo "\t\t" . $this->db->last_query() . "\n";
|
||||
exit;
|
||||
}
|
||||
public function list_rujukan($date = "")
|
||||
{
|
||||
if ($date == "") {
|
||||
$date = date("Y-m-d");
|
||||
}
|
||||
$sql = "select T_OrderHeaderLabNumber,T_OrderHeaderAddOnLabNumberOrigin,
|
||||
T_OrderHeaderID,
|
||||
group_concat(distinct T_SampleTypeT_BahanID separator '.') BahanID
|
||||
from t_orderheader
|
||||
join t_ordersample on T_OrderHeaderID = T_OrderSampleT_OrderHeaderID
|
||||
and T_OrderSampleIsActive = 'Y'
|
||||
join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID
|
||||
join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderAddOnIsActive = 'Y'
|
||||
left join rujukan_bahan on T_OrderHeaderID = rujukanBahanT_OrderHeaderID
|
||||
where T_OrderHeaderAddOnLabNumberOrigin is not null
|
||||
and date(T_OrderHeaderDate) = ?
|
||||
and rujukanBahanID is null
|
||||
group by T_OrderHeaderID";
|
||||
$qry = $this->db->query($sql, [$date]);
|
||||
if (!$qry) {
|
||||
echo json_encode(
|
||||
array(
|
||||
"status" => "ERR",
|
||||
"message" => "Error Listing Order Rujukan | {$this->db->error()['message']}|{$this->db->last_query()}"
|
||||
)
|
||||
);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode(
|
||||
array(
|
||||
"status" => "OK",
|
||||
"count" => count($rows),
|
||||
"data" => $rows
|
||||
)
|
||||
);
|
||||
exit;
|
||||
}
|
||||
public function log($msg)
|
||||
{
|
||||
$date = date("Y-m-d H:i:s");
|
||||
echo "$date $msg\n";
|
||||
}
|
||||
public function get_json_pasien($orderID, $patientID)
|
||||
{
|
||||
}
|
||||
public function fix_pasien_address($orderID, $json_patient, $is_api=0)
|
||||
{
|
||||
$sql = "select T_OrderHeaderM_PatientID from t_orderheader where T_OrderHeaderID=?";
|
||||
$qry = $this->db->query($sql, [$orderID]);
|
||||
if (!$qry) {
|
||||
if ($is_api == 0) {
|
||||
$this->db_error();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
if ($is_api == 0) {
|
||||
echo "T_OrderHeaderID $orderID tidak ketemu";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$patientID = $rows[0]["T_OrderHeaderM_PatientID"];
|
||||
$sql = "select count(*) total
|
||||
from m_patientaddress where M_PatientAddressM_PatientID = ?";
|
||||
$qry = $this->db->query($sql, [$patientID]);
|
||||
if (!$qry) {
|
||||
$this->db_error();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if ($rows[0]["total"] == 0) {
|
||||
if (isset($json_patient["address"]) && count($json_patient["address"]) > 0) {
|
||||
$address = $json_patient["address"][0];
|
||||
unset($address["M_PatientAddressID"]);
|
||||
$address["M_PatientAddressM_PatientID"] = $patientID;
|
||||
$qry = $this->db->insert("m_patientaddress", $address);
|
||||
if (!$qry) {
|
||||
if ($is_api == 0) {
|
||||
$this->db_error();
|
||||
}
|
||||
}
|
||||
if ($is_api == 0) {
|
||||
echo "Data Alamat Pasien berhasil di masukan : " .
|
||||
print_r($address, true);
|
||||
}
|
||||
} else {
|
||||
if ($is_api == 0) {
|
||||
echo "Kiriman Alamat Pasien Kosong";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public function fix($nolab)
|
||||
{
|
||||
$sql = "select
|
||||
t_orderheader.*,T_OrderHeaderAddOnLabNumberOrigin
|
||||
from
|
||||
t_orderheader
|
||||
join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnID
|
||||
and
|
||||
( T_OrderHeaderLabNumber = ? or T_OrderHeaderAddOnLabNumberOrigin = ? )
|
||||
";
|
||||
$qry = $this->db->query($sql, [$nolab,$nolab]);
|
||||
if (!$qry) {
|
||||
$this->db_error();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
$this->log("Nolab $nolab tidak di ketemukan");
|
||||
exit;
|
||||
}
|
||||
if ($rows[0]["T_OrderHeaderIsActive"] != "Y") {
|
||||
$this->log("Nolab $nolab void.");
|
||||
exit;
|
||||
}
|
||||
if ($rows[0]["T_OrderHeaderAddOnLabNumberOrigin"] == "") {
|
||||
$this->log("Nolab $nolab bukan rujukan.");
|
||||
exit;
|
||||
}
|
||||
$orderID = $rows[0]["T_OrderHeaderID"];
|
||||
echo "<H5> No. Lab: {$rows[0]['T_OrderHeaderLabNumber']} | asal : {$rows[0]['T_OrderHeaderAddOnLabNumberOrigin']} ";
|
||||
//show detail pasien
|
||||
$sql ="
|
||||
select
|
||||
M_PatientID,M_PatientNoreg,
|
||||
CONCAT(M_TitleName,' ',ifnull(M_PatientPrefix,''),' ',M_PatientName,' ',ifnull(M_PatientSuffix,''))
|
||||
AS M_PatientName, M_PatientHP , M_PatientPhone , M_PatientEmail, M_PatientIDNumber,
|
||||
(SELECT M_PatientAddressDescription
|
||||
from m_patientaddress AS p
|
||||
WHERE M_PatientAddressM_PatientID = M_PatientID
|
||||
ORDER BY M_PatientAddressM_PatientID
|
||||
LIMIT 1) AS M_PatientAddressDescription,
|
||||
T_OrderHeaderM_PatientAge
|
||||
from
|
||||
t_orderheader
|
||||
join m_patient on T_OrderHeaderID = ?
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
and T_OrderHeaderM_PatientID = M_PatientID";
|
||||
$qry = $this->db->query($sql, [$orderID]);
|
||||
if (!$qry) {
|
||||
$this->db_error();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
$this->log("Pasien untuk $nolab tidak di ketemukan");
|
||||
exit;
|
||||
}
|
||||
$patientID = $rows[0]["M_PatientID"];
|
||||
echo "<H5>Pasien tercatat di Lab Rujukan </H5>";
|
||||
$this->print_table($rows, array_keys($rows[0]));
|
||||
|
||||
echo "<H5>Data pasien di kirim </H5>";
|
||||
$sql = "select group_concat(distinct(T_SampleTypeT_BahanID) separator '.') bahanID
|
||||
from
|
||||
t_ordersample
|
||||
join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID
|
||||
and T_OrderSampleT_OrderHeaderID = ? and T_OrderSampleIsActive = 'Y'
|
||||
group by T_OrderSampleT_OrderHeaderID";
|
||||
$qry = $this->db->query($sql, [$orderID]);
|
||||
if (!$qry) {
|
||||
$this->db_error();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$bahanID = $rows[0]["bahanID"];
|
||||
$this->get_pasien_kiriman($orderID, $bahanID);
|
||||
}
|
||||
public function sampling_info()
|
||||
{
|
||||
// Bahan | Sampling Date | Sampling Time
|
||||
$prm = $this->sys_input;
|
||||
$orderID = $prm["orderID"];
|
||||
$sql = "select
|
||||
T_BahanName,T_BahanID,
|
||||
max(concat(T_OrderSampleReceiveDate,' ',T_OrderSampleReceiveTime))
|
||||
T_OrderSampleReceiveDateTime
|
||||
from
|
||||
t_ordersample
|
||||
join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID
|
||||
and T_OrderSampleT_OrderHeaderID = ?
|
||||
and T_OrderSampleIsActive = 'Y'
|
||||
join t_bahan on T_SampleTypeT_BahanID = T_BahanID
|
||||
group by T_BahanID
|
||||
";
|
||||
$qry = $this->db->query($sql, [$orderID]);
|
||||
if (!$qry) {
|
||||
echo json_encode(
|
||||
array(
|
||||
"status" => "ERR",
|
||||
"message" => $this->db->error()['message'] . " | "
|
||||
. $this->db->last_query()
|
||||
)
|
||||
);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode(
|
||||
array(
|
||||
"status" => "OK",
|
||||
"prm" => $prm,
|
||||
"sql" => $this->db->last_query(),
|
||||
"data" => $rows
|
||||
)
|
||||
);
|
||||
}
|
||||
public function get_pasien_kiriman($orderID, $bahanID, $is_api=0)
|
||||
{
|
||||
$sql = "select
|
||||
incomingRefDetailPatient, incomingRefDetailNewM_PatientID,
|
||||
M_BranchIPAddress, incomingRefDetailT_OrderHeaderID
|
||||
from
|
||||
incoming_ref_detail
|
||||
join incoming_ref on incomingRefID = incomingRefDetailIncomingRefID
|
||||
join m_branch on incomingRefM_BranchID = M_BranchID
|
||||
where incomingRefDetailNewT_OrderHeaderID = ?
|
||||
order by incomingRefDetailID desc
|
||||
limit 0,1
|
||||
";
|
||||
$qry = $this->db->query($sql, [$orderID]);
|
||||
if (!$qry) {
|
||||
$this->db_error();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
if ($is_api == 1) {
|
||||
echo json_encode(
|
||||
array(
|
||||
"status" => "ERR",
|
||||
"message" => "Data tidak di temukan"
|
||||
)
|
||||
);
|
||||
} else {
|
||||
echo "Data tidak di temukan";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
$originIpAddress = $rows[0]["M_BranchIPAddress"];
|
||||
$originOrderID = $rows[0]["incomingRefDetailT_OrderHeaderID"];
|
||||
|
||||
$patient = json_decode($rows[0]["incomingRefDetailPatient"], true);
|
||||
$this->fix_pasien_address($orderID, $patient, $is_api);
|
||||
|
||||
if ($is_api == 0) {
|
||||
echo "<h5>Data Kiriman Pasien<h5>";
|
||||
}
|
||||
//TODO : Fix T_OrderHeaderPjM_DoctorID
|
||||
$sql = "select
|
||||
M_DoctorID, fn_get_doctor_fullname(M_DoctorID) FullNameDr
|
||||
from
|
||||
m_doctor
|
||||
join m_doctorpj on M_DoctorID = M_DoctorPjM_DoctorID
|
||||
and M_DoctorIsActive = 'Y'
|
||||
and M_DoctorPjIsActive = 'Y'
|
||||
and M_DoctorPjIsDefaultPJ = 'Y'
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
if ($is_api == 1) {
|
||||
echo json_encode(
|
||||
array(
|
||||
"status" => "ERR",
|
||||
"message" => "Select Dr PJ | " . $this->db->error()['message'] .
|
||||
"|" . $this->db->last_query()
|
||||
)
|
||||
);
|
||||
exit;
|
||||
} else {
|
||||
$this->db_error();
|
||||
}
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
if ($is_api == 1) {
|
||||
echo json_encode(
|
||||
array(
|
||||
"status" => "ERR",
|
||||
"message" => "Dr Default PJ tidak di temukan"
|
||||
)
|
||||
);
|
||||
exit;
|
||||
} else {
|
||||
$this->db_error();
|
||||
echo "Data Default Dr PJ tidak di temukan";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$doctorPjID = $rows[0]["M_DoctorID"];
|
||||
if ($is_api == 0) {
|
||||
echo "<H5>Dr PJ </H5>";
|
||||
$this->print_table($rows, array_keys($rows[0]));
|
||||
}
|
||||
//Update Dr PJ
|
||||
$sql = "update t_orderheader set T_OrderHeaderPjM_DoctorID=?
|
||||
where T_OrderHeaderID=?";
|
||||
$this->db->query($sql, [$doctorPjID, $orderID]);
|
||||
|
||||
|
||||
$samplingUrl = "http://$originIpAddress/one-api/fix/fix_rujukan_pasien/sampling_info";
|
||||
$a_bahan = explode(".", $bahanID);
|
||||
$param = json_encode(array("orderID" => $originOrderID,"bahanID" => $a_bahan));
|
||||
if ($is_api == 0) {
|
||||
echo "<H5> Get Sampling Info from $samplingUrl </h5>";
|
||||
}
|
||||
$result = $this->post($samplingUrl, $param);
|
||||
if ($result["status"] == "ERR") {
|
||||
if ($is_api == 1) {
|
||||
echo json_encode(
|
||||
array(
|
||||
"status" => "ERR",
|
||||
"message" => "Error get Sampling" ,
|
||||
"response" => print_r($result, true)
|
||||
)
|
||||
);
|
||||
exit;
|
||||
} else {
|
||||
echo "Error Get Sampling";
|
||||
print_r($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if ($is_api == 0) {
|
||||
$this->print_table($result["data"], array_keys($result["data"][0]));
|
||||
}
|
||||
$db_msg = [];
|
||||
foreach ($result["data"] as $d) {
|
||||
$sql = "insert into rujukan_bahan(rujukanBahanT_OrderHeaderID,
|
||||
rujukanBahanT_BahanID,rujukanBahanT_BahanName,
|
||||
rujukanBahanReceiveDate)
|
||||
values(?,?,?,?)
|
||||
on duplicate key update
|
||||
rujukanBahanT_BahanName = ?,
|
||||
rujukanBahanReceiveDate = ?
|
||||
";
|
||||
$qry = $this->db->query(
|
||||
$sql,
|
||||
[ $orderID, $d["T_BahanID"], $d["T_BahanName"], $d["T_OrderSampleReceiveDateTime"],
|
||||
$d["T_BahanName"], $d["T_OrderSampleReceiveDateTime"]
|
||||
]
|
||||
);
|
||||
|
||||
if (!$qry) {
|
||||
if ($is_api == 1) {
|
||||
$db_msg[] = array(
|
||||
"orderID" => $orderID,
|
||||
"originIPAddress" => $originIpAddress,
|
||||
"error" => $this->db->error()['message'] . "|" . $this->db->last_query()
|
||||
);
|
||||
} else {
|
||||
echo "Error Insert|Update Rujukan Bahan : " .
|
||||
$this->db->error()['message'] . " |\n" .
|
||||
$this->db->last_query() . "\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($is_api == 1) {
|
||||
if (count($db_msg) > 0) {
|
||||
echo json_encode(
|
||||
array(
|
||||
"status" => "ERR",
|
||||
"error" => $db_msg
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
public 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_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
));
|
||||
$result = curl_exec($ch);
|
||||
if (curl_errno($ch) > 0) {
|
||||
return array(
|
||||
"status" => "ERR",
|
||||
"message" => curl_error($ch)
|
||||
);
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode != 200) {
|
||||
return array(
|
||||
"status" => "ERR",
|
||||
"message" => "Http Response : $httpCode | $result"
|
||||
);
|
||||
}
|
||||
$j_result = json_decode($result, true);
|
||||
if (!$j_result) {
|
||||
return array(
|
||||
"status" => "ERR",
|
||||
"message" => "JSON invalid: $result"
|
||||
);
|
||||
}
|
||||
return $j_result;
|
||||
}
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table($rows, $keys)
|
||||
{
|
||||
$this->print_table_style();
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
93
application/controllers/fix/Fixsspricemou.php
Normal file
93
application/controllers/fix/Fixsspricemou.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
class Fixsspricemou extends CI_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function packet($packetID) {
|
||||
$sql = "select T_PacketM_MouID from t_packet where T_PacketID = ?";
|
||||
$qry = $this->db->query($sql,array($packetID));
|
||||
$mouID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$mouID = $rows[0]["T_PacketM_MouID"];
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
if ( $mouID == 0 ) {
|
||||
echo "Mou not found";
|
||||
exit;
|
||||
}
|
||||
$sql = "select M_MouM_CompanyID from m_mou where M_MouID = ?";
|
||||
$qry = $this->db->query($sql,array($mouID));
|
||||
$companyID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$companyID= $rows[0]["M_MouM_CompanyID"];
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
if ($companyID == 0 ) {
|
||||
echo "CompanyID not found!";
|
||||
exit;
|
||||
}
|
||||
//child test
|
||||
$sql = "select T_PacketM_MouID T_PriceM_MouID, T_TestID, T_TestName, 'N' IsFromPanel, Nat_TestID,
|
||||
T_TestID T_PriceT_TestID, 'N' T_PriceIsCito, $companyID T_PriceM_CompanyID,
|
||||
T_PacketM_mouID T_PriceM_MouID, 0 T_PricePriority, T_PacketDetailPriceAmount T_PriceAmount,
|
||||
T_PacketDetailPriceDisc T_PriceDisc, T_PacketDetailPriceDiscRp T_PriceDiscRp, T_PacketDetailPriceSubTotal T_PriceSubTotal,
|
||||
0 T_PriceOther, T_PacketDetailPrice T_PriceTotal,
|
||||
'Y' T_TestForceSell, 'N' is_packet, 0 packet_id,
|
||||
'PX' px_type, concat('[', T_TestNat_TestID , ']') nat_test, '[]' child_test, 'N' IsFavourite, T_TestSasCode
|
||||
from t_packetdetail
|
||||
join t_packet on T_PacketDetailT_PacketID = T_PacketID and T_PacketID = ?
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
and T_PacketDetailIsActive = 'Y' and T_TestIsActive = 'Y'
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID
|
||||
and Nat_TestIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql,array($packetID));
|
||||
if (!$qry ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
$ct_rows = $qry->result_array();
|
||||
$p_nat_test = array();
|
||||
foreach($ct_rows as $ct_idx => $cr) {
|
||||
$sasCode = $cr["T_TestSasCode"] . '%';
|
||||
$sql = "select distinct T_TestNat_TestID
|
||||
from t_test
|
||||
where T_TestSasCode like ?
|
||||
and T_TestIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql,array($sasCode));
|
||||
if (!$qry ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
$nt_rows = $qry->result_array();
|
||||
$t_rows = array();
|
||||
foreach($nt_rows as $nr) {
|
||||
$t_rows[] = intval( $nr["T_TestNat_TestID"]);
|
||||
$p_nat_test[]= intval( $nr["T_TestNat_TestID"]);
|
||||
}
|
||||
$ct_rows[$ct_idx]['nat_test'] = json_encode($t_rows,JSON_NUMERIC_CHECK);
|
||||
}
|
||||
if (count($ct_rows) > 0 ) {
|
||||
$x_arr = array();
|
||||
foreach($ct_rows as $x_cr) {
|
||||
$x_arr[] = $x_cr;
|
||||
}
|
||||
$child_test = json_encode($x_arr,true);
|
||||
$nat_test = json_encode($p_nat_test,true);
|
||||
}
|
||||
echo "Child Test : \n" ;
|
||||
echo $child_test . "\n";
|
||||
echo "Nat Test : \n";
|
||||
echo $nat_test . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
137
application/controllers/fix/Hs_deliveryorder.php
Normal file
137
application/controllers/fix/Hs_deliveryorder.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
class Hs_deliveryorder extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo '<pre>';
|
||||
echo "cek [username]<br/> Untuk menampilkan list surat jalan petugas";
|
||||
}
|
||||
public function cek($petugas)
|
||||
{
|
||||
//query TestName UnitName NatUnitName MethodeUnitName
|
||||
// UnitName : UnitName yang ada di t_orderdetail
|
||||
// NatUnitName : UnitName yg diambil dari T_Test
|
||||
// MethodeUnitName : UnitName yg diambil dari nat_methode_unit, sesuai dengan t_orderdetail methodeID
|
||||
// Action : tampilkan tombol "Fix Unit" jika UnitName <> NatUnitName atau UnitName <> MethodeUnitName
|
||||
// parameter dari tombol ini adalah orderDetailID dan petugas
|
||||
// url_fix = "/one-api/fix/unit/fix/$orderDetailID/$petugas"
|
||||
// "<button onClick=\"document.location.href='$url_fix'\">Fix Verif Valid Race</button>";
|
||||
// utk menampilkan listing bisa menggunakan fungsi print_table dengan parameter rows dari qry->result_array
|
||||
|
||||
$sql = "SELECT HS_DeliveryOrderID as id,
|
||||
DATE_FORMAT(HS_DeliveryOrderDate,'%d-%m-%Y') as tanggal,
|
||||
HS_DeliveryOrderNumber as nomor,
|
||||
CONCAT(M_StaffName, ' [',M_UserUsername,']') as petugas,
|
||||
CASE
|
||||
WHEN HS_DeliveryOrderStatus = 'N' THEN 'Baru'
|
||||
WHEN HS_DeliveryOrderStatus = 'S' THEN 'Kirim'
|
||||
WHEN HS_DeliveryOrderStatus = 'A' THEN 'Diterima'
|
||||
WHEN HS_DeliveryOrderStatus = 'X' THEN 'Ditolak'
|
||||
WHEN HS_DeliveryOrderStatus = 'G' THEN 'Berangkat'
|
||||
WHEN HS_DeliveryOrderStatus = 'P' THEN 'Proses'
|
||||
WHEN HS_DeliveryOrderStatus = 'D' THEN 'Selesai'
|
||||
ELSE ''
|
||||
END as status
|
||||
FROM one_hs.hs_deliveryorder
|
||||
join m_user ON M_UserID = HS_DeliveryOrderM_UserID
|
||||
join m_staff ON M_StaffID = M_UserM_StaffID
|
||||
WHERE M_UserUsername = ?
|
||||
AND HS_DeliveryOrderIsActive = 'Y'
|
||||
AND HS_DeliveryOrderStatus <> 'D'";
|
||||
$qry = $this->db->query($sql, [$petugas]);
|
||||
if (!$qry) {
|
||||
echo "ERR : \n";
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
echo '<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
';
|
||||
echo '<table>';
|
||||
echo '<tr>';
|
||||
echo "<td>Tanggal</td> <td>Nomor</td> <td>Petugas</td> <td>Status</td> <td>Aksi</td>
|
||||
</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo '<tr>';
|
||||
|
||||
echo "<td>{$r['tanggal']} </td> <td>{$r['nomor']}</td> <td>{$r['petugas']}</td> <td>{$r['status']}</td>
|
||||
";
|
||||
$url_target = '/one-api/fix/hs_deliveryorder/fix/'. $r['id'] . '/' . $petugas;
|
||||
|
||||
|
||||
echo '<td>';
|
||||
echo "<a type='button' target=\"_blank\" href=\"$url_target\"> Ganti status 'selesai' </a>";
|
||||
echo "</td>";
|
||||
// $x_note = "<pre>" . print_r($r, true) . "</pre>";
|
||||
// echo "<td>$x_note</td>";
|
||||
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
function fix($id, $petugas)
|
||||
{
|
||||
|
||||
$sql = "UPDATE one_hs.hs_deliveryorder SET HS_DeliveryOrderStatus = 'D' WHERE HS_DeliveryOrderID = $id";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo 'update OK';
|
||||
header("Location: /one-api/fix/hs_deliveryorder/cek/".$petugas);
|
||||
exit();
|
||||
|
||||
}
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table($keys)
|
||||
{
|
||||
$this->print_table_style();
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
}
|
||||
397
application/controllers/fix/Itf.php
Normal file
397
application/controllers/fix/Itf.php
Normal file
@@ -0,0 +1,397 @@
|
||||
<?php
|
||||
|
||||
class Itf extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
echo "<pre>";
|
||||
echo "order [instrumentID] [Nomor Reg]:\n Untuk melihat Status Order\n\n";
|
||||
echo "reset_order [instrumentID] [Nomor Reg]:\n Untuk Mereset Order\n\n";
|
||||
}
|
||||
function cek($nolab, $test = "ALL")
|
||||
{
|
||||
$sql = "select * from t_orderheader where T_OrderHeaderLabNumber = ?";
|
||||
$qry = $this->db->query($sql, [$nolab]);
|
||||
if (!$qry) {
|
||||
$this->query_error();
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "<pre>No Order found.\n";
|
||||
exit;
|
||||
}
|
||||
$orderID = $rows[0]["T_OrderHeaderID"];
|
||||
$sql = "select T_OrderDetailID, T_OrderDetailT_TestName, T_OrderDetailNat_InstrumentID ,
|
||||
Nat_InstrumentName, T_OrderDetailResult
|
||||
from t_orderdetail
|
||||
left join nat_instrument on
|
||||
T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailNat_InstrumentID = Nat_InstrumentID
|
||||
where T_OrderDetailT_OrderHeaderID = ?
|
||||
";
|
||||
$qry = $this->db->query($sql, [$orderID]);
|
||||
if (!$qry) {
|
||||
$this->query_error();
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "<pre>No Order Detail found.\n";
|
||||
exit;
|
||||
}
|
||||
$fields = array_keys($rows[0]);
|
||||
$this->print_table($rows, $fields);
|
||||
}
|
||||
function raw($rawID)
|
||||
{
|
||||
$sql = "select Nat_InstrumentName, itf_RawDate, concat('<PRE>', Itf_RawData, '</PRE>') RawData
|
||||
|
||||
from itf_raw
|
||||
join nat_instrument on Nat_InstrumentID = Itf_RawNat_InstrumentID
|
||||
where itf_RawID=?";
|
||||
$qry = $this->db->query($sql, [$rawID]);
|
||||
if (!$qry) {
|
||||
$this->query_error();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "<pre>No Parsing Record found.\n";
|
||||
exit();
|
||||
}
|
||||
$fields = array_keys($rows[0]);
|
||||
$this->print_table($rows, $fields);
|
||||
|
||||
$sql = "select
|
||||
Itf_ResultInstrumentDate, Itf_ResultNoreg, Itf_ResultKode, Itf_ResultResult, Itf_ResultIsSent
|
||||
from itf_result where Itf_ResultItf_RawID = ?";
|
||||
|
||||
$qry = $this->db->query($sql, [$rawID]);
|
||||
if (!$qry) {
|
||||
$this->query_error();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "<pre>No Record found.\n";
|
||||
echo $this->db->last_query();
|
||||
exit();
|
||||
}
|
||||
$fields = array_keys($rows[0]);
|
||||
$this->print_table($rows, $fields);
|
||||
}
|
||||
function incoming($instrumentID, $nolab)
|
||||
{
|
||||
$sample = $nolab . "%";
|
||||
$sql = "select
|
||||
Itf_ResultInstrumentDate, Itf_ResultNoreg, Itf_ResultAssay, Itf_ResultResult, ItfResultRawID
|
||||
from itf_result
|
||||
where Itf_ResultNoreg like ?
|
||||
and Itf_ResultNat_InstrumentID=?";
|
||||
$qry = $this->db->query($sql, [$sample, $instrumentID]);
|
||||
if (!$qry) {
|
||||
$this->query_error();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "<pre>No Record found.\n";
|
||||
echo $this->db->last_query();
|
||||
exit();
|
||||
}
|
||||
$fields = array_keys($rows[0]);
|
||||
$this->print_table($rows, $fields);
|
||||
}
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table($rows, $keys)
|
||||
{
|
||||
$this->print_table_style();
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
public function instrument($query = "")
|
||||
{
|
||||
$query = "%$query%";
|
||||
$sql = "select Nat_InstrumentID,Nat_InstrumentName, Nat_InstrumentIsActive
|
||||
from nat_instrument
|
||||
join t_instrument_local on T_InstrumentLocalNat_InstrumentID = Nat_InstrumentID
|
||||
and T_InstrumentLocalIsActive = 'Y'
|
||||
and Nat_InstrumentName like ?";
|
||||
$qry = $this->db->query($sql, [$query]);
|
||||
if (!$qry) {
|
||||
$this->query_error();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "<pre>No Record found.\n";
|
||||
echo $this->db->last_query();
|
||||
exit();
|
||||
}
|
||||
$fields = array_keys($rows[0]);
|
||||
$this->print_table($rows, $fields);
|
||||
}
|
||||
public function query_error()
|
||||
{
|
||||
echo "<pre>Erro Query : " . $this->db->error()["message"] . "\n";
|
||||
echo $this->db->last_query();
|
||||
exit();
|
||||
}
|
||||
public function reset_order($instrumentID, $nolab, $status = "N")
|
||||
{
|
||||
echo "<pre>";
|
||||
$sql = "call sp_itf_order_reset(?,?,?)";
|
||||
try {
|
||||
$qry = $this->db->query($sql, [$instrumentID, $nolab, $status]);
|
||||
if ($qry) {
|
||||
echo json_encode(["status" => "OK", "message" => ""]);
|
||||
} else {
|
||||
$msg = print_r($this->db->error(), true);
|
||||
echo json_encode(["status" => "OK", "message" => $msg]);
|
||||
}
|
||||
} catch (exception $e) {
|
||||
echo json_encode(["status" => "ERR", "message" => $e->message()]);
|
||||
}
|
||||
}
|
||||
public function order_api_v2($instrumentID, $sampleID)
|
||||
{
|
||||
$sql = "call sp_itf_order_v2(?,?)";
|
||||
try {
|
||||
$qry = $this->db->query($sql, array($instrumentID, $sampleID));
|
||||
if (isset($qry->result_id->num_rows)) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode(
|
||||
array("status" => "OK", "order" => $rows)
|
||||
);
|
||||
} else {
|
||||
echo json_encode(
|
||||
array("status" => "OK", "order" => array())
|
||||
);
|
||||
}
|
||||
} catch (exception $e) {
|
||||
echo json_encode(
|
||||
array("status" => "ERR", "message" => $e->message())
|
||||
);
|
||||
}
|
||||
}
|
||||
public function order_api($instrumentID, $sampleID)
|
||||
{
|
||||
$sql = "call sp_itf_order(?,?)";
|
||||
try {
|
||||
$qry = $this->db->query($sql, array($instrumentID, $sampleID));
|
||||
if (isset($qry->result_id->num_rows)) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode(
|
||||
array("status" => "OK", "order" => $rows)
|
||||
);
|
||||
} else {
|
||||
echo json_encode(
|
||||
array("status" => "OK", "order" => array())
|
||||
);
|
||||
}
|
||||
} catch (exception $e) {
|
||||
echo json_encode(
|
||||
array("status" => "ERR", "message" => $e->message())
|
||||
);
|
||||
}
|
||||
}
|
||||
public function order($instrumentID, $nolab)
|
||||
{
|
||||
$sql = " select
|
||||
T_BarcodeLabT_OrderHeaderID, T_BarcodeLabT_SampleTypeID ,
|
||||
T_BarcodeLabBarcode
|
||||
from t_barcodelab
|
||||
where T_BarcodeLabBarcode like concat(?,'%')
|
||||
and T_BarcodeLabIsActive ='Y'
|
||||
order by T_BarcodeLabID desc
|
||||
limit 0,1; ";
|
||||
$qry = $this->db->query($sql, [$nolab]);
|
||||
if (!$qry) {
|
||||
echo "ERR select order :\n";
|
||||
print_r($this->db->error());
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "Checking Order from rujukan</p>";
|
||||
$sql = " select
|
||||
T_BarcodeLabT_OrderHeaderID, T_BarcodeLabT_SampleTypeID ,
|
||||
T_BarcodeLabBarcodeOrigin
|
||||
from t_barcodelab
|
||||
where T_BarcodeLabBarcodeOrigin like concat(?,'%')
|
||||
and T_BarcodeLabIsActive ='Y'
|
||||
limit 0,1";
|
||||
$qry = $this->db->query($sql, [$nolab]);
|
||||
if (!$qry) {
|
||||
echo "ERR select order :\n";
|
||||
print_r($this->db->error());
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "Checking Order from rujukan WorkAround</p>";
|
||||
//02208301DCSK
|
||||
$nolab_only = substr($nolab, 0, 10);
|
||||
$sample = substr($nolab, 10, 2);
|
||||
$sql = "select concat(T_OrderHeaderLabNumber,?) Nolab
|
||||
from t_orderheaderaddon
|
||||
join t_orderheader on T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
where T_OrderHeaderAddOnLabNumberOrigin= ?
|
||||
and T_OrderHeaderAddOnIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$sample, $nolab_only]);
|
||||
if (!$qry) {
|
||||
echo "ERR select order WorkAround :\n";
|
||||
print_r($this->db->error());
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "ERR order not found : noreg $nolab\n";
|
||||
exit();
|
||||
}
|
||||
$new_nolab = $rows[0]["Nolab"];
|
||||
$sql = " select
|
||||
T_BarcodeLabT_OrderHeaderID, T_BarcodeLabT_SampleTypeID ,
|
||||
T_BarcodeLabBarcode
|
||||
from t_barcodelab
|
||||
where T_BarcodeLabBarcode like concat(?,'%')
|
||||
and T_BarcodeLabIsActive ='Y'
|
||||
order by T_BarcodeLabID desc
|
||||
";
|
||||
$qry = $this->db->query($sql, [$new_nolab]);
|
||||
if (!$qry) {
|
||||
echo "ERR select order :\n";
|
||||
print_r($this->db->error());
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
print_r($rows);
|
||||
if (count($rows) == 0) {
|
||||
echo "ERR order not found : noreg $nolab\n";
|
||||
exit();
|
||||
}
|
||||
$r = $rows[0];
|
||||
$barcode = $r["T_BarcodeLabBarcode"];
|
||||
} else {
|
||||
$r = $rows[0];
|
||||
$barcode = $r["T_BarcodeLabBarcode"];
|
||||
}
|
||||
} else {
|
||||
$r = $rows[0];
|
||||
$barcode = $r["T_BarcodeLabBarcode"];
|
||||
}
|
||||
$orderHeaderID = $r["T_BarcodeLabT_OrderHeaderID"];
|
||||
$sampleTypeID = $r["T_BarcodeLabT_SampleTypeID"];
|
||||
|
||||
$sql = "select if(@flagOrigin, T_OrderHeaderAddOnLabNumberOrigin,
|
||||
T_OrderHeaderLabNumber) T_OrderHeaderLabNumber,
|
||||
concat(M_TitleName,' ', M_PatientName)
|
||||
M_PatientName,
|
||||
concat(M_DoctorPrefix, if(M_DoctorPrefix <> '' , ' ','') ,
|
||||
M_DoctorPrefix2,if(M_DoctorPrefix2 <> '' , ' ',''),
|
||||
M_DoctorName,
|
||||
M_DoctorSufix) M_DoctorName,
|
||||
replace(M_PatientDob,'-','') M_PatientDob,
|
||||
T_OrderHeaderM_PatientAge, T_OrderHeaderDate ,
|
||||
M_PatientNoReg,
|
||||
case
|
||||
when M_SexCode = 'P' then 'F'
|
||||
when M_SexCode = 'L' then 'M'
|
||||
else M_SexCode
|
||||
end Sex
|
||||
from t_orderheader
|
||||
join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
join m_patient on T_OrderHeaderID =?
|
||||
and M_PatientID = T_OrderHeaderM_PatientID
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
and M_PatientIsActive = 'Y'
|
||||
join m_sex on M_PatientM_SexID = M_SexID
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join m_doctor on T_OrderHeaderSenderM_DoctorID = M_DoctorID ";
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
echo "ERR select order :\n";
|
||||
$this->query_error();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$r = $rows[0];
|
||||
$noreg = $r["T_OrderHeaderLabNumber"];
|
||||
$pasien = $r["M_PatientName"];
|
||||
$dokter = $r["M_DoctorName"];
|
||||
$dob = $r["M_PatientDob"];
|
||||
$orderDate = $r["T_OrderHeaderDate"];
|
||||
$sex = $r["M_SexCode"];
|
||||
$pid = $r["pid"];
|
||||
$this->print_table([$r], array_keys($r));
|
||||
|
||||
echo "<p>Assay</p>";
|
||||
$sql = "select
|
||||
T_OrderDetailAddOnID,T_OrderDetailT_TestName, M_InstrumentAssayCode,T_OrderDetailAddOnFlagIsRunning,
|
||||
if(T_OrderDetailAddOnFlagIsRunning='N','-',T_OrderDetailAddOnRunDate)
|
||||
T_OrderDetailAddOnRunDate,
|
||||
Nat_InstrumentName
|
||||
from
|
||||
m_instrumentassay
|
||||
join t_test on M_InstrumentAssayNat_TestID = T_TestNat_TestID
|
||||
and M_InstrumentAssayNat_InstrumentID = ?
|
||||
and M_InstrumentAssayIsActive = 'Y'
|
||||
and (
|
||||
T_TestT_SampleTypeID = ? or
|
||||
fn_sampletype_from_local(T_TestNat_TestID) = ?
|
||||
)
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailT_TestID = T_TestID and T_OrderDetailIsActive = 'Y'
|
||||
join t_orderdetailaddon on T_OrderDetailID = T_OrderDetailAddOnT_OrderDetailID
|
||||
left join nat_instrument on T_OrderDetailAddOnRunNat_InstrumentID = Nat_InstrumentID
|
||||
";
|
||||
$qry = $this->db->query($sql, [
|
||||
$instrumentID,
|
||||
$sampleTypeID,
|
||||
$sampleTypeID,
|
||||
$orderHeaderID,
|
||||
]);
|
||||
|
||||
if (!$qry) {
|
||||
echo "ERR select Assay :\n";
|
||||
$this->query_error();
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "No Assay.";
|
||||
echo "<pre>" . $this->db->last_query() . "</pre>";
|
||||
exit();
|
||||
}
|
||||
$f = array_keys($rows[0]);
|
||||
$this->print_table($rows, $f);
|
||||
}
|
||||
}
|
||||
135
application/controllers/fix/Merujuk.php
Normal file
135
application/controllers/fix/Merujuk.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
class Merujuk extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
function index() {
|
||||
echo "Double Check Rujukan";
|
||||
}
|
||||
function verify() {
|
||||
$sql = "select * from m_branch where M_BranchIsDefault = 'Y' and M_BranchIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql,$date);
|
||||
if (! $qry) {
|
||||
echo "Err :" ; print_r($this->db->error()); exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
echo "Err : No Branch.";
|
||||
exit;
|
||||
}
|
||||
$branchCode = $rows[0]["M_BranchCode"];
|
||||
$branchName = $rows[0]["M_BranchName"];
|
||||
$prm = $this->sys_input;
|
||||
$originBranch = $prm["branchCode"];
|
||||
$s_order = "'0x0'";
|
||||
$result = array();
|
||||
foreach($prm["order"] as $d) {
|
||||
if($s_order != "" ) $s_order .= ",";
|
||||
$s_order .= "'" . $d . "'";
|
||||
$result[$d] = array("Tx" => "Y" , "Rx" => "N");
|
||||
}
|
||||
$sql = "select * from incoming_ref where incomingRefOriginM_BranchCode=?
|
||||
and incomingRefT_RefDeliveryOrderNumber in ( $s_order ) ";
|
||||
$qry = $this->db->query($sql, array($originBranch));
|
||||
if (! $qry ) {
|
||||
echo json_encode(array("status" => "ERR" , "message" => print_r($this->db->error(),true)));
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$result[$r["incomingRefT_RefDeliveryOrderNumber"]]["Rx"] = "Y";
|
||||
}
|
||||
echo json_encode( array("status"=>"OK" , "branchName" => $branchName, "data" => $result));
|
||||
}
|
||||
function cek($date = "") {
|
||||
if ($date == "" ) $date = date("Y-m-d");
|
||||
$sql = "select * from m_branch where M_BranchIsDefault = 'Y' and M_BranchIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db->query($sql,$date);
|
||||
if (! $qry) {
|
||||
echo "Err :" ; print_r($this->db->error()); exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
echo "Err : No Branch.";
|
||||
exit;
|
||||
}
|
||||
$branchCode = $rows[0]["M_BranchCode"];
|
||||
$sql = "select group_concat(T_RefDeliveryOrderNumber separator '^') as Nomor,
|
||||
M_BranchIPAddress
|
||||
from t_ref_deliveryorder
|
||||
join m_branch on T_RefDeliveryOrderM_DestinationID = M_BranchID
|
||||
where T_RefDeliveryOrderIsActive = 'Y' and
|
||||
(T_RefDeliveryOrderIsConfirm = 'S' )
|
||||
and (
|
||||
date(T_RefDeliveryOrderLastUpdated) = ?
|
||||
)
|
||||
group by M_BranchCode
|
||||
limit 0,50
|
||||
";
|
||||
$qry = $this->db->query($sql,$date);
|
||||
if (! $qry) {
|
||||
echo "Err :" ; print_r($this->db->error()); exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$ip_address = $r["M_BranchIPAddress"];
|
||||
$a_nomor = explode("^",$r["Nomor"]);
|
||||
$url = "http://$ip_address/one-api/fix/merujuk/verify";
|
||||
$date = date("Y-m-d H:i:s");
|
||||
echo "\n$date Check : $url\n";
|
||||
$param = json_encode( array("branchCode" => $branchCode , "order" => $a_nomor));
|
||||
$result = $this->post($url,$param);
|
||||
$j_result = json_decode($result,true);
|
||||
if (! $j_result ) {
|
||||
echo "\t $result\n";
|
||||
continue;
|
||||
}
|
||||
if ($j_result["status"] == "ERR" ) {
|
||||
echo "\t {$j_result['message']}\n";
|
||||
continue;
|
||||
}
|
||||
echo "\t {$j_result['branchName']}\n";
|
||||
foreach($a_nomor as $n) {
|
||||
if ($j_result["data"][$n]["Rx"] == "N" ) {
|
||||
$sql = "select * from t_ref_deliveryorder where T_RefDeliveryOrderNumber= '$n'";
|
||||
$qry = $this->db->query($sql);
|
||||
$xid = 0;
|
||||
$xstatus = "";
|
||||
if ($qry) {
|
||||
$xrows = $qry->result_array();
|
||||
if(count($xrows) > 0 ) {
|
||||
$xid = $xrows[0]["T_RefDeliveryOrderID"];
|
||||
$xstatus = $xrows[0]["T_RefDeliveryOrderIsConfirm"];
|
||||
$sql = "update t_ref_deliveryorder set T_RefDeliveryOrderIsConfirm = 'Y' where T_RefDeliveryOrderID = $xid";
|
||||
$this->db->query($sql);
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
echo "\t{$n} sent not received | $xid | $xstatus \n";
|
||||
} else {
|
||||
if ($j_result["data"][$n]["Rx"] == "Y" ) {
|
||||
echo "\t{$n} sent received\n";
|
||||
} else {
|
||||
echo "\t{$n} sent not received\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_VERBOSE, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
//echo "RST : $result ";
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
150
application/controllers/fix/Mobile_check.php
Normal file
150
application/controllers/fix/Mobile_check.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
class Mobile_check extends MY_Controller
|
||||
{
|
||||
function index()
|
||||
{
|
||||
global $_SERVER;
|
||||
$this->print_table_style();
|
||||
//ping
|
||||
$origin = $_SERVER["SERVER_NAME"];
|
||||
$rows = [];
|
||||
$rows[] = ["host" => "Server $origin"];
|
||||
$this->print_table($rows,array_keys($rows[0]),"Origin");
|
||||
|
||||
$output = [];
|
||||
exec("ping -c 3 mobile.pramita.co.id",$output,$result_code);
|
||||
$rows = [];
|
||||
$rows[] = ["Ping Test to mobile.pramita.co.id" => "Result Code : $result_code"];
|
||||
$rows[] = ["Ping Test to mobile.pramita.co.id" =>
|
||||
implode("<br/>",$output)];
|
||||
$this->print_table($rows,array_keys($rows[0]));
|
||||
//curl to mobile.pramita.co.id
|
||||
echo "<br/>";
|
||||
$resp = $this->post("https://mobile.pramita.co.id/one-api/info","");
|
||||
$this->print_table([$resp], array_keys($resp), "curl https://mobile.pramita.co.id/one-api/info");
|
||||
$rows = $this->get_heartbeat();
|
||||
echo "<br/>";
|
||||
$this->print_table($rows,array_keys($rows[0]),"Last HeartBeat status");
|
||||
echo "<br/>";
|
||||
$rows = $this->get_upload();
|
||||
$this->print_table($rows,array_keys($rows[0]),"Last Post Back status");
|
||||
}
|
||||
function get_upload() {
|
||||
$sql = "select distinct pbUploadCode,pbUploadExecuted from pb_upload";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "Error Get Poll Back status : " . $this->db->error()["message"];
|
||||
return [];
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
return $rows;
|
||||
}
|
||||
function get_heartbeat() {
|
||||
$sql = "select distinct heartbeatCode,heartbeatExecuted,heartbeatStatus from regonline.heartbeat";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "Error Get HeartBeat status : " . $ths->db->error()["message"];
|
||||
return [];
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $idx => $r) {
|
||||
switch($r["heartbeatCode"]) {
|
||||
case "CAROUSEL" :
|
||||
$rows[$idx]["heartbeatCode"] = "Caraousel";
|
||||
break;
|
||||
case "PING" :
|
||||
$rows[$idx]["heartbeatCode"] = "Ping";
|
||||
break;
|
||||
case "SWAB" :
|
||||
$rows[$idx]["heartbeatCode"] = "Schedule";
|
||||
break;
|
||||
case "QUOTA_PCR":
|
||||
$rows[$idx]["heartbeatCode"] = "Quota";
|
||||
break;
|
||||
case "PRICE_PACKET":
|
||||
$rows[$idx]["heartbeatCode"] = "Price and Agreement";
|
||||
break;
|
||||
case "HS":
|
||||
case "MOU_REG":
|
||||
case "ORDER_BRANCH":
|
||||
unset($rows[$idx]);
|
||||
break;
|
||||
case "BEST_SELLER":
|
||||
$rows[$idx]["heartbeatCode"] = "Best Seller";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
public 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_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
));
|
||||
$z_result = curl_exec($ch);
|
||||
if (curl_errno($ch) > 0) {
|
||||
return array(
|
||||
"status" => "ERR",
|
||||
"message" => curl_error($ch)
|
||||
);
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode != 200) {
|
||||
return array(
|
||||
"status" => "ERR",
|
||||
"message" => "Http Response : $httpCode | $z_result"
|
||||
);
|
||||
}
|
||||
$j_result = ["status" => "OK", "message" => "Connection OK"];
|
||||
return $j_result;
|
||||
}
|
||||
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table($rows, $keys, $title = false)
|
||||
{
|
||||
echo "<table>";
|
||||
if ($title) {
|
||||
$col_span = count($keys);
|
||||
echo "<tr>";
|
||||
echo "<th colspan=$col_span>$title</th>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
240
application/controllers/fix/Mobile_report.php
Normal file
240
application/controllers/fix/Mobile_report.php
Normal file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
class Mobile_report extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo ".: Mobile Report Check :.";
|
||||
}
|
||||
function info($nolab) {
|
||||
$sql = "select T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderLabNumberExt, T_OrderHeaderID,
|
||||
T_OnlineOrderID, T_OnlineOrderT_OrderID,
|
||||
T_OnlineTxOrgID, max(Result_ProcessToOfficeLastUpdated) maxDate ,
|
||||
max(T_OrderHeaderAddonReadyPrintDate) maxPrintDate,
|
||||
pbUploadExecuted,
|
||||
T_OrderHeaderM_PatientID
|
||||
from t_onlineorder
|
||||
join t_onlinetx on T_OnlineOrderT_OnlineTxID = T_OnlineTxID
|
||||
and T_OnlineOrderIsActive = 'Y'
|
||||
and T_OnlineTxIsActive = 'Y'
|
||||
and T_OnlineOrderUploaded is not null
|
||||
join t_orderheader
|
||||
on T_OnlineOrderT_OrderHeaderID = T_OrderHeaderID
|
||||
and date(T_OrderHeaderDate) >= '2021-12-13'
|
||||
and T_OrderHeaderLabNumber = ?
|
||||
join t_orderheaderaddon on T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
||||
join pb_upload
|
||||
on pbUploadCode = 'RESULT'
|
||||
join result_processtooffice on
|
||||
Result_ProcessToOfficeT_OrderHeaderID = T_OrderHeaderID
|
||||
and Result_ProcessToOfficeIsActive = 'Y'
|
||||
group by T_OrderHeaderID
|
||||
"; $qry = $this->db->query($sql,[$nolab]);
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo $this->db->last_query();
|
||||
echo "No record";
|
||||
exit;
|
||||
}
|
||||
$maxDate = $rows[0]["maxDate"];
|
||||
|
||||
$this->print_table_style();
|
||||
$this->print_table($rows,array_keys($rows[0]));
|
||||
if (count($rows)>0) {
|
||||
$res = $this->get_report($rows[0]["T_OrderHeaderID"]);
|
||||
if(count($res) > 0 ) {
|
||||
$encDate= bin2hex($maxDate);
|
||||
$url_fix = "/one-api/fix/mobile_report/force/" . $encDate . "/$nolab";
|
||||
|
||||
echo "<br/><button onClick=\"document.location.href='$url_fix'\">Force Upload</button>";
|
||||
}
|
||||
}
|
||||
}
|
||||
function force($encDate,$nolab) {
|
||||
$maxDate = hex2bin($encDate);
|
||||
$newMax = date("Y-m-d H:i:s", strtotime($maxDate . " - 1 hour"));
|
||||
$sql = "update pb_upload set pbUploadExecuted = ? where pbUploadCode ='RESULT'";
|
||||
$qry = $this->db->query($sql,[$newMax]);
|
||||
if(!$qry){
|
||||
echo "ERR : " . $this->db->error()["message"];
|
||||
exit;
|
||||
}
|
||||
header("Location: /one-api/fix/mobile_report/info/$nolab");
|
||||
}
|
||||
function get_report($headerID)
|
||||
{
|
||||
$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'),'%')
|
||||
group by Group_ResultID";
|
||||
$qry = $this->db->query($sql, [$headerID]);
|
||||
if (!$qry) {
|
||||
echo "{$this->now()} Error Ger Report : " .
|
||||
$this->db->error()["message"] .
|
||||
"|\n" .
|
||||
$this->db->last_query() .
|
||||
" \n";
|
||||
return [];
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$ts = "&ts=" . date("Ymdhis");
|
||||
$id = $headerID;
|
||||
$result = [];
|
||||
|
||||
foreach ($rows as $r) {
|
||||
$xname = $r["Group_ResultName"];
|
||||
$name = $this->escape_fname($xname);
|
||||
$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;
|
||||
}
|
||||
$result[] = ["Group_ResultName" => $xname, "url_rpt" => $report];
|
||||
}
|
||||
$this->print_table($result,array_keys($result[0]));
|
||||
return $result;
|
||||
}
|
||||
|
||||
function escape_fname($xname)
|
||||
{
|
||||
$find = [" ", "&", '\r\n', '\n', "+", ","];
|
||||
$xname = str_replace($find, "-", $xname);
|
||||
|
||||
//delete and replace rest of special chars
|
||||
$find = ["/[^a-zA-Z0-9\-<>]/", "/[\-]+/", "/<[^>]*>/"];
|
||||
$repl = ["", "-", ""];
|
||||
$xname = preg_replace($find, $repl, $xname);
|
||||
return $xname;
|
||||
}
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table($rows, $keys)
|
||||
{
|
||||
$this->print_table_style();
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
}
|
||||
180
application/controllers/fix/Perubahan_sample.php
Normal file
180
application/controllers/fix/Perubahan_sample.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
class Perubahan_sample extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function get_rows($sql, $prm = false)
|
||||
{
|
||||
}
|
||||
function index()
|
||||
{
|
||||
}
|
||||
public function cek($day = 7)
|
||||
{
|
||||
$sql = "select
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber,
|
||||
T_OrderSampleT_SampleTypeID,
|
||||
T_OrderSampleSamplingDate,
|
||||
T_OrderSampleSamplingTime,
|
||||
T_OrderSampleReceiveDate,
|
||||
T_OrderSampleReceiveTime,
|
||||
T_SampleTypeName,
|
||||
T_OrderSampleID,
|
||||
T_SampleTypeName,
|
||||
T_OrderSampleIsActive
|
||||
from
|
||||
t_orderheader
|
||||
join t_ordersample on T_OrderHeaderID = T_OrderSampleT_OrderHeaderID
|
||||
and T_OrderSampleT_SampleTypeID in ( 122, 259 )
|
||||
and T_OrderHeaderID in
|
||||
(
|
||||
select
|
||||
distinct T_OrderSampleT_OrderHeaderID
|
||||
from
|
||||
t_ordersample
|
||||
join t_orderheader on T_OrderSampleT_OrderHeaderID = T_OrderHeaderID
|
||||
and T_OrderHeaderDate + interval $day day > now()
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderSampleT_SampleTypeID = 259
|
||||
)
|
||||
join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID
|
||||
order by T_OrderHeaderID,T_OrderSampleT_SampleTypeID";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "ERR : " . $this->db->error()["message"] . "|" . $this->db->last_query();
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$order_122 = array_filter(
|
||||
$rows,
|
||||
function ($r) {
|
||||
return $r["T_OrderSampleT_SampleTypeID"] == 122;
|
||||
}
|
||||
);
|
||||
$dup_order = [];
|
||||
foreach ($order_122 as $r) {
|
||||
$dup_order[] = $r["T_OrderHeaderID"];
|
||||
}
|
||||
|
||||
$dup_rows = array_filter($rows, function ($r) use ($dup_order, $order_122) {
|
||||
if ($r["T_OrderSampleT_SampleTypeID"] != 259) return false;
|
||||
if (in_array($r["T_OrderHeaderID"], $dup_order)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
$dup_rows = array_map(function ($r) use ($order_122) {
|
||||
$result = $r;
|
||||
foreach ($order_122 as $r2) {
|
||||
if ($r["T_OrderHeaderID"] == $r2["T_OrderHeaderID"]) {
|
||||
$result["OrgT_OrderSampleID"] = $r2["T_OrderSampleID"];
|
||||
$result["OrgT_OrderSampleReceiveDate"] = $r2["T_OrderSampleReceiveDate"];
|
||||
$result["OrgT_OrderSampleReceiveTime"] = $r2["T_OrderSampleReceiveTime"];
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}, $dup_rows);
|
||||
|
||||
$this->header();
|
||||
usort($dup_rows, function ($a, $b) {
|
||||
return $a["T_OrderHeaderID"] - $b["T_OrderHeaderID"];
|
||||
});
|
||||
$total_diff = 0;
|
||||
foreach ($dup_rows as $r) {
|
||||
$sampling_date = $r["T_OrderSampleReceiveDate"] . " " . $r["T_OrderSampleReceiveTime"];
|
||||
$org_sampling_date = $r["OrgT_OrderSampleReceiveDate"] . " " . $r["OrgT_OrderSampleReceiveTime"];
|
||||
|
||||
if ($sampling_date != "" && $sampling_date > $org_sampling_date) {
|
||||
$total_diff++;
|
||||
}
|
||||
}
|
||||
echo "<tr><td colspan=4> Total : <b>$total_diff</b> dari " . count($dup_rows)
|
||||
. " ($day hari terakhir) </td>\n";
|
||||
foreach ($dup_rows as $r) {
|
||||
$this->detail($r);
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
function do_ubah($targetID, $sourceID)
|
||||
{
|
||||
//harus di null kan dulu
|
||||
|
||||
$sql = "update t_ordersample
|
||||
set
|
||||
T_OrderSampleReceiveDate = NULL,
|
||||
T_OrderSampleReceiveTime = NULL,
|
||||
T_OrderSampleReceive = 'N'
|
||||
where T_OrderSampleID = $targetID
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "ERR : " . $this->db->error()["message"] . "|" . $this->db->last_query();
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update t_ordersample target, t_ordersample source
|
||||
set
|
||||
target.T_OrderSampleSampling = source.T_OrderSampleSampling,
|
||||
target.T_OrderSampleSamplingDate = source.T_OrderSampleSamplingDate,
|
||||
target.T_OrderSampleSamplingTime = source.T_OrderSampleSamplingTime,
|
||||
target.T_OrderSampleSamplingUserID = source.T_OrderSampleSamplingUserID,
|
||||
target.T_OrderSampleReceive = source.T_OrderSampleReceive,
|
||||
target.T_OrderSampleReceiveDate = source.T_OrderSampleReceiveDate,
|
||||
target.T_OrderSampleReceiveTime = source.T_OrderSampleReceiveTime,
|
||||
target.T_OrderSampleReceiveUserID = source.T_OrderSampleReceiveUserID
|
||||
where target.T_OrderSampleID = $targetID and source.T_OrderSampleID = $sourceID
|
||||
and $targetID > $sourceID
|
||||
and source.T_OrderSampleSampling = 'Y'
|
||||
and source.T_OrderSampleReceive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "ERR : " . $this->db->error()["message"] . "|" . $this->db->last_query();
|
||||
exit;
|
||||
}
|
||||
echo "Sampling Time Updated.";
|
||||
echo "<script>document.location.href='/one-api/fix/perubahan_sample/cek'</script>";
|
||||
}
|
||||
function detail($r)
|
||||
{
|
||||
$sampling_date = $r["T_OrderSampleReceiveDate"] . " " . $r["T_OrderSampleReceiveTime"];
|
||||
$org_sampling_date = $r["OrgT_OrderSampleReceiveDate"] . " " . $r["OrgT_OrderSampleReceiveTime"];
|
||||
echo "<tr>";
|
||||
echo "<td>" . $r["T_OrderHeaderLabNumber"] . "</td>";
|
||||
echo "<td> $sampling_date </td>";
|
||||
if ($sampling_date > $org_sampling_date) {
|
||||
$url_ubah = "window.location.href='./do_ubah/" . $r["T_OrderSampleID"] . "/" . $r["OrgT_OrderSampleID"] . "'";
|
||||
echo "<td> <button onClick=\"$url_ubah\">Ubah sesuai origin => </td> </td>";
|
||||
} else {
|
||||
echo "<td> </td>";
|
||||
}
|
||||
echo "<td> $org_sampling_date </td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
function header()
|
||||
{
|
||||
echo '<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
';
|
||||
echo '<table>';
|
||||
echo '<tr>';
|
||||
echo "<td>Lab No.</td>
|
||||
<td>Sampling Rcv Date</td>
|
||||
<td> === </td>
|
||||
<td>Sampling Rcv Date Origin</td>
|
||||
</tr>\n";
|
||||
}
|
||||
}
|
||||
542
application/controllers/fix/Pktbruto-cimahi.php
Normal file
542
application/controllers/fix/Pktbruto-cimahi.php
Normal file
@@ -0,0 +1,542 @@
|
||||
<?php
|
||||
class PktBruto extends CI_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function fix_tprice($mouID,$testID) {
|
||||
$sql = "select * from t_price where T_PriceM_MouID = ? and T_PriceT_TestID = ? and T_PriceIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, array($mouID, $testID) );
|
||||
if ( !$qry ) {
|
||||
return false;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$len = count($rows);
|
||||
if ($len > 0 ) {
|
||||
$amount = $rows[0]["T_PriceAmount"];
|
||||
$disc= $rows[0]["T_PriceDisc"];
|
||||
$discRp= $rows[0]["T_PriceDiscRp"];
|
||||
$subtotal = $rows[0]["T_PriceSubTotal"];
|
||||
$total = $rows[0]["T_PriceTotal"];
|
||||
return $rows[0];
|
||||
}
|
||||
}
|
||||
function cekmou($mouID) {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketM_MouID = $mouID and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
echo "\n ---------------\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "\n $paket_name : \n";
|
||||
foreach($ct as $idx => $t) {
|
||||
$test_name = $t["T_TestName"];
|
||||
$testid = $t["T_TestID"];
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$disc = $t["T_PriceDisc"];
|
||||
$discRp = $t["T_PriceDiscRp"];
|
||||
$subtotal = $t["T_PriceSubTotal"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
echo "\t $test_name : amount : $amount , disc : $disc , discRp : $discRp, subtotal : $subtotal => $total\n";
|
||||
$this->tprice($mouID,$testid);
|
||||
}
|
||||
}
|
||||
}
|
||||
function fixmou($mouID) {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketM_MouID= $mouID and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$sql_u = "update ss_price_mou set child_test = ? where Ss_PriceMouID = ?";
|
||||
foreach($rows as $r) {
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
echo "\n ---------------\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "\n $paket_name : \n";
|
||||
foreach($ct as $idx => $t) {
|
||||
$test_name = $t["T_TestName"];
|
||||
$testid = $t["T_TestID"];
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$disc = $t["T_PriceDisc"];
|
||||
$discRp = $t["T_PriceDiscRp"];
|
||||
$subtotal = $t["T_PriceSubTotal"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
$tprice = $this->fix_tprice($mouID,$testid);
|
||||
$ct[$idx]["T_PriceAmount"] = $tprice["T_PriceAmount"];
|
||||
$ct[$idx]["T_PriceDisc"] = $tprice["T_PriceDisc"];
|
||||
$ct[$idx]["T_PriceDiscRp"] = $tprice["T_PriceDiscRp"];
|
||||
$ct[$idx]["T_PriceSubTotal"] = $tprice["T_PriceSubTotal"];
|
||||
$ct[$idx]["T_PriceTotal"] = $tprice["T_PriceTotal"];
|
||||
}
|
||||
$j_ct = json_encode($ct);
|
||||
$qry = $this->db->query($sql_u, array($j_ct, $ssPriceMouID));
|
||||
if (! $qry ) {
|
||||
echo "update Error : " . print_r($this->db->error(),true) . "\n";
|
||||
} else {
|
||||
echo "update OK\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
function fix() {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketOriginalBruto = 0 and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$sql_u = "update ss_price_mou set child_test = ? where Ss_PriceMouID = ?";
|
||||
foreach($rows as $r) {
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
echo "\n ---------------\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "\n $paket_name : \n";
|
||||
foreach($ct as $idx => $t) {
|
||||
$test_name = $t["T_TestName"];
|
||||
$testid = $t["T_TestID"];
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$disc = $t["T_PriceDisc"];
|
||||
$discRp = $t["T_PriceDiscRp"];
|
||||
$subtotal = $t["T_PriceSubTotal"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
$tprice = $this->fix_tprice($mouID,$testid);
|
||||
$ct[$idx]["T_PriceAmount"] = $tprice["T_PriceAmount"];
|
||||
$ct[$idx]["T_PriceDisc"] = $tprice["T_PriceDisc"];
|
||||
$ct[$idx]["T_PriceDiscRp"] = $tprice["T_PriceDiscRp"];
|
||||
$ct[$idx]["T_PriceSubTotal"] = $tprice["T_PriceSubTotal"];
|
||||
$ct[$idx]["T_PriceTotal"] = $tprice["T_PriceTotal"];
|
||||
}
|
||||
$j_ct = json_encode($ct);
|
||||
$qry = $this->db->query($sql_u, array($j_ct, $ssPriceMouID));
|
||||
if (! $qry ) {
|
||||
echo "update Error : " . print_r($this->db->error(),true) . "\n";
|
||||
} else {
|
||||
echo "update OK\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function cek() {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketOriginalBruto = 0 and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
echo "\n ---------------\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "\n $paket_name : \n";
|
||||
foreach($ct as $idx => $t) {
|
||||
$test_name = $t["T_TestName"];
|
||||
$testid = $t["T_TestID"];
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$disc = $t["T_PriceDisc"];
|
||||
$discRp = $t["T_PriceDiscRp"];
|
||||
$subtotal = $t["T_PriceSubTotal"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
echo "\t $test_name : amount : $amount , disc : $disc , discRp : $discRp, subtotal : $subtotal => $total\n";
|
||||
$this->tprice($mouID,$testid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function cekprofilemou($mouID) {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y' and T_PacketType = 'PR'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketM_MouID = $mouID and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
echo $this->db->last_query();
|
||||
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join t_packet on packet_id = T_PacketID
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$no = 0;
|
||||
foreach($rows as $r) {
|
||||
$no++;
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
|
||||
$originalBruto = 0;
|
||||
$originalPrice = 0;
|
||||
foreach($ct as $idx => $t) {
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
$originalBruto += $amount;
|
||||
$originalPrice += $total;
|
||||
}
|
||||
$amount = $r["T_PriceAmount"];
|
||||
$subtotal = $r["T_PriceSubTotal"];
|
||||
$disc = $r["T_PriceDisc"];
|
||||
$total = $r["T_PriceTotal"];
|
||||
echo "\n ---------------\n";
|
||||
echo "NO : $no\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "$paket_name : \n";
|
||||
echo "\t Amount : $amount, disc : $disc ,subtotal : $subtotal => $total\n";
|
||||
echo "\t Fix \n ";
|
||||
$disc = $originalBruto - $originalPrice;
|
||||
echo "\t Amount : $originalBruto, disc : $disc ,subtotal : $originalPrice => $originalPrice\n";
|
||||
|
||||
}
|
||||
}
|
||||
function cekpanelmou($mouID) {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y' and T_PacketType = 'PN'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketM_MouID = $mouID and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
echo $this->db->last_query();
|
||||
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join t_packet on packet_id = T_PacketID
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$no = 0;
|
||||
foreach($rows as $r) {
|
||||
$no++;
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
|
||||
$originalBruto = 0;
|
||||
$originalPrice = 0;
|
||||
foreach($ct as $idx => $t) {
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
$originalBruto += $amount;
|
||||
$originalPrice += $total;
|
||||
}
|
||||
$amount = $r["T_PriceAmount"];
|
||||
$subtotal = $r["T_PriceSubTotal"];
|
||||
$disc = $r["T_PriceDisc"];
|
||||
$total = $r["T_PriceTotal"];
|
||||
echo "\n ---------------\n";
|
||||
echo "NO : $no\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "$paket_name : \n";
|
||||
echo "\t Amount : $amount, disc : $disc ,subtotal : $subtotal => $total\n";
|
||||
echo "\t Fix \n ";
|
||||
$disc = $originalBruto - $originalPrice;
|
||||
echo "\t Amount : $originalBruto, disc : $disc ,subtotal : $originalPrice => $originalPrice\n";
|
||||
|
||||
}
|
||||
}
|
||||
function cekpanel() {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y' and T_PacketType = 'PN'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketOriginalBruto = 0 and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join t_packet on packet_id = T_PacketID
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$no = 0;
|
||||
foreach($rows as $r) {
|
||||
$no++;
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
|
||||
$originalBruto = 0;
|
||||
$originalPrice = 0;
|
||||
foreach($ct as $idx => $t) {
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
$originalBruto += $amount;
|
||||
$originalPrice += $total;
|
||||
}
|
||||
$amount = $r["T_PriceAmount"];
|
||||
$subtotal = $r["T_PriceSubTotal"];
|
||||
$disc = $r["T_PriceDisc"];
|
||||
$total = $r["T_PriceTotal"];
|
||||
echo "\n ---------------\n";
|
||||
echo "NO : $no\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "$paket_name : \n";
|
||||
echo "\t Amount : $amount, disc : $disc ,subtotal : $subtotal => $total\n";
|
||||
echo "\t Fix \n ";
|
||||
$disc = $originalBruto - $originalPrice;
|
||||
echo "\t Amount : $originalBruto, disc : $disc ,subtotal : $originalPrice => $originalPrice\n";
|
||||
|
||||
}
|
||||
}
|
||||
function fixpanel() {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y' and T_PacketType = 'PN'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketOriginalBruto = 0 and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join t_packet on packet_id = T_PacketID
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$no = 0;
|
||||
$sql_u = "update ss_price_mou set T_PriceAmount = ?,
|
||||
T_PriceDiscRp = ?, T_PriceSubTotal = ?
|
||||
where Ss_PriceMouID = ?";
|
||||
foreach($rows as $r) {
|
||||
$no++;
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
|
||||
$originalBruto = 0;
|
||||
$originalPrice = 0;
|
||||
foreach($ct as $idx => $t) {
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
$originalBruto += $amount;
|
||||
$originalPrice += $total;
|
||||
}
|
||||
$amount = $r["T_PriceAmount"];
|
||||
$subtotal = $r["T_PriceSubTotal"];
|
||||
$disc = $r["T_PriceDisc"];
|
||||
$total = $r["T_PriceTotal"];
|
||||
echo "\n ---------------\n";
|
||||
echo "NO : $no\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "$paket_name : \n";
|
||||
echo "\t Amount : $amount, disc : $disc ,subtotal : $subtotal => $total\n";
|
||||
echo "\t Fix \n ";
|
||||
$disc = $originalBruto - $originalPrice;
|
||||
echo "\t Amount : $originalBruto, disc : $disc ,subtotal : $originalPrice => $originalPrice\n";
|
||||
$qry = $this->db->query($sql_u, array($originalBruto, $disc, $originalPrice, $ssPriceMouID));
|
||||
if (! $qry ) {
|
||||
echo "update ERR : " . print_r($this->db->error(), true) . "\n";
|
||||
} else {
|
||||
echo "update OK\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
function tprice($mouID,$testID) {
|
||||
$sql = "select * from t_price where T_PriceM_MouID = ? and T_PriceT_TestID = ? and T_PriceIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, array($mouID, $testID) );
|
||||
if ( !$qry ) {
|
||||
echo "\t Error get T_Price : " . print_r($this->db->error(),true);
|
||||
return;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$len = count($rows);
|
||||
echo "\t[ $len ] T_Price : ";
|
||||
if ($len > 0 ) {
|
||||
$amount = $rows[0]["T_PriceAmount"];
|
||||
$disc= $rows[0]["T_PriceDisc"];
|
||||
$discRp= $rows[0]["T_PriceDiscRp"];
|
||||
$subtotal = $rows[0]["T_PriceSubTotal"];
|
||||
$total = $rows[0]["T_PriceTotal"];
|
||||
echo "\t amount : $amount , disc : $disc , discRp : $discRp, subtotal : $subtotal => $total\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
478
application/controllers/fix/Pktbruto.php
Normal file
478
application/controllers/fix/Pktbruto.php
Normal file
@@ -0,0 +1,478 @@
|
||||
<?php
|
||||
class PktBruto extends CI_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function fix_tprice($mouID,$testID) {
|
||||
$sql = "select * from t_price where T_PriceM_MouID = ? and T_PriceT_TestID = ? and T_PriceIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, array($mouID, $testID) );
|
||||
if ( !$qry ) {
|
||||
return false;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$len = count($rows);
|
||||
if ($len > 0 ) {
|
||||
$amount = $rows[0]["T_PriceAmount"];
|
||||
$disc= $rows[0]["T_PriceDisc"];
|
||||
$discRp= $rows[0]["T_PriceDiscRp"];
|
||||
$subtotal = $rows[0]["T_PriceSubTotal"];
|
||||
$total = $rows[0]["T_PriceTotal"];
|
||||
return $rows[0];
|
||||
}
|
||||
}
|
||||
function cekmou($mouID) {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketM_MouID = $mouID and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
echo $this->db->last_query();
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
echo "\n ---------------\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "\n $paket_name : \n";
|
||||
foreach($ct as $idx => $t) {
|
||||
$test_name = $t["T_TestName"];
|
||||
$testid = $t["T_TestID"];
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$disc = $t["T_PriceDisc"];
|
||||
$discRp = $t["T_PriceDiscRp"];
|
||||
$subtotal = $t["T_PriceSubTotal"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
echo "\t $test_name : amount : $amount , disc : $disc , discRp : $discRp, subtotal : $subtotal => $total\n";
|
||||
$this->tprice($mouID,$testid);
|
||||
}
|
||||
}
|
||||
}
|
||||
function fixmou($mouID) {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketM_MouID= $mouID and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$sql_u = "update ss_price_mou set child_test = ? where Ss_PriceMouID = ?";
|
||||
foreach($rows as $r) {
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
echo "\n ---------------\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "\n $paket_name : \n";
|
||||
foreach($ct as $idx => $t) {
|
||||
$test_name = $t["T_TestName"];
|
||||
$testid = $t["T_TestID"];
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$disc = $t["T_PriceDisc"];
|
||||
$discRp = $t["T_PriceDiscRp"];
|
||||
$subtotal = $t["T_PriceSubTotal"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
$tprice = $this->fix_tprice($mouID,$testid);
|
||||
$ct[$idx]["T_PriceAmount"] = $tprice["T_PriceAmount"];
|
||||
$ct[$idx]["T_PriceDisc"] = $tprice["T_PriceDisc"];
|
||||
$ct[$idx]["T_PriceDiscRp"] = $tprice["T_PriceDiscRp"];
|
||||
$ct[$idx]["T_PriceSubTotal"] = $tprice["T_PriceSubTotal"];
|
||||
$ct[$idx]["T_PriceTotal"] = $tprice["T_PriceTotal"];
|
||||
}
|
||||
$j_ct = json_encode($ct);
|
||||
$qry = $this->db->query($sql_u, array($j_ct, $ssPriceMouID));
|
||||
if (! $qry ) {
|
||||
echo "update Error : " . print_r($this->db->error(),true) . "\n";
|
||||
} else {
|
||||
echo "update OK\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
function fix() {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketOriginalBruto = 0 and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$sql_u = "update ss_price_mou set child_test = ? where Ss_PriceMouID = ?";
|
||||
foreach($rows as $r) {
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
echo "\n ---------------\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "\n $paket_name : \n";
|
||||
foreach($ct as $idx => $t) {
|
||||
$test_name = $t["T_TestName"];
|
||||
$testid = $t["T_TestID"];
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$disc = $t["T_PriceDisc"];
|
||||
$discRp = $t["T_PriceDiscRp"];
|
||||
$subtotal = $t["T_PriceSubTotal"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
$tprice = $this->fix_tprice($mouID,$testid);
|
||||
$ct[$idx]["T_PriceAmount"] = $tprice["T_PriceAmount"];
|
||||
$ct[$idx]["T_PriceDisc"] = $tprice["T_PriceDisc"];
|
||||
$ct[$idx]["T_PriceDiscRp"] = $tprice["T_PriceDiscRp"];
|
||||
$ct[$idx]["T_PriceSubTotal"] = $tprice["T_PriceSubTotal"];
|
||||
$ct[$idx]["T_PriceTotal"] = $tprice["T_PriceTotal"];
|
||||
}
|
||||
$j_ct = json_encode($ct);
|
||||
$qry = $this->db->query($sql_u, array($j_ct, $ssPriceMouID));
|
||||
if (! $qry ) {
|
||||
echo "update Error : " . print_r($this->db->error(),true) . "\n";
|
||||
} else {
|
||||
echo "update OK\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function cek() {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketOriginalBruto = 0 and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
echo "\n ---------------\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "\n $paket_name : \n";
|
||||
foreach($ct as $idx => $t) {
|
||||
$test_name = $t["T_TestName"];
|
||||
$testid = $t["T_TestID"];
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$disc = $t["T_PriceDisc"];
|
||||
$discRp = $t["T_PriceDiscRp"];
|
||||
$subtotal = $t["T_PriceSubTotal"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
echo "\t $test_name : amount : $amount , disc : $disc , discRp : $discRp, subtotal : $subtotal => $total\n";
|
||||
$this->tprice($mouID,$testid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function cekpanelmou($mouID) {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y' and T_PacketType = 'PN'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketM_MouID = $mouID and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
echo $this->db->last_query();
|
||||
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join t_packet on packet_id = T_PacketID
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$no = 0;
|
||||
foreach($rows as $r) {
|
||||
$no++;
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
|
||||
$originalBruto = 0;
|
||||
$originalPrice = 0;
|
||||
foreach($ct as $idx => $t) {
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
$originalBruto += $amount;
|
||||
$originalPrice += $total;
|
||||
}
|
||||
$amount = $r["T_PriceAmount"];
|
||||
$subtotal = $r["T_PriceSubTotal"];
|
||||
$disc = $r["T_PriceDisc"];
|
||||
$total = $r["T_PriceTotal"];
|
||||
echo "\n ---------------\n";
|
||||
echo "NO : $no\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "$paket_name : \n";
|
||||
echo "\t Amount : $amount, disc : $disc ,subtotal : $subtotal => $total\n";
|
||||
echo "\t Fix \n ";
|
||||
$disc = $originalBruto - $originalPrice;
|
||||
echo "\t Amount : $originalBruto, disc : $disc ,subtotal : $originalPrice => $originalPrice\n";
|
||||
|
||||
}
|
||||
}
|
||||
function cekpanel() {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y' and T_PacketType = 'PN'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketOriginalBruto = 0 and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join t_packet on packet_id = T_PacketID
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$no = 0;
|
||||
foreach($rows as $r) {
|
||||
$no++;
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
|
||||
$originalBruto = 0;
|
||||
$originalPrice = 0;
|
||||
foreach($ct as $idx => $t) {
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
$originalBruto += $amount;
|
||||
$originalPrice += $total;
|
||||
}
|
||||
$amount = $r["T_PriceAmount"];
|
||||
$subtotal = $r["T_PriceSubTotal"];
|
||||
$disc = $r["T_PriceDisc"];
|
||||
$total = $r["T_PriceTotal"];
|
||||
echo "\n ---------------\n";
|
||||
echo "NO : $no\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "$paket_name : \n";
|
||||
echo "\t Amount : $amount, disc : $disc ,subtotal : $subtotal => $total\n";
|
||||
echo "\t Fix \n ";
|
||||
$disc = $originalBruto - $originalPrice;
|
||||
echo "\t Amount : $originalBruto, disc : $disc ,subtotal : $originalPrice => $originalPrice\n";
|
||||
|
||||
}
|
||||
}
|
||||
function fixpanel() {
|
||||
$sql = "create temporary table xtmp
|
||||
select distinct T_PacketID
|
||||
FROM `t_packet`
|
||||
JOIN m_mou ON T_PacketM_MouID = M_MouID AND M_MouIsActive = 'Y' and T_PacketType = 'PN'
|
||||
JOIN t_packetdetail ON T_PacketID = T_PacketDetailT_PacketID AND T_PacketDetailIsActive = 'Y' AND
|
||||
M_MouIsReleased = 'Y'
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_PacketOriginalBruto = 0 and T_PacketIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$sql = "select ss_price_mou.*, M_CompanyName, M_MouName
|
||||
from ss_price_mou
|
||||
join t_packet on packet_id = T_PacketID
|
||||
join m_mou on Ss_PriceMouM_MouID = M_MouID
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
where is_packet = 'Y' and packet_id in ( select * from xtmp )";
|
||||
$qry = $this->db->query($sql);
|
||||
if ( !$qry ) {
|
||||
echo "ERR : select " . print_r($this->db->error(), true);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$no = 0;
|
||||
$sql_u = "update ss_price_mou set T_PriceAmount = ?,
|
||||
T_PriceDiscRp = ?, T_PriceSubTotal = ?
|
||||
where Ss_PriceMouID = ?";
|
||||
foreach($rows as $r) {
|
||||
$no++;
|
||||
$ssPriceMouID = $r["Ss_PriceMouID"];
|
||||
$paket_name = $r["T_TestName"];
|
||||
$company = $r["M_CompanyName"];
|
||||
$mou_name = $r["M_MouName"];
|
||||
$mouID = $r["Ss_PriceMouM_MouID"];
|
||||
$j_ct = $r["child_test"];
|
||||
$ct = json_decode($j_ct,true);
|
||||
|
||||
$originalBruto = 0;
|
||||
$originalPrice = 0;
|
||||
foreach($ct as $idx => $t) {
|
||||
$amount = $t["T_PriceAmount"];
|
||||
$total = $t["T_PriceTotal"];
|
||||
$originalBruto += $amount;
|
||||
$originalPrice += $total;
|
||||
}
|
||||
$amount = $r["T_PriceAmount"];
|
||||
$subtotal = $r["T_PriceSubTotal"];
|
||||
$disc = $r["T_PriceDisc"];
|
||||
$total = $r["T_PriceTotal"];
|
||||
echo "\n ---------------\n";
|
||||
echo "NO : $no\n";
|
||||
echo "ID : $ssPriceMouID\n";
|
||||
echo "Company : $company\n";
|
||||
echo "Mou : $mou_name\n";
|
||||
echo "$paket_name : \n";
|
||||
echo "\t Amount : $amount, disc : $disc ,subtotal : $subtotal => $total\n";
|
||||
echo "\t Fix \n ";
|
||||
$disc = $originalBruto - $originalPrice;
|
||||
echo "\t Amount : $originalBruto, disc : $disc ,subtotal : $originalPrice => $originalPrice\n";
|
||||
$qry = $this->db->query($sql_u, array($originalBruto, $disc, $originalPrice, $ssPriceMouID));
|
||||
if (! $qry ) {
|
||||
echo "update ERR : " . print_r($this->db->error(), true) . "\n";
|
||||
} else {
|
||||
echo "update OK\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
function tprice($mouID,$testID) {
|
||||
$sql = "select * from t_price where T_PriceM_MouID = ? and T_PriceT_TestID = ? and T_PriceIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, array($mouID, $testID) );
|
||||
if ( !$qry ) {
|
||||
echo "\t Error get T_Price : " . print_r($this->db->error(),true);
|
||||
return;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$len = count($rows);
|
||||
echo "\t[ $len ] T_Price : ";
|
||||
if ($len > 0 ) {
|
||||
$amount = $rows[0]["T_PriceAmount"];
|
||||
$disc= $rows[0]["T_PriceDisc"];
|
||||
$discRp= $rows[0]["T_PriceDiscRp"];
|
||||
$subtotal = $rows[0]["T_PriceSubTotal"];
|
||||
$total = $rows[0]["T_PriceTotal"];
|
||||
echo "\t amount : $amount , disc : $disc , discRp : $discRp, subtotal : $subtotal => $total\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
1810
application/controllers/fix/Pramitalabku.php
Normal file
1810
application/controllers/fix/Pramitalabku.php
Normal file
File diff suppressed because it is too large
Load Diff
248
application/controllers/fix/Pramitalabku_lunas.php
Normal file
248
application/controllers/fix/Pramitalabku_lunas.php
Normal file
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
|
||||
class Pramitalabku_lunas extends MY_Controller
|
||||
{
|
||||
function index()
|
||||
{
|
||||
echo "/check/[date]";
|
||||
echo "\n";
|
||||
}
|
||||
function check($date = "")
|
||||
{
|
||||
if ($date == "") {
|
||||
$date = date("Y-m-d");
|
||||
}
|
||||
|
||||
$this->print_table_style();
|
||||
$sql = "select distinct T_OnlineTxOrgID, T_OnlineTxBookingDate,
|
||||
T_OnlineTxNumbering, T_OnlineTxBookingName,
|
||||
T_OnlineTxPgReference, T_OnlineTxBookingQrCode, T_OnlineTxIsLunas,
|
||||
F_Payment_OrderHeaderIsLunas
|
||||
from t_onlinetx
|
||||
join t_onlineorder on T_OnlineTxID = T_OnlineOrderT_OnlineTxID
|
||||
-- and T_OnlineTxIsLunas = 'Y'
|
||||
and date(T_OnlineTxLastUpdated) = ?
|
||||
join t_orderheader on T_OrderHeaderID = T_OnlineOrderT_OrderHeaderID
|
||||
join f_payment on F_PaymentT_OrderHeaderID = T_OrderHeaderID
|
||||
join f_payment_orderheader on F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
and F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
join f_paymentdetail on F_PaymentID = F_PaymentDetailF_PaymentID
|
||||
and F_PaymentDetailM_PaymentTypeID <> 1000
|
||||
";
|
||||
$qry = $this->db->query($sql, [$date]);
|
||||
if (!$qry) {
|
||||
echo "{$this->now()} ERR Get TxOnineID: {$this->db->error()["message"]}\n";
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "\t No Upload data\n";
|
||||
exit();
|
||||
}
|
||||
|
||||
$new_rows = [];
|
||||
foreach ($rows as $idx => $r) {
|
||||
if ($r["T_OnlineTxPgReference"] != "") continue;
|
||||
$txID = $r["T_OnlineTxOrgID"];
|
||||
$r[
|
||||
"Action"
|
||||
] = "<a href='/one-api/fix/pramitalabku_lunas/fix/$txID'>Re-Upload Status Lunas</a>";
|
||||
unset($r["T_OnlineTxPgReference"]);
|
||||
$new_rows[] = $r;
|
||||
}
|
||||
$this->print_table($new_rows, array_keys($new_rows[0]), "Bayar di Tempat");
|
||||
// belum lunas
|
||||
$sql = "select distinct T_OnlineTxOrgID, T_OnlineTxBookingDate, T_OnlineTxID,
|
||||
T_OnlineTxNumbering, T_OnlineTxBookingName,
|
||||
T_OnlineTxPgReference, T_OnlineTxBookingQrCode, T_OnlineTxIsLunas, T_OrderHeaderID
|
||||
from t_onlinetx
|
||||
join t_onlineorder on T_OnlineTxID = T_OnlineOrderT_OnlineTxID
|
||||
and (
|
||||
date(T_OnlineTxLastUpdated) = ?
|
||||
or
|
||||
date(T_OnlineTxCreated) = ?
|
||||
)
|
||||
join t_orderheader on T_OrderHeaderID = T_OnlineOrderT_OrderHeaderID";
|
||||
$qry = $this->db->query($sql, [$date,$date]);
|
||||
if (!$qry) {
|
||||
echo "{$this->now()} ERR Get TxOnineID: {$this->db->error()["message"]}\n";
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "\t No Upload data\n";
|
||||
exit();
|
||||
}
|
||||
|
||||
$new_rows = [];
|
||||
foreach ($rows as $idx => $r) {
|
||||
if ($r["T_OnlineTxPgReference"] != "") continue;
|
||||
list($is_lunas,$payment_data) = $this->get_payment($r["T_OrderHeaderID"],$r["T_OnlineTxIsLunas"], $r["T_OnlineTxID"]);
|
||||
if ($is_lunas) continue;
|
||||
unset($r["T_OrderHeaderID"]);
|
||||
unset($r["T_OnlineTxID"]);
|
||||
unset($r["T_OnlineTxPgReference"]);
|
||||
$r["Payment"] = $payment_data;
|
||||
$new_rows[] = $r;
|
||||
}
|
||||
echo "<br/>";
|
||||
|
||||
$this->print_table($new_rows, array_keys($new_rows[0]), "Bayar di Tempat <b>Belum Lunas</b>");
|
||||
}
|
||||
|
||||
function get_payment($orderID,$txLunas,$tOnlineTxID) {
|
||||
$sql = "select ifnull(F_Payment_OrderHeaderIsLunas,'N') IsLunas,
|
||||
f_paymentdetail.*
|
||||
from
|
||||
f_payment
|
||||
join f_payment_orderheader on F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
join f_paymentdetail on F_PaymentID = F_PaymentDetailF_PaymentID
|
||||
and F_PaymentT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql,[$orderID]);
|
||||
if (!$qry) {
|
||||
return [false, "Err : " . $this->db->error()["message"]];
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$is_lunas = false;
|
||||
foreach($rows as $r) {
|
||||
if ($r["IsLunas"] == "Y") {
|
||||
$is_lunas = true;
|
||||
}
|
||||
}
|
||||
if ($txLunas == "Y" && !$is_lunas) {
|
||||
$sql = "update t_onlinetx set T_OnlineTxIsLunas = 'N' where T_OnlineTxID = ?";
|
||||
$qry = $this->db->query($sql,[$tOnlineTxID]);
|
||||
if (!$qry) {
|
||||
return [true,"Err Fix TxLunas: " . $this->db->error()["message"] ];
|
||||
}
|
||||
}
|
||||
return [$is_lunas, json_encode($rows,JSON_PRETTY_PRINT)];
|
||||
}
|
||||
function now()
|
||||
{
|
||||
return Date("Y-m-d H:i:s");
|
||||
}
|
||||
function fix($txID)
|
||||
{
|
||||
$sql = "select distinct T_OnlineTxOrgID, T_OnlineTxNumbering, T_OnlineTxBookingName
|
||||
from t_onlinetx
|
||||
join t_onlineorder on T_OnlineTxID = T_OnlineOrderT_OnlineTxID
|
||||
-- and T_OnlineTxIsLunas = 'Y'
|
||||
and T_OnlineTxOrgID = ?
|
||||
join t_orderheader on T_OrderHeaderID = T_OnlineOrderT_OrderHeaderID
|
||||
join f_payment on F_PaymentT_OrderHeaderID = T_OrderHeaderID
|
||||
join f_payment_orderheader on F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
and F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
join f_paymentdetail on F_PaymentID = F_PaymentDetailF_PaymentID
|
||||
and F_PaymentDetailM_PaymentTypeID <> 1000
|
||||
";
|
||||
$qry = $this->db->query($sql, [$txID]);
|
||||
if (!$qry) {
|
||||
echo "{$this->now()} ERR Get TxOnineID: {$this->db->error()["message"]}\n";
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "\t No Upload data\n";
|
||||
exit();
|
||||
}
|
||||
$param = ["data" => $rows];
|
||||
$url =
|
||||
"https://mobile.pramita.co.id/one-api/tools/regonline/r_download/status_lunas";
|
||||
$z_param = gzdeflate(json_encode($param), 9);
|
||||
$resp = $this->post($url, $z_param);
|
||||
if ($resp["status"] == "OK") {
|
||||
$counter = count($rows);
|
||||
$arr = [];
|
||||
$arr[] = [
|
||||
"Status" => "{$this->now()} Upload Pelunasan bayar di tempat : $counter<br/>",
|
||||
];
|
||||
$this->print_table($arr, array_keys($arr[0]), "Re Upload");
|
||||
} else {
|
||||
$arr = [];
|
||||
$arr[] = [
|
||||
"Status" => "{$this->now()} ERR Upload Pelunasan bayar di tempat : {$resp["message"]}",
|
||||
];
|
||||
$this->print_table($arr, array_keys($arr[0]), "Re Upload");
|
||||
}
|
||||
}
|
||||
public function post($url, $data)
|
||||
{
|
||||
echo "{$this->now()} DEBUG : $url\n";
|
||||
$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_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$z_result = curl_exec($ch);
|
||||
if (curl_errno($ch) > 0) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => curl_error($ch),
|
||||
];
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode != 200) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => "Http Response : $httpCode | $z_result",
|
||||
];
|
||||
}
|
||||
|
||||
$result = gzinflate($z_result);
|
||||
$j_result = json_decode($result, true);
|
||||
if (!$j_result) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => "JSON invalid: $z_result",
|
||||
];
|
||||
}
|
||||
return $j_result;
|
||||
}
|
||||
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table($rows, $keys, $title = false)
|
||||
{
|
||||
echo "<table>";
|
||||
if ($title) {
|
||||
$col_span = count($keys);
|
||||
echo "<tr>";
|
||||
echo "<th colspan=$col_span>$title</th>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
550
application/controllers/fix/Pramitalabku_report.php
Normal file
550
application/controllers/fix/Pramitalabku_report.php
Normal file
@@ -0,0 +1,550 @@
|
||||
<?php
|
||||
|
||||
class Pramitalabku_report extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->url =
|
||||
"https://mobile.pramita.co.id/one-api/tools/regonline/r_download/";
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->check();
|
||||
}
|
||||
function check($date = "")
|
||||
{
|
||||
if ($date == "") {
|
||||
$date = date("Y-m-d");
|
||||
}
|
||||
$sql = "select T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderLabNumberExt, T_OrderHeaderID,
|
||||
T_OnlineTxNumbering, T_OnlineTxBookingName
|
||||
from t_onlineorder
|
||||
join t_onlinetx on T_OnlineOrderT_OnlineTxID = T_OnlineTxID
|
||||
and T_OnlineOrderIsActive = 'Y'
|
||||
and T_OnlineTxIsActive = 'Y'
|
||||
and T_OnlineOrderUploaded is not null
|
||||
join t_orderheader
|
||||
on T_OnlineOrderT_OrderHeaderID = T_OrderHeaderID
|
||||
and date(T_OrderHeaderDate) = ?
|
||||
";
|
||||
$qry = $this->db->query($sql, [$date]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => print_r($this->db->error(), true),
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo $this->db->last_query();
|
||||
echo "No record";
|
||||
exit();
|
||||
}
|
||||
foreach ($rows as $idx => $r) {
|
||||
$orderID = $r["T_OrderHeaderID"];
|
||||
unset($rows[$idx]["T_OrderHeaderID"]);
|
||||
$url = "<a href='/one-api/fix/pramitalabku_report/detail/$orderID'>Show Report </a>";
|
||||
$rows[$idx]["Action"] = $url;
|
||||
}
|
||||
$this->print_table_style();
|
||||
$this->print_table($rows, array_keys($rows[0]));
|
||||
}
|
||||
function show_error()
|
||||
{
|
||||
ini_set("display_errors", 1);
|
||||
ini_set("display_startup_errors", 1);
|
||||
error_reporting(E_ALL);
|
||||
}
|
||||
function detail($orderID)
|
||||
{
|
||||
$resp = $this->get_report($orderID);
|
||||
$this->print_table_style();
|
||||
foreach ($resp as $idx => $r) {
|
||||
$url = $r["url"];
|
||||
$action = substr($url, 0, 30) . "<br/>";
|
||||
$action .= "<a href='$url'>View</a><br/>";
|
||||
$action .= "<a href='/one-api/fix/pramitalabku_report/re_post/$orderID'>Post Ulang</a>";
|
||||
$resp[$idx]["url"] = $action;
|
||||
}
|
||||
$this->print_table($resp, array_keys($resp[0]), "Report Lists");
|
||||
}
|
||||
function re_post($orderID)
|
||||
{
|
||||
$resp = $this->get_report($orderID);
|
||||
$arr_reports = [];
|
||||
foreach ($resp as $idx => $r) {
|
||||
$rpt_url = "http://localhost/" . $r["url"];
|
||||
$arr_reports[] = [
|
||||
"name" => $r["Type"],
|
||||
"branchCode" => $r["branchCode"],
|
||||
"fname" => $r["fname"],
|
||||
"content" => base64_encode(file_get_contents($rpt_url)),
|
||||
];
|
||||
}
|
||||
$url = $this->url . "status";
|
||||
$status = [];
|
||||
$status[] = ["reports" => $arr_reports];
|
||||
$param = ["status" => $status];
|
||||
$z_param = gzdeflate(json_encode($param), 9);
|
||||
$resp = $this->post($url, $z_param);
|
||||
$this->print_table_style();
|
||||
print_r($resp);
|
||||
if ($resp["status"] == "OK") {
|
||||
$arr = [];
|
||||
$arr[] = ["message" => $resp["message"]];
|
||||
$this->print_table($arr, array_keys($arr[0]), " Upload OK");
|
||||
$reports = $status["report"];
|
||||
$this->print_table(
|
||||
$reports,
|
||||
array_keys($reports[0]),
|
||||
"Report file"
|
||||
);
|
||||
} else {
|
||||
$arr = [];
|
||||
$arr[] = ["message" => $resp["message"]];
|
||||
$this->print_table($arr, array_keys($arr[0]), " Upload Error");
|
||||
}
|
||||
}
|
||||
|
||||
function get_report($orderID)
|
||||
{
|
||||
$sql = " SELECT
|
||||
T_OrderHeaderID as order_id,
|
||||
T_OrderHeaderLabNumberExt as order_noreg_ext,
|
||||
T_OrderHeaderLabNumber as order_noreg,
|
||||
CASE
|
||||
WHEN Group_ResultID = 1 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_test_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 2 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_papsmear_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 3 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_fna_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 4 THEN 'laporan_Rontgen'
|
||||
WHEN Group_ResultID = 5 THEN 'laporan_BMD'
|
||||
WHEN Group_ResultID = 6 THEN 'laporan_USG'
|
||||
WHEN Group_ResultID = 7 THEN 'laporan_Elektromedik'
|
||||
WHEN Group_ResultID = 8 THEN 'laporan_Pemeriksaan Fisik'
|
||||
WHEN Group_ResultID = 9 THEN 'laporan_Tensi'
|
||||
WHEN Group_ResultID = 10 THEN 'laporan_Tensi'
|
||||
WHEN Group_ResultID = 11 THEN 'laporan_Manthoux Test'
|
||||
WHEN Group_ResultID = 12 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_lcprep_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 13 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_test_mikro_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 14 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_cytologi_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
END as url_rpt,
|
||||
Group_ResultID,
|
||||
if(Group_ResultFlagPerTest = 'Y',T_TestName,Group_ResultName) as type_result,
|
||||
DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y') as order_date,
|
||||
'' as details,
|
||||
'X' So_ResultEntrySo_TemplateOther
|
||||
FROM
|
||||
t_orderheader
|
||||
JOIN result_processtooffice ON Result_ProcessToOfficeT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_OrderHeaderID = $orderID
|
||||
AND Result_ProcessToOfficeStatus = 'S'
|
||||
JOIN t_orderdelivery ON Result_ProcessToOfficeT_OrderDeliveryID = T_OrderDeliveryID AND T_OrderDeliveryIsActive = 'Y'
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Result_ProcessToOfficeGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
GROUP BY Result_ProcessToOfficeID
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
T_OrderHeaderID as order_id,
|
||||
T_OrderHeaderLabNumberExt as order_noreg_ext,
|
||||
T_OrderHeaderLabNumber as order_noreg,
|
||||
CASE
|
||||
WHEN Group_ResultID = 1 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_test_email_eng.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 2 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_papsmear_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 3 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_fna_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 4 THEN 'laporan_Rontgen'
|
||||
WHEN Group_ResultID = 5 THEN 'laporan_BMD'
|
||||
WHEN Group_ResultID = 6 THEN 'laporan_USG'
|
||||
WHEN Group_ResultID = 7 THEN 'laporan_Elektromedik'
|
||||
WHEN Group_ResultID = 8 THEN 'laporan_Pemeriksaan Fisik'
|
||||
WHEN Group_ResultID = 9 THEN 'laporan_Tensi'
|
||||
WHEN Group_ResultID = 10 THEN 'laporan_Tensi'
|
||||
WHEN Group_ResultID = 11 THEN 'laporan_Manthoux Test'
|
||||
WHEN Group_ResultID = 12 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_lcprep_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 13 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_test_mikro_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 14 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_cytologi_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
END as url_rpt,
|
||||
Group_ResultID,
|
||||
CONCAT(if(Group_ResultFlagPerTest = 'Y',T_TestName,Group_ResultName),'_',M_LangCode) as type_result,
|
||||
DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y') as order_date,
|
||||
'' as details,
|
||||
'X' So_ResultEntrySo_TemplateOther
|
||||
FROM t_orderheader
|
||||
JOIN t_orderheaderaddon ON T_OrderHeaderID = $orderID and
|
||||
T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_lang ON T_OrderHeaderAddOnSecondM_LangID = M_LangID
|
||||
JOIN result_processtooffice ON Result_ProcessToOfficeT_OrderHeaderID = T_OrderHeaderID AND
|
||||
Result_ProcessToOfficeStatus = 'S'
|
||||
JOIN t_orderdelivery ON Result_ProcessToOfficeT_OrderDeliveryID = T_OrderDeliveryID AND T_OrderDeliveryIsActive = 'Y'
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Result_ProcessToOfficeGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
||||
AND Group_ResultID = 1
|
||||
GROUP BY Result_ProcessToOfficeID
|
||||
|
||||
UNION
|
||||
|
||||
SELECT T_OrderHeaderID as order_id,
|
||||
T_OrderHeaderLabNumberExt as order_noreg_ext,
|
||||
T_OrderHeaderLabNumber as order_noreg,
|
||||
CASE
|
||||
WHEN Group_ResultID = 1 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_test_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 2 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_papsmear_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 3 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_fna_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 4 THEN T_EmailNonLabUrl
|
||||
WHEN Group_ResultID = 5 THEN T_EmailNonLabUrl
|
||||
WHEN Group_ResultID = 6 THEN T_EmailNonLabUrl
|
||||
WHEN Group_ResultID = 7 THEN T_EmailNonLabUrl
|
||||
WHEN Group_ResultID = 8 THEN T_EmailNonLabUrl
|
||||
WHEN Group_ResultID = 9 THEN T_EmailNonLabUrl
|
||||
WHEN Group_ResultID = 10 THEN T_EmailNonLabUrl
|
||||
WHEN Group_ResultID = 11 THEN T_EmailNonLabUrl
|
||||
WHEN Group_ResultID = 12 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_lcprep_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 13 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_test_mikro_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 14 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_cytologi_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
END as url_rpt,
|
||||
Group_ResultID,
|
||||
if(Group_ResultFlagPerTest = 'Y',T_TestName,Group_ResultName) as type_result,
|
||||
DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y') as order_date,
|
||||
'' as details,
|
||||
'X' So_ResultEntrySo_TemplateOther
|
||||
FROM t_orderheader
|
||||
JOIN result_processtooffice ON T_OrderHeaderID = $orderID and
|
||||
Result_ProcessToOfficeT_OrderHeaderID = T_OrderHeaderID AND
|
||||
Result_ProcessToOfficeStatus = 'S'
|
||||
JOIN t_orderdelivery ON Result_ProcessToOfficeT_OrderDeliveryID = T_OrderDeliveryID AND T_OrderDeliveryIsActive = 'Y'
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'Y' AND Group_ResultFlagPerTest = 'N'
|
||||
JOIN t_email_nonlab ON T_EmailNonLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_EmailNonLabResultEntryID = 0 AND
|
||||
T_EmailNonLabType = Group_ResultName
|
||||
JOIN m_emailconfig ON M_EmailConfigIsActive = 'Y'
|
||||
GROUP BY T_EmailNonLabID
|
||||
|
||||
UNION
|
||||
|
||||
SELECT T_OrderHeaderID as order_id,
|
||||
T_OrderHeaderLabNumberExt as order_noreg_ext,
|
||||
T_OrderHeaderLabNumber as order_noreg,
|
||||
CASE
|
||||
WHEN Group_ResultID = 1 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_test_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 2 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_papsmear_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 3 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_fna_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 12 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_lcprep_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 13 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_test_mikro_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
WHEN Group_ResultID = 14 THEN CONCAT('/birt/frameset?__report=report/one/lab/rpt_hasil_cytologi_email.rptdesign&__format=pdf&username=','admin','&PID=',T_OrderHeaderID,'&ts=',UNIX_TIMESTAMP())
|
||||
ELSE
|
||||
T_EmailNonLabUrl
|
||||
END as url_rpt,
|
||||
Group_ResultID,
|
||||
if(Group_ResultFlagPerTest = 'Y',T_TestName,Group_ResultName) as type_result,
|
||||
DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y') as order_date,
|
||||
'' as details,
|
||||
So_ResultEntrySo_TemplateOther
|
||||
FROM t_orderheader
|
||||
JOIN result_processtooffice ON T_OrderHeaderID = $orderID AND
|
||||
Result_ProcessToOfficeT_OrderHeaderID = T_OrderHeaderID AND
|
||||
Result_ProcessToOfficeStatus = 'S'
|
||||
JOIN t_orderdelivery ON Result_ProcessToOfficeT_OrderDeliveryID = T_OrderDeliveryID AND T_OrderDeliveryIsActive = 'Y'
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'Y' AND Group_ResultFlagPerTest = 'Y'
|
||||
JOIN so_resultentry ON So_ResultEntryT_OrderDetailID = T_OrderDetailID AND So_ResultEntryIsActive = 'Y'
|
||||
JOIN t_email_nonlab ON T_EmailNonLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND T_EmailNonLabResultEntryID = So_ResultEntryID AND
|
||||
T_EmailNonLabResultEntryID <> 0
|
||||
GROUP BY T_EmailNonLabID";
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
echo "<pre>";
|
||||
echo "Err : " . $this->db->error()["message"] . "\n";
|
||||
echo $this->db->last_query();
|
||||
echo "</pre>";
|
||||
exit();
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$arr_grouping = [];
|
||||
if ($rows) {
|
||||
$exist_lab = "N";
|
||||
foreach ($rows as $kx => $vx) {
|
||||
if ($vx["type_result"] == "LAB") {
|
||||
$exist_lab = "Y";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($rows as $k => $v) {
|
||||
if (
|
||||
$v["So_ResultEntrySo_TemplateOther"] == "UMUM" ||
|
||||
$v["So_ResultEntrySo_TemplateOther"] == "UMUM_KONSUL"
|
||||
) {
|
||||
$x_url = $rows[$k]["url_rpt"];
|
||||
$ex_url = explode("|^|", $x_url);
|
||||
//print_r($ex_url);
|
||||
$rows[$k]["type_result"] = "Riwayat";
|
||||
$rows[$k]["url_rpt"] = $ex_url[0];
|
||||
$new_group = $rows[$k];
|
||||
$new_group["type_result"] = "Fisik";
|
||||
$new_group["url_rpt"] = isset($ex_url[1])
|
||||
? $ex_url[1]
|
||||
: $ex_url[0];
|
||||
array_push($rows, $new_group);
|
||||
}
|
||||
|
||||
if (
|
||||
$v["Group_ResultID"] == "13" ||
|
||||
$v["Group_ResultID"] == 13
|
||||
) {
|
||||
$sql = "SELECT T_OrderDetailResult as result
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_OrderDetailT_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N' AND
|
||||
Group_ResultName = 'Mikro'
|
||||
WHERE T_OrderDetailT_OrderHeaderID = {$v["order_id"]} AND T_OrderDetailIsActive = 'Y' LIMIT 1";
|
||||
$xresult = $this->db_onedev->query($sql)->row()->result;
|
||||
if ($xresult != "Terlampir") {
|
||||
$rows[$k]["url_rpt"] =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_test_email.rptdesign&__format=pdf&username=" .
|
||||
$v["staff_name"] .
|
||||
"&PID=" .
|
||||
$v["order_id"] .
|
||||
"&ts=" .
|
||||
strtotime("now");
|
||||
}
|
||||
|
||||
if ($xresult == "Terlampir" && $exist_lab == "N") {
|
||||
$rows[$k]["type_result"] = "Lampiran Mikro";
|
||||
$new_group = $rows[$k];
|
||||
$new_group["type_result"] = "Mikro";
|
||||
$new_group["url_rpt"] =
|
||||
"/birt/frameset?__report=report/one/lab/rpt_test_email.rptdesign&__format=pdf&username=" .
|
||||
$v["staff_name"] .
|
||||
"&PID=" .
|
||||
$v["order_id"] .
|
||||
"&ts=" .
|
||||
strtotime("now");
|
||||
array_push($rows, $new_group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($rows as $ki => $vi) {
|
||||
$idx = $this->getgroup_idx($arr_grouping, $vi["order_id"]);
|
||||
if ($idx == -1) {
|
||||
$xnew = $vi;
|
||||
$xnew["details"] = [
|
||||
[
|
||||
"type_result" => $vi["type_result"],
|
||||
"url" => $vi["url_rpt"],
|
||||
],
|
||||
];
|
||||
array_push($arr_grouping, $xnew);
|
||||
} else {
|
||||
$e_old = $arr_grouping[$idx]["details"];
|
||||
array_push($e_old, [
|
||||
"type_result" => $vi["type_result"],
|
||||
"url" => $vi["url_rpt"],
|
||||
]);
|
||||
$arr_grouping[$idx]["details"] = $e_old;
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = [];
|
||||
/*
|
||||
$fname =
|
||||
$r["T_OnlineTxOrgID"] .
|
||||
"_" .
|
||||
$r["T_OnlineOrderT_OrderID"] .
|
||||
"_" .
|
||||
$xr["Group_ResultName"] .
|
||||
"_" .
|
||||
$r["T_OrderHeaderLabNumberExt"] .
|
||||
".pdf";
|
||||
$arr_reports[] = [
|
||||
"name" => $xr["Group_ResultName"],
|
||||
"branchCode" => $branchCode,
|
||||
"fname" => $fname,
|
||||
"content" => base64_encode(file_get_contents($rpt_url)),
|
||||
];
|
||||
*/
|
||||
$sql = "select T_OnlineTxOrgID, T_OnlineOrderT_OrderID,
|
||||
T_OrderHeaderLabNumberExt
|
||||
from t_orderheader
|
||||
join t_onlineorder on T_OrderHeaderID = ?
|
||||
and T_OnlineOrderT_OrderHeaderID = T_OrderHeaderID
|
||||
join t_onlinetx on T_OnlineOrderT_OnlineTxID = T_OnlineTxID";
|
||||
$qry = $this->db->query($sql, [$orderID]);
|
||||
if (!$qry) {
|
||||
echo "ERR Get Online Tx : " .
|
||||
$this->db->error()["message"] .
|
||||
"\n" .
|
||||
$this->db->last_query();
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "Err No Online Tx";
|
||||
exit();
|
||||
}
|
||||
$r = $rows[0];
|
||||
$T_OnlineTxOrgID = $r["T_OnlineTxOrgID"];
|
||||
$T_OnlineOrderT_OrderID = $r["T_OnlineOrderT_OrderID"];
|
||||
$T_OrderHeaderLabNumberExt = $r["T_OrderHeaderLabNumberExt"];
|
||||
|
||||
$sql =
|
||||
"select M_BranchCode from m_branch where M_BranchIsDefault = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "ERR Get Branch Code : " .
|
||||
$this->db->error()["message"] .
|
||||
"\n" .
|
||||
$this->db->last_query();
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo "Err No Default Branch";
|
||||
exit();
|
||||
}
|
||||
$branchCode = $rows[0]["M_BranchCode"];
|
||||
|
||||
foreach ($arr_grouping as $r) {
|
||||
$arr = [];
|
||||
$arr["Noreg"] = $r["order_noreg"];
|
||||
$arr["T_OrderHeaderID"] = $r["order_id"];
|
||||
if (isset($r["details"]) && count($r["details"]) > 0) {
|
||||
foreach ($r["details"] as $rd) {
|
||||
$fname =
|
||||
$T_OnlineTxOrgID .
|
||||
"_" .
|
||||
$T_OnlineOrderT_OrderID .
|
||||
"_" .
|
||||
$rd["type_result"] .
|
||||
"_" .
|
||||
$T_OrderHeaderLabNumberExt .
|
||||
".pdf";
|
||||
$arr["Type"] = $rd["type_result"];
|
||||
$arr["url"] = $rd["url"];
|
||||
$arr["branchCode"] = $branchCode;
|
||||
$arr["fname"] = $fname;
|
||||
$result[] = $arr;
|
||||
}
|
||||
} else {
|
||||
$fname =
|
||||
$T_OnlineTxOrgID .
|
||||
"_" .
|
||||
$T_OnlineOrderT_OrderID .
|
||||
"_" .
|
||||
$r["type_result"] .
|
||||
"_" .
|
||||
$T_OrderHeaderLabNumberExt .
|
||||
".pdf";
|
||||
|
||||
$arr["Type"] = $r["type_result"];
|
||||
$arr["url"] = $r["url_rpt"];
|
||||
$arr["branchCode"] = $branchCode;
|
||||
$arr["fname"] = $fname;
|
||||
$result[] = $arr;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getgroup_idx($groups, $orderid)
|
||||
{
|
||||
$idx = -1;
|
||||
foreach ($groups as $k => $v) {
|
||||
if ($v["order_id"] == $orderid) {
|
||||
$idx = $k;
|
||||
}
|
||||
}
|
||||
return $idx;
|
||||
}
|
||||
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table($rows, $keys, $title = false)
|
||||
{
|
||||
echo "<table>";
|
||||
if ($title) {
|
||||
$col_span = count($keys);
|
||||
echo "<tr>";
|
||||
echo "<th colspan=$col_span>$title</th>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
public 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_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: " . strlen($data),
|
||||
]);
|
||||
$z_result = curl_exec($ch);
|
||||
if (curl_errno($ch) > 0) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => curl_error($ch),
|
||||
];
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
if ($httpCode != 200) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => "Http Response : $httpCode | $z_result",
|
||||
];
|
||||
}
|
||||
|
||||
$result = gzinflate($z_result);
|
||||
$j_result = json_decode($result, true);
|
||||
if (!$j_result) {
|
||||
return [
|
||||
"status" => "ERR",
|
||||
"message" => "JSON invalid: $z_result",
|
||||
];
|
||||
}
|
||||
return $j_result;
|
||||
}
|
||||
}
|
||||
115
application/controllers/fix/Qr_result.php
Normal file
115
application/controllers/fix/Qr_result.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
class Qr_result extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo ".: Qr Result Dual :.";
|
||||
}
|
||||
function dual($nolab)
|
||||
{
|
||||
$sql = "select T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderLabNumberExt, T_OrderHeaderID,
|
||||
JSON_UNQUOTE(
|
||||
JSON_EXTRACT(fn_get_patient_atribute(T_OrderHeaderM_PatientID), '$.patient_fullname')) as Patient
|
||||
from
|
||||
t_orderheader
|
||||
where ( T_OrderHeaderLabNumber = ? or T_OrderHeaderLabNumberExt = ? ) ";
|
||||
$qry = $this->db->query($sql, [$nolab,$nolab]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => print_r($this->db->error(), true),
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
echo $this->db->last_query();
|
||||
echo "No record";
|
||||
exit();
|
||||
}
|
||||
$orderHeaderID = $rows[0]["T_OrderHeaderID"];
|
||||
$sql = "select count(*) xtot
|
||||
from
|
||||
t_orderheaderaddon
|
||||
where T_OrderHeaderAddOnT_OrderHeaderID=? and T_OrderHeaderAddOnSecondM_LangID = 2";
|
||||
|
||||
$qry = $this->db->query($sql, [$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => print_r($this->db->error(), true),
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$xrows = $qry->result_array();
|
||||
$flag_have_en = true;
|
||||
if (count($xrows) == 0) {
|
||||
$flag_have_en = false;
|
||||
}
|
||||
foreach($rows as $idx => $r) {
|
||||
unset($rows[$idx]["T_OrderHeaderID"]);
|
||||
$rows[$idx]["English"] = $flag_have_en ? "Requested" : "Not Requested";
|
||||
}
|
||||
$this->print_table_style();
|
||||
$this->print_table($rows, array_keys($rows[0]));
|
||||
echo "<br/>";
|
||||
$url_barcode = "/one-api/chart/the_qr/v3_dual/$orderHeaderID/" . date("Y-m-dHis");
|
||||
echo "<div style='margin-left:15%'> <image src='$url_barcode' style='width:350px'/> </div>";
|
||||
if ($flag_have_en) {
|
||||
echo "Call sp_rpt_t_hasil_eng($orderHeaderID,'admin'), hasil :<br/>\n";
|
||||
$sql = "call sp_rpt_t_hasil_eng(?,'admin')";
|
||||
$qry = $this->db->query($sql,[$orderHeaderID]);
|
||||
if (!$qry) {
|
||||
echo json_encode([
|
||||
"status" => "ERR",
|
||||
"message" => print_r($this->db->error(), true),
|
||||
]);
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
print_r($rows);
|
||||
}
|
||||
}
|
||||
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table($rows, $keys)
|
||||
{
|
||||
$this->print_table_style();
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
73
application/controllers/fix/Rekap_rpt_044.php
Normal file
73
application/controllers/fix/Rekap_rpt_044.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
class Rekap_rpt_044 extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo '<pre>\nRekap sp_rpt_r_044';
|
||||
}
|
||||
function rekap($start, $end)
|
||||
{
|
||||
$sdate = $start;
|
||||
while ($sdate <= $end) {
|
||||
$this->log("Processing $sdate");
|
||||
|
||||
$sql = "call sp_rpt_r_044(?,?,?)";
|
||||
$qry = $this->db->query($sql, [$sdate, $sdate, "admin"]);
|
||||
if (!$qry) {
|
||||
echo "Error : " . $this->db->error()["message"];
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
$sql = "delete from ss_rpt_044 where SsRpt044OrderDate = ?";
|
||||
$qry = $this->db->query($sql, [$sdate]);
|
||||
if (!$qry) {
|
||||
echo "Error Delete $sdate: " . $this->db->error()["message"] . "\n" . $this->db->last_query() . "\n";
|
||||
exit();
|
||||
}
|
||||
$tot_count = 0;
|
||||
foreach ($rows as $idx => $r) {
|
||||
$r["SsRpt044OrderDate"] = $sdate;
|
||||
$qry = $this->db->insert("ss_rpt_044", $r);
|
||||
if (!$qry) {
|
||||
echo "Error Insert : " . $this->db->error()["message"] . "\n" . $this->db->last_query() . "\n";
|
||||
exit();
|
||||
}
|
||||
$tot_count++;
|
||||
}
|
||||
$this->log(" Done $tot_count rows");
|
||||
$sdate = date("Y-m-d", strtotime($sdate . " + 1 day "));
|
||||
$this->log("Wait 3s");
|
||||
sleep(3);
|
||||
}
|
||||
}
|
||||
function log($msg) {
|
||||
echo date("Y-m-d H:i:s") . " " . $msg . "\n";
|
||||
}
|
||||
}
|
||||
/*
|
||||
create table ss_rpt_044 (
|
||||
SsRpt044ID int not null auto_increment primary key,
|
||||
SsRpt044OrderDate date,
|
||||
T_TestName varchar(500),
|
||||
pemeriksaan int,
|
||||
bruto int,
|
||||
disc int,
|
||||
netto int,
|
||||
Nat_SubgroupName varchar(100),
|
||||
Nat_SubSubGroupName varchar(100),
|
||||
T_TestNat_GroupID int,
|
||||
T_TestID int,
|
||||
SsRpt044Created datetime default current_timestamp(),
|
||||
Nat_SubgroupID int,
|
||||
branch varchar(100),
|
||||
key(SsRpt044OrderDate),
|
||||
key(T_TestName)
|
||||
);
|
||||
*/
|
||||
?>
|
||||
83
application/controllers/fix/Rujukan.php
Normal file
83
application/controllers/fix/Rujukan.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
class Rujukan extends CI_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index() {
|
||||
echo "Fix Rujukan";
|
||||
}
|
||||
function upload() {
|
||||
$sql = "select incomingRefChildNewT_OrderHeaderID,
|
||||
T_OrderDetailValUserID,
|
||||
T_OrderDetailID,
|
||||
M_StaffName, T_OrderDetailT_TestName,
|
||||
T_OrderHeaderAddOnLabNumberOrigin
|
||||
from incoming_ref_child
|
||||
join t_orderdetail on T_OrderDetailT_OrderHeaderID = incomingRefChildNewT_OrderHeaderID
|
||||
and T_OrderDetailT_TestID = incomingRefChildT_TestID
|
||||
join t_orderheaderaddon on T_OrderHeaderAddOnT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
join m_user on T_OrderDetailValUserID = M_UserID
|
||||
join m_staff on M_StaffID = M_UserM_StaffID
|
||||
where date(incomingRefChildCreated) = date(now())
|
||||
and T_OrderHeaderAddOnLabNumberOrigin <> '00202630DC'
|
||||
order by incomingRefChildNewT_OrderHeaderID";
|
||||
$qry = $this->db->query($sql);
|
||||
$this->load->library("Txbranchstatus");
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
$prev_orderid = 0;
|
||||
$rows_id = array();
|
||||
foreach($rows as $r) {
|
||||
$orderid = $r["incomingRefChildNewT_OrderHeaderID"];
|
||||
$detail_id = $r["T_OrderDetailID"];
|
||||
$this->load->library("Txbranchstatus");
|
||||
$userID = $r["T_OrderDetailValUserID"];
|
||||
$noreg = $r["T_OrderHeaderAddOnLabNumberOrigin"];
|
||||
$userName = $r["M_StaffName"];
|
||||
$testName = $r["T_OrderDetailT_TestName"];
|
||||
$this->txbranchstatus->update("VALIDATION",$detail_id,$userName);
|
||||
echo "Process $noreg : $testName => $orderid : $detail_id : $userName \n";
|
||||
}
|
||||
} else {
|
||||
print_r($this->db->error());
|
||||
}
|
||||
}
|
||||
function child_test() {
|
||||
$sql = "update incoming_ref_child, incoming_ref_detail
|
||||
set incomingRefChildNewT_OrderHeaderID = incomingRefDetailNewT_OrderHeaderID
|
||||
where incomingRefChildIncomingRefID = incomingRefDetailIncomingRefID
|
||||
and incomingRefChildT_OrderHeaderID = incomingRefDetailT_OrderHeaderID
|
||||
and incomingRefChildNewT_OrderHeaderID is null
|
||||
and date(incomingRefDetailCreated) = date(now())
|
||||
";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$date = date("Y-m-d H:i:s ");
|
||||
echo "$date update rows : " . $this->db->affected_rows() . "\n";
|
||||
} else {
|
||||
$msg = print_r($this->db->error(),true);
|
||||
echo "$date err : $msg \n";
|
||||
}
|
||||
}
|
||||
function barcode_label() {
|
||||
$sql = "update incoming_ref_detail, t_test, t_barcodelab
|
||||
set T_BarcodeLabBarcodeOrigin = incomingRefDetailT_BarcodeLabBarcode
|
||||
where
|
||||
incomingRefDetailT_TestID = T_TestID
|
||||
and incomingRefDetailNewT_OrderHeaderID = T_BarcodeLabT_OrderHeaderID
|
||||
and T_BarcodeLabT_SampleTypeID = json_extract(fn_worklist_get_info(incomingRefDetailNewT_OrderHeaderID,T_TestID), '$.sampleTypeID')
|
||||
and date(incomingRefDetailCreated) = date(now())
|
||||
and T_TestT_SampleTypeID = 0
|
||||
and T_BarcodeLabBarcodeOrigin is null";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$date = date("Y-m-d H:i:s ");
|
||||
echo "$date update rows : " . $this->db->affected_rows() . "\n";
|
||||
} else {
|
||||
$msg = print_r($this->db->error(),true);
|
||||
echo "$date err : $msg \n";
|
||||
}
|
||||
}
|
||||
}
|
||||
75
application/controllers/fix/Serumkuningmerah.php
Normal file
75
application/controllers/fix/Serumkuningmerah.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
class Serumkuningmerah extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
function cek_order($order) {
|
||||
$sql = "select * from t_orderheader where T_OrderHeaderLabNumber like ?";
|
||||
$qry = $this->db->query($sql, array("%" . $order . "%"));
|
||||
if (! $qry) {
|
||||
echo "ERR : \n" ;
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
echo "{$r['T_OrderHeaderID']}\t{$r['T_OrderHeaderDate']}\t{$r['T_OrderHeaderLabNumber']}\n";
|
||||
}
|
||||
}
|
||||
function cek($headerID) {
|
||||
$sql ="select *
|
||||
from t_ordersample
|
||||
join t_sampletype on T_OrderSampleT_SampleTypeID = T_SampleTypeID
|
||||
where T_OrderSampleIsActive = 'Y' and T_OrderSampleT_OrderHeaderID=? order by T_OrderSampleID";
|
||||
$qry = $this->db->query($sql,array($headerID));
|
||||
if (! $qry) {
|
||||
echo "ERR : \n" ;
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
echo "{$r['T_OrderSampleID']}\t{$r['T_OrderSampleBarcode']}\t{$r['T_SampleTypeName']}\t{$r['T_OrderSampleWorklistReceive']}\t" .
|
||||
"{$r['T_OrderSampleWorklistReceiveDatetime']}\t{$r['T_OrderSampleWorklistReceiveUserID']}\n";
|
||||
}
|
||||
}
|
||||
function cek_kuning($headerID) {
|
||||
$sql ="select a.T_OrderSampleWorklistReceive , b.T_OrderSampleWorklistReceive bRcv,
|
||||
a.T_OrderSampleWorklistReceiveDatetime, b.T_OrderSampleWorklistReceiveDatetime bDate,
|
||||
a.T_OrderSampleWorklistReceiveUserID, b.T_OrderSampleWorklistReceiveUserID bUser
|
||||
from t_ordersample a
|
||||
join t_ordersample b on a.T_OrderSampleT_OrderHeaderID = b.T_OrderSampleT_OrderHeaderID
|
||||
and a.T_OrderSampleBarcode like '%SK%' and b.T_OrderSampleBarcode like '%SP%'
|
||||
and a.T_OrderSampleIsActive = 'Y' and b.T_OrderSampleIsActive = 'Y'
|
||||
and a.T_OrderSampleT_OrderHeaderID = ?";
|
||||
$qry = $this->db->query($sql,array($headerID));
|
||||
if (! $qry) {
|
||||
echo "ERR : \n" ;
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
print_r($rows);
|
||||
}
|
||||
|
||||
function update_kuning($headerID) {
|
||||
$sql = "update t_ordersample a
|
||||
join t_ordersample b on a.T_OrderSampleT_OrderHeaderID = b.T_OrderSampleT_OrderHeaderID
|
||||
and a.T_OrderSampleBarcode like '%SK%' and b.T_OrderSampleBarcode like '%SP%'
|
||||
and a.T_OrderSampleIsActive = 'Y' and b.T_OrderSampleIsActive = 'Y'
|
||||
and a.T_OrderSampleT_OrderHeaderID = ?
|
||||
set
|
||||
a.T_OrderSampleWorklistReceive = b.T_OrderSampleWorklistReceive ,
|
||||
a.T_OrderSampleWorklistReceiveDatetime = b.T_OrderSampleWorklistReceiveDatetime ,
|
||||
a.T_OrderSampleWorklistReceiveUserID = b.T_OrderSampleWorklistReceiveUserID
|
||||
";
|
||||
$qry = $this->db->query($sql,array($headerID));
|
||||
if (! $qry) {
|
||||
echo "ERR : \n" ;
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
echo "Serum Kuning di update";
|
||||
}
|
||||
}
|
||||
171
application/controllers/fix/Sspiutang.php
Normal file
171
application/controllers/fix/Sspiutang.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
class Sspiutang extends CI_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index() {
|
||||
echo "Fix Rujukan";
|
||||
}
|
||||
function check($sdate,$edate) {
|
||||
$sql = "select
|
||||
SsPiutangType,
|
||||
T_OrderHeaderLabNumber,
|
||||
fn_get_name(T_OrderHeaderM_PatientID) PatientName,
|
||||
SsPiutangID, SsPiutangDate, SsPiutangT_OrderHeaderID,
|
||||
cast(SsPiutangTotal as decimal(15,0)) as SsPiutangTotal ,
|
||||
cast( sum(SsPiutangTestTotal) as decimal(15,0) ) as SumSsPiutangTestTotal
|
||||
from ss_piutang
|
||||
join ss_piutang_test
|
||||
on SsPiutangID = SsPiutangTestSsPiutangID
|
||||
join t_orderheader on SsPiutangT_OrderHeaderID = T_OrderHeaderID
|
||||
where
|
||||
ssPiutangDate >= ? and SsPiutangDate <= ?
|
||||
and SsPiutangIsActive = 'Y'
|
||||
and SsPiutangType in ('A1','A2','A3')
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
group by SsPiutangID,SsPiutangT_OrderHeaderID
|
||||
having SsPiutangTotal <> SumSsPiutangTestTotal
|
||||
and SumSsPiutangTestTotal > 0
|
||||
";
|
||||
$qry = $this->db->query($sql,array($sdate,$edate));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$orderheaderID = $r["SsPiutangT_OrderHeaderID"];
|
||||
$ssPiutangID = $r["SsPiutangID"];
|
||||
$noreg = $r["T_OrderHeaderLabNumber"];
|
||||
$name = $r["PatientName"];
|
||||
$tgl = $r["SsPiutangDate"];
|
||||
$piutangTotal = $r["SsPiutangTotal"];
|
||||
$testTotal = $r["SumSsPiutangTestTotal"];
|
||||
|
||||
$sql = "select
|
||||
T_OrderDetailT_TestName,T_OrderDetailT_TestID,
|
||||
T_OrderDetailT_TestIsPrice, T_OrderDetailPrice,
|
||||
T_OrderDetailDiscTotal, T_OrderDetailTotal
|
||||
from
|
||||
t_orderdetail
|
||||
where T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailPrice > 0
|
||||
and T_OrderDetailT_TestID not in (
|
||||
select SsPiutangTestT_TestID
|
||||
from ss_piutang_test
|
||||
where SsPiutangTestSsPiutangID = ?
|
||||
)";
|
||||
$qry = $this->db->query($sql,array($orderheaderID, $ssPiutangID));
|
||||
echo "\n============\n";
|
||||
echo "$tgl \t $noreg \t $name \t\t $piutangTotal\n";
|
||||
echo " \t \t piutang_test \t\t $testTotal\n";
|
||||
if ($qry) {
|
||||
$drows = $qry->result_array();
|
||||
foreach($drows as $dr) {
|
||||
$test = $dr["T_OrderDetailT_TestName"];
|
||||
$total = $dr["T_OrderDetailTotal"];
|
||||
echo " \t \t $test \t\t $total\n";
|
||||
$testTotal += $total;
|
||||
}
|
||||
echo " \t \t Sum \t\t $testTotal\n";
|
||||
} else {
|
||||
$date = date("Y-m-d H:i:s");
|
||||
$msg = print_r($this->db->error(),true);
|
||||
echo "$date err : $msg \n";
|
||||
}
|
||||
echo "-----------\n";
|
||||
}
|
||||
} else {
|
||||
$date = date("Y-m-d H:i:s");
|
||||
$msg = print_r($this->db->error(),true);
|
||||
echo "$date err : $msg \n";
|
||||
}
|
||||
}
|
||||
function fix($sdate,$edate) {
|
||||
$sql = "select
|
||||
SsPiutangType,
|
||||
T_OrderHeaderLabNumber,
|
||||
fn_get_name(T_OrderHeaderM_PatientID) PatientName,
|
||||
SsPiutangID, SsPiutangDate, SsPiutangT_OrderHeaderID,
|
||||
cast(SsPiutangTotal as decimal(15,0)) as SsPiutangTotal ,
|
||||
cast( sum(SsPiutangTestTotal) as decimal(15,0) ) as SumSsPiutangTestTotal
|
||||
from ss_piutang
|
||||
join ss_piutang_test
|
||||
on SsPiutangID = SsPiutangTestSsPiutangID
|
||||
join t_orderheader on SsPiutangT_OrderHeaderID = T_OrderHeaderID
|
||||
where
|
||||
ssPiutangDate >= ? and SsPiutangDate <= ?
|
||||
and SsPiutangIsActive = 'Y'
|
||||
and SsPiutangType in ('A1','A2','A3')
|
||||
and T_OrderHeaderIsActive = 'Y'
|
||||
group by SsPiutangID,SsPiutangT_OrderHeaderID
|
||||
having SsPiutangTotal <> SumSsPiutangTestTotal
|
||||
and SumSsPiutangTestTotal > 0
|
||||
";
|
||||
$qry = $this->db->query($sql,array($sdate,$edate));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
foreach($rows as $r) {
|
||||
$orderheaderID = $r["SsPiutangT_OrderHeaderID"];
|
||||
$ssPiutangID = $r["SsPiutangID"];
|
||||
$noreg = $r["T_OrderHeaderLabNumber"];
|
||||
$name = $r["PatientName"];
|
||||
$tgl = $r["SsPiutangDate"];
|
||||
$piutangTotal = $r["SsPiutangTotal"];
|
||||
$testTotal = $r["SumSsPiutangTestTotal"];
|
||||
|
||||
$sql = "select
|
||||
T_OrderDetailT_TestName,T_OrderDetailT_TestID,
|
||||
T_OrderDetailT_TestIsPrice, T_OrderDetailPrice,
|
||||
T_OrderDetailDiscTotal, T_OrderDetailTotal
|
||||
from
|
||||
t_orderdetail
|
||||
where T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderDetailPrice > 0
|
||||
and T_OrderDetailT_TestID not in (
|
||||
select SsPiutangTestT_TestID
|
||||
from ss_piutang_test
|
||||
where SsPiutangTestSsPiutangID = ?
|
||||
)";
|
||||
$qry = $this->db->query($sql,array($orderheaderID, $ssPiutangID));
|
||||
echo "\n============\n";
|
||||
echo "$tgl \t $noreg \t $name \t\t $piutangTotal\n";
|
||||
echo " \t \t piutang_test \t\t $testTotal\n";
|
||||
if ($qry) {
|
||||
$drows = $qry->result_array();
|
||||
foreach($drows as $dr) {
|
||||
$test = $dr["T_OrderDetailT_TestName"];
|
||||
$total = $dr["T_OrderDetailTotal"];
|
||||
echo " \t \t $test \t\t $total\n";
|
||||
$testTotal += $total;
|
||||
$sql = "insert into ss_piutang_test(SsPiutangTestSsPiutangID,
|
||||
SsPiutangTestT_TestID, SsPiutangTestPrice, SsPiutangTestDiscTotal,
|
||||
SsPiutangTestTotal)
|
||||
values(?, ?,?,?, ?)";
|
||||
$testID = $dr["T_OrderDetailT_TestID"];
|
||||
$r_price = $dr["T_OrderDetailPrice"];
|
||||
$r_disc = $dr["T_OrderDetailDiscTotal"];
|
||||
$r_total = $dr["T_OrderDetailTotal"];
|
||||
$iqry = $this->db->query($sql, array($ssPiutangID, $testID, $r_price, $r_disc, $r_total));
|
||||
if (!$iqry) {
|
||||
$date = date("Y-m-d H:i:s");
|
||||
$msg = print_r($this->db->error(),true);
|
||||
echo "$date err : $msg \n";
|
||||
}
|
||||
}
|
||||
echo " \t \t Sum \t\t $testTotal\n";
|
||||
} else {
|
||||
$date = date("Y-m-d H:i:s");
|
||||
$msg = print_r($this->db->error(),true);
|
||||
echo "$date err : $msg \n";
|
||||
}
|
||||
echo "-----------\n";
|
||||
}
|
||||
} else {
|
||||
$date = date("Y-m-d H:i:s");
|
||||
$msg = print_r($this->db->error(),true);
|
||||
echo "$date err : $msg \n";
|
||||
}
|
||||
}
|
||||
}
|
||||
86
application/controllers/fix/Tx_branch.php
Normal file
86
application/controllers/fix/Tx_branch.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
class Tx_branch extends MY_Controller
|
||||
{
|
||||
function index()
|
||||
{
|
||||
global $_SERVER;
|
||||
$this->print_table_style();
|
||||
|
||||
$sql = "select M_BranchID, M_BranchCode, M_BranchName, TxBranchStatusM_BranchIP TxIpAddress,
|
||||
M_BranchIPAddress, count(*) total
|
||||
from
|
||||
tx_branch_status
|
||||
join m_branch on TxBranchStatusIsSent = 'N'
|
||||
and TxBranchStatusM_BranchID = M_BranchID
|
||||
group by M_BranchCode, TxBranchStatusM_BranchIP ";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo "ERR : " . $this->db->error()["message"] . "\n";
|
||||
exit();
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $idx => $r) {
|
||||
$branchID = $r["M_BranchID"];
|
||||
$branchIP = $r["M_BranchIPAddress"];
|
||||
$action = "<a href='/one-api/fix/tx_branch/fix/$branchID/$branchIP'>Fix IP and Retry</a>";
|
||||
$rows[$idx]["Action"] = $action;
|
||||
}
|
||||
$this->print_table($rows, array_keys($rows[0]), "Tx Branch Status");
|
||||
}
|
||||
function fix($branchID, $branchIP)
|
||||
{
|
||||
$sql = "update tx_branch_status
|
||||
set TxBranchStatusRetry =1 , TxBranchStatusM_BranchIP = ?
|
||||
where TxBranchStatusIsSent = 'N' and
|
||||
TxBranchStatusM_BranchID = ? ";
|
||||
$qry = $this->db->query($sql, [$branchIP, $branchID]);
|
||||
if (!$qry) {
|
||||
echo "ERR : " . $this->db->error()["message"] . "\n";
|
||||
exit();
|
||||
}
|
||||
header("Location: /one-api/fix/tx_branch");
|
||||
exit();
|
||||
}
|
||||
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table($rows, $keys, $title = false)
|
||||
{
|
||||
echo "<table>";
|
||||
if ($title) {
|
||||
$col_span = count($keys);
|
||||
echo "<tr>";
|
||||
echo "<th colspan=$col_span>$title</th>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
142
application/controllers/fix/Unit.php
Normal file
142
application/controllers/fix/Unit.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
class Unit extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo '<pre>';
|
||||
echo "cek [NomorLab]<br/> Untuk menampilkan list unit name";
|
||||
}
|
||||
public function cek($nomorlab)
|
||||
{
|
||||
//query TestName UnitName NatUnitName MethodeUnitName
|
||||
// UnitName : UnitName yang ada di t_orderdetail
|
||||
// NatUnitName : UnitName yg diambil dari T_Test
|
||||
// MethodeUnitName : UnitName yg diambil dari nat_methode_unit, sesuai dengan t_orderdetail methodeID
|
||||
// Action : tampilkan tombol "Fix Unit" jika UnitName <> NatUnitName atau UnitName <> MethodeUnitName
|
||||
// parameter dari tombol ini adalah orderDetailID dan nomorlab
|
||||
// url_fix = "/one-api/fix/unit/fix/$orderDetailID/$nomorlab"
|
||||
// "<button onClick=\"document.location.href='$url_fix'\">Fix Verif Valid Race</button>";
|
||||
// utk menampilkan listing bisa menggunakan fungsi print_table dengan parameter rows dari qry->result_array
|
||||
|
||||
$sql = "select T_OrderDetailT_TestName as test,
|
||||
T_OrderDetailNat_UnitName as satuan_byorder,a.Nat_UnitName satuan_bytest, b.Nat_UnitName as satuan_bymethode,
|
||||
T_OrderDetailNat_UnitID as idbyorder,a.Nat_UnitID idbytest, IFNULL(b.Nat_UnitID,0) as idbymethode,
|
||||
Nat_TestID, T_OrderDetailID, T_OrderDetailNat_MethodeID
|
||||
|
||||
from t_orderheader
|
||||
join t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
join t_test ON T_TestID = T_OrderDetailT_TestID
|
||||
join nat_test ON Nat_TestID = T_TestNat_TestID
|
||||
join nat_unit a ON a.Nat_UnitID = Nat_TestNat_UnitID
|
||||
left join nat_methodeunit ON Nat_MethodeUnitNat_MethodeID = T_OrderDetailNat_MethodeID AND Nat_MethodeUnitNat_TestID = Nat_TestID AND Nat_MethodeUnitIsActive = 'Y'
|
||||
left join nat_unit b ON b.Nat_UnitID = Nat_MethodeUnitNat_UnitID
|
||||
where T_OrderHeaderIsActive = 'Y' and T_OrderHeaderLabNumber = ? order by T_OrderDetailID";
|
||||
$qry = $this->db->query($sql, [$nomorlab]);
|
||||
if (!$qry) {
|
||||
echo "ERR : \n";
|
||||
print_r($this->db->error());
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
echo '<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
';
|
||||
echo '<table>';
|
||||
echo '<tr>';
|
||||
echo "<td>Test</td> <td>UnitName</td> <td>NatUnitName</td> <td>MethodeUnitName</td> <td>Aksi</td>
|
||||
</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo '<tr>';
|
||||
|
||||
echo "<td>{$r['test']} </td> <td>{$r['satuan_byorder']}</td> <td>{$r['satuan_bytest']}</td> <td>{$r['satuan_bymethode']}</td>
|
||||
";
|
||||
$url_target = '/one-api/fix/unit/fix/'. $r['T_OrderDetailID'] . '/' . $nomorlab . '/' . $r['idbytest'] . '/' .$r['idbymethode'];
|
||||
|
||||
if($r['idbymethode'] != 0){
|
||||
echo '<td>';
|
||||
echo "<a type='button' target=\"_blank\" href=\"$url_target\"> Ganti satuan </a>";
|
||||
echo "</td>";
|
||||
// $x_note = "<pre>" . print_r($r, true) . "</pre>";
|
||||
// echo "<td>$x_note</td>";
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
function fix($orderDetailID, $nomorlab, $idbytest, $idbymethode)
|
||||
{
|
||||
//fix unit name dari t_orderdetail
|
||||
//1. jika methodeid ada di nat_methode_unit di update berdasarkan nat_methode_unit
|
||||
//2. jika 1 tidak terpenuhi, update berdasarkan t_test
|
||||
//3. redirect ke cek lagi
|
||||
// header("/one-api/fix/unit/")
|
||||
if($idbymethode == 0){
|
||||
$unitid = $idbytest;
|
||||
}else{
|
||||
$unitid = $idbymethode;
|
||||
}
|
||||
$sql = $this->db->query("SELECT Nat_UnitName as unitname FROM nat_unit WHERE Nat_UnitID = $unitid")->row();
|
||||
$unitname = $sql->unitname;
|
||||
$sql = "UPDATE t_orderdetail SET T_OrderDetailNat_UnitID = $unitid, T_OrderDetailNat_UnitName = '{$unitname}'
|
||||
WHERE T_OrderDetailID = $orderDetailID";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
echo json_encode(['status' => 'ERR', 'message' => print_r($this->db->error(), true)]);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo 'update OK';
|
||||
header("Location: /one-api/fix/unit/cek/".$nomorlab);
|
||||
exit();
|
||||
|
||||
}
|
||||
public function print_table_style()
|
||||
{
|
||||
echo "
|
||||
<style>
|
||||
th, td {
|
||||
padding: 15px;
|
||||
text-align: left;
|
||||
}
|
||||
tr:nth-child(even) {background-color: #f2f2f2;}
|
||||
table {
|
||||
border: solid 1px ;
|
||||
min-width:600px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
public function print_table($keys)
|
||||
{
|
||||
$this->print_table_style();
|
||||
echo "<table>";
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>$k</td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
foreach ($rows as $r) {
|
||||
echo "<tr>";
|
||||
foreach ($keys as $k) {
|
||||
echo "<td>" . $r[$k] . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
}
|
||||
89
application/controllers/fix/keu/Ss_piutang.php
Normal file
89
application/controllers/fix/keu/Ss_piutang.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
class Ss_Piutang extends MY_Controller {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function now() {
|
||||
return date("Y-m-d H:i:s");
|
||||
}
|
||||
function b1($start,$end) {
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
$sql = "select
|
||||
SsPiutangID
|
||||
from
|
||||
ss_piutang
|
||||
left join order_px
|
||||
on SsPiutangT_OrderHeaderID = OrderPxT_OrderHeaderID
|
||||
where
|
||||
SsPiutangType = 'B1'
|
||||
and SsPiutangIsActive = 'Y'
|
||||
and OrderPxT_OrderHeaderID is null
|
||||
and SsPiutangDate >= ?
|
||||
and SsPiutangDate <= ?";
|
||||
|
||||
$qry = $this->db->query($sql, array($start,$end));
|
||||
if(!$qry) {
|
||||
echo "{$this->now()} ERR Get B1 : | {$this->db->error()['message']} |\n" . $this->db->last_query() . "\n";
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$s_ids = "";
|
||||
foreach($rows as $r) {
|
||||
if ($s_ids != "") $s_ids .= ",";
|
||||
$s_ids .= $r["SsPiutangID"];
|
||||
}
|
||||
if ($s_ids == "") {
|
||||
echo "{$this->now()} No B1 record\n";
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
|
||||
//ss_piutang
|
||||
$sql = "update ss_piutang set SsPiutangIsActive = 'N' where SsPiutangID in ($s_ids) ";
|
||||
$qry = $this->db->query($sql);
|
||||
if(!$qry) {
|
||||
echo "{$this->now()} ERR Update Ss_Piutang : " . $this->db->last_query() . "\n";
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
echo "SS Piutang : Non Active-kan {$this->db->affected_rows()} \n";
|
||||
|
||||
//ss_piutang_packet
|
||||
$sql = "delete from ss_piutang_packet where SsPiutangPacketSsPiutangID in ($s_ids)";
|
||||
$qry = $this->db->query($sql);
|
||||
if(!$qry) {
|
||||
echo "{$this->now()} ERR Delete Ss_Piutang_Packet : " . $this->db->last_query() . "\n";
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
echo "{$this->now()} SS Piutang Packet : deleted {$this->db->affected_rows()} \n";
|
||||
|
||||
|
||||
//ss_piutang_payment
|
||||
$sql = "update ss_piutang_payment set SsPiutangPaymentIsActive='N' where SsPiutangPaymentSsPiutangID in ($s_ids)";
|
||||
$qry = $this->db->query($sql);
|
||||
if(!$qry) {
|
||||
echo "{$this->now()} ERR Update Ss_Piutang_Payment : " . $this->db->last_query() . "\n";
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
echo "{$this->now()} SS Piutang Payment : updated {$this->db->affected_rows()} \n";
|
||||
|
||||
//ss_piutang_test
|
||||
$sql = "delete from ss_piutang_payment where SsPiutangPaymentSsPiutangID in ($s_ids)";
|
||||
$qry = $this->db->query($sql);
|
||||
if(!$qry) {
|
||||
echo "{$this->now()} ERR Delete Ss_Piutang_Payment : " . $this->db->last_query() . "\n";
|
||||
$this->db->trans_rollback();
|
||||
exit;
|
||||
}
|
||||
echo "{$this->now()} SS Piutang Payment : deleted {$this->db->affected_rows()} \n";
|
||||
|
||||
$this->db->trans_commit();
|
||||
}
|
||||
}
|
||||
547
application/controllers/fix/xnotes.php
Normal file
547
application/controllers/fix/xnotes.php
Normal file
@@ -0,0 +1,547 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
class Fix{
|
||||
|
||||
// retrun array status, message
|
||||
public function create($mouID) {
|
||||
$CI =& get_instance();
|
||||
$this->db = $CI->load->database("onedev",true);
|
||||
|
||||
$sql = "select * from m_mou where M_MouID = ?";
|
||||
$qry = $this->db->query($sql, array($mouID));
|
||||
if (! $qry ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return array(false, "MOU ID : $mouID not found");
|
||||
}
|
||||
$companyID = $rows[0]["M_MouM_CompanyID"];
|
||||
|
||||
$sql = "select distinct 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, $mouID Ss_PriceMouM_MouID
|
||||
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 ) {
|
||||
return array(false, "Regional select t_price " . print_r($this->db->error(),true));
|
||||
}
|
||||
$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 ) {
|
||||
return array(false, "Regional " . print_r($this->db->error(),true));
|
||||
}
|
||||
$nt_rows = $qry->result_array();
|
||||
$t_rows = array($r["Nat_TestID"]);
|
||||
foreach($nt_rows as $nr) {
|
||||
$t_rows[] = $nr["T_TestNat_TestID"];
|
||||
}
|
||||
$rows[$idx]['nat_test'] = "[" . join(",",$t_rows) . "]";
|
||||
break;
|
||||
default :
|
||||
$rows[$idx]['nat_test'] = '[' . $r['Nat_TestID'] . ']';
|
||||
break;
|
||||
}
|
||||
unset($rows[$idx]["Nat_TestNat_TestTypeID"]);
|
||||
unset($rows[$idx]["T_TestSasCode"]);
|
||||
}
|
||||
//Test Profile
|
||||
// wip profile
|
||||
$sql = "select distinct $mouID T_PriceM_MouID, T_TestID, T_TestName, 'N' IsFromPanel, Nat_TestID,
|
||||
T_TestID T_PriceT_TestID, 'N' T_PriceIsCito, $companyID T_PriceM_CompanyID, $mouID T_PriceM_MouID,
|
||||
0 T_PricePriority, 0 T_PriceAmount, 0 T_PriceDisc, 0 T_PriceDiscRp, 0 T_PriceSubTotal,
|
||||
0 T_PriceOther, 0 T_PriceTotal, T_TestForceSell, 'N' is_packet, 0 packet_id,
|
||||
'PXR' px_type, '[]' nat_test, '[]' child_test, 'N' IsFavourite,
|
||||
Nat_TestNat_TestTypeID, T_TestSasCode, $mouID Ss_PriceMouM_MouID
|
||||
from t_test
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID
|
||||
and Nat_TestIsActive = 'Y' and Nat_TestNat_TestTypeID = 5
|
||||
where length(T_TestSasCode) = 8 ";
|
||||
$qry = $this->db->query($sql, array($mouID));
|
||||
if (! $qry ) {
|
||||
return array(false, "Regional " . print_r($this->db->error(),true));
|
||||
}
|
||||
$p_rows = $qry->result_array();
|
||||
|
||||
$sql = "select distinct substr(T_TestSasCode,1,8) parentCode, 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, concat('[', T_TestNat_TestID , ']') nat_test, '[]' child_test, 'N' IsFavourite,
|
||||
Nat_TestNat_TestTypeID, T_TestSasCode,T_TestIsResult, T_TestCode
|
||||
from t_price
|
||||
join t_test on T_PriceT_TestID = T_TestID
|
||||
and T_PriceIsActive = 'Y' and T_TestIsActive = 'Y'
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_PriceIsCito = 'N'
|
||||
and length(T_TestSasCode) = 10
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID
|
||||
and Nat_TestIsActive = 'Y'
|
||||
where T_PriceM_MouID = ? ";
|
||||
$qry = $this->db->query($sql,array($mouID));
|
||||
if (!$qry ) {
|
||||
return array(false, "Regional child test " . print_r($this->db->error(),true));
|
||||
}
|
||||
$xrows = $qry->result_array();
|
||||
$arr_child = array();
|
||||
$p_codes = "'0'";
|
||||
foreach($xrows as $r ) {
|
||||
$pCode = $r["parentCode"];
|
||||
if ( ! isset($arr_child[$pCode])) {
|
||||
$arr_child[$pCode] = array();
|
||||
}
|
||||
$cCode = $r["T_TestSasCode"];
|
||||
$p_codes .= ", '$cCode'";
|
||||
unset($r["parentCode"]);
|
||||
$arr_child[$pCode][] = $r;
|
||||
}
|
||||
$sql = "select substr(T_TestSasCode,1,8) parentCode,
|
||||
group_concat(distinct T_TestNat_TestID) nat
|
||||
from t_test
|
||||
where ( T_TestIsResult = 'Y' or T_TestIsPrice = 'Y' )
|
||||
and T_TestSasCode in ( $p_codes )
|
||||
and T_TestIsActive = 'Y'
|
||||
group by parentCode";
|
||||
$qry = $this->db->query($sql,array($mouID));
|
||||
if (!$qry ) {
|
||||
return array(false, "Regional " . print_r($this->db->error(),true));
|
||||
}
|
||||
$xrows = $qry->result_array();
|
||||
$arr_nat = array();
|
||||
foreach($xrows as $r ) {
|
||||
$pCode = $r["parentCode"];
|
||||
//if ( ! isset($arr_nat[$pCode])) {
|
||||
// $arr_nat[$pCode] = array();
|
||||
//}
|
||||
$arr_nat[$pCode] = $r["nat"];
|
||||
}
|
||||
$flag_error = false;
|
||||
foreach($p_rows as $idx => $r) {
|
||||
$T_TestName= $r["T_TestName"] ;
|
||||
$sasCode = $r["T_TestSasCode"];
|
||||
if ( isset($arr_child[$sasCode]) ) {
|
||||
$the_childs = $arr_child[$sasCode];
|
||||
$p_rows[$idx]['child_test'] = json_encode($the_childs,true);
|
||||
if ( isset($arr_nat[$sasCode] )) {
|
||||
$p_rows[$idx]['nat_test'] = "[" . $arr_nat[$sasCode] . "]";
|
||||
}
|
||||
unset($p_rows[$idx]["Nat_TestNat_TestTypeID"]);
|
||||
unset($p_rows[$idx]["T_TestSasCode"]);
|
||||
} else {
|
||||
unset($p_rows[$idx]);
|
||||
}
|
||||
}
|
||||
//Paket Panel / Profile
|
||||
$sql = "select distinct $mouID T_PriceM_MouID, T_PacketID T_TestID, T_PacketName T_TestName, 'N' IsFromPanel, 0 Nat_TestID,
|
||||
T_PacketID T_PriceT_TestID, 'N' T_PriceIsCito, $companyID T_PriceM_CompanyID, $mouID T_PriceM_MouID,
|
||||
0 T_PricePriority, T_PacketOriginalBruto T_PriceAmount, 0 T_PriceDisc,
|
||||
(T_PacketOriginalBruto - T_PacketPrice) T_PriceDiscRp, 0 T_PriceSubTotal,
|
||||
0 T_PriceOther, T_PacketPrice T_PriceTotal, 'Y' T_TestForceSell, 'Y' is_packet, T_PacketID packet_id,
|
||||
T_PacketType px_type, '[]' nat_test, '[]' child_test, 'N' IsFavourite,
|
||||
$mouID Ss_PriceMouM_MouID
|
||||
from
|
||||
t_packet
|
||||
where
|
||||
T_PacketIsActive = 'Y'
|
||||
and T_PacketM_MouID = ?";
|
||||
|
||||
$qry = $this->db->query($sql, array($mouID));
|
||||
if (! $qry ) {
|
||||
return array(false, "Regional " . print_r($this->db->error(),true));
|
||||
}
|
||||
$pn_rows = $qry->result_array();
|
||||
foreach($pn_rows as $idx => $pnr) {
|
||||
$packetID = $pnr["packet_id"];
|
||||
//child test
|
||||
$sql = "select distinct $mouID T_PriceM_MouID, T_TestID, T_TestName, 'N' IsFromPanel, Nat_TestID,
|
||||
T_TestID T_PriceT_TestID, 'N' T_PriceIsCito, $companyID T_PriceM_CompanyID,
|
||||
$mouID T_PriceM_MouID, 0 T_PricePriority, T_PacketDetailPriceAmount T_PriceAmount,
|
||||
T_PacketDetailPriceDisc T_PriceDisc, T_PacketDetailPriceDiscRp T_PriceDiscRp, T_PacketDetailPriceSubTotal T_PriceSubTotal,
|
||||
0 T_PriceOther, T_PacketDetailPrice T_PriceTotal,
|
||||
'Y' T_TestForceSell, 'N' is_packet, 0 packet_id,
|
||||
'PX' px_type, concat('[', T_TestNat_TestID , ']') nat_test, '[]' child_test, 'N' IsFavourite, T_TestSasCode
|
||||
from t_packetdetail
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
and T_PacketDetailIsActive = 'Y' and T_TestIsActive = 'Y'
|
||||
and T_PacketDetailT_PacketID = ?
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID
|
||||
and Nat_TestIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql,array($packetID));
|
||||
if (!$qry ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
$ct_rows = $qry->result_array();
|
||||
$p_nat_test = array();
|
||||
foreach($ct_rows as $ct_idx => $cr) {
|
||||
$sasCode = $cr["T_TestSasCode"] . '%';
|
||||
$sql = "select distinct T_TestNat_TestID
|
||||
from t_test
|
||||
where T_TestSasCode like ?
|
||||
and T_TestIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql,array($sasCode));
|
||||
if (!$qry ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
$nt_rows = $qry->result_array();
|
||||
$t_rows = array();
|
||||
foreach($nt_rows as $nr) {
|
||||
$t_rows[] = intval( $nr["T_TestNat_TestID"]);
|
||||
$p_nat_test[]= intval( $nr["T_TestNat_TestID"]);
|
||||
}
|
||||
$ct_rows[$ct_idx]['nat_test'] = json_encode($t_rows,JSON_NUMERIC_CHECK);
|
||||
}
|
||||
if (count($ct_rows) > 0 ) {
|
||||
$x_arr = array();
|
||||
foreach($ct_rows as $x_cr) {
|
||||
$x_arr[] = $x_cr;
|
||||
}
|
||||
$pn_rows[$idx]['child_test'] = json_encode($x_arr,true);
|
||||
$pn_rows[$idx]['nat_test'] = json_encode($p_nat_test,true);
|
||||
}
|
||||
unset($pn_rows[$idx]["Nat_TestNat_TestTypeID"]);
|
||||
unset($pn_rows[$idx]["T_TestSasCode"]);
|
||||
}
|
||||
|
||||
$rows = array_merge($rows,$p_rows, $pn_rows);
|
||||
$qry = $this->db->query("delete from ss_price_mou where Ss_PriceMouM_MouID=?", array($mouID));
|
||||
if ( ! $qry ) {
|
||||
return array(false, "Regional " . print_r($this->db->error(),true));
|
||||
}
|
||||
$qry = $this->db->insert_batch("ss_price_mou", $rows);
|
||||
if ( ! $qry ) {
|
||||
return array(false, "Regional " . print_r($this->db->error(),true));
|
||||
}
|
||||
return array(true, "OK");
|
||||
}
|
||||
public function edit($mouID,$testID,$cito) {
|
||||
$CI =& get_instance();
|
||||
$this->db = $CI->load->database("onedev",true);
|
||||
|
||||
$sql = "select * from t_test where T_TestID = ? ";
|
||||
$qry = $this->db->query($sql, array($testID));
|
||||
if (! $qry ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return array(false, "No Test $testID found");
|
||||
}
|
||||
$sasCode = $rows[0]["T_TestSasCode"];
|
||||
if ( strlen($sasCode) == 8 ) {
|
||||
$flagProfile = false;
|
||||
} else {
|
||||
$flagProfile = true;
|
||||
}
|
||||
|
||||
$sql = "select * from m_mou where M_MouID = ?";
|
||||
$qry = $this->db->query($sql, array($mouID));
|
||||
if (! $qry ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return array(false, "No MOU $mouID found");
|
||||
}
|
||||
$mouName = $rows[0]["M_MouName"];
|
||||
$companyID = $rows[0]["M_MouM_CompanyID"];
|
||||
|
||||
$sql = "select distinct 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, $mouID Ss_PriceMouM_MouID
|
||||
from t_price
|
||||
join t_test on T_PriceT_TestID = T_TestID and T_TestID = ?
|
||||
and T_PriceIsActive = 'Y' and T_TestIsActive = 'Y'
|
||||
and T_TestIsPrice = 'Y' and T_PriceIsCito = ?
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID
|
||||
and Nat_TestIsActive = 'Y' and Nat_TestNat_TestTypeID <> 5
|
||||
where T_PriceM_MouID = ?";
|
||||
$qry = $this->db->query($sql, array($testID, $cito, $mouID));
|
||||
if (! $qry ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
|
||||
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 ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
$nt_rows = $qry->result_array();
|
||||
$t_rows = array($r["Nat_TestID"]);
|
||||
foreach($nt_rows as $nr) {
|
||||
$t_rows[] = $nr["T_TestNat_TestID"];
|
||||
}
|
||||
$rows[$idx]['nat_test'] = "[" . join(",",$t_rows) . "]";
|
||||
break;
|
||||
default :
|
||||
$rows[$idx]['nat_test'] = '[' . $r['Nat_TestID'] . ']';
|
||||
break;
|
||||
}
|
||||
unset($rows[$idx]["Nat_TestNat_TestTypeID"]);
|
||||
}
|
||||
if ( count($rows) > 0 ) {
|
||||
$r = $rows[0];
|
||||
unset($r["T_TestSasCode"]);
|
||||
$this->db->where("T_PriceM_MouID", $r["T_PriceM_MouID"]);
|
||||
$this->db->where("T_TestID", $r["T_TestID"]);
|
||||
$this->db->where("T_PriceIsCito", $r["T_PriceIsCito"]);
|
||||
$qry = $this->db->update("ss_price_mou",$r);
|
||||
if (! $qry ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
}
|
||||
$sasCode = substr($sasCode,0,8);
|
||||
foreach($rows as $idx => $r ) {
|
||||
if ( strlen($r["T_TestSasCode"]) > 8 ) {
|
||||
unset($rows[$idx]);
|
||||
} else {
|
||||
unset($rows[$idx]["T_TestSasCode"]);
|
||||
}
|
||||
}
|
||||
if ($cito == 'Y' ) {
|
||||
return array(true,"OK",$rows);
|
||||
}
|
||||
// for non cito
|
||||
if($flagProfile ) {
|
||||
//wip profile
|
||||
$sql = "select distinct $mouID T_PriceM_MouID, T_TestID, T_TestName, 'N' IsFromPanel, Nat_TestID,
|
||||
T_TestID T_PriceT_TestID, 'N' T_PriceIsCito, $companyID T_PriceM_CompanyID, $mouID T_PriceM_MouID,
|
||||
0 T_PricePriority, 0 T_PriceAmount, 0 T_PriceDisc, 0 T_PriceDiscRp, 0 T_PriceSubTotal,
|
||||
0 T_PriceOther, 0 T_PriceTotal, T_TestForceSell, 'N' is_packet, 0 packet_id,
|
||||
'PXR' px_type, '[]' nat_test, '[]' child_test, 'N' IsFavourite,
|
||||
Nat_TestNat_TestTypeID, T_TestSasCode, $mouID Ss_PriceMouM_MouID
|
||||
from t_test
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID and T_TestSasCode = ?
|
||||
and Nat_TestIsActive = 'Y' and Nat_TestNat_TestTypeID = 5
|
||||
where length(T_TestSasCode) = 8 ";
|
||||
$qry = $this->db->query($sql, array($sasCode));
|
||||
|
||||
if (! $qry ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
$p_rows = $qry->result_array();
|
||||
|
||||
$sasCodeLike = $sasCode . "%";
|
||||
$sql = "select distinct substr(T_TestSasCode,1,8) parentCode, 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, concat('[', T_TestNat_TestID , ']') nat_test, '[]' child_test, 'N' IsFavourite,
|
||||
Nat_TestNat_TestTypeID, T_TestSasCode,T_TestIsResult, T_TestCode
|
||||
from t_price
|
||||
join t_test on T_PriceT_TestID = T_TestID
|
||||
and T_PriceIsActive = 'Y' and T_TestIsActive = 'Y'
|
||||
and T_TestIsPrice = 'Y' and T_PriceIsCito = 'N'
|
||||
and T_TestSasCode like ?
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID
|
||||
and Nat_TestIsActive = 'Y'
|
||||
where T_PriceM_MouID = ? ";
|
||||
$qry = $this->db->query($sql,array($sasCodeLike,$mouID));
|
||||
if (!$qry ) {
|
||||
return array(false, "Regional child_test " . print_r($this->db->error(),true));
|
||||
}
|
||||
$xrows = $qry->result_array();
|
||||
$arr_child = array();
|
||||
$p_codes = "'0'";
|
||||
foreach($xrows as $r ) {
|
||||
$pCode = $r["parentCode"];
|
||||
if ( ! isset($arr_child[$pCode])) {
|
||||
$arr_child[$pCode] = array();
|
||||
}
|
||||
$cCode = $r["T_TestSasCode"];
|
||||
$p_codes .= ", '$cCode'";
|
||||
unset($r["parentCode"]);
|
||||
$arr_child[$pCode][] = $r;
|
||||
}
|
||||
|
||||
$sql = "select substr(T_TestSasCode,1,8) parentCode,
|
||||
group_concat(distinct T_TestNat_TestID) nat
|
||||
from t_test
|
||||
where ( T_TestIsResult = 'Y' or T_TestIsPrice = 'Y' )
|
||||
and T_TestSasCode in ( $p_codes )
|
||||
and T_TestIsActive = 'Y'
|
||||
group by parentCode";
|
||||
$qry = $this->db->query($sql,array($mouID));
|
||||
if (!$qry ) {
|
||||
return array(false, "Regional nat_test " . print_r($this->db->error(),true));
|
||||
}
|
||||
$xrows = $qry->result_array();
|
||||
$arr_nat = array();
|
||||
foreach($xrows as $r ) {
|
||||
$pCode = $r["parentCode"];
|
||||
//if ( ! isset($arr_nat[$pCode])) {
|
||||
// $arr_nat[$pCode] = array();
|
||||
//}
|
||||
$arr_nat[$pCode] = $r["nat"];
|
||||
}
|
||||
|
||||
$flag_error = false;
|
||||
foreach($p_rows as $idx => $r) {
|
||||
$T_TestName= $r["T_TestName"] ;
|
||||
$sasCode = $r["T_TestSasCode"];
|
||||
if ( isset($arr_child[$sasCode]) ) {
|
||||
$the_childs = $arr_child[$sasCode];
|
||||
$p_rows[$idx]['child_test'] = json_encode($the_childs,true);
|
||||
if ( isset($arr_nat[$sasCode] )) {
|
||||
$p_rows[$idx]['nat_test'] = "[" . $arr_nat[$sasCode] . "]";
|
||||
}
|
||||
unset($p_rows[$idx]["Nat_TestNat_TestTypeID"]);
|
||||
unset($p_rows[$idx]["T_TestSasCode"]);
|
||||
} else {
|
||||
unset($p_rows[$idx]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($p_rows as $r) {
|
||||
$this->db->where("T_PriceM_MouID", $r["T_PriceM_MouID"]);
|
||||
$this->db->where("T_TestID", $r["T_TestID"]);
|
||||
$this->db->where("T_PriceIsCito", $r["T_PriceIsCito"]);
|
||||
$qry = $this->db->update("ss_price_mou",$r);
|
||||
if (! $qry ) {
|
||||
return array(false, "Err Update Ss_priceMou " . print_r($this->db->error(),true));
|
||||
}
|
||||
}
|
||||
$rows = array_merge($rows,$p_rows);
|
||||
}
|
||||
//Update Panel yang mengandung Test
|
||||
$sql = "select
|
||||
distinct T_PacketDetailT_PacketID
|
||||
from
|
||||
t_packetdetail
|
||||
where T_PacketDetailIsActive = 'Y'
|
||||
and T_PacketDetailT_TestID = ?";
|
||||
$qry = $this->db->query($sql, array($testID));
|
||||
if (!$qry) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
$xrows = $qry->result_array();
|
||||
$packet_ids = "0";
|
||||
foreach($xrows as $r ) {
|
||||
$packet_ids .= "," . $r["T_PacketDetailT_PacketID"];
|
||||
}
|
||||
|
||||
$sql = "select distinct $mouID T_PriceM_MouID, T_PacketID T_TestID, T_PacketName T_TestName, 'N' IsFromPanel, 0 Nat_TestID,
|
||||
T_PacketID T_PriceT_TestID, 'N' T_PriceIsCito, $companyID T_PriceM_CompanyID, $mouID T_PriceM_MouID,
|
||||
0 T_PricePriority, T_PacketOriginalBruto T_PriceAmount, 0 T_PriceDisc,
|
||||
(T_PacketOriginalBruto - T_PacketPrice) T_PriceDiscRp, 0 T_PriceSubTotal,
|
||||
0 T_PriceOther, T_PacketPrice T_PriceTotal, 'Y' T_TestForceSell, 'Y' is_packet, T_PacketID packet_id,
|
||||
T_PacketType px_type, '[]' nat_test, '[]' child_test, 'N' IsFavourite,
|
||||
$mouID Ss_PriceMouM_MouID
|
||||
from
|
||||
t_packet
|
||||
where
|
||||
T_PacketIsActive = 'Y' and T_PacketID in ( $packet_ids )
|
||||
and T_PacketM_MouID = ?";
|
||||
|
||||
$qry = $this->db->query($sql, array($mouID));
|
||||
if (! $qry ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
$pn_rows = $qry->result_array();
|
||||
foreach($pn_rows as $idx => $pnr) {
|
||||
$packetID = $pnr["packet_id"];
|
||||
//child test
|
||||
$sql = "select $mouID T_PriceM_MouID, T_TestID, T_TestName, 'N' IsFromPanel, Nat_TestID,
|
||||
T_TestID T_PriceT_TestID, 'N' T_PriceIsCito, $companyID T_PriceM_CompanyID,
|
||||
$mouID T_PriceM_MouID, 0 T_PricePriority, T_PacketDetailPriceAmount T_PriceAmount,
|
||||
T_PacketDetailPriceDisc T_PriceDisc, T_PacketDetailPriceDiscRp T_PriceDiscRp, T_PacketDetailPriceSubTotal T_PriceSubTotal,
|
||||
0 T_PriceOther, T_PacketDetailPrice T_PriceTotal,
|
||||
'Y' T_TestForceSell, 'N' is_packet, 0 packet_id,
|
||||
'PX' px_type, '[]' nat_test, '[]' child_test, 'N' IsFavourite, T_TestSasCode
|
||||
from t_packetdetail
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
and T_PacketDetailIsActive = 'Y' and T_TestIsActive = 'Y'
|
||||
and T_PacketDetailT_PacketID = ?
|
||||
join nat_test on T_TestNat_TestID = Nat_TestID
|
||||
and Nat_TestIsActive = 'Y'
|
||||
";
|
||||
$qry = $this->db->query($sql,array($packetID));
|
||||
if (!$qry ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
$ct_rows = $qry->result_array();
|
||||
$p_nat_test = array();
|
||||
foreach($ct_rows as $ct_idx => $cr) {
|
||||
$sasCode = $cr["T_TestSasCode"] . '%';
|
||||
$sql = "select distinct T_TestNat_TestID
|
||||
from t_test
|
||||
where T_TestSasCode like ?
|
||||
and T_TestIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql,array($sasCode));
|
||||
if (!$qry ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
$nt_rows = $qry->result_array();
|
||||
$t_rows = array();
|
||||
foreach($nt_rows as $nr) {
|
||||
$t_rows[] = intval( $nr["T_TestNat_TestID"]);
|
||||
$p_nat_test[]= intval( $nr["T_TestNat_TestID"]);
|
||||
}
|
||||
$ct_rows[$ct_idx]['nat_test'] = json_encode($t_rows,JSON_NUMERIC_CHECK);
|
||||
}
|
||||
if (count($ct_rows) > 0 ) {
|
||||
$x_arr = array();
|
||||
foreach($ct_rows as $x_cr) {
|
||||
$x_arr[] = $x_cr;
|
||||
}
|
||||
$pn_rows[$idx]['child_test'] = json_encode($x_arr,true);
|
||||
$pn_rows[$idx]['nat_test'] = json_encode($p_nat_test,true);
|
||||
}
|
||||
unset($pn_rows[$idx]["Nat_TestNat_TestTypeID"]);
|
||||
unset($pn_rows[$idx]["T_TestSasCode"]);
|
||||
}
|
||||
foreach($pn_rows as $r ) {
|
||||
$this->db->where("T_PriceM_MouID", $r["T_PriceM_MouID"]);
|
||||
$this->db->where("T_TestID", $r["T_TestID"]);
|
||||
$this->db->where("T_PriceIsCito", $r["T_PriceIsCito"]);
|
||||
$qry = $this->db->update("ss_price_mou",$r);
|
||||
if (! $qry ) {
|
||||
return array(false, print_r($this->db->error(),true));
|
||||
}
|
||||
}
|
||||
$rows = array_merge($rows,$pn_rows);
|
||||
return array(true,"OK",$rows);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user