373 lines
13 KiB
PHP
373 lines
13 KiB
PHP
<?php
|
|
class Tat_v2 extends MY_Controller
|
|
{
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->db = $this->load->database("onedev", true);
|
|
}
|
|
function nonlab($prm_date) {
|
|
$sql = "call sp_rpt_tat_002(?,?,'admin')";
|
|
$qry = $this->db->query($sql,array($prm_date, $prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR ss_tat_002 : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$o_rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
$sql = "delete from ss_tat_v2_nonlab where SsTatV2NonLabDate = ?";
|
|
$qry = $this->db->query($sql,array($prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR del ss_tat_v2_nolab : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$rows = array();
|
|
foreach($o_rows as $r) {
|
|
$rows[] = array(
|
|
"SsTatV2NonLabDate"=> $prm_date,
|
|
"SsTatV2NonLabNat_GroupID"=> $r["Nat_GroupID"],
|
|
"SsTatV2NonLabNat_GroupName"=> $r["Nat_GroupName"],
|
|
"SsTatV2NonLabHandlingData"=> $r["data"],
|
|
"SsTatV2NonLabHandling"=> $r["hasil"],
|
|
"SsTatV2NonLabHandlingPct"=> $r["persen"]
|
|
);
|
|
}
|
|
$qry = $this->db->insert_batch("ss_tat_v2_nonlab", $rows);
|
|
if (! $qry ) {
|
|
echo "ERR insert ss_tat_v2_nonlab : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$date = Date("Y-m-d H:i:s");
|
|
echo "$date Insert ss_tat_v2_nonlab Handling \n";
|
|
|
|
$sql = "call sp_rpt_tat_002i(?,?,'admin')";
|
|
$qry = $this->db->query($sql,array($prm_date, $prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR ss_tat_002 i : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$o_rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
|
|
foreach($o_rows as $r) {
|
|
$this->db->where("SsTatV2NonLabDate", $prm_date);
|
|
$this->db->where("SsTatV2NonLabNat_GroupID" , $r["Nat_GroupID"]);
|
|
$rows = array(
|
|
"SsTatV2NonLabVerifikasiData" => $r["data"],
|
|
"SsTatV2NonLabVerifikasi" => $r["hasil"],
|
|
"SsTatV2NonLabVerifikasiPct" => $r["persen"]
|
|
);
|
|
$qry = $this->db->update("ss_tat_v2_nonlab", $rows);
|
|
}
|
|
|
|
$date = Date("Y-m-d H:i:s");
|
|
echo "$date Insert ss_tat_v2_nonlab Verifikasi\n";
|
|
|
|
$sql = "call sp_rpt_tat_002ii(?,?,'admin')";
|
|
$qry = $this->db->query($sql,array($prm_date, $prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR ss_tat_002 ii : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$o_rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
|
|
foreach($o_rows as $r) {
|
|
$this->db->where("SsTatV2NonLabDate", $prm_date);
|
|
$this->db->where("SsTatV2NonLabNat_GroupID" , $r["Nat_GroupID"]);
|
|
$rows = array(
|
|
"SsTatV2NonLabHandlingImageData" => $r["data"],
|
|
"SsTatV2NonLabHandlingImage" => $r["hasil"],
|
|
"SsTatV2NonLabHandlingImagePct" => $r["persen"]
|
|
);
|
|
$qry = $this->db->update("ss_tat_v2_nonlab", $rows);
|
|
}
|
|
|
|
$date = Date("Y-m-d H:i:s");
|
|
echo "$date Insert ss_tat_v2_nonlab Handling Image \n";
|
|
|
|
|
|
$sql = "call sp_rpt_tat_002iii(?,?,'admin')";
|
|
$qry = $this->db->query($sql,array($prm_date, $prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR ss_tat_002 iii : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$o_rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
|
|
foreach($o_rows as $r) {
|
|
$this->db->where("SsTatV2NonLabDate", $prm_date);
|
|
$this->db->where("SsTatV2NonLabNat_GroupID" , $r["Nat_GroupID"]);
|
|
$rows = array(
|
|
"SsTatV2NonLabValidasiData" => $r["data"],
|
|
"SsTatV2NonLabValidasi" => $r["hasil"],
|
|
"SsTatV2NonLabValidasiPct" => $r["persen"]
|
|
);
|
|
$qry = $this->db->update("ss_tat_v2_nonlab", $rows);
|
|
}
|
|
|
|
$date = Date("Y-m-d H:i:s");
|
|
echo "$date Insert ss_tat_v2_nonlab Validasi\n";
|
|
|
|
$sql = "call sp_rpt_tat_002iiii(?,?,'admin')";
|
|
$qry = $this->db->query($sql,array($prm_date, $prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR ss_tat_002 iiii : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$o_rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
|
|
foreach($o_rows as $r) {
|
|
$this->db->where("SsTatV2NonLabDate", $prm_date);
|
|
$this->db->where("SsTatV2NonLabNat_GroupID" , $r["Nat_GroupID"]);
|
|
$rows = array(
|
|
"SsTatV2NonLabTerimaFoData" => $r["data"],
|
|
"SsTatV2NonLabTerimaFo" => $r["hasil"],
|
|
"SsTatV2NonLabTerimaFoPct" => $r["persen"]
|
|
);
|
|
$qry = $this->db->update("ss_tat_v2_nonlab", $rows);
|
|
}
|
|
|
|
$date = Date("Y-m-d H:i:s");
|
|
echo "$date Insert ss_tat_v2_nonlab Terima FO\n";
|
|
|
|
}
|
|
|
|
function do($prm_date) {
|
|
$sql = "call sp_rpt_tat_001(?,?,'admin')";
|
|
$qry = $this->db->query($sql,array($prm_date, $prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR ss_tat_001 : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$o_rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
$sql = "delete from ss_tat_v2 where SsTatV2Date = ?";
|
|
$qry = $this->db->query($sql,array($prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR del ss_tat_v2 : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$rows = array();
|
|
foreach($o_rows as $r) {
|
|
$rows[] = array(
|
|
"SsTatV2Date"=> $prm_date,
|
|
"SsTatV2Month"=> $r["bulan"],
|
|
"SsTatV2FoTargetEntry"=> $r["targetentry"],
|
|
"SsTatV2FoVerif"=> $r["verif"],
|
|
"SsTatV2FoTotalData"=> $r["totaldata"],
|
|
"SsTatV2FoPctFo"=> $r["persenfo"],
|
|
"SsTatV2FoPctVerif"=> $r["persenverif"]
|
|
);
|
|
}
|
|
$qry = $this->db->insert_batch("ss_tat_v2", $rows);
|
|
if (! $qry ) {
|
|
echo "ERR insert ss_tat_v2 : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$date = Date("Y-m-d H:i:s");
|
|
echo "$date Insert ss_tat_v2 FO \n";
|
|
|
|
//Delete daily ss_tat_v2
|
|
$sql = "delete from ss_tat_v2b where SsTatV2bDate = ?";
|
|
$qry = $this->db->query($sql,array($prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR del ss_tat_v2b : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
//i Nat_GroupID [T_SampleStationID] [T_SampleStationName] [data] [hasil] [persen]
|
|
$sql = "call sp_rpt_tat_001i(?,?,'admin')";
|
|
$qry = $this->db->query($sql,array($prm_date, $prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR ss_tat_001 i : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$o_rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
|
|
$rows = array();
|
|
foreach($o_rows as $r) {
|
|
$rows[] = array(
|
|
"SsTatV2bDate" => $prm_date,
|
|
"SsTatV2bNat_GroupID" => $r["Nat_GroupID"],
|
|
"SsTatV2bT_SampleStationID" => $r["T_SampleStationID"],
|
|
"SsTatV2bT_SampleStationName" => $r["T_SampleStationName"],
|
|
"SsTatV2bTungguData" => $r["data"],
|
|
"SsTatV2bTunggu" => $r["hasil"],
|
|
"SsTatV2bTungguPct" => $r["persen"]
|
|
);
|
|
}
|
|
|
|
$qry = $this->db->insert_batch("ss_tat_v2b", $rows);
|
|
$date = Date("Y-m-d H:i:s");
|
|
echo "$date Insert ss_tat_v2b ( i ) \n";
|
|
|
|
//ii [data] [hasil] [persen]
|
|
$sql = "call sp_rpt_tat_001ii(?,?,'admin')";
|
|
$qry = $this->db->query($sql,array($prm_date, $prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR ss_tat_001 ii : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$o_rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
|
|
$rows = array();
|
|
foreach($o_rows as $r) {
|
|
$rows = array(
|
|
"SsTatV2SamplingData" => $r["data"],
|
|
"SsTatV2SamplingHasil" => $r["hasil"],
|
|
"SsTatV2SamplingPct" => $r["persen"]
|
|
);
|
|
}
|
|
$this->db->where("SsTatV2Date", $prm_date);
|
|
$qry = $this->db->update("ss_tat_v2", $rows);
|
|
|
|
$date = Date("Y-m-d H:i:s");
|
|
echo "$date Update ss_tat_v2 Sampling ( ii ) \n";
|
|
|
|
//iii [data] [hasil] [persen]
|
|
$sql = "call sp_rpt_tat_001iii(?,?,'admin')";
|
|
$qry = $this->db->query($sql,array($prm_date, $prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR ss_tat_001 iii : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$o_rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
$rows = array();
|
|
foreach($o_rows as $r) {
|
|
$rows = array(
|
|
"SsTatV2VerifData" => $r["data"],
|
|
"SsTatV2VerifHasil" => $r["hasil"],
|
|
"SsTatV2VerifPct" => $r["persen"]
|
|
);
|
|
}
|
|
$this->db->where("SsTatV2Date", $prm_date);
|
|
$qry = $this->db->update("ss_tat_v2", $rows);
|
|
|
|
$date = Date("Y-m-d H:i:s");
|
|
echo "$date Update ss_tat_v2 Verif ( iii ) \n";
|
|
|
|
//iiii [data] [hasil] [persen]
|
|
$sql = "call sp_rpt_tat_001iiii(?,?,'admin')";
|
|
$qry = $this->db->query($sql,array($prm_date, $prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR ss_tat_001 iiii : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$o_rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
$rows = array();
|
|
foreach($o_rows as $r) {
|
|
$rows = array(
|
|
"SsTatV2PengolahanData" => $r["data"],
|
|
"SsTatV2PengolahanHasil" => $r["hasil"],
|
|
"SsTatV2PengolahanPct" => $r["persen"]
|
|
);
|
|
}
|
|
$this->db->where("SsTatV2Date", $prm_date);
|
|
$qry = $this->db->update("ss_tat_v2", $rows);
|
|
|
|
$date = Date("Y-m-d H:i:s");
|
|
echo "$date Update ss_tat_v2 Pengolahan ( iiii ) \n";
|
|
|
|
//v [Nat_SubgroupID] [Nat_SubgroupName] [data] [hasil] [persen]
|
|
$sql = "call sp_rpt_tat_001iiiii(?,?,'admin')";
|
|
$qry = $this->db->query($sql,array($prm_date, $prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR ss_tat_001 iiiii : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$o_rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
$rows = array();
|
|
foreach($o_rows as $r) {
|
|
$rows[] = array(
|
|
"SsTatV2cDate" => $prm_date,
|
|
"SsTatV2cNat_SubgroupID" => $r["Nat_SubgroupID"],
|
|
"SsTatV2cNat_SubgroupName" => $r["Nat_SubgroupName"],
|
|
"SsTatV2cVerifikasiData" => $r["data"],
|
|
"SsTatV2cVerifikasi" => $r["hasil"],
|
|
"SsTatV2cVerifikasiPct" => $r["persen"]
|
|
);
|
|
}
|
|
|
|
$qry = $this->db->insert_batch("ss_tat_v2c", $rows);
|
|
$date = Date("Y-m-d H:i:s");
|
|
echo "$date Insert ss_tat_v2c Verifikasi ( iiiii ) \n";
|
|
|
|
|
|
//vi Validasi
|
|
$sql = "call sp_rpt_tat_001iiiiii(?,?,'admin')";
|
|
$qry = $this->db->query($sql,array($prm_date, $prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR ss_tat_001 vi : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$o_rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
$rows = array();
|
|
foreach($o_rows as $r) {
|
|
$rows = array(
|
|
"SsTatV2ValidasiData" => $r["data"],
|
|
"SsTatV2ValidasiHasil" => $r["hasil"],
|
|
"SsTatV2ValidasiPct" => $r["persen"]
|
|
);
|
|
}
|
|
$this->db->where("SsTatV2Date", $prm_date);
|
|
$qry = $this->db->update("ss_tat_v2", $rows);
|
|
|
|
$date = Date("Y-m-d H:i:s");
|
|
echo "$date Update ss_tat_v2 Validasi( iiiiii ) \n";
|
|
|
|
//vii [data] [hasil] [persen]
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
$sql = "call sp_rpt_tat_001iiiiiii(?,?,'admin')";
|
|
$qry = $this->db->query($sql,array($prm_date, $prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR ss_tat_001 vii : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$o_rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
$rows = array();
|
|
foreach($o_rows as $r) {
|
|
$rows = array(
|
|
"SsTatV2AdmLabData" => $r["data"],
|
|
"SsTatV2AdmLabHasil" => $r["hasil"],
|
|
"SsTatV2AdmLabPct" => $r["persen"]
|
|
);
|
|
}
|
|
$this->db->where("SsTatV2Date", $prm_date);
|
|
$qry = $this->db->update("ss_tat_v2", $rows);
|
|
|
|
$date = Date("Y-m-d H:i:s");
|
|
echo "$date Update ss_tat_v2 Adm Lab ( vii ) \n";
|
|
|
|
//viii [data] [hasil] [persen]
|
|
$sql = "call sp_rpt_tat_001iiiiiiii(?,?,'admin')";
|
|
$qry = $this->db->query($sql,array($prm_date, $prm_date));
|
|
if (! $qry ) {
|
|
echo "ERR ss_tat_001 viii : " . print_r( $this->db->error(), true) . "\n";
|
|
exit;
|
|
}
|
|
$o_rows = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
$rows = array();
|
|
foreach($o_rows as $r) {
|
|
$rows = array(
|
|
"SsTatV2FullLabData" => $r["data"],
|
|
"SsTatV2FullLabHasil" => $r["hasil"],
|
|
"SsTatV2FullLabPct" => $r["persen"]
|
|
);
|
|
}
|
|
$this->db->where("SsTatV2Date", $prm_date);
|
|
$qry = $this->db->update("ss_tat_v2", $rows);
|
|
|
|
$date = Date("Y-m-d H:i:s");
|
|
echo "$date Update ss_tat_v2 Full Lab ( viii ) \n";
|
|
}
|
|
}
|