74 lines
2.2 KiB
PHP
74 lines
2.2 KiB
PHP
<?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)
|
|
);
|
|
*/
|
|
?>
|