Initial import
This commit is contained in:
268
one-api/application/controllers/one_mitra/Updatestatusreg.php
Normal file
268
one-api/application/controllers/one_mitra/Updatestatusreg.php
Normal file
@@ -0,0 +1,268 @@
|
||||
<?php
|
||||
class Updatestatusreg extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function index()
|
||||
{
|
||||
echo "Api: UPDATE STATUS X/R";
|
||||
}
|
||||
function reply($resp)
|
||||
{
|
||||
echo json_encode($resp);
|
||||
}
|
||||
|
||||
function reply_gz($resp, $debug = "")
|
||||
{
|
||||
if ($debug != "") {
|
||||
echo json_encode($resp);
|
||||
} else {
|
||||
echo gzcompress(json_encode($resp));
|
||||
}
|
||||
}
|
||||
|
||||
function get_param()
|
||||
{
|
||||
$body = file_get_contents("php://input");
|
||||
return json_decode($body, true);
|
||||
}
|
||||
|
||||
function get_param_z()
|
||||
{
|
||||
$body_z = file_get_contents("php://input");
|
||||
$body = gzuncompress($body_z);
|
||||
return json_decode($body, true);
|
||||
}
|
||||
function updatestatusorder()
|
||||
{
|
||||
try {
|
||||
$prm = $this->get_param_z();
|
||||
|
||||
$orderList = $prm['order'];
|
||||
$waList = $prm['wa'];
|
||||
$success = [];
|
||||
$error = [];
|
||||
$errorMsg = [];
|
||||
$successWa = [];
|
||||
$errorWa = [];
|
||||
$errorMsgWa = [];
|
||||
for ($i = 0; $i < count($orderList); $i++) {
|
||||
$sql_update = "UPDATE one_mitra.t_order
|
||||
SET T_OrderStatus = 'Y'
|
||||
WHERE T_OrderIsActive = 'Y'
|
||||
AND T_OrderID = ?";
|
||||
$qry_update = $this->db->query($sql_update, [$orderList[$i]]);
|
||||
if (!$qry_update) {
|
||||
$error[] = $orderList[$i];
|
||||
$errorMsg[] = $this->db->error();
|
||||
} else {
|
||||
$success[] = $orderList[$i];
|
||||
}
|
||||
}
|
||||
for ($i = 0; $i < count($waList); $i++) {
|
||||
$sql_update = "UPDATE one_mitra.t_order
|
||||
SET T_OrderStatusQR = 'S'
|
||||
WHERE T_OrderIsActive = 'Y'
|
||||
AND T_OrderID = ?";
|
||||
$qry_update = $this->db->query($sql_update, $waList[$i]);
|
||||
if (!$qry_update) {
|
||||
$errorWa[] = $waList[$i];
|
||||
$errorMsgWa[] = $this->db->error();
|
||||
} else {
|
||||
$successWa[] = $waList[$i];
|
||||
}
|
||||
}
|
||||
$resultOrder = [
|
||||
"success" => $success,
|
||||
"error" => $error,
|
||||
"message" => $errorMsg,
|
||||
];
|
||||
$resultWa = [
|
||||
"success" => $successWa,
|
||||
"error" => $errorWa,
|
||||
"message" => $errorMsgWa,
|
||||
];
|
||||
|
||||
|
||||
$result = [
|
||||
"order" => $resultOrder,
|
||||
"wa" => $resultWa
|
||||
];
|
||||
$this->reply_gz($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function updatestatus()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
$successUpdate = array();
|
||||
$errorUpdate = array();
|
||||
$errorMsg = array();
|
||||
for ($i = 0; $i < count($prm); $i++) {
|
||||
|
||||
$sql = "UPDATE one_mitra.t_order
|
||||
SET T_OrderStatus = ?
|
||||
WHERE T_OrderID = ?
|
||||
AND T_OrderIsActive ='Y'";
|
||||
$query = $this->db->query($sql, [$prm[$i]['T_OrderStatus'], $prm[$i]['T_OrderID']]);
|
||||
if (!$query) {
|
||||
$message = $this->db->error();
|
||||
// $this->sys_error($message);
|
||||
$errorUpdate[] = $prm[$i]['T_OrderID'];
|
||||
$errorMsg[] = $message;
|
||||
} else {
|
||||
for ($j = 0; $j < count($prm[$i]['sample']); $j++) {
|
||||
if ($prm[$i]['sample'][$j]['type'] == "S") {
|
||||
$sql_update = "UPDATE one_mitra.t_orderdetailsample
|
||||
SET T_OrderDetailSampleStatus = ?
|
||||
WHERE T_OrderDetailSampleID = ?
|
||||
AND T_OrderDetailSampleIsActive = 'Y'";
|
||||
$query_update = $this->db->query($sql_update, [
|
||||
$prm[$i]['sample'][$j]['status'],
|
||||
$prm[$i]['sample'][$j]['id']
|
||||
]);
|
||||
if (!$query_update) {
|
||||
$message = $this->db->error();
|
||||
// $this->sys_error($message);
|
||||
$errorMsg[] = $message;
|
||||
}
|
||||
} else if ($prm[$i]['sample'][$j]['type'] == "B") {
|
||||
$sql_update = "UPDATE one_mitra.t_orderdetailbahan
|
||||
SET T_OrderDetailBahanStatus = ?
|
||||
WHERE T_OrderDetailBahanID = ?
|
||||
AND T_OrderDetailBahanIsActive = 'Y'";
|
||||
$query_update = $this->db->query($sql_update, [
|
||||
$prm[$i]['sample'][$j]['status'],
|
||||
$prm[$i]['sample'][$j]['id']
|
||||
]);
|
||||
if (!$query_update) {
|
||||
$message = $this->db->error();
|
||||
// $this->sys_error($message);
|
||||
$errorMsg[] = $message;
|
||||
}
|
||||
}
|
||||
}
|
||||
$successUpdate[] = $prm[$i]['T_OrderID'];
|
||||
}
|
||||
}
|
||||
// $result = $query->result_array();
|
||||
// $z_param = gzcompress(json_encode($result));
|
||||
|
||||
$result = [
|
||||
"success" => $successUpdate,
|
||||
"error" => $errorUpdate,
|
||||
"msg" => $errorMsg,
|
||||
|
||||
];
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function updatestatuspq()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
$successUpdate = array();
|
||||
$errorUpdate = array();
|
||||
$errorMsg = array();
|
||||
for ($i = 0; $i < count($prm); $i++) {
|
||||
|
||||
$sql = "UPDATE one_mitra.t_order
|
||||
SET T_OrderStatus = ?
|
||||
WHERE T_OrderID = ?
|
||||
AND T_OrderIsActive ='Y'";
|
||||
$query = $this->db->query($sql, [$prm[$i]['status'], $prm[$i]['orderID']]);
|
||||
if (!$query) {
|
||||
$message = $this->db->error();
|
||||
// $this->sys_error($message);
|
||||
$errorUpdate[] = $prm[$i]['orderID'];
|
||||
$errorMsg[] = $message;
|
||||
} else {
|
||||
$successUpdate[] = $prm[$i]['orderID'];
|
||||
}
|
||||
}
|
||||
// $result = $query->result_array();
|
||||
// $z_param = gzcompress(json_encode($result));
|
||||
|
||||
$result = [
|
||||
"success" => $successUpdate,
|
||||
"error" => $errorUpdate,
|
||||
"msg" => $errorMsg,
|
||||
|
||||
];
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function checkorderdone()
|
||||
{
|
||||
try {
|
||||
$sql = "SELECT
|
||||
T_OrderID AS orderID,
|
||||
T_OrderNumber AS orderNumber,
|
||||
YEAR(T_OrderDate) AS year,
|
||||
T_OrderM_CompanyID AS company_id
|
||||
FROM one_mitra.t_order
|
||||
WHERE T_OrderStatus IN ('P', 'Q')
|
||||
AND T_OrderIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, []);
|
||||
if (!$query) {
|
||||
$message = $this->db->error();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$rst = $query->result_array();
|
||||
// $a = glob("/data-s3/$companyID/$yearFull/$orderNum*pdf");
|
||||
// $rst[] = [
|
||||
// "company_id" => "1710",
|
||||
// "year" => "2023",
|
||||
// "orderNumber" => "MT231010001"
|
||||
// ];
|
||||
$orderList = [];
|
||||
$error = [];
|
||||
$errorMsg = [];
|
||||
$success = [];
|
||||
for ($i = 0; $i < count($rst); $i++) {
|
||||
$companyID = $rst[$i]["company_id"];
|
||||
$year = $rst[$i]["year"];
|
||||
$orderNumber = $rst[$i]["orderNumber"];
|
||||
$a = glob("/data-s3/$companyID/$year/$orderNumber*pdf");
|
||||
if (count($a) > 0) {
|
||||
$sql = "UPDATE one_mitra.t_order
|
||||
SET T_OrderStatus = 'D'
|
||||
WHERE T_OrderID = ?
|
||||
AND T_OrderIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, [$rst[$i]["orderID"]]);
|
||||
if (!$query) {
|
||||
$error[] = $rst[$i]["orderNumber"];
|
||||
$errorMsg[] = $this->db->error();
|
||||
} {
|
||||
$success[] = $rst[$i]["orderNumber"];
|
||||
}
|
||||
}
|
||||
$orderList[] = $orderNumber;
|
||||
}
|
||||
$result = [
|
||||
"list_order" => $orderList,
|
||||
"error" => $error,
|
||||
"success" => $success,
|
||||
"errorMsg" => $errorMsg
|
||||
];
|
||||
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user