117 lines
3.3 KiB
PHP
117 lines
3.3 KiB
PHP
<?php
|
|
class Updateprocessresult 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 updateprocess()
|
|
{
|
|
try {
|
|
$prm = $this->get_param_z();
|
|
|
|
$orderList = $prm['order'];
|
|
$success = [];
|
|
$error = [];
|
|
$errorMsg = [];
|
|
for ($i = 0; $i < count($orderList); $i++) {
|
|
$sql_update = "UPDATE one_mitra.t_order
|
|
SET T_OrderStatus = 'P'
|
|
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];
|
|
}
|
|
}
|
|
$resultOrder = [
|
|
"success" => $success,
|
|
"error" => $error,
|
|
"message" => $errorMsg,
|
|
];
|
|
|
|
|
|
$result = [
|
|
"order" => $resultOrder
|
|
];
|
|
$this->reply_gz($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
function updateresult()
|
|
{
|
|
try {
|
|
$prm = $this->get_param_z();
|
|
|
|
$orderList = $prm['order'];
|
|
$success = [];
|
|
$error = [];
|
|
$errorMsg = [];
|
|
for ($i = 0; $i < count($orderList); $i++) {
|
|
$sql_update = "UPDATE one_mitra.t_order
|
|
SET T_OrderStatus = 'R'
|
|
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];
|
|
}
|
|
}
|
|
$resultOrder = [
|
|
"success" => $success,
|
|
"error" => $error,
|
|
"message" => $errorMsg,
|
|
];
|
|
|
|
|
|
$result = [
|
|
"order" => $resultOrder
|
|
];
|
|
$this->reply_gz($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
}
|