From 01c73cffb46b997cc633107c806c13c8104df971 Mon Sep 17 00:00:00 2001 From: "sas.fajri" Date: Thu, 28 May 2026 10:55:34 +0700 Subject: [PATCH] FHM28052601 - add email config endpoint --- .../email_notification/Config_email.php | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 application/controllers/email_notification/Config_email.php diff --git a/application/controllers/email_notification/Config_email.php b/application/controllers/email_notification/Config_email.php new file mode 100644 index 0000000..500b4a6 --- /dev/null +++ b/application/controllers/email_notification/Config_email.php @@ -0,0 +1,78 @@ +db_onedev = $this->load->database("onedev", true); + } + + public function index() + { + echo "EMAIL CONFIG API"; + } + + public function getdata() + { + try { + 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(); + 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 { + if (!$this->isLogin) { + $this->sys_error("Invalid Token"); + exit; + } + + $prm = $this->sys_input; + $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_EmailConfigResultFormatAPS = '{$prm['M_EmailConfigResultFormatAPS']}', + M_EmailConfigCc = '{$prm['M_EmailConfigCc']}', + M_EmailConfigLastUpdate = now() + where + M_EmailConfigID = {$prm['M_EmailConfigID']}"; + $query = $this->db_onedev->query($sql); + + if (!$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); + } + } +}