573 lines
21 KiB
PHP
573 lines
21 KiB
PHP
<?php
|
|
class Uploader extends MY_Controller
|
|
{
|
|
var $target;
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->target =
|
|
"http://devone.aplikasi.web.id/one-api/mcu_company/R_uploader";
|
|
}
|
|
function get_upload_mou()
|
|
{
|
|
//Hardcode 1st
|
|
//2277,2278,2279,2613
|
|
list($branchID, $branchCode) = $this->get_branch();
|
|
$sql = "select M_MouID
|
|
from m_mou where M_MouM_CompanyID in (7727,7728) and M_MouIsActive = 'Y'";
|
|
$resp = $this->get_rows($sql);
|
|
if ($resp["status"] == -1) {
|
|
$this->error_reply_gz($resp["message"]);
|
|
}
|
|
$data = json_encode(["status"=> "OK", "data" => $resp["data"]]);
|
|
|
|
$this->reply_gz($data);
|
|
}
|
|
function mou_order($mouID)
|
|
{
|
|
list($branchID, $branchCode) = $this->get_branch();
|
|
// get order | pasien
|
|
$sql = "select T_OrderHeaderID,T_OrderHeaderDate,T_OrderHeaderLabNumber,T_OrderHeaderLabNumberExt,
|
|
T_OrderHeaderLastUpdated, max(ifnull(T_OrderDetailValDate,'1971-01-01 00:01:01')) LastValidationDate,
|
|
max(ifnull(T_OrderDetailVerDate,'1971-01-01 00:01:01')) LastVerifDate,
|
|
$branchID M_BranchID, '$branchCode' M_BranchCode, T_OrderHeaderM_PatientID,
|
|
JSON_UNQUOTE( JSON_EXTRACT(fn_get_patient_atribute(T_OrderHeaderM_PatientID),'$.patient_fullname')) FullName,
|
|
JSON_UNQUOTE( JSON_EXTRACT(fn_get_patient_atribute(T_OrderHeaderM_PatientID),'$.M_PatientName')) M_PatientName,
|
|
T_OrderHeaderM_CompanyID M_CompanyID, M_CompanyNumber,
|
|
T_OrderHeaderM_MouID M_MouID
|
|
from
|
|
t_orderheader
|
|
join t_orderheaderaddon on
|
|
T_OrderHeaderM_MouID = ?
|
|
and T_OrderHeaderID = T_OrderHeaderAddOnT_OrderHeaderID
|
|
and T_OrderHeaderIsActive = 'Y' and T_OrderHeaderAddOnValidationDone = 'Y'
|
|
join m_company on M_CompanyID = T_OrderHeaderM_CompanyID
|
|
join t_orderdetail
|
|
on T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
|
group by T_OrderHeaderID";
|
|
$resp = $this->get_rows($sql, [$mouID]);
|
|
if ($resp["status"] == -1) {
|
|
$this->error_reply_gz(
|
|
"Err Get Order for MOU ID : $mouID | " . $resp["message"]
|
|
);
|
|
exit();
|
|
}
|
|
$orders = $resp["data"];
|
|
echo $this->reply_gz(json_encode(["status" => "OK", "data" => $orders]));
|
|
}
|
|
|
|
//Get Detail Mou
|
|
function mou_detail($mouID) {
|
|
list($branchID, $branchCode) = $this->get_branch();
|
|
$sql = "select $branchID Corp_M_BranchID , '$branchCode' Corp_M_BranchCode,
|
|
M_MouID, M_MouName, M_MouNote , M_CompanyNumber M_MouM_CompanyNumber,
|
|
M_MouM_CompanyID , M_MouRefNumber ,
|
|
M_MouNumber , M_MouStartDate , M_MouEndDate , M_MouBase,
|
|
M_MouM_OmzetTypeID , M_MouIsReleased , M_MouReleaseDate ,
|
|
M_MouReleaseUserID , M_MouCreated , M_MouLastUpdated ,
|
|
M_MouIsActive, M_MouUserID
|
|
from m_mou
|
|
join m_company on M_MouM_CompanyID = M_CompanyID
|
|
where M_MouID = ?";
|
|
$resp = $this->get_row($sql,[$mouID]);
|
|
if($resp["status"] == -1) {
|
|
$this->error_reply_gz($resp["message"]);
|
|
}
|
|
if($resp["status"] == 0) {
|
|
$this->error_reply_gz("Mou ID $mouID not found.");
|
|
}
|
|
$result = $resp["data"];
|
|
$this->reply_gz(
|
|
json_encode(
|
|
[ "status"=>"OK",
|
|
"data" => $resp["data"]
|
|
])
|
|
);
|
|
}
|
|
function reply_gz($resp) {
|
|
echo gzcompress($resp);
|
|
exit;
|
|
}
|
|
function get_branch()
|
|
{
|
|
$sql =
|
|
"select M_BranchID,M_BranchCode from m_branch where M_BranchIsActive='Y' and M_BranchIsDefault ='Y'";
|
|
$resp = $this->get_row($sql);
|
|
if ($resp["status"] != 1) {
|
|
echo json_encode($resp);
|
|
exit();
|
|
}
|
|
return [$resp["data"]["M_BranchID"], $resp["data"]["M_BranchCode"]];
|
|
}
|
|
function log($msg)
|
|
{
|
|
$dt = date("Y-m-d H:i:s");
|
|
echo "$dt $msg\n";
|
|
}
|
|
function error_reply_gz($msg)
|
|
{
|
|
echo gzcompress(json_encode(["status" => "ERR", "message" => $msg]));
|
|
}
|
|
function reply($resp,$type = 1) {
|
|
echo json_encode($resp);
|
|
}
|
|
function error_reply($msg)
|
|
{
|
|
echo json_encode(["status" => "ERR", "message" => $msg]);
|
|
}
|
|
function get_mou_param($mouID)
|
|
{
|
|
$sql = "select M_MouM_CompanyID, M_MouStartDate, M_MouEndDate
|
|
from m_mou
|
|
where M_MouID = ?";
|
|
$resp = $this->get_row($sql, [$mouID]);
|
|
if ($resp["status"] == -1) {
|
|
$this->error_reply(
|
|
"Err Get Mou Param from $mouID : " . $resp["message"]
|
|
);
|
|
exit();
|
|
}
|
|
if ($resp["status"] == 0) {
|
|
return [0, "1971-01-01", "1971-01-01"];
|
|
}
|
|
$r = $resp["data"];
|
|
return [
|
|
$r["M_MouM_CompanyID"],
|
|
$r["M_MouStartDate"],
|
|
$r["M_MouEndDate"],
|
|
];
|
|
}
|
|
function getCompanyNumber($companyID) {
|
|
$sql = "select M_CompanyNumber from m_company where M_CompanyID = ?";
|
|
$resp = $this->get_row($sql, [$companyID]);
|
|
if ($resp["status"] == -1) {
|
|
$this->error_reply(
|
|
"Err Get Company from $companyID: " . $resp["message"]
|
|
);
|
|
exit();
|
|
}
|
|
if ($resp["status"] == 0) {
|
|
return "";
|
|
}
|
|
$r = $resp["data"];
|
|
return $r["M_CompanyNumber"];
|
|
}
|
|
//
|
|
function do_global($mouID)
|
|
{
|
|
list($branchID, $branchCode) = $this->get_branch();
|
|
$arr_sp = ["sp_rpt_nl_001_v2", "sp_rpt_nl_002_v2", "sp_rpt_nl_003_v2"];
|
|
list($companyID, $startDate, $endDate) = $this->get_mou_param($mouID);
|
|
$companyNumber = $this->getCompanyNumber($companyID);
|
|
|
|
$result = [];
|
|
for($idx=0;$idx<3; $idx++) {
|
|
$sp = $arr_sp[$idx];
|
|
$key = str_replace("sp_", "", $sp);
|
|
$key = str_replace("_v2", "", $key);
|
|
|
|
$sql = "call {$sp}(?,?,?,?,'admin')";
|
|
$resp = $this->get_sp($sql, [$startDate, $endDate, $companyID, $mouID]);
|
|
if ($resp["status"] == -1) {
|
|
$this->error_reply_gz("Err $sp : " . $resp["message"]);
|
|
exit();
|
|
}
|
|
$xresult = [];
|
|
foreach($resp["data"] as $r) {
|
|
$r["M_CompanyNumber"] = $companyNumber;
|
|
$r["M_BranchID"] = $branchID;
|
|
$r["M_BranchCode"] = $branchCode;
|
|
$xresult[] = $r;
|
|
}
|
|
$result[$key] = $xresult;
|
|
}
|
|
echo $this->reply_gz(json_encode([
|
|
"status" => "OK",
|
|
"branchID" => $branchID,
|
|
"branchCode" => $branchCode,
|
|
"companyID" => $companyID,
|
|
"result" => $result,
|
|
]));
|
|
}
|
|
|
|
function get_resume_id($headerID)
|
|
{
|
|
$sql = "select Mcu_ResumeID from mcu_resume
|
|
where Mcu_ResumeT_OrderHeaderID = ?
|
|
and Mcu_ResumeIsActive = 'Y'
|
|
order by Mcu_ResumeID desc
|
|
limit 0,1";
|
|
$resp = $this->get_row($sql, [$headerID]);
|
|
if ($resp["status"] == -1) {
|
|
$this->error_reply(
|
|
"Err Get ResumeID from T_OrderHeaderID $headerID : " .
|
|
$resp["message"]
|
|
);
|
|
exit();
|
|
}
|
|
if ($resp["status"] == 0) {
|
|
return 0;
|
|
}
|
|
return $resp["data"]["Mcu_ResumeID"];
|
|
}
|
|
function json_get_so_id($headerID,$so="") {
|
|
echo json_encode($this->get_so_result_entry_id($headerID,$so));
|
|
}
|
|
function get_so_result_entry_id($headerID, $so = "")
|
|
{
|
|
$sql = "select So_ResultEntryID
|
|
from so_resultentry
|
|
where So_ResultEntryT_OrderHeaderID = ?
|
|
and So_ResultentryIsActive = 'Y'
|
|
order by So_ResultEntryID desc
|
|
limit 0,1";
|
|
if ($so == "elmd") {
|
|
$sql = "select So_ResultEntryID
|
|
from so_resultentry
|
|
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
|
join t_test on T_OrderDetailT_TestID = T_TestID
|
|
and T_TestNat_GroupID = 2
|
|
where So_ResultEntryT_OrderHeaderID = ?
|
|
and So_ResultentryIsActive = 'Y'
|
|
order by So_ResultEntryID desc
|
|
limit 0,1";
|
|
}
|
|
if ($so == "usg") {
|
|
$sql = "select So_ResultEntryID
|
|
from so_resultentry
|
|
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
|
join t_test on T_OrderDetailT_TestID = T_TestID
|
|
and T_TestNat_GroupID = 3
|
|
and T_TestNat_SubGroupID = 22
|
|
where So_ResultEntryT_OrderHeaderID = ?
|
|
and So_ResultentryIsActive = 'Y'
|
|
order by So_ResultEntryID desc
|
|
limit 0,1";
|
|
}
|
|
if ($so == "manthoux") {
|
|
$sql = "select So_ResultEntryID
|
|
from so_resultentry
|
|
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
|
join t_test on T_OrderDetailT_TestID = T_TestID
|
|
and T_TestNat_GroupID = 1
|
|
and T_TestNat_SubGroupID = 10
|
|
where So_ResultEntryT_OrderHeaderID = ?
|
|
and So_ResultentryIsActive = 'Y'
|
|
order by So_ResultEntryID desc
|
|
limit 0,1";
|
|
}
|
|
if ($so == "manthoux") {
|
|
$sql = "select So_ResultEntryID
|
|
from so_resultentry
|
|
join t_orderdetail on T_OrderDetailID = So_ResultEntryT_OrderDetailID
|
|
join t_test on T_OrderDetailT_TestID = T_TestID
|
|
and T_TestNat_GroupID = 4
|
|
and T_TestNat_SubGroupID = 24
|
|
where So_ResultEntryT_OrderHeaderID = ?
|
|
and So_ResultentryIsActive = 'Y'
|
|
order by So_ResultEntryID desc
|
|
limit 0,1";
|
|
}
|
|
$resp = $this->get_row($sql, [$headerID]);
|
|
if ($resp["status"] == -1) {
|
|
$this->error_reply(
|
|
"Err Get ResumeID from T_OrderHeaderID $headerID : " .
|
|
$resp["message"]
|
|
);
|
|
exit();
|
|
}
|
|
if ($resp["status"] == 0) {
|
|
return 0;
|
|
}
|
|
return $resp["data"]["So_ResultEntryID"];
|
|
}
|
|
|
|
// Hasil lab per individu
|
|
// Hasil Non Lab per individu
|
|
// Hasil Resume Individu
|
|
// by T_OrderHeaderID
|
|
function individu($headerID)
|
|
{
|
|
$arr_sp = [
|
|
"sp_rpt_t_hasil2",
|
|
"sp_rpt_t_hasil_eng",
|
|
"sp_rpt_t_hasil_sampling",
|
|
"sp_rpt_t_hasil_sampling_eng",
|
|
"sp_rpt_t_hasil_so_xray",
|
|
"sp_rpt_t_hasil_so_usg",
|
|
"sp_rpt_t_hasil_so_elmd",
|
|
"sp_rpt_t_hasil_so_manthoux",
|
|
"sp_rpt_t_hasil_so_manthoux_sampling",
|
|
"sp_rpt_t_hasil_so_layanan",
|
|
//"sp_rpt_t_hasil_so_bdm",
|
|
"sp_rpt_t_hasil_so",
|
|
"sp_rpt_mcu_resume_cp_r",
|
|
"sp_rpt_mcu_resume_cp_r_eng",
|
|
"sp_dummy_fisik"
|
|
];
|
|
$result = [];
|
|
foreach ($arr_sp as $sp) {
|
|
$key = str_replace("sp_", "", $sp);
|
|
$sql = "call {$sp}(?,'admin')";
|
|
|
|
if ($sp == "sp_rpt_mcu_resume_cp_r") {
|
|
$sql = "call {$sp}(?,1,'admin')";
|
|
$resumeID = $this->get_resume_id($headerID);
|
|
$resp = $this->get_sp($sql, [$resumeID]);
|
|
|
|
} elseif ($sp == "sp_rpt_mcu_resume_cp_r_eng") {
|
|
$sql = "call {$sp}(?,2,'admin')";
|
|
$resumeID = $this->get_resume_id($headerID);
|
|
$resp = $this->get_sp($sql, [$resumeID]);
|
|
} elseif ($sp == "sp_rpt_t_hasil_so") {
|
|
$sql = "call {$sp}(?,2,'admin')";
|
|
$resultEntryID = $this->get_so_result_entry_id($headerID);
|
|
$resp = $this->get_sp($sql, [$resultEntryID]);
|
|
$new_data = [];
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 2;
|
|
$new_data[] = $d;
|
|
}
|
|
$sql = "call {$sp}(?,1,'admin')";
|
|
$resp = $this->get_sp($sql, [$resultEntryID]);
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 1;
|
|
$new_data[] = $d;
|
|
}
|
|
$resp["data"] = $new_data;
|
|
} elseif ($sp == "sp_rpt_t_hasil_bdm") {
|
|
$sql = "call {$sp}(?,2,'admin')";
|
|
$resp = $this->get_sp($sql, [$headerID]);
|
|
$new_data = [];
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 2;
|
|
$new_data[] = $d;
|
|
}
|
|
$sql = "call {$sp}(?,1,'admin')";
|
|
$resp = $this->get_sp($sql, [$headerID]);
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 1;
|
|
$new_data[] = $d;
|
|
}
|
|
$resp["data"] = $new_data;
|
|
} elseif ($sp == "sp_rpt_t_hasil_so_elmd") {
|
|
$sql = "call {$sp}(?,2,'admin')";
|
|
$resultEntryID = $this->get_so_result_entry_id(
|
|
$headerID,
|
|
"elmd"
|
|
);
|
|
|
|
$resp = $this->get_sp($sql, [$resultEntryID]);
|
|
$new_data = [];
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 2;
|
|
$new_data[] = $d;
|
|
}
|
|
$sql = "call {$sp}(?,1,'admin')";
|
|
$resp = $this->get_sp($sql, [$resultEntryID]);
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 1;
|
|
$new_data[] = $d;
|
|
}
|
|
$resp["data"] = $new_data;
|
|
} elseif ($sp == "sp_rpt_t_hasil_so_layanan") {
|
|
$sql = "call {$sp}(?,2,'admin')";
|
|
$resultEntryID = $this->get_so_result_entry_id(
|
|
$headerID,
|
|
"layanan"
|
|
);
|
|
$resp = $this->get_sp($sql, [$resultEntryID]);
|
|
$new_data = [];
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 2;
|
|
$new_data[] = $d;
|
|
}
|
|
$sql = "call {$sp}(?,1,'admin')";
|
|
$resp = $this->get_sp($sql, [$resultEntryID]);
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 1;
|
|
$new_data[] = $d;
|
|
}
|
|
$resp["data"] = $new_data;
|
|
|
|
} elseif ($sp == "sp_rpt_t_hasil_so_manthoux") {
|
|
$sql = "call {$sp}(?,2,'admin')";
|
|
$resultEntryID = $this->get_so_result_entry_id(
|
|
$headerID,
|
|
"manthoux"
|
|
);
|
|
$resp = $this->get_sp($sql, [$resultEntryID]);
|
|
$new_data = [];
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 2;
|
|
$new_data[] = $d;
|
|
}
|
|
$sql = "call {$sp}(?,1,'admin')";
|
|
$resp = $this->get_sp($sql, [$resultEntryID]);
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 1;
|
|
$new_data[] = $d;
|
|
}
|
|
$resp["data"] = $new_data;
|
|
} elseif ($sp == "sp_rpt_t_hasil_so_manthoux_sampling") {
|
|
$sql = "call {$sp}(?,2,'admin')";
|
|
$resultEntryID = $this->get_so_result_entry_id(
|
|
$headerID,
|
|
"manthoux"
|
|
);
|
|
$resp = $this->get_sp($sql, [$resultEntryID]);
|
|
$new_data = [];
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 2;
|
|
$new_data[] = $d;
|
|
}
|
|
$sql = "call {$sp}(?,1,'admin')";
|
|
$resp = $this->get_sp($sql, [$resultEntryID]);
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 1;
|
|
$new_data[] = $d;
|
|
}
|
|
$resp["data"] = $new_data;
|
|
} elseif ($sp == "sp_rpt_t_hasil_so_usg") {
|
|
$sql = "call {$sp}(?,2,'admin')";
|
|
$resultEntryID = $this->get_so_result_entry_id(
|
|
$headerID,
|
|
"usg"
|
|
);
|
|
$resp = $this->get_sp($sql, [$resultEntryID]);
|
|
$new_data = [];
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 2;
|
|
$new_data[] = $d;
|
|
}
|
|
$sql = "call {$sp}(?,1,'admin')";
|
|
$resp = $this->get_sp($sql, [$resultEntryID]);
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 1;
|
|
$new_data[] = $d;
|
|
}
|
|
$resp["data"] = $new_data;
|
|
} elseif ($sp == "sp_rpt_t_hasil_so_xray") {
|
|
$sql = "call {$sp}(?,2,'admin')";
|
|
$resp = $this->get_sp($sql, [$headerID]);
|
|
$new_data = [];
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 2;
|
|
$new_data[] = $d;
|
|
}
|
|
$sql = "call {$sp}(?,1,'admin')";
|
|
$resp = $this->get_sp($sql, [$headerID]);
|
|
foreach ($resp["data"] as $d) {
|
|
$d["M_LangID"] = 1;
|
|
$new_data[] = $d;
|
|
}
|
|
$resp["data"] = $new_data;
|
|
} elseif ($sp == "sp_dummy_fisik") {
|
|
$arr_sub_url = ["pribadi", "keluhan_saat_ini_new", "riwayat_phobia",
|
|
"riwayat_obat","riwayat_penyakit","riwayat_hidup","riwayat_keluarga",
|
|
"tanda_vital","status_gizi",
|
|
"keadaan_umum","mulut","gigi","visus",
|
|
"kepala_wajah","mata","telinga","thorax",
|
|
"paru","jantung","integumen","sistem",
|
|
"anggota","genitourinaria","perut",
|
|
"leher","hidung","persepsi_warna"];
|
|
$resultEntryID = $this->get_so_result_entry_id(
|
|
$headerID,
|
|
"fisik"
|
|
);
|
|
$new_data = ["fisik" => [], "riwayat" =>[]];
|
|
if ($resultEntryID > 0 ) {
|
|
foreach($arr_sub_url as $s_url) {
|
|
$new_data["fisik"][$s_url] = $this->get_fisik($s_url,$resultEntryID,"fisik");
|
|
$new_data["riwayat"][$s_url] = $this->get_fisik($s_url,$resultEntryID,"riwayat");
|
|
}
|
|
}
|
|
$resp= ["data" => $new_data , "status" => 0 ];
|
|
|
|
} else {
|
|
$resp = $this->get_sp($sql, [$headerID]);
|
|
}
|
|
if ($resp["status"] == -1) {
|
|
$this->error_reply_gz("Err $sp : " . $resp["message"]);
|
|
exit();
|
|
}
|
|
$result[$key] = $resp["data"];
|
|
}
|
|
echo $this->reply_gz( json_encode(["status" => "OK", "result" => $result]));
|
|
}
|
|
function get_fisik($param,$result_entry_id,$type,$lang_id=1) {
|
|
$url = "http://localhost/one-api/v1/report/fisik/$param/$result_entry_id/$lang_id/$type";
|
|
$resp = $this->get($url);
|
|
return json_decode($resp,true);
|
|
}
|
|
function get($url, $timeout = 60, $c_timeout = 5)
|
|
{
|
|
$ch = curl_init($url);
|
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $c_timeout);
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
$result = curl_exec($ch);
|
|
$err_msg = curl_error($ch);
|
|
if ($err_msg != "") {
|
|
return json_encode(array("status" => "ERR", "message" => $err_msg));
|
|
}
|
|
return $result;
|
|
}
|
|
function get_sp($sql, $param = false)
|
|
{
|
|
$resp = $this->get_rows($sql, $param);
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
return $resp;
|
|
}
|
|
function get_mou($companyID)
|
|
{
|
|
$sql = "select M_MouID,M_MouName, M_MouNumber
|
|
from m_mou
|
|
where M_MouIsActive = 'Y' and M_MouM_CompanyID = ?";
|
|
$resp = $this->get_rows($sql, [$companyID]);
|
|
if ($resp["status"] == -1) {
|
|
$this->error_reply("Error Get MOU by Company $companyID");
|
|
exit();
|
|
}
|
|
echo json_encode([
|
|
"status" => "OK",
|
|
"data" => $resp["data"],
|
|
]);
|
|
}
|
|
function step_debug($rows)
|
|
{
|
|
print_r($rows);
|
|
exit();
|
|
}
|
|
function get_rows($sql, $param = false)
|
|
{
|
|
if ($param) {
|
|
$qry = $this->db->query($sql, $param);
|
|
} else {
|
|
$qry = $this->db->query($sql);
|
|
}
|
|
if (!$qry) {
|
|
return [
|
|
"status" => -1,
|
|
"message" =>
|
|
$this->db->last_query() .
|
|
"|" .
|
|
$this->db->error()["message"],
|
|
];
|
|
}
|
|
return ["status" => 0, "data" => $qry->result_array()];
|
|
}
|
|
function get_row($sql, $param = false)
|
|
{
|
|
$resp = $this->get_rows($sql, $param);
|
|
if ($resp["status"] == -1) {
|
|
return $resp;
|
|
}
|
|
if (count($resp["data"]) == 0) {
|
|
return ["status" => 0, "message" => "Not found."];
|
|
}
|
|
return ["status" => 1, "data" => $resp["data"][0]];
|
|
}
|
|
}
|
|
?>
|