Files
BE_IBL/application/controllers/cpone/masterdata/Fisiktemplate.php
2026-04-15 15:23:57 +07:00

907 lines
31 KiB
PHP

<?php
class Fisiktemplate extends MY_Controller
{
var $db;
public function index()
{
echo "PATIENT API";
}
public function __construct()
{
parent::__construct();
// $this->db_onedev = $this->load->database("onedev", true);
}
function lookupfisikbyname()
{
try {
//# cek token valid
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$fisikname = $prm['fisikname'];
$filter = '';
if (isset($sexid)) {
$filter .= "AND ($sexid = 0 or ($sexid > 0 and Nat_SexID = $sexid)) ";
}
if (isset($flagid)) {
$filter .= "AND ($flagid = 0 or ($flagid > 0 and Nat_FlagID = $flagid))";
}
$limit = '';
if ($all == 'N') {
$limit = ' LIMIT 10';
}
$number_limit = 10;
$number_offset = ($prm['current_page'] - 1) * $number_limit;
$sql = "SELECT COUNT(*) as total FROM
(SELECT *
FROM fisik_template_mapping
WHERE FisikTemplateMappingIsActive = 'Y' AND
FisikTemplateMappingName LIKE '%{$fisikname}%'
GROUP BY FisikTemplateMappingID) x";
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
$query = $this->db->query($sql);
//echo $this->db->last_query();
$tot_count = 0;
$tot_page = 0;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
$tot_page = ceil($tot_count / $number_limit);
} else {
$this->sys_error_db("fisik_template_mapping count", $this->db);
exit;
}
$sql = "SELECT FisikTemplateMappingID as id,
FisikTemplateMappingID,
FisikTemplateMappingName
FROM fisik_template_mapping
WHERE FisikTemplateMappingIsActive = 'Y' AND
FisikTemplateMappingName LIKE '%{$fisikname}%'
GROUP BY FisikTemplateMappingID
ORDER BY FisikTemplateMappingName ASC
limit $number_limit offset $number_offset";
// $sql_param = array($search);
$query = $this->db->query($sql);
// echo $this->db->last_query();
if ($query) {
$rows = $query->result_array();
} else {
$this->sys_error_db("fisik_template_mapping select");
exit;
}
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function addfisik()
{
try {
//# cek token valid
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$this->db->trans_begin();
$prm = $this->sys_input;
$userid = $this->sys_user['M_UserID'];
$name = "";
if (isset($prm["name"])) {
$name = trim($prm["name"]);
}
$sql = "INSERT INTO fisik_template_mapping(
FisikTemplateMappingName,
FisikTemplateMappingCreated,
FisikTemplateMappingCreatedUserID,
FisikTemplateMappingLastUpdated
) VALUES(?,NOW(),?,NOW())";
$qry = $this->db->query($sql, array($name, $userid));
if (!$qry) {
$this->db->trans_rollback();
$this->sys_error_db("save fisik_template_mapping error", $this->db);
exit;
}
$this->db->trans_commit();
$result = array(
"total" => 1,
"affected_rows" => $this->db->affected_rows()
);
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function lookupfisikdetailbyid()
{
try {
//# cek token valid
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$code = $prm['code'];
$name = $prm['name'];
$all = $prm['all'];
// $filter = '';
// if ($status != 'A') {
// $filter .= "AND status = '{$status}' ";
// } else {
// $filter .= "";
// }
$limit = '';
if ($all == 'N') {
$limit = ' LIMIT 10';
}
$number_limit = 10;
$number_offset = ($prm['current_page'] - 1) * $number_limit;
$sql = "SELECT COUNT(*) as total
FROM (
SELECT *, IF(IFNULL(FisikTemplateMappingDetailID, 0) > 0, 'Y', 'N') AS status
FROM fisik_template
LEFT JOIN fisik_template_mapping_detail ON FisikTemplateID = FisikTemplateMappingDetailFisikTemplateID
AND FisikTemplateMappingDetailFisikTemplateMappingID = $id AND FisikTemplateMappingDetailIsActive = 'Y'
) x
WHERE
FisikTemplateCode LIKE '%{$code}%' AND
FisikTemplateTitle LIKE '%{$name}%'";
// $total = $this->db->query($sql,$sql_param)->row()->total;
$query = $this->db->query($sql);
//echo $this->db->last_query();
$tot_count = 0;
$tot_page = 0;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
$tot_page = ceil($tot_count / $number_limit);
} else {
$this->sys_error_db("fisik_template count", $this->db);
exit;
}
$sql = "SELECT FisikTemplateID as id,
FisikTemplateJSON as xjson,
FisikTemplateID,
FisikTemplateType,
FisikTemplateCode,
FisikTemplateTableName,
FisikTemplateTitle,
FisikTemplateMappingDetailID,
FisikTemplateMappingDetailFisikTemplateMappingID,
FisikTemplateMappingDetailFisikTemplateID,
FisikTemplateIsActive,
IF(IFNULL(FisikTemplateMappingDetailID, 0) > 0, 'Y', 'N') AS status
FROM fisik_template
LEFT JOIN fisik_template_mapping_detail ON FisikTemplateID = FisikTemplateMappingDetailFisikTemplateID
AND FisikTemplateMappingDetailFisikTemplateMappingID = $id AND FisikTemplateMappingDetailIsActive = 'Y'
WHERE FisikTemplateIsActive = 'Y' AND
FisikTemplateCode LIKE '%{$code}%' AND
FisikTemplateTitle LIKE '%{$name}%'
GROUP BY FisikTemplateID
ORDER BY FisikTemplateCode ASC
limit $number_limit offset $number_offset";
$query = $this->db->query($sql);
//echo $this->db->last_query();
if ($query) {
$rows = $query->result_array();
foreach ($rows as $key => $value) {
$rows[$key]['xjson'] = json_decode($value['xjson']);
}
} else {
$this->sys_error_db("fisik_template select");
exit;
}
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function saveaddeditfisikdetail()
{
try {
//# cek token valid
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$mappingdetailid = $prm['FisikTemplateMappingDetailID'];
$templatemappingID = $prm['templatemappingID'];
$templateID = $prm['FisikTemplateID'];
$status = $prm['status'];
$userid = $this->sys_user["M_UserID"];
if ($status == 'Y') {
$sql = "INSERT INTO fisik_template_mapping_detail(
FisikTemplateMappingDetailFisikTemplateMappingID,
FisikTemplateMappingDetailFisikTemplateID,
FisikTemplateMappingDetailCreated,
FisikTemplateMappingDetailCreatedUserID,
FisikTemplateMappingDetailLastUpdated) VALUES(?,?,NOW(),?,NOW())";
$query = $this->db->query(
$sql,
array(
$templatemappingID,
$templateID,
$userid
)
);
if (!$query) {
$this->sys_error_db("fisik_template_mapping_detail insert", $this->db);
exit;
}
$last_id = $this->db->insert_id();
$result = array("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
} else {
$sql = "UPDATE fisik_template_mapping_detail SET
FisikTemplateMappingDetailIsActive = 'N',
FisikTemplateMappingDetailLastUpdated = NOW(),
FisikTemplateMappingDetailLastUpdatedUserID = ?
WHERE FisikTemplateMappingDetailID = ?";
$query = $this->db->query(
$sql,
array(
$userid,
$mappingdetailid,
)
);
if (!$query) {
$this->sys_error_db("fisik_template_mapping_detail insert", $this->db);
exit;
}
$last_id = $this->db->insert_id();
$result = array("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
}
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function lookupuserbyname()
{
try {
//# cek token valid
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$groupname = $prm['groupname'];
$filter = '';
if (isset($sexid)) {
$filter .= "AND ($sexid = 0 or ($sexid > 0 and Nat_SexID = $sexid)) ";
}
if (isset($flagid)) {
$filter .= "AND ($flagid = 0 or ($flagid > 0 and Nat_FlagID = $flagid))";
}
$limit = '';
if ($all == 'N') {
$limit = ' LIMIT 10';
}
$number_limit = 10;
$number_offset = ($prm['current_page'] - 1) * $number_limit;
$sql = "select COUNT(*) as total
FROM(SELECT *
from m_usergroup
WHERE
M_UserGroupIsActive = 'Y' AND
M_UserGroupName like '%{$groupname}%'
$filter GROUP BY M_UserGroupID) a";
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
$query = $this->db_onedev->query($sql);
//echo $this->db_onedev->last_query();
$tot_count = 0;
$tot_page = 0;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
$tot_page = ceil($tot_count / $number_limit);
} else {
$this->sys_error_db("m_usergroup count", $this->db_onedev);
exit;
}
$sql = "SELECT m_usergroup.*,
M_UserGroupID as id,
M_UserGroupID,
M_UserGroupName
FROM m_usergroup
WHERE
M_UserGroupIsActive = 'Y' AND
M_UserGroupName like '%{$groupname}%'
$filter
GROUP BY M_UserGroupID
ORDER BY M_UserGroupName ASC
limit $number_limit offset $number_offset";
$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_usergroup select");
exit;
}
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function lookupreportbyid()
{
try {
//# cek token valid
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$reportgroup = $prm['reportgroup'];
$reportcode = $prm['reportcode'];
$reportname = $prm['reportname'];
$status = $prm['status'];
$all = $prm['all'];
$filter = '';
if ($status != 'A') {
$filter .= "AND status = '{$status}' ";
} else {
$filter .= "";
}
$limit = '';
if ($all == 'N') {
$limit = ' LIMIT 10';
}
$number_limit = 10;
$number_offset = ($prm['current_page'] - 1) * $number_limit;
$sql = "select COUNT(*) as total
FROM(SELECT *, IF(IFNULL(UserGroupReportID,0) > 0 , 'Y', 'N') as status
from r_report
LEFT JOIN usergroup_report ON R_ReportID = UserGroupReportR_ReportID AND UserGroupReportM_UserGroupID = $id AND UserGroupReportIsActive = 'Y'
LEFT JOIN m_usergroup ON UserGroupReportM_UserGroupID = M_UserGroupID AND M_UserGroupIsActive = 'Y'
LEFT JOIN r_reportgroup ON R_ReportR_ReportGroupID = R_ReportGroupID
WHERE
R_ReportIsActive = 'Y') a
WHERE
R_ReportGroupName like '%{$reportgroup}%' AND
R_ReportCode like '%{$reportcode}%' AND
R_ReportName like '%{$reportname}%' $filter";
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
$query = $this->db_onedev->query($sql);
//echo $this->db_onedev->last_query();
$tot_count = 0;
$tot_page = 0;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
$tot_page = ceil($tot_count / $number_limit);
} else {
$this->sys_error_db("r_report count", $this->db_onedev);
exit;
}
$sql = "SELECT * FROM(select R_ReportID as id,
R_ReportID,
R_ReportCode,
R_ReportName,
R_ReportGroupName,
UserGroupReportID,
UserGroupReportM_UserGroupID,
UserGroupReportR_ReportID,
IF(IFNULL(UserGroupReportID,0) > 0 , 'Y', 'N') as status
from r_report
LEFT JOIN usergroup_report ON R_ReportID = UserGroupReportR_ReportID AND UserGroupReportM_UserGroupID = $id AND UserGroupReportIsActive = 'Y'
LEFT JOIN m_usergroup ON UserGroupReportM_UserGroupID = M_UserGroupID AND M_UserGroupIsActive = 'Y'
LEFT JOIN r_reportgroup ON R_ReportR_ReportGroupID = R_ReportGroupID
WHERE
R_ReportIsActive = 'Y') a
WHERE
R_ReportGroupName like '%{$reportgroup}%' AND
R_ReportCode like '%{$reportcode}%' AND
R_ReportName like '%{$reportname}%' $filter
GROUP BY R_ReportID
ORDER BY R_ReportGroupName ASC, R_ReportName ASC
limit $number_limit offset $number_offset";
$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("r_report select");
exit;
}
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function getsexreg()
{
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$rows = [];
$query = "
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
UNION
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
UNION
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
";
//echo $query;
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
$result = array(
"total" => count($rows),
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
function getstatus()
{
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$rows = [];
$query = "
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
UNION
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
UNION
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
";
//echo $query;
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
$result = array(
"total" => count($rows),
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
public function addnewreport()
{
try {
//# cek token valid
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$userid = $prm['userid'];
$reportcode = $prm['reportcode'];
$reportname = $prm['reportname'];
$userid = $this->sys_user["M_UserID"];
$sql = "insert into r_report(
R_ReportCode,
R_ReportName,
R_ReportUserID,
R_ReportCreated,
R_ReportLastUpdated
)
values(?,?,?,now(),now())";
$query = $this->db_onedev->query(
$sql,
array(
$reportcode,
$reportname,
$userid
)
);
if (!$query) {
$this->sys_error_db("m_usergroup insert", $this->db_onedev);
exit;
}
$last_id = $this->db_onedev->insert_id();
$result = array("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function saveaddeditreport()
{
try {
//# cek token valid
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$usergroupid = $prm['userid'];
$reportid = $prm['R_ReportID'];
$reportuserid = $prm['UserGroupReportID'];
$status = $prm['status'];
$userid = $this->sys_user["M_UserID"];
if ($status == 'Y') {
$sql = "insert into usergroup_report(
UserGroupReportM_UserGroupID,
UserGroupReportR_ReportID,
UserGroupUserID,
UserGroupReportCreated,
UserGroupReportLastUpdated
)
values(?,?,?,now(),now())";
$query = $this->db_onedev->query(
$sql,
array(
$usergroupid,
$reportid,
$userid
)
);
if (!$query) {
$this->sys_error_db("usergroup_report insert", $this->db_onedev);
exit;
}
$last_id = $this->db_onedev->insert_id();
$result = array("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
} else {
$sql = "UPDATE usergroup_report SET
UserGroupReportIsActive = 'N',
UserGroupUserID = ?,
UserGroupReportCreated = now(),
UserGroupReportLastUpdated = now()
WHERE UserGroupReportID = ?";
$query = $this->db_onedev->query(
$sql,
array(
$userid,
$reportuserid
)
);
if (!$query) {
$this->sys_error_db("usergroup_report insert", $this->db_onedev);
exit;
}
$last_id = $this->db_onedev->insert_id();
$result = array("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
}
} catch (Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
function saveallreport()
{
if (!$this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$details = $prm['details'];
$userid = $this->sys_user["M_UserID"];
foreach ($details as $k => $v) {
$query = "UPDATE usergroup_report SET
UserGroupReportM_UserGroupID = '{$v['UserGroupReportM_UserGroupID']}',
UserGroupReportAdviceIna = '{$v['UserGroupReportAdviceIna']}',
UserGroupReportAdviceEng = '{$v['UserGroupReportAdviceEng']}',
UserGroupReportUserID = {$userid},
UserGroupReportCreated = now(),
UserGroupReportLastUpdated = now()
WHERE UserGroupReportID = {$v['UserGroupReportID']}";
//echo $query;
$action = $this->db_onedev->query($query);
}
if ($action) {
$result = array(
"total" => 1,
"records" => array(),
);
$this->sys_ok($result);
exit;
} else {
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
exit;
}
}
public function deleteuser()
{
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 nat_methode SET
Nat_MethodeIsActive = 'N'
WHERE
Nat_MethodeID = ?
";
$query = $this->db_onedev->query(
$sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("nat_methode delete");
exit;
}
$sql = "update m_usergroup SET
M_UserGroupIsActive = 'N'
WHERE
M_UserGroupNat_MethodeID = ?
";
$query = $this->db_onedev->query(
$sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("m_usergroup 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 deletereport()
{
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_usergroup SET
M_UserGroupIsActive = 'N'
WHERE
M_UserGroupID = ?
";
$query = $this->db_onedev->query(
$sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("m_usergroup 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 searchuser()
{
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 nat_methode
WHERE
Nat_MethodeName like ?
AND Nat_MethodeIsActive = '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("nat_methode count", $this->db_onedev);
exit;
}
$sql = "
SELECT Nat_MethodeID, Nat_MethodeName
FROM nat_methode
WHERE
Nat_MethodeName like ?
AND Nat_MethodeIsActive = 'Y'
ORDER BY Nat_MethodeName 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("nat_methode rows", $this->db_onedev);
exit;
}
}
function searchuserbyname()
{
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 nat_methode
WHERE
Nat_MethodeName like ?
AND Nat_MethodeIsActive = '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("nat_methode count", $this->db_onedev);
exit;
}
$sql = "
SELECT Nat_MethodeID, Nat_MethodeName
FROM nat_methode
WHERE
Nat_MethodeName like ?
AND Nat_MethodeIsActive = 'Y'
ORDER BY Nat_MethodeName 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("nat_methode rows", $this->db_onedev);
exit;
}
}
function searchtest()
{
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 t_test
WHERE
T_TestName like ?
AND T_TestIsActive = 'Y' AND T_TestIsResult = '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("t_test count", $this->db_onedev);
exit;
}
$sql = "
SELECT *
FROM t_test
WHERE
T_TestName like ?
AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'
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("t_test rows", $this->db_onedev);
exit;
}
}
}