1685 lines
50 KiB
PHP
1685 lines
50 KiB
PHP
<?php
|
|
|
|
class Sotemplateresult extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "SO TEMPLATE RESULT API";
|
|
}
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
|
|
function lookupsovalue(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$idlabel = $prm['idlabel'];
|
|
$idso = $prm['idso'];
|
|
$sql = "select IF(So_TemplateValueID IS NULL, 'N','Y') as isinput, IFNULL(So_TemplateValueID,So_TemplateDetailID+9999) as id,
|
|
so_templatevalue.*,so_templatedetail.*,
|
|
So_TemplateLabelName,M_LangName
|
|
from so_templatedetail
|
|
JOIN so_templatelabel ON So_TemplateLabelID = {$idlabel}
|
|
LEFT JOIN so_templatevalue ON So_TemplateDetailID = So_TemplateValueSo_TemplateDetailID AND So_TemplateLabelID = So_TemplateValueSo_TemplateLabelID AND So_TemplateValueIsActive = 'Y'
|
|
LEFT JOIN m_lang ON So_TemplateDetailM_LangID = M_LangID
|
|
where
|
|
So_TemplateDetailSo_TemplateID = {$idso} AND So_TemplateDetailIsActive = 'Y'";
|
|
// echo $sql;
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
$rows = $query->result_array();
|
|
if($rows){
|
|
}
|
|
|
|
$result = array ("total" => count($rows), "records" => $rows);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function lookup()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$search = $prm['search'];
|
|
$all = $prm['all'];
|
|
$limit = '';
|
|
if($all == 'N'){
|
|
$limit = ' LIMIT 10';
|
|
}
|
|
$sql = "select COUNT(*) as total
|
|
from so_templatelabel
|
|
where
|
|
So_TemplateLabelIsActive = 'Y'";
|
|
$sql_param = array($search);
|
|
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
|
|
|
|
|
$sql = "select So_TemplateLabelID as id, So_TemplateLabelID as idlabel, So_TemplateLabelSo_TemplateID as idso,
|
|
So_TemplateLabelName as name,
|
|
IF(So_TemplateLabelM_DoctorID = 0, 'Semua Dokter',CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,''))) as M_DoctorName,
|
|
T_TestName,
|
|
So_TemplateName,
|
|
so_templatelabel.*
|
|
from so_templatelabel
|
|
LEFT JOIN so_template ON So_TemplateLabelSo_TemplateID = So_TemplateID
|
|
LEFT JOIN m_doctor ON So_TemplateLabelM_DoctorID = M_DoctorID
|
|
LEFT JOIN t_test ON So_TemplateLabelT_TestID = T_TestID
|
|
where
|
|
( So_TemplateLabelName LIKE CONCAT('%','{$search}','%')
|
|
)AND
|
|
So_TemplateLabelIsActive = 'Y'
|
|
GROUP BY So_TemplateLabelID
|
|
ORDER BY So_TemplateLabelID DESC $limit";
|
|
$sql_param = array($search);
|
|
$query = $this->db_onedev->query($sql);
|
|
//echo $this->db_onedev->last_query();
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
|
|
|
|
} else {
|
|
$this->sys_error_db("so_templatelabel select");
|
|
exit;
|
|
}
|
|
|
|
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
|
|
public function addnewsolabel()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$labelname = $prm['labelname'];
|
|
$doctorid = $prm['doctorid'];
|
|
$testid = $prm['testid'];
|
|
$sotemplateid = $prm['sotemplateid'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$sql = "insert into so_templatelabel(
|
|
So_TemplateLabelName,
|
|
So_TemplateLabelM_DoctorID,
|
|
So_TemplateLabelT_TestID,
|
|
So_TemplateLabelSo_TemplateID,
|
|
So_TemplateLabelUserID,
|
|
So_TemplateLabelCreated,
|
|
So_TemplateLabelLastUpdated
|
|
)
|
|
values( ?, ?, ?, ?, ?, now(), now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$labelname,
|
|
$doctorid,
|
|
$testid,
|
|
$sotemplateid,
|
|
$userid
|
|
)
|
|
);
|
|
//echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("so_templatelabel insert");
|
|
exit;
|
|
}
|
|
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
$last_id = $this->db_onedev->insert_id();
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
public function editsolabel()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$labelname = $prm['labelname'];
|
|
$doctorid = $prm['doctorid'];
|
|
$testid = $prm['testid'];
|
|
$sotemplateid = $prm['sotemplateid'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$sqlcompany = "update so_templatelabel SET
|
|
So_TemplateLabelName = ?,
|
|
So_TemplateLabelM_DoctorID = ?,
|
|
So_TemplateLabelT_TestID = ?,
|
|
So_TemplateLabelSo_TemplateID = ?,
|
|
So_TemplateLabelUserID = ?,
|
|
So_TemplateLabelLastUpdated = now()
|
|
where
|
|
So_TemplateLabelID = ?
|
|
";
|
|
$querycompany = $this->db_onedev->query($sqlcompany,
|
|
array(
|
|
$labelname,
|
|
$doctorid,
|
|
$testid,
|
|
$sotemplateid,
|
|
$userid,
|
|
$id
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$querycompany) {
|
|
$this->sys_error_db("so_templatelabel update");
|
|
exit;
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => $id));
|
|
$this->sys_ok($result);
|
|
|
|
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function addnewcompanytype()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$name_companytype = $prm['name'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$sql = "insert into m_companytype(
|
|
M_CompanyTypeName,
|
|
M_CompanyTypeUserID,
|
|
M_CompanyTypeCreated,
|
|
M_CompanyTypeLastUpdated
|
|
)
|
|
values(?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$name_companytype,
|
|
$userid
|
|
)
|
|
);
|
|
//echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_companytype insert");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *, COUNT(M_CompanyID) as used
|
|
FROM (SELECT m_companytype.*,M_CompanyID
|
|
FROM
|
|
m_companytype
|
|
LEFT JOIN m_company ON M_CompanyTypeID = M_CompanyM_CompanyTypeID AND M_CompanyIsActive = 'Y'
|
|
WHERE M_CompanyTypeIsActive = 'Y') a
|
|
GROUP BY M_CompanyTypeID
|
|
";
|
|
//echo $query;
|
|
$rows['companytypes'] = $this->db_onedev->query($query)->result_array();
|
|
$result = array ("total" => 1, "records" => $rows);
|
|
$this->sys_ok($result);
|
|
$last_id = $this->db_onedev->insert_id();
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function editcompanytype()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$id_company = $prm['id'];
|
|
$name_company = $prm['name'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$sqlcompany = "update m_companytype SET
|
|
M_CompanyTypeName = ?,
|
|
M_CompanyTypeUserID = ?,
|
|
M_CompanyTypeLastUpdated = now()
|
|
where
|
|
M_CompanyTypeID = ?
|
|
";
|
|
$querycompany = $this->db_onedev->query($sqlcompany,
|
|
array(
|
|
$name_company,
|
|
$userid,
|
|
$id_company
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$querycompany) {
|
|
$this->sys_error_db("m_companytype update");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *, COUNT(M_CompanyID) as used
|
|
FROM (SELECT m_companytype.*,M_CompanyID
|
|
FROM
|
|
m_companytype
|
|
LEFT JOIN m_company ON M_CompanyTypeID = M_CompanyM_CompanyTypeID AND M_CompanyIsActive = 'Y'
|
|
WHERE M_CompanyTypeIsActive = 'Y') a
|
|
GROUP BY M_CompanyTypeID";
|
|
//echo $query;
|
|
$rows['companytypes'] = $this->db_onedev->query($query)->result_array();
|
|
$result = array ("total" => 1, "records" => $rows);
|
|
$this->sys_ok($result);
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function deletecompanytype()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$id_company = $prm['id'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$sqlcompany = "update m_companytype SET
|
|
M_CompanyTypeIsActive = 'N',
|
|
M_CompanyTypeUserID = ?,
|
|
M_CompanyTypeLastUpdated = now()
|
|
where
|
|
M_CompanyTypeID = ?
|
|
";
|
|
$querycompany = $this->db_onedev->query($sqlcompany,
|
|
array(
|
|
$userid,
|
|
$id_company
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$querycompany) {
|
|
$this->sys_error_db("m_companytype update");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_companytype
|
|
WHERE
|
|
M_CompanyTypeIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['companytypes'] = $this->db_onedev->query($query)->result_array();
|
|
$result = array ("total" => 1, "records" => $rows);
|
|
$this->sys_ok($result);
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function addnewcompanybusiness()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$name_companytype = $prm['name'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$sql = "insert into m_companybusiness(
|
|
M_CompanyBusinessName,
|
|
M_CompanyBusinessUserID,
|
|
M_CompanyBusinessCreated,
|
|
M_CompanyBusinessLastUpdated
|
|
)
|
|
values(?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$name_companytype,
|
|
$userid
|
|
)
|
|
);
|
|
//echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_companybusiness insert");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *, COUNT(M_CompanyID) as used
|
|
FROM (SELECT m_companybusiness.*,M_CompanyID
|
|
FROM
|
|
m_companybusiness
|
|
LEFT JOIN m_company ON M_CompanyBusinessID = M_CompanyM_CompanyBusinessID AND M_CompanyIsActive = 'Y'
|
|
WHERE M_CompanyBusinessIsActive = 'Y') a
|
|
GROUP BY M_CompanyBusinessID
|
|
";
|
|
//echo $query;
|
|
$rows['companybusinesss'] = $this->db_onedev->query($query)->result_array();
|
|
$result = array ("total" => 1, "records" => $rows);
|
|
$this->sys_ok($result);
|
|
$last_id = $this->db_onedev->insert_id();
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function editcompanybusiness()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$id_company = $prm['id'];
|
|
$name_company = $prm['name'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$sqlcompany = "update m_companybusiness SET
|
|
M_CompanyBusinessName = ?,
|
|
M_CompanyBusinessUserID = ?,
|
|
M_CompanyBusinessLastUpdated = now()
|
|
where
|
|
M_CompanyBusinessID = ?
|
|
";
|
|
$querycompany = $this->db_onedev->query($sqlcompany,
|
|
array(
|
|
$name_company,
|
|
$userid,
|
|
$id_company
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$querycompany) {
|
|
$this->sys_error_db("m_companybusiness update");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *, COUNT(M_CompanyID) as used
|
|
FROM (SELECT m_companybusiness.*,M_CompanyID
|
|
FROM
|
|
m_companybusiness
|
|
LEFT JOIN m_company ON M_CompanyBusinessID = M_CompanyM_CompanyBusinessID AND M_CompanyIsActive = 'Y'
|
|
WHERE M_CompanyBusinessIsActive = 'Y') a
|
|
GROUP BY M_CompanyBusinessID";
|
|
//echo $query;
|
|
$rows['companybusinesss'] = $this->db_onedev->query($query)->result_array();
|
|
$result = array ("total" => 1, "records" => $rows);
|
|
$this->sys_ok($result);
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function deletecompanybusiness()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$id_company = $prm['id'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$sqlcompany = "update m_companybusiness SET
|
|
M_CompanyBusinessIsActive = 'N',
|
|
M_CompanyBusinessUserID = ?,
|
|
M_CompanyBusinessLastUpdated = now()
|
|
where
|
|
M_CompanyBusinessID = ?
|
|
";
|
|
$querycompany = $this->db_onedev->query($sqlcompany,
|
|
array(
|
|
$userid,
|
|
$id_company
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$querycompany) {
|
|
$this->sys_error_db("m_companybusiness update");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_companybusiness
|
|
WHERE
|
|
M_CompanyBusinessIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['companybusinesss'] = $this->db_onedev->query($query)->result_array();
|
|
$result = array ("total" => 1, "records" => $rows);
|
|
$this->sys_ok($result);
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function addnewsovalue()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$solabelid = $prm['solabelid'];
|
|
$sovaluedetailid = $prm['sovaluedetailid'];
|
|
$sovaluetext = $prm['sovaluetext'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
if($prm['xid'] == 0){
|
|
|
|
$sql = "insert into so_templatevalue(
|
|
So_TemplateValueSo_TemplateLabelID,
|
|
So_TemplateValueSo_TemplateDetailID,
|
|
So_TemplateValueText,
|
|
So_TemplateValueUserID,
|
|
So_TemplateValueLastUpdated,
|
|
So_TemplateValueCreated
|
|
|
|
)
|
|
values( ?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$solabelid,
|
|
$sovaluedetailid,
|
|
$sovaluetext,
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("so_templatevalue insert",$this->db_onedev);
|
|
exit;
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
}else{
|
|
|
|
//echo $query;
|
|
$sql = "UPDATE so_templatevalue SET So_TemplateValueSo_TemplateLabelID = '{$solabelid}',
|
|
So_TemplateValueSo_TemplateDetailID = '{$sovaluedetailid}',
|
|
So_TemplateValueText = '{$sovaluetext}',
|
|
So_TemplateValueUserID = '{$userid}' WHERE So_TemplateValueID = '{$prm['xid']}'";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function addnewconvert()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$instrumentid = $prm['instrumentid'];
|
|
$resultorigin = $prm['resultorigin'];
|
|
$resultconvert = $prm['resultconvert'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
if($prm['xid'] == 0){
|
|
|
|
$sql = "insert into m_instrumentconvert(
|
|
M_InstrumentConvertNat_InstrumentID,
|
|
M_InstrumentConvertResultOrigin,
|
|
M_InstrumentConvertResultConvert,
|
|
M_InstrumentConvertUserID,
|
|
M_InstrumentConvertCreated,
|
|
M_InstrumentConvertLastUpdated
|
|
|
|
)
|
|
values( ?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$instrumentid,
|
|
$resultorigin,
|
|
$resultconvert,
|
|
$userid
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("m_instrumentconvert insert",$this->db_onedev);
|
|
exit;
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
}else{
|
|
|
|
//echo $query;
|
|
$sql = "UPDATE m_instrumentconvert SET M_InstrumentConvertResultOrigin = '{$resultorigin}',
|
|
M_InstrumentConvertResultConvert = '{$resultconvert}',
|
|
M_InstrumentConvertUserID = '{$userid}' WHERE M_InstrumentConvertID = '{$prm['xid']}'";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function deleteuser()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "update m_user SET
|
|
M_UserIsActive = 'N',
|
|
M_UserLastUpdated = now()
|
|
WHERE
|
|
M_UserID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_user delete");
|
|
exit;
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function confirmmou()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "update m_mou SET
|
|
M_MouIsApproved = 'Y',
|
|
M_MouLastUpdated = now()
|
|
WHERE
|
|
M_MouID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_mou update");
|
|
exit;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function verifymou()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$id = $prm['id'];
|
|
$sql = "update m_mou SET
|
|
M_MouIsVerified = 'Y',
|
|
M_MouVerifyDate = now(),
|
|
M_MouStatus = 'V',
|
|
M_MouVerifyUserID = '{$userid}',
|
|
M_MouLastUpdated = now()
|
|
WHERE
|
|
M_MouID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_mou update");
|
|
exit;
|
|
}
|
|
|
|
$querystatus ="INSERT g_moustatuslog
|
|
(G_MouStatusLogDate,
|
|
G_MouStatusLogM_MouID,
|
|
G_MouStatusLogStatus,
|
|
G_MouStatusLogUserID,
|
|
G_MouStatusLogCreated,
|
|
G_MouStatusLogLastUpdated)
|
|
VALUES(
|
|
date(now()),
|
|
'{$id}',
|
|
'V',
|
|
'{$userid}',
|
|
now(),
|
|
now())
|
|
";
|
|
$rows = $this->db_onedev->query($querystatus);
|
|
|
|
|
|
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function unverifymou()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$id = $prm['id'];
|
|
$sql = "update m_mou SET
|
|
M_MouIsVerified = 'N',
|
|
M_MouStatus = 'UV',
|
|
M_MouVerifyDate = now(),
|
|
M_MouVerifyUserID = '{$userid}',
|
|
M_MouLastUpdated = now()
|
|
WHERE
|
|
M_MouID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_mou update");
|
|
exit;
|
|
}
|
|
$querystatus ="INSERT g_moustatuslog
|
|
(G_MouStatusLogDate,
|
|
G_MouStatusLogM_MouID,
|
|
G_MouStatusLogStatus,
|
|
G_MouStatusLogUserID,
|
|
G_MouStatusLogCreated,
|
|
G_MouStatusLogLastUpdated)
|
|
VALUES(
|
|
date(now()),
|
|
'{$id}',
|
|
'UV',
|
|
'{$userid}',
|
|
now(),
|
|
now())
|
|
";
|
|
$rows = $this->db_onedev->query($querystatus);
|
|
|
|
|
|
|
|
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function releasemou()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$id = $prm['id'];
|
|
$sql = "update m_mou SET
|
|
M_MouIsReleased = 'Y',
|
|
M_MouStatus = 'R',
|
|
M_MouReleaseDate = now(),
|
|
M_MouReleaseUserID = '{$userid}',
|
|
M_MouIsApproved = 'Y',
|
|
M_MouLastUpdated = now()
|
|
WHERE
|
|
M_MouID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_mou update");
|
|
exit;
|
|
}
|
|
$querystatus ="INSERT g_moustatuslog
|
|
(G_MouStatusLogDate,
|
|
G_MouStatusLogM_MouID,
|
|
G_MouStatusLogStatus,
|
|
G_MouStatusLogUserID,
|
|
G_MouStatusLogCreated,
|
|
G_MouStatusLogLastUpdated)
|
|
VALUES(
|
|
date(now()),
|
|
'{$id}',
|
|
'R',
|
|
'{$userid}',
|
|
now(),
|
|
now())
|
|
";
|
|
$rows = $this->db_onedev->query($querystatus);
|
|
|
|
|
|
|
|
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function unreleasemou()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$id = $prm['id'];
|
|
$sql = "update m_mou SET
|
|
M_MouIsReleased = 'N',
|
|
M_MouStatus = 'UR',
|
|
M_MouReleaseDate = now(),
|
|
M_MouReleaseUserID = '{$userid}',
|
|
M_MouIsApproved = 'N',
|
|
M_MouLastUpdated = now()
|
|
WHERE
|
|
M_MouID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_mou update");
|
|
exit;
|
|
}
|
|
$querystatus ="INSERT g_moustatuslog
|
|
(G_MouStatusLogDate,
|
|
G_MouStatusLogM_MouID,
|
|
G_MouStatusLogStatus,
|
|
G_MouStatusLogUserID,
|
|
G_MouStatusLogCreated,
|
|
G_MouStatusLogLastUpdated)
|
|
VALUES(
|
|
date(now()),
|
|
'{$id}',
|
|
'UR',
|
|
'{$userid}',
|
|
now(),
|
|
now())
|
|
";
|
|
$rows = $this->db_onedev->query($querystatus);
|
|
|
|
|
|
|
|
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
public function deletesolabel()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$sql = "update so_templatelabel SET
|
|
So_TemplateLabelIsActive = 'N',
|
|
So_TemplateLabelLastUpdated = now(),
|
|
So_TemplateLabelUserID = '{$userid}'
|
|
WHERE
|
|
So_TemplateLabelID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("so_templatelabel delete");
|
|
exit;
|
|
}
|
|
$sql = "update so_templatevalue SET
|
|
So_TemplateValueIsActive = 'N',
|
|
So_TemplateValueLastUpdated = now(),
|
|
So_TemplateValueUserID = '{$userid}'
|
|
WHERE
|
|
So_TemplateValueSo_TemplateLabelID = ?
|
|
|
|
";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['id']
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("so_templatevalue delete");
|
|
exit;
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
function selectcompanytype(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *, COUNT(M_CompanyID) as used
|
|
FROM (SELECT m_companytype.*,M_CompanyID
|
|
FROM
|
|
m_companytype
|
|
LEFT JOIN m_company ON M_CompanyTypeID = M_CompanyM_CompanyTypeID AND M_CompanyIsActive = 'Y'
|
|
WHERE M_CompanyTypeIsActive = 'Y') a
|
|
GROUP BY M_CompanyTypeID
|
|
";
|
|
//echo $query;
|
|
$rows['companytypes'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
|
|
}
|
|
function selectcompanybusiness(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *, COUNT(M_CompanyID) as used
|
|
FROM (SELECT m_companybusiness.*,M_CompanyID
|
|
FROM
|
|
m_companybusiness
|
|
LEFT JOIN m_company ON M_CompanyBusinessID = M_CompanyM_CompanyBusinessID AND M_CompanyIsActive = 'Y'
|
|
WHERE M_CompanyBusinessIsActive = 'Y') a
|
|
GROUP BY M_CompanyBusinessID
|
|
";
|
|
//echo $query;
|
|
$rows['companybusinesss'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
|
|
}
|
|
function selectcompanylevel(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$rows = [];
|
|
$query =" SELECT *,CONCAT(Nat_CompanyLevelName,' [',M_CompanyName,']') as Nat_CompanyLevelName, COUNT(M_CompanyID) as used
|
|
FROM (SELECT nat_companylevel.*,M_CompanyID,M_CompanyName
|
|
FROM
|
|
nat_companylevel
|
|
LEFT JOIN m_company ON Nat_CompanyLevelNat_CompanyID = M_CompanyID AND M_CompanyIsActive = 'Y'
|
|
WHERE Nat_CompanyLevelIsActive = 'Y') a
|
|
GROUP BY Nat_CompanyLevelID
|
|
";
|
|
//echo $query;
|
|
$rows['companylevels'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
|
|
}
|
|
function selecthierarchy(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *, COUNT(M_CompanyID) as used
|
|
FROM (SELECT nat_hierarchy.*,M_CompanyID
|
|
FROM
|
|
nat_hierarchy
|
|
LEFT JOIN m_company ON Nat_HierarchyID = M_CompanyNat_HierarchyID AND M_CompanyIsActive = 'Y'
|
|
WHERE Nat_HierarchyIsActive = 'Y') a
|
|
GROUP BY Nat_HierarchyID
|
|
";
|
|
//echo $query;
|
|
$rows['hierarchys'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
|
|
}
|
|
function selectdoctor(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_doctor
|
|
WHERE
|
|
M_DoctorIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['doctors'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
|
|
}
|
|
function searchdoctor(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM
|
|
m_doctor
|
|
WHERE
|
|
M_DoctorName like ?
|
|
AND M_DoctorIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_doctor count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT * FROM(
|
|
SELECT 0 as M_DoctorID, 'Semua Dokter' as M_DoctorName, 'Semua Dokter' as M_DoctorNames
|
|
UNION
|
|
SELECT M_DoctorID, M_DoctorName, CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as M_DoctorNames
|
|
FROM m_doctor
|
|
WHERE M_DoctorIsActive = 'Y') a
|
|
WHERE
|
|
M_DoctorNames like ?
|
|
ORDER BY M_DoctorName DESC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_doctor rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchtestheader(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM so_testtemplate
|
|
LEFT JOIN t_test ON So_TestTemplateT_TestID = T_TestID
|
|
WHERE
|
|
T_TestName like ?
|
|
AND So_TestTemplateIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("so_testtemplate count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT T_TestID,CONCAT(T_TestSasCode,' ',T_TestName) T_TestName
|
|
FROM so_testtemplate
|
|
LEFT JOIN t_test ON So_TestTemplateT_TestID = T_TestID
|
|
WHERE
|
|
T_TestName like ?
|
|
AND So_TestTemplateIsActive = 'Y'
|
|
GROUP BY T_TestID
|
|
ORDER BY T_TestName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("so_testtemplate rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchtemplate(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM so_template
|
|
WHERE
|
|
So_TemplateName like ?
|
|
AND So_TemplateIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("so_template count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT So_TemplateID, So_TemplateName
|
|
FROM so_template
|
|
WHERE
|
|
So_TemplateName like ?
|
|
AND So_TemplateIsActive = 'Y'
|
|
GROUP BY So_TemplateID
|
|
ORDER BY So_TemplateName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("so_template rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchcompanylevel(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
|
|
$name = $prm['name'];
|
|
$hirarkiid = intval($prm['id']) - 1;
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM nat_companylevel
|
|
WHERE
|
|
Nat_CompanyLevelName like '%{$name}%'
|
|
AND
|
|
Nat_CompanyLevelNat_HierarchyID = '{$hirarkiid}'
|
|
AND Nat_CompanyLevelIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("nat_companylevel count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT * FROM(SELECT *, CONCAT(Nat_CompanyLevelName, ' [',M_CompanyName,']') as Nat_CompanyLevelNames
|
|
FROM nat_companylevel
|
|
LEFT JOIN m_company ON Nat_CompanyLevelNat_CompanyID = M_CompanyID
|
|
WHERE Nat_CompanyLevelIsActive = 'Y') a
|
|
WHERE
|
|
Nat_CompanyLevelName like '%{$name}%'
|
|
AND
|
|
Nat_CompanyLevelNat_HierarchyID = '{$hirarkiid}'
|
|
AND Nat_CompanyLevelIsActive = 'Y'
|
|
ORDER BY Nat_CompanyLevelName DESC
|
|
";
|
|
$query = $this->db_onedev->query($sql);
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("nat_companylevel rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchcity(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM m_city
|
|
WHERE
|
|
M_CityName like ?
|
|
AND M_CityIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_city count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *
|
|
FROM m_city
|
|
WHERE
|
|
M_CityName like ?
|
|
AND M_CityIsActive = 'Y'
|
|
ORDER BY M_CityName DESC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_city rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function getstaff(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_staff
|
|
WHERE
|
|
M_StaffIsActive = 'Y' AND M_StaffM_PositionID = 2";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getprovince(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_province
|
|
WHERE
|
|
M_ProvinceIsActive = 'Y'";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getcity(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_city
|
|
WHERE
|
|
M_CityIsActive = 'Y' AND M_CityM_ProvinceID = ?
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getdistrict(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_district
|
|
WHERE
|
|
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getkelurahan(){
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT *
|
|
FROM m_kelurahan
|
|
WHERE
|
|
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function selectbase(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT 'SPK' as baseid, 'SPK' as basename
|
|
UNION SELECT 'MOU' as baseid, 'MOU' as basename
|
|
";
|
|
//echo $query;
|
|
$rows['bases'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
|
|
}
|
|
function selectomzettype(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_omzettype
|
|
WHERE
|
|
M_OmzetTypeIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['omzettypes'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
|
|
}
|
|
function selectmoutype(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_moutype
|
|
WHERE
|
|
M_MouTypeIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['moutypes'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
|
|
}
|
|
function selectagingtype(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_agingtype
|
|
WHERE
|
|
M_AgingIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['agingtypes'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
|
|
}
|
|
|
|
} |