Files
BE_IBL/application/controllers/mockup/masterdata/Emailconfig0.php
2026-04-15 15:24:12 +07:00

89 lines
2.3 KiB
PHP

<?php
class Emailconfig extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "EMAIL CONFIG API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
public function getdata()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$sql = "select *
from m_emailconfig
where
M_EmailConfigIsActive = 'Y' LIMIT 1";
$rows = $this->db_onedev->query($sql)->row_array();
//echo $this->db_onedev->last_query();
if (!$rows) {
$this->sys_error_db("emailconfig select");
exit;
}
$result = array ("total" => count($rows),"records" => $rows);
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function save()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
//print_r($prm);
$sql = "update m_emailconfig SET
M_EmailConfigSender = '{$prm['M_EmailConfigSender']}',
M_EmailConfigUsername = '{$prm['M_EmailConfigUsername']}',
M_EmailConfigPassword = '{$prm['M_EmailConfigPassword']}',
M_EmailConfigServer = '{$prm['M_EmailConfigServer']}',
M_EmailConfigMaxRetry = '{$prm['M_EmailConfigMaxRetry']}',
M_EmailConfigHomeServiceFormat = '{$prm['M_EmailConfigHomeServiceFormat']}',
M_EmailConfigCc = '{$prm['M_EmailConfigCc']}',
M_EmailConfigLastUpdate = now()
where
M_EmailConfigID = {$prm['M_EmailConfigID']}
";
$query = $this->db_onedev->query($sql);
if (!$query) {
//echo $this->db_onedev->last_query();
$this->sys_error_db("email config update");
exit;
}
$result = array ("total" => 1, "records" => array());
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}