Files
2026-04-27 10:26:26 +07:00

48 lines
1.5 KiB
PHP

<?php
class Company 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 editcompanyafterrelease() {
$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;
}
$company = $param["company"];
if ( $this->is_exists("m_company","M_CompanyID", $company["M_CompanyID"]) ) {
$this->db->where("M_CompanyID", $company["M_CompanyID"]);
$qry = $this->db->update("m_company",$company);
}
if (! $qry ) {
echo json_encode(array("status" => "ERR", "message" => "Update Company : " . print_r($this->db->error(),true) ));
exit;
}
echo json_encode( array("status" => "OK" , "message" => "" , "companyID" => $company["M_MouID"]));
}
}