Files
BE_CPONE/application/controllers/mockup/masterdata/Companynewx.php
2026-04-27 10:31:17 +07:00

1845 lines
59 KiB
PHP

<?php
class Companynewx extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "COMPANY API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
function lookupmou(){
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$sql = "select M_MouID as id,
M_MouM_CompanyID as companyid,
IFNULL((SELECT `fn_mou_get_count_price`(M_MouID)),0) as countprice,
M_MouName as name,
M_MouStartDate,
M_MouEndDate,
DATE_FORMAT(M_MouStartDate,'%d%m%Y') as startdate,
DATE_FORMAT(M_MouEndDate,'%d%m%Y') as enddate,
CONCAT(DATE_FORMAT(M_MouStartDate,'%d-%m-%Y'), ' s/d ', DATE_FORMAT(M_MouEndDate,'%d-%m-%Y')) as periode,
M_MouIsBill as isbill,
M_MouRefNumber as refnumber,
M_MouNumber as number,
CONCAT(M_MouNumber, ' [',M_MouBase, ']') as numberx,
CONCAT(M_MouName, ' [',M_OmzetTypeName, ']') as namex,
M_MouIsDefault as isdefault,
M_MouIsUsingFavourite as isfavorit,
M_MouJpaIsNetto as isjpanetto,
M_MouIsMcu as ismcu,
M_MouIsApproved as isapproved,
M_MouIsAgingOnHold as isaging,
M_MouEmailIsDefault as isemail,
M_MouMinDP as mindp,
IFNULL(M_MouIsAgingOnHoldNote,'') as agingnote,
M_MouNote as xnote,
IFNULL(M_MouEmail,'') as mouemail,
IF(M_MouIsBill = 'Y','Pakai Billing','Tidak Pakai Billing') as bill,
M_MouBase as baseid,
M_MouBase as basename,
M_MouM_OmzetTypeID,
M_OmzetTypeID,
M_OmzetTypeName,
M_MouM_MouTypeID,
M_MouTypeID,
M_MouTypeName,
M_AgingTypeID,
M_AgingTypeName,
M_MouIsVerified as isverified,
IF(v.M_UserFullName IS NULL,'',DATE_FORMAT(M_MouVerifyDate,'%d-%m-%Y %h:%i:%s')) as verifydate,
M_MouVerifyUserID,
IFNULL(v.M_UserFullName,'') as verifyuser,
IF(v.M_UserFullName IS NULL, '', CONCAT(DATE_FORMAT(M_MouVerifyDate,'%d-%m-%Y %h:%i:%s'),'\r',v.M_UserFullName)) as verify,
M_MouIsReleased as isreleased,
IF(r.M_UserFullName IS NULL,'',DATE_FORMAT(M_MouReleaseDate,'%d-%m-%Y %h:%i:%s')) as releasedate,
M_MouReleaseUserID,
IFNULL(r.M_UserFullName,'') as releaseuser,
IF(r.M_UserFullName IS NULL, '', CONCAT(DATE_FORMAT(M_MouReleaseDate,'%d-%m-%Y %h:%i:%s'),'\r',r.M_UserFullName)) as released,
M_MouIsConfirm as isconfirm,
'xxx' as action,
CASE
WHEN M_MouStatus = 'N' THEN 'Baru'
WHEN M_MouStatus = 'V' THEN 'Verified'
WHEN M_MouStatus = 'UV' THEN 'Unverified'
WHEN M_MouStatus = 'R' THEN 'Released'
WHEN M_MouStatus = 'C' THEN 'Konfirmasi'
ELSE 'Unreleased'
END as aksi,
'xxx' as statuss,
M_MouJpa1Name,
M_MouJpa1Percent,
M_MouJpa2Name,
M_MouJpa2Percent,
M_MouJpa3Name,
M_MouJpa3Percent,
M_MouJpa4Name,
M_MouJpa4Percent
from m_mou
LEFT JOIN m_omzettype ON M_MouM_OmzetTypeID = M_OmzetTypeID
LEFT JOIN m_moutype ON M_MouM_MouTypeID = M_MouTypeID
LEFT JOIN m_agingtype ON M_MouM_AgingTypeID = M_AgingTypeID
LEFT join m_user v ON M_MouVerifyUserID = v.M_UserID
LEFT join m_user r ON M_MouReleaseUserID = r.M_UserID
where
M_MouM_CompanyID = {$id} AND M_MouIsActive = 'Y'";
// echo $sql;
$query = $this->db_onedev->query($sql, $sql_param);
$rows = $query->result_array();
if($rows){
foreach($rows as $k => $v){
$x = $this->db_onedev->query("select concat( '[', group_concat( json_object('id', G_MouStatusLogID, 'status',
CASE
WHEN G_MouStatusLogStatus = 'N' THEN 'Baru'
WHEN G_MouStatusLogStatus = 'V' THEN 'Verified'
WHEN G_MouStatusLogStatus = 'UV' THEN 'Unverified'
WHEN G_MouStatusLogStatus = 'R' THEN 'Released'
ELSE 'Unreleased'
END, 'waktu', DATE_FORMAT(G_MouStatusLogCreated,'%d-%m-%Y %H:%i'), 'user' , M_UserUsername) separator ',' ), ']' )
as n from g_moustatuslog
LEFT JOIN m_user ON G_MouStatusLogUserID = M_UserID
LEFT JOIN m_staff ON M_UserM_StaffID = M_StaffID
WHERE G_MouStatusLogM_MouID = '{$v['id']}' AND G_MouStatusLogIsActive = 'Y'")->row();
$rows[$k]['statuss'] = json_decode($x->n);
}
}
$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 m_company
where
M_CompanyIsActive = 'Y'";
$sql_param = array($search);
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
$sql = "select M_CompanyID as id, M_CompanyName as name, M_CompanyAddress as address, M_CompanyPhone as phone, M_CompanyEmail as email,M_CompanyFax as fax, M_CompanyPIC as pic,
CONCAT(M_CompanyName,' ' ,'[ ', ifnull(M_CompanyTypeName,'-') ,' ]') as description , M_CompanyTypeID, M_CompanyM_CompanyTypeID as companytypeid, M_CompanyTypeName as companytypename,
M_CompanyIsLabFrom as islabfrom, M_CompanyIsLabTo as islabto, M_CompanyIsDefault as isdefault,'xxx' as companymou,
M_CompanyBusinessID,M_CompanyBusinessName,Nat_CompanyLevelID,Nat_CompanyLevelName,CONCAT(Nat_CompanyLevelName,' [',M_CompanyName,']') as Nat_CompanyLevelNames ,M_ProvinceID,M_ProvinceName,M_StaffID,M_StaffName,M_CompanyNumber,M_CompanyIDParent,
Nat_HierarchyID,Nat_HierarchyName,M_CompanyFax,
M_CityID, M_CityName, M_DistrictID, M_DistrictName, M_KelurahanID, M_KelurahanName, M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorNames
from m_company
LEFT JOIN m_companytype ON M_CompanyM_CompanyTypeID = M_CompanyTypeID
LEFT JOIN m_kelurahan ON M_CompanyM_KelurahanID = M_KelurahanID
LEFT JOIN m_district ON M_CompanyM_DistrictID = M_DistrictID
LEFT JOIN m_city ON M_CompanyM_CityID = M_CityID
LEFT JOIN m_province ON M_CompanyM_ProvinceID = M_ProvinceID
LEFT JOIN m_companybusiness ON M_CompanyM_CompanyBusinessID = M_CompanyBusinessID
LEFT JOIN m_staff ON M_CompanyM_StaffID = M_StaffID
LEFT JOIN nat_companylevel ON M_CompanyNat_CompanyLevelID = Nat_CompanyLevelID
LEFT JOIN nat_hierarchy ON M_CompanyNat_HierarchyID = Nat_HierarchyID
LEFT JOIN m_doctor ON M_CompanyM_DoctorID = M_DoctorID
where
( M_CompanyName LIKE CONCAT('%','{$search}','%')
)AND
M_CompanyIsActive = 'Y' $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("m_company 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 addnewcompany()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$name = $prm['name'];
$idparent = $prm['idparent'];
$companytype = $prm['companytype'];
$companybusiness = $prm['companybusiness'];
$hierarkiid = $prm['hierarkiid'];
$companylevelid = $prm['companylevelid'];
$staffid = $prm['staffid'];
$province = $prm['province'];
$city = $prm['city'];
$district = $prm['district'];
$kelurahan = $prm['kelurahan'];
$address = $prm['address'];
$email = $prm['email'];
$phone = $prm['phone'];
$fax = $prm['fax'];
$isdefault = $prm['isdefault'];
$sql = "insert into m_company(
M_CompanyName,
M_CompanyIDParent,
M_CompanyM_CompanyTypeID,
M_CompanyM_CompanyBusinessID,
M_CompanyNat_HierarchyID,
M_CompanyNat_CompanyLevelID,
M_CompanyM_StaffID,
M_CompanyM_ProvinceID,
M_CompanyM_CityID,
M_CompanyM_DistrictID,
M_CompanyM_KelurahanID,
M_CompanyAddress,
M_CompanyEmail,
M_CompanyPhone,
M_CompanyFax,
M_CompanyIsDefault,
M_CompanyCreated,
M_CompanyLastUpdated
)
values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, now(), now())";
// echo $sql;
$query = $this->db_onedev->query($sql,
array(
$name,
$idparent,
$companytype,
$companybusiness,
$hierarkiid,
$companylevelid,
$staffid,
$province,
$city,
$district,
$kelurahan,
$address,
$email,
$phone,
$fax,
$isdefault
)
);
if (!$query) {
echo $this->db_onedev->last_query();
$this->sys_error_db("m_company insert");
exit;
}
$result = array ("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
$last_id = $this->db_onedev->insert_id();
if($isdefault == 'Y'){
$querydefault ="UPDATE m_company SET
M_CompanyIsDefault = 'N' WHERE M_CompanyIsDefault = 'Y'
AND M_CompanyID <> '{$last_id}' AND M_CompanyIsActive = 'Y'
";
$rows = $this->db_onedev->query($querydefault);
}
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function editcompany()
{
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 = $prm['name'];
$idparent = $prm['idparent'];
$companytype = $prm['companytype'];
$companybusiness = $prm['companybusiness'];
$hierarkiid = $prm['hierarkiid'];
$companylevelid = $prm['companylevelid'];
$staffid = $prm['staffid'];
$province = $prm['province'];
$city = $prm['city'];
$district = $prm['district'];
$kelurahan = $prm['kelurahan'];
$address = $prm['address'];
$email = $prm['email'];
$phone = $prm['phone'];
$fax = $prm['fax'];
$isdefault = $prm['isdefault'];
$sqlcompany = "update m_company SET
M_CompanyName = ?,
M_CompanyIDParent = ?,
M_CompanyM_CompanyTypeID = ?,
M_CompanyM_CompanyBusinessID = ?,
M_CompanyNat_HierarchyID = ?,
M_CompanyNat_CompanyLevelID = ?,
M_CompanyM_StaffID = ?,
M_CompanyM_ProvinceID = ?,
M_CompanyM_CityID = ?,
M_CompanyM_DistrictID = ?,
M_CompanyM_KelurahanID = ?,
M_CompanyAddress = ?,
M_CompanyEmail = ?,
M_CompanyPhone = ?,
M_CompanyFax = ?,
M_CompanyIsDefault = ?,
M_CompanyLastUpdated = now()
where
M_CompanyID = ?
";
$querycompany = $this->db_onedev->query($sqlcompany,
array(
$name,
$idparent,
$companytype,
$companybusiness,
$hierarkiid,
$companylevelid,
$staffid,
$province,
$city,
$district,
$kelurahan,
$address,
$email,
$phone,
$fax,
$isdefault,
$id_company
)
);
// echo $query;
if (!$querycompany) {
$this->sys_error_db("m_company update");
exit;
}
$result = array ("total" => 1, "records" => array("xid" => $id_company));
$this->sys_ok($result);
if($isdefault == 'Y'){
$querydefault ="UPDATE m_company SET
M_CompanyIsDefault = 'N' WHERE M_CompanyIsDefault = 'Y' AND M_CompanyIsActive = 'Y'
AND M_CompanyID <> '{$id_company}'
";
$rows = $this->db_onedev->query($querydefault);
}
} 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 addnewmou()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$userid = $this->sys_user["M_UserID"];
//# ambil parameter input
$prm = $this->sys_input;
$companyid = $prm['companyid'];
$name = $prm['name'];
$startdate = date('Y-m-d',strtotime($prm['startdate']));
$enddate = date('Y-m-d',strtotime($prm['enddate']));
$isbill = $prm['isbill'];
$isdefault = $prm['isdefault'];
$isaging = $prm['isaging'];
$isemail = $prm['isemail'];
$isfavorit = $prm['isfavorit'];
$isjpanetto = $prm['isjpanetto'];
$ismcu = $prm['ismcu'];
$refnumber = $prm['refnumber'];
$mindp = $prm['mindp'];
$agingnote = $prm['agingnote'];
$xnote = $prm['xnote'];
$mouemail = $prm['mouemail'];
$base = $prm['base'];
$omzettype = $prm['omzettype'];
$moutype = $prm['moutype'];
$agingtype = $prm['agingtype'];
$jpa1Name = $prm['jpa1Name'];
$jpa2Name = $prm['jpa2Name'];
$jpa3Name = $prm['jpa3Name'];
$jpa4Name = $prm['jpa4Name'];
$jpa1Percent = $prm['jpa1Percent'];
$jpa2Percent = $prm['jpa2Percent'];
$jpa3Percent = $prm['jpa3Percent'];
$jpa4Percent = $prm['jpa4Percent'];
if($prm['xid'] == "0" || $prm['xid'] == 0){
$query = "SELECT COUNT(*) as exist FROM m_mou WHERE M_MouIsActive = 'Y' AND M_MouName = '{$name}'";
$exist_name = $this->db_onedev->query($query)->row()->exist;
if($exist_name == 0){
$sql = "insert into m_mou(
M_MouM_CompanyID,
M_MouName,
M_MouStartDate,
M_MouEndDate,
M_MouIsBill,
M_MouIsDefault,
M_MouIsAgingOnHold,
M_MouEmailIsDefault,
M_MouIsUsingFavourite,
M_MouJpaIsNetto,
M_MouRefNumber,
M_MouMinDP,
M_MouIsAgingOnHoldNote,
M_MouNote,
M_MouEmail,
M_MouBase,
M_MouM_OmzetTypeID,
M_MouM_MouTypeID,
M_MouM_AgingTypeID,
M_MouUserID,
M_MouJpa1Name,
M_MouJpa1Percent,
M_MouJpa2Name,
M_MouJpa2Percent,
M_MouJpa3Name,
M_MouJpa3Percent,
M_MouJpa4Name,
M_MouJpa4Percent,
M_MouIsMcu,
M_MouCreated,
M_MouLastUpdated
)
values( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,now(),now())";
$query = $this->db_onedev->query($sql,
array(
$companyid,
$name,
$startdate,
$enddate,
$isbill,
$isdefault,
$isaging,
$isemail,
$isfavorit,
$isjpanetto,
$refnumber,
$mindp,
$agingnote,
$xnote,
$mouemail,
$base,
$omzettype,
$moutype,
$agingtype,
$userid,
$jpa1Name,
$jpa1Percent,
$jpa2Name,
$jpa2Percent,
$jpa3Name,
$jpa3Percent,
$jpa4Name,
$jpa4Percent,
$ismcu
)
);
//echo $query;
if (!$query) {
$this->sys_error_db("m_mou insert");
exit;
}
$last_id = $this->db_onedev->insert_id();
$result = array ("total" => 1, "records" => array("xid" => 0), "lastid" => $last_id);
$this->sys_ok($result);
$querystatus ="INSERT g_moustatuslog
(G_MouStatusLogDate,
G_MouStatusLogM_MouID,
G_MouStatusLogStatus,
G_MouStatusLogUserID,
G_MouStatusLogCreated,
G_MouStatusLogLastUpdated)
VALUES(
date(now()),
'{$last_id}',
'N',
'{$userid}',
now(),
now())
";
$rows = $this->db_onedev->query($querystatus);
if($isdefault == 'Y'){
$querydefault ="UPDATE m_mou SET
M_MouIsDefault = 'N' WHERE M_MouIsDefault = 'Y' AND M_MouM_CompanyID = '{$companyid}'
AND M_MouID <> '{$last_id}'
";
$rows = $this->db_onedev->query($querydefault);
}
}else{
$errors = array();
if($exist_name != 0){
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
}
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
$this->sys_ok($result);
}
}else{
$query = "SELECT COUNT(*) as exist FROM m_mou WHERE M_MouIsActive = 'Y' AND M_MouName = '{$name}' AND M_MouID <> {$prm['xid']}";
$exist_name = $this->db_onedev->query($query)->row()->exist;
//echo $query;
if($exist_name == 0){
$lastid = $prm['xid'];
$sql = "UPDATE m_mou SET M_MouName = '{$name}',
M_MouRefNumber = '{$refnumber}', M_MouStartDate = '{$startdate}', M_MouEndDate = '{$enddate}', M_MouIsBill = '{$isbill}',
M_MouIsDefault = '{$isdefault}', M_MouIsAgingOnHold = '{$isaging}',M_MouEmailIsDefault = '{$isemail}',M_MouIsUsingFavourite = '{$isfavorit}',M_MouJpaIsNetto = '{$isjpanetto}',M_MouMinDP = '{$mindp}',M_MouIsAgingOnHoldNote = '{$agingnote}',
M_MouNote = '{$xnote}',
M_MouEmail = '{$mouemail}',M_MouBase = '{$base}',M_MouM_OmzetTypeID = '{$omzettype}',M_MouM_MouTypeID = '{$moutype}',
M_MouM_AgingTypeID = '{$agingtype}',
M_MouJpa1Name = '{$jpa1Name}',
M_MouJpa1Percent = '{$jpa1Percent}',
M_MouJpa2Name = '{$jpa2Name}',
M_MouJpa2Percent = '{$jpa2Percent}',
M_MouJpa3Name = '{$jpa3Name}',
M_MouJpa3Percent = '{$jpa3Percent}',
M_MouJpa4Name = '{$jpa4Name}',
M_MouJpa4Percent = '{$jpa4Percent}',
M_MouIsMcu = '{$ismcu}'
WHERE M_MouID = '{$prm['xid']}'";
//echo $sql;
$query = $this->db_onedev->query($sql);
$result = array ("total" => 1, "records" => array("xid" => 0), "lastid" => $lastid);
$this->sys_ok($result);
if($isdefault == 'Y'){
$querydefault ="UPDATE m_mou SET
M_MouIsDefault = 'N' WHERE M_MouIsDefault = 'Y' AND M_MouM_CompanyID = '{$companyid}'
AND M_MouID <> '{$prm['xid']}'
";
$rows = $this->db_onedev->query($querydefault);
}
}else{
$errors = array();
if($exist_name != 0){
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
}
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
$this->sys_ok($result);
}
}
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function deletemou()
{
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_MouIsActive = '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 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;
$userid = $this->sys_user["M_UserID"];
$id = $prm['id'];
$sql = "update m_mou SET
M_MouIsConfirm = 'Y',
M_MouConfirmDate = now(),
M_MouStatus = 'C',
M_MouConfirmUserID = '{$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}',
'C',
'{$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 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 deletecompany()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$sql = "update m_company SET
M_CompanyIsActive = 'N',
M_CompanyLastUpdated = now()
WHERE
M_CompanyID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("m_company delete");
exit;
}
$sql = "UPDATE m_mou SET
M_MouIsActive = 'N',
M_MouLastUpdated = now()
WHERE
M_MouM_CompanyID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("m_mou 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 *, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorNames
FROM m_doctor
WHERE M_DoctorIsActive = 'Y') a
WHERE
M_DoctorNames like ?
AND M_DoctorIsActive = 'Y'
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 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);
}
}
}