113 lines
4.1 KiB
PHP
113 lines
4.1 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
class Txmikro {
|
|
|
|
public function update($order_header_id,$username)
|
|
{
|
|
$CI =& get_instance();
|
|
$this->db = $CI->load->database("onedev",true);
|
|
$s_ids = join(",",$ids);
|
|
$sql = "select T_OrderDetailT_TestID
|
|
from
|
|
t_orderdetail
|
|
join other_mikro on Other_MikroT_OrderDetailID = T_OrderDetailID
|
|
and T_OrderDetailValidation = 'Y'
|
|
where T_OrderDetailT_OrderHeaderID = ? ";
|
|
$qry = $this->db->query($sql,$array($order_header_id));
|
|
$incomingRefID = 0;
|
|
$s_detail_ids = "0";
|
|
$s_child_ids = "0";
|
|
$headerID = 0;
|
|
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
if(count($rows) > 0 ) {
|
|
$headerID = $order_header_id
|
|
$s_test = "0";
|
|
foreach($rows as $r) {
|
|
$s_test .= "," . $r["T_OrderDetailT_TestID"];
|
|
}
|
|
$sql = "select incomingRefDetailID , incomingRefDetailIncomingRefID
|
|
from incoming_ref_detail
|
|
where incomingRefDetailNewT_OrderHeaderID = ?
|
|
and incomingRefDetailT_TestID in ($s_test) ";
|
|
$qryd = $this->db->query($sql, array($headerID));
|
|
$flag_found = false;
|
|
if($qryd) {
|
|
$rowsd = $qryd->result_array();
|
|
if ( count($rowsd) > 0 ) {
|
|
$incomingRefID = $rowsd[0]["incomingRefDetailIncomingRefID"];
|
|
foreach($rowsd as $r) {
|
|
$s_detail_ids .= "," . $r["incomingRefDetailID"];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ($s_detail_ids == "0" ) {
|
|
return false;
|
|
}
|
|
$sql = "select M_BranchID, M_BranchIPAddress
|
|
from m_branch
|
|
join incoming_ref
|
|
on M_BranchID = incomingRefM_BranchID
|
|
where incomingRefID = ?";
|
|
$qry = $this->db->query($sql, array($incomingRefID));
|
|
$branchID = 0;
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
if(count($rows)>0) {
|
|
$branchID = $rows[0]["M_BranchID"];
|
|
$branchIPAddress = $rows[0]["M_BranchIPAddress"];
|
|
}
|
|
}
|
|
if ($branchID == 0 ) {
|
|
return false;
|
|
}
|
|
$val_note = "";
|
|
if ($headerID > 0 ) {
|
|
$sql = "select T_OrderHeaderAddOnValidationNote
|
|
from t_orderheaderaddon
|
|
where T_orderHeaderAddOnT_OrderHeaderID = ?";
|
|
$qry = $this->db->query($sql,array($headerID));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
if (count($rows) > 0 ) {
|
|
$val_note = $rows[0]["T_OrderHeaderAddOnValidationNote"];
|
|
if ( $val_note == null ) $val_note = "";
|
|
}
|
|
}
|
|
}
|
|
$note = "$stage by $username";
|
|
if ($s_detail_ids!= "0" ) {
|
|
$sql = "select
|
|
incomingRefT_RefDeliveryOrderID,
|
|
incomingRefDetailT_OrderDetailID,
|
|
incomingRefDetailStatus,
|
|
T_OrderDetailResult,
|
|
T_OrderDetailNat_NormalValueID,
|
|
T_OrderDetailVerification,
|
|
T_OrderDetailValidation,
|
|
T_OrderDetailNote,
|
|
? note,
|
|
? validation_note
|
|
from incoming_ref_detail
|
|
join incoming_ref on incomingRefID = incomingRefDetailIncomingRefID
|
|
and incomingRefDetailID in ($s_detail_ids)
|
|
left join t_orderdetail on incomingRefDetailNewT_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
|
and T_OrderDetailIsActive = 'Y' and incomingRefDetailT_TestID = T_OrderDetailT_TestID";
|
|
$qry = $this->db->query($sql, array($note,$val_note));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
$param = json_encode($rows);
|
|
//insert to
|
|
$sql = "insert into tx_branch_status(TxBranchStatusStage, TxBranchStatusM_BranchID,
|
|
TxBranchStatusM_BranchIP, TxBranchStatusJson,TxBranchStatusNote )
|
|
values (?,?,?,?,?)";
|
|
$qry = $this->db->query($sql, array($stage,$branchID, $branchIPAddress, $param, $note));
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|