158 lines
5.7 KiB
PHP
158 lines
5.7 KiB
PHP
<?php
|
|
class Upl_mou extends MY_Controller
|
|
{
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->db = $this->load->database('regional', true);
|
|
}
|
|
function unrelease() {
|
|
$param = $this->sys_input["param"];
|
|
$j_param = json_encode($param);
|
|
$md5 = $this->sys_input["md5"];
|
|
$l_md5 = md5($j_param);
|
|
|
|
if ($md5 != $l_md5 ) {
|
|
$this->sys_error("Md5 $md5 <> $l_md5");
|
|
exit;
|
|
}
|
|
$mouID = $param["mouID"];
|
|
$staffNIK = $param["staffNIK"];
|
|
$branchCode = $param["branchCode"];
|
|
$ipAddress = $param["ipAddress"];
|
|
$staffName = $param["staffName"];
|
|
$jsonParam = json_encode(array("param" => $param, "md5" => $md5 ));
|
|
|
|
$data = array("TxMouReleaseM_MouID" => $mouID,
|
|
"TxMouReleaseIPAddress" => $ipAddress,
|
|
"TxMouReleaseM_BranchCode" => $branchCode,
|
|
"TxMouReleaseM_StaffNIK" => $staffNIK,
|
|
"TxMouReleaseM_StaffName" => $staffName,
|
|
"TxMouReleaseJson" => $jsonParam,
|
|
"TxMouReleaseStatus" => $param["status"]
|
|
);
|
|
$qry = $this->db->insert("tx_mou_release",$data);
|
|
if (!$qry ) {
|
|
$this->sys_error( print_r($this->db->error(),true));
|
|
exit;
|
|
}
|
|
$sql = "INSERT g_moustatuslog
|
|
(G_MouStatusLogDate,
|
|
G_MouStatusLogM_MouID,
|
|
G_MouStatusLogStatus,
|
|
G_MouStatusLogUserID,
|
|
G_MouStatusLogCreated,
|
|
G_MouStatusLogLastUpdated)
|
|
VALUES(
|
|
date(now()),
|
|
'{$mouID}',
|
|
'UR',
|
|
'3',
|
|
now(),
|
|
now())";
|
|
$qry = $this->db->query($sql);
|
|
if (!$qry ) {
|
|
$this->sys_error( print_r($this->db->error(),true));
|
|
exit;
|
|
}
|
|
$sql = "update m_mou SET
|
|
M_MouIsReleased = 'N',
|
|
M_MouStatus = 'UR',
|
|
M_MouAllowVerify = 'Y',
|
|
M_MouReleaseDate = now(),
|
|
M_MouReleaseUserID = 3,
|
|
M_MouIsApproved = 'Y',
|
|
M_MouLastUpdated = now()
|
|
WHERE
|
|
M_MouID = ?";
|
|
$qry = $this->db->query($sql,array($mouID));
|
|
if (!$qry ) {
|
|
$this->sys_error( print_r($this->db->error(),true));
|
|
exit;
|
|
}
|
|
$this->sys_ok( array("message" => "Un Release OK"));
|
|
}
|
|
function release() {
|
|
$param = $this->sys_input["param"];
|
|
$j_param = json_encode($param);
|
|
$md5 = $this->sys_input["md5"];
|
|
$l_md5 = md5($j_param);
|
|
if ($md5 != $l_md5 ) {
|
|
$this->sys_error("Md5 $md5 <> $l_md5");
|
|
exit;
|
|
}
|
|
$mouID = $param["mouID"];
|
|
$staffNIK = $param["staffNIK"];
|
|
$branchCode = $param["branchCode"];
|
|
$ipAddress = $param["ipAddress"];
|
|
$staffName = $param["staffName"];
|
|
$jsonParam = json_encode(array("param" => $param, "md5" => $md5 ));
|
|
|
|
$data = array("TxMouReleaseM_MouID" => $mouID,
|
|
"TxMouReleaseIPAddress" => $ipAddress,
|
|
"TxMouReleaseM_BranchCode" => $branchCode,
|
|
"TxMouReleaseM_StaffNIK" => $staffNIK,
|
|
"TxMouReleaseM_StaffName" => $staffName,
|
|
"TxMouReleaseJson" => $jsonParam,
|
|
"TxMouReleaseStatus" => $param["status"]
|
|
);
|
|
|
|
$qry = $this->db->insert("tx_mou_release",$data);
|
|
if (!$qry ) {
|
|
$this->sys_error( print_r($this->db->error(),true));
|
|
exit;
|
|
}
|
|
$sql = "INSERT g_moustatuslog
|
|
(G_MouStatusLogDate,
|
|
G_MouStatusLogM_MouID,
|
|
G_MouStatusLogStatus,
|
|
G_MouStatusLogUserID,
|
|
G_MouStatusLogCreated,
|
|
G_MouStatusLogLastUpdated)
|
|
VALUES(
|
|
date(now()),
|
|
'{$mouID}',
|
|
'R',
|
|
'3',
|
|
now(),
|
|
now())";
|
|
$qry = $this->db->query($sql);
|
|
if (!$qry ) {
|
|
$this->sys_error( " Insert MOU " . print_r($this->db->error(),true));
|
|
exit;
|
|
}
|
|
$sql = "update m_mou SET
|
|
M_MouIsReleased = 'Y',
|
|
M_MouStatus = 'R',
|
|
M_MouAllowVerify = 'N',
|
|
M_MouReleaseDate = now(),
|
|
M_MouReleaseUserID = 3,
|
|
M_MouIsApproved = 'Y',
|
|
M_MouLastUpdated = now()
|
|
WHERE
|
|
M_MouID = ?";
|
|
$qry = $this->db->query($sql,array($mouID));
|
|
if (!$qry ) {
|
|
$this->sys_error( print_r($this->db->error(),true));
|
|
exit;
|
|
}
|
|
$this->sys_ok( array("message" => "Release OK"));
|
|
}
|
|
function post($url,$data) {
|
|
$ch = curl_init($url);
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
'Content-Type: application/json',
|
|
'Content-Length: ' . strlen($data))
|
|
);
|
|
$result = curl_exec($ch);
|
|
if (curl_errno($ch)){
|
|
return json_encode( array("status" => "ERR",
|
|
"message" => curl_error($ch)) );
|
|
}
|
|
curl_close($ch);
|
|
return $result;
|
|
}
|
|
}
|