80 lines
2.8 KiB
PHP
80 lines
2.8 KiB
PHP
<?php
|
|
|
|
class Editfromnasional extends MY_Controller
|
|
{
|
|
function __construct() {
|
|
parent::__construct();
|
|
//$this->db = $this->load->database('regional', true);
|
|
$this->db = $this->load->database('onedev', true);
|
|
}
|
|
|
|
function is_exists($table, $field, $value) {
|
|
$this->db->where($field,$value);
|
|
$qry = $this->db->get($table);
|
|
if (! $qry) {
|
|
echo json_encode(array("status" => "ERR", "message" => "Cek exists $table $field $value". print_r($this->db->error(),true) ));
|
|
exit;
|
|
}
|
|
if (! empty($qry->result_array())) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function download() {
|
|
$this->decompress();
|
|
$md5 = $this->sys_input["md5"];
|
|
$param = $this->sys_input["param"];
|
|
$j_param = json_encode($param);
|
|
$l_md5 = md5($j_param);
|
|
if ($md5 != $l_md5 ) {
|
|
echo json_encode(array("status" => "ERR", "message" => "MD5 $md5 <> $l_md5"));
|
|
exit;
|
|
}
|
|
$mou = $param["mou"];
|
|
|
|
if ( $this->is_exists("m_mou","M_MouID", $mou["M_MouID"]) ) {
|
|
$sql = "UPDATE m_mou SET
|
|
M_MouPicBillName = '{$mou['M_MouPicBillName']}',
|
|
M_MouPicBillHandphone = '{$mou['M_MouPicBillHandphone']}',
|
|
M_MouPicBillEmail = '{$mou['M_MouPicBillEmail']}',
|
|
M_MouFinanceName = '{$mou['M_MouFinanceName']}',
|
|
M_MouFinanceHandphone = '{$mou['M_MouFinanceHandphone']}',
|
|
M_MouFinanceEmail = '{$mou['M_MouFinanceEmail']}',
|
|
M_MouEmail = '{$mou['M_MouEmail']}',
|
|
M_MouEmailIsDefault = '{$mou['M_MouEmailIsDefault']}',
|
|
M_MouEresultPersonal = '{$mou['M_MouEresultPersonal']}',
|
|
M_MouEresultCompany = '{$mou['M_MouEresultCompany']}'
|
|
WHERE M_MouID = {$mou["M_MouID"]}";
|
|
$qry = $this->db->query($sql);
|
|
}
|
|
|
|
if ( $this->is_exists("m_mouaddon","M_MouAddonM_MouID", $mou["M_MouAddonM_MouID"]) ) {
|
|
$sql = "UPDATE m_mouaddon SET
|
|
M_MouAddonAddressResult = '{$mou['M_MouAddonAddressResult']}',
|
|
M_MouAddonAddressBill = '{$mou['M_MouAddonAddressBill']}',
|
|
M_MouAddonNoteResult = '{$mou['M_MouAddonNoteResult']}',
|
|
M_MouAddonNoteBill = '{$mou['M_MouAddonNoteBill']}'
|
|
WHERE M_MouAddonM_MouID = {$mou["M_MouID"]}";
|
|
$qry = $this->db->query($sql);
|
|
}
|
|
if (! $qry ) {
|
|
echo json_encode(array("status" => "ERR", "message" => "Update Addon : " . print_r($this->db->error(),true) ));
|
|
exit;
|
|
}
|
|
|
|
if (! $qry ) {
|
|
echo json_encode(array("status" => "ERR", "message" => "Update MOU : " . print_r($this->db->error(),true) ));
|
|
exit;
|
|
}
|
|
|
|
|
|
|
|
echo json_encode( array("status" => "OK" , "message" => "" , "mouID" => $mou["M_MouID"]));
|
|
}
|
|
function decompress() {
|
|
$zparam = file_get_contents("php://input");
|
|
$param = gzinflate($zparam);
|
|
$this->sys_input = json_decode($param,true);
|
|
}
|
|
}
|