Initial import
This commit is contained in:
129
application/controllers/tools/Xstatusbranch_v2-devone.php
Normal file
129
application/controllers/tools/Xstatusbranch_v2-devone.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
class Xstatusbranch_v2 extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
function index() {
|
||||
echo "API";
|
||||
}
|
||||
function update() {
|
||||
$prm = $this->sys_input;
|
||||
foreach($prm as $p) {
|
||||
$deliveryOrderID = $p["incomingRefT_RefDeliveryOrderID"];
|
||||
$detailID = $p["incomingRefDetailT_OrderDetailID"];
|
||||
$normalValueID = $p["T_OrderDetailNat_NormalValueID"];
|
||||
$result = $p["T_OrderDetailResult"];
|
||||
$validation = $p["T_OrderDetailValidation"];
|
||||
$verification = $p["T_OrderDetailVerification"];
|
||||
$status = $p["incomingRefDetailStatus"];
|
||||
$note = '';
|
||||
if (isset($p["note"])) $note = $p["note"];
|
||||
if ($validation == "Y") {
|
||||
$ret = $this->update_delivery($deliveryOrderID,$detailID,"$result","VALIDATION",$note);
|
||||
if ($ret) $ret = $this->update_order($detailID,$result,$normalValueID);
|
||||
} elseif($verification == "Y") {
|
||||
$ret = $this->update_delivery($deliveryOrderID,$detailID,"$result","VERIFICATION",$note);
|
||||
} elseif($status != "N") {
|
||||
$ret = $this->update_delivery($deliveryOrderID,$detailID,"Diterima");
|
||||
} else {
|
||||
$ret = $this->update_delivery($deliveryOrderID,$detailID,"Ditolak");
|
||||
}
|
||||
if (! $ret ) {
|
||||
echo json_encode( array("status"=>"ERR", "message"=> print_r($this->db->error(),true) ));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
echo json_encode( array("status"=>"OK", "message"=>""));
|
||||
}
|
||||
function update_delivery($deliveryOrderID,$detailID,$value,$stage = "", $note = "" ) {
|
||||
$sql = "select T_RefDeliveryOrderDetailT_OrderDetailID ,
|
||||
T_RefDeliveryOrderDetailID,
|
||||
T_RefDeliveryOrderChildID
|
||||
from t_ref_deliveryorder_child
|
||||
join t_ref_deliveryorder_detail on
|
||||
T_RefDeliveryOrderChildT_RefDeliveryOrderDetailID = T_RefDeliveryOrderDetailID
|
||||
where T_RefDeliveryOrderDetailT_RefDeliveryOrderID = ?
|
||||
and T_RefDeliveryOrderChildT_OrderDetailID = ?";
|
||||
$qry = $this->db->query($sql, array($deliveryOrderID, $detailID));
|
||||
$flag_child = false;
|
||||
$child_id = 0;
|
||||
$refDeliveryOrderDetailID = 0;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$flag_child = true;
|
||||
$child_id = $rows[0]["T_RefDeliveryOrderChildID"];
|
||||
$parentDetailID = $rows[0]["T_RefDeliveryOrderDetailID"];
|
||||
}
|
||||
}
|
||||
if ($flag_child) {
|
||||
$sql = "update t_ref_deliveryorder_child
|
||||
set T_RefDeliveryOrderChildResult = ?,
|
||||
T_RefDeliveryOrderChildStage= ? ,
|
||||
T_RefDeliveryOrderChildNote = ?
|
||||
where T_RefDeliveryOrderChildID=?";
|
||||
|
||||
$qry = $this->db->query($sql, array($value, $state, $note, $child_id));
|
||||
$value = "...";
|
||||
$detailID = $parentDetailID;
|
||||
}
|
||||
|
||||
if ($flag_child) {
|
||||
$sql = "update t_ref_deliveryorder_detail
|
||||
set T_RefDeliveryOrderDetailResult = ?,
|
||||
T_RefDeliveryOrderDetailStage = ?,
|
||||
T_RefDeliveryOrderDetailNote = ?
|
||||
where T_RefDeliveryOrderDetailT_RefDeliveryOrderID = ?
|
||||
and T_RefDeliveryOrderDetailID = ?";
|
||||
} else {
|
||||
$sql = "update t_ref_deliveryorder_detail
|
||||
set T_RefDeliveryOrderDetailResult = ?,
|
||||
T_RefDeliveryOrderDetailStage = ?,
|
||||
T_RefDeliveryOrderDetailNote = ?
|
||||
where T_RefDeliveryOrderDetailT_RefDeliveryOrderID = ?
|
||||
and T_RefDeliveryOrderDetailT_OrderDetailID = ?";
|
||||
}
|
||||
|
||||
$qry = $this->db->query($sql, array($value, $stage, $note, $deliveryOrderID, $detailID));
|
||||
|
||||
return $qry;
|
||||
}
|
||||
function update_order($detailID,$value,$normalValueID) {
|
||||
$verUserID = 3;
|
||||
|
||||
$sql = "update t_orderdetail
|
||||
set T_OrderDetailResult = ?,
|
||||
T_OrderDetailNat_NormalValueID = ?,
|
||||
T_OrderDetailVerification = 'Y',
|
||||
T_OrderDetailVerDate = now(),
|
||||
T_OrderDetailVerUserID = $verUserID
|
||||
where T_OrderDetailID = ?";
|
||||
$qry = $this->db->query($sql, array($value, $normalValueID, $detailID));
|
||||
|
||||
if ( $qry) {
|
||||
$sql = "update t_orderdetail, nat_normalvalue, nat_methode
|
||||
set T_OrderDetailNat_MethodeID = Nat_NormalValueNat_MethodeID ,
|
||||
T_OrderDetailNat_MethodeName = Nat_MethodeName,
|
||||
T_OrderDetailNormalValueNote = Nat_NormalValueNote,
|
||||
T_OrderDetailNormalValueDescription = Nat_NormalValueDescription,
|
||||
T_OrderDetailMinValue = Nat_NormalValueMinValue,
|
||||
T_OrderDetailMaxValue = Nat_NormalValueMaxValue,
|
||||
T_OrderDetailMinValueInclusive = Nat_NormalValueMinValueInclusive,
|
||||
T_OrderDetailMaxValueInclusive = Nat_NormalValueMaxValueInclusive
|
||||
where T_OrderDetailID = ?
|
||||
and T_OrderDetailNat_NormalValueID = Nat_NormalValueID
|
||||
and Nat_NormalValueNat_MethodeID = Nat_MethodeID";
|
||||
$qryn = $this->db->query($sql, array($detailID));
|
||||
//if (! $qryn ) print_r($this->db->error());
|
||||
if (! $qryn ) return false;
|
||||
$sql = "call sp_set_normal_value_flag(?)";
|
||||
$qryu = $this->db->query($sql, array($detailID));
|
||||
//if (! $qryu ) print_r($this->db->error());
|
||||
if (! $qryu ) return false;
|
||||
$this->clean_mysqli_connection($this->db->conn_id);
|
||||
}
|
||||
return $qry;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user