1311 lines
39 KiB
PHP
1311 lines
39 KiB
PHP
<?php
|
|
|
|
class Company 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,
|
|
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,
|
|
M_MouIsBill as isbill,
|
|
M_MouRefNumber as refnumber,
|
|
M_MouNumber as number,
|
|
M_MouIsDefault as isdefault,
|
|
M_MouIsUsingFavourite as isfavorit,
|
|
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,
|
|
'xxx' as action
|
|
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;
|
|
$rows = $this->db_onedev->query($sql)->result();
|
|
|
|
$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_CompanyPIC as pic,
|
|
ifnull( CONCAT(M_CompanyName,' ' ,'[ ', ifnull(M_CompanyTypeName,'-') ,' ]'), M_CompanyName ) 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_StaffID,M_StaffName,
|
|
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_doctor ON M_CompanyM_DoctorID = M_DoctorID
|
|
LEFT JOIN m_staff ON M_CompanyM_StaffID = M_StaffID
|
|
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_company = $prm['name'];
|
|
$address_company = $prm['address'];
|
|
$phone_company = $prm['phone'];
|
|
$email_company = $prm['email'];
|
|
$pic_company = $prm['pic'];
|
|
$companytypenew_company = $prm['companytypenew'];
|
|
$companytype_company = $prm['companytype'];
|
|
$staff_company = $prm['staff'];
|
|
$isdefault = $prm['isdefault'];
|
|
$islabfrom = $prm['islabfrom'];
|
|
$islabto = $prm['islabto'];
|
|
$city = $prm['city'];
|
|
$district = $prm['district'];
|
|
$kelurahan = $prm['kelurahan'];
|
|
$doctor = $prm['doctor'];
|
|
|
|
if($companytypenew_company != ''){
|
|
$sql = "insert into m_companytype(
|
|
M_CompanyTypeName,
|
|
M_CompanyTypeCreated,
|
|
M_CompanyTypeLastUpdated
|
|
)
|
|
values( ?, now(), now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$companytypenew_company
|
|
)
|
|
);
|
|
//echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_companytype insert");
|
|
exit;
|
|
}
|
|
$companytypenewid = $this->db_onedev->insert_id();
|
|
$sqlcompany = "insert into m_company(
|
|
M_CompanyName,
|
|
M_CompanyM_CityID,
|
|
M_CompanyM_DistrictID,
|
|
M_CompanyM_KelurahanID,
|
|
M_CompanyAddress,
|
|
M_CompanyPhone,
|
|
M_CompanyEmail,
|
|
M_CompanyPIC,
|
|
M_CompanyM_CompanyTypeID,
|
|
M_CompanyM_StaffID
|
|
M_CompanyIsLabFrom,
|
|
M_CompanyIsLabTo,
|
|
M_CompanyM_DoctorID,
|
|
M_CompanyIsDefault,
|
|
M_CompanyCreated,
|
|
M_CompanyLastUpdated
|
|
)
|
|
values( ?, ?, ?, ?, ?, ?,?, ?, ?, ?, ?, ?, ?, ?, now(), now())";
|
|
$querycompany = $this->db_onedev->query($sqlcompany,
|
|
array(
|
|
$name_company,
|
|
$city,
|
|
$district,
|
|
$kelurahan,
|
|
$address_company,
|
|
$phone_company,
|
|
$email_company,
|
|
$pic_company,
|
|
$companytypenewid,
|
|
$staff_company,
|
|
$islabfrom,
|
|
$islabto,
|
|
$doctor,
|
|
$isdefault
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$querycompany) {
|
|
$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}'
|
|
";
|
|
$rows = $this->db_onedev->query($querydefault);
|
|
}
|
|
} else{
|
|
$sql = "insert into m_company(
|
|
M_CompanyName,
|
|
M_CompanyM_CityID,
|
|
M_CompanyM_DistrictID,
|
|
M_CompanyM_KelurahanID,
|
|
M_CompanyAddress,
|
|
M_CompanyPhone,
|
|
M_CompanyEmail,
|
|
M_CompanyPIC,
|
|
M_CompanyM_CompanyTypeID,
|
|
M_CompanyM_StaffID,
|
|
M_CompanyIsLabFrom,
|
|
M_CompanyIsLabTo,
|
|
M_CompanyM_DoctorID,
|
|
M_CompanyIsDefault,
|
|
M_CompanyCreated,
|
|
M_CompanyLastUpdated
|
|
)
|
|
values( ?, ?, ?, ?, ?, ?, ?,?, ?, ?, ?, ?, ?, ?,now(), now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$name_company,
|
|
$city,
|
|
$district,
|
|
$kelurahan,
|
|
$address_company,
|
|
$phone_company,
|
|
$email_company,
|
|
$pic_company,
|
|
$companytype_company,
|
|
$staff_company,
|
|
$islabfrom,
|
|
$islabto,
|
|
$doctor,
|
|
$isdefault
|
|
)
|
|
);
|
|
//echo $query;
|
|
if (!$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}'
|
|
";
|
|
$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_company = $prm['name'];
|
|
$address_company = $prm['address'];
|
|
$phone_company = $prm['phone'];
|
|
$email_company = $prm['email'];
|
|
$pic_company = $prm['pic'];
|
|
$companytypenew_company = $prm['companytypenew'];
|
|
$companytype_company = $prm['companytype'];
|
|
$staff_company = $prm['staff'];
|
|
$isdefault = $prm['isdefault'];
|
|
$islabfrom = $prm['islabfrom'];
|
|
$islabto = $prm['islabto'];
|
|
$city = $prm['city'];
|
|
$district = $prm['district'];
|
|
$kelurahan = $prm['kelurahan'];
|
|
$doctor = $prm['doctor'];
|
|
|
|
if($companytypenew_company != ''){
|
|
$sql = "insert into m_companytype(
|
|
M_CompanyTypeName,
|
|
M_CompanyTypeCreated,
|
|
M_CompanyTypeLastUpdated
|
|
)
|
|
values( ?, now(), now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$companytypenew_company
|
|
)
|
|
);
|
|
//echo $query;
|
|
if (!$query) {
|
|
$this->sys_error_db("m_companytype insert");
|
|
exit;
|
|
}
|
|
$companytypenewid = $this->db_onedev->insert_id();
|
|
$sqlcompany = "update m_company SET
|
|
M_CompanyName = ?,
|
|
M_CompanyM_CityID = ?,
|
|
M_CompanyM_DistrictID = ?,
|
|
M_CompanyM_KelurahanID = ?,
|
|
M_CompanyAddress = ?,
|
|
M_CompanyPhone = ?,
|
|
M_CompanyEmail = ?,
|
|
M_CompanyPIC = ?,
|
|
M_CompanyM_CompanyTypeID = ?,
|
|
M_CompanyM_StaffID = ?,
|
|
M_CompanyIsLabFrom = ?,
|
|
M_CompanyIsLabTo = ?,
|
|
M_CompanyM_DoctorID = ?,
|
|
M_CompanyIsDefault = ?,
|
|
M_CompanyLastUpdated = now()
|
|
where
|
|
M_CompanyID = ?
|
|
";
|
|
$querycompany = $this->db_onedev->query($sqlcompany,
|
|
array(
|
|
$name_company,
|
|
$city,
|
|
$district,
|
|
$kelurahan,
|
|
$address_company,
|
|
$phone_company,
|
|
$email_company,
|
|
$pic_company,
|
|
$companytypenewid,
|
|
$staff_company,
|
|
$islabfrom,
|
|
$islabto,
|
|
$doctor,
|
|
$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_CompanyID <> '{$id_company}'
|
|
";
|
|
$rows = $this->db_onedev->query($querydefault);
|
|
}
|
|
} else {
|
|
$sql = "update m_company SET
|
|
M_CompanyName = ?,
|
|
M_CompanyM_CityID = ?,
|
|
M_CompanyM_DistrictID = ?,
|
|
M_CompanyM_KelurahanID = ?,
|
|
M_CompanyAddress = ?,
|
|
M_CompanyPhone = ?,
|
|
M_CompanyEmail = ?,
|
|
M_CompanyPIC = ?,
|
|
M_CompanyM_CompanyTypeID = ?,
|
|
M_CompanyM_StaffID = ?,
|
|
M_CompanyIsLabFrom = ?,
|
|
M_CompanyIsLabTo = ?,
|
|
M_CompanyM_DoctorID = ?,
|
|
M_CompanyIsDefault = ?,
|
|
M_CompanyLastUpdated = now()
|
|
where
|
|
M_CompanyID = ?
|
|
";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$name_company,
|
|
$city,
|
|
$district,
|
|
$kelurahan,
|
|
$address_company,
|
|
$phone_company,
|
|
$email_company,
|
|
$pic_company,
|
|
$companytype_company,
|
|
$staff_company,
|
|
$islabfrom,
|
|
$islabto,
|
|
$doctor,
|
|
$isdefault,
|
|
$id_company
|
|
)
|
|
);
|
|
// echo $query;
|
|
if (!$query) {
|
|
$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_CompanyID <> '{$id_company}'
|
|
";
|
|
$rows = $this->db_onedev->query($querydefault);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} 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;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$companyid = $prm['companyid'];
|
|
$name = $prm['name'];
|
|
$startdate = $prm['startdate'];
|
|
$enddate = $prm['enddate'];
|
|
$isbill = $prm['isbill'];
|
|
$isdefault = $prm['isdefault'];
|
|
$isaging = $prm['isaging'];
|
|
$isemail = $prm['isemail'];
|
|
$isfavorit = $prm['isfavorit'];
|
|
$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'];
|
|
|
|
|
|
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_MouRefNumber,
|
|
M_MouMinDP,
|
|
M_MouIsAgingOnHoldNote,
|
|
M_MouNote,
|
|
M_MouEmail,
|
|
M_MouBase,
|
|
M_MouM_OmzetTypeID,
|
|
M_MouM_MouTypeID,
|
|
M_MouM_AgingTypeID,
|
|
M_MouCreated,
|
|
M_MouLastUpdated
|
|
)
|
|
values( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$companyid,
|
|
$name,
|
|
$startdate,
|
|
$enddate,
|
|
$isbill,
|
|
$isdefault,
|
|
$isaging,
|
|
$isemail,
|
|
$isfavorit,
|
|
$refnumber,
|
|
$mindp,
|
|
$agingnote,
|
|
$xnote,
|
|
$mouemail,
|
|
$base,
|
|
$omzettype,
|
|
$moutype,
|
|
$agingtype
|
|
|
|
)
|
|
);
|
|
//echo $query;
|
|
|
|
|
|
if (!$query) {
|
|
$this->sys_error_db("m_mou 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_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){
|
|
$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_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}' WHERE M_MouID = '{$prm['xid']}'";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
$result = array ("total" => 1, "records" => array("xid" => 0));
|
|
$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;
|
|
|
|
$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"];
|
|
$sql = "update m_mou SET
|
|
M_MouIsVerified = 'Y',
|
|
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;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$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"];
|
|
$sql = "update m_mou SET
|
|
M_MouIsVerified = 'N',
|
|
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;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$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"];
|
|
$sql = "update m_mou SET
|
|
M_MouIsReleased = 'Y',
|
|
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;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$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"];
|
|
$sql = "update m_mou SET
|
|
M_MouIsReleased = 'N',
|
|
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;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$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 *
|
|
FROM m_companytype
|
|
WHERE
|
|
M_CompanyTypeIsActive = 'Y'
|
|
";
|
|
//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 selectstaff(){
|
|
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_staff
|
|
WHERE
|
|
M_StaffIsActive = 'Y' and M_StaffM_PositionID = '2'
|
|
";
|
|
//echo $query;
|
|
$rows['staffs'] = $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 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 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);
|
|
}
|
|
|
|
}
|
|
|
|
}
|