update file BE folder map from server

This commit is contained in:
2026-05-06 16:50:10 +07:00
parent bf0cc4af84
commit 4234c37e75
5 changed files with 3263 additions and 0 deletions

View File

@@ -0,0 +1,697 @@
<?php
class Faclassv2 extends MY_Controller{
var $db_onedev;
public function index()
{
echo "AUTH API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
// search
function search()
{
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$search = isset($prm["search"]) ? trim($prm["search"]) : '';
$search = ($search !== '') ? "%$search%" : "%%";
// $number_offset = ($prm["current_page"] > 0) ? ($prm["current_page"] - 1) * 20 : 0;
// $number_limit = 2;
$number_limit = 10;
$number_offset = ($prm["current_page"] > 0) ? ($prm["current_page"] - 1) * $number_limit : 0;
$sql = "SELECT
f.Fa_ClassID,
IFNULL(f.Fa_ClassName, '') AS Fa_ClassName,
IFNULL(f.Fa_ClassCoaID, '') AS Fa_ClassCoaID,
IFNULL(f.Fa_ClassCoaAccountNo, '') AS Fa_ClassCoaAccountNo,
IFNULL(f.Fa_ClassCoaDesc, '') AS Fa_ClassCoaDesc,
IFNULL(f.Fa_ClassDepreCorp, 0.00) AS Fa_ClassDepreCorp,
IFNULL(f.Fa_ClassDepreGov, 0.00) AS Fa_ClassDepreGov,
IFNULL(f.Fa_ClassAccumDepreCoaID, 0) AS Fa_ClassAccumDepreCoaID,
IFNULL(f.Fa_ClassAccumDepreCoaAccountNo, '') AS Fa_ClassAccumDepreCoaAccountNo,
IFNULL(f.Fa_ClassAccumDepreCoaDesc, '') AS Fa_ClassAccumDepreCoaDesc,
IFNULL(f.Fa_ClassAccumNote, '') AS Fa_ClassAccumNote,
IFNULL(f.Fa_ClassAccumCreated, CURRENT_TIMESTAMP) AS Fa_ClassAccumCreated,
IFNULL(f.Fa_ClassAccumLastUpdated, CURRENT_TIMESTAMP) AS Fa_ClassAccumLastUpdated,
IFNULL(f.Fa_ClassIsActive, 'N') AS Fa_ClassIsActive,
IFNULL(f.Fa_ClassM_UserID, 0) AS Fa_ClassM_UserID,
IFNULL(f.Fa_ClassAgeAsset, 0.00) AS Fa_ClassAgeAsset,
-- Data dari tabel coa untuk Class CoA
IFNULL(c_class.coaID, 0) AS ClassCoaID,
IFNULL(c_class.coaAccountNo, '') AS ClassCoaAccountNo,
IFNULL(c_class.coaDescription, '') AS ClassCoaDescription,
-- Data dari tabel coa untuk Accumulated Depreciation CoA
IFNULL(c_accum.coaID, 0) AS AccumDepreCoaID,
IFNULL(c_accum.coaAccountNo, '') AS AccumDepreCoaAccountNo,
IFNULL(c_accum.coaDescription, '') AS AccumDepreCoaDescription,
-- Data dari tabel coa untuk Biaya Depresiasi CoA
IFNULL(c_cost.coaID, 0) AS DepreCostCoaID,
IFNULL(c_cost.coaAccountNo, '') AS DepreCostCoaAccountNo,
IFNULL(c_cost.coaDescription, '') AS DepreCostCoaDescription
FROM fa_class f
LEFT JOIN coa c_class
ON f.Fa_ClassCoaID = c_class.coaID
AND c_class.coaIsActive = 'Y'
AND c_class.coaIsInput = 'Y'
LEFT JOIN coa c_accum
ON f.Fa_ClassAccumDepreCoaID = c_accum.coaID
AND c_accum.coaIsActive = 'Y'
AND c_accum.coaIsInput = 'Y'
LEFT JOIN coa c_cost
ON f.Fa_ClassAccumDepreCostCoaID = c_cost.coaID
AND c_cost.coaIsActive = 'Y'
AND c_cost.coaIsInput = 'Y'
WHERE f.Fa_ClassIsActive = 'Y'
AND (
f.Fa_ClassName LIKE CONCAT('%', '$search', '%')
OR f.Fa_ClassCoaAccountNo LIKE CONCAT('%', '$search', '%')
OR f.Fa_ClassCoaDesc LIKE CONCAT('%', '$search', '%')
OR f.Fa_ClassAccumDepreCoaAccountNo LIKE CONCAT('%', '$search', '%')
OR f.Fa_ClassAccumDepreCoaDesc LIKE CONCAT('%', '$search', '%')
OR f.Fa_ClassAccumNote LIKE CONCAT('%', '$search', '%')
OR f.Fa_ClassDepreCorp LIKE CONCAT('%', '$search', '%')
)
ORDER BY f.Fa_ClassID ASC";
$sql_total = "SELECT count(*) as total FROM ($sql) as x";
$qry_total = $this->db_onedev->query($sql_total);
$totalCount = 0;
$totalPage = 0;
if ($qry_total) {
$totalCount = $qry_total->result_array()[0]["total"];
$totalPage = ceil($totalCount / $number_limit);
} else {
$this->sys_error_db("select fa_class count error", $this->db_onedev);;
exit;
}
$sql_select = $sql . " LIMIT $number_limit OFFSET $number_offset";
$qry = $this->db_onedev->query($sql_select);
if ($qry) {
$rows = $qry->result_array();
} else {
$this->db_onedev->trans_rollback();
$this->sys_error_db("select fa_class error", $this->db_onedev);
exit;
}
$response = [
"total" => $totalPage,
"totalFilter" => $totalCount,
"records" => $rows,
"sql" => $this->db_onedev->last_query()
];
$this->sys_ok($response);
} catch (Exception $exc) {
$this->sys_error($exc->getMessage());
}
}
// ac getAcAccumDepre
function getAcAccumDepre()
{
$prm = $this->sys_input;
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$search = $prm['search'];
// $where_search = "%%";
$where_search_desc = '%'.$search.'%';
$where_search_acc = "$search%";
$sql = "SELECT
coaID,
coaAccountNo,
coaDescription,
coaSubDescription,
coaAccountType,
coaSpecialAccountType,
coaIsInput,
coaReportSchedule,
coaCurrencyCode,
coaCashFlowCategory,
coaCreated,
coaLastUpdated,
coaIsActive,
coaLevel
FROM coa
WHERE coaIsInput = 'Y'
AND coaIsActive = 'Y'
AND
(
coaDescription LIKE '$where_search_desc'
OR coaAccountNo LIKE '$where_search_acc'
)";
// echo $sql;
// die();
$qry = $this->db_onedev->query($sql, array());
if (!$qry) {
// $this->db->trans_rollback();
$this->sys_error_db("Error get coa pendapatan");
exit;
}
$result = $qry->result_array();
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function getAcDepreCost()
{
$prm = $this->sys_input;
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$search = $prm['search'];
// $where_search = "%%";
$where_search_desc = '%'.$search.'%';
$where_search_acc = "$search%";
$sql = "SELECT
coaID,
coaAccountNo,
coaDescription,
coaSubDescription,
coaAccountType,
coaSpecialAccountType,
coaIsInput,
coaReportSchedule,
coaCurrencyCode,
coaCashFlowCategory,
coaCreated,
coaLastUpdated,
coaIsActive,
coaLevel
FROM coa
WHERE coaIsInput = 'Y'
AND coaIsActive = 'Y'
AND
(
coaDescription LIKE '$where_search_desc'
OR coaAccountNo LIKE '$where_search_acc'
)";
// echo $sql;
// die();
$qry = $this->db_onedev->query($sql, array());
if (!$qry) {
// $this->db->trans_rollback();
$this->sys_error_db("Error get coa pendapatan");
exit;
}
$result = $qry->result_array();
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
// ac getAcCoa
function getAcCoa()
{
$prm = $this->sys_input;
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$search = $prm['search'];
// $where_search = "%%";
$where_search_desc = '%'.$search.'%';
$where_search_acc = "$search%";
$sql = "SELECT
coaID,
coaAccountNo,
coaDescription,
coaSubDescription,
coaAccountType,
coaSpecialAccountType,
coaIsInput,
coaReportSchedule,
coaCurrencyCode,
coaCashFlowCategory,
coaCreated,
coaLastUpdated,
coaIsActive,
coaLevel
FROM coa
WHERE coaIsInput = 'Y'
AND coaIsActive = 'Y'
AND
(
coaDescription LIKE '$where_search_desc'
OR coaAccountNo LIKE '$where_search_acc'
)";
// echo $sql;
// die();
$qry = $this->db_onedev->query($sql, array());
if (!$qry) {
// $this->db->trans_rollback();
$this->sys_error_db("Error get coa pendapatan");
exit;
}
$result = $qry->result_array();
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
// addData
function addData()
{
$prm = $this->sys_input;
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$this->db_onedev->trans_begin();
$userid = $this->sys_user['M_UserID'];
$a_classname = $prm['a_classname'];
$a_coa = $prm['a_coa'];
$a_deprecorp = $prm['a_deprecorp'];
$a_age = $prm['a_age'];
$a_coa_accum_depre = $prm['a_coa_accum_depre'];
$a_coa_depre_cost = $prm['a_coa_depre_cost'];
$a_note = $prm['a_note'];
// defined variable
$Fa_ClassIsActive = "Y";
$Fa_ClassAccumCreated = date('Y-m-d H:i:s');
$Fa_ClassAccumLastUpdated = date('Y-m-d H:i:s');
// a_classname
$Fa_ClassName = isset($a_classname) ? $a_classname : "";
// coa
$Fa_ClassCoaID = isset($a_coa['coaID']) ? $a_coa['coaID'] : 0;
$Fa_ClassCoaAccountNo = isset($a_coa['coaAccountNo']) ? $a_coa['coaAccountNo'] : '';
$Fa_ClassCoaDesc = isset($a_coa['coaDescription']) ? $a_coa['coaDescription'] : '';
// a_deprecorp
$Fa_ClassDepreCorp = isset($a_deprecorp) ? $a_deprecorp : 0.00;
// a_deprecorp
$Fa_ClassAgeAsset = isset($a_age) ? $a_age : 0;
// accum depre
$Fa_ClassAccumDepreCoaID = isset($a_coa_accum_depre['coaID']) ? $a_coa_accum_depre['coaID'] : 0;
$Fa_ClassAccumDepreCoaAccountNo = isset($a_coa_accum_depre['coaAccountNo']) ? $a_coa_accum_depre['coaAccountNo'] : '';
$Fa_ClassAccumDepreCoaDesc = isset($a_coa_accum_depre['coaDescription']) ? $a_coa_accum_depre['coaDescription'] : '';
$Fa_ClassAccumDepreCostCoaID = isset($a_coa_depre_cost['coaID']) ? $a_coa_depre_cost['coaID'] : 0;
// note
$Fa_ClassAccumNote = isset($a_note) ? $a_note : "";
// mulai insert
$sql = "INSERT INTO fa_class (
Fa_ClassName,
Fa_ClassCoaID,
Fa_ClassCoaAccountNo,
Fa_ClassCoaDesc,
Fa_ClassDepreCorp,
Fa_ClassDepreGov,
Fa_ClassAccumDepreCoaID,
Fa_ClassAccumDepreCoaAccountNo,
Fa_ClassAccumDepreCoaDesc,
Fa_ClassAccumNote,
Fa_ClassAccumCreated,
Fa_ClassAccumLastUpdated,
Fa_ClassIsActive,
Fa_ClassM_UserID,
Fa_ClassAccumDepreCostCoaID
) VALUES (
'$Fa_ClassName',
'$Fa_ClassCoaID',
'$Fa_ClassCoaAccountNo',
'$Fa_ClassCoaDesc',
'$Fa_ClassDepreCorp',
'0.00',
'$Fa_ClassAccumDepreCoaID',
'$Fa_ClassAccumDepreCoaAccountNo',
'$Fa_ClassAccumDepreCoaDesc',
'$Fa_ClassAccumNote',
'$Fa_ClassAccumCreated',
'$Fa_ClassAccumLastUpdated',
'$Fa_ClassIsActive',
'$userid',
'$Fa_ClassAccumDepreCostCoaID'
)
";
// echo $sql;
$qry = $this->db_onedev->query($sql);
if (!$qry) {
$this->db_onedev->trans_rollback();
$error = array(
"message" => $this->db_onedev->error()["message"],
// "sql" => $last_qry
);
$this->sys_error_db($error, $this->db_onedev);
exit;
}
$this->db_onedev->trans_commit();
$result = array("total" => 1);
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
// get_by_id
function get_by_id()
{
$prm = $this->sys_input;
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
// fa_class
$Fa_ClassID = isset($prm['Fa_ClassID']) ? $prm['Fa_ClassID'] : 0;
$sql_m = "SELECT * FROM fa_class where Fa_ClassID = '$Fa_ClassID'";
$qry_m = $this->db_onedev->query($sql_m);
if (!$qry_m) {
$error = array(
"message" => $this->db_onedev->error()["message"],
"sql" => $this->db_onedev->last_query()
);
$this->sys_error_db($error, $this->db_onedev);
exit;
}
$rows_m = $qry_m->result_array();
// coa start
$Fa_ClassCoaID = isset($prm['Fa_ClassCoaID']) ? $prm['Fa_ClassCoaID'] : 0;
$sql_u = "SELECT * FROM coa where coaID = '$Fa_ClassCoaID'
AND coaIsInput = 'Y'
AND coaIsActive = 'Y'
";
$qry_u = $this->db_onedev->query($sql_u);
if (!$qry_u) {
$error = array(
"message" => $this->db_onedev->error()["message"],
"sql" => $this->db_onedev->last_query()
);
$this->sys_error_db($error, $this->db_onedev);
exit;
}
$rows_u = $qry_u->result_array();
// empty $rows_u
if (empty($rows_u)) {
$rows_u = [[
"coaID" => 0,
"coaAccountNo" => '',
"coaDescription" => '',
"coaSubDescription" => '',
"coaAccountType" => '',
"coaSpecialAccountType" => '',
"coaIsInput" => 'N',
"coaReportSchedule" => '',
"coaCurrencyCode" => '',
"coaCashFlowCategory" => '',
"coaCreated" => '',
"coaLastUpdated" => '',
"coaIsActive" => 'Y',
"coaLevel" => 1
]];
}
// coa end
// accum depre start
$Fa_ClassAccumDepreCoaID = $prm['Fa_ClassAccumDepreCoaID'];
$sql_h = "SELECT * FROM coa where coaID = '$Fa_ClassAccumDepreCoaID'
AND coaIsInput = 'Y'
AND coaIsActive = 'Y'";
$qry_h = $this->db_onedev->query($sql_h);
if (!$qry_h) {
$error = array(
"message" => $this->db_onedev->error()["message"],
"sql" => $this->db_onedev->last_query()
);
$this->sys_error_db($error, $this->db_onedev);
exit;
}
$rows_h = $qry_h->result_array();
// empty $rows_h
if (empty($rows_h)) {
$rows_h = [[
"coaID" => 0,
"coaAccountNo" => '',
"coaDescription" => '',
"coaSubDescription" => '',
"coaAccountType" => '',
"coaSpecialAccountType" => '',
"coaIsInput" => 'N',
"coaReportSchedule" => '',
"coaCurrencyCode" => '',
"coaCashFlowCategory" => '',
"coaCreated" => '',
"coaLastUpdated" => '',
"coaIsActive" => 'Y',
"coaLevel" => 1
]];
}
// accum depre end
// depre cost start
$Fa_ClassAccumDepreCostCoaID = $prm['Fa_ClassAccumDepreCostCoaID'];
$sql_c = "SELECT * FROM coa where coaID = '$Fa_ClassAccumDepreCostCoaID'
AND coaIsInput = 'Y'
AND coaIsActive = 'Y'";
$qry_c = $this->db_onedev->query($sql_c);
if (!$qry_c) {
$error = array(
"message" => $this->db_onedev->error()["message"],
"sql" => $this->db_onedev->last_query()
);
$this->sys_error_db($error, $this->db_onedev);
exit;
}
$rows_c = $qry_c->result_array();
// empty $rows_h
if (empty($rows_c)) {
$rows_c = [[
"coaID" => 0,
"coaAccountNo" => '',
"coaDescription" => '',
"coaSubDescription" => '',
"coaAccountType" => '',
"coaSpecialAccountType" => '',
"coaIsInput" => 'N',
"coaReportSchedule" => '',
"coaCurrencyCode" => '',
"coaCashFlowCategory" => '',
"coaCreated" => '',
"coaLastUpdated" => '',
"coaIsActive" => 'Y',
"coaLevel" => 1
]];
}
// accum depre end
$response = [
"record_fa_class" => $rows_m,
"records_coa" => $rows_u,
"records_accum_depre" => $rows_h,
"records_depre_cost" => $rows_c,
"sql" => $this->db_onedev->last_query()
];
$this->sys_ok($response);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
// editData
function editData()
{
$prm = $this->sys_input;
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$this->db_onedev->trans_begin();
$userid = $this->sys_user['M_UserID'];
$Fa_ClassID = $prm['Fa_ClassID'];
$e_classname = $prm['e_classname'];
$e_coa = $prm['e_coa'];
$e_deprecorp = $prm['e_deprecorp'];
$e_coa_accum_depre = $prm['e_coa_accum_depre'];
$e_note = $prm['e_note'];
$e_age = $prm['e_age'];
$e_coa_depre_cost = $prm['e_coa_depre_cost'];
// defined variable
$Fa_ClassIsActive = "Y";
$Fa_ClassAccumLastUpdated = date('Y-m-d H:i:s');
// e_classname
$Fa_ClassName = isset($e_classname) ? $e_classname : "";
// coa
$Fa_ClassCoaID = isset($e_coa['coaID']) ? $e_coa['coaID'] : 0;
$Fa_ClassCoaAccountNo = isset($e_coa['coaAccountNo']) ? $e_coa['coaAccountNo'] : '';
$Fa_ClassCoaDesc = isset($e_coa['coaDescription']) ? $e_coa['coaDescription'] : '';
// e_deprecorp
$Fa_ClassDepreCorp = isset($e_deprecorp) ? $e_deprecorp : 0.00;
$Fa_ClassAgeAsset = isset($e_age) ? $e_age : 0;
// accum depre
$Fa_ClassAccumDepreCoaID = isset($e_coa_accum_depre['coaID']) ? $e_coa_accum_depre['coaID'] : 0;
$Fa_ClassAccumDepreCoaAccountNo = isset($e_coa_accum_depre['coaAccountNo']) ? $e_coa_accum_depre['coaAccountNo'] : '';
$Fa_ClassAccumDepreCoaDesc = isset($e_coa_accum_depre['coaDescription']) ? $e_coa_accum_depre['coaDescription'] : '';
$Fa_ClassAccumDepreCostCoaID = isset($e_coa_depre_cost['coaID']) ? $e_coa_depre_cost['coaID'] : 0;
// note
$Fa_ClassAccumNote = isset($e_note) ? $e_note : "";
$sql = "UPDATE fa_class SET
Fa_ClassName = '$Fa_ClassName',
Fa_ClassCoaID = '$Fa_ClassCoaID',
Fa_ClassCoaAccountNo = '$Fa_ClassCoaAccountNo',
Fa_ClassCoaDesc = '$Fa_ClassCoaDesc',
Fa_ClassDepreCorp = '$Fa_ClassDepreCorp',
Fa_ClassAgeAsset = '$Fa_ClassAgeAsset',
Fa_ClassDepreGov = '0.00',
Fa_ClassAccumDepreCostCoaID = '$Fa_ClassAccumDepreCostCoaID',
Fa_ClassAccumDepreCoaID = '$Fa_ClassAccumDepreCoaID',
Fa_ClassAccumDepreCoaAccountNo = '$Fa_ClassAccumDepreCoaAccountNo',
Fa_ClassAccumDepreCoaDesc = '$Fa_ClassAccumDepreCoaDesc',
Fa_ClassAccumNote = '$Fa_ClassAccumNote',
Fa_ClassAccumLastUpdated = '$Fa_ClassAccumLastUpdated',
Fa_ClassIsActive = '$Fa_ClassIsActive',
Fa_ClassM_UserID = '$userid'
WHERE Fa_ClassID = '$Fa_ClassID'
";
// echo $sql;
$qry = $this->db_onedev->query($sql);
if (!$qry) {
$this->db_onedev->trans_rollback();
$error = array(
"message" => $this->db_onedev->error()["message"],
// "sql" => $last_qry
);
$this->sys_error_db($error, $this->db_onedev);
exit;
}
$this->db_onedev->trans_commit();
$result = array("total" => 1);
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
// deleteData
function deleteData()
{
$prm = $this->sys_input;
try {
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$this->db_onedev->trans_begin();
$userid = $this->sys_user['M_UserID'];
$Fa_ClassID = $prm['Fa_ClassID'];
$Fa_ClassAccumLastUpdated = date('Y-m-d H:i:s');
$sql = "UPDATE fa_class
SET
Fa_ClassIsActive = 'N',
Fa_ClassAccumLastUpdated = '$Fa_ClassAccumLastUpdated',
Fa_ClassM_UserID = '$userid'
WHERE Fa_ClassID = '$Fa_ClassID'";
$qry = $this->db_onedev->query($sql);
if (!$qry) {
$this->db_onedev->trans_rollback();
$error = array(
"message" => $this->db_onedev->error()["message"],
"sql" => $last_qry
);
$this->sys_error_db($error, $this->db_onedev);
exit;
}
$this->db_onedev->trans_commit();
$result = array("total" => 1);
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
}
?>