add endpoint api for mapping jasa account
This commit is contained in:
78
application/controllers/map/ServiceCoaMapping.php
Normal file
78
application/controllers/map/ServiceCoaMapping.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ServiceCoaMapping extends MY_Controller
|
||||||
|
{
|
||||||
|
var $db;
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
echo "Jasa Coa Mapping API";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getListCoa()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (!$this->sys_input) {
|
||||||
|
throw new Exception("Invalid token");
|
||||||
|
}
|
||||||
|
|
||||||
|
$para = $this->sys_input;
|
||||||
|
$keyword = "%" . $para["keyword"] . "%";
|
||||||
|
|
||||||
|
$sql = "SELECT
|
||||||
|
FROM coa
|
||||||
|
WHERE coaIsInput = 'Y'
|
||||||
|
AND (
|
||||||
|
coaDescription LIKE ?
|
||||||
|
OR coaAccountNo LIKE ?
|
||||||
|
)
|
||||||
|
AND coaIsActive = 'Y'
|
||||||
|
LIMIT 15";
|
||||||
|
$que = $this->db->query($sql, [$keyword, $keyword]);
|
||||||
|
if (!$que) {
|
||||||
|
throw new Exception("failed to query data coa", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $que->result_array();
|
||||||
|
$this->sys_ok($data);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$mssg = "[Error] " . $e->getMessage();
|
||||||
|
$code = $e->getCode();
|
||||||
|
if ($code == 0) {
|
||||||
|
$this->sys_error($mssg);
|
||||||
|
} else {
|
||||||
|
$this->sys_error_db($mssg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getListServiceMapping()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (!$this->isLogin) {
|
||||||
|
throw new Exception('invalid token');
|
||||||
|
|
||||||
|
$sql = "";
|
||||||
|
$que = $this->db->query($sql);
|
||||||
|
if (!$que) {
|
||||||
|
throw new Exception('failed to query service coa mapping', 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $que->result_array();
|
||||||
|
$this->sys_ok($data);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$mssg = "[Error] " . $e->getMessage();
|
||||||
|
$code = $e->getCode();
|
||||||
|
if ($code == 0) {
|
||||||
|
$this->sys_error($mssg);
|
||||||
|
} else {
|
||||||
|
$this->sys_error_db($mssg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user