Initial import
This commit is contained in:
213
one-api/application/controllers/v1/clinic/fo/Area.php
Normal file
213
one-api/application/controllers/v1/clinic/fo/Area.php
Normal file
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
class Area extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "AREA API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search_province()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$src = "%";
|
||||
|
||||
if ($prm['search'])
|
||||
$src = "%{$prm['search']}%";
|
||||
|
||||
$max_rst = 40;
|
||||
$tot_count =0;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_province
|
||||
where M_ProvinceName LIKE ?
|
||||
and M_ProvinceIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql, array($src));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_province count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_ProvinceID, M_ProvinceName, IF(Conf_DefaultID IS NULL, 'N', 'Y') is_default
|
||||
from m_province
|
||||
left join conf_default on conf_defaultisactive = 'Y' and conf_defaultm_provinceid = M_ProvinceID
|
||||
where M_ProvinceName LIKE ?
|
||||
and M_ProvinceIsActive = 'Y'
|
||||
order by M_ProvinceName
|
||||
limit 0, {$max_rst}
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($src));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_province rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_city()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$src = "%";
|
||||
|
||||
if ($prm['search'])
|
||||
$src = "%{$prm['search']}%";
|
||||
|
||||
$max_rst = 40;
|
||||
$tot_count =0;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_city
|
||||
where M_CityName LIKE ?
|
||||
and M_CityIsActive = 'Y'
|
||||
and M_CityM_ProvinceID = ?";
|
||||
$query = $this->db_regional->query($sql, array($src, $prm['province_id']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_CityID, M_CityName, IF(Conf_DefaultID IS NULL, 'N', 'Y') is_default
|
||||
from m_city
|
||||
left join conf_default on conf_defaultisactive = 'Y' and conf_defaultm_cityid = M_CityID
|
||||
where M_CityName LIKE ?
|
||||
and M_CityIsActive = 'Y'
|
||||
and M_CityM_ProvinceID = ?
|
||||
order by M_CityName
|
||||
limit 0, {$max_rst}
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($src, $prm['province_id']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_district()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$src = "%";
|
||||
|
||||
if ($prm['search'])
|
||||
$src = "%{$prm['search']}%";
|
||||
|
||||
$max_rst = 40;
|
||||
$tot_count =0;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_district
|
||||
where M_DistrictName LIKE ?
|
||||
and M_DistrictIsActive = 'Y'
|
||||
and M_DistrictM_CityID = ?";
|
||||
$query = $this->db_regional->query($sql, array($src, $prm['city_id']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_DistrictID, M_DistrictName, IF(Conf_DefaultID IS NULL, 'N', 'Y') is_default
|
||||
from m_district
|
||||
left join conf_default on conf_defaultisactive = 'Y' and conf_defaultm_districtid = M_DistrictID
|
||||
where M_DistrictName LIKE ?
|
||||
and M_DistrictIsActive = 'Y'
|
||||
and M_DistrictM_CityID = ?
|
||||
order by M_DistrictName
|
||||
limit 0, {$max_rst}
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($src, $prm['city_id']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_kelurahan()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$src = "%";
|
||||
|
||||
if ($prm['search'])
|
||||
$src = "%{$prm['search']}%";
|
||||
|
||||
$max_rst = 40;
|
||||
$tot_count =0;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_kelurahan
|
||||
where M_KelurahanName LIKE ?
|
||||
and M_KelurahanIsActive = 'Y'
|
||||
and M_KelurahanM_DistrictID = ?";
|
||||
$query = $this->db_regional->query($sql, array($src, $prm['district_id']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_kelurahan count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_KelurahanID, M_KelurahanName, IF(Conf_DefaultID IS NULL, 'N', 'Y') is_default
|
||||
from m_kelurahan
|
||||
left join conf_default on conf_defaultisactive = 'Y' and conf_defaultm_kelurahanid = M_KelurahanID
|
||||
where M_KelurahanName LIKE ?
|
||||
and M_KelurahanIsActive = 'Y'
|
||||
and M_KelurahanM_DistrictID = ?
|
||||
order by M_KelurahanName
|
||||
limit 0, {$max_rst}
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($src, $prm['district_id']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_kelurahan rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
1332
one-api/application/controllers/v1/db
Normal file
1332
one-api/application/controllers/v1/db
Normal file
File diff suppressed because it is too large
Load Diff
253
one-api/application/controllers/v1/doctor_monitoring/Doctor.php
Normal file
253
one-api/application/controllers/v1/doctor_monitoring/Doctor.php
Normal file
@@ -0,0 +1,253 @@
|
||||
<?php
|
||||
class Doctor extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "DOCTOR MONITORING API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$name = $prm["name"];
|
||||
$date = $prm["date"];
|
||||
$staffid = $prm["staffid"];
|
||||
$typeid = $prm["typeid"];
|
||||
$statusid = $prm["statusid"];
|
||||
$branchid = $prm["branchid"];
|
||||
$filter_staff = '';
|
||||
if(intval($staffid) > 0)
|
||||
$filter_staff = " AND M_UserM_StaffID = {$staffid}";
|
||||
$filter_branch = '';
|
||||
if(intval($branchid) > 0)
|
||||
$filter_branch = " AND M_BranchID = {$branchid}";
|
||||
|
||||
$filter_status = "WHERE DoctorToBranchStatus = '{$statusid}'";
|
||||
$filter_type = '';
|
||||
if($typeid !== 'S'){
|
||||
$filter_type = "AND DoctorToBranchType = '{$typeid}'";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM (SELECT doctortobranch.*,
|
||||
DoctorToBranchID as id,
|
||||
CASE
|
||||
WHEN DoctorToBranchType = 'D' THEN 'Dokter Baru'
|
||||
WHEN DoctorToBranchType = 'UD' THEN 'Update Dokter'
|
||||
WHEN DoctorToBranchType = 'A' THEN 'Alamat Baru'
|
||||
ELSE 'Update Alamat'
|
||||
END as tipe,
|
||||
DATE_FORMAT(DoctorToBranchCreated,'%d-%m-%Y %T') as doctordate,
|
||||
DoctorToBranchM_DoctorID as doctorid,
|
||||
M_DoctorName as doctorname,
|
||||
'' as doctoraddress,
|
||||
IF(DoctorToBranchStatus = 'N','Pending','Terkirim') as status,
|
||||
DoctorToBranchRetry as pengulangan,
|
||||
M_StaffName as staffname,
|
||||
M_BranchID,
|
||||
M_BranchName as branchname,
|
||||
IF(DoctorToBranchStatus = 'N','Y','N') as chex
|
||||
FROM doctortobranch
|
||||
JOIN m_doctor ON DoctorToBranchM_DoctorID = M_DoctorID
|
||||
JOIN m_user ON DoctorToBranchUserID = M_UserID
|
||||
JOIN m_staff ON M_UserM_StaffID = M_StaffID
|
||||
JOIN m_branch ON DoctorToBranchM_BranchIPAddress = M_BranchIPAddress
|
||||
WHERE (DoctorToBranchType = 'D' OR DoctorToBranchType = 'UD') AND date(DoctorToBranchCreated) = '{$date}'
|
||||
GROUP BY DoctorToBranchID
|
||||
|
||||
UNION
|
||||
SELECT doctortobranch.*,
|
||||
DoctorToBranchID as id,
|
||||
CASE
|
||||
WHEN DoctorToBranchType = 'D' THEN 'Dokter Baru'
|
||||
WHEN DoctorToBranchType = 'UD' THEN 'Update Dokter'
|
||||
WHEN DoctorToBranchType = 'A' THEN 'Alamat Baru'
|
||||
ELSE 'Update Alamat'
|
||||
END as tipe,
|
||||
DATE_FORMAT(DoctorToBranchCreated,'%d-%m-%Y %T') as doctordate,
|
||||
DoctorToBranchM_DoctorID as doctorid,
|
||||
M_DoctorName as doctorname,
|
||||
CONCAT(M_DoctorAddressNote, ' : ',M_DoctorAddressDescription) as doctoraddress,
|
||||
IF(DoctorToBranchStatus = 'N','Pending','Terkirim') as status,
|
||||
DoctorToBranchRetry as pengulangan,
|
||||
M_StaffName as staffname,
|
||||
M_BranchID,
|
||||
M_BranchName as branchname,
|
||||
IF(DoctorToBranchStatus = 'N','Y','N') as chex
|
||||
FROM doctortobranch
|
||||
join m_doctoraddress ON M_DoctorAddressID = DoctorToBranchM_DoctorID
|
||||
JOIN m_doctor ON M_DoctorAddressM_DoctorID = M_DoctorID
|
||||
JOIN m_user ON DoctorToBranchUserID = M_UserID
|
||||
JOIN m_staff ON M_UserM_StaffID = M_StaffID
|
||||
JOIN m_branch ON DoctorToBranchM_BranchIPAddress = M_BranchIPAddress
|
||||
WHERE (DoctorToBranchType = 'A' OR DoctorToBranchType = 'UA') AND date(DoctorToBranchCreated) = '{$date}'
|
||||
GROUP BY DoctorToBranchID) a
|
||||
$filter_status $filter_type $filter_branch
|
||||
ORDER BY DoctorToBranchID DESC
|
||||
";
|
||||
// echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N'){
|
||||
$rows[$k]['chex'] = false;
|
||||
}else{
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function getstationstatus(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$rows['types'] = array(array('id'=>'S','name'=>'Semua'),array('id'=>'D','name'=>'Dokter Baru'),array('id'=>'UD','name'=>'Update Dokter'),array('id'=>'A','name'=>'Alamat Baru'),array('id'=>'UA','name'=>'Update Alamat'));
|
||||
$rows['statuss'] = array(array('id'=>'N','name'=>'Pending'),array('id'=>'Y','name'=>'Terkirim'));
|
||||
$sql = "SELECT 0 as id, 'Semua' as name
|
||||
UNION
|
||||
SELECT M_BranchID as id, M_BranchName as name
|
||||
FROM m_branch
|
||||
WHERE
|
||||
M_BranchIsActive = 'Y'
|
||||
GROUP BY M_BranchID";
|
||||
$rows['branchs'] = $this->db_regional->query($sql)->result_array();
|
||||
$sql = "SELECT 0 as id, 'Semua' as name
|
||||
UNION
|
||||
SELECT M_StaffID as id, M_StaffName as name
|
||||
FROM doctortobranch
|
||||
JOIN m_user ON DoctorToBranchUserID = M_UserID
|
||||
JOIN m_staff ON M_UserM_StaffID = M_StaffID
|
||||
GROUP BY M_StaffID";
|
||||
$rows['staffs'] = $this->db_regional->query($sql)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function doaction(){
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$doctors = $prm["doctors"];
|
||||
foreach($doctors as $idx => $doctor) {
|
||||
$urlxxx = '';
|
||||
if ( $doctor["chex"] == 1 ) {
|
||||
$dt_arr = array();
|
||||
if($doctor['DoctorToBranchType'] == 'D' || $doctor['DoctorToBranchType'] == 'UD'){
|
||||
$sql = "SELECT *
|
||||
FROM m_doctor
|
||||
WHERE
|
||||
M_DoctorID = {$doctor['DoctorToBranchM_DoctorID']}";
|
||||
$vx = $this->db_regional->query($sql)->row_array();
|
||||
$x_arr = array();
|
||||
if($doctor['DoctorToBranchType'] == 'D'){
|
||||
array_push($x_arr,$vx);
|
||||
$urlxxx = 'downloaddoctor';
|
||||
}
|
||||
else{
|
||||
$x_arr = $vx;
|
||||
$urlxxx = 'updatedoctor';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($doctor['DoctorToBranchType'] == 'A' || $doctor['DoctorToBranchType'] == 'UA'){
|
||||
$sql = "SELECT *
|
||||
FROM m_doctoraddress
|
||||
WHERE
|
||||
M_DoctorAddressID = {$doctor['DoctorToBranchM_DoctorID']}";
|
||||
$vx = $this->db_regional->query($sql)->row_array();
|
||||
$x_arr = array();
|
||||
if($doctor['DoctorToBranchType'] == 'A'){
|
||||
array_push($x_arr,$vx);
|
||||
$urlxxx = 'newaddressdoctor';
|
||||
}
|
||||
else{
|
||||
$x_arr = $vx;
|
||||
$urlxxx = 'updateaddressdoctor';
|
||||
}
|
||||
}
|
||||
|
||||
$data = json_encode($x_arr);
|
||||
$md5 = md5($data);
|
||||
$param = array("data" => $data, "md5" => $md5);
|
||||
$jparam = json_encode($param);
|
||||
$url = "http://".$doctor['DoctorToBranchM_BranchIPAddress']."/one-api/tools/marketing/{$urlxxx}/";
|
||||
$j_result = $this->post($url,$jparam);
|
||||
//echo "Result : $j_result";
|
||||
$result = json_decode($j_result,true);
|
||||
//echo $result["query"];
|
||||
if ($result["status"] == "OK") {
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
||||
WHERE
|
||||
DoctorToBranchID = {$doctor['DoctorToBranchID']}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
else{
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
||||
WHERE
|
||||
DoctorToBranchID = {$doctor['DoctorToBranchID']}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = array ("message" => "Resend OK");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 12);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
class Doctorv2 extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "DOCTOR MONITORING API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$name = $prm["name"];
|
||||
$date = $prm["date"];
|
||||
$staffid = $prm["staffid"];
|
||||
$typeid = $prm["typeid"];
|
||||
$statusid = $prm["statusid"];
|
||||
$branchid = $prm["branchid"];
|
||||
$filter_staff = '';
|
||||
if(intval($staffid) > 0)
|
||||
$filter_staff = " AND M_UserM_StaffID = {$staffid}";
|
||||
$filter_branch = '';
|
||||
if(intval($branchid) > 0)
|
||||
$filter_branch = " AND M_BranchID = {$branchid}";
|
||||
|
||||
$filter_status = "WHERE DoctorToBranchStatus = '{$statusid}'";
|
||||
$filter_type = '';
|
||||
if($typeid !== 'S'){
|
||||
$filter_type = "AND DoctorToBranchType = '{$typeid}'";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM (SELECT doctortobranch.*,
|
||||
DoctorToBranchID as id,
|
||||
CASE
|
||||
WHEN DoctorToBranchType = 'D' THEN 'Dokter Baru'
|
||||
WHEN DoctorToBranchType = 'UD' THEN 'Update Dokter'
|
||||
WHEN DoctorToBranchType = 'A' THEN 'Alamat Baru'
|
||||
ELSE 'Update Alamat'
|
||||
END as tipe,
|
||||
DATE_FORMAT(DoctorToBranchCreated,'%d-%m-%Y %T') as doctordate,
|
||||
DoctorToBranchM_DoctorID as doctorid,
|
||||
CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,' ',M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as doctorname,
|
||||
'' as doctoraddress,
|
||||
IF(DoctorToBranchStatus = 'N','Pending','Terkirim') as status,
|
||||
IF(M_DoctorIsMarketingConfirm = 'N','Belum dikonfirmasi','Sudah dikonfirmasi') as konfirmasi,
|
||||
DoctorToBranchRetry as pengulangan,
|
||||
Nat_StaffName as staffname,
|
||||
M_BranchID,
|
||||
M_BranchName as branchname,
|
||||
IF(DoctorToBranchStatus = 'N','Y','N') as chex
|
||||
FROM doctortobranch
|
||||
JOIN m_doctor ON DoctorToBranchM_DoctorID = M_DoctorID
|
||||
JOIN m_user ON DoctorToBranchUserID = M_UserID
|
||||
JOIN nat_staff ON M_UserM_StaffID = Nat_StaffID
|
||||
JOIN m_branch ON DoctorToBranchM_BranchIPAddress = M_BranchIPAddress
|
||||
WHERE (DoctorToBranchType = 'D' OR DoctorToBranchType = 'UD') AND date(DoctorToBranchCreated) = '{$date}'
|
||||
GROUP BY DoctorToBranchID
|
||||
|
||||
UNION
|
||||
SELECT doctortobranch.*,
|
||||
DoctorToBranchID as id,
|
||||
CASE
|
||||
WHEN DoctorToBranchType = 'D' THEN 'Dokter Baru'
|
||||
WHEN DoctorToBranchType = 'UD' THEN 'Update Dokter'
|
||||
WHEN DoctorToBranchType = 'A' THEN 'Alamat Baru'
|
||||
ELSE 'Update Alamat'
|
||||
END as tipe,
|
||||
DATE_FORMAT(DoctorToBranchCreated,'%d-%m-%Y %T') as doctordate,
|
||||
DoctorToBranchM_DoctorID as doctorid,
|
||||
CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,' ',M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as doctorname,
|
||||
CONCAT(M_DoctorAddressNote, ' : ',M_DoctorAddressDescription) as doctoraddress,
|
||||
IF(DoctorToBranchStatus = 'N','Pending','Terkirim') as status,
|
||||
IF(M_DoctorIsMarketingConfirm = 'N','Belum dikonfirmasi','Sudah dikonfirmasi') as konfirmasi,
|
||||
DoctorToBranchRetry as pengulangan,
|
||||
Nat_StaffName as staffname,
|
||||
M_BranchID,
|
||||
M_BranchName as branchname,
|
||||
IF(DoctorToBranchStatus = 'N','Y','N') as chex
|
||||
FROM doctortobranch
|
||||
join m_doctoraddress ON M_DoctorAddressID = DoctorToBranchM_DoctorID
|
||||
JOIN m_doctor ON M_DoctorAddressM_DoctorID = M_DoctorID
|
||||
JOIN m_user ON DoctorToBranchUserID = M_UserID
|
||||
JOIN nat_staff ON M_UserM_StaffID = Nat_StaffID
|
||||
JOIN m_branch ON DoctorToBranchM_BranchIPAddress = M_BranchIPAddress
|
||||
WHERE (DoctorToBranchType = 'A' OR DoctorToBranchType = 'UA') AND date(DoctorToBranchCreated) = '{$date}'
|
||||
GROUP BY DoctorToBranchID) a
|
||||
$filter_status $filter_type $filter_branch
|
||||
ORDER BY DoctorToBranchID DESC
|
||||
";
|
||||
// echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N'){
|
||||
$rows[$k]['chex'] = false;
|
||||
}else{
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function getstationstatus(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$rows['types'] = array(array('id'=>'S','name'=>'Semua'),array('id'=>'D','name'=>'Dokter Baru'),array('id'=>'UD','name'=>'Update Dokter'),array('id'=>'A','name'=>'Alamat Baru'),array('id'=>'UA','name'=>'Update Alamat'));
|
||||
$rows['statuss'] = array(array('id'=>'N','name'=>'Pending'),array('id'=>'Y','name'=>'Terkirim'));
|
||||
$sql = "SELECT 0 as id, 'Semua' as name
|
||||
UNION
|
||||
SELECT M_BranchID as id, M_BranchName as name
|
||||
FROM m_branch
|
||||
WHERE
|
||||
M_BranchIsActive = 'Y'
|
||||
GROUP BY M_BranchID";
|
||||
$rows['branchs'] = $this->db_regional->query($sql)->result_array();
|
||||
$sql = "SELECT 0 as id, 'Semua' as name
|
||||
UNION
|
||||
SELECT Nat_StaffID as id, Nat_StaffName as name
|
||||
FROM doctortobranch
|
||||
JOIN m_user ON DoctorToBranchUserID = M_UserID
|
||||
JOIN nat_staff ON M_UserM_StaffID = Nat_StaffID
|
||||
GROUP BY Nat_StaffID";
|
||||
$rows['staffs'] = $this->db_regional->query($sql)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function doaction(){
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$doctors = $prm["doctors"];
|
||||
foreach($doctors as $idx => $doctor) {
|
||||
$urlxxx = '';
|
||||
if ( $doctor["chex"] == 1 ) {
|
||||
$dt_arr = array();
|
||||
if($doctor['DoctorToBranchType'] == 'D' || $doctor['DoctorToBranchType'] == 'UD'){
|
||||
$sql = "SELECT *
|
||||
FROM m_doctor
|
||||
WHERE
|
||||
M_DoctorID = {$doctor['DoctorToBranchM_DoctorID']}";
|
||||
$vx = $this->db_regional->query($sql)->row_array();
|
||||
$x_arr = array();
|
||||
if($doctor['DoctorToBranchType'] == 'D'){
|
||||
array_push($x_arr,$vx);
|
||||
$urlxxx = 'downloaddoctor';
|
||||
}
|
||||
else{
|
||||
$x_arr = $vx;
|
||||
$urlxxx = 'updatedoctor';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($doctor['DoctorToBranchType'] == 'A' || $doctor['DoctorToBranchType'] == 'UA'){
|
||||
$sql = "SELECT *
|
||||
FROM m_doctoraddress
|
||||
WHERE
|
||||
M_DoctorAddressID = {$doctor['DoctorToBranchM_DoctorID']}";
|
||||
$vx = $this->db_regional->query($sql)->row_array();
|
||||
$x_arr = array();
|
||||
if($doctor['DoctorToBranchType'] == 'A'){
|
||||
array_push($x_arr,$vx);
|
||||
$urlxxx = 'newaddressdoctor';
|
||||
}
|
||||
else{
|
||||
$x_arr = $vx;
|
||||
$urlxxx = 'updateaddressdoctor';
|
||||
}
|
||||
}
|
||||
|
||||
$data = json_encode($x_arr);
|
||||
$md5 = md5($data);
|
||||
$param = array("data" => $data, "md5" => $md5);
|
||||
$jparam = json_encode($param);
|
||||
$url = "http://".$doctor['DoctorToBranchM_BranchIPAddress']."/one-api/tools/marketing/{$urlxxx}/";
|
||||
$j_result = $this->post($url,$jparam);
|
||||
$result = json_decode($j_result,true);
|
||||
//echo $result["query"];
|
||||
if ($result["status"] == "OK") {
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
||||
WHERE
|
||||
DoctorToBranchID = {$doctor['DoctorToBranchID']}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
else{
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
||||
WHERE
|
||||
DoctorToBranchID = {$doctor['DoctorToBranchID']}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = array ("message" => "Resend OK");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 12);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
451
one-api/application/controllers/v1/fo/Register.php
Normal file
451
one-api/application/controllers/v1/fo/Register.php
Normal file
@@ -0,0 +1,451 @@
|
||||
<?php
|
||||
/*
|
||||
### Register API
|
||||
- Functions
|
||||
- login x
|
||||
- logout
|
||||
- search_patient x
|
||||
- search_doctor x
|
||||
- search_px x
|
||||
- last_px x
|
||||
- search_patient_type x
|
||||
- search_delivery_type x
|
||||
- do_register
|
||||
- get_barcode
|
||||
- update_barcode
|
||||
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Register extends MY_Controller {
|
||||
function index() {
|
||||
echo "isLogin : {$this->isLogin} \n";
|
||||
print_r($this->sys_input);
|
||||
print_r($this->sys_user);
|
||||
}
|
||||
|
||||
function new_patient(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//# ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//#ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//# generate no reg pasien
|
||||
$rstNoreg = $this->db->query('select `fn_get_numbering`(\'P\') as nomor')->row();
|
||||
$prm['M_PatientNoReg'] = $rstNoreg->nomor;
|
||||
|
||||
//# insert data pasien
|
||||
$sql = "insert into m_patient(
|
||||
M_PatientNoReg,
|
||||
M_PatientM_TitleID,
|
||||
M_PatientName,
|
||||
M_PatientM_SexID,
|
||||
M_PatientDOB,
|
||||
M_PatientNationality,
|
||||
M_PatientUserID,
|
||||
M_PatientLastUpdate)
|
||||
values( ?, ?, ?, ?, ?, ?,?, now())";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm["M_PatientNoReg"],
|
||||
$prm["M_PatientM_TitleID"],
|
||||
$prm["M_PatientName"],
|
||||
$prm["M_PatientM_SexID"],
|
||||
$prm["M_PatientDOB"],
|
||||
$prm["M_PatientNationality"],
|
||||
$tokenM_UserID
|
||||
)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_patient insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function new_patient_address(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//# ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//# insert data alamat pasien
|
||||
$sql = "insert into m_patientaddress(
|
||||
M_PatientAddressM_PatientID,
|
||||
M_PatientAddressType,
|
||||
M_PatientAddressName,
|
||||
M_PatientAddressNote,
|
||||
M_PatientAddressPostCode,
|
||||
M_PatientAddressUserID,
|
||||
M_PatientAddressLastUpdate)
|
||||
values( ?, ?, ?, ?, ?, ?, now())";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm["M_PatientAddressM_PatientID"],
|
||||
$prm["M_PatientAddressType"],
|
||||
$prm["M_PatientAddressName"],
|
||||
$prm["M_PatientAddressNote"],
|
||||
$prm["M_PatientAddressPostCode"],
|
||||
$tokenM_UserID
|
||||
)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_patientaddress insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_patient() {
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//# jumlah baris per page default 10 jika tidak di set
|
||||
$row_per_page = 10;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
array_push($sql_param,$s_query);
|
||||
|
||||
//# hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_patient
|
||||
where ( M_PatientNoReg like ? OR M_PatientName like ? ) and M_PatientIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_patient count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *
|
||||
from m_patient
|
||||
where ( M_PatientNoReg like ? OR M_PatientName like ? ) and M_PatientIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_patient rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function new_doctor_sender(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//# ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//#ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//# insert data dokter pengirim
|
||||
$sql = "insert into m_doctor(
|
||||
M_DoctorCode,
|
||||
M_DoctorName,
|
||||
M_DoctorSpecialization,
|
||||
M_DoctorHP,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorUserID,
|
||||
M_DoctorLastUpdate)
|
||||
values( ?, ?, ?, ?, ?, ?, now())";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm["M_DoctorCode"],
|
||||
$prm["M_DoctorName"],
|
||||
$prm["M_DoctorSpecialization"],
|
||||
$prm["M_DoctorHP"],
|
||||
$prm["M_DoctorM_SexID"],
|
||||
$tokenM_UserID
|
||||
)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function new_doctor_sender_address(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//# ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//# insert data alamat pasien
|
||||
$sql = "insert into m_doctoraddress(
|
||||
M_DoctorAddressM_DoctorID,
|
||||
M_DoctorAddressType,
|
||||
M_DoctorAddressName,
|
||||
M_DoctorAddressNote,
|
||||
M_DoctorAddressPostCode,
|
||||
M_DoctorAddressUserID,
|
||||
M_DoctorAddressLastUpdate)
|
||||
values( ?, ?, ?, ?, ?, ?, now())";
|
||||
|
||||
$query = $this->db->query($sql,
|
||||
array(
|
||||
$prm["M_DoctorAddressM_DoctorID"],
|
||||
$prm["M_DoctorAddressType"],
|
||||
$prm["M_DoctorAddressName"],
|
||||
$prm["M_DoctorAddressNote"],
|
||||
$prm["M_DoctorAddressPostCode"],
|
||||
$tokenM_UserID
|
||||
)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_doctor_sender() {
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//# jumlah baris per page default 10 jika tidak di set
|
||||
$row_per_page = 10;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
array_push($sql_param,$s_query);
|
||||
|
||||
//# hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_doctor
|
||||
where ( M_DoctorCode like ? OR M_DoctorName like ? ) and M_DoctorIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *
|
||||
from m_doctor
|
||||
where ( M_DoctorCode like ? OR M_DoctorName like ? ) and M_DoctorIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_doctor_pj() {
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//# jumlah baris per page default 10 jika tidak di set
|
||||
$row_per_page = 10;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
array_push($sql_param,$s_query);
|
||||
|
||||
//# hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_doctor
|
||||
where ( M_DoctorCode like ? OR M_DoctorName like ? ) and M_DoctorIsPJ = 'Y' and M_DoctorIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *
|
||||
from m_doctor
|
||||
where ( M_DoctorCode like ? OR M_DoctorName like ? ) and M_DoctorIsPJ = 'Y' and M_DoctorIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
432
one-api/application/controllers/v1/fo/Register_old.php
Normal file
432
one-api/application/controllers/v1/fo/Register_old.php
Normal file
@@ -0,0 +1,432 @@
|
||||
<?php
|
||||
/*
|
||||
### Register API
|
||||
- Functions
|
||||
- login x
|
||||
- logout
|
||||
- search_patient x
|
||||
- search_doctor x
|
||||
- search_px x
|
||||
- last_px x
|
||||
- search_patient_type x
|
||||
- search_delivery_type x
|
||||
- do_register
|
||||
- get_barcode
|
||||
- update_barcode
|
||||
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Register extends MY_Controller {
|
||||
function index() {
|
||||
echo "isLogin : {$this->isLogin} \n";
|
||||
print_r($this->sys_input);
|
||||
print_r($this->sys_user);
|
||||
}
|
||||
function last_test() {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$patientID = $prm["M_PatientID"];
|
||||
$orderHeaderID = 0;
|
||||
$sql = "select T_OrderHeaderID
|
||||
from
|
||||
t_orderheader
|
||||
where
|
||||
T_OrderHeaderM_PatientID = ? and T_OrderHeaderIsActive = 'Y'
|
||||
order by T_OrderHeaderID desc
|
||||
limit 0,1";
|
||||
$query = $this->db->query($sql,array($patientID));
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) > 0 ) $orderHeaderID = $rows[0]["T_OrderHeaderID"];
|
||||
} else {
|
||||
$this->sys_error_db("find last order");
|
||||
exit;
|
||||
}
|
||||
$rows = array();
|
||||
if ($orderHeaderID > 0 ) {
|
||||
$sql = "select T_TestID,T_TestName
|
||||
from
|
||||
t_orderdetail
|
||||
join t_test on T_OrderDetailT_OrderHeaderID =? and
|
||||
T_TestIsActive ='Y' and T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestIsPrice = 'Y' and T_OrderDetailIsActive='Y'";
|
||||
$query = $this->db->query($sql,array($orderHeaderID));
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("find last test");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function search_delivery_type() {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
$max = 25;
|
||||
if (isset($prm["max_row"]) && $prm["max_row"] < $max ) $max = $prm["max_row"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
$sql = "select count(*) as tot
|
||||
from m_deliveryservice
|
||||
where M_DeliveryServiceName like ? and M_DeliveryServiceIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("delivery type count");
|
||||
exit;
|
||||
}
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
$sql = "select *
|
||||
from m_deliveryservice
|
||||
where M_DeliveryServiceName like ? and M_DeliveryServiceIsActive='Y'
|
||||
limit 0,$max";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("delivery type count");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function search_patient_type() {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
$max = 25;
|
||||
if (isset($prm["max_row"]) && $prm["max_row"] < $max ) $max = $prm["max_row"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
$sql = "select count(*) as tot
|
||||
from m_patienttype
|
||||
where M_PatientTypeName like ? and M_PatientTypeIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("test/panel count");
|
||||
exit;
|
||||
}
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
$sql = "select *
|
||||
from m_patienttype
|
||||
where M_PatientTypeName like ? and M_PatientTypeIsActive='Y'
|
||||
limit 0,$max";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("test/panel count");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function search_test() {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
$max = 25;
|
||||
if (isset($prm["max_row"]) && $prm["max_row"] < $max ) $max = $prm["max_row"];
|
||||
//name
|
||||
$sql = "select count(*) as tot
|
||||
from
|
||||
(
|
||||
select T_TestID
|
||||
from
|
||||
t_test
|
||||
where T_TestName like ? and T_TestIsActive = 'Y'
|
||||
union
|
||||
select T_TestPanelID
|
||||
from
|
||||
t_testpanel
|
||||
where
|
||||
T_TestPanelName like ? and T_TestPanelIsActive = 'Y'
|
||||
) x
|
||||
";
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query, $s_query);
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("test/panel count");
|
||||
exit;
|
||||
}
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
$sql = "select *
|
||||
from
|
||||
(
|
||||
select T_TestID X_ID, T_TestName X_Name, 'N' IsPanel , concat('\'',T_TestID,'\'') as A_Test
|
||||
from
|
||||
t_test
|
||||
where T_TestName like ? and T_TestIsActive = 'Y'
|
||||
union
|
||||
select T_TestPanelID X_ID, T_TestPanelName X_Name, 'Y' IsPanel,
|
||||
group_concat(T_TestPanelDetailT_TestID) as A_Test
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelDetailIsActive = 'Y'
|
||||
where
|
||||
T_TestPanelName like ? and T_TestPanelIsActive = 'Y'
|
||||
group by T_TestPanelID
|
||||
) x
|
||||
limit 0, $max
|
||||
";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $idx => $r) {
|
||||
$a_test = explode(",",$r["A_Test"]);
|
||||
$rows[$idx]["A_Test"] = $a_test;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("test/panel data");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search_doctor() {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
//name+address+phone
|
||||
$a_param = explode("+",$prm["query"]);
|
||||
$sql_where = " M_DoctorIsActive='Y' ";
|
||||
$sql_param = array();
|
||||
foreach($a_param as $idx => $inp) {
|
||||
if (trim($inp) == "") continue;
|
||||
if ($sql_where != "") $sql_where .= " and ";
|
||||
switch($idx) {
|
||||
case 0 :
|
||||
$sql_where .= " M_DoctorName like ? ";
|
||||
$sql_param[] = "%$inp%";
|
||||
break;
|
||||
case 1 :
|
||||
$sql_where .= " ( M_DoctorHomeAddress like ? or M_DoctorPracticeAddress like ? ) ";
|
||||
$sql_param[] = "%$inp%";
|
||||
$sql_param[] = "%$inp%";
|
||||
break;
|
||||
case 2 :
|
||||
$sql_where .= " M_DoctorPhone like ? ";
|
||||
$sql_param[] = "%$inp%";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($sql_where != "" ) $sql_where = " where $sql_where";
|
||||
$max = 25;
|
||||
if (isset($prm["max_row"]) && $prm["max_row"] < $max ) $max = $prm["max_row"];
|
||||
|
||||
$sql = "select count(*) as tot from m_doctor $sql_where";
|
||||
$tot_count = 0;
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("search_doctor count");
|
||||
exit;
|
||||
}
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
$sql = "select * from m_doctor $sql_where limit 0,$max";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("search_doctor data");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function search_patient() {
|
||||
// $this->sys_debug();
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//name+address+phone+dob(ddmmyy)
|
||||
|
||||
$a_param = explode("+",$prm["query"]);
|
||||
$sql_where = " M_PatientIsActive='Y' ";
|
||||
$sql_param = array();
|
||||
foreach($a_param as $idx => $inp) {
|
||||
if (trim($inp) == "") continue;
|
||||
if ($sql_where != "") $sql_where .= " and ";
|
||||
switch($idx) {
|
||||
case 0 :
|
||||
$sql_where .= " M_PatientName like ? ";
|
||||
$sql_param[] = "%$inp%";
|
||||
break;
|
||||
case 1 :
|
||||
$sql_where .= " M_PatientAddress like ? ";
|
||||
$sql_param[] = "%$inp%";
|
||||
break;
|
||||
case 2 :
|
||||
$sql_where .= " M_PatientPhone like ? ";
|
||||
$sql_param[] = "%$inp%";
|
||||
break;
|
||||
case 3 :
|
||||
$sql_where .= " M_PatientDOB like ? ";
|
||||
//ddmmyy
|
||||
if (strlen($inp) == 6) {
|
||||
$year = substr($inp,4,2);
|
||||
if ($year > 20) {
|
||||
$year = "19$year";
|
||||
} else {
|
||||
$year = "20$year";
|
||||
}
|
||||
$dob = "$year-" . substr($inp,2,2) . "-" . substr($inp,0,2);
|
||||
}
|
||||
$sql_param[] = $dob;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($sql_where != "" ) $sql_where = " where $sql_where";
|
||||
$max = 25;
|
||||
if (isset($prm["max_row"]) && $prm["max_row"] < $max ) $max = $prm["max_row"];
|
||||
|
||||
$sql = "select count(*) as tot from m_patient $sql_where";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("search patient count");
|
||||
exit;
|
||||
}
|
||||
$rows = array();
|
||||
if ($tot_count > 0 ) {
|
||||
$sql = "select * from m_patient $sql_where limit 0,$max";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("search patient data");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array("total" => $tot_count , "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function login() {
|
||||
$prm = $this->sys_input;
|
||||
try {
|
||||
//existing password enc
|
||||
$sm_password = md5($this->smartlab_salt . $prm["userPassword"] .
|
||||
$this->smartlab_salt);
|
||||
$query = $this->db->query("select M_UserID,M_UserUserName
|
||||
from m_user
|
||||
where M_UserUserName=? and M_UserPassword=?
|
||||
and M_UserIsActive = 'Y'
|
||||
",array($prm["userName"], $sm_password));
|
||||
if (!$query) {
|
||||
$message = $this->db->error();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$user = $rows[0];
|
||||
$token = JWT::encode($user,$this->SECRET_KEY);
|
||||
$data = array(
|
||||
"user" => $user,
|
||||
"token" => $token
|
||||
);
|
||||
$this->sys_ok($data);
|
||||
exit;
|
||||
}
|
||||
$this->sys_error_db("Invalid UserName / Password");
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function logout() {
|
||||
$this->sys_error("ok");
|
||||
}
|
||||
}
|
||||
?>
|
||||
226
one-api/application/controllers/v1/master/Bank.php
Normal file
226
one-api/application/controllers/v1/master/Bank.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/*
|
||||
### Bank API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Bank extends MY_Controller {
|
||||
function index() {
|
||||
echo "Bank Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 jika tidak di set
|
||||
$row_per_page = 10;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_bank
|
||||
where M_BankName like ? and M_BankIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_bank count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *
|
||||
from m_bank
|
||||
where M_BankName like ? and M_BankIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_bank rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//3. validasi input jika di perlukan, contoh di sini cek M_BankCode harus belum ada
|
||||
$sql = "select count(*) tot
|
||||
from m_bank
|
||||
where M_BankIsActive='Y' and M_BankCode=?";
|
||||
$query = $this->db->query($sql,array($prm["M_BankCode"]));
|
||||
//cek jika query error kirim pesan agar tidak crash
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
if ($tot_count > 0) {
|
||||
$message = "BankCode : " . $prm["M_BankCode"] . " already exists.";
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_bank bankCode validation");
|
||||
exit;
|
||||
}
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into m_bank(M_BankCode, M_BankName, M_BankAddress, M_BankBranch, M_BankHISDefault,
|
||||
M_BankUserID, M_BankLastUpdate) values( ?, ?, ?, ?, ?, ?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["M_BankCode"], $prm["M_BankName"], $prm["M_BankAddress"], $prm["M_BankBranch"], $prm["M_BankHisIsDefault"],
|
||||
$tokenM_UserID)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_bank insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_bank
|
||||
set M_BankCode = ? , M_BankName = ?, M_BankAddress = ? , M_BankBranch = ?, M_BankHISDefault = ?,
|
||||
M_BankLastUpdate = now() , M_BankUserID = ?
|
||||
where M_BankID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["M_BankCode"], $prm["M_BankName"], $prm["M_BankAddress"], $prm["M_BankBranch"], $prm["M_BankHISDefault"],
|
||||
$tokenM_UserID, $prm["M_BankID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_bank update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_bank
|
||||
set M_BankIsActive = 'N', M_BankLastUpdate = now(),
|
||||
M_BankUserID = ?
|
||||
where M_BankID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["M_BankID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_bank delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
209
one-api/application/controllers/v1/master/Pamorfology.php
Normal file
209
one-api/application/controllers/v1/master/Pamorfology.php
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
/*
|
||||
### Sex API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Pamorfology extends MY_Controller {
|
||||
function index() {
|
||||
echo "Pamorfology Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 jika tidak di set
|
||||
$row_per_page = 25;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from pa_morfology
|
||||
where Pa_MorfologyName like ? and Pa_MorfologyIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("pa_morfology count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *
|
||||
from pa_morfology
|
||||
where Pa_MorfologyName like ? and Pa_MorfologyIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("pa_morfology rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["Pa_MorfologyUserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into pa_morfology(Pa_MorfologyName, Pa_MorfologyUserID, Pa_MorfologyLastUpdate) values( ?,?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["Pa_MorfologyName"],$tokenM_UserID)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("pa_morfology insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["Pa_MorfologyUserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update pa_morfology
|
||||
set Pa_MorfologyName = ?,
|
||||
Pa_MorfologyLastUpdate = now() , Pa_MorfologyUserID = ?
|
||||
where Pa_MorfologyID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["Pa_MorfologyName"],
|
||||
$tokenM_UserID, $prm["Pa_MorfologyID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("pa_morfology update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["Pa_MorfologyUserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update pa_morfology
|
||||
set Pa_MorfologyIsActive = 'N', Pa_MorfologyLastUpdate = now(),
|
||||
Pa_MorfologyUserID = ?
|
||||
where Pa_MorfologyID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["Pa_MorfologyID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("pa_morfology delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
95
one-api/application/controllers/v1/master/Province.php
Normal file
95
one-api/application/controllers/v1/master/Province.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class Province extends MY_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
|
||||
// $this->sys_debug();
|
||||
try
|
||||
{
|
||||
// Token validation
|
||||
if (! $this->isLogin)
|
||||
{
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Getting inputs
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
// Predefined values
|
||||
$row_per_page = 25;
|
||||
$page = 1;
|
||||
$tot_count = 0;
|
||||
|
||||
$sqlc = "SELECT COUNT(*) as n
|
||||
FROM m_province
|
||||
WHERE M_ProvinceName LIKE ? AND M_ProvinceIsActive='Y'";
|
||||
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
|
||||
$sql_param = array($s_query);
|
||||
|
||||
// Getting total rows
|
||||
$sql = $sqlc;
|
||||
$query = $this->db->query($sql, $sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->row()->n;
|
||||
} else {
|
||||
$this->sys_error_db("m_sex count");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Getting records if count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0)
|
||||
{
|
||||
// Start_limit < 0 ? > total_count ?
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count)
|
||||
$start_limit = 0;
|
||||
|
||||
if ($start_limit < 0)
|
||||
$start_limit = 0;
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM m_province
|
||||
WHERE M_ProvinceName like ? and M_ProvinceIsActive='Y'
|
||||
LIMIT $start_limit, $row_per_page";
|
||||
$query = $this->db->query($sql, $sql_param);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_sex rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
}
|
||||
|
||||
catch(Exception $exc)
|
||||
{
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
229
one-api/application/controllers/v1/master/Religion.php
Normal file
229
one-api/application/controllers/v1/master/Religion.php
Normal file
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/*
|
||||
### Religion API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Religion extends MY_Controller {
|
||||
function index() {
|
||||
echo "Religion Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 jika tidak di set
|
||||
$row_per_page = 10;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_religion
|
||||
where M_ReligionName like ? and M_ReligionIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_religion count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *
|
||||
from m_religion
|
||||
where M_ReligionName like ? and M_ReligionIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_religion rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//3. validasi input jika di perlukan, contoh di sini cek M_ReligionCode harus belum ada
|
||||
/*
|
||||
$sql = "select count(*) tot
|
||||
from m_religion
|
||||
where M_ReligionIsActive='Y' and M_ReligionCode=?";
|
||||
$query = $this->db->query($sql,array($prm["M_ReligionCode"]));
|
||||
//cek jika query error kirim pesan agar tidak crash
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
if ($tot_count > 0) {
|
||||
$message = "ReligionCode : " . $prm["M_ReligionCode"] . " already exists.";
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_religion religionCode validation");
|
||||
exit;
|
||||
}
|
||||
|
||||
*/
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into m_religion(M_ReligionName, M_ReligionHISDefault,
|
||||
M_ReligionUserID, M_ReligionLastUpdate) values(?, ?, ?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["M_ReligionName"], $prm["M_ReligionHISDefault"],
|
||||
$tokenM_UserID)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_religion insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_religion
|
||||
set M_ReligionName = ?, M_ReligionHISDefault = ?,
|
||||
M_ReligionLastUpdate = now() , M_ReligionUserID = ?
|
||||
where M_ReligionID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["M_ReligionName"], $prm["M_ReligionHISDefault"],
|
||||
$tokenM_UserID, $prm["M_ReligionID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_religion update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_religion
|
||||
set M_ReligionIsActive = 'N', M_ReligionLastUpdate = now(),
|
||||
M_ReligionUserID = ?
|
||||
where M_ReligionID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["M_ReligionID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_religion delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
226
one-api/application/controllers/v1/master/Sex.php
Normal file
226
one-api/application/controllers/v1/master/Sex.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/*
|
||||
### Sex API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Sex extends MY_Controller {
|
||||
function index() {
|
||||
echo "Sex Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 jika tidak di set
|
||||
$row_per_page = 25;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_sex
|
||||
where M_SexName like ? and M_SexIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_sex count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *
|
||||
from m_sex
|
||||
where M_SexName like ? and M_SexIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_sex rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//3. validasi input jika di perlukan, contoh di sini cek M_SexCode harus belum ada
|
||||
$sql = "select count(*) tot
|
||||
from m_sex
|
||||
where M_SexIsActive='Y' and M_SexCode=?";
|
||||
$query = $this->db->query($sql,array($prm["M_SexCode"]));
|
||||
//cek jika query error kirim pesan agar tidak crash
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
if ($tot_count > 0) {
|
||||
$message = "SexCode : " . $prm["M_SexCode"] . " already exists.";
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_sex sexCode validation");
|
||||
exit;
|
||||
}
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into m_sex(M_SexCode, M_SexName, M_SexHISDefault,
|
||||
M_SexUserID, M_SexLastUpdate) values( ?, ?, ?, ?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["M_SexCode"], $prm["M_SexName"], $prm["M_SexHisIsDefault"],
|
||||
$tokenM_UserID)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_sex insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_sex
|
||||
set M_SexCode = ? , M_SexName = ?, M_SexHISDefault = ?,
|
||||
M_SexLastUpdate = now() , M_SexUserID = ?
|
||||
where M_SexID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["M_SexCode"], $prm["M_SexName"], $prm["M_SexHISDefault"],
|
||||
$tokenM_UserID, $prm["M_SexID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_sex update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_sex
|
||||
set M_SexIsActive = 'N', M_SexLastUpdate = now(),
|
||||
M_SexUserID = ?
|
||||
where M_SexID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["M_SexID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_sex delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
231
one-api/application/controllers/v1/master/Title.php
Normal file
231
one-api/application/controllers/v1/master/Title.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
/*
|
||||
### Title API
|
||||
- Functions
|
||||
- search
|
||||
- add
|
||||
- edit
|
||||
- delete
|
||||
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Title extends MY_Controller {
|
||||
function index() {
|
||||
echo "Title Api";
|
||||
}
|
||||
function search() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$s_query = "%" . $prm["query"] . "%";
|
||||
$s_query2 = "%" . $prm["query2"] . "%";
|
||||
|
||||
//2A. jumlah baris per page default 25 jika tidak di set
|
||||
$row_per_page = 25;
|
||||
if (isset($prm["row_per_page"])) $row_per_page = $prm["row_per_page"];
|
||||
$page = 1;
|
||||
if (isset($prm["page"])) $page = $prm["page"];
|
||||
$tot_count = 0;
|
||||
$sql_param = array($s_query,$s_query2);
|
||||
|
||||
//3. hitung total rows
|
||||
$sql = "select count(*) as tot
|
||||
from m_title
|
||||
left join m_sex on M_TitleM_SexID = M_SexID
|
||||
where M_TitleName like ? and M_SexName like ? and M_TitleIsActive='Y'";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
} else {
|
||||
$this->sys_error_db("m_title count");
|
||||
exit;
|
||||
}
|
||||
|
||||
//4. cari records jika total count > 0
|
||||
$rows = array();
|
||||
if ($tot_count > 0) {
|
||||
//4A. start_limit set ke 0 jika negative atau > total count
|
||||
$start_limit = ($page - 1) * $row_per_page;
|
||||
if ($start_limit > $tot_count) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
if ($start_limit < 0) {
|
||||
$start_limit = 0;
|
||||
}
|
||||
$sql = "select *, M_SexName
|
||||
from m_title
|
||||
left join m_sex on M_TitleM_SexID = M_SexID
|
||||
where M_TitleName like ? and M_SexName like ? and M_TitleIsActive='Y'
|
||||
limit $start_limit,$row_per_page";
|
||||
$query = $this->db->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_title rows");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//3. validasi input jika di perlukan, contoh di sini cek M_TitleCode harus belum ada
|
||||
/*
|
||||
$sql = "select count(*) tot
|
||||
from m_title
|
||||
where M_TitleIsActive='Y' and M_TitleCode=?";
|
||||
$query = $this->db->query($sql,array($prm["M_TitleCode"]));
|
||||
//cek jika query error kirim pesan agar tidak crash
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["tot"];
|
||||
if ($tot_count > 0) {
|
||||
$message = "TitleCode : " . $prm["M_TitleCode"] . " already exists.";
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_title titleCode validation");
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
//4. insert statement menggunakan explicit field name di sebutkan
|
||||
// untuk menghindari kesalahan karena penambahan field baru
|
||||
$sql = "insert into m_title(M_TitleM_SexID, M_TitleName, M_TitleHISDefault,
|
||||
M_TitleUserID, M_TitleLastUpdate) values( ?, ?, ?, ?, now())";
|
||||
//4a. Create statment
|
||||
$query = $this->db->query($sql,
|
||||
array($prm["M_TitleM_SexID"], $prm["M_TitleName"], $prm["M_TitleHISDefault"],
|
||||
$tokenM_UserID)
|
||||
);
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"inserted_id" => $this->db->insert_id(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_title insert");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function edit() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_title
|
||||
set M_TitleM_SexID = ? , M_TitleName = ?, M_TitleHISDefault = ?,
|
||||
M_TitleLastUpdate = now() , M_TitleUserID = ?
|
||||
where M_TitleID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$prm["M_TitleM_SexID"], $prm["M_TitleName"], $prm["M_TitleHISDefault"],
|
||||
$tokenM_UserID, $prm["M_TitleID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_title update");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function delete() {
|
||||
//$this->sys_debug();
|
||||
try {
|
||||
//1. cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//1a. ambil userID dari token
|
||||
$tokenM_UserID = $this->sys_user["M_UserID"];
|
||||
|
||||
//2. ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sql = "update m_title
|
||||
set M_TitleIsActive = 'N', M_TitleLastUpdate = now(),
|
||||
M_TitleUserID = ?
|
||||
where M_TitleID = ? ";
|
||||
$query = $this->db->query($sql, array(
|
||||
$tokenM_UserID, $prm["M_TitleID"]
|
||||
));
|
||||
if ($query) {
|
||||
echo json_encode(array(
|
||||
"status" => "OK",
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"message" => "",
|
||||
"data" => array()
|
||||
));
|
||||
} else {
|
||||
$this->sys_error_db("m_title delete");
|
||||
exit;
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
856
one-api/application/controllers/v1/masterdata/Abnormalv4.php
Normal file
856
one-api/application/controllers/v1/masterdata/Abnormalv4.php
Normal file
@@ -0,0 +1,856 @@
|
||||
<?php
|
||||
|
||||
class Abnormalv4 extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "ABNORMAL API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupabnormalbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$testname = $prm['testname'];
|
||||
$methodename = $prm['methodename'];
|
||||
$sexid = $prm['sexid'];
|
||||
$flagid = $prm['flagid'];
|
||||
$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 nat_normalvalue
|
||||
LEFT JOIN nat_advice_abnormal ON Nat_NormalValueID = Nat_AdviceAbnormalNat_NormalValueID AND Nat_AdviceAbnormalIsActive = 'Y'
|
||||
LEFT JOIN nat_sex ON Nat_NormalValueNat_SexID = Nat_SexID
|
||||
JOIN nat_test ON Nat_NormalValueNat_TestID = Nat_TestID
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID AND Nat_MethodeIsActive = 'Y'
|
||||
JOIN nat_normalvaluetype ON Nat_NormalValueNat_NormalValueTypeID = Nat_NormalValueTypeID
|
||||
LEFT JOIN nat_flag ON Nat_NormalValueNat_FlagID = Nat_FlagID
|
||||
WHERE
|
||||
Nat_NormalValueIsActive = 'Y' AND Nat_NormalValueIsAbnormal = 'Y' AND
|
||||
Nat_TestName like '%{$testname}%' AND
|
||||
Nat_MethodeName like '%{$methodename}%'
|
||||
$filter GROUP BY Nat_NormalValueID) 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("nat_normalvalue count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT nat_normalvalue.*,
|
||||
Nat_NormalValueID as id,
|
||||
Nat_NormalValueID,
|
||||
IFNULL(Nat_AdviceAbnormalID,0) as Nat_AdviceAbnormalID,
|
||||
Nat_TestName,
|
||||
Nat_SexID,
|
||||
Nat_SexName,
|
||||
Nat_MethodeID,
|
||||
Nat_MethodeName,
|
||||
Nat_NormalValueTypeID,
|
||||
Nat_NormalValueTypeName,
|
||||
Nat_FlagID,
|
||||
Nat_FlagName,
|
||||
Nat_NormalValueMinAge,
|
||||
Nat_NormalValueMaxAge,
|
||||
CASE
|
||||
WHEN Nat_NormalValueMinAgeInclusive = 'Y' AND Nat_NormalValueMaxAgeInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinAge,' - ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')')
|
||||
WHEN Nat_NormalValueMinAgeInclusive = 'Y' AND Nat_NormalValueMaxAgeInclusive = 'N' THEN CONCAT(Nat_NormalValueMinAge,' > ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')')
|
||||
WHEN Nat_NormalValueMinAgeInclusive = 'N' AND Nat_NormalValueMaxAgeInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinAge,' < ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')')
|
||||
ELSE '-'
|
||||
END as Nat_NormalValueAge,
|
||||
CASE
|
||||
WHEN Nat_NormalValueMinValueInclusive = 'Y' AND Nat_NormalValueMaxValueInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinValue,' - ',Nat_NormalValueMaxValue)
|
||||
WHEN Nat_NormalValueMinValueInclusive = 'Y' AND Nat_NormalValueMaxValueInclusive = 'N' THEN CONCAT(Nat_NormalValueMinValue,' > ',Nat_NormalValueMaxValue)
|
||||
WHEN Nat_NormalValueMinValueInclusive = 'N' AND Nat_NormalValueMaxValueInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinValue,' < ',Nat_NormalValueMaxValue)
|
||||
ELSE '-'
|
||||
END as Nat_NormalValueValue,
|
||||
CASE
|
||||
WHEN Nat_NormalValueAgeUnit = 'HARI' THEN '1'
|
||||
WHEN Nat_NormalValueAgeUnit = 'BULAN' THEN '2'
|
||||
WHEN Nat_NormalValueAgeUnit = 'TAHUN' THEN '3'
|
||||
ELSE '4'
|
||||
END as ageunit,
|
||||
IF(Nat_NormalValueIsAbnormal = 'N',Nat_NormalValueID,Nat_NormalValueParentID) as parentid
|
||||
FROM nat_normalvalue
|
||||
LEFT JOIN nat_advice_abnormal ON Nat_NormalValueID = Nat_AdviceAbnormalNat_NormalValueID AND Nat_AdviceAbnormalIsActive = 'Y'
|
||||
LEFT JOIN nat_sex ON Nat_NormalValueNat_SexID = Nat_SexID
|
||||
JOIN nat_test ON Nat_NormalValueNat_TestID = Nat_TestID
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID AND Nat_MethodeIsActive = 'Y'
|
||||
JOIN nat_normalvaluetype ON Nat_NormalValueNat_NormalValueTypeID = Nat_NormalValueTypeID
|
||||
LEFT JOIN nat_flag ON Nat_NormalValueNat_FlagID = Nat_FlagID
|
||||
WHERE
|
||||
Nat_NormalValueIsActive = 'Y' AND Nat_NormalValueIsAbnormal = 'Y' AND
|
||||
Nat_TestName like '%{$testname}%' AND
|
||||
Nat_MethodeName like '%{$methodename}%'
|
||||
$filter
|
||||
GROUP BY Nat_NormalValueID
|
||||
ORDER BY Nat_NormalValueNat_SexID ASC, ageunit ASC, Nat_NormalValueMinAge ASC, Nat_NormalValueMaxAge ASC, parentid 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("nat_normalvalue 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 lookupadvicebyid(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$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(Nat_AdviceAbnormalID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_abnormal ON Nat_AdviceID = Nat_AdviceAbnormalNat_AdviceID AND Nat_AdviceAbnormalNat_NormalValueID = $id AND Nat_AdviceAbnormalIsActive = 'Y'
|
||||
LEFT JOIN nat_normalvalue ON Nat_AdviceAbnormalNat_NormalValueID = Nat_NormalValueID AND Nat_NormalValueIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' GROUP BY Nat_AdviceID) a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $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("nat_advice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(select Nat_AdviceID as id,
|
||||
Nat_AdviceID,
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdviceAbnormalID,
|
||||
Nat_AdviceAbnormalNat_NormalValueID,
|
||||
Nat_AdviceAbnormalNat_AdviceID,
|
||||
IF(IFNULL(Nat_AdviceAbnormalID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_abnormal ON Nat_AdviceID = Nat_AdviceAbnormalNat_AdviceID AND Nat_AdviceAbnormalNat_NormalValueID = $id AND Nat_AdviceAbnormalIsActive = 'Y'
|
||||
LEFT JOIN nat_normalvalue ON Nat_AdviceAbnormalNat_NormalValueID = Nat_NormalValueID AND Nat_NormalValueIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y') a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $filter
|
||||
GROUP BY Nat_AdviceID
|
||||
ORDER BY Nat_AdviceID 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("nat_advice 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 listingadvice(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'";
|
||||
// $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("nat_advice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'
|
||||
ORDER BY Nat_AdviceID 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("nat_advice 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 *
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_normalvaluetype
|
||||
WHERE
|
||||
Nat_NormalValueTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['normalvaluetypees'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['flages'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['ageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['minageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['maxageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 0 as Nat_SexID, 'Semua' as Nat_SexName
|
||||
UNION
|
||||
SELECT Nat_SexID, Nat_SexName
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_sexs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 0 as Nat_FlagID, 'Semua' as Nat_FlagName
|
||||
UNION
|
||||
SELECT Nat_FlagID, Nat_FlagName
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows['f_flags'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$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 addnewadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$abnormalid = $prm['abnormalid'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into nat_advice(
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdviceUserID,
|
||||
Nat_AdviceCreated,
|
||||
Nat_AdviceLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$adviceina,
|
||||
$adviceeng,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_normalvalue 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 saveaddeditadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$abnormalid = $prm['abnormalid'];
|
||||
$adviceid = $prm['Nat_AdviceID'];
|
||||
$adviceabnormalid = $prm['Nat_AdviceAbnormalID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($status == 'Y'){
|
||||
$sql = "insert into nat_advice_abnormal(
|
||||
Nat_AdviceAbnormalNat_NormalValueID,
|
||||
Nat_AdviceAbnormalNat_AdviceID,
|
||||
Nat_AdviceAbnormalUserID,
|
||||
Nat_AdviceAbnormalCreated,
|
||||
Nat_AdviceAbnormalLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$abnormalid,
|
||||
$adviceid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_abnormal 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 nat_advice_abnormal SET
|
||||
Nat_AdviceAbnormalIsActive = 'N',
|
||||
Nat_AdviceAbnormalUserID = ?,
|
||||
Nat_AdviceAbnormalCreated = now(),
|
||||
Nat_AdviceAbnormalLastUpdated = now()
|
||||
WHERE Nat_AdviceAbnormalID = ?";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$adviceabnormalid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_abnormal 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 saveeditsaran(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE nat_advice SET
|
||||
Nat_AdviceIna = '{$prm['ina']}',
|
||||
Nat_AdviceEng = '{$prm['eng']}',
|
||||
Nat_AdviceIsActive = '{$prm['status']}',
|
||||
Nat_AdviceUserID = {$userid}
|
||||
WHERE
|
||||
Nat_AdviceID = {$prm['id']}
|
||||
";
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
function savealladvice(){
|
||||
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 nat_advice_abnormal SET
|
||||
Nat_AdviceAbnormalNat_NormalValueID = '{$v['Nat_AdviceAbnormalNat_NormalValueID']}',
|
||||
Nat_AdviceAbnormalAdviceIna = '{$v['Nat_AdviceAbnormalAdviceIna']}',
|
||||
Nat_AdviceAbnormalAdviceEng = '{$v['Nat_AdviceAbnormalAdviceEng']}',
|
||||
Nat_AdviceAbnormalUserID = {$userid},
|
||||
Nat_AdviceAbnormalCreated = now(),
|
||||
Nat_AdviceAbnormalLastUpdated = now()
|
||||
WHERE Nat_AdviceAbnormalID = {$v['Nat_AdviceAbnormalID']}";
|
||||
|
||||
//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 deleteabnormal()
|
||||
{
|
||||
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 nat_normalvalue SET
|
||||
Nat_NormalValueIsActive = 'N'
|
||||
WHERE
|
||||
Nat_NormalValueNat_MethodeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_normalvalue 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 deleteadvice()
|
||||
{
|
||||
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_normalvalue SET
|
||||
Nat_NormalValueIsActive = 'N'
|
||||
WHERE
|
||||
Nat_NormalValueID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_normalvalue 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 searchabnormal(){
|
||||
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 searchabnormalbyname(){
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
878
one-api/application/controllers/v1/masterdata/Advicefisik.php
Normal file
878
one-api/application/controllers/v1/masterdata/Advicefisik.php
Normal file
@@ -0,0 +1,878 @@
|
||||
<?php
|
||||
|
||||
class Advicefisik extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "ABNORMAL API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupfisikbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$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_advice_fisik
|
||||
WHERE
|
||||
M_AdviceFisikIsActive = 'Y' AND
|
||||
M_AdviceFisikLabel like '%{$name}%'
|
||||
GROUP BY M_AdviceFisikID) 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_advice_fisik count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT m_advice_fisik.*,
|
||||
M_AdviceFisikID as id
|
||||
from m_advice_fisik
|
||||
WHERE
|
||||
M_AdviceFisikIsActive = 'Y' AND
|
||||
M_AdviceFisikLabel like '%{$name}%'
|
||||
GROUP BY M_AdviceFisikID
|
||||
ORDER BY M_AdviceFisikLabel 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_advice_fisik 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 lookupadvicebyid(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$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(Nat_AdvicefisikID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_fisik ON Nat_AdviceID = Nat_AdvicefisikNat_AdviceID AND Nat_AdvicefisikM_AdviceFisikID = $id AND Nat_AdvicefisikIsActive = 'Y'
|
||||
LEFT JOIN m_advice_fisik ON Nat_AdvicefisikM_AdviceFisikID = M_AdviceFisikID AND M_AdviceFisikIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' GROUP BY Nat_AdviceID) a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $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("nat_advice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(select Nat_AdviceID as id,
|
||||
Nat_AdviceID,
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdvicefisikID,
|
||||
M_AdviceFisikCode,
|
||||
M_AdviceFisikLabel,
|
||||
Nat_AdvicefisikM_AdviceFisikID,
|
||||
Nat_AdvicefisikNat_AdviceID,
|
||||
IF(IFNULL(Nat_AdvicefisikID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_fisik ON Nat_AdviceID = Nat_AdvicefisikNat_AdviceID AND Nat_AdvicefisikM_AdviceFisikID = $id AND Nat_AdvicefisikIsActive = 'Y'
|
||||
LEFT JOIN m_advice_fisik ON Nat_AdvicefisikM_AdviceFisikID = M_AdviceFisikID AND M_AdviceFisikIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y') a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $filter
|
||||
GROUP BY Nat_AdviceID
|
||||
ORDER BY Nat_AdviceID 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("nat_advice 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 listingadvice(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'";
|
||||
// $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("nat_advice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'
|
||||
ORDER BY Nat_AdviceID 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("nat_advice 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 *
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM m_advice_fisiktype
|
||||
WHERE
|
||||
M_AdviceFisikTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['normalvaluetypees'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['flages'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['ageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['minageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['maxageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 0 as Nat_SexID, 'Semua' as Nat_SexName
|
||||
UNION
|
||||
SELECT Nat_SexID, Nat_SexName
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_sexs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 0 as Nat_FlagID, 'Semua' as Nat_FlagName
|
||||
UNION
|
||||
SELECT Nat_FlagID, Nat_FlagName
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows['f_flags'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$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 addnewfisik()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into m_advice_fisik(
|
||||
M_AdviceFisikCode,
|
||||
M_AdviceFisikLabel,
|
||||
M_AdviceFisikUserID,
|
||||
M_AdviceFisikCreated,
|
||||
M_AdviceFisikLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_advice_fisik 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 editfisik(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE m_advice_fisik SET
|
||||
M_AdviceFisikCode = '{$prm['code']}',
|
||||
M_AdviceFisikLabel = '{$prm['name']}',
|
||||
M_AdviceFisikUserID = {$userid}
|
||||
WHERE
|
||||
M_AdviceFisikID = {$prm['id']}
|
||||
";
|
||||
|
||||
//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 addnewadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$fisikid = $prm['fisikid'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into nat_advice(
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdviceUserID,
|
||||
Nat_AdviceCreated,
|
||||
Nat_AdviceLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$adviceina,
|
||||
$adviceeng,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_advice_fisik 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 saveaddeditadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$fisikid = $prm['fisikid'];
|
||||
$adviceid = $prm['Nat_AdviceID'];
|
||||
$advicefisikid = $prm['Nat_AdvicefisikID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($status == 'Y'){
|
||||
$sql = "insert into nat_advice_fisik(
|
||||
Nat_AdvicefisikM_AdviceFisikID,
|
||||
Nat_AdvicefisikNat_AdviceID,
|
||||
Nat_AdvicefisikUserID,
|
||||
Nat_AdvicefisikCreated,
|
||||
Nat_AdvicefisikLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$fisikid,
|
||||
$adviceid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_fisik 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 nat_advice_fisik SET
|
||||
Nat_AdvicefisikIsActive = 'N',
|
||||
Nat_AdvicefisikUserID = ?,
|
||||
Nat_AdvicefisikCreated = now(),
|
||||
Nat_AdvicefisikLastUpdated = now()
|
||||
WHERE Nat_AdvicefisikID = ?";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$advicefisikid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_fisik 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 saveeditsaran(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE nat_advice SET
|
||||
Nat_AdviceIna = '{$prm['ina']}',
|
||||
Nat_AdviceEng = '{$prm['eng']}',
|
||||
Nat_AdviceIsActive = '{$prm['status']}',
|
||||
Nat_AdviceUserID = {$userid}
|
||||
WHERE
|
||||
Nat_AdviceID = {$prm['id']}
|
||||
";
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
function savealladvice(){
|
||||
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 nat_advice_fisik SET
|
||||
Nat_AdvicefisikM_AdviceFisikID = '{$v['Nat_AdvicefisikM_AdviceFisikID']}',
|
||||
Nat_AdvicefisikAdviceIna = '{$v['Nat_AdvicefisikAdviceIna']}',
|
||||
Nat_AdvicefisikAdviceEng = '{$v['Nat_AdvicefisikAdviceEng']}',
|
||||
Nat_AdvicefisikUserID = {$userid},
|
||||
Nat_AdvicefisikCreated = now(),
|
||||
Nat_AdvicefisikLastUpdated = now()
|
||||
WHERE Nat_AdvicefisikID = {$v['Nat_AdvicefisikID']}";
|
||||
|
||||
//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 deletefisik()
|
||||
{
|
||||
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_advice_fisik SET
|
||||
M_AdviceFisikIsActive = 'N'
|
||||
WHERE
|
||||
M_AdviceFisikID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_advice_fisik delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update nat_advice_fisik SET
|
||||
Nat_AdvicefisikIsActive = 'N'
|
||||
WHERE
|
||||
Nat_AdvicefisikM_AdviceFisikID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_fisik 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 deleteadvice()
|
||||
{
|
||||
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_advice_fisik SET
|
||||
M_AdviceFisikIsActive = 'N'
|
||||
WHERE
|
||||
M_AdviceFisikID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_advice_fisik 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 searchfisik(){
|
||||
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 searchfisikbyname(){
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
966
one-api/application/controllers/v1/masterdata/Antibiotic.php
Normal file
966
one-api/application/controllers/v1/masterdata/Antibiotic.php
Normal file
@@ -0,0 +1,966 @@
|
||||
<?php
|
||||
|
||||
class Antibiotic extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "ANTIBIOTIC API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev =$this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupantibioticbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$bacteria = $prm['bacteria'];
|
||||
$antibiotic = $prm['antibiotic'];;
|
||||
$all = $prm['all'];
|
||||
$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 t_antibiotic
|
||||
JOIN t_bacteria ON T_AntibioticT_BacteriaID = T_BacteriaID AND T_BacteriaIsActive = 'Y'
|
||||
WHERE
|
||||
T_BacteriaName LIKE CONCAT('%','{$bacteria}','%') AND
|
||||
T_AntibioticIsActive = 'Y' GROUP BY T_AntibioticID) 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("t_antibiotic count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_AntibioticID as id,
|
||||
T_AntibioticName as name,
|
||||
T_BacteriaID,
|
||||
T_BacteriaName,
|
||||
t_antibiotic.*,
|
||||
CONCAT(T_AntibioticMinValueR,' - ',T_AntibioticMaxValueR) as descR,
|
||||
CONCAT(T_AntibioticMinValueS,' - ',T_AntibioticMaxValueS) as descS,
|
||||
CONCAT(T_AntibioticMinValueI,' - ',T_AntibioticMaxValueI) as descI
|
||||
from t_antibiotic
|
||||
JOIN t_bacteria ON T_AntibioticT_BacteriaID = T_BacteriaID AND T_BacteriaIsActive = 'Y'
|
||||
WHERE
|
||||
T_BacteriaName LIKE CONCAT('%','{$bacteria}','%') AND
|
||||
T_AntibioticName LIKE CONCAT('%','{$antibiotic}','%') AND
|
||||
T_AntibioticIsActive = 'Y'
|
||||
GROUP BY T_AntibioticID
|
||||
ORDER BY T_BacteriaName ASC, T_AntibioticName 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("t_antibiotic 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 lookupbacteriabyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$bacteria = $prm['bacteria'];
|
||||
$antibiotic = $prm['antibiotic'];
|
||||
$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 t_bacteria
|
||||
LEFT JOIN t_antibiotic ON T_BacteriaID = T_AntibioticT_BacteriaID AND T_AntibioticIsActive = 'Y'
|
||||
where
|
||||
T_BacteriaName LIKE CONCAT('%','{$bacteria}','%') AND
|
||||
IFNULL(T_AntibioticName,'') LIKE CONCAT('%','{$antibiotic}','%') AND
|
||||
T_BacteriaIsActive = 'Y'
|
||||
GROUP BY T_BacteriaID) a";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$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("t_bacteria count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_BacteriaID as id,
|
||||
T_BacteriaName as name,
|
||||
T_BacteriaName as namex,
|
||||
t_bacteria.*
|
||||
from t_bacteria
|
||||
LEFT JOIN t_antibiotic ON T_BacteriaID = T_AntibioticT_BacteriaID AND T_AntibioticIsActive = 'Y'
|
||||
where
|
||||
T_BacteriaName LIKE CONCAT('%','{$bacteria}','%') AND
|
||||
IFNULL(T_AntibioticName,'') LIKE CONCAT('%','{$antibiotic}','%') AND
|
||||
T_BacteriaIsActive = 'Y'
|
||||
GROUP BY T_BacteriaID
|
||||
ORDER BY T_BacteriaName 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("t_bacteria 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 addnewbacteria()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$sql = "insert into t_bacteria(
|
||||
T_BacteriaName,
|
||||
T_BacteriaCreated,
|
||||
T_BacteriaLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bacteria insert");
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editbacteria()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sqlcompany = "update t_bacteria SET
|
||||
T_BacteriaName = ?,
|
||||
T_BacteriaLastUpdated = now()
|
||||
where
|
||||
T_BacteriaID = ?
|
||||
";
|
||||
$querycompany = $this->db_onedev->query($sqlcompany,
|
||||
array(
|
||||
$name,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("t_bacteria update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function addnewantibiotic()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$bacteriaid = $prm['bacteriaid'];
|
||||
$T_AntibioticName = $prm['T_AntibioticName'];
|
||||
$T_AntibioticMinValueR = $prm['T_AntibioticMinValueR'];
|
||||
$T_AntibioticMaxValueR = $prm['T_AntibioticMaxValueR'];
|
||||
$T_AntibioticMinInclusiveR = $prm['T_AntibioticMinInclusiveR'];
|
||||
$T_AntibioticMaxInclusiveR = $prm['T_AntibioticMaxInclusiveR'];
|
||||
$T_AntibioticNoteR = $prm['T_AntibioticNoteR'];
|
||||
$T_AntibioticMinValueS = $prm['T_AntibioticMinValueS'];
|
||||
$T_AntibioticMaxValueS = $prm['T_AntibioticMaxValueS'];
|
||||
$T_AntibioticMinInclusiveS = $prm['T_AntibioticMinInclusiveS'];
|
||||
$T_AntibioticMaxInclusiveS = $prm['T_AntibioticMaxInclusiveS'];
|
||||
$T_AntibioticNoteS = $prm['T_AntibioticNoteS'];
|
||||
$T_AntibioticMinValueI = $prm['T_AntibioticMinValueI'];
|
||||
$T_AntibioticMaxValueI = $prm['T_AntibioticMaxValueI'];
|
||||
$T_AntibioticMinInclusiveI = $prm['T_AntibioticMinInclusiveI'];
|
||||
$T_AntibioticMaxInclusiveI = $prm['T_AntibioticMaxInclusiveI'];
|
||||
$T_AntibioticNoteI = $prm['T_AntibioticNoteI'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($bacteriaid == 0){
|
||||
$errors = array();
|
||||
if($bacteriaid == 0){
|
||||
array_push($errors,array('field'=>'bacteria','msg'=>'Bakteri dipilih dulu dong'));
|
||||
}
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
if($prm['xid'] == 0){
|
||||
$sql = "insert into t_antibiotic(
|
||||
T_AntibioticName,
|
||||
T_AntibioticT_BacteriaID,
|
||||
T_AntibioticMinValueR,
|
||||
T_AntibioticMaxValueR,
|
||||
T_AntibioticMinInclusiveR,
|
||||
T_AntibioticMaxInclusiveR,
|
||||
T_AntibioticNoteR,
|
||||
T_AntibioticMinValueS,
|
||||
T_AntibioticMaxValueS,
|
||||
T_AntibioticMinInclusiveS,
|
||||
T_AntibioticMaxInclusiveS,
|
||||
T_AntibioticNoteS,
|
||||
T_AntibioticMinValueI,
|
||||
T_AntibioticMaxValueI,
|
||||
T_AntibioticMinInclusiveI,
|
||||
T_AntibioticMaxInclusiveI,
|
||||
T_AntibioticNoteI,
|
||||
T_AntibioticUserID,
|
||||
T_AntibioticCreated,
|
||||
T_AntibioticLastUpdated)
|
||||
values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$T_AntibioticName,
|
||||
$bacteriaid,
|
||||
$T_AntibioticMinValueR,
|
||||
$T_AntibioticMaxValueR,
|
||||
$T_AntibioticMinInclusiveR,
|
||||
$T_AntibioticMaxInclusiveR,
|
||||
$T_AntibioticNoteR,
|
||||
$T_AntibioticMinValueS,
|
||||
$T_AntibioticMaxValueS,
|
||||
$T_AntibioticMinInclusiveS,
|
||||
$T_AntibioticMaxInclusiveS,
|
||||
$T_AntibioticNoteS,
|
||||
$T_AntibioticMinValueI,
|
||||
$T_AntibioticMaxValueI,
|
||||
$T_AntibioticMinInclusiveI,
|
||||
$T_AntibioticMaxInclusiveI,
|
||||
$T_AntibioticNoteI,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_antibiotic 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 t_antibiotic SET T_AntibioticT_BacteriaID = '{$bacteriaid}',
|
||||
T_AntibioticName = '{$T_AntibioticName}',
|
||||
T_AntibioticMinValueR = '{$T_AntibioticMinValueR}',
|
||||
T_AntibioticMaxValueR = '{$T_AntibioticMaxValueR}',
|
||||
T_AntibioticMinInclusiveR = '{$T_AntibioticMinInclusiveR}',
|
||||
T_AntibioticMaxInclusiveR = '{$T_AntibioticMaxInclusiveR}',
|
||||
T_AntibioticNoteR = '{$T_AntibioticNoteR}',
|
||||
T_AntibioticMinValueS = '{$T_AntibioticMinValueS}',
|
||||
T_AntibioticMaxValueS = '{$T_AntibioticMaxValueS}',
|
||||
T_AntibioticMinInclusiveS = '{$T_AntibioticMinInclusiveS}',
|
||||
T_AntibioticMaxInclusiveS = '{$T_AntibioticMaxInclusiveS}',
|
||||
T_AntibioticNoteS = '{$T_AntibioticNoteS}',
|
||||
T_AntibioticMinValueI = '{$T_AntibioticMinValueI}',
|
||||
T_AntibioticMaxValueI = '{$T_AntibioticMaxValueI}',
|
||||
T_AntibioticMinInclusiveI = '{$T_AntibioticMinInclusiveI}',
|
||||
T_AntibioticMaxInclusiveI = '{$T_AntibioticMaxInclusiveI}',
|
||||
T_AntibioticNoteI = '{$T_AntibioticNoteI}',
|
||||
T_AntibioticUserID = '{$userid}',
|
||||
T_AntibioticLastUpdated = now()
|
||||
WHERE T_AntibioticID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function deletebacteria()
|
||||
{
|
||||
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 t_bacteria SET
|
||||
T_BacteriaIsActive = 'N',
|
||||
T_BacteriaLastUpdated = now()
|
||||
WHERE
|
||||
T_BacteriaID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bacteria delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update t_antibiotic SET
|
||||
T_AntibioticIsActive = 'N',
|
||||
T_AntibioticLastUpdated = now()
|
||||
WHERE
|
||||
T_AntibioticT_BacteriaID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_antibiotic 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 deleteantibiotic()
|
||||
{
|
||||
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 t_antibiotic SET
|
||||
T_AntibioticIsActive = 'N',
|
||||
T_AntibioticLastUpdated = now()
|
||||
WHERE
|
||||
T_AntibioticID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_antibiotic 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 searchbacteria(){
|
||||
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_bacteria
|
||||
WHERE
|
||||
T_BacteriaName like ?
|
||||
AND T_BacteriaIsActive = '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_bacteria count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT T_BacteriaID, T_BacteriaName
|
||||
FROM t_bacteria
|
||||
WHERE
|
||||
T_BacteriaName like ?
|
||||
AND T_BacteriaIsActive = 'Y'
|
||||
ORDER BY T_BacteriaName 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_bacteria rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchbacteriabyname(){
|
||||
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_bacteria
|
||||
WHERE
|
||||
T_BacteriaName like ?
|
||||
AND T_BacteriaIsActive = '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_bacteria count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT T_BacteriaID, T_BacteriaName
|
||||
FROM t_bacteria
|
||||
WHERE
|
||||
T_BacteriaName like ?
|
||||
AND T_BacteriaIsActive = 'Y'
|
||||
ORDER BY T_BacteriaName 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_bacteria 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 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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function searchdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictM_CityID = '{$id}'
|
||||
AND M_DistrictIsActive = '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_district count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictM_CityID = '{$id}'
|
||||
AND M_DistrictIsActive = 'Y'
|
||||
ORDER BY M_DistrictName 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("m_district rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = '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_district count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = 'Y'
|
||||
ORDER BY M_KelurahanName 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("m_district rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcompany(){
|
||||
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_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = '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_company count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName 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("m_company rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchmou(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = '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_mou count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = 'Y'
|
||||
ORDER BY M_MouName 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("m_mou rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
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(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?";
|
||||
$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 M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?
|
||||
ORDER BY M_DoctorName 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("m_doctor rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function selectaddressdoctor(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query ="SELECT M_DoctorAddressID,
|
||||
CONCAT(M_DoctorAddressNote, ': ',M_DoctorAddressDescription) as M_DoctorAddressNote
|
||||
FROM
|
||||
m_doctoraddress
|
||||
WHERE M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = '{$id}'";
|
||||
//echo $query;
|
||||
$rows['addressdoctors'] = $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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,777 @@
|
||||
<?php
|
||||
|
||||
class Autoverificationv2 extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "AUTO VERIFICATION API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookuptrendanalys(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select nat_trend_analysis.*,Nat_TestID as testid
|
||||
from nat_trend_analysis
|
||||
JOIN nat_test ON Nat_TrendAnalysisNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
|
||||
where
|
||||
Nat_TrendAnalysisNat_TestID = {$id} AND Nat_TrendAnalysisIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_regional->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_trend_analysis select");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function lookuphasil(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select Nat_MultiruleID as id, M_ValueName as name, Nat_MultiruleM_ValueID as hasilid, Nat_MultiruleNat_TestID as testid
|
||||
from nat_multirule
|
||||
JOIN m_value ON Nat_MultiruleM_ValueID = M_ValueID AND M_ValueIsActive = 'Y'
|
||||
where
|
||||
Nat_MultiruleNat_TestID = {$id} AND Nat_MultiruleIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_regional->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_multirule");
|
||||
exit;
|
||||
}
|
||||
$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 nat_test
|
||||
LEFT JOIN nat_trend_analysis ON Nat_TestID = Nat_TrendAnalysisNat_TestID
|
||||
LEFT JOIN nat_delta_check ON Nat_TestID = Nat_DeltaCheckNat_TestID
|
||||
where
|
||||
Nat_TestIsActive = 'Y' AND
|
||||
Nat_TestIsQuantitative = 'Y' AND
|
||||
Nat_TestIsResult = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select Nat_TestID as id, CONCAT(Nat_TestName,' ' ,'[ ',Nat_TestCode,' ]') as name,
|
||||
Nat_TrendAnalysisNat_TestID,Nat_TrendAnalysisMinCount,Nat_TrendAnalysisLow,
|
||||
Nat_TrendAnalysisHigh,
|
||||
nat_delta_check.*, M_TimeName as xtime, Nat_DeltaTypeName as xdif,Nat_TestIsDeltaCheck,Nat_TestIsTrendAnalysis
|
||||
from nat_test
|
||||
LEFT JOIN nat_trend_analysis ON Nat_TestID = Nat_TrendAnalysisNat_TestID
|
||||
LEFT JOIN nat_delta_check ON Nat_TestID = Nat_DeltaCheckNat_TestID
|
||||
LEFT JOIN m_time ON Nat_DeltaCheckM_TimeID = M_TimeID
|
||||
LEFT JOIN nat_delta_type ON Nat_DeltaCheckNat_DeltaTypeID = Nat_DeltaTypeID
|
||||
where
|
||||
(Nat_TestName LIKE CONCAT('%','{$search}','%') OR Nat_TestCode LIKE CONCAT('%','{$search}','%')) AND
|
||||
Nat_TestIsActive = 'Y' AND
|
||||
Nat_TestIsQuantitative = 'Y' AND
|
||||
(Nat_TestIsDeltaCheck = 'Y' OR Nat_TestIsTrendAnalysis = 'Y') $limit";
|
||||
// echo $sql;
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_regional->query($sql,$sql_param);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("nat_test 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 addnewschedule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name_schedule = $prm['name'];
|
||||
$query = "SELECT COUNT(*) as exist FROM m_schedule WHERE M_ScheduleIsActive = 'Y' AND M_ScheduleName = '{$name_schedule}'";
|
||||
$exist_name = $this->db_regional->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
$sql = "insert into m_schedule(
|
||||
M_ScheduleName,
|
||||
M_ScheduleCreated,
|
||||
M_ScheduleLastUpdated
|
||||
)
|
||||
values( ?,now(),now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$name_schedule
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedule insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$result = array ("total" => -1, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editschedule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_schedule = $prm['id'];
|
||||
$name_schedule = $prm['name'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM m_schedule WHERE M_ScheduleIsActive = 'Y' AND M_ScheduleName = '{$name_schedule}' AND M_ScheduleID <> {$id_schedule}";
|
||||
$exist_name = $this->db_regional->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
$sql = "update m_schedule SET
|
||||
M_ScheduleName = ?,
|
||||
M_ScheduleLastUpdated = now()
|
||||
where
|
||||
M_ScheduleID = ?
|
||||
";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$name_schedule,
|
||||
$id_schedule
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedule update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_schedule));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$result = array ("total" => -1, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function savetrendanalys()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$testid = $prm['testid'];
|
||||
$mintest = $prm['mintest'];
|
||||
$islow = $prm['islow'];
|
||||
$ishigh = $prm['ishigh'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_trend_analysis WHERE Nat_TrendAnalysisIsActive = 'Y' AND Nat_TrendAnalysisNat_TestID = '{$testid}'";
|
||||
$exisnat_test = $this->db_regional->query($query)->row()->exist;
|
||||
if($exisnat_test == 0){
|
||||
$sql = "insert into nat_trend_analysis(
|
||||
Nat_TrendAnalysisNat_TestID,
|
||||
Nat_TrendAnalysisMinCount,
|
||||
Nat_TrendAnalysisLow,
|
||||
Nat_TrendAnalysisHigh,
|
||||
Nat_TrendAnalysisCreated,
|
||||
Nat_TrendAnalysisLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,now(),now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$mintest,
|
||||
$islow,
|
||||
$ishigh
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_trend_analysis insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$sql = "update nat_trend_analysis SET
|
||||
Nat_TrendAnalysisMinCount = ?,
|
||||
Nat_TrendAnalysisLow = ?,
|
||||
Nat_TrendAnalysisHigh = ?,
|
||||
Nat_TrendAnalysisLastUpdated = now()
|
||||
WHERE
|
||||
Nat_TrendAnalysisIsActive = 'Y' AND
|
||||
Nat_TrendAnalysisNat_TestID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$mintest,
|
||||
$islow,
|
||||
$ishigh,
|
||||
$testid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_trend_analysis 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 savedeltacheck()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$testid = $prm['testid'];
|
||||
$differenceid = $prm['differenceid'];
|
||||
$validinterval = $prm['validinterval'];
|
||||
$timeid = $prm['timeid'];
|
||||
$minvalue = $prm['minvalue'];
|
||||
$maxvalue = $prm['maxvalue'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_delta_check WHERE Nat_DeltaCheckIsActive = 'Y' AND Nat_DeltaCheckNat_TestID = '{$testid}'";
|
||||
$exisnat_test = $this->db_regional->query($query)->row()->exist;
|
||||
if($exisnat_test == 0){
|
||||
$sql = "insert into nat_delta_check(
|
||||
Nat_DeltaCheckNat_TestID,
|
||||
Nat_DeltaCheckNat_DeltaTypeID,
|
||||
Nat_DeltaCheckInterval,
|
||||
Nat_DeltaCheckM_TimeID,
|
||||
Nat_DeltaCheckMinValue,
|
||||
Nat_DeltaCheckMaxValue,
|
||||
Nat_DeltaCheckCreated,
|
||||
Nat_DeltaCheckLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,?,?,now(),now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$differenceid,
|
||||
$validinterval,
|
||||
$timeid,
|
||||
$minvalue,
|
||||
$maxvalue
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_delta_check insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$sql = "update nat_delta_check SET
|
||||
Nat_DeltaCheckNat_DeltaTypeID = ?,
|
||||
Nat_DeltaCheckInterval = ?,
|
||||
Nat_DeltaCheckM_TimeID = ?,
|
||||
Nat_DeltaCheckMinValue = ?,
|
||||
Nat_DeltaCheckMaxValue = ?,
|
||||
Nat_DeltaCheckLastUpdated = now()
|
||||
WHERE
|
||||
Nat_DeltaCheckIsActive = 'Y' AND
|
||||
Nat_DeltaCheckNat_TestID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$differenceid,
|
||||
$validinterval,
|
||||
$timeid,
|
||||
$minvalue,
|
||||
$maxvalue,
|
||||
$testid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_delta_check update");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function selectvaluex(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_value
|
||||
WHERE
|
||||
M_ValueIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['valuexs'] = $this->db_regional->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 selecttime(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_time
|
||||
WHERE
|
||||
M_TimeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['times'] = $this->db_regional->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 selectdif(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_delta_type
|
||||
WHERE
|
||||
Nat_DeltaTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['difs'] = $this->db_regional->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);
|
||||
}
|
||||
|
||||
}
|
||||
public function savemultirule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$testid = $prm['testid'];
|
||||
$hasilid = $prm['hasilid'];
|
||||
|
||||
$sql = "insert into nat_multirule(
|
||||
Nat_MultiruleNat_TestID,
|
||||
Nat_MultiruleM_ValueID,
|
||||
Nat_MultiruleCreated,
|
||||
Nat_MultiruleLastUpdated
|
||||
)
|
||||
values( ?,?,now(),now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$hasilid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_multirule insert");
|
||||
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 deleteschedulepromise()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_schedulepromise SET
|
||||
M_SchedulePromiseIsActive = 'N',
|
||||
M_SchedulePromiseLastUpdate = now()
|
||||
WHERE
|
||||
M_SchedulePromiseID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedulepromise 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 deletescheduletest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_scheduletest SET
|
||||
M_ScheduleTestIsActive = 'N',
|
||||
M_ScheduleTestLastUpdated = now()
|
||||
WHERE
|
||||
M_ScheduleTestID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_scheduletest 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 deleteschedule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_schedule SET
|
||||
M_ScheduleIsActive = 'N',
|
||||
M_ScheduleLastUpdated = now()
|
||||
WHERE
|
||||
M_ScheduleID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedule delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update m_scheduletest SET
|
||||
M_ScheduleTestIsActive = 'N',
|
||||
M_ScheduleTestLastUpdated = now()
|
||||
WHERE
|
||||
M_ScheduleTestM_ScheduleID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_scheduletest delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update m_schedulepromise SET
|
||||
M_SchedulePromiseIsActive = 'N',
|
||||
M_SchedulePromiseLastUpdate = now()
|
||||
WHERE
|
||||
M_SchedulePromiseM_ScheduleID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedulepromise 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 searchtest()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$scheduleid = $prm['id'];
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM nat_test
|
||||
LEFT JOIN m_scheduletest ON M_ScheduleTestNat_TestID = Nat_TestID AND M_ScheduleTestM_ScheduleID = ? AND M_ScheduleTestIsActive = 'Y'
|
||||
WHERE
|
||||
ISNULL(M_ScheduleTestID) AND
|
||||
|
||||
Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestName like ?";
|
||||
$query = $this->db_regional->query($sql,array($scheduleid,$q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_test count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_TestID as id,
|
||||
Nat_TestName as name
|
||||
FROM nat_test
|
||||
LEFT JOIN m_scheduletest ON M_ScheduleTestNat_TestID = Nat_TestID AND M_ScheduleTestM_ScheduleID = ? AND M_ScheduleTestIsActive = 'Y'
|
||||
WHERE
|
||||
ISNULL(M_ScheduleTestID) AND
|
||||
Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestName like ?
|
||||
ORDER BY Nat_TestCode ASC
|
||||
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($scheduleid,$q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_test rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,789 @@
|
||||
<?php
|
||||
|
||||
class Autoverificationv3 extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "AUTO VERIFICATION API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookuptrendanalys(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select nat_trend_analysis.*,Nat_TestID as testid
|
||||
from nat_trend_analysis
|
||||
JOIN nat_test ON Nat_TrendAnalysisNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
|
||||
where
|
||||
Nat_TrendAnalysisNat_TestID = {$id} AND Nat_TrendAnalysisIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_regional->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_trend_analysis select");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function lookuphasil(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select Nat_MultiruleID as id, M_ValueName as name, Nat_MultiruleM_ValueID as hasilid, Nat_MultiruleNat_TestID as testid
|
||||
from nat_multirule
|
||||
JOIN m_value ON Nat_MultiruleM_ValueID = M_ValueID AND M_ValueIsActive = 'Y'
|
||||
where
|
||||
Nat_MultiruleNat_TestID = {$id} AND Nat_MultiruleIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_regional->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_multirule");
|
||||
exit;
|
||||
}
|
||||
$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 nat_test
|
||||
LEFT JOIN nat_trend_analysis ON Nat_TestID = Nat_TrendAnalysisNat_TestID
|
||||
LEFT JOIN nat_delta_check ON Nat_TestID = Nat_DeltaCheckNat_TestID
|
||||
where
|
||||
Nat_TestIsActive = 'Y' AND
|
||||
Nat_TestIsQuantitative = 'Y' AND
|
||||
Nat_TestIsResult = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select Nat_TestID as id, CONCAT(Nat_TestName,' ' ,'[ ',Nat_TestCode,' ]') as name,
|
||||
Nat_TrendAnalysisNat_TestID,Nat_TrendAnalysisMinCount,Nat_TrendAnalysisLow,
|
||||
Nat_TrendAnalysisHigh,
|
||||
Nat_DeltaCheckID,
|
||||
Nat_DeltaCheckNat_TestID,
|
||||
Nat_DeltaCheckNat_DeltaTypeID,
|
||||
Nat_DeltaCheckInterval,
|
||||
Nat_DeltaCheckM_TimeID,
|
||||
Nat_DeltaCheckMinValue,
|
||||
Nat_DeltaCheckMaxValue,
|
||||
IFNULL(Nat_DeltaCheckHaveDeltaCheck,'Y') as Nat_DeltaCheckHaveDeltaCheck, M_TimeName as xtime, Nat_DeltaTypeName as xdif,Nat_TestIsDeltaCheck,Nat_TestIsTrendAnalysis
|
||||
from nat_test
|
||||
LEFT JOIN nat_trend_analysis ON Nat_TestID = Nat_TrendAnalysisNat_TestID
|
||||
LEFT JOIN nat_delta_check ON Nat_TestID = Nat_DeltaCheckNat_TestID
|
||||
LEFT JOIN m_time ON Nat_DeltaCheckM_TimeID = M_TimeID
|
||||
LEFT JOIN nat_delta_type ON Nat_DeltaCheckNat_DeltaTypeID = Nat_DeltaTypeID
|
||||
where
|
||||
(Nat_TestName LIKE CONCAT('%','{$search}','%') OR Nat_TestCode LIKE CONCAT('%','{$search}','%')) AND
|
||||
Nat_TestIsActive = 'Y' AND
|
||||
Nat_TestIsQuantitative = 'Y' AND
|
||||
(Nat_TestIsDeltaCheck = 'Y' OR Nat_TestIsTrendAnalysis = 'Y') $limit";
|
||||
// echo $sql;
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_regional->query($sql,$sql_param);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("nat_test 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 addnewschedule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name_schedule = $prm['name'];
|
||||
$query = "SELECT COUNT(*) as exist FROM m_schedule WHERE M_ScheduleIsActive = 'Y' AND M_ScheduleName = '{$name_schedule}'";
|
||||
$exist_name = $this->db_regional->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
$sql = "insert into m_schedule(
|
||||
M_ScheduleName,
|
||||
M_ScheduleCreated,
|
||||
M_ScheduleLastUpdated
|
||||
)
|
||||
values( ?,now(),now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$name_schedule
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedule insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$result = array ("total" => -1, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editschedule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_schedule = $prm['id'];
|
||||
$name_schedule = $prm['name'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM m_schedule WHERE M_ScheduleIsActive = 'Y' AND M_ScheduleName = '{$name_schedule}' AND M_ScheduleID <> {$id_schedule}";
|
||||
$exist_name = $this->db_regional->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
$sql = "update m_schedule SET
|
||||
M_ScheduleName = ?,
|
||||
M_ScheduleLastUpdated = now()
|
||||
where
|
||||
M_ScheduleID = ?
|
||||
";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$name_schedule,
|
||||
$id_schedule
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedule update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_schedule));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$result = array ("total" => -1, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function savetrendanalys()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$testid = $prm['testid'];
|
||||
$mintest = $prm['mintest'];
|
||||
$islow = $prm['islow'];
|
||||
$ishigh = $prm['ishigh'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_trend_analysis WHERE Nat_TrendAnalysisIsActive = 'Y' AND Nat_TrendAnalysisNat_TestID = '{$testid}'";
|
||||
$exisnat_test = $this->db_regional->query($query)->row()->exist;
|
||||
if($exisnat_test == 0){
|
||||
$sql = "insert into nat_trend_analysis(
|
||||
Nat_TrendAnalysisNat_TestID,
|
||||
Nat_TrendAnalysisMinCount,
|
||||
Nat_TrendAnalysisLow,
|
||||
Nat_TrendAnalysisHigh,
|
||||
Nat_TrendAnalysisCreated,
|
||||
Nat_TrendAnalysisLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,now(),now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$mintest,
|
||||
$islow,
|
||||
$ishigh
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_trend_analysis insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$sql = "update nat_trend_analysis SET
|
||||
Nat_TrendAnalysisMinCount = ?,
|
||||
Nat_TrendAnalysisLow = ?,
|
||||
Nat_TrendAnalysisHigh = ?,
|
||||
Nat_TrendAnalysisLastUpdated = now()
|
||||
WHERE
|
||||
Nat_TrendAnalysisIsActive = 'Y' AND
|
||||
Nat_TrendAnalysisNat_TestID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$mintest,
|
||||
$islow,
|
||||
$ishigh,
|
||||
$testid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_trend_analysis 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 savedeltacheck()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$testid = $prm['testid'];
|
||||
$differenceid = $prm['differenceid'];
|
||||
$validinterval = $prm['validinterval'];
|
||||
$timeid = $prm['timeid'];
|
||||
$minvalue = $prm['minvalue'];
|
||||
$maxvalue = $prm['maxvalue'];
|
||||
$havedeltacheck = $prm['havedeltacheck'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_delta_check WHERE Nat_DeltaCheckIsActive = 'Y' AND Nat_DeltaCheckNat_TestID = '{$testid}'";
|
||||
$exisnat_test = $this->db_regional->query($query)->row()->exist;
|
||||
if($exisnat_test == 0){
|
||||
$sql = "insert into nat_delta_check(
|
||||
Nat_DeltaCheckNat_TestID,
|
||||
Nat_DeltaCheckNat_DeltaTypeID,
|
||||
Nat_DeltaCheckInterval,
|
||||
Nat_DeltaCheckM_TimeID,
|
||||
Nat_DeltaCheckMinValue,
|
||||
Nat_DeltaCheckMaxValue,
|
||||
Nat_DeltaCheckHaveDeltaCheck,
|
||||
Nat_DeltaCheckCreated,
|
||||
Nat_DeltaCheckLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,?,?,?,now(),now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$differenceid,
|
||||
$validinterval,
|
||||
$timeid,
|
||||
$minvalue,
|
||||
$maxvalue,
|
||||
$havedeltacheck
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_delta_check insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$sql = "update nat_delta_check SET
|
||||
Nat_DeltaCheckNat_DeltaTypeID = ?,
|
||||
Nat_DeltaCheckInterval = ?,
|
||||
Nat_DeltaCheckM_TimeID = ?,
|
||||
Nat_DeltaCheckMinValue = ?,
|
||||
Nat_DeltaCheckMaxValue = ?,
|
||||
Nat_DeltaCheckHaveDeltaCheck = ?,
|
||||
Nat_DeltaCheckLastUpdated = now()
|
||||
WHERE
|
||||
Nat_DeltaCheckIsActive = 'Y' AND
|
||||
Nat_DeltaCheckNat_TestID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$differenceid,
|
||||
$validinterval,
|
||||
$timeid,
|
||||
$minvalue,
|
||||
$maxvalue,
|
||||
$havedeltacheck,
|
||||
$testid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_delta_check update");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function selectvaluex(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_value
|
||||
WHERE
|
||||
M_ValueIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['valuexs'] = $this->db_regional->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 selecttime(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_time
|
||||
WHERE
|
||||
M_TimeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['times'] = $this->db_regional->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 selectdif(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_delta_type
|
||||
WHERE
|
||||
Nat_DeltaTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['difs'] = $this->db_regional->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);
|
||||
}
|
||||
|
||||
}
|
||||
public function savemultirule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$testid = $prm['testid'];
|
||||
$hasilid = $prm['hasilid'];
|
||||
|
||||
$sql = "insert into nat_multirule(
|
||||
Nat_MultiruleNat_TestID,
|
||||
Nat_MultiruleM_ValueID,
|
||||
Nat_MultiruleCreated,
|
||||
Nat_MultiruleLastUpdated
|
||||
)
|
||||
values( ?,?,now(),now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$hasilid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_multirule insert");
|
||||
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 deleteschedulepromise()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_schedulepromise SET
|
||||
M_SchedulePromiseIsActive = 'N',
|
||||
M_SchedulePromiseLastUpdate = now()
|
||||
WHERE
|
||||
M_SchedulePromiseID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedulepromise 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 deletescheduletest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_scheduletest SET
|
||||
M_ScheduleTestIsActive = 'N',
|
||||
M_ScheduleTestLastUpdated = now()
|
||||
WHERE
|
||||
M_ScheduleTestID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_scheduletest 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 deleteschedule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_schedule SET
|
||||
M_ScheduleIsActive = 'N',
|
||||
M_ScheduleLastUpdated = now()
|
||||
WHERE
|
||||
M_ScheduleID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedule delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update m_scheduletest SET
|
||||
M_ScheduleTestIsActive = 'N',
|
||||
M_ScheduleTestLastUpdated = now()
|
||||
WHERE
|
||||
M_ScheduleTestM_ScheduleID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_scheduletest delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update m_schedulepromise SET
|
||||
M_SchedulePromiseIsActive = 'N',
|
||||
M_SchedulePromiseLastUpdate = now()
|
||||
WHERE
|
||||
M_SchedulePromiseM_ScheduleID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedulepromise 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 searchtest()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$scheduleid = $prm['id'];
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM nat_test
|
||||
LEFT JOIN m_scheduletest ON M_ScheduleTestNat_TestID = Nat_TestID AND M_ScheduleTestM_ScheduleID = ? AND M_ScheduleTestIsActive = 'Y'
|
||||
WHERE
|
||||
ISNULL(M_ScheduleTestID) AND
|
||||
|
||||
Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestName like ?";
|
||||
$query = $this->db_regional->query($sql,array($scheduleid,$q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_test count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_TestID as id,
|
||||
Nat_TestName as name
|
||||
FROM nat_test
|
||||
LEFT JOIN m_scheduletest ON M_ScheduleTestNat_TestID = Nat_TestID AND M_ScheduleTestM_ScheduleID = ? AND M_ScheduleTestIsActive = 'Y'
|
||||
WHERE
|
||||
ISNULL(M_ScheduleTestID) AND
|
||||
Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestName like ?
|
||||
ORDER BY Nat_TestCode ASC
|
||||
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($scheduleid,$q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_test rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
523
one-api/application/controllers/v1/masterdata/Bahan.php
Normal file
523
one-api/application/controllers/v1/masterdata/Bahan.php
Normal file
@@ -0,0 +1,523 @@
|
||||
<?php
|
||||
|
||||
class Bahan extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "BAHAN API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
|
||||
function lookupsampletype(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select Nat_SampleTypeID as id,
|
||||
Nat_SampleTypeNat_BahanID as bahanid,
|
||||
Nat_SampleTypeCode as code,
|
||||
Nat_SampleTypeName as name,
|
||||
Nat_SampleTypeSuffix as suffix,
|
||||
'xxx' as action
|
||||
from nat_sampletype
|
||||
where
|
||||
Nat_SampleTypeNat_BahanID = {$id} AND Nat_SampleTypeIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_regional->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 nat_bahan
|
||||
where
|
||||
Nat_BahanIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select Nat_BahanID as id, Nat_BahanCode as code, Nat_BahanName as name, CONCAT('[ ',Nat_BahanCode,' ]',' ', Nat_BahanName) as description , 'xxx' as bahansampletype
|
||||
from nat_bahan
|
||||
where
|
||||
( Nat_BahanCode LIKE CONCAT('%','{$search}','%') OR
|
||||
Nat_BahanName LIKE CONCAT('%','{$search}','%')
|
||||
)AND
|
||||
Nat_BahanIsActive = 'Y' $limit";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("nat_bahan 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 addnewbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code_bahan = $prm['code'];
|
||||
$name_bahan = $prm['name'];
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanCode = '{$code_bahan}'";
|
||||
$exist_code = $this->db_regional->query($query)->row()->exist;
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanName = '{$name_bahan}'";
|
||||
$exist_name = $this->db_regional->query($query)->row()->exist;
|
||||
//echo $exist_name;
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "insert into nat_bahan(
|
||||
Nat_BahanCode,
|
||||
Nat_BahanName,
|
||||
Nat_BahanCreated,
|
||||
Nat_BahanLastUpdated
|
||||
)
|
||||
values( ?, ?, now(), now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$code_bahan,
|
||||
$name_bahan
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_bahan insert");
|
||||
exit;
|
||||
}
|
||||
$sql = "insert into t_bahan(
|
||||
T_BahanCode,
|
||||
T_BahanName,
|
||||
T_BahanCreated,
|
||||
T_BahanLastUpdated
|
||||
)
|
||||
values( ?, ?, now(), now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$code_bahan,
|
||||
$name_bahan
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
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 editbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_bahan = $prm['id'];
|
||||
$code_bahan = $prm['code'];
|
||||
$name_bahan = $prm['name'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanCode = '{$code_bahan}' AND Nat_BahanID <> {$id_bahan}";
|
||||
$exist_code = $this->db_regional->query($query)->row()->exist;
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanName = '{$name_bahan}' AND Nat_BahanID <> {$id_bahan}";
|
||||
$exist_name = $this->db_regional->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "update nat_bahan SET
|
||||
Nat_BahanCode = ?,
|
||||
Nat_BahanName = ?,
|
||||
Nat_BahanLastUpdated = now()
|
||||
where
|
||||
Nat_BahanID = ?
|
||||
";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$code_bahan,
|
||||
$name_bahan,
|
||||
$id_bahan
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_bahan update");
|
||||
exit;
|
||||
}
|
||||
$sql = "update t_bahan SET
|
||||
T_BahanCode = ?,
|
||||
T_BahanName = ?,
|
||||
T_BahanLastUpdated = now()
|
||||
where
|
||||
T_BahanID = ?
|
||||
";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$code_bahan,
|
||||
$name_bahan,
|
||||
$id_bahan
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_bahan));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
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 addnewsampletype()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$bahanid = $prm['bahanid'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$suffix = $prm['suffix'];
|
||||
//$agingonhold = $prm['agingonhold'];
|
||||
//$agingonholdtime = $prm['agingonholdtime'];
|
||||
// $sampleimgid = $prm['sampleimgid'];
|
||||
|
||||
|
||||
if($prm['xid'] == "0" || $prm['xid'] == 0){
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeCode = '{$code}'";
|
||||
$exist_code = $this->db_regional->query($query)->row()->exist;
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeName = '{$name}'";
|
||||
$exist_name = $this->db_regional->query($query)->row()->exist;
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "insert into nat_sampletype(
|
||||
Nat_SampleTypeNat_BahanID,
|
||||
Nat_SampleTypeCode,
|
||||
Nat_SampleTypeName,
|
||||
Nat_SampleTypeSuffix,
|
||||
Nat_SampleTypeCreated,
|
||||
Nat_SampleTypeLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,now(),now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$bahanid,
|
||||
$code,
|
||||
$name,
|
||||
$suffix
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_sampletype insert");
|
||||
exit;
|
||||
}
|
||||
$sql = "insert into t_sampletype(
|
||||
T_SampleTypeT_BahanID,
|
||||
T_SampleTypeCode,
|
||||
T_SampleTypeName,
|
||||
T_SampleTypeSuffix,
|
||||
T_SampleTypeCreated,
|
||||
T_SampleTypeLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,now(),now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$bahanid,
|
||||
$code,
|
||||
$name,
|
||||
$suffix
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_sampletype insert");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
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 nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeCode = '{$code}' AND Nat_SampleTypeID <> {$prm['xid']}";
|
||||
$exist_code = $this->db_regional->query($query)->row()->exist;
|
||||
//echo $query;
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeName = '{$name}' AND Nat_SampleTypeID <> {$prm['xid']}";
|
||||
$exist_name = $this->db_regional->query($query)->row()->exist;
|
||||
//echo $query;
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "UPDATE nat_sampletype SET Nat_SampleTypeCode = '{$code}', Nat_SampleTypeName = '{$name}', Nat_SampleTypeSuffix = '{$suffix}' WHERE Nat_SampleTypeID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
|
||||
$sqllocal = "UPDATE t_sampletype SET T_SampleTypeCode = '{$code}', T_SampleTypeName = '{$name}', T_SampleTypeSuffix = '{$suffix}' WHERE T_SampleTypeID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$querylocal = $this->db_regional->query($sqllocal);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
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 deletesampletype()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update nat_sampletype SET
|
||||
Nat_SampleTypeIsActive = 'N',
|
||||
Nat_SampleTypeLastUpdated = now()
|
||||
WHERE
|
||||
Nat_SampleTypeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_sampletype delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update t_sampletype SET
|
||||
T_SampleTypeIsActive = 'N',
|
||||
T_SampleTypeLastUpdated = now()
|
||||
WHERE
|
||||
T_SampleTypeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_sampletype 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 deletebahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update nat_bahan SET
|
||||
Nat_BahanIsActive = 'N',
|
||||
Nat_BahanLastUpdated = now()
|
||||
WHERE
|
||||
Nat_BahanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_bahan delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE nat_sampletype SET
|
||||
Nat_SampleTypeIsActive = 'N',
|
||||
Nat_SampleTypeLastUpdated = now()
|
||||
WHERE
|
||||
Nat_SampleTypeNat_BahanID = ?
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_sampletype delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "UPDATE t_sampletype SET
|
||||
T_SampleTypeIsActive = 'N',
|
||||
T_SampleTypeLastUpdated = now()
|
||||
WHERE
|
||||
T_SampleTypeNat_BahanID = ?
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_sampletype delete");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1018
one-api/application/controllers/v1/masterdata/Branchv2.php
Normal file
1018
one-api/application/controllers/v1/masterdata/Branchv2.php
Normal file
File diff suppressed because it is too large
Load Diff
2306
one-api/application/controllers/v1/masterdata/Companyadmin_v10.php
Normal file
2306
one-api/application/controllers/v1/masterdata/Companyadmin_v10.php
Normal file
File diff suppressed because it is too large
Load Diff
2322
one-api/application/controllers/v1/masterdata/Companyadmin_v11.php
Normal file
2322
one-api/application/controllers/v1/masterdata/Companyadmin_v11.php
Normal file
File diff suppressed because it is too large
Load Diff
2345
one-api/application/controllers/v1/masterdata/Companyadmin_v12.php
Normal file
2345
one-api/application/controllers/v1/masterdata/Companyadmin_v12.php
Normal file
File diff suppressed because it is too large
Load Diff
2721
one-api/application/controllers/v1/masterdata/Companyadmin_v13.php
Normal file
2721
one-api/application/controllers/v1/masterdata/Companyadmin_v13.php
Normal file
File diff suppressed because it is too large
Load Diff
2792
one-api/application/controllers/v1/masterdata/Companyadmin_v14.php
Normal file
2792
one-api/application/controllers/v1/masterdata/Companyadmin_v14.php
Normal file
File diff suppressed because it is too large
Load Diff
2816
one-api/application/controllers/v1/masterdata/Companyadmin_v15.php
Normal file
2816
one-api/application/controllers/v1/masterdata/Companyadmin_v15.php
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
2044
one-api/application/controllers/v1/masterdata/Companyadmin_v4.php
Normal file
2044
one-api/application/controllers/v1/masterdata/Companyadmin_v4.php
Normal file
File diff suppressed because it is too large
Load Diff
2179
one-api/application/controllers/v1/masterdata/Companyadmin_v5.php
Normal file
2179
one-api/application/controllers/v1/masterdata/Companyadmin_v5.php
Normal file
File diff suppressed because it is too large
Load Diff
2179
one-api/application/controllers/v1/masterdata/Companyadmin_v6.php
Normal file
2179
one-api/application/controllers/v1/masterdata/Companyadmin_v6.php
Normal file
File diff suppressed because it is too large
Load Diff
2179
one-api/application/controllers/v1/masterdata/Companyadmin_v7.php
Normal file
2179
one-api/application/controllers/v1/masterdata/Companyadmin_v7.php
Normal file
File diff suppressed because it is too large
Load Diff
2181
one-api/application/controllers/v1/masterdata/Companyadmin_v8.php
Normal file
2181
one-api/application/controllers/v1/masterdata/Companyadmin_v8.php
Normal file
File diff suppressed because it is too large
Load Diff
2185
one-api/application/controllers/v1/masterdata/Companyadmin_v9.php
Normal file
2185
one-api/application/controllers/v1/masterdata/Companyadmin_v9.php
Normal file
File diff suppressed because it is too large
Load Diff
1770
one-api/application/controllers/v1/masterdata/Companynew.php
Normal file
1770
one-api/application/controllers/v1/masterdata/Companynew.php
Normal file
File diff suppressed because it is too large
Load Diff
1847
one-api/application/controllers/v1/masterdata/Companynewx.php
Normal file
1847
one-api/application/controllers/v1/masterdata/Companynewx.php
Normal file
File diff suppressed because it is too large
Load Diff
2000
one-api/application/controllers/v1/masterdata/Companynewx2-bkp.php
Normal file
2000
one-api/application/controllers/v1/masterdata/Companynewx2-bkp.php
Normal file
File diff suppressed because it is too large
Load Diff
1997
one-api/application/controllers/v1/masterdata/Companynewx2-dev.php
Normal file
1997
one-api/application/controllers/v1/masterdata/Companynewx2-dev.php
Normal file
File diff suppressed because it is too large
Load Diff
1937
one-api/application/controllers/v1/masterdata/Companynewx2-sipe.php
Normal file
1937
one-api/application/controllers/v1/masterdata/Companynewx2-sipe.php
Normal file
File diff suppressed because it is too large
Load Diff
1997
one-api/application/controllers/v1/masterdata/Companynewx2.php
Normal file
1997
one-api/application/controllers/v1/masterdata/Companynewx2.php
Normal file
File diff suppressed because it is too large
Load Diff
916
one-api/application/controllers/v1/masterdata/Companytype.php
Normal file
916
one-api/application/controllers/v1/masterdata/Companytype.php
Normal file
@@ -0,0 +1,916 @@
|
||||
<?php
|
||||
|
||||
class Companytype extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "COMPANY TYPE API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupcompanybusinessbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$companybusiness = $prm['companybusiness'];;
|
||||
$all = $prm['all'];
|
||||
$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_companybusiness
|
||||
WHERE
|
||||
M_CompanyBusinessName LIKE CONCAT('%','{$companybusiness}','%') AND
|
||||
M_CompanyBusinessIsActive = 'Y' GROUP BY M_CompanyBusinessID) a";
|
||||
// $total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->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_companybusiness count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *, COUNT(M_CompanyID) as used
|
||||
FROM (select M_CompanyBusinessID as id,
|
||||
M_CompanyBusinessName as name,
|
||||
M_CompanyID,
|
||||
m_companybusiness.*
|
||||
from m_companybusiness
|
||||
LEFT JOIN m_company ON M_CompanyBusinessID = M_CompanyM_CompanyBusinessID AND M_CompanyIsActive = 'Y'
|
||||
WHERE
|
||||
M_CompanyBusinessName LIKE CONCAT('%','{$companybusiness}','%') AND
|
||||
M_CompanyBusinessIsActive = 'Y') a
|
||||
GROUP BY M_CompanyBusinessID
|
||||
ORDER BY M_CompanyBusinessName ASC";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("m_companybusiness 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 lookupcompanytypebyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$companytype = $prm['companytype'];
|
||||
$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_companytype
|
||||
where
|
||||
M_CompanyTypeName LIKE CONCAT('%','{$companytype}','%') AND
|
||||
M_CompanyTypeIsActive = 'Y'
|
||||
GROUP BY M_CompanyTypeID) a";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_regional->query($sql);
|
||||
$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_companytype count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *, COUNT(M_CompanyID) as used
|
||||
FROM (select M_CompanyTypeID as id,
|
||||
M_CompanyTypeName as name,
|
||||
M_CompanyTypeName as namex,
|
||||
M_CompanyID,
|
||||
m_companytype.*
|
||||
from m_companytype
|
||||
LEFT JOIN m_company ON M_CompanyTypeID = M_CompanyM_CompanyTypeID AND M_CompanyIsActive = 'Y'
|
||||
WHERE
|
||||
M_CompanyTypeName LIKE CONCAT('%','{$companytype}','%') AND
|
||||
M_CompanyTypeIsActive = 'Y') a
|
||||
GROUP BY M_CompanyTypeID
|
||||
ORDER BY M_CompanyTypeName ASC";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("m_companytype 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 addnewcompanytype()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "SELECT COUNT(*) as exist FROM m_companytype WHERE M_CompanyTypeIsActive = 'Y' AND M_CompanyTypeName = '{$name}'";
|
||||
$exist_name = $this->db_regional->query($query)->row()->exist;
|
||||
if($exist_name == 0){
|
||||
$sql = "insert into m_companytype(
|
||||
M_CompanyTypeName,
|
||||
M_CompanyTypeUserID,
|
||||
M_CompanyTypeCreated,
|
||||
M_CompanyTypeLastUpdated
|
||||
)
|
||||
values( ?, ?,now(), now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$name,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_companytype insert");
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}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 editcompanytype()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "SELECT COUNT(*) as exist FROM m_companytype WHERE M_CompanyTypeIsActive = 'Y' AND M_CompanyTypeName = '{$name}' AND M_CompanyTypeID <> '{$id}'";
|
||||
$exist_name = $this->db_regional->query($query)->row()->exist;
|
||||
if($exist_name == 0){
|
||||
$sqlcompany = "update m_companytype SET
|
||||
M_CompanyTypeName = ?,
|
||||
M_CompanyTypeLastUpdated = now(),
|
||||
M_CompanyTypeUserID = ?
|
||||
where
|
||||
M_CompanyTypeID = ?
|
||||
";
|
||||
$querycompany = $this->db_regional->query($sqlcompany,
|
||||
array(
|
||||
$name,
|
||||
$userid,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("m_companytype update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
}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 addnewcompanybusiness()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$M_CompanyBusinessName = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($prm['xid'] == 0){
|
||||
$query = "SELECT COUNT(*) as exist FROM m_companybusiness WHERE M_CompanyBusinessIsActive = 'Y' AND M_CompanyBusinessName = '{$M_CompanyBusinessName}'";
|
||||
$exist_name = $this->db_regional->query($query)->row()->exist;
|
||||
if($exist_name == 0){
|
||||
$sql = "insert into m_companybusiness(
|
||||
M_CompanyBusinessName,
|
||||
M_CompanyBusinessUserID,
|
||||
M_CompanyBusinessCreated,
|
||||
M_CompanyBusinessLastUpdated)
|
||||
values(?,?,now(),now())";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$M_CompanyBusinessName,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_companybusiness insert",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}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_companybusiness WHERE M_CompanyBusinessIsActive = 'Y' AND M_CompanyBusinessName = '{$M_CompanyBusinessName}' AND M_CompanyBusinessID <> '{$prm['xid']}'";
|
||||
$exist_name = $this->db_regional->query($query)->row()->exist;
|
||||
if($exist_name == 0){
|
||||
$sql = "UPDATE m_companybusiness SET M_CompanyBusinessName = '{$M_CompanyBusinessName}',
|
||||
M_CompanyBusinessUserID = '{$userid}',
|
||||
M_CompanyBusinessLastUpdated = now()
|
||||
WHERE M_CompanyBusinessID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
}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 deletecompanytype()
|
||||
{
|
||||
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_companytype SET
|
||||
M_CompanyTypeIsActive = 'N',
|
||||
M_CompanyTypeLastUpdated = now()
|
||||
WHERE
|
||||
M_CompanyTypeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_companytype 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 deletecompanybusiness()
|
||||
{
|
||||
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_companybusiness SET
|
||||
M_CompanyBusinessIsActive = 'N',
|
||||
M_CompanyBusinessLastUpdated = now()
|
||||
WHERE
|
||||
M_CompanyBusinessID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_companybusiness 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 searchcompanytype(){
|
||||
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_companytype
|
||||
WHERE
|
||||
M_CompanyTypeName like ?
|
||||
AND M_CompanyTypeIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_companytype count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT M_CompanyTypeID, M_CompanyTypeName
|
||||
FROM m_companytype
|
||||
WHERE
|
||||
M_CompanyTypeName like ?
|
||||
AND M_CompanyTypeIsActive = 'Y'
|
||||
ORDER BY M_CompanyTypeName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_companytype rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcompanytypebyname(){
|
||||
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_companytype
|
||||
WHERE
|
||||
M_CompanyTypeName like ?
|
||||
AND M_CompanyTypeIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_companytype count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT M_CompanyTypeID, M_CompanyTypeName
|
||||
FROM m_companytype
|
||||
WHERE
|
||||
M_CompanyTypeName like ?
|
||||
AND M_CompanyTypeIsActive = 'Y'
|
||||
ORDER BY M_CompanyTypeName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_companytype rows",$this->db_regional);
|
||||
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_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function searchdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictM_CityID = '{$id}'
|
||||
AND M_DistrictIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictM_CityID = '{$id}'
|
||||
AND M_DistrictIsActive = 'Y'
|
||||
ORDER BY M_DistrictName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = 'Y'
|
||||
ORDER BY M_KelurahanName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcompany(){
|
||||
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_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchmou(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = 'Y'
|
||||
ORDER BY M_MouName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
// echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_mou rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcompanybusiness(){
|
||||
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(SELECT M_CompanyBusinessID, CONCAT(M_CompanyBusinessPrefix, ' ',M_CompanyBusinessName) as M_CompanyBusinessName
|
||||
FROM m_companybusiness
|
||||
WHERE M_CompanyBusinessIsActive = 'Y') a
|
||||
WHERE
|
||||
M_CompanyBusinessName like ?";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_companybusiness count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(SELECT M_CompanyBusinessID, CONCAT(M_CompanyBusinessPrefix, ' ',M_CompanyBusinessName) as M_CompanyBusinessName
|
||||
FROM m_companybusiness
|
||||
WHERE M_CompanyBusinessIsActive = 'Y') a
|
||||
WHERE
|
||||
M_CompanyBusinessName like ?
|
||||
ORDER BY M_CompanyBusinessName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_companybusiness rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function selectaddresscompanybusiness(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query ="SELECT M_CompanyBusinessAddressID,
|
||||
CONCAT(M_CompanyBusinessAddressNote, ': ',M_CompanyBusinessAddressDescription) as M_CompanyBusinessAddressNote
|
||||
FROM
|
||||
m_companybusinessaddress
|
||||
WHERE M_CompanyBusinessAddressIsActive = 'Y' AND M_CompanyBusinessAddressM_CompanyBusinessID = '{$id}'";
|
||||
//echo $query;
|
||||
$rows['addresscompanybusinesss'] = $this->db_regional->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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
2039
one-api/application/controllers/v1/masterdata/Companyv4.php
Normal file
2039
one-api/application/controllers/v1/masterdata/Companyv4.php
Normal file
File diff suppressed because it is too large
Load Diff
2216
one-api/application/controllers/v1/masterdata/Companyverif_v10.php
Normal file
2216
one-api/application/controllers/v1/masterdata/Companyverif_v10.php
Normal file
File diff suppressed because it is too large
Load Diff
2501
one-api/application/controllers/v1/masterdata/Companyverif_v11.php
Normal file
2501
one-api/application/controllers/v1/masterdata/Companyverif_v11.php
Normal file
File diff suppressed because it is too large
Load Diff
2515
one-api/application/controllers/v1/masterdata/Companyverif_v12.php
Normal file
2515
one-api/application/controllers/v1/masterdata/Companyverif_v12.php
Normal file
File diff suppressed because it is too large
Load Diff
2575
one-api/application/controllers/v1/masterdata/Companyverif_v13.php
Normal file
2575
one-api/application/controllers/v1/masterdata/Companyverif_v13.php
Normal file
File diff suppressed because it is too large
Load Diff
2557
one-api/application/controllers/v1/masterdata/Companyverif_v14.php
Normal file
2557
one-api/application/controllers/v1/masterdata/Companyverif_v14.php
Normal file
File diff suppressed because it is too large
Load Diff
2578
one-api/application/controllers/v1/masterdata/Companyverif_v16.php
Normal file
2578
one-api/application/controllers/v1/masterdata/Companyverif_v16.php
Normal file
File diff suppressed because it is too large
Load Diff
2627
one-api/application/controllers/v1/masterdata/Companyverif_v17.php
Normal file
2627
one-api/application/controllers/v1/masterdata/Companyverif_v17.php
Normal file
File diff suppressed because it is too large
Load Diff
2721
one-api/application/controllers/v1/masterdata/Companyverif_v18.php
Normal file
2721
one-api/application/controllers/v1/masterdata/Companyverif_v18.php
Normal file
File diff suppressed because it is too large
Load Diff
2792
one-api/application/controllers/v1/masterdata/Companyverif_v19.php
Normal file
2792
one-api/application/controllers/v1/masterdata/Companyverif_v19.php
Normal file
File diff suppressed because it is too large
Load Diff
2816
one-api/application/controllers/v1/masterdata/Companyverif_v20.php
Normal file
2816
one-api/application/controllers/v1/masterdata/Companyverif_v20.php
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
2039
one-api/application/controllers/v1/masterdata/Companyverif_v5.php
Normal file
2039
one-api/application/controllers/v1/masterdata/Companyverif_v5.php
Normal file
File diff suppressed because it is too large
Load Diff
2050
one-api/application/controllers/v1/masterdata/Companyverif_v6.php
Normal file
2050
one-api/application/controllers/v1/masterdata/Companyverif_v6.php
Normal file
File diff suppressed because it is too large
Load Diff
2208
one-api/application/controllers/v1/masterdata/Companyverif_v7.php
Normal file
2208
one-api/application/controllers/v1/masterdata/Companyverif_v7.php
Normal file
File diff suppressed because it is too large
Load Diff
2213
one-api/application/controllers/v1/masterdata/Companyverif_v8.php
Normal file
2213
one-api/application/controllers/v1/masterdata/Companyverif_v8.php
Normal file
File diff suppressed because it is too large
Load Diff
2213
one-api/application/controllers/v1/masterdata/Companyverif_v9.php
Normal file
2213
one-api/application/controllers/v1/masterdata/Companyverif_v9.php
Normal file
File diff suppressed because it is too large
Load Diff
717
one-api/application/controllers/v1/masterdata/Doctor.php
Normal file
717
one-api/application/controllers/v1/masterdata/Doctor.php
Normal file
@@ -0,0 +1,717 @@
|
||||
<?php
|
||||
class Doctor extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nama = $prm["name"];
|
||||
$status = $prm["status"];
|
||||
$staff = $prm['staff'];
|
||||
// echo $norm;
|
||||
|
||||
$sql_where = "";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_DoctorName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
|
||||
if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
$sql_where .= " M_DoctorIsMarketingConfirm = '{$status}' AND M_DoctorIsActive = 'Y' ";
|
||||
if ($sql_where != "") {
|
||||
$sql_where = " where $sql_where";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
if(intval($staff) > 0){
|
||||
$sql_where = "$sql_where AND M_DoctorM_StaffID = {$staff}";
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
LEFT JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
LEFT JOIN m_staff ON M_DoctorM_StaffID = M_StaffID
|
||||
|
||||
$sql_where
|
||||
";
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
$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_doctor count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$doctor_field = "
|
||||
M_DoctorID,
|
||||
M_DoctorOldCode,
|
||||
M_DoctorCode ,
|
||||
M_DoctorPrefix ,
|
||||
M_DoctorPrefix2 ,
|
||||
M_DoctorName ,
|
||||
M_DoctorSufix ,
|
||||
M_DoctorSufix2 ,
|
||||
M_DoctorSufix3 ,
|
||||
M_DoctorM_SexID ,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorM_StaffID,
|
||||
IFNULL(M_DoctorEmail,'') as M_DoctorEmail,
|
||||
M_DoctorHP ,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone ,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
ifnull(M_DoctorPjIsPJ,'N') M_DoctorIsPJ,
|
||||
ifnull(M_DoctorPjIsDefaultPJ,'N') M_DoctorIsDefaultPJ ,
|
||||
M_DoctorM_SpecialID ,
|
||||
ifnull(M_DoctorPjIsClinic,'N') M_DoctorIsClinic ,
|
||||
ifnull(M_DoctorPjIsDefault,'N') M_DoctorIsDefault ,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorIsDefaultMcu,
|
||||
M_DoctorCreated ,
|
||||
M_DoctorLastUpdated,
|
||||
M_DoctorIsActive,
|
||||
M_DoctorReportCode ,
|
||||
M_DoctorPrivateRequest,
|
||||
M_DoctorM_UserID ,
|
||||
";
|
||||
$sql = "SELECT $doctor_field
|
||||
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_fullname,
|
||||
M_SexName,
|
||||
M_ReligionName,
|
||||
M_StaffName,
|
||||
IF(M_DoctorIsMarketingConfirm = 'N', 'Belum dikonfirmasi marketing','Sudah dikonfirmasi marketing') as status
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
left join m_doctorpj on M_DoctorID = M_DoctorPjM_DoctorID AND M_DoctorPjIsActive = 'Y'
|
||||
left JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
left JOIN m_staff ON M_DoctorM_StaffID = M_StaffID
|
||||
$sql_where
|
||||
ORDER BY M_DoctorName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
//echo $this->db_regional->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_PatientID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_sex
|
||||
WHERE
|
||||
M_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_regional->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM m_religion
|
||||
WHERE
|
||||
M_ReligionIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['religions'] = $this->db_regional->query($query)->result_array();
|
||||
$query ="
|
||||
SELECT 0 as M_StaffID, 'Semua' as M_StaffName
|
||||
UNION
|
||||
SELECT M_StaffID, M_StaffName
|
||||
FROM m_staff
|
||||
WHERE
|
||||
M_StaffIsActive = 'Y' and M_StaffM_PositionID = '2'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['staffs'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['jpas'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
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_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName DESC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getjpa(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query)->result_array();
|
||||
|
||||
// $rows['jpas'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
// ambil data lama
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$old_doctor = array();
|
||||
if (count($rows) > 0 ) $old_doctor = $rows[0];
|
||||
|
||||
$ispj = $prm['M_DoctorIsPJ'];
|
||||
$isdefaultpj = $prm['M_DoctorIsDefaultPJ'];
|
||||
$isdefault = $prm['M_DoctorIsDefault'];
|
||||
$isclinic = $prm['M_DoctorIsClinic'];
|
||||
if($prm['M_DoctorEmail'] == ''){
|
||||
$prm['M_DoctorEmailIsDefault'] = 'N';
|
||||
}
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorPrefix = '{$prm['M_DoctorPrefix']}',
|
||||
M_DoctorPrefix2 = '{$prm['M_DoctorPrefix2']}',
|
||||
M_DoctorName = '{$prm['M_DoctorName']}',
|
||||
M_DoctorSufix = '{$prm['M_DoctorSufix']}',
|
||||
M_DoctorSufix2 = '{$prm['M_DoctorSufix2']}',
|
||||
M_DoctorSufix3 = '{$prm['M_DoctorSufix3']}',
|
||||
M_DoctorM_SexID = '{$prm['M_DoctorM_SexID']}',
|
||||
M_DoctorM_ReligionID = '{$prm['M_DoctorM_ReligionID']}',
|
||||
M_DoctorM_StaffID = '{$prm['M_DoctorM_StaffID']}',
|
||||
M_DoctorEmail = '{$prm['M_DoctorEmail']}',
|
||||
M_DoctorHP = '{$prm['M_DoctorHP']}',
|
||||
M_DoctorNote = '{$prm['M_DoctorNote']}',
|
||||
M_DoctorPhone = '{$prm['M_DoctorPhone']}',
|
||||
M_DoctorIsMarketingConfirm = '{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
M_DoctorIsPJ = '{$prm['M_DoctorIsPJ']}',
|
||||
M_DoctorIsDefaultMcu = '{$prm['M_DoctorIsDefaultMcu']}',
|
||||
M_DoctorIsDefaultPJ = '{$prm['M_DoctorIsDefaultPJ']}',
|
||||
M_DoctorIsClinic = '{$prm['M_DoctorIsClinic']}',
|
||||
M_DoctorIsDefault = '{$prm['M_DoctorIsDefault']}',
|
||||
M_DoctorEmailIsDefault = '{$prm['M_DoctorEmailIsDefault']}'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$sqlx = "select * from m_doctorpj
|
||||
where M_DoctorPjM_DoctorID = ? and M_DoctorPjIsActive = 'Y'";
|
||||
$qryx= $this->db_regional->query($sqlx,array($prm["M_DoctorID"]));
|
||||
$rowsx = $qryx->result_array();
|
||||
if (count($rowsx) > 0 ) {
|
||||
$sql = "UPDATE m_doctorpj set
|
||||
M_DoctorPjIsPJ = ?, M_DoctorPjIsDefaultPJ = ?, M_DoctorPjIsClinic = ?, M_DoctorPjIsDefault =?
|
||||
where M_DoctorPjM_DoctorID = ? AND M_DoctorPjIsActive = 'Y'";
|
||||
$this->db_regional->query($sql, array($ispj,$isdefaultpj,$isclinic,$isdefault,$prm["M_DoctorID"]));
|
||||
if ($isdefaultpj == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefaultPj= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
if ($isdefault == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefault= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
}else{
|
||||
//sipe modifikasi ispj
|
||||
if($ispj == 'Y' || $isdefaultpj == 'Y' || $isdefault == 'Y' || $isclinic === 'Y'){
|
||||
$sql = "select * from m_doctorpj
|
||||
where M_DoctorPjM_DoctorID = ? and M_DoctorPjIsActive = 'Y' ";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$sql = "insert into m_doctorpj(M_DoctorPjM_DoctorID,
|
||||
M_DoctorPjIsPJ, M_DoctorPjIsDefaultPJ, M_DoctorPjIsClinic, M_DoctorPjIsDefault)
|
||||
values(?,?,?,?,?)";
|
||||
$this->db_regional->query($sql, array($prm["M_DoctorID"],$ispj,$isdefaultpj,$isclinic,$isdefault));
|
||||
}
|
||||
if ($isdefaultpj == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefaultPj= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
if ($isdefault == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefault= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
} else {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsActive= 'N', M_DoctorPjIsPJ = 'N'
|
||||
where M_DoctorPjM_DoctorID = ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
|
||||
// ambil data baru
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$new_doctor = array();
|
||||
if (count($rows) > 0 ) $new_doctor = $rows[0];
|
||||
$d_doctor = json_encode(array("old" => $old_doctor , "new" => $new_doctor));
|
||||
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$ispj = $prm['M_DoctorIsPJ'];
|
||||
$isdefaultpj = $prm['M_DoctorIsDefaultPJ'];
|
||||
$isdefault = $prm['M_DoctorIsDefault'];
|
||||
$isclinic = $prm['M_DoctorIsClinic'];
|
||||
$query ="INSERT INTO m_doctor (
|
||||
M_DoctorPrefix,
|
||||
M_DoctorPrefix2,
|
||||
M_DoctorName,
|
||||
M_DoctorSufix,
|
||||
M_DoctorSufix2,
|
||||
M_DoctorSufix3,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorM_StaffID,
|
||||
M_DoctorEmail,
|
||||
M_DoctorHP,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
M_DoctorIsPJ,
|
||||
M_DoctorIsDefaultMcu,
|
||||
M_DoctorIsDefaultPJ,
|
||||
M_DoctorIsClinic,
|
||||
M_DoctorIsDefault,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorM_UserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorPrefix']}',
|
||||
'{$prm['M_DoctorPrefix2']}',
|
||||
'{$prm['M_DoctorName']}',
|
||||
'{$prm['M_DoctorSufix']}',
|
||||
'{$prm['M_DoctorSufix2']}',
|
||||
'{$prm['M_DoctorSufix3']}',
|
||||
'{$prm['M_DoctorM_SexID']}',
|
||||
'{$prm['M_DoctorM_ReligionID']}',
|
||||
'{$prm['M_DoctorM_StaffID']}',
|
||||
'{$prm['M_DoctorEmail']}',
|
||||
'{$prm['M_DoctorHP']}',
|
||||
'{$prm['M_DoctorNote']}',
|
||||
'{$prm['M_DoctorPhone']}',
|
||||
'{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
'{$prm['M_DoctorIsPJ']}',
|
||||
'{$prm['M_DoctorIsDefaultMcu']}',
|
||||
'{$prm['M_DoctorIsDefaultPJ']}',
|
||||
'{$prm['M_DoctorIsClinic']}',
|
||||
'{$prm['M_DoctorIsDefault']}',
|
||||
'{$prm['M_DoctorEmailIsDefault']}',
|
||||
$userid
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
if($rows){
|
||||
if($isdefault == 'Y'){
|
||||
$querydefault ="UPDATE m_doctorpj SET
|
||||
M_DoctorPjIsDefault = 'N' WHERE M_DoctorPjIsDefault = 'Y'
|
||||
";
|
||||
$rows = $this->db_regional->query($querydefault);
|
||||
}
|
||||
if($isdefaultpj == 'Y'){
|
||||
$querydefault ="UPDATE m_doctorpj SET
|
||||
M_DoctorPjIsDefaultPJ = 'N' WHERE M_DoctorPjIsDefaultPJ = 'Y'
|
||||
";
|
||||
$rows = $this->db_regional->query($querydefault);
|
||||
}
|
||||
if($ispj == 'Y' || $isdefaultpj == 'Y' || $isdefault == 'Y' || $isclinic === 'Y'){
|
||||
$querypj ="INSERT INTO m_doctorpj (
|
||||
M_DoctorPjM_DoctorID,
|
||||
M_DoctorPjIsPJ,
|
||||
M_DoctorPjIsDefaultPJ,
|
||||
M_DoctorPjIsClinic,
|
||||
M_DoctorPjIsDefault,
|
||||
M_DoctorPjCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$prm['M_DoctorIsPJ']}',
|
||||
'{$prm['M_DoctorIsDefaultPJ']}',
|
||||
'{$prm['M_DoctorIsClinic']}',
|
||||
'{$prm['M_DoctorIsDefault']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
$rows = $this->db_regional->query($querypj);
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
//sipe tambah log doctor
|
||||
$prm["M_DoctorID"] = $last_id;
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADD','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletedoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// sipe nambah ambil userid
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_doctoraddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,Nat_JpaName,
|
||||
'' as action
|
||||
FROM m_doctoraddress
|
||||
JOIN m_kelurahan ON M_DoctorAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
left join nat_jpa on M_DoctorAddressNat_JpaID = Nat_JpaID
|
||||
WHERE
|
||||
M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function savenewaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$count_addrs = $this->db_regional->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_regional->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_DoctorAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_regional->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}' AND M_DoctorAddressNote = 'Utama' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_DoctorAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_DoctorAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$query ="INSERT INTO m_doctoraddress (
|
||||
M_DoctorAddressM_DoctorID,
|
||||
M_DoctorAddressNote,
|
||||
M_DoctorAddressDescription,
|
||||
M_DoctorAddressM_KelurahanID,
|
||||
M_DoctorAddressNat_JpaID,
|
||||
M_DoctorAddressCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorAddressM_DoctorID']}',
|
||||
'{$prm['M_DoctorAddressNote']}',
|
||||
'{$prm['M_DoctorAddressDescription']}',
|
||||
'{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
'{$prm['M_DoctorAddressNat_JpaID']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}',
|
||||
M_DoctorAddressNote = '{$prm['M_DoctorAddressNote']}',
|
||||
M_DoctorAddressDescription = '{$prm['M_DoctorAddressDescription']}',
|
||||
M_DoctorAddressM_KelurahanID = '{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
M_DoctorAddressNat_JpaID = '{$prm['M_DoctorAddressNat_JpaID']}'
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
715
one-api/application/controllers/v1/masterdata/Doctorcabang.php
Normal file
715
one-api/application/controllers/v1/masterdata/Doctorcabang.php
Normal file
@@ -0,0 +1,715 @@
|
||||
<?php
|
||||
|
||||
class Doctorcabang extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "DOCTOR MCU API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookupdoctormcubyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$doctormcu = $prm['doctormcu'];
|
||||
$all = $prm['all'];
|
||||
$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_doctormcu
|
||||
JOIN m_doctor ON M_DoctorMcuM_DoctorID = M_DoctorID AND M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
(M_DoctorCode LIKE CONCAT('%','{$doctormcu}','%') OR
|
||||
CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) LIKE CONCAT('%','{$doctormcu}','%')) AND
|
||||
M_DoctorMcuIsActive = 'Y' GROUP BY M_DoctorMcuID) 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_doctormcu count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_DoctorMcuID as id,
|
||||
CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as name,
|
||||
M_DoctorCode as code,
|
||||
M_DoctorID,
|
||||
M_DoctorCode,
|
||||
CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as M_DoctorName,
|
||||
m_doctormcu.*
|
||||
from m_doctormcu
|
||||
JOIN m_doctor ON M_DoctorMcuM_DoctorID = M_DoctorID AND M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
(M_DoctorCode LIKE CONCAT('%','{$doctormcu}','%') OR
|
||||
CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) LIKE CONCAT('%','{$doctormcu}','%')) AND
|
||||
M_DoctorMcuIsActive = 'Y'
|
||||
GROUP BY M_DoctorMcuID
|
||||
ORDER BY M_DoctorName 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_doctormcu 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 addnewdoctormcu()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$M_DoctorMcuM_DoctorID = $prm['M_DoctorMcuM_DoctorID'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($M_DoctorMcuM_DoctorID == 0){
|
||||
$errors = array();
|
||||
if($M_DoctorMcuM_DoctorID == 0){
|
||||
array_push($errors,array('field'=>'grup','msg'=>'Dokternya dipilih dulu dong'));
|
||||
}
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
if($prm['xid'] == 0){
|
||||
$sql = "insert into m_doctormcu(
|
||||
M_DoctorMcuM_DoctorID,
|
||||
M_DoctorMcuUserID,
|
||||
M_DoctorMcuLastUpdated,
|
||||
M_DoctorMcuCreated)
|
||||
values(?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$M_DoctorMcuM_DoctorID,
|
||||
$userid)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctormcu 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 m_doctormcu SET M_DoctorMcuM_DoctorID = '{$M_DoctorMcuM_DoctorID}'
|
||||
WHERE M_DoctorMcuID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function savepj()
|
||||
{
|
||||
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"];
|
||||
|
||||
$query = "UPDATE m_doctorpj SET M_DoctorPjIsActive = 'N' WHERE M_DoctorPjIsActive = 'Y'";
|
||||
$this->db_onedev->query($query);
|
||||
$query = " INSERT INTO m_doctorpj (
|
||||
M_DoctorPjM_DoctorID,
|
||||
M_DoctorPjIsDefaultPJ,
|
||||
M_DoctorPjIsPJ,
|
||||
M_DoctorPjIsDefault,
|
||||
M_DoctorPjIsClinic,
|
||||
M_DoctorPjUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['M_DoctorID']},
|
||||
'Y',
|
||||
'Y',
|
||||
'Y',
|
||||
'N',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => $last_id));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function lookuppj()
|
||||
{
|
||||
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"];
|
||||
$rst = array();
|
||||
$query = "SELECT m_doctor.* ,CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as M_DoctorName
|
||||
FROM m_doctorpj
|
||||
JOIN m_doctor ON M_DoctorPjM_DoctorID = M_DoctorID AND M_DoctorIsActive = 'Y'
|
||||
WHERE
|
||||
M_DoctorPjIsDefaultPJ = 'Y' AND M_DoctorPjIsPJ = 'Y' AND M_DoctorPjIsActive = 'Y' LIMIT 1";
|
||||
$get_row = $this->db_onedev->query($query);
|
||||
if($get_row){
|
||||
$rst = $get_row->row_array();
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => $rst);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function deletedoctormcu()
|
||||
{
|
||||
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_doctormcu SET
|
||||
M_DoctorMcuIsActive = 'N',
|
||||
M_DoctorMcuLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorMcuID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctormcu 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 searchdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'tes' => '%'
|
||||
];
|
||||
|
||||
if ($prm['tes'] != '')
|
||||
{
|
||||
$q['tes'] = "%{$prm['tes']}%";
|
||||
}
|
||||
|
||||
// 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['tes']);
|
||||
//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 M_DoctorID, CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE
|
||||
CONCAT(M_DoctorPrefix,M_DoctorPrefix2,M_DoctorName,M_DoctorSufix,M_DoctorSufix2,M_DoctorSufix3) like ?
|
||||
AND M_DoctorIsActive = 'Y'
|
||||
ORDER BY M_DoctorName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['tes']));
|
||||
|
||||
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 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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function searchdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictM_CityID = '{$id}'
|
||||
AND M_DistrictIsActive = '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_district count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictM_CityID = '{$id}'
|
||||
AND M_DistrictIsActive = 'Y'
|
||||
ORDER BY M_DistrictName 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("m_district rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = '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_district count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = 'Y'
|
||||
ORDER BY M_KelurahanName 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("m_district rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcompany(){
|
||||
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_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = '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_company count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName 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("m_company rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchmou(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = '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_mou count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = 'Y'
|
||||
ORDER BY M_MouName 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("m_mou rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchdoctorold(){
|
||||
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(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?";
|
||||
$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 M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?
|
||||
ORDER BY M_DoctorName 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("m_doctor rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function selectaddressdoctor(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query ="SELECT M_DoctorAddressID,
|
||||
CONCAT(M_DoctorAddressNote, ': ',M_DoctorAddressDescription) as M_DoctorAddressNote
|
||||
FROM
|
||||
m_doctoraddress
|
||||
WHERE M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = '{$id}'";
|
||||
//echo $query;
|
||||
$rows['addressdoctors'] = $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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
783
one-api/application/controllers/v1/masterdata/Doctorv2.php
Normal file
783
one-api/application/controllers/v1/masterdata/Doctorv2.php
Normal file
@@ -0,0 +1,783 @@
|
||||
<?php
|
||||
class Doctorv2 extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nama = $prm["name"];
|
||||
$status = $prm["status"];
|
||||
$staff = $prm['staff'];
|
||||
// echo $norm;
|
||||
|
||||
$sql_where = "";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_DoctorName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
|
||||
if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
$sql_where .= " M_DoctorIsMarketingConfirm = '{$status}' AND M_DoctorIsActive = 'Y' ";
|
||||
if ($sql_where != "") {
|
||||
$sql_where = " where $sql_where";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
if(intval($staff) > 0){
|
||||
$sql_where = "$sql_where AND M_DoctorM_StaffNIK = {$staff}";
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
LEFT JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
LEFT JOIN nat_staff ON M_DoctorM_StaffNIK = Nat_StaffNIK
|
||||
|
||||
$sql_where
|
||||
";
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
$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_doctor count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$doctor_field = "
|
||||
M_DoctorID,
|
||||
M_DoctorOldCode,
|
||||
M_DoctorCode ,
|
||||
M_DoctorPrefix ,
|
||||
M_DoctorPrefix2 ,
|
||||
M_DoctorName ,
|
||||
M_DoctorSufix ,
|
||||
M_DoctorSufix2 ,
|
||||
M_DoctorSufix3 ,
|
||||
M_DoctorM_SexID ,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorM_StaffID,
|
||||
IFNULL(M_DoctorEmail,'') as M_DoctorEmail,
|
||||
M_DoctorHP ,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone ,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
ifnull(M_DoctorPjIsPJ,'N') M_DoctorIsPJ,
|
||||
ifnull(M_DoctorPjIsDefaultPJ,'N') M_DoctorIsDefaultPJ ,
|
||||
M_DoctorM_SpecialID ,
|
||||
ifnull(M_DoctorPjIsClinic,'N') M_DoctorIsClinic ,
|
||||
ifnull(M_DoctorPjIsDefault,'N') M_DoctorIsDefault ,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorIsDefaultMcu,
|
||||
M_DoctorCreated ,
|
||||
M_DoctorLastUpdated,
|
||||
M_DoctorIsActive,
|
||||
M_DoctorReportCode ,
|
||||
M_DoctorPrivateRequest,
|
||||
M_DoctorM_UserID ,
|
||||
M_DoctorM_StaffNIK,
|
||||
";
|
||||
$sql = "SELECT $doctor_field
|
||||
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_fullname,
|
||||
M_SexName,
|
||||
M_ReligionName,
|
||||
Nat_StaffID,
|
||||
Nat_StaffNIK,
|
||||
IF(Nat_StaffNIK = '' OR Nat_StaffNIK IS NULL, '', Nat_StaffName) as Nat_StaffName,
|
||||
IF(M_DoctorIsMarketingConfirm = 'N', 'Belum dikonfirmasi marketing','Sudah dikonfirmasi marketing') as status
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
left join m_doctorpj on M_DoctorID = M_DoctorPjM_DoctorID AND M_DoctorPjIsActive = 'Y'
|
||||
left JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
left JOIN nat_staff ON M_DoctorM_StaffNIK = Nat_StaffNIK
|
||||
$sql_where
|
||||
GROUP BY M_DoctorID
|
||||
ORDER BY M_DoctorName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
// echo $this->db_regional->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_PatientID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_sex
|
||||
WHERE
|
||||
M_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_regional->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM m_religion
|
||||
WHERE
|
||||
M_ReligionIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['religions'] = $this->db_regional->query($query)->result_array();
|
||||
$query ="
|
||||
SELECT 0 as Nat_StaffID, 'Semua' as Nat_StaffName, '' as Nat_StaffNIK
|
||||
UNION
|
||||
SELECT Nat_StaffID, Nat_StaffName, Nat_StaffNIK
|
||||
FROM nat_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['staffs'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['jpas'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function searchstaff(){
|
||||
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_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y'
|
||||
AND (Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')";
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_staff count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT * FROM(SELECT *, CONCAT(Nat_StaffName, ' [',Nat_StaffNIK,']') as Nat_StaffNames
|
||||
FROM nat_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y') a
|
||||
WHERE
|
||||
(Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')
|
||||
AND Nat_StaffIsActive = 'Y'
|
||||
ORDER BY Nat_StaffName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_staff rows",$this->db_regional);
|
||||
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_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName DESC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getjpa(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query)->result_array();
|
||||
|
||||
// $rows['jpas'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
// ambil data lama
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$old_doctor = array();
|
||||
if (count($rows) > 0 ) $old_doctor = $rows[0];
|
||||
|
||||
$ispj = $prm['M_DoctorIsPJ'];
|
||||
$isdefaultpj = $prm['M_DoctorIsDefaultPJ'];
|
||||
$isdefault = $prm['M_DoctorIsDefault'];
|
||||
$isclinic = $prm['M_DoctorIsClinic'];
|
||||
if($prm['M_DoctorEmail'] == ''){
|
||||
$prm['M_DoctorEmailIsDefault'] = 'N';
|
||||
}
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorPrefix = '{$prm['M_DoctorPrefix']}',
|
||||
M_DoctorPrefix2 = '{$prm['M_DoctorPrefix2']}',
|
||||
M_DoctorName = '{$prm['M_DoctorName']}',
|
||||
M_DoctorSufix = '{$prm['M_DoctorSufix']}',
|
||||
M_DoctorSufix2 = '{$prm['M_DoctorSufix2']}',
|
||||
M_DoctorSufix3 = '{$prm['M_DoctorSufix3']}',
|
||||
M_DoctorM_SexID = '{$prm['M_DoctorM_SexID']}',
|
||||
M_DoctorM_ReligionID = '{$prm['M_DoctorM_ReligionID']}',
|
||||
M_DoctorM_StaffID = '{$prm['M_DoctorM_StaffID']}',
|
||||
M_DoctorM_StaffNIK = '{$prm['M_DoctorM_StaffNIK']}',
|
||||
M_DoctorEmail = '{$prm['M_DoctorEmail']}',
|
||||
M_DoctorHP = '{$prm['M_DoctorHP']}',
|
||||
M_DoctorNote = '{$prm['M_DoctorNote']}',
|
||||
M_DoctorPhone = '{$prm['M_DoctorPhone']}',
|
||||
M_DoctorIsMarketingConfirm = '{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
M_DoctorIsPJ = '{$prm['M_DoctorIsPJ']}',
|
||||
M_DoctorIsDefaultMcu = '{$prm['M_DoctorIsDefaultMcu']}',
|
||||
M_DoctorIsDefaultPJ = '{$prm['M_DoctorIsDefaultPJ']}',
|
||||
M_DoctorIsClinic = '{$prm['M_DoctorIsClinic']}',
|
||||
M_DoctorIsDefault = '{$prm['M_DoctorIsDefault']}',
|
||||
M_DoctorEmailIsDefault = '{$prm['M_DoctorEmailIsDefault']}'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$sqlx = "select * from m_doctorpj
|
||||
where M_DoctorPjM_DoctorID = ? and M_DoctorPjIsActive = 'Y'";
|
||||
$qryx= $this->db_regional->query($sqlx,array($prm["M_DoctorID"]));
|
||||
$rowsx = $qryx->result_array();
|
||||
if (count($rowsx) > 0 ) {
|
||||
$sql = "UPDATE m_doctorpj set
|
||||
M_DoctorPjIsPJ = ?, M_DoctorPjIsDefaultPJ = ?, M_DoctorPjIsClinic = ?, M_DoctorPjIsDefault =?
|
||||
where M_DoctorPjM_DoctorID = ? AND M_DoctorPjIsActive = 'Y'";
|
||||
$this->db_regional->query($sql, array($ispj,$isdefaultpj,$isclinic,$isdefault,$prm["M_DoctorID"]));
|
||||
if ($isdefaultpj == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefaultPj= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
if ($isdefault == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefault= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
}else{
|
||||
//sipe modifikasi ispj
|
||||
if($ispj == 'Y' || $isdefaultpj == 'Y' || $isdefault == 'Y' || $isclinic === 'Y'){
|
||||
$sql = "select * from m_doctorpj
|
||||
where M_DoctorPjM_DoctorID = ? and M_DoctorPjIsActive = 'Y' ";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$sql = "insert into m_doctorpj(M_DoctorPjM_DoctorID,
|
||||
M_DoctorPjIsPJ, M_DoctorPjIsDefaultPJ, M_DoctorPjIsClinic, M_DoctorPjIsDefault)
|
||||
values(?,?,?,?,?)";
|
||||
$this->db_regional->query($sql, array($prm["M_DoctorID"],$ispj,$isdefaultpj,$isclinic,$isdefault));
|
||||
}
|
||||
if ($isdefaultpj == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefaultPj= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
if ($isdefault == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefault= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
} else {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsActive= 'N', M_DoctorPjIsPJ = 'N'
|
||||
where M_DoctorPjM_DoctorID = ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
|
||||
// ambil data baru
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$new_doctor = array();
|
||||
if (count($rows) > 0 ) $new_doctor = $rows[0];
|
||||
$d_doctor = json_encode(array("old" => $old_doctor , "new" => $new_doctor));
|
||||
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$ispj = $prm['M_DoctorIsPJ'];
|
||||
$isdefaultpj = $prm['M_DoctorIsDefaultPJ'];
|
||||
$isdefault = $prm['M_DoctorIsDefault'];
|
||||
$isclinic = $prm['M_DoctorIsClinic'];
|
||||
$query ="INSERT INTO m_doctor (
|
||||
M_DoctorPrefix,
|
||||
M_DoctorPrefix2,
|
||||
M_DoctorName,
|
||||
M_DoctorSufix,
|
||||
M_DoctorSufix2,
|
||||
M_DoctorSufix3,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorM_StaffID,
|
||||
M_DoctorM_StaffNIK,
|
||||
M_DoctorEmail,
|
||||
M_DoctorHP,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
M_DoctorIsPJ,
|
||||
M_DoctorIsDefaultMcu,
|
||||
M_DoctorIsDefaultPJ,
|
||||
M_DoctorIsClinic,
|
||||
M_DoctorIsDefault,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorM_UserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorPrefix']}',
|
||||
'{$prm['M_DoctorPrefix2']}',
|
||||
'{$prm['M_DoctorName']}',
|
||||
'{$prm['M_DoctorSufix']}',
|
||||
'{$prm['M_DoctorSufix2']}',
|
||||
'{$prm['M_DoctorSufix3']}',
|
||||
'{$prm['M_DoctorM_SexID']}',
|
||||
'{$prm['M_DoctorM_ReligionID']}',
|
||||
'{$prm['M_DoctorM_StaffID']}',
|
||||
'{$prm['M_DoctorM_StaffNIK']}',
|
||||
'{$prm['M_DoctorEmail']}',
|
||||
'{$prm['M_DoctorHP']}',
|
||||
'{$prm['M_DoctorNote']}',
|
||||
'{$prm['M_DoctorPhone']}',
|
||||
'{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
'{$prm['M_DoctorIsPJ']}',
|
||||
'{$prm['M_DoctorIsDefaultMcu']}',
|
||||
'{$prm['M_DoctorIsDefaultPJ']}',
|
||||
'{$prm['M_DoctorIsClinic']}',
|
||||
'{$prm['M_DoctorIsDefault']}',
|
||||
'{$prm['M_DoctorEmailIsDefault']}',
|
||||
$userid
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
if($rows){
|
||||
if($isdefault == 'Y'){
|
||||
$querydefault ="UPDATE m_doctorpj SET
|
||||
M_DoctorPjIsDefault = 'N' WHERE M_DoctorPjIsDefault = 'Y'
|
||||
";
|
||||
$rows = $this->db_regional->query($querydefault);
|
||||
}
|
||||
if($isdefaultpj == 'Y'){
|
||||
$querydefault ="UPDATE m_doctorpj SET
|
||||
M_DoctorPjIsDefaultPJ = 'N' WHERE M_DoctorPjIsDefaultPJ = 'Y'
|
||||
";
|
||||
$rows = $this->db_regional->query($querydefault);
|
||||
}
|
||||
if($ispj == 'Y' || $isdefaultpj == 'Y' || $isdefault == 'Y' || $isclinic === 'Y'){
|
||||
$querypj ="INSERT INTO m_doctorpj (
|
||||
M_DoctorPjM_DoctorID,
|
||||
M_DoctorPjIsPJ,
|
||||
M_DoctorPjIsDefaultPJ,
|
||||
M_DoctorPjIsClinic,
|
||||
M_DoctorPjIsDefault,
|
||||
M_DoctorPjCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$prm['M_DoctorIsPJ']}',
|
||||
'{$prm['M_DoctorIsDefaultPJ']}',
|
||||
'{$prm['M_DoctorIsClinic']}',
|
||||
'{$prm['M_DoctorIsDefault']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
$rows = $this->db_regional->query($querypj);
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
//sipe tambah log doctor
|
||||
$prm["M_DoctorID"] = $last_id;
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADD','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletedoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// sipe nambah ambil userid
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_doctoraddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,Nat_JpaName,
|
||||
'' as action
|
||||
FROM m_doctoraddress
|
||||
JOIN m_kelurahan ON M_DoctorAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
left join nat_jpa on M_DoctorAddressNat_JpaID = Nat_JpaID
|
||||
WHERE
|
||||
M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorOldCode = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function savenewaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$count_addrs = $this->db_regional->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorOldCode = '{$prm['M_DoctorAddressM_DoctorOldCode']}' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_regional->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_DoctorAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_regional->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorOldCode = '{$prm['M_DoctorAddressM_DoctorOldCode']}' AND M_DoctorAddressNote = 'Utama' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_DoctorAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_DoctorAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$query ="INSERT INTO m_doctoraddress (
|
||||
M_DoctorAddressM_DoctorOldCode,
|
||||
M_DoctorAddressNote,
|
||||
M_DoctorAddressDescription,
|
||||
M_DoctorAddressM_KelurahanID,
|
||||
M_DoctorAddressNat_JpaID,
|
||||
M_DoctorAddressLastUpdated,
|
||||
M_DoctorAddressCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorAddressM_DoctorOldCode']}',
|
||||
'{$prm['M_DoctorAddressNote']}',
|
||||
'{$prm['M_DoctorAddressDescription']}',
|
||||
'{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
'{$prm['M_DoctorAddressNat_JpaID']}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressM_DoctorOldCode = '{$prm['M_DoctorAddressM_DoctorOldCode']}',
|
||||
M_DoctorAddressNote = '{$prm['M_DoctorAddressNote']}',
|
||||
M_DoctorAddressDescription = '{$prm['M_DoctorAddressDescription']}',
|
||||
M_DoctorAddressM_KelurahanID = '{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
M_DoctorAddressNat_JpaID = '{$prm['M_DoctorAddressNat_JpaID']}',
|
||||
M_DoctorAddressLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressIsActive = 'N',
|
||||
M_DoctorAddressLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
779
one-api/application/controllers/v1/masterdata/Doctorv2b.php
Normal file
779
one-api/application/controllers/v1/masterdata/Doctorv2b.php
Normal file
@@ -0,0 +1,779 @@
|
||||
<?php
|
||||
class Doctorv2b extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nama = $prm["name"];
|
||||
$status = $prm["status"];
|
||||
$staff = $prm['staff'];
|
||||
// echo $norm;
|
||||
|
||||
$sql_where = "";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_DoctorName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
|
||||
if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
$sql_where .= " M_DoctorIsMarketingConfirm = '{$status}' AND M_DoctorIsActive = 'Y' ";
|
||||
if ($sql_where != "") {
|
||||
$sql_where = " where $sql_where";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
if(intval($staff) > 0){
|
||||
$sql_where = "$sql_where AND M_DoctorM_StaffNIK = {$staff}";
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
LEFT JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
LEFT JOIN nat_staff ON M_DoctorM_StaffNIK = Nat_StaffNIK
|
||||
|
||||
$sql_where
|
||||
";
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
$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_doctor count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$doctor_field = "
|
||||
M_DoctorID,
|
||||
M_DoctorOldCode,
|
||||
M_DoctorCode ,
|
||||
M_DoctorPrefix ,
|
||||
M_DoctorPrefix2 ,
|
||||
M_DoctorName ,
|
||||
M_DoctorSufix ,
|
||||
M_DoctorSufix2 ,
|
||||
M_DoctorSufix3 ,
|
||||
M_DoctorM_SexID ,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorM_StaffID,
|
||||
IFNULL(M_DoctorEmail,'') as M_DoctorEmail,
|
||||
M_DoctorHP ,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone ,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
ifnull(M_DoctorPjIsPJ,'N') M_DoctorIsPJ,
|
||||
ifnull(M_DoctorPjIsDefaultPJ,'N') M_DoctorIsDefaultPJ ,
|
||||
M_DoctorM_SpecialID ,
|
||||
ifnull(M_DoctorPjIsClinic,'N') M_DoctorIsClinic ,
|
||||
ifnull(M_DoctorPjIsDefault,'N') M_DoctorIsDefault ,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorIsDefaultMcu,
|
||||
M_DoctorCreated ,
|
||||
M_DoctorLastUpdated,
|
||||
M_DoctorIsActive,
|
||||
M_DoctorReportCode ,
|
||||
M_DoctorPrivateRequest,
|
||||
M_DoctorM_UserID ,
|
||||
M_DoctorM_StaffNIK,
|
||||
";
|
||||
$sql = "SELECT $doctor_field
|
||||
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_fullname,
|
||||
M_SexName,
|
||||
M_ReligionName,
|
||||
Nat_StaffID,
|
||||
Nat_StaffNIK,
|
||||
IF(Nat_StaffNIK = '' OR Nat_StaffNIK IS NULL, '', Nat_StaffName) as Nat_StaffName,
|
||||
IF(M_DoctorIsMarketingConfirm = 'N', 'Belum dikonfirmasi marketing','Sudah dikonfirmasi marketing') as status
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
left join m_doctorpj on M_DoctorID = M_DoctorPjM_DoctorID AND M_DoctorPjIsActive = 'Y'
|
||||
left JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
left JOIN nat_staff ON M_DoctorM_StaffNIK = Nat_StaffNIK
|
||||
$sql_where
|
||||
GROUP BY M_DoctorID
|
||||
ORDER BY M_DoctorName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
// echo $this->db_regional->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_PatientID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_sex
|
||||
WHERE
|
||||
M_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_regional->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM m_religion
|
||||
WHERE
|
||||
M_ReligionIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['religions'] = $this->db_regional->query($query)->result_array();
|
||||
$query ="
|
||||
SELECT 0 as Nat_StaffID, 'Semua' as Nat_StaffName, '' as Nat_StaffNIK
|
||||
UNION
|
||||
SELECT Nat_StaffID, Nat_StaffName, Nat_StaffNIK
|
||||
FROM nat_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['staffs'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['jpas'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function searchstaff(){
|
||||
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_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y'
|
||||
AND (Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')";
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_staff count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT * FROM(SELECT *, CONCAT(Nat_StaffName, ' [',Nat_StaffNIK,']') as Nat_StaffNames
|
||||
FROM nat_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y') a
|
||||
WHERE
|
||||
(Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')
|
||||
AND Nat_StaffIsActive = 'Y'
|
||||
ORDER BY Nat_StaffName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_staff rows",$this->db_regional);
|
||||
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_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName DESC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getjpa(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query)->result_array();
|
||||
|
||||
// $rows['jpas'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
// ambil data lama
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$old_doctor = array();
|
||||
if (count($rows) > 0 ) $old_doctor = $rows[0];
|
||||
|
||||
$ispj = $prm['M_DoctorIsPJ'];
|
||||
$isdefaultpj = $prm['M_DoctorIsDefaultPJ'];
|
||||
$isdefault = $prm['M_DoctorIsDefault'];
|
||||
$isclinic = $prm['M_DoctorIsClinic'];
|
||||
if($prm['M_DoctorEmail'] == ''){
|
||||
$prm['M_DoctorEmailIsDefault'] = 'N';
|
||||
}
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorPrefix = '{$prm['M_DoctorPrefix']}',
|
||||
M_DoctorPrefix2 = '{$prm['M_DoctorPrefix2']}',
|
||||
M_DoctorName = '{$prm['M_DoctorName']}',
|
||||
M_DoctorSufix = '{$prm['M_DoctorSufix']}',
|
||||
M_DoctorSufix2 = '{$prm['M_DoctorSufix2']}',
|
||||
M_DoctorSufix3 = '{$prm['M_DoctorSufix3']}',
|
||||
M_DoctorM_SexID = '{$prm['M_DoctorM_SexID']}',
|
||||
M_DoctorM_ReligionID = '{$prm['M_DoctorM_ReligionID']}',
|
||||
M_DoctorM_StaffID = '{$prm['M_DoctorM_StaffID']}',
|
||||
M_DoctorM_StaffNIK = '{$prm['M_DoctorM_StaffNIK']}',
|
||||
M_DoctorEmail = '{$prm['M_DoctorEmail']}',
|
||||
M_DoctorHP = '{$prm['M_DoctorHP']}',
|
||||
M_DoctorNote = '{$prm['M_DoctorNote']}',
|
||||
M_DoctorPhone = '{$prm['M_DoctorPhone']}',
|
||||
M_DoctorIsMarketingConfirm = '{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
M_DoctorIsPJ = '{$prm['M_DoctorIsPJ']}',
|
||||
M_DoctorIsDefaultMcu = '{$prm['M_DoctorIsDefaultMcu']}',
|
||||
M_DoctorIsDefaultPJ = '{$prm['M_DoctorIsDefaultPJ']}',
|
||||
M_DoctorIsClinic = '{$prm['M_DoctorIsClinic']}',
|
||||
M_DoctorIsDefault = '{$prm['M_DoctorIsDefault']}',
|
||||
M_DoctorEmailIsDefault = '{$prm['M_DoctorEmailIsDefault']}'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$sqlx = "select * from m_doctorpj
|
||||
where M_DoctorPjM_DoctorID = ? and M_DoctorPjIsActive = 'Y'";
|
||||
$qryx= $this->db_regional->query($sqlx,array($prm["M_DoctorID"]));
|
||||
$rowsx = $qryx->result_array();
|
||||
if (count($rowsx) > 0 ) {
|
||||
$sql = "UPDATE m_doctorpj set
|
||||
M_DoctorPjIsPJ = ?, M_DoctorPjIsDefaultPJ = ?, M_DoctorPjIsClinic = ?, M_DoctorPjIsDefault =?
|
||||
where M_DoctorPjM_DoctorID = ? AND M_DoctorPjIsActive = 'Y'";
|
||||
$this->db_regional->query($sql, array($ispj,$isdefaultpj,$isclinic,$isdefault,$prm["M_DoctorID"]));
|
||||
if ($isdefaultpj == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefaultPj= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
if ($isdefault == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefault= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
}else{
|
||||
//sipe modifikasi ispj
|
||||
if($ispj == 'Y' || $isdefaultpj == 'Y' || $isdefault == 'Y' || $isclinic === 'Y'){
|
||||
$sql = "select * from m_doctorpj
|
||||
where M_DoctorPjM_DoctorID = ? and M_DoctorPjIsActive = 'Y' ";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$sql = "insert into m_doctorpj(M_DoctorPjM_DoctorID,
|
||||
M_DoctorPjIsPJ, M_DoctorPjIsDefaultPJ, M_DoctorPjIsClinic, M_DoctorPjIsDefault)
|
||||
values(?,?,?,?,?)";
|
||||
$this->db_regional->query($sql, array($prm["M_DoctorID"],$ispj,$isdefaultpj,$isclinic,$isdefault));
|
||||
}
|
||||
if ($isdefaultpj == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefaultPj= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
if ($isdefault == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefault= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
} else {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsActive= 'N', M_DoctorPjIsPJ = 'N'
|
||||
where M_DoctorPjM_DoctorID = ? ";
|
||||
$this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
|
||||
// ambil data baru
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$new_doctor = array();
|
||||
if (count($rows) > 0 ) $new_doctor = $rows[0];
|
||||
$d_doctor = json_encode(array("old" => $old_doctor , "new" => $new_doctor));
|
||||
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$ispj = $prm['M_DoctorIsPJ'];
|
||||
$isdefaultpj = $prm['M_DoctorIsDefaultPJ'];
|
||||
$isdefault = $prm['M_DoctorIsDefault'];
|
||||
$isclinic = $prm['M_DoctorIsClinic'];
|
||||
$query ="INSERT INTO m_doctor (
|
||||
M_DoctorPrefix,
|
||||
M_DoctorPrefix2,
|
||||
M_DoctorName,
|
||||
M_DoctorSufix,
|
||||
M_DoctorSufix2,
|
||||
M_DoctorSufix3,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorM_StaffID,
|
||||
M_DoctorM_StaffNIK,
|
||||
M_DoctorEmail,
|
||||
M_DoctorHP,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
M_DoctorIsPJ,
|
||||
M_DoctorIsDefaultMcu,
|
||||
M_DoctorIsDefaultPJ,
|
||||
M_DoctorIsClinic,
|
||||
M_DoctorIsDefault,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorM_UserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorPrefix']}',
|
||||
'{$prm['M_DoctorPrefix2']}',
|
||||
'{$prm['M_DoctorName']}',
|
||||
'{$prm['M_DoctorSufix']}',
|
||||
'{$prm['M_DoctorSufix2']}',
|
||||
'{$prm['M_DoctorSufix3']}',
|
||||
'{$prm['M_DoctorM_SexID']}',
|
||||
'{$prm['M_DoctorM_ReligionID']}',
|
||||
'{$prm['M_DoctorM_StaffID']}',
|
||||
'{$prm['M_DoctorM_StaffNIK']}',
|
||||
'{$prm['M_DoctorEmail']}',
|
||||
'{$prm['M_DoctorHP']}',
|
||||
'{$prm['M_DoctorNote']}',
|
||||
'{$prm['M_DoctorPhone']}',
|
||||
'{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
'{$prm['M_DoctorIsPJ']}',
|
||||
'{$prm['M_DoctorIsDefaultMcu']}',
|
||||
'{$prm['M_DoctorIsDefaultPJ']}',
|
||||
'{$prm['M_DoctorIsClinic']}',
|
||||
'{$prm['M_DoctorIsDefault']}',
|
||||
'{$prm['M_DoctorEmailIsDefault']}',
|
||||
$userid
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
if($rows){
|
||||
if($isdefault == 'Y'){
|
||||
$querydefault ="UPDATE m_doctorpj SET
|
||||
M_DoctorPjIsDefault = 'N' WHERE M_DoctorPjIsDefault = 'Y'
|
||||
";
|
||||
$rows = $this->db_regional->query($querydefault);
|
||||
}
|
||||
if($isdefaultpj == 'Y'){
|
||||
$querydefault ="UPDATE m_doctorpj SET
|
||||
M_DoctorPjIsDefaultPJ = 'N' WHERE M_DoctorPjIsDefaultPJ = 'Y'
|
||||
";
|
||||
$rows = $this->db_regional->query($querydefault);
|
||||
}
|
||||
if($ispj == 'Y' || $isdefaultpj == 'Y' || $isdefault == 'Y' || $isclinic === 'Y'){
|
||||
$querypj ="INSERT INTO m_doctorpj (
|
||||
M_DoctorPjM_DoctorID,
|
||||
M_DoctorPjIsPJ,
|
||||
M_DoctorPjIsDefaultPJ,
|
||||
M_DoctorPjIsClinic,
|
||||
M_DoctorPjIsDefault,
|
||||
M_DoctorPjCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$prm['M_DoctorIsPJ']}',
|
||||
'{$prm['M_DoctorIsDefaultPJ']}',
|
||||
'{$prm['M_DoctorIsClinic']}',
|
||||
'{$prm['M_DoctorIsDefault']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
$rows = $this->db_regional->query($querypj);
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
//sipe tambah log doctor
|
||||
$prm["M_DoctorID"] = $last_id;
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADD','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletedoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// sipe nambah ambil userid
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_doctoraddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,Nat_JpaName,
|
||||
'' as action
|
||||
FROM m_doctoraddress
|
||||
JOIN m_kelurahan ON M_DoctorAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
left join nat_jpa on M_DoctorAddressNat_JpaID = Nat_JpaID
|
||||
WHERE
|
||||
M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressOldCode = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function savenewaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$count_addrs = $this->db_regional->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressOldCode = '{$prm['M_DoctorAddressOldCode']}' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_regional->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_DoctorAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_regional->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressOldCode = '{$prm['M_DoctorAddressOldCode']}' AND M_DoctorAddressNote = 'Utama' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_DoctorAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_DoctorAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$query ="INSERT INTO m_doctoraddress (
|
||||
M_DoctorAddressOldCode,
|
||||
M_DoctorAddressNote,
|
||||
M_DoctorAddressDescription,
|
||||
M_DoctorAddressM_KelurahanID,
|
||||
M_DoctorAddressNat_JpaID,
|
||||
M_DoctorAddressCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorAddressOldCode']}',
|
||||
'{$prm['M_DoctorAddressNote']}',
|
||||
'{$prm['M_DoctorAddressDescription']}',
|
||||
'{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
'{$prm['M_DoctorAddressNat_JpaID']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressOldCode = '{$prm['M_DoctorAddressOldCode']}',
|
||||
M_DoctorAddressNote = '{$prm['M_DoctorAddressNote']}',
|
||||
M_DoctorAddressDescription = '{$prm['M_DoctorAddressDescription']}',
|
||||
M_DoctorAddressM_KelurahanID = '{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
M_DoctorAddressNat_JpaID = '{$prm['M_DoctorAddressNat_JpaID']}'
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
1191
one-api/application/controllers/v1/masterdata/Doctorv3.php
Normal file
1191
one-api/application/controllers/v1/masterdata/Doctorv3.php
Normal file
File diff suppressed because it is too large
Load Diff
954
one-api/application/controllers/v1/masterdata/Doctorv3.php--
Normal file
954
one-api/application/controllers/v1/masterdata/Doctorv3.php--
Normal file
@@ -0,0 +1,954 @@
|
||||
<?php
|
||||
class Doctorv3 extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nama = $prm["name"];
|
||||
$status = $prm["status"];
|
||||
$staff = $prm['staff'];
|
||||
// echo $norm;
|
||||
//echo 'dasdsa';
|
||||
$sql_where = "WHERE M_DoctorIsActive = 'Y' AND M_DoctorIsMarketingConfirm = '{$status}'";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_DoctorName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_DoctorIsMarketingConfirm = '{$status}' AND M_DoctorIsActive = 'Y' ";
|
||||
if ($sql_where != "") {
|
||||
$sql_where = " $sql_where";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
if(intval($staff) > 0){
|
||||
$sql_where = "$sql_where AND M_DoctorM_StaffNIK = '{$staff}'";
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
LEFT JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
LEFT JOIN nat_staff ON M_DoctorM_StaffNIK = Nat_StaffNIK
|
||||
|
||||
$sql_where
|
||||
GROUP BY M_DoctorID
|
||||
) x
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
$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_doctor count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$doctor_field = "
|
||||
M_DoctorID,
|
||||
M_DoctorOldCode,
|
||||
M_DoctorCode ,
|
||||
M_DoctorPrefix ,
|
||||
M_DoctorPrefix2 ,
|
||||
M_DoctorName ,
|
||||
M_DoctorSufix ,
|
||||
M_DoctorSufix2 ,
|
||||
M_DoctorSufix3 ,
|
||||
M_DoctorM_SexID ,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorM_StaffID,
|
||||
IFNULL(M_DoctorEmail,'') as M_DoctorEmail,
|
||||
M_DoctorHP ,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone ,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
ifnull(M_DoctorPjIsPJ,'N') M_DoctorIsPJ,
|
||||
ifnull(M_DoctorPjIsDefaultPJ,'N') M_DoctorIsDefaultPJ ,
|
||||
M_DoctorM_SpecialID ,
|
||||
ifnull(M_DoctorPjIsClinic,'N') M_DoctorIsClinic ,
|
||||
ifnull(M_DoctorPjIsDefault,'N') M_DoctorIsDefault ,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorIsDefaultMcu,
|
||||
M_DoctorCreated ,
|
||||
M_DoctorLastUpdated,
|
||||
M_DoctorIsActive,
|
||||
M_DoctorReportCode ,
|
||||
M_DoctorPrivateRequest,
|
||||
M_DoctorM_UserID ,
|
||||
M_DoctorM_StaffNIK,
|
||||
M_DoctorM_SpecialistID,
|
||||
DATE_FORMAT(M_DoctorDOB,'%d%m%Y') M_DoctorDOB,
|
||||
";
|
||||
$sql = "SELECT $doctor_field
|
||||
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_fullname,
|
||||
M_SexName,
|
||||
M_ReligionName,
|
||||
Nat_StaffID,
|
||||
Nat_StaffNIK,
|
||||
IF(Nat_StaffNIK = '' OR Nat_StaffNIK IS NULL, '', Nat_StaffName) as Nat_StaffName,
|
||||
IF(M_DoctorM_SpecialistID = 0 OR M_DoctorM_SpecialistID IS NULL, '', M_SpecialistName) as M_SpecialistName,
|
||||
IF(M_DoctorIsMarketingConfirm = 'N', 'Belum dikonfirmasi marketing','Sudah dikonfirmasi marketing') as status
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
left join m_doctorpj on M_DoctorID = M_DoctorPjM_DoctorID AND M_DoctorPjIsActive = 'Y'
|
||||
left JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
left JOIN nat_staff ON M_DoctorM_StaffNIK = Nat_StaffNIK
|
||||
LEFT JOIN m_specialist ON M_DoctorM_SpecialistID = M_SpecialistID
|
||||
$sql_where
|
||||
GROUP BY M_DoctorID
|
||||
ORDER BY M_DoctorName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
//echo $this->db_regional->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_PatientID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_sex
|
||||
WHERE
|
||||
M_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_regional->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM m_religion
|
||||
WHERE
|
||||
M_ReligionIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['religions'] = $this->db_regional->query($query)->result_array();
|
||||
$query ="
|
||||
SELECT 0 as Nat_StaffID, 'Semua' as Nat_StaffName, '' as Nat_StaffNIK
|
||||
UNION
|
||||
SELECT Nat_StaffID, Nat_StaffName, Nat_StaffNIK
|
||||
FROM nat_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['staffs'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['jpas'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query =" SELECT M_SpecialistID as id, M_SpecialistName as name
|
||||
FROM m_specialist
|
||||
WHERE
|
||||
M_SpecialistIsActive = 'Y'
|
||||
";
|
||||
// echo $query;
|
||||
$rows['specialistes'] = $this->db_regional->query($query)->result_array();
|
||||
//print_r($rows['specialistes']);
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function searchstaff(){
|
||||
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_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y'
|
||||
AND (Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')";
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_staff count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT * FROM(SELECT *, CONCAT(Nat_StaffName, ' [',Nat_StaffNIK,']') as Nat_StaffNames
|
||||
FROM nat_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y') a
|
||||
WHERE
|
||||
(Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')
|
||||
AND Nat_StaffIsActive = 'Y'
|
||||
ORDER BY Nat_StaffName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_staff rows",$this->db_regional);
|
||||
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_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName DESC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getjpa(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query)->result_array();
|
||||
|
||||
// $rows['jpas'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
// ambil data lama
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$old_doctor = array();
|
||||
if (count($rows) > 0 ) $old_doctor = $rows[0];
|
||||
|
||||
if($prm['M_DoctorEmail'] == ''){
|
||||
$prm['M_DoctorEmailIsDefault'] = 'N';
|
||||
}
|
||||
$x_dob = $prm['M_DoctorDOB'];
|
||||
$updated_dob = substr($x_dob, 0,2).'-'.substr($x_dob, 2,2).'-'.substr($x_dob, 4,4);
|
||||
$xxdob = date("Y-m-d", strtotime($updated_dob));
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorPrefix = '{$prm['M_DoctorPrefix']}',
|
||||
M_DoctorPrefix2 = '{$prm['M_DoctorPrefix2']}',
|
||||
M_DoctorName = '{$prm['M_DoctorName']}',
|
||||
M_DoctorSufix = '{$prm['M_DoctorSufix']}',
|
||||
M_DoctorSufix2 = '{$prm['M_DoctorSufix2']}',
|
||||
M_DoctorSufix3 = '{$prm['M_DoctorSufix3']}',
|
||||
M_DoctorM_SexID = '{$prm['M_DoctorM_SexID']}',
|
||||
M_DoctorM_ReligionID = '{$prm['M_DoctorM_ReligionID']}',
|
||||
M_DoctorM_StaffID = '{$prm['M_DoctorM_StaffID']}',
|
||||
M_DoctorM_StaffNIK = '{$prm['M_DoctorM_StaffNIK']}',
|
||||
M_DoctorEmail = '{$prm['M_DoctorEmail']}',
|
||||
M_DoctorHP = '{$prm['M_DoctorHP']}',
|
||||
M_DoctorNote = '{$prm['M_DoctorNote']}',
|
||||
M_DoctorPhone = '{$prm['M_DoctorPhone']}',
|
||||
M_DoctorIsMarketingConfirm = '{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
M_DoctorEmailIsDefault = '{$prm['M_DoctorEmailIsDefault']}',
|
||||
M_DoctorDOB = '{$xxdob}',
|
||||
M_DoctorM_SpecialistID = {$prm['M_DoctorM_SpecialistID']}
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
if($rows){
|
||||
|
||||
$data = json_encode($prm);
|
||||
//print_r($prm);
|
||||
$md5 = md5($data);
|
||||
$param = array("data" => $data, "md5" => $md5);
|
||||
$jparam = json_encode($param);
|
||||
|
||||
$sql = "SELECT * FROM m_branch WHERE M_BranchIsActive = 'Y'";
|
||||
$branches = $this->db_regional->query($sql)->result_array();
|
||||
foreach($branches as $k => $v){
|
||||
try {
|
||||
$sql = "INSERT INTO doctortobranch (
|
||||
DoctorToBranchM_DoctorID,
|
||||
DoctorToBranchM_BranchIPAddress,
|
||||
DoctorToBranchCreated,
|
||||
DoctorToBranchUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['M_DoctorID']},
|
||||
'{$v['M_BranchIPAddress']}',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_regional->query($sql);
|
||||
$last_xid = $this->db_regional->insert_id();
|
||||
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/updatedoctor/";
|
||||
|
||||
//echo "Uploading : ".$prm['M_DoctorName'];
|
||||
$j_result = $this->post($url,$jparam);
|
||||
$result = json_decode($j_result,true);
|
||||
//print_r($result);
|
||||
//echo $result["qry"];
|
||||
if ($result["status"] == "OK") {
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
else{
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
//throw new Exception("ERRR : " . $result["qry"] . "\n");
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
//echo $message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
|
||||
// ambil data baru
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$new_doctor = array();
|
||||
if (count($rows) > 0 ) $new_doctor = $rows[0];
|
||||
$d_doctor = json_encode(array("old" => $old_doctor , "new" => $new_doctor));
|
||||
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//echo 'Yihaa';
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
///print_r($prm);
|
||||
$prm['userid'] = $userid;
|
||||
if(!$prm['M_DoctorM_StaffID'])
|
||||
$prm['M_DoctorM_StaffID'] = 0;
|
||||
|
||||
$x_dob = $prm['M_DoctorDOB'];
|
||||
$updated_dob = substr($x_dob, 0,2).'-'.substr($x_dob, 2,2).'-'.substr($x_dob, 4,4);
|
||||
$xxdob = date("Y-m-d", strtotime($updated_dob));
|
||||
|
||||
$query ="INSERT INTO m_doctor (
|
||||
M_DoctorPrefix,
|
||||
M_DoctorPrefix2,
|
||||
M_DoctorName,
|
||||
M_DoctorSufix,
|
||||
M_DoctorSufix2,
|
||||
M_DoctorSufix3,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorM_StaffID,
|
||||
M_DoctorM_StaffNIK,
|
||||
M_DoctorEmail,
|
||||
M_DoctorHP,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorDOB,
|
||||
M_DoctorM_SpecialistID,
|
||||
M_DoctorM_UserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorPrefix']}',
|
||||
'{$prm['M_DoctorPrefix2']}',
|
||||
'{$prm['M_DoctorName']}',
|
||||
'{$prm['M_DoctorSufix']}',
|
||||
'{$prm['M_DoctorSufix2']}',
|
||||
'{$prm['M_DoctorSufix3']}',
|
||||
'{$prm['M_DoctorM_SexID']}',
|
||||
'{$prm['M_DoctorM_ReligionID']}',
|
||||
'{$prm['M_DoctorM_StaffID']}',
|
||||
'{$prm['M_DoctorM_StaffNIK']}',
|
||||
'{$prm['M_DoctorEmail']}',
|
||||
'{$prm['M_DoctorHP']}',
|
||||
'{$prm['M_DoctorNote']}',
|
||||
'{$prm['M_DoctorPhone']}',
|
||||
'{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
'{$prm['M_DoctorEmailIsDefault']}',
|
||||
'{$xxdob}',
|
||||
'{$prm['M_DoctorM_SpecialistID']}',
|
||||
$userid
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
if($rows){
|
||||
|
||||
$data = json_encode($prm);
|
||||
//print_r($prm);
|
||||
$md5 = md5($data);
|
||||
$param = array("data" => $data, "md5" => $md5);
|
||||
$jparam = json_encode($param);
|
||||
|
||||
$sql = "SELECT * FROM m_branch WHERE M_BranchIsActive = 'Y'";
|
||||
$branches = $this->db_regional->query($sql)->result_array();
|
||||
foreach($branches as $k => $v){
|
||||
try {
|
||||
$sql = "INSERT INTO doctortobranch (
|
||||
DoctorToBranchM_DoctorID,
|
||||
DoctorToBranchM_BranchIPAddress,
|
||||
DoctorToBranchCreated,
|
||||
DoctorToBranchUserID
|
||||
)
|
||||
VALUES(
|
||||
{$last_id},
|
||||
'{$v['M_BranchIPAddress']}',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_regional->query($sql);
|
||||
$last_xid = $this->db_regional->insert_id();
|
||||
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/downloaddoctor/";
|
||||
//echo "Uploading : ".$prm['M_DoctorName'];
|
||||
$j_result = $this->post($url,$jparam);
|
||||
$result = json_decode($j_result,true);
|
||||
//echo $result["qry"];
|
||||
if ($result["status"] == "OK") {
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
else{
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
//throw new Exception("ERR : " . $result["message"] . "\n");
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
//echo $message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
//sipe tambah log doctor
|
||||
$prm["M_DoctorID"] = $last_id;
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADD','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function deletedoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// sipe nambah ambil userid
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_doctoraddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,Nat_JpaName,
|
||||
'' as action
|
||||
FROM m_doctoraddress
|
||||
JOIN m_kelurahan ON M_DoctorAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
left join nat_jpa on M_DoctorAddressNat_JpaID = Nat_JpaID
|
||||
WHERE
|
||||
M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function savenewaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$count_addrs = $this->db_regional->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorOldCode = '{$prm['M_DoctorAddressM_DoctorOldCode']}' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_regional->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_DoctorAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_regional->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorOldCode = '{$prm['M_DoctorAddressM_DoctorOldCode']}' AND M_DoctorAddressNote = 'Utama' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_DoctorAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_DoctorAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$query ="INSERT INTO m_doctoraddress (
|
||||
M_DoctorAddressM_DoctorID,
|
||||
M_DoctorAddressNote,
|
||||
M_DoctorAddressDescription,
|
||||
M_DoctorAddressM_KelurahanID,
|
||||
M_DoctorAddressNat_JpaID,
|
||||
M_DoctorAddressLastUpdated,
|
||||
M_DoctorAddressCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorAddressM_DoctorID']}',
|
||||
'{$prm['M_DoctorAddressNote']}',
|
||||
'{$prm['M_DoctorAddressDescription']}',
|
||||
'{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
'{$prm['M_DoctorAddressNat_JpaID']}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
if($rows){
|
||||
$data = json_encode($prm);
|
||||
//print_r($prm);
|
||||
$md5 = md5($data);
|
||||
$param = array("data" => $data, "md5" => $md5);
|
||||
$jparam = json_encode($param);
|
||||
|
||||
$sql = "SELECT * FROM m_branch WHERE M_BranchIsActive = 'Y'";
|
||||
$branches = $this->db_regional->query($sql)->result_array();
|
||||
foreach($branches as $k => $v){
|
||||
try {
|
||||
$sql = "INSERT INTO doctortobranch (
|
||||
DoctorToBranchM_DoctorID,
|
||||
DoctorToBranchM_BranchIPAddress,
|
||||
DoctorToBranchType,
|
||||
DoctorToBranchCreated,
|
||||
DoctorToBranchUserID
|
||||
)
|
||||
VALUES(
|
||||
{$last_id},
|
||||
'{$v['M_BranchIPAddress']}',
|
||||
'A',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_regional->query($sql);
|
||||
$last_xid = $this->db_regional->insert_id();
|
||||
//echo $last_xid;
|
||||
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/newaddressdoctor/";
|
||||
//echo $url;
|
||||
//echo "Uploading : ".$prm['M_DoctorName'];
|
||||
$j_result = $this->post($url,$jparam);
|
||||
$result = json_decode($j_result,true);
|
||||
//echo $result["qry"];
|
||||
if ($result["status"] == "OK") {
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
else{
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
//throw new Exception("ERRZ : " . $result["message"] . "\n");
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
//echo $message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}',
|
||||
M_DoctorAddressNote = '{$prm['M_DoctorAddressNote']}',
|
||||
M_DoctorAddressDescription = '{$prm['M_DoctorAddressDescription']}',
|
||||
M_DoctorAddressM_KelurahanID = '{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
M_DoctorAddressNat_JpaID = '{$prm['M_DoctorAddressNat_JpaID']}',
|
||||
M_DoctorAddressLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $prm['M_DoctorAddressID'];
|
||||
if($rows){
|
||||
$data = json_encode($prm);
|
||||
//print_r($prm);
|
||||
$md5 = md5($data);
|
||||
$param = array("data" => $data, "md5" => $md5);
|
||||
$jparam = json_encode($param);
|
||||
|
||||
$sql = "SELECT * FROM m_branch WHERE M_BranchIsActive = 'Y'";
|
||||
$branches = $this->db_regional->query($sql)->result_array();
|
||||
foreach($branches as $k => $v){
|
||||
try {
|
||||
$sql = "INSERT INTO doctortobranch (
|
||||
DoctorToBranchM_DoctorID,
|
||||
DoctorToBranchM_BranchIPAddress,
|
||||
DoctorToBranchType,
|
||||
DoctorToBranchCreated,
|
||||
DoctorToBranchUserID
|
||||
)
|
||||
VALUES(
|
||||
{$last_id},
|
||||
'{$v['M_BranchIPAddress']}',
|
||||
'A',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_regional->query($sql);
|
||||
$last_xid = $this->db_regional->insert_id();
|
||||
//echo $last_xid;
|
||||
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/updateaddressdoctor/";
|
||||
//echo $url;
|
||||
//echo "Uploading : ".$prm['M_DoctorName'];
|
||||
$j_result = $this->post($url,$jparam);
|
||||
$result = json_decode($j_result,true);
|
||||
//echo $result["qry"];
|
||||
if ($result["status"] == "OK") {
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
else{
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
//throw new Exception("ERRZ : " . $result["message"] . "\n");
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
//echo $message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressIsActive = 'N',
|
||||
M_DoctorAddressLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
1191
one-api/application/controllers/v1/masterdata/Doctorv3.php-130720
Normal file
1191
one-api/application/controllers/v1/masterdata/Doctorv3.php-130720
Normal file
File diff suppressed because it is too large
Load Diff
1185
one-api/application/controllers/v1/masterdata/Doctorv3.php-140420
Normal file
1185
one-api/application/controllers/v1/masterdata/Doctorv3.php-140420
Normal file
File diff suppressed because it is too large
Load Diff
1488
one-api/application/controllers/v1/masterdata/Doctorv3x.php
Normal file
1488
one-api/application/controllers/v1/masterdata/Doctorv3x.php
Normal file
File diff suppressed because it is too large
Load Diff
1452
one-api/application/controllers/v1/masterdata/Doctorv3x.php-190720
Normal file
1452
one-api/application/controllers/v1/masterdata/Doctorv3x.php-190720
Normal file
File diff suppressed because it is too large
Load Diff
1378
one-api/application/controllers/v1/masterdata/Doctorv3x.phpafasfa
Normal file
1378
one-api/application/controllers/v1/masterdata/Doctorv3x.phpafasfa
Normal file
File diff suppressed because it is too large
Load Diff
1469
one-api/application/controllers/v1/masterdata/Doctorv3x2.php
Normal file
1469
one-api/application/controllers/v1/masterdata/Doctorv3x2.php
Normal file
File diff suppressed because it is too large
Load Diff
952
one-api/application/controllers/v1/masterdata/Doctorv4.php
Normal file
952
one-api/application/controllers/v1/masterdata/Doctorv4.php
Normal file
@@ -0,0 +1,952 @@
|
||||
<?php
|
||||
class Doctorv4 extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nama = $prm["name"];
|
||||
$status = $prm["status"];
|
||||
$staff = $prm['staff'];
|
||||
// echo $norm;
|
||||
//echo 'dasdsa';
|
||||
$sql_where = "WHERE M_DoctorIsActive = 'Y' AND M_DoctorIsMarketingConfirm = '{$status}'";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_DoctorName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_DoctorIsMarketingConfirm = '{$status}' AND M_DoctorIsActive = 'Y' ";
|
||||
if ($sql_where != "") {
|
||||
$sql_where = "$sql_where";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
if(intval($staff) > 0){
|
||||
$sql_where = "$sql_where AND M_DoctorM_StaffNIK = '{$staff}'";
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
LEFT JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
LEFT JOIN nat_staff ON M_DoctorM_StaffNIK = Nat_StaffNIK
|
||||
|
||||
$sql_where
|
||||
GROUP BY M_DoctorID
|
||||
) x
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
$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_doctor count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$doctor_field = "
|
||||
M_DoctorID,
|
||||
M_DoctorOldCode,
|
||||
M_DoctorCode ,
|
||||
M_DoctorPrefix ,
|
||||
M_DoctorPrefix2 ,
|
||||
M_DoctorName ,
|
||||
M_DoctorSufix ,
|
||||
M_DoctorSufix2 ,
|
||||
M_DoctorSufix3 ,
|
||||
M_DoctorM_SexID ,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorM_StaffID,
|
||||
IFNULL(M_DoctorEmail,'') as M_DoctorEmail,
|
||||
M_DoctorHP ,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone ,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
ifnull(M_DoctorPjIsPJ,'N') M_DoctorIsPJ,
|
||||
ifnull(M_DoctorPjIsDefaultPJ,'N') M_DoctorIsDefaultPJ ,
|
||||
M_DoctorM_SpecialID ,
|
||||
ifnull(M_DoctorPjIsClinic,'N') M_DoctorIsClinic ,
|
||||
ifnull(M_DoctorPjIsDefault,'N') M_DoctorIsDefault ,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorIsDefaultMcu,
|
||||
M_DoctorCreated ,
|
||||
M_DoctorLastUpdated,
|
||||
M_DoctorIsActive,
|
||||
M_DoctorReportCode ,
|
||||
M_DoctorPrivateRequest,
|
||||
M_DoctorM_UserID ,
|
||||
M_DoctorM_StaffNIK,
|
||||
M_DoctorM_SpecialistID,
|
||||
DATE_FORMAT(M_DoctorDOB,'%d%m%Y') M_DoctorDOB,
|
||||
";
|
||||
$sql = "SELECT $doctor_field
|
||||
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_fullname,
|
||||
M_SexName,
|
||||
M_ReligionName,
|
||||
Nat_StaffID,
|
||||
Nat_StaffNIK,
|
||||
IF(Nat_StaffNIK = '' OR Nat_StaffNIK IS NULL, '', Nat_StaffName) as Nat_StaffName,
|
||||
IF(M_DoctorM_SpecialistID = 0 OR M_DoctorM_SpecialistID IS NULL, '', M_SpecialistName) as M_SpecialistName,
|
||||
IF(M_DoctorIsMarketingConfirm = 'N', 'Belum dikonfirmasi marketing','Sudah dikonfirmasi marketing') as status
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
left join m_doctorpj on M_DoctorID = M_DoctorPjM_DoctorID AND M_DoctorPjIsActive = 'Y'
|
||||
left JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
left JOIN nat_staff ON M_DoctorM_StaffNIK = Nat_StaffNIK
|
||||
LEFT JOIN m_specialist ON M_DoctorM_SpecialistID = M_SpecialistID
|
||||
$sql_where
|
||||
GROUP BY M_DoctorID
|
||||
ORDER BY M_DoctorName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
//echo $this->db_regional->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_PatientID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_sex
|
||||
WHERE
|
||||
M_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_regional->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM m_religion
|
||||
WHERE
|
||||
M_ReligionIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['religions'] = $this->db_regional->query($query)->result_array();
|
||||
$query ="
|
||||
SELECT 0 as Nat_StaffID, 'Semua' as Nat_StaffName, '' as Nat_StaffNIK
|
||||
UNION
|
||||
SELECT Nat_StaffID, Nat_StaffName, Nat_StaffNIK
|
||||
FROM nat_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['staffs'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['jpas'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query =" SELECT M_SpecialistID as id, M_SpecialistName as name
|
||||
FROM m_specialist
|
||||
WHERE
|
||||
M_SpecialistIsActive = 'Y'
|
||||
";
|
||||
// echo $query;
|
||||
$rows['specialistes'] = $this->db_regional->query($query)->result_array();
|
||||
//print_r($rows['specialistes']);
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function searchstaff(){
|
||||
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_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y'
|
||||
AND (Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')";
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_staff count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT * FROM(SELECT *, CONCAT(Nat_StaffName, ' [',Nat_StaffNIK,']') as Nat_StaffNames
|
||||
FROM nat_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y') a
|
||||
WHERE
|
||||
(Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')
|
||||
AND Nat_StaffIsActive = 'Y'
|
||||
ORDER BY Nat_StaffName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_staff rows",$this->db_regional);
|
||||
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_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName DESC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getjpa(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query)->result_array();
|
||||
|
||||
// $rows['jpas'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
// ambil data lama
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$old_doctor = array();
|
||||
if (count($rows) > 0 ) $old_doctor = $rows[0];
|
||||
|
||||
if($prm['M_DoctorEmail'] == ''){
|
||||
$prm['M_DoctorEmailIsDefault'] = 'N';
|
||||
}
|
||||
$x_dob = $prm['M_DoctorDOB'];
|
||||
$updated_dob = substr($x_dob, 0,2).'-'.substr($x_dob, 2,2).'-'.substr($x_dob, 4,4);
|
||||
$xxdob = date("Y-m-d", strtotime($updated_dob));
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorPrefix = '{$prm['M_DoctorPrefix']}',
|
||||
M_DoctorPrefix2 = '{$prm['M_DoctorPrefix2']}',
|
||||
M_DoctorName = '{$prm['M_DoctorName']}',
|
||||
M_DoctorSufix = '{$prm['M_DoctorSufix']}',
|
||||
M_DoctorSufix2 = '{$prm['M_DoctorSufix2']}',
|
||||
M_DoctorSufix3 = '{$prm['M_DoctorSufix3']}',
|
||||
M_DoctorM_SexID = '{$prm['M_DoctorM_SexID']}',
|
||||
M_DoctorM_ReligionID = '{$prm['M_DoctorM_ReligionID']}',
|
||||
M_DoctorM_StaffID = '{$prm['M_DoctorM_StaffID']}',
|
||||
M_DoctorM_StaffNIK = '{$prm['M_DoctorM_StaffNIK']}',
|
||||
M_DoctorEmail = '{$prm['M_DoctorEmail']}',
|
||||
M_DoctorHP = '{$prm['M_DoctorHP']}',
|
||||
M_DoctorNote = '{$prm['M_DoctorNote']}',
|
||||
M_DoctorPhone = '{$prm['M_DoctorPhone']}',
|
||||
M_DoctorIsMarketingConfirm = '{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
M_DoctorEmailIsDefault = '{$prm['M_DoctorEmailIsDefault']}',
|
||||
M_DoctorDOB = '{$xxdob}',
|
||||
M_DoctorM_SpecialistID = {$prm['M_DoctorM_SpecialistID']}
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
if($rows){
|
||||
|
||||
$data = json_encode($prm);
|
||||
//print_r($prm);
|
||||
$md5 = md5($data);
|
||||
$param = array("data" => $data, "md5" => $md5);
|
||||
$jparam = json_encode($param);
|
||||
|
||||
$sql = "SELECT * FROM m_branch WHERE M_BranchIsActive = 'Y'";
|
||||
$branches = $this->db_regional->query($sql)->result_array();
|
||||
foreach($branches as $k => $v){
|
||||
try {
|
||||
$sql = "INSERT INTO doctortobranch (
|
||||
DoctorToBranchM_DoctorID,
|
||||
DoctorToBranchM_BranchIPAddress,
|
||||
DoctorToBranchCreated,
|
||||
DoctorToBranchUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['M_DoctorID']},
|
||||
'{$v['M_BranchIPAddress']}',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_regional->query($sql);
|
||||
$last_xid = $this->db_regional->insert_id();
|
||||
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/updatedoctor/";
|
||||
|
||||
//echo "Uploading : ".$prm['M_DoctorName'];
|
||||
$j_result = $this->post($url,$jparam);
|
||||
$result = json_decode($j_result,true);
|
||||
//print_r($result);
|
||||
//echo $result["qry"];
|
||||
if ($result["status"] == "OK") {
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
else{
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
throw new Exception("ERRR : " . $result["qry"] . "\n");
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
echo $message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
|
||||
// ambil data baru
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$new_doctor = array();
|
||||
if (count($rows) > 0 ) $new_doctor = $rows[0];
|
||||
$d_doctor = json_encode(array("old" => $old_doctor , "new" => $new_doctor));
|
||||
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//echo 'Yihaa';
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
///print_r($prm);
|
||||
$prm['userid'] = $userid;
|
||||
if(!$prm['M_DoctorM_StaffID'])
|
||||
$prm['M_DoctorM_StaffID'] = 0;
|
||||
|
||||
$x_dob = $prm['M_DoctorDOB'];
|
||||
$updated_dob = substr($x_dob, 0,2).'-'.substr($x_dob, 2,2).'-'.substr($x_dob, 4,4);
|
||||
$xxdob = date("Y-m-d", strtotime($updated_dob));
|
||||
|
||||
$query ="INSERT INTO m_doctor (
|
||||
M_DoctorPrefix,
|
||||
M_DoctorPrefix2,
|
||||
M_DoctorName,
|
||||
M_DoctorSufix,
|
||||
M_DoctorSufix2,
|
||||
M_DoctorSufix3,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorM_StaffID,
|
||||
M_DoctorM_StaffNIK,
|
||||
M_DoctorEmail,
|
||||
M_DoctorHP,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorDOB,
|
||||
M_DoctorM_SpecialistID,
|
||||
M_DoctorM_UserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorPrefix']}',
|
||||
'{$prm['M_DoctorPrefix2']}',
|
||||
'{$prm['M_DoctorName']}',
|
||||
'{$prm['M_DoctorSufix']}',
|
||||
'{$prm['M_DoctorSufix2']}',
|
||||
'{$prm['M_DoctorSufix3']}',
|
||||
'{$prm['M_DoctorM_SexID']}',
|
||||
'{$prm['M_DoctorM_ReligionID']}',
|
||||
'{$prm['M_DoctorM_StaffID']}',
|
||||
'{$prm['M_DoctorM_StaffNIK']}',
|
||||
'{$prm['M_DoctorEmail']}',
|
||||
'{$prm['M_DoctorHP']}',
|
||||
'{$prm['M_DoctorNote']}',
|
||||
'{$prm['M_DoctorPhone']}',
|
||||
'{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
'{$prm['M_DoctorEmailIsDefault']}',
|
||||
'{$xxdob}',
|
||||
'{$prm['M_DoctorM_SpecialistID']}',
|
||||
$userid
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
if($rows){
|
||||
|
||||
$data = json_encode($prm);
|
||||
//print_r($prm);
|
||||
$md5 = md5($data);
|
||||
$param = array("data" => $data, "md5" => $md5);
|
||||
$jparam = json_encode($param);
|
||||
|
||||
$sql = "SELECT * FROM m_branch WHERE M_BranchIsActive = 'Y'";
|
||||
$branches = $this->db_regional->query($sql)->result_array();
|
||||
foreach($branches as $k => $v){
|
||||
try {
|
||||
$sql = "INSERT INTO doctortobranch (
|
||||
DoctorToBranchM_DoctorID,
|
||||
DoctorToBranchM_BranchIPAddress,
|
||||
DoctorToBranchCreated,
|
||||
DoctorToBranchUserID
|
||||
)
|
||||
VALUES(
|
||||
{$last_id},
|
||||
'{$v['M_BranchIPAddress']}',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_regional->query($sql);
|
||||
$last_xid = $this->db_regional->insert_id();
|
||||
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/downloaddoctor/";
|
||||
//echo "Uploading : ".$prm['M_DoctorName'];
|
||||
$j_result = $this->post($url,$jparam);
|
||||
$result = json_decode($j_result,true);
|
||||
//echo $result["qry"];
|
||||
if ($result["status"] == "OK") {
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
else{
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
throw new Exception("ERR : " . $result["message"] . "\n");
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
echo $message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
//sipe tambah log doctor
|
||||
$prm["M_DoctorID"] = $last_id;
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADD','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function deletedoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// sipe nambah ambil userid
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_doctoraddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,Nat_JpaName,
|
||||
'' as action
|
||||
FROM m_doctoraddress
|
||||
JOIN m_kelurahan ON M_DoctorAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
left join nat_jpa on M_DoctorAddressNat_JpaID = Nat_JpaID
|
||||
WHERE
|
||||
M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function savenewaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$count_addrs = $this->db_regional->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorOldCode = '{$prm['M_DoctorAddressM_DoctorOldCode']}' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_regional->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_DoctorAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_regional->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorOldCode = '{$prm['M_DoctorAddressM_DoctorOldCode']}' AND M_DoctorAddressNote = 'Utama' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_DoctorAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_DoctorAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$query ="INSERT INTO m_doctoraddress (
|
||||
M_DoctorAddressM_DoctorOldCode,
|
||||
M_DoctorAddressNote,
|
||||
M_DoctorAddressDescription,
|
||||
M_DoctorAddressM_KelurahanID,
|
||||
M_DoctorAddressNat_JpaID,
|
||||
M_DoctorAddressLastUpdated,
|
||||
M_DoctorAddressCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorAddressM_DoctorOldCode']}',
|
||||
'{$prm['M_DoctorAddressNote']}',
|
||||
'{$prm['M_DoctorAddressDescription']}',
|
||||
'{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
'{$prm['M_DoctorAddressNat_JpaID']}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
if($rows){
|
||||
$data = json_encode($prm);
|
||||
//print_r($prm);
|
||||
$md5 = md5($data);
|
||||
$param = array("data" => $data, "md5" => $md5);
|
||||
$jparam = json_encode($param);
|
||||
|
||||
$sql = "SELECT * FROM m_branch WHERE M_BranchIsActive = 'Y'";
|
||||
$branches = $this->db_regional->query($sql)->result_array();
|
||||
foreach($branches as $k => $v){
|
||||
try {
|
||||
$sql = "INSERT INTO doctortobranch (
|
||||
DoctorToBranchM_DoctorID,
|
||||
DoctorToBranchM_BranchIPAddress,
|
||||
DoctorToBranchType,
|
||||
DoctorToBranchCreated,
|
||||
DoctorToBranchUserID
|
||||
)
|
||||
VALUES(
|
||||
{$last_id},
|
||||
'{$v['M_BranchIPAddress']}',
|
||||
'A',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_regional->query($sql);
|
||||
$last_xid = $this->db_regional->insert_id();
|
||||
//echo $last_xid;
|
||||
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/newaddressdoctor/";
|
||||
//echo $url;
|
||||
//echo "Uploading : ".$prm['M_DoctorName'];
|
||||
$j_result = $this->post($url,$jparam);
|
||||
$result = json_decode($j_result,true);
|
||||
//echo $result["qry"];
|
||||
if ($result["status"] == "OK") {
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
else{
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
throw new Exception("ERRZ : " . $result["message"] . "\n");
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
echo $message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressM_DoctorOldCode = '{$prm['M_DoctorAddressM_DoctorOldCode']}',
|
||||
M_DoctorAddressNote = '{$prm['M_DoctorAddressNote']}',
|
||||
M_DoctorAddressDescription = '{$prm['M_DoctorAddressDescription']}',
|
||||
M_DoctorAddressM_KelurahanID = '{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
M_DoctorAddressNat_JpaID = '{$prm['M_DoctorAddressNat_JpaID']}',
|
||||
M_DoctorAddressLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $prm['M_DoctorAddressID'];
|
||||
if($rows){
|
||||
$data = json_encode($prm);
|
||||
//print_r($prm);
|
||||
$md5 = md5($data);
|
||||
$param = array("data" => $data, "md5" => $md5);
|
||||
$jparam = json_encode($param);
|
||||
|
||||
$sql = "SELECT * FROM m_branch WHERE M_BranchIsActive = 'Y'";
|
||||
$branches = $this->db_regional->query($sql)->result_array();
|
||||
foreach($branches as $k => $v){
|
||||
try {
|
||||
$sql = "INSERT INTO doctortobranch (
|
||||
DoctorToBranchM_DoctorID,
|
||||
DoctorToBranchM_BranchIPAddress,
|
||||
DoctorToBranchType,
|
||||
DoctorToBranchCreated,
|
||||
DoctorToBranchUserID
|
||||
)
|
||||
VALUES(
|
||||
{$last_id},
|
||||
'{$v['M_BranchIPAddress']}',
|
||||
'A',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_regional->query($sql);
|
||||
$last_xid = $this->db_regional->insert_id();
|
||||
//echo $last_xid;
|
||||
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/updateaddressdoctor/";
|
||||
//echo $url;
|
||||
//echo "Uploading : ".$prm['M_DoctorName'];
|
||||
$j_result = $this->post($url,$jparam);
|
||||
$result = json_decode($j_result,true);
|
||||
//echo $result["qry"];
|
||||
if ($result["status"] == "OK") {
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
else{
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
throw new Exception("ERRZ : " . $result["message"] . "\n");
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
echo $message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressIsActive = 'N',
|
||||
M_DoctorAddressLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
952
one-api/application/controllers/v1/masterdata/Doctorv4.php--
Normal file
952
one-api/application/controllers/v1/masterdata/Doctorv4.php--
Normal file
@@ -0,0 +1,952 @@
|
||||
<?php
|
||||
class Doctorv4 extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nama = $prm["name"];
|
||||
$status = $prm["status"];
|
||||
$staff = $prm['staff'];
|
||||
// echo $norm;
|
||||
//echo 'dasdsa';
|
||||
$sql_where = "WHERE M_DoctorIsActive = 'Y' AND M_DoctorIsMarketingConfirm = '{$status}'";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_DoctorName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_DoctorIsMarketingConfirm = '{$status}' AND M_DoctorIsActive = 'Y' ";
|
||||
if ($sql_where != "") {
|
||||
$sql_where = "$sql_where";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
if(intval($staff) > 0){
|
||||
$sql_where = "$sql_where AND M_DoctorM_StaffNIK = '{$staff}'";
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
LEFT JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
LEFT JOIN nat_staff ON M_DoctorM_StaffNIK = Nat_StaffNIK
|
||||
|
||||
$sql_where
|
||||
GROUP BY M_DoctorID
|
||||
) x
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
$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_doctor count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$doctor_field = "
|
||||
M_DoctorID,
|
||||
M_DoctorOldCode,
|
||||
M_DoctorCode ,
|
||||
M_DoctorPrefix ,
|
||||
M_DoctorPrefix2 ,
|
||||
M_DoctorName ,
|
||||
M_DoctorSufix ,
|
||||
M_DoctorSufix2 ,
|
||||
M_DoctorSufix3 ,
|
||||
M_DoctorM_SexID ,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorM_StaffID,
|
||||
IFNULL(M_DoctorEmail,'') as M_DoctorEmail,
|
||||
M_DoctorHP ,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone ,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
ifnull(M_DoctorPjIsPJ,'N') M_DoctorIsPJ,
|
||||
ifnull(M_DoctorPjIsDefaultPJ,'N') M_DoctorIsDefaultPJ ,
|
||||
M_DoctorM_SpecialID ,
|
||||
ifnull(M_DoctorPjIsClinic,'N') M_DoctorIsClinic ,
|
||||
ifnull(M_DoctorPjIsDefault,'N') M_DoctorIsDefault ,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorIsDefaultMcu,
|
||||
M_DoctorCreated ,
|
||||
M_DoctorLastUpdated,
|
||||
M_DoctorIsActive,
|
||||
M_DoctorReportCode ,
|
||||
M_DoctorPrivateRequest,
|
||||
M_DoctorM_UserID ,
|
||||
M_DoctorM_StaffNIK,
|
||||
M_DoctorM_SpecialistID,
|
||||
DATE_FORMAT(M_DoctorDOB,'%d%m%Y') M_DoctorDOB,
|
||||
";
|
||||
$sql = "SELECT $doctor_field
|
||||
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_fullname,
|
||||
M_SexName,
|
||||
M_ReligionName,
|
||||
Nat_StaffID,
|
||||
Nat_StaffNIK,
|
||||
IF(Nat_StaffNIK = '' OR Nat_StaffNIK IS NULL, '', Nat_StaffName) as Nat_StaffName,
|
||||
IF(M_DoctorM_SpecialistID = 0 OR M_DoctorM_SpecialistID IS NULL, '', M_SpecialistName) as M_SpecialistName,
|
||||
IF(M_DoctorIsMarketingConfirm = 'N', 'Belum dikonfirmasi marketing','Sudah dikonfirmasi marketing') as status
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
left join m_doctorpj on M_DoctorID = M_DoctorPjM_DoctorID AND M_DoctorPjIsActive = 'Y'
|
||||
left JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
left JOIN nat_staff ON M_DoctorM_StaffNIK = Nat_StaffNIK
|
||||
LEFT JOIN m_specialist ON M_DoctorM_SpecialistID = M_SpecialistID
|
||||
$sql_where
|
||||
GROUP BY M_DoctorID
|
||||
ORDER BY M_DoctorName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
//echo $this->db_regional->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_PatientID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_sex
|
||||
WHERE
|
||||
M_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_regional->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM m_religion
|
||||
WHERE
|
||||
M_ReligionIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['religions'] = $this->db_regional->query($query)->result_array();
|
||||
$query ="
|
||||
SELECT 0 as Nat_StaffID, 'Semua' as Nat_StaffName, '' as Nat_StaffNIK
|
||||
UNION
|
||||
SELECT Nat_StaffID, Nat_StaffName, Nat_StaffNIK
|
||||
FROM nat_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['staffs'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['jpas'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query =" SELECT M_SpecialistID as id, M_SpecialistName as name
|
||||
FROM m_specialist
|
||||
WHERE
|
||||
M_SpecialistIsActive = 'Y'
|
||||
";
|
||||
// echo $query;
|
||||
$rows['specialistes'] = $this->db_regional->query($query)->result_array();
|
||||
//print_r($rows['specialistes']);
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function searchstaff(){
|
||||
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_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y'
|
||||
AND (Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')";
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_staff count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT * FROM(SELECT *, CONCAT(Nat_StaffName, ' [',Nat_StaffNIK,']') as Nat_StaffNames
|
||||
FROM nat_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y') a
|
||||
WHERE
|
||||
(Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')
|
||||
AND Nat_StaffIsActive = 'Y'
|
||||
ORDER BY Nat_StaffName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_staff rows",$this->db_regional);
|
||||
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_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName DESC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getjpa(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query)->result_array();
|
||||
|
||||
// $rows['jpas'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
// ambil data lama
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$old_doctor = array();
|
||||
if (count($rows) > 0 ) $old_doctor = $rows[0];
|
||||
|
||||
if($prm['M_DoctorEmail'] == ''){
|
||||
$prm['M_DoctorEmailIsDefault'] = 'N';
|
||||
}
|
||||
$x_dob = $prm['M_DoctorDOB'];
|
||||
$updated_dob = substr($x_dob, 0,2).'-'.substr($x_dob, 2,2).'-'.substr($x_dob, 4,4);
|
||||
$xxdob = date("Y-m-d", strtotime($updated_dob));
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorPrefix = '{$prm['M_DoctorPrefix']}',
|
||||
M_DoctorPrefix2 = '{$prm['M_DoctorPrefix2']}',
|
||||
M_DoctorName = '{$prm['M_DoctorName']}',
|
||||
M_DoctorSufix = '{$prm['M_DoctorSufix']}',
|
||||
M_DoctorSufix2 = '{$prm['M_DoctorSufix2']}',
|
||||
M_DoctorSufix3 = '{$prm['M_DoctorSufix3']}',
|
||||
M_DoctorM_SexID = '{$prm['M_DoctorM_SexID']}',
|
||||
M_DoctorM_ReligionID = '{$prm['M_DoctorM_ReligionID']}',
|
||||
M_DoctorM_StaffID = '{$prm['M_DoctorM_StaffID']}',
|
||||
M_DoctorM_StaffNIK = '{$prm['M_DoctorM_StaffNIK']}',
|
||||
M_DoctorEmail = '{$prm['M_DoctorEmail']}',
|
||||
M_DoctorHP = '{$prm['M_DoctorHP']}',
|
||||
M_DoctorNote = '{$prm['M_DoctorNote']}',
|
||||
M_DoctorPhone = '{$prm['M_DoctorPhone']}',
|
||||
M_DoctorIsMarketingConfirm = '{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
M_DoctorEmailIsDefault = '{$prm['M_DoctorEmailIsDefault']}',
|
||||
M_DoctorDOB = '{$xxdob}',
|
||||
M_DoctorM_SpecialistID = {$prm['M_DoctorM_SpecialistID']}
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
if($rows){
|
||||
|
||||
$data = json_encode($prm);
|
||||
//print_r($prm);
|
||||
$md5 = md5($data);
|
||||
$param = array("data" => $data, "md5" => $md5);
|
||||
$jparam = json_encode($param);
|
||||
|
||||
$sql = "SELECT * FROM m_branch WHERE M_BranchIsActive = 'Y'";
|
||||
$branches = $this->db_regional->query($sql)->result_array();
|
||||
foreach($branches as $k => $v){
|
||||
try {
|
||||
$sql = "INSERT INTO doctortobranch (
|
||||
DoctorToBranchM_DoctorID,
|
||||
DoctorToBranchM_BranchIPAddress,
|
||||
DoctorToBranchCreated,
|
||||
DoctorToBranchUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['M_DoctorID']},
|
||||
'{$v['M_BranchIPAddress']}',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_regional->query($sql);
|
||||
$last_xid = $this->db_regional->insert_id();
|
||||
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/updatedoctor/";
|
||||
|
||||
//echo "Uploading : ".$prm['M_DoctorName'];
|
||||
$j_result = $this->post($url,$jparam);
|
||||
$result = json_decode($j_result,true);
|
||||
//print_r($result);
|
||||
//echo $result["qry"];
|
||||
if ($result["status"] == "OK") {
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
else{
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
throw new Exception("ERRR : " . $result["qry"] . "\n");
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
echo $message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
|
||||
// ambil data baru
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_regional->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$new_doctor = array();
|
||||
if (count($rows) > 0 ) $new_doctor = $rows[0];
|
||||
$d_doctor = json_encode(array("old" => $old_doctor , "new" => $new_doctor));
|
||||
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//echo 'Yihaa';
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
///print_r($prm);
|
||||
$prm['userid'] = $userid;
|
||||
if(!$prm['M_DoctorM_StaffID'])
|
||||
$prm['M_DoctorM_StaffID'] = 0;
|
||||
|
||||
$x_dob = $prm['M_DoctorDOB'];
|
||||
$updated_dob = substr($x_dob, 0,2).'-'.substr($x_dob, 2,2).'-'.substr($x_dob, 4,4);
|
||||
$xxdob = date("Y-m-d", strtotime($updated_dob));
|
||||
|
||||
$query ="INSERT INTO m_doctor (
|
||||
M_DoctorPrefix,
|
||||
M_DoctorPrefix2,
|
||||
M_DoctorName,
|
||||
M_DoctorSufix,
|
||||
M_DoctorSufix2,
|
||||
M_DoctorSufix3,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorM_StaffID,
|
||||
M_DoctorM_StaffNIK,
|
||||
M_DoctorEmail,
|
||||
M_DoctorHP,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorDOB,
|
||||
M_DoctorM_SpecialistID,
|
||||
M_DoctorM_UserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorPrefix']}',
|
||||
'{$prm['M_DoctorPrefix2']}',
|
||||
'{$prm['M_DoctorName']}',
|
||||
'{$prm['M_DoctorSufix']}',
|
||||
'{$prm['M_DoctorSufix2']}',
|
||||
'{$prm['M_DoctorSufix3']}',
|
||||
'{$prm['M_DoctorM_SexID']}',
|
||||
'{$prm['M_DoctorM_ReligionID']}',
|
||||
'{$prm['M_DoctorM_StaffID']}',
|
||||
'{$prm['M_DoctorM_StaffNIK']}',
|
||||
'{$prm['M_DoctorEmail']}',
|
||||
'{$prm['M_DoctorHP']}',
|
||||
'{$prm['M_DoctorNote']}',
|
||||
'{$prm['M_DoctorPhone']}',
|
||||
'{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
'{$prm['M_DoctorEmailIsDefault']}',
|
||||
'{$xxdob}',
|
||||
'{$prm['M_DoctorM_SpecialistID']}',
|
||||
$userid
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
if($rows){
|
||||
|
||||
$data = json_encode($prm);
|
||||
//print_r($prm);
|
||||
$md5 = md5($data);
|
||||
$param = array("data" => $data, "md5" => $md5);
|
||||
$jparam = json_encode($param);
|
||||
|
||||
$sql = "SELECT * FROM m_branch WHERE M_BranchIsActive = 'Y'";
|
||||
$branches = $this->db_regional->query($sql)->result_array();
|
||||
foreach($branches as $k => $v){
|
||||
try {
|
||||
$sql = "INSERT INTO doctortobranch (
|
||||
DoctorToBranchM_DoctorID,
|
||||
DoctorToBranchM_BranchIPAddress,
|
||||
DoctorToBranchCreated,
|
||||
DoctorToBranchUserID
|
||||
)
|
||||
VALUES(
|
||||
{$last_id},
|
||||
'{$v['M_BranchIPAddress']}',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_regional->query($sql);
|
||||
$last_xid = $this->db_regional->insert_id();
|
||||
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/downloaddoctor/";
|
||||
//echo "Uploading : ".$prm['M_DoctorName'];
|
||||
$j_result = $this->post($url,$jparam);
|
||||
$result = json_decode($j_result,true);
|
||||
//echo $result["qry"];
|
||||
if ($result["status"] == "OK") {
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
else{
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
throw new Exception("ERR : " . $result["message"] . "\n");
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
echo $message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
//sipe tambah log doctor
|
||||
$prm["M_DoctorID"] = $last_id;
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADD','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function deletedoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// sipe nambah ambil userid
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_doctoraddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,Nat_JpaName,
|
||||
'' as action
|
||||
FROM m_doctoraddress
|
||||
JOIN m_kelurahan ON M_DoctorAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
left join nat_jpa on M_DoctorAddressNat_JpaID = Nat_JpaID
|
||||
WHERE
|
||||
M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function savenewaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$count_addrs = $this->db_regional->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorOldCode = '{$prm['M_DoctorAddressM_DoctorOldCode']}' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_regional->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_DoctorAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_regional->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorOldCode = '{$prm['M_DoctorAddressM_DoctorOldCode']}' AND M_DoctorAddressNote = 'Utama' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_DoctorAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_DoctorAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$query ="INSERT INTO m_doctoraddress (
|
||||
M_DoctorAddressM_DoctorOldCode,
|
||||
M_DoctorAddressNote,
|
||||
M_DoctorAddressDescription,
|
||||
M_DoctorAddressM_KelurahanID,
|
||||
M_DoctorAddressNat_JpaID,
|
||||
M_DoctorAddressLastUpdated,
|
||||
M_DoctorAddressCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorAddressM_DoctorOldCode']}',
|
||||
'{$prm['M_DoctorAddressNote']}',
|
||||
'{$prm['M_DoctorAddressDescription']}',
|
||||
'{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
'{$prm['M_DoctorAddressNat_JpaID']}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
if($rows){
|
||||
$data = json_encode($prm);
|
||||
//print_r($prm);
|
||||
$md5 = md5($data);
|
||||
$param = array("data" => $data, "md5" => $md5);
|
||||
$jparam = json_encode($param);
|
||||
|
||||
$sql = "SELECT * FROM m_branch WHERE M_BranchIsActive = 'Y'";
|
||||
$branches = $this->db_regional->query($sql)->result_array();
|
||||
foreach($branches as $k => $v){
|
||||
try {
|
||||
$sql = "INSERT INTO doctortobranch (
|
||||
DoctorToBranchM_DoctorID,
|
||||
DoctorToBranchM_BranchIPAddress,
|
||||
DoctorToBranchType,
|
||||
DoctorToBranchCreated,
|
||||
DoctorToBranchUserID
|
||||
)
|
||||
VALUES(
|
||||
{$last_id},
|
||||
'{$v['M_BranchIPAddress']}',
|
||||
'A',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_regional->query($sql);
|
||||
$last_xid = $this->db_regional->insert_id();
|
||||
//echo $last_xid;
|
||||
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/newaddressdoctor/";
|
||||
//echo $url;
|
||||
//echo "Uploading : ".$prm['M_DoctorName'];
|
||||
$j_result = $this->post($url,$jparam);
|
||||
$result = json_decode($j_result,true);
|
||||
//echo $result["qry"];
|
||||
if ($result["status"] == "OK") {
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
else{
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
throw new Exception("ERRZ : " . $result["message"] . "\n");
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
echo $message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressM_DoctorOldCode = '{$prm['M_DoctorAddressM_DoctorOldCode']}',
|
||||
M_DoctorAddressNote = '{$prm['M_DoctorAddressNote']}',
|
||||
M_DoctorAddressDescription = '{$prm['M_DoctorAddressDescription']}',
|
||||
M_DoctorAddressM_KelurahanID = '{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
M_DoctorAddressNat_JpaID = '{$prm['M_DoctorAddressNat_JpaID']}',
|
||||
M_DoctorAddressLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $prm['M_DoctorAddressID'];
|
||||
if($rows){
|
||||
$data = json_encode($prm);
|
||||
//print_r($prm);
|
||||
$md5 = md5($data);
|
||||
$param = array("data" => $data, "md5" => $md5);
|
||||
$jparam = json_encode($param);
|
||||
|
||||
$sql = "SELECT * FROM m_branch WHERE M_BranchIsActive = 'Y'";
|
||||
$branches = $this->db_regional->query($sql)->result_array();
|
||||
foreach($branches as $k => $v){
|
||||
try {
|
||||
$sql = "INSERT INTO doctortobranch (
|
||||
DoctorToBranchM_DoctorID,
|
||||
DoctorToBranchM_BranchIPAddress,
|
||||
DoctorToBranchType,
|
||||
DoctorToBranchCreated,
|
||||
DoctorToBranchUserID
|
||||
)
|
||||
VALUES(
|
||||
{$last_id},
|
||||
'{$v['M_BranchIPAddress']}',
|
||||
'A',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_regional->query($sql);
|
||||
$last_xid = $this->db_regional->insert_id();
|
||||
//echo $last_xid;
|
||||
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/updateaddressdoctor/";
|
||||
//echo $url;
|
||||
//echo "Uploading : ".$prm['M_DoctorName'];
|
||||
$j_result = $this->post($url,$jparam);
|
||||
$result = json_decode($j_result,true);
|
||||
//echo $result["qry"];
|
||||
if ($result["status"] == "OK") {
|
||||
//echo $result["qry"];
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
else{
|
||||
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
||||
WHERE
|
||||
DoctorToBranchID = {$last_xid}";
|
||||
$this->db_regional->query($sql);
|
||||
throw new Exception("ERRZ : " . $result["message"] . "\n");
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
echo $message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressIsActive = 'N',
|
||||
M_DoctorAddressLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_regional->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
754
one-api/application/controllers/v1/masterdata/Ekspose.php
Normal file
754
one-api/application/controllers/v1/masterdata/Ekspose.php
Normal file
@@ -0,0 +1,754 @@
|
||||
<?php
|
||||
class Ekspose extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " Nat_TestCode LIKE CONCAT('{$search_code}','%') ";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " Nat_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (SELECT *
|
||||
FROM nat_test
|
||||
JOIN t_test ON T_TestNat_TestID = Nat_TestID AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultID = 4
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
LEFT JOIN m_eksposi ON Nat_TestID = M_EksposiNat_TestID
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
GROUP BY Nat_TestID) x
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$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("t_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *, IFNULL(M_EksposiID,0) as eksposiid
|
||||
FROM nat_test
|
||||
JOIN t_test ON T_TestNat_TestID = Nat_TestID AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'
|
||||
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultID = 4
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
LEFT JOIN m_eksposi ON Nat_TestID = M_EksposiNat_TestID
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
GROUP BY Nat_TestID
|
||||
ORDER BY Nat_TestCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getinitdatas(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_GroupID as id, Nat_GroupName as name
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
||||
/*$query =" SELECT Nat_SubGroupID as id, CONCAT('[ ',Nat_SubGroupCode,' ] ', Nat_SubGroupName) as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['subgroups'] = $this->db_onedev->query($query)->result_array();*/
|
||||
$query =" SELECT Nat_TestTypeID as id, Nat_TestTypeName as name
|
||||
FROM nat_testtype
|
||||
WHERE
|
||||
Nat_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['nonlabs'] = array(array("id"=>"","name"=>"LAB"),array("id"=>"XRAY","name"=>"XRAY"), array("id"=>"USG","name"=>"USG"),array("id"=>"ELECTROMEDIS","name"=>"ELECTROMEDIS"));
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subsubgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name
|
||||
FROM nat_subsubgroup
|
||||
WHERE
|
||||
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
|
||||
function searchunit(){
|
||||
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_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = '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 Nat_UnitId as id, Nat_UnitName as name
|
||||
FROM nat_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = 'Y'
|
||||
ORDER BY Nat_UnitName 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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchsample(){
|
||||
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_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = '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 Nat_SampleTypeID as id, Nat_SampleTypeName as name
|
||||
FROM nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = 'Y'
|
||||
ORDER BY Nat_SampleTypeName 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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$testid = $prm['id'];
|
||||
$expose = $prm['expose'];
|
||||
$tegangan = $prm['tegangan'];
|
||||
$arus = $prm['arus'];
|
||||
$waktu = $prm['waktu'];
|
||||
$mas = $prm['mas'];
|
||||
if($prm['eksposiid'] == 0){
|
||||
$sql = "insert into m_eksposi(
|
||||
M_EksposiNat_TestID,
|
||||
M_EksposiExpose,
|
||||
M_EksposiKV,
|
||||
M_EksposiMa,
|
||||
M_EksposiS,
|
||||
M_EksposiMaS,
|
||||
M_EksposiUserID,
|
||||
M_EksposiLastUpdated,
|
||||
M_EksposiCreated
|
||||
)
|
||||
values( ?,?,?,?,?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$expose,
|
||||
$tegangan,
|
||||
$arus,
|
||||
$waktu,
|
||||
$mas,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_eksposi insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
|
||||
//echo $query;
|
||||
$sql = "UPDATE m_eksposi SET M_EksposiExpose = '{$expose}', M_EksposiKV = '{$tegangan}',
|
||||
M_EksposiMa = '{$arus}',M_EksposiS = '{$waktu}',
|
||||
M_EksposiMaS = '{$mas}',
|
||||
M_EksposiUserID = '{$userid}' WHERE M_EksposiID = '{$prm['eksposiid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function checkcodeexist(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rtn = 'N';
|
||||
$query =" SELECT COUNT(*) as countx
|
||||
FROM nat_test
|
||||
WHERE Nat_TestCode = '{$prm['code']}' AND Nat_TestIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rst = $this->db_onedev->query($query)->row()->countx;
|
||||
if($rst > 0)
|
||||
$rtn = 'Y';
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rtn,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdataselected(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['Nat_TestID'];
|
||||
|
||||
$query =" SELECT
|
||||
Nat_TestCode as code,
|
||||
Nat_TestName as name,
|
||||
Nat_TestShortName as shortname,
|
||||
Nat_TestShortNameBarcode as codebarcode,
|
||||
'' as xgroup,
|
||||
Nat_GroupID as group_id,
|
||||
Nat_GroupName as group_name,
|
||||
'' as subgroup,
|
||||
Nat_SubGroupID as subgroup_id,
|
||||
Nat_SubGroupName as subgroup_name,
|
||||
'' as subsubgroup,
|
||||
Nat_SubSubGroupID as subsubgroup_id,
|
||||
Nat_SubSubGroupName as subsubgroup_name,
|
||||
'' as type,
|
||||
Nat_TestNat_TestTypeID as type_id,
|
||||
Nat_TestTypeName as type_name,
|
||||
'' as unit,
|
||||
Nat_TestNat_UnitID as unit_id,
|
||||
Nat_UnitName as unit_name,
|
||||
'' as sample,
|
||||
Nat_TestIsNonLab as nonlab,
|
||||
Nat_TestNat_SampleTypeID as sample_id,
|
||||
Nat_SampleTypeName as sample_name,
|
||||
Nat_TestFontSize as fontsize,
|
||||
Nat_TestFontColor as fontcolor,
|
||||
Nat_TestIsBold as flagbold,
|
||||
Nat_TestIsItalic as flagitalic,
|
||||
Nat_TestFlagGluc as flaggluc,
|
||||
Nat_TestIsQuantitative as flagquantitative,
|
||||
Nat_TestIsDeltaCheck as deltacheck,
|
||||
Nat_TestIsResult as isresult,
|
||||
Nat_TestIsPrice as isprice,
|
||||
Nat_TestIsPrintResult as printresult,
|
||||
Nat_TestIsPrintNota as printnote,
|
||||
Nat_TestIsTrendAnalysis as trendanalysis,
|
||||
Nat_TestIsWorklist as isworklist,
|
||||
Nat_TestIsLongResult as islongresult,
|
||||
Nat_TestIsEkspertisi as isekspertisi,
|
||||
Nat_TestWorklistName as worklistname,
|
||||
Nat_TestFlagLow as flaglow,
|
||||
Nat_TestFlagHigh as flaghigh,
|
||||
'' as groupsprice,
|
||||
Nat_TestPriceSumToNat_TestID as selected_group_price,
|
||||
Nat_TestFlagMcu as selected_flag_mcu,
|
||||
IFNULL(M_EksposiID,0) as eksposiid,
|
||||
IFNULL(M_EksposiExpose,0) as expose,
|
||||
IFNULL(M_EksposiKV,0) as tegangan,
|
||||
IFNULL(M_EksposiMa,0) as arus,
|
||||
IFNULL(M_EksposiS,0) as waktu,
|
||||
IFNULL(M_EksposiMaS,0) as mas
|
||||
FROM nat_test
|
||||
JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
LEFT JOIN m_eksposi ON Nat_TestID = M_EksposiNat_TestID
|
||||
WHERE Nat_TestID = '{$id}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['xform'] = $this->db_onedev->query($query)->row_array();
|
||||
if($rows['xform']){
|
||||
if($rows['xform']['selected_flag_mcu'] == 'N')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'N','name'=>'Tidak ada');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'G')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'G','name'=>'Dengan perhitungan abnormal');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'A')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'G','name'=>'Sesuai hasil');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'C')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'C','name'=>'Berdasarkan SUBSUBGROUP');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'R')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'R','name'=>'Reaktif Tidak normal');
|
||||
if($rows['xform']['selected_flag_mcu'] == 'P')
|
||||
$rows['xform']['selected_flag_mcu'] = array('id'=>'P','name'=>'Positif Tidak normal');
|
||||
|
||||
$sevencode = substr($rows['xform']['code'],0,7);
|
||||
$sql = "SELECT 0 as id, '' as name
|
||||
UNION
|
||||
SELECT Nat_TestID as id, Nat_TestName as name FROM nat_test WHERE Nat_TestCode LIKE '{$sevencode}%'";
|
||||
$rows['xform']['groupsprice'] = $this->db_onedev->query($sql)->result_array();
|
||||
$selected_group_price = array();
|
||||
if($rows['xform']['groupsprice']){
|
||||
foreach($rows['xform']['groupsprice'] as $k =>$v){
|
||||
//echo $rows['xform']['selected_group_price'];echo '-';
|
||||
//echo $v['id'];echo '-';echo $rows['xform']['selected_group_price'];echo '&';
|
||||
if(intval($v['id']) == intval($rows['xform']['selected_group_price'])){
|
||||
//print_r($v);
|
||||
$selected_group_price = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rows['xform']['selected_group_price'] = $selected_group_price;
|
||||
|
||||
$rows['xform']['unit'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['unit'] = array('id'=>$rows['xform']['unit_id'],'name'=>$rows['xform']['unit_name']);
|
||||
|
||||
$rows['xform']['sample'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['sample'] = array('id'=>$rows['xform']['sample_id'],'name'=>$rows['xform']['sample_name']);
|
||||
|
||||
$rows['xform']['xgroup'] = array('id'=>$rows['xform']['group_id'],'name'=>$rows['xform']['group_name']);
|
||||
$rows['xform']['subgroup'] = array('id'=>$rows['xform']['subgroup_id'],'name'=>$rows['xform']['subgroup_name']);
|
||||
$rows['xform']['subsubgroup'] = array('id'=>$rows['xform']['subsubgroup_id'],'name'=>$rows['xform']['subsubgroup_name']);
|
||||
$rows['xform']['type'] = array('id'=>$rows['xform']['type_id'],'name'=>$rows['xform']['type_name']);
|
||||
|
||||
|
||||
if($rows['xform']['nonlab'] == '')
|
||||
$rows['xform']['nonlab'] = array('id'=>'','name'=>'LAB');
|
||||
else
|
||||
$rows['xform']['nonlab'] = array('id'=>$rows['xform']['nonlab'],'name'=>$rows['xform']['nonlab']);
|
||||
|
||||
unset($rows['xform']['sample_id']);
|
||||
unset($rows['xform']['unit_id']);
|
||||
unset($rows['xform']['group_id']);
|
||||
unset($rows['xform']['subgroup_id']);
|
||||
unset($rows['xform']['subsubgroup_id']);
|
||||
unset($rows['xform']['sample_name']);
|
||||
unset($rows['xform']['unit_name']);
|
||||
unset($rows['xform']['group_name']);
|
||||
unset($rows['xform']['subgroup_name']);
|
||||
unset($rows['xform']['subsubgroup_name']);
|
||||
}
|
||||
|
||||
$sql = "SELECT Nat_SubGroupID as id, Nat_SubGroupName as name FROM nat_subgroup WHERE Nat_SubGroupNat_GroupID = {$prm['Nat_GroupID']} AND Nat_SubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subgroups'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name FROM nat_subsubgroup WHERE Nat_SubSubGroupSubGroupID = {$prm['Nat_SubGroupID']} AND Nat_SubSubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subsubgroups'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaddtest(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rtn = true;
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$codefrom = $prm['codefrom'];
|
||||
$codetoward = $prm['codetoward'];
|
||||
$leng = strlen($codetoward);
|
||||
$code_parent = substr($codetoward, 0,-2);
|
||||
$sql = "SELECT count(*) as existtest FROM t_test WHERE T_TestSasCode LIKE '{$code_parent}%' AND T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$xcount = $this->db_onedev->query($sql)->row()->existtest;
|
||||
if($xcount == 0){
|
||||
$sql = "
|
||||
select T_TestID ,T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 2 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where T_TestSasCode like '{$code_parent}%' AND length(T_TestSasCode) = {$leng} AND T_TestSasCode >= '{$codetoward}'
|
||||
UNION
|
||||
select T_TestID , T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 1 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where ( T_TestSasCode like '{$code_parent}%' AND T_TestSasCode > '{$codetoward}' ) OR T_TestSasCode = '{$codetoward}'
|
||||
";
|
||||
//echo $sql;
|
||||
$toupdate = $this->db_onedev->query($sql)->result();
|
||||
if($toupdate){
|
||||
foreach($toupdate as $k => $v){
|
||||
$sql = "UPDATE t_test SET T_TestSasCode = '{$v->NewCode}' WHERE T_TestID = {$v->T_TestID} ";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y'";
|
||||
$parentid = $this->db_onedev->query($sql)->row()->T_TestID;
|
||||
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestParentT_TestID,
|
||||
T_TestNat_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestShortName,
|
||||
T_TestShortNameBarcode,
|
||||
T_TestNat_GroupID,
|
||||
T_TestNat_SubGroupID,
|
||||
T_TestT_SampleTypeID,
|
||||
T_TestFontSize,
|
||||
T_TestFontColor,
|
||||
T_TestIsBold,
|
||||
T_TestIsItalic,
|
||||
T_TestFlagGluc,
|
||||
T_TestIsQuantitative,
|
||||
T_TestIsDeltaCheck,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice,
|
||||
T_TestIsPrintResult,
|
||||
T_TestIsPrintNota,
|
||||
T_TestIsTrendAnalysis,
|
||||
T_TestIsWorklist,
|
||||
T_TestIsNonLab,
|
||||
T_TestWorklistName,
|
||||
T_TestFlagLow,
|
||||
T_TestFlagHigh,
|
||||
T_TestUserID,
|
||||
T_TestCreated
|
||||
)
|
||||
SELECT
|
||||
{$parentid},
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
'{$codetoward}',
|
||||
Nat_TestName,
|
||||
Nat_TestShortName,
|
||||
Nat_TestShortNameBarcode,
|
||||
Nat_TestNat_GroupID,
|
||||
Nat_TestNat_SubGroupID,
|
||||
Nat_TestNat_SampleTypeID,
|
||||
Nat_TestFontSize,
|
||||
Nat_TestFontColor,
|
||||
Nat_TestIsBold,
|
||||
Nat_TestIsItalic,
|
||||
Nat_TestFlagGluc,
|
||||
Nat_TestIsQuantitative,
|
||||
Nat_TestIsDeltaCheck,
|
||||
Nat_TestIsResult,
|
||||
Nat_TestIsPrice,
|
||||
Nat_TestIsPrintResult,
|
||||
Nat_TestIsPrintNota,
|
||||
Nat_TestIsTrendAnalysis,
|
||||
Nat_TestIsWorklist,
|
||||
Nat_TestIsNonLab,
|
||||
Nat_TestWorklistName,
|
||||
Nat_TestFlagLow,
|
||||
Nat_TestFlagHigh,
|
||||
{$userid},
|
||||
NOW()
|
||||
FROM nat_test
|
||||
WHERE
|
||||
Nat_TestCode = '{$codefrom}' AND Nat_TestIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$this->db_onedev->query($query);
|
||||
$sql = "SELECT T_TestID FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y' LIMIT 1";
|
||||
$data_parent = $this->db_onedev->query($sql)->row();
|
||||
if($data_parent){
|
||||
$testidparent = $data_parent->T_TestID;
|
||||
$sql = "UPDATE t_test SET T_TestIsParent = 'Y' WHERE T_TestID = {$testidparent}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $xcount,
|
||||
"debug"=>$query
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
665
one-api/application/controllers/v1/masterdata/Groupresult.php
Normal file
665
one-api/application/controllers/v1/masterdata/Groupresult.php
Normal file
@@ -0,0 +1,665 @@
|
||||
<?php
|
||||
|
||||
class Groupresult extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "GROUP RESULT API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupdetailbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$groupresult = $prm['groupresult'];
|
||||
$detail = $prm['detail'];;
|
||||
$all = $prm['all'];
|
||||
$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 group_resultdetail
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultIsActive = 'Y'
|
||||
JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
Group_ResultName LIKE CONCAT('%','{$groupresult}','%') AND
|
||||
T_TestName LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultDetailIsActive = 'Y' GROUP BY Group_ResultDetailID) a";
|
||||
// $total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->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("group_resultdetail count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Group_ResultDetailID as id,
|
||||
Group_ResultName,
|
||||
T_TestName,
|
||||
group_resultdetail.*
|
||||
from group_resultdetail
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultIsActive = 'Y'
|
||||
JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
Group_ResultName LIKE CONCAT('%','{$groupresult}','%') AND
|
||||
T_TestName LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultDetailIsActive = 'Y'
|
||||
GROUP BY Group_ResultDetailID
|
||||
ORDER BY Group_ResultName ASC, T_TestName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("group_resultdetail 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 lookupdetailbyid(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$groupresult = $prm['groupresult'];
|
||||
$detail = $prm['detail'];;
|
||||
$all = $prm['all'];
|
||||
$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 group_resultdetail
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultIsActive = 'Y'
|
||||
JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
($groupresult = 0 or ($groupresult > 0 and Group_ResultDetailGroup_ResultID = $groupresult)) AND
|
||||
T_TestName LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultDetailIsActive = 'Y' GROUP BY Group_ResultDetailID) a";
|
||||
// $total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->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("group_resultdetail count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Group_ResultDetailID as id,
|
||||
Group_ResultName,
|
||||
T_TestName,
|
||||
group_resultdetail.*
|
||||
from group_resultdetail
|
||||
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultIsActive = 'Y'
|
||||
JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
WHERE
|
||||
($groupresult = 0 or ($groupresult > 0 and Group_ResultDetailGroup_ResultID = $groupresult)) AND
|
||||
T_TestName LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultDetailIsActive = 'Y'
|
||||
GROUP BY Group_ResultDetailID
|
||||
ORDER BY Group_ResultName ASC, T_TestName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("group_resultdetail 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 lookupgroupresultbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$groupresult = $prm['groupresult'];
|
||||
$detail = $prm['detail'];
|
||||
$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 group_result
|
||||
LEFT JOIN group_resultdetail ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultDetailIsActive = 'Y'
|
||||
LEFT JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
where
|
||||
Group_ResultName LIKE CONCAT('%','{$groupresult}','%') AND
|
||||
IFNULL(T_TestName,'') LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultIsActive = 'Y'
|
||||
GROUP BY Group_ResultID) a";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_regional->query($sql);
|
||||
$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("group_result count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Group_ResultID as id,
|
||||
Group_ResultName as name,
|
||||
Group_ResultName as namex,
|
||||
IF(Group_ResultFlagPerTest = 'Y','Ya','Tidak') as ispertest,
|
||||
IF(Group_ResultFlagNonLab = 'Y','Ya','Tidak') as isnonlab,
|
||||
group_result.*
|
||||
from group_result
|
||||
LEFT JOIN group_resultdetail ON Group_ResultID = Group_ResultDetailGroup_ResultID AND Group_ResultDetailIsActive = 'Y'
|
||||
LEFT JOIN t_test ON Group_ResultDetailT_TestID = T_TestID
|
||||
where
|
||||
Group_ResultName LIKE CONCAT('%','{$groupresult}','%') AND
|
||||
IFNULL(T_TestName,'') LIKE CONCAT('%','{$detail}','%') AND
|
||||
Group_ResultIsActive = 'Y'
|
||||
GROUP BY Group_ResultID
|
||||
ORDER BY Group_ResultName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("group_result 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 addnewgroupresult()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$ispertest = $prm['ispertest'];
|
||||
$isnonlab = $prm['isnonlab'];
|
||||
$sql = "insert into group_result(
|
||||
Group_ResultName,
|
||||
Group_ResultFlagPerTest,
|
||||
Group_ResultFlagNonLab
|
||||
)
|
||||
values( ?, ?, ?)";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$name,
|
||||
$ispertest,
|
||||
$isnonlab
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_result insert");
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editgroupresult()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$name = $prm['name'];
|
||||
$ispertest = $prm['ispertest'];
|
||||
$isnonlab = $prm['isnonlab'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sqlcompany = "update group_result SET
|
||||
Group_ResultName = ?,
|
||||
Group_ResultFlagPerTest = ?,
|
||||
Group_ResultFlagNonLab = ?
|
||||
where
|
||||
Group_ResultID = ?
|
||||
";
|
||||
$querycompany = $this->db_regional->query($sqlcompany,
|
||||
array(
|
||||
$name,
|
||||
$ispertest,
|
||||
$isnonlab,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("group_result update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function addnewdetail()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$groupresultid = $prm['groupresultid'];
|
||||
$testid = $prm['testid'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($groupresultid == 0 || $testid == 0){
|
||||
$errors = array();
|
||||
if($groupresultid == 0){
|
||||
array_push($errors,array('field'=>'groupresult','msg'=>'Kelompok hasil dipilih dulu dong'));
|
||||
}
|
||||
if($testid == 0){
|
||||
array_push($errors,array('field'=>'test','msg'=>'Pemeriksaan dipilih dulu dong'));
|
||||
}
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
if($prm['xid'] == 0){
|
||||
$sql = "insert into group_resultdetail(
|
||||
Group_ResultDetailGroup_ResultID,
|
||||
Group_ResultDetailT_TestID)
|
||||
values(?,?)";
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$groupresultid,
|
||||
$testid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_resultdetail insert",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
}else{
|
||||
$sql = "UPDATE group_resultdetail SET Group_ResultDetailGroup_ResultID = '{$groupresultid}',
|
||||
Group_ResultDetailT_TestID = '{$testid}'
|
||||
WHERE Group_ResultDetailID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function deletegroupresult()
|
||||
{
|
||||
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 group_result SET
|
||||
Group_ResultIsActive = 'N'
|
||||
WHERE
|
||||
Group_ResultID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_result delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update group_resultdetail SET
|
||||
Group_ResultDetailIsActive = 'N'
|
||||
WHERE
|
||||
Group_ResultDetailGroup_ResultID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_resultdetail 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 deletedetail()
|
||||
{
|
||||
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 group_resultdetail SET
|
||||
Group_ResultDetailIsActive = 'N'
|
||||
WHERE
|
||||
Group_ResultDetailID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("group_resultdetail 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 searchgroupresult(){
|
||||
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 group_result
|
||||
WHERE
|
||||
Group_ResultName like ?
|
||||
AND Group_ResultIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("group_result count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Group_ResultID, Group_ResultName
|
||||
FROM group_result
|
||||
WHERE
|
||||
Group_ResultName like ?
|
||||
AND Group_ResultIsActive = 'Y'
|
||||
ORDER BY Group_ResultName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("group_result rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchgroupresultbyname(){
|
||||
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 group_result
|
||||
WHERE
|
||||
Group_ResultName like ?
|
||||
AND Group_ResultIsActive = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("group_result count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Group_ResultID, Group_ResultName
|
||||
FROM group_result
|
||||
WHERE
|
||||
Group_ResultName like ?
|
||||
AND Group_ResultIsActive = 'Y'
|
||||
ORDER BY Group_ResultName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("group_result rows",$this->db_regional);
|
||||
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_regional->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_regional);
|
||||
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_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
85
one-api/application/controllers/v1/masterdata/Jpaleft.php
Normal file
85
one-api/application/controllers/v1/masterdata/Jpaleft.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
class Jpaleft extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingverify API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT nat_jpa.*,'N' as open_edit
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if(intval($prm['id']) != 0){
|
||||
if($prm['status'] == 'N')
|
||||
$query =" UPDATE nat_jpa SET Nat_JpaIsActive = 'N', Nat_JpaUserID = {$userid} WHERE Nat_JpaID = {$prm['id']}";
|
||||
else
|
||||
$query =" UPDATE nat_jpa SET Nat_JpaName = '{$prm['Nat_JpaName']}', Nat_JpaUserID = {$userid} WHERE Nat_JpaID = {$prm['id']}";
|
||||
}
|
||||
else{
|
||||
$query = "insert into nat_jpa(
|
||||
Nat_JpaName,
|
||||
Nat_JpaUserID,
|
||||
Nat_JpaCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['value']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)";
|
||||
}
|
||||
//echo $query;
|
||||
$action = $this->db_regional->query($query);
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_regional->last_query(), $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
240
one-api/application/controllers/v1/masterdata/Jparight.php
Normal file
240
one-api/application/controllers/v1/masterdata/Jparight.php
Normal file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
class Jparight extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingverify API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_JPAGroupID,
|
||||
Nat_JPAGroupName,
|
||||
{$prm['Nat_JpaID']} as Nat_JpaID,
|
||||
fn_jpa_get_discount({$prm['Nat_JpaID']},Nat_JPAGroupID) as Nat_JPADetailDiscount,
|
||||
fn_jpa_get_discount_rp({$prm['Nat_JpaID']},Nat_JPAGroupID) as Nat_JPADetailDiscountRp
|
||||
FROM nat_jpagroup
|
||||
WHERE
|
||||
Nat_JPAGroupIsActive = 'Y'
|
||||
GROUP BY Nat_JPAGroupID
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function search_listing()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_JPAGroupID,
|
||||
Nat_JPAGroupName
|
||||
FROM nat_jpagroup
|
||||
WHERE
|
||||
Nat_JPAGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "insert into nat_jpadetail(
|
||||
Nat_JPADetailNat_JPAID,
|
||||
Nat_JPADetailNat_JPAGroupID,
|
||||
Nat_JPADetailDiscount,
|
||||
Nat_JPADetailDiscountRp,
|
||||
Nat_JPADetailUserID,
|
||||
Nat_JPADetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['Nat_JpaID']}',
|
||||
'{$prm['Nat_JPAGroupID']}',
|
||||
'{$prm['Nat_JPADetailDiscount']}',
|
||||
'{$prm['Nat_JPADetailDiscountRp']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Nat_JPADetailDiscount = {$prm['Nat_JPADetailDiscount']},
|
||||
Nat_JPADetailDiscountRp = {$prm['Nat_JPADetailDiscountRp']},
|
||||
Nat_JPADetailUserID = {$userid}";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_regional->query($query);
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_regional->last_query(), $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function savejpagroup(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "insert into nat_jpagroup(
|
||||
Nat_JPAGroupName,
|
||||
Nat_JPAGroupUserID,
|
||||
Nat_JPAGroupCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['value']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_regional->query($query);
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_regional->last_query(), $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function savelistingjpagroup(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE nat_jpagroup SET
|
||||
Nat_JPAGroupName = '{$prm['name']}',
|
||||
Nat_JPAGroupIsActive = '{$prm['status']}',
|
||||
Nat_JPAGroupUserID = {$userid}
|
||||
WHERE
|
||||
Nat_JPAGroupID = {$prm['id']}
|
||||
";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_regional->query($query);
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_regional->last_query(), $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function savealljpadetail(){
|
||||
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 = "insert into nat_jpadetail(
|
||||
Nat_JPADetailNat_JPAID,
|
||||
Nat_JPADetailNat_JPAGroupID,
|
||||
Nat_JPADetailDiscount,
|
||||
Nat_JPADetailDiscountRp,
|
||||
Nat_JPADetailUserID,
|
||||
Nat_JPADetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$v['Nat_JpaID']}',
|
||||
'{$v['Nat_JPAGroupID']}',
|
||||
'{$v['Nat_JPADetailDiscount']}',
|
||||
'{$v['Nat_JPADetailDiscountRp']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Nat_JPADetailDiscount = {$v['Nat_JPADetailDiscount']},
|
||||
Nat_JPADetailDiscountRp = {$v['Nat_JPADetailDiscountRp']},
|
||||
Nat_JPADetailUserID = {$userid}";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_regional->query($query);
|
||||
}
|
||||
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_regional->last_query(), $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
690
one-api/application/controllers/v1/masterdata/Jpatestleft.php
Normal file
690
one-api/application/controllers/v1/masterdata/Jpatestleft.php
Normal file
@@ -0,0 +1,690 @@
|
||||
<?php
|
||||
class Jpatestleft extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$join_sql = 'LEFT ';
|
||||
$status = $prm["status"];
|
||||
$jpagroup = $prm["jpagroup"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
|
||||
$number_limit = 20;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " Nat_TestCode LIKE CONCAT('{$search_code}','%') ";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " Nat_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
$where_status = " AND JPA_TestNat_JpaGroupID = {$jpagroup} ";
|
||||
|
||||
if($status == 'Y'){
|
||||
$join_sql = '';
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
$join_sql JOIN jpa_test ON JPA_TestNat_TestID = Nat_TestID $where_status AND JPA_TestIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
|
||||
$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("t_samplestorage count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT nat_test.*, IF(ISNULL(JPA_TestID),'N','Y') as status
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
$join_sql JOIN jpa_test ON JPA_TestNat_TestID = Nat_TestID $where_status AND JPA_TestIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY Nat_TestCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getinitdatas(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_GroupID as id, Nat_GroupName as name
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['groups'] = $this->db_regional->query($query)->result_array();
|
||||
/*$query =" SELECT Nat_SubGroupID as id, CONCAT('[ ',Nat_SubGroupCode,' ] ', Nat_SubGroupName) as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['subgroups'] = $this->db_regional->query($query)->result_array();*/
|
||||
$query =" SELECT Nat_TestTypeID as id, Nat_TestTypeName as name
|
||||
FROM nat_testtype
|
||||
WHERE
|
||||
Nat_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['types'] = $this->db_regional->query($query)->result_array();
|
||||
$rows['nonlabs'] = array(array("id"=>"","name"=>"LAB"),array("id"=>"XRAY","name"=>"XRAY"), array("id"=>"USG","name"=>"USG"),array("id"=>"ELECTROMEDIS","name"=>"ELECTROMEDIS"));
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subsubgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name
|
||||
FROM nat_subsubgroup
|
||||
WHERE
|
||||
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_regional->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_regional->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
|
||||
function searchunit(){
|
||||
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_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = 'Y'";
|
||||
$query = $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_UnitId as id, Nat_UnitName as name
|
||||
FROM nat_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = 'Y'
|
||||
ORDER BY Nat_UnitName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchsample(){
|
||||
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_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = 'Y'";
|
||||
$query = $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_SampleTypeID as id, Nat_SampleTypeName as name
|
||||
FROM nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = 'Y'
|
||||
ORDER BY Nat_SampleTypeName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "INSERT INTO jpa_test (
|
||||
JPA_TestNat_JpaGroupID,
|
||||
JPA_TestNat_TestID,
|
||||
JPA_TestUserID,
|
||||
JPA_TestCreated
|
||||
)
|
||||
VALUES(
|
||||
{$prm['jpagroupid']},
|
||||
{$prm['Nat_TestID']},
|
||||
{$userid},
|
||||
NOW()
|
||||
)
|
||||
on duplicate key update
|
||||
JPA_TestIsActive = '{$prm['status']}',
|
||||
JPA_TestUserID = {$userid}";
|
||||
$this->db_regional->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $data_log_header,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkcodeexist(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rtn = 'N';
|
||||
$query =" SELECT COUNT(*) as countx
|
||||
FROM nat_test
|
||||
WHERE Nat_TestCode = '{$prm['code']}' AND Nat_TestIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rst = $this->db_regional->query($query)->row()->countx;
|
||||
if($rst > 0)
|
||||
$rtn = 'Y';
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rtn,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdataselected(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['Nat_TestID'];
|
||||
|
||||
$query =" SELECT
|
||||
Nat_TestCode as code,
|
||||
Nat_TestName as name,
|
||||
Nat_TestShortName as shortname,
|
||||
Nat_TestShortNameBarcode as codebarcode,
|
||||
'' as xgroup,
|
||||
Nat_GroupID as group_id,
|
||||
Nat_GroupName as group_name,
|
||||
'' as subgroup,
|
||||
Nat_SubGroupID as subgroup_id,
|
||||
Nat_SubGroupName as subgroup_name,
|
||||
'' as subsubgroup,
|
||||
Nat_SubSubGroupID as subsubgroup_id,
|
||||
Nat_SubSubGroupName as subsubgroup_name,
|
||||
|
||||
'' as type,
|
||||
Nat_TestNat_TestTypeID as type_id,
|
||||
Nat_TestTypeName as type_name,
|
||||
'' as unit,
|
||||
Nat_TestNat_UnitID as unit_id,
|
||||
Nat_UnitName as unit_name,
|
||||
'' as sample,
|
||||
Nat_TestIsNonLab as nonlab,
|
||||
Nat_TestNat_SampleTypeID as sample_id,
|
||||
Nat_SampleTypeName as sample_name,
|
||||
Nat_TestFontSize as fontsize,
|
||||
Nat_TestFontColor as fontcolor,
|
||||
Nat_TestIsBold as flagbold,
|
||||
Nat_TestIsItalic as flagitalic,
|
||||
Nat_TestFlagGluc as flaggluc,
|
||||
Nat_TestIsQuantitative as flagquantitative,
|
||||
Nat_TestIsDeltaCheck as deltacheck,
|
||||
Nat_TestIsResult as isresult,
|
||||
Nat_TestIsPrice as isprice,
|
||||
Nat_TestIsPrintResult as printresult,
|
||||
Nat_TestIsPrintNota as printnote,
|
||||
Nat_TestIsTrendAnalysis as trendanalysis,
|
||||
Nat_TestIsWorklist as isworklist,
|
||||
Nat_TestWorklistName as worklistname,
|
||||
Nat_TestFlagLow as flaglow,
|
||||
Nat_TestFlagHigh as flaghigh
|
||||
FROM nat_test
|
||||
JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE Nat_TestID = '{$id}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['xform'] = $this->db_regional->query($query)->row_array();
|
||||
if($rows['xform']){
|
||||
$rows['xform']['unit'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['unit'] = array('id'=>$rows['xform']['unit_id'],'name'=>$rows['xform']['unit_name']);
|
||||
|
||||
$rows['xform']['sample'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['sample'] = array('id'=>$rows['xform']['sample_id'],'name'=>$rows['xform']['sample_name']);
|
||||
|
||||
$rows['xform']['xgroup'] = array('id'=>$rows['xform']['group_id'],'name'=>$rows['xform']['group_name']);
|
||||
$rows['xform']['subgroup'] = array('id'=>$rows['xform']['subgroup_id'],'name'=>$rows['xform']['subgroup_name']);
|
||||
$rows['xform']['subsubgroup'] = array('id'=>$rows['xform']['subsubgroup_id'],'name'=>$rows['xform']['subsubgroup_name']);
|
||||
$rows['xform']['type'] = array('id'=>$rows['xform']['type_id'],'name'=>$rows['xform']['type_name']);
|
||||
|
||||
|
||||
if($rows['xform']['nonlab'] == '')
|
||||
$rows['xform']['nonlab'] = array('id'=>'','name'=>'LAB');
|
||||
else
|
||||
$rows['xform']['nonlab'] = array('id'=>$rows['xform']['nonlab'],'name'=>$rows['xform']['nonlab']);
|
||||
|
||||
unset($rows['xform']['sample_id']);
|
||||
unset($rows['xform']['unit_id']);
|
||||
unset($rows['xform']['group_id']);
|
||||
unset($rows['xform']['subgroup_id']);
|
||||
unset($rows['xform']['subsubgroup_id']);
|
||||
unset($rows['xform']['sample_name']);
|
||||
unset($rows['xform']['unit_name']);
|
||||
unset($rows['xform']['group_name']);
|
||||
unset($rows['xform']['subgroup_name']);
|
||||
unset($rows['xform']['subsubgroup_name']);
|
||||
}
|
||||
|
||||
$sql = "SELECT Nat_SubGroupID as id, Nat_SubGroupName as name FROM nat_subgroup WHERE Nat_SubGroupNat_GroupID = {$prm['Nat_GroupID']} AND Nat_SubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subgroups'] = $this->db_regional->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name FROM nat_subsubgroup WHERE Nat_SubSubGroupSubGroupID = {$prm['Nat_SubGroupID']} AND Nat_SubSubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subsubgroups'] = $this->db_regional->query($sql)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaddtest(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rtn = true;
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$codefrom = $prm['codefrom'];
|
||||
$codetoward = $prm['codetoward'];
|
||||
$leng = strlen($codetoward);
|
||||
$code_parent = substr($codetoward, 0,-2);
|
||||
$sql = "SELECT count(*) as existtest FROM t_test WHERE T_TestSasCode LIKE '{$code_parent}%' AND T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$xcount = $this->db_regional->query($sql)->row()->existtest;
|
||||
if($xcount == 0){
|
||||
$sql = "
|
||||
select T_TestID ,T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 2 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where T_TestSasCode like '{$code_parent}%' AND length(T_TestSasCode) = {$leng} AND T_TestSasCode >= '{$codetoward}'
|
||||
UNION
|
||||
select T_TestID , T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 1 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where ( T_TestSasCode like '{$code_parent}%' AND T_TestSasCode > '{$codetoward}' ) OR T_TestSasCode = '{$codetoward}'
|
||||
";
|
||||
//echo $sql;
|
||||
$toupdate = $this->db_regional->query($sql)->result();
|
||||
if($toupdate){
|
||||
foreach($toupdate as $k => $v){
|
||||
$sql = "UPDATE t_test SET T_TestSasCode = '{$v->NewCode}' WHERE T_TestID = {$v->T_TestID} ";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y'";
|
||||
$parentid = $this->db_regional->query($sql)->row()->T_TestID;
|
||||
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestParentT_TestID,
|
||||
T_TestNat_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestShortName,
|
||||
T_TestShortNameBarcode,
|
||||
T_TestNat_GroupID,
|
||||
T_TestNat_SubGroupID,
|
||||
T_TestT_SampleTypeID,
|
||||
T_TestFontSize,
|
||||
T_TestFontColor,
|
||||
T_TestIsBold,
|
||||
T_TestIsItalic,
|
||||
T_TestFlagGluc,
|
||||
T_TestIsQuantitative,
|
||||
T_TestIsDeltaCheck,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice,
|
||||
T_TestIsPrintResult,
|
||||
T_TestIsPrintNota,
|
||||
T_TestIsTrendAnalysis,
|
||||
T_TestIsWorklist,
|
||||
T_TestIsNonLab,
|
||||
T_TestWorklistName,
|
||||
T_TestFlagLow,
|
||||
T_TestFlagHigh,
|
||||
T_TestUserID,
|
||||
T_TestCreated
|
||||
)
|
||||
SELECT
|
||||
{$parentid},
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
'{$codetoward}',
|
||||
Nat_TestName,
|
||||
Nat_TestShortName,
|
||||
Nat_TestShortNameBarcode,
|
||||
Nat_TestNat_GroupID,
|
||||
Nat_TestNat_SubGroupID,
|
||||
Nat_TestNat_SampleTypeID,
|
||||
Nat_TestFontSize,
|
||||
Nat_TestFontColor,
|
||||
Nat_TestIsBold,
|
||||
Nat_TestIsItalic,
|
||||
Nat_TestFlagGluc,
|
||||
Nat_TestIsQuantitative,
|
||||
Nat_TestIsDeltaCheck,
|
||||
Nat_TestIsResult,
|
||||
Nat_TestIsPrice,
|
||||
Nat_TestIsPrintResult,
|
||||
Nat_TestIsPrintNota,
|
||||
Nat_TestIsTrendAnalysis,
|
||||
Nat_TestIsWorklist,
|
||||
Nat_TestIsNonLab,
|
||||
Nat_TestWorklistName,
|
||||
Nat_TestFlagLow,
|
||||
Nat_TestFlagHigh,
|
||||
{$userid},
|
||||
NOW()
|
||||
FROM nat_test
|
||||
WHERE
|
||||
Nat_TestCode = '{$codefrom}' AND Nat_TestIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$this->db_regional->query($query);
|
||||
$sql = "SELECT T_TestID FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y' LIMIT 1";
|
||||
$data_parent = $this->db_regional->query($sql)->row();
|
||||
if($data_parent){
|
||||
$testidparent = $data_parent->T_TestID;
|
||||
$sql = "UPDATE t_test SET T_TestIsParent = 'Y' WHERE T_TestID = {$testidparent}";
|
||||
$this->db_regional->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $xcount,
|
||||
"debug"=>$query
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
229
one-api/application/controllers/v1/masterdata/Jpatestright.php
Normal file
229
one-api/application/controllers/v1/masterdata/Jpatestright.php
Normal file
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
class Jpatestright extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingverify API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM nat_jpagroup
|
||||
WHERE
|
||||
Nat_JPAGroupIsActive = 'Y'
|
||||
GROUP BY Nat_JPAGroupID
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function search_listing()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM nat_jpagroup
|
||||
WHERE
|
||||
Nat_JPAGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql);
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "insert into nat_jpadetail(
|
||||
Nat_JPADetailNat_JPAID,
|
||||
Nat_JPADetailNat_JPAGroupID,
|
||||
Nat_JPADetailDiscount,
|
||||
Nat_JPADetailUserID,
|
||||
Nat_JPADetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['Nat_JpaID']}',
|
||||
'{$prm['Nat_JPAGroupID']}',
|
||||
'{$prm['Nat_JPADetailDiscount']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Nat_JPADetailDiscount = {$prm['Nat_JPADetailDiscount']},
|
||||
Nat_JPADetailUserID = {$userid}";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_regional->query($query);
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_regional->last_query(), $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function savejpagroup(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "insert into nat_jpagroup(
|
||||
Nat_JPAGroupName,
|
||||
Nat_JPAGroupUserID,
|
||||
Nat_JPAGroupCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['value']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_regional->query($query);
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_regional->last_query(), $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function savelistingjpagroup(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE nat_jpagroup SET
|
||||
Nat_JPAGroupName = '{$prm['name']}',
|
||||
Nat_JPAGroupIsActive = '{$prm['status']}',
|
||||
Nat_JPAGroupUserID = {$userid}
|
||||
WHERE
|
||||
Nat_JPAGroupID = {$prm['id']}
|
||||
";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_regional->query($query);
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_regional->last_query(), $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function savealljpadetail(){
|
||||
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 = "insert into nat_jpadetail(
|
||||
Nat_JPADetailNat_JPAID,
|
||||
Nat_JPADetailNat_JPAGroupID,
|
||||
Nat_JPADetailDiscount,
|
||||
Nat_JPADetailUserID,
|
||||
Nat_JPADetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$v['Nat_JpaID']}',
|
||||
'{$v['Nat_JPAGroupID']}',
|
||||
'{$v['Nat_JPADetailDiscount']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Nat_JPADetailDiscount = {$v['Nat_JPADetailDiscount']},
|
||||
Nat_JPADetailUserID = {$userid}";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_regional->query($query);
|
||||
}
|
||||
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_regional->last_query(), $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
804
one-api/application/controllers/v1/masterdata/Mcunonlab.php
Normal file
804
one-api/application/controllers/v1/masterdata/Mcunonlab.php
Normal file
@@ -0,0 +1,804 @@
|
||||
<?php
|
||||
|
||||
class Mcunonlab extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "MCU NON LAB API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupmcunonlabbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$testname = $prm['testname'];
|
||||
$testcode = $prm['testcode'];
|
||||
$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 nat_test
|
||||
LEFT JOIN nat_mcunormalnolab ON Nat_TestID = Nat_McuNormalNonLabNat_TestID AND Nat_McuNormalNonLabIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_TestIsActive = 'Y' AND Nat_TestIsNonLab <> '' AND Nat_TestIsResult = 'Y' AND
|
||||
Nat_TestName like '%{$testname}%' AND
|
||||
Nat_TestCode like '%{$testcode}%'
|
||||
$filter GROUP BY Nat_TestID) 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("nat_test count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT nat_test.*,
|
||||
Nat_TestID as id,
|
||||
Nat_TestID,
|
||||
IFNULL(Nat_McuNormalNonLabID,0) as Nat_McuNormalNonLabID,
|
||||
Nat_TestName,
|
||||
Nat_TestCode
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_mcunormalnolab ON Nat_TestID = Nat_McuNormalNonLabNat_TestID AND Nat_McuNormalNonLabIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_TestIsActive = 'Y' AND Nat_TestIsNonLab <> '' AND Nat_TestIsResult = 'Y' AND
|
||||
Nat_TestName like '%{$testname}%' AND
|
||||
Nat_TestCode like '%{$testcode}%'
|
||||
$filter
|
||||
GROUP BY Nat_TestID
|
||||
ORDER BY Nat_TestCode 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("nat_test 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 lookupmcunormalnonlabbyid(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$mcunonlabtext = $prm['mcunormalnonlabtext'];
|
||||
$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(Nat_McuNormalNonLabID,0) > 0 , 'Y', 'N') as status
|
||||
from m_mcunonlab
|
||||
LEFT JOIN nat_mcunormalnolab ON M_McuNonLabID = Nat_McuNormalNonLabM_McuNonLabID AND Nat_McuNormalNonLabNat_TestID = $id AND Nat_McuNormalNonLabIsActive = 'Y'
|
||||
LEFT JOIN nat_test ON Nat_McuNormalNonLabNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
|
||||
WHERE
|
||||
M_McuNonLabIsActive = 'Y' GROUP BY M_McuNonLabID) a
|
||||
WHERE
|
||||
M_McuNonLabText like '%{$mcunonlabtext}%' $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("m_mcunonlab count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(select M_McuNonLabID as id,
|
||||
M_McuNonLabID,
|
||||
M_McuNonLabText,
|
||||
Nat_McuNormalNonLabID,
|
||||
Nat_McuNormalNonLabNat_TestID,
|
||||
Nat_McuNormalNonLabM_McuNonLabID,
|
||||
IF(IFNULL(Nat_McuNormalNonLabID,0) > 0 , 'Y', 'N') as status
|
||||
from m_mcunonlab
|
||||
LEFT JOIN nat_mcunormalnolab ON M_McuNonLabID = Nat_McuNormalNonLabM_McuNonLabID AND Nat_McuNormalNonLabNat_TestID = $id AND Nat_McuNormalNonLabIsActive = 'Y'
|
||||
LEFT JOIN nat_test ON Nat_McuNormalNonLabNat_TestID = Nat_TestID AND Nat_TestIsActive = 'Y'
|
||||
WHERE
|
||||
M_McuNonLabIsActive = 'Y') a
|
||||
WHERE
|
||||
M_McuNonLabText like '%{$mcunonlabtext}%' $filter
|
||||
GROUP BY M_McuNonLabID
|
||||
ORDER BY M_McuNonLabID 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_mcunonlab 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 listingmcunormalnonlab(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$mcunonlabtext = $prm['mcunormalnonlabtext'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
from m_mcunonlab
|
||||
WHERE
|
||||
M_McuNonLabIsActive = 'Y' AND
|
||||
M_McuNonLabText like '%{$mcunonlabtext}%'";
|
||||
// $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_mcunonlab count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
from m_mcunonlab
|
||||
WHERE
|
||||
M_McuNonLabIsActive = 'Y' AND
|
||||
M_McuNonLabText like '%{$mcunonlabtext}%'
|
||||
ORDER BY M_McuNonLabID 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_mcunonlab 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 *
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_testtype
|
||||
WHERE
|
||||
Nat_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['normalvaluetypees'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['flages'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['ageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['minageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['maxageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 0 as Nat_SexID, 'Semua' as Nat_SexName
|
||||
UNION
|
||||
SELECT Nat_SexID, Nat_SexName
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_sexs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 0 as Nat_FlagID, 'Semua' as Nat_FlagName
|
||||
UNION
|
||||
SELECT Nat_FlagID, Nat_FlagName
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows['f_flags'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$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 addnewmcunormalnonlab()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$mcunonlabtext = $prm['mcunonlabtext'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into m_mcunonlab(
|
||||
M_McuNonLabText,
|
||||
M_McuNonLabUserID,
|
||||
M_McuNonLabCreated,
|
||||
M_McuNonLabLastUpdated
|
||||
)
|
||||
values(?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$mcunonlabtext,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_mcunonlab 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 saveaddeditmcunormalnonlab()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$testid = $prm['testid'];
|
||||
$mcunonlabid = $prm['M_McuNonLabID'];
|
||||
$mcunonlabmcunormalnonlabid = $prm['Nat_McuNormalNonLabID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($status == 'Y'){
|
||||
$sql = "insert into nat_mcunormalnolab(
|
||||
Nat_McuNormalNonLabNat_TestID,
|
||||
Nat_McuNormalNonLabM_McuNonLabID,
|
||||
Nat_McuNormalNonLabUserID,
|
||||
Nat_McuNormalNonLabCreated,
|
||||
Nat_McuNormalNonLabLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$mcunonlabid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_mcunormalnolab 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 nat_mcunormalnolab SET
|
||||
Nat_McuNormalNonLabIsActive = 'N',
|
||||
Nat_McuNormalNonLabUserID = ?,
|
||||
Nat_McuNormalNonLabCreated = now(),
|
||||
Nat_McuNormalNonLabLastUpdated = now()
|
||||
WHERE Nat_McuNormalNonLabID = ?";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$mcunonlabmcunormalnonlabid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_mcunormalnolab 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 saveeditsaran(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE m_mcunonlab SET
|
||||
M_McuNonLabText = '{$prm['mcunonlabtext']}',
|
||||
M_McuNonLabIsActive = '{$prm['status']}',
|
||||
M_McuNonLabUserID = {$userid}
|
||||
WHERE
|
||||
M_McuNonLabID = {$prm['id']}
|
||||
";
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
function saveallmcunonlab(){
|
||||
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 nat_mcunormalnolab SET
|
||||
Nat_McuNormalNonLabNat_TestID = '{$v['Nat_McuNormalNonLabNat_TestID']}',
|
||||
Nat_McuNormalNonLabAdviceIna = '{$v['Nat_McuNormalNonLabAdviceIna']}',
|
||||
Nat_McuNormalNonLabAdviceEng = '{$v['Nat_McuNormalNonLabAdviceEng']}',
|
||||
Nat_McuNormalNonLabUserID = {$userid},
|
||||
Nat_McuNormalNonLabCreated = now(),
|
||||
Nat_McuNormalNonLabLastUpdated = now()
|
||||
WHERE Nat_McuNormalNonLabID = {$v['Nat_McuNormalNonLabID']}";
|
||||
|
||||
//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 deletemcunormalnonlab()
|
||||
{
|
||||
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 nat_test SET
|
||||
Nat_TestIsActive = 'N'
|
||||
WHERE
|
||||
Nat_TestNat_MethodeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_test 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 deletemcunonlab()
|
||||
{
|
||||
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_test SET
|
||||
Nat_TestIsActive = 'N'
|
||||
WHERE
|
||||
Nat_TestID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_test 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 searchmcunormalnonlab(){
|
||||
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_TestCode 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_TestCode
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_TestCode like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_TestCode 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 searchmcunormalnonlabbyname(){
|
||||
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_TestCode 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_TestCode
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_TestCode like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_TestCode 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
218
one-api/application/controllers/v1/masterdata/Menu.php
Normal file
218
one-api/application/controllers/v1/masterdata/Menu.php
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
|
||||
class Priviledge extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "USERGROUP PRIVILEDGE API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function lookupusergroup()
|
||||
{
|
||||
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_usergroup
|
||||
where
|
||||
M_UserGroupIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_regional->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select M_UserGroupID as id, M_UserGroupDashboard as dashboard, M_UserGroupName as name, M_UserGroupIsClinic as clinic, M_UserGroupName as description , 'xxx' as usergrouptype
|
||||
from m_usergroup
|
||||
where
|
||||
M_UserGroupName LIKE CONCAT('%','{$search}','%') AND
|
||||
M_UserGroupIsActive = 'Y' $limit";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("m_usergroup 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 lookuppriviledge()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT S_MenuID as id, S_MenuUrl, S_MenuName as name, '' as childs FROM s_menu WHERE S_MenuParentS_MenuID = 0 AND S_MenuIsActive = 'Y' ORDER BY S_MenuOrder ASC";
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
if($v['S_MenuUrl'] == '#'){
|
||||
$sql = " SELECT S_MenuID as id, S_MenuID, S_MenuUrl, S_MenuName, S_PrivilegeID, {$prm['id']} as usergroupid, IF(ISNULL(S_PrivilegeID),'N','Y') as status, 'N' as active, '' as childs
|
||||
FROM s_menu
|
||||
LEFT JOIN s_privilege ON S_PrivilegeS_MenuID = S_MenuID AND S_PrivilegeIsActive = 'Y' AND S_PrivilegeM_UserGroupID = '{$prm['id']}'
|
||||
WHERE
|
||||
S_MenuIsActive = 'Y' AND S_MenuParentS_MenuID = '{$v['id']}'
|
||||
ORDER BY S_MenuOrder ASC";
|
||||
$rows[$k]['childs'] = $this->db_regional->query($sql)->result_array();
|
||||
if($rows[$k]['childs']){
|
||||
foreach($rows[$k]['childs'] as $kx => $vx){
|
||||
if($vx['S_MenuUrl'] == '#'){
|
||||
$sql = " SELECT S_MenuID, S_MenuUrl, S_MenuName, S_PrivilegeID, {$prm['id']} as usergroupid, IF(ISNULL(S_PrivilegeID),'N','Y') as status, 'N' as active, '' as childs
|
||||
FROM s_menu
|
||||
LEFT JOIN s_privilege ON S_PrivilegeS_MenuID = S_MenuID AND S_PrivilegeIsActive = 'Y' AND S_PrivilegeM_UserGroupID = '{$prm['id']}'
|
||||
WHERE
|
||||
S_MenuIsActive = 'Y' AND S_MenuParentS_MenuID = '{$vx['id']}'
|
||||
ORDER BY S_MenuOrder ASC";
|
||||
$rows[$k]['childs'][$kx]['childs'] = $this->db_regional->query($sql)->result_array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
$sql = " SELECT S_MenuID, S_MenuUrl, S_MenuName, S_PrivilegeID, {$prm['id']} as usergroupid, IF(ISNULL(S_PrivilegeID),'N','Y') as status, 'N' as active, '' as childs
|
||||
FROM s_menu
|
||||
LEFT JOIN s_privilege ON S_PrivilegeS_MenuID = S_MenuID AND S_PrivilegeIsActive = 'Y' AND S_PrivilegeM_UserGroupID = '{$prm['id']}'
|
||||
WHERE
|
||||
S_MenuIsActive = 'Y' AND S_MenuID = '{$v['id']}'
|
||||
ORDER BY S_MenuOrder ASC";
|
||||
$rows[$k]['childs'] = $this->db_regional->query($sql)->result_array();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_usergroup select");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$datas = $prm['datas'];
|
||||
foreach ($datas as $k => $v){
|
||||
foreach ($v['childs'] as $kx => $vx){
|
||||
if($vx['active'] == 'Y'){
|
||||
if(is_null($vx['S_PrivilegeID']) && $vx['status'] == 'Y'){
|
||||
$sql = "INSERT INTO s_privilege (
|
||||
S_PrivilegeM_UserGroupID,
|
||||
S_PrivilegeS_MenuID,
|
||||
S_PrivilegeCreated
|
||||
)
|
||||
VALUES(
|
||||
{$vx['usergroupid']},
|
||||
{$vx['S_MenuID']},
|
||||
NOW()
|
||||
)";
|
||||
$this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
}
|
||||
|
||||
if(!is_null($vx['S_PrivilegeID'])){
|
||||
$sql = "UPDATE s_privilege SET
|
||||
S_PrivilegeIsActive = '{$vx['status']}'
|
||||
WHERE
|
||||
S_PrivilegeID = '{$vx['S_PrivilegeID']}'
|
||||
";
|
||||
$this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
}
|
||||
}
|
||||
if($vx['childs']){
|
||||
foreach ($vx['childs'] as $kxz => $vxz){
|
||||
if($vxz['active'] == 'Y'){
|
||||
if(is_null($vxz['S_PrivilegeID']) && $vxz['status'] == 'Y'){
|
||||
$sql = "INSERT INTO s_privilege (
|
||||
S_PrivilegeM_UserGroupID,
|
||||
S_PrivilegeS_MenuID,
|
||||
S_PrivilegeCreated
|
||||
)
|
||||
VALUES(
|
||||
{$vxz['usergroupid']},
|
||||
{$vxz['S_MenuID']},
|
||||
NOW()
|
||||
)";
|
||||
$this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
}
|
||||
|
||||
if(!is_null($vxz['S_PrivilegeID'])){
|
||||
$sql = "UPDATE s_privilege SET
|
||||
S_PrivilegeIsActive = '{$vxz['status']}'
|
||||
WHERE
|
||||
S_PrivilegeID = '{$vxz['S_PrivilegeID']}'
|
||||
";
|
||||
$this->db_regional->query($sql);
|
||||
//echo $this->db_regional->last_query();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total"=>1,"records" => array());
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
219
one-api/application/controllers/v1/masterdata/Methode.php
Normal file
219
one-api/application/controllers/v1/masterdata/Methode.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
class Methode extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$code = $prm["scode"];
|
||||
$nama = $prm["nama"];
|
||||
|
||||
// echo $nik;
|
||||
|
||||
$sql_where = "WHERE Nat_MethodeIsActive = 'Y' ";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " Nat_MethodeName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
if ($code != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
if ($code == "xxx") {
|
||||
$sql_where .= " Nat_MethodeCode = Nat_MethodeOldCode ";
|
||||
$sql_param[] = "%$code%";
|
||||
} else {
|
||||
$sql_where .= " Nat_MethodeCode like ? ";
|
||||
$sql_param[] = "%$code%";
|
||||
}
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_StaffIsActive = 'Y' ";
|
||||
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM nat_methode
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM nat_methode
|
||||
$sql_where
|
||||
ORDER BY Nat_MethodeCode ASC
|
||||
limit 0,$tot_count";
|
||||
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_methode($v['M_StaffID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($prm['Nat_MethodePriority'] == '')
|
||||
$prm['Nat_MethodePriority'] = 0;
|
||||
|
||||
$query ="UPDATE nat_methode SET
|
||||
Nat_MethodeName = '{$prm['Nat_MethodeName']}',
|
||||
Nat_MethodeNameInResult = '{$prm['Nat_MethodeNameInResult']}',
|
||||
Nat_MethodeCode = '{$prm['Nat_MethodeCode']}',
|
||||
Nat_MethodePriority = '{$prm['Nat_MethodePriority']}',
|
||||
Nat_MethodeM_UserID = '{$userid}',
|
||||
Nat_MethodeLastUpdated = now()
|
||||
WHERE Nat_MethodeID = '{$prm['Nat_MethodeID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
if($rows){
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function newmethode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
if($prm['Nat_MethodePriority'] == '')
|
||||
$prm['Nat_MethodePriority'] = 0;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO nat_methode (
|
||||
Nat_MethodeName,
|
||||
Nat_MethodeNameInResult,
|
||||
Nat_MethodeCode,
|
||||
Nat_MethodePriority,
|
||||
Nat_MethodeM_UserID,
|
||||
Nat_MethodeCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['Nat_MethodeName']}',
|
||||
'{$prm['Nat_MethodeNameInResult']}',
|
||||
'{$prm['Nat_MethodeCode']}',
|
||||
'{$prm['Nat_MethodePriority']}',
|
||||
'{$userid}',
|
||||
now()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
if($rows){
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function deletemethode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE nat_methode SET
|
||||
Nat_MethodeIsActive = 'N'
|
||||
WHERE
|
||||
Nat_MethodeID = '{$prm['Nat_MethodeID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$query ="UPDATE nat_normalvalue SET
|
||||
Nat_NormalValueIsActive = 'N'
|
||||
WHERE
|
||||
Nat_NormalValueNat_MethodeID = '{$prm['Nat_MethodeID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function checkcodeexist(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rtn = 'N';
|
||||
$query =" SELECT COUNT(*) as countx
|
||||
FROM nat_methode
|
||||
WHERE Nat_MethodeCode = '{$prm['code']}' AND Nat_MethodeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rst = $this->db_regional->query($query)->row()->countx;
|
||||
if($rst > 0)
|
||||
$rtn = 'Y';
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rtn,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
1156
one-api/application/controllers/v1/masterdata/Methodeunit.php
Normal file
1156
one-api/application/controllers/v1/masterdata/Methodeunit.php
Normal file
File diff suppressed because it is too large
Load Diff
2736
one-api/application/controllers/v1/masterdata/Mou_re_verify.php
Normal file
2736
one-api/application/controllers/v1/masterdata/Mou_re_verify.php
Normal file
File diff suppressed because it is too large
Load Diff
2733
one-api/application/controllers/v1/masterdata/Mou_re_verify_v4.php
Normal file
2733
one-api/application/controllers/v1/masterdata/Mou_re_verify_v4.php
Normal file
File diff suppressed because it is too large
Load Diff
262
one-api/application/controllers/v1/masterdata/Mouexpired.php
Normal file
262
one-api/application/controllers/v1/masterdata/Mouexpired.php
Normal file
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
class Mouexpired extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Mou Expired API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$company = $prm['company'];
|
||||
$status = $prm['status'];
|
||||
// echo $norm;
|
||||
if($status === 'C'){
|
||||
$sql_status = " AND M_MouStatus = 'R' AND M_MouEndDate <= now() + INTERVAL + 30 DAY AND M_MouEndDate > now()";
|
||||
}elseif($status === 'Y'){
|
||||
$sql_status = " AND M_MouStatus = 'R' AND M_MouEndDate < now()";
|
||||
}elseif($status === 'N'){
|
||||
$sql_status = " AND M_MouStatus = 'R' AND M_MouEndDate > now()";
|
||||
}elseif($status === 'A'){
|
||||
$sql_status = " AND M_MouStatus = 'R'";
|
||||
}
|
||||
$sql_where = "WHERE M_MouIsActive = 'Y'";
|
||||
if(intval($company) > 0){
|
||||
$sql_where = "$sql_where AND M_MouM_CompanyID = {$company}";
|
||||
}
|
||||
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM m_mou
|
||||
|
||||
$sql_where $sql_status
|
||||
";
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
$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_mou count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$doctor_field = "
|
||||
M_MouID as id,
|
||||
M_MouM_CompanyID as companyid,
|
||||
M_MouM_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,
|
||||
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,
|
||||
M_MouAllowVerify as isallowverified,
|
||||
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
|
||||
";
|
||||
$sql = "SELECT $doctor_field, M_CompanyName,
|
||||
IF(M_MouEndDate <= now() + INTERVAL + 30 DAY AND M_MouEndDate > now(),'C','N') as isexpired
|
||||
from m_mou
|
||||
JOIN m_company On M_MouM_CompanyID = M_CompanyID
|
||||
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
|
||||
$sql_where $sql_status
|
||||
GROUP BY M_MouID
|
||||
ORDER BY M_CompanyName ASC, M_MouEndDate ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
//echo $this->db_regional->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_PatientID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_sex
|
||||
WHERE
|
||||
M_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_regional->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM m_religion
|
||||
WHERE
|
||||
M_ReligionIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['religions'] = $this->db_regional->query($query)->result_array();
|
||||
$query ="
|
||||
SELECT 0 as M_CompanyID, 'Semua' as M_CompanyName
|
||||
UNION
|
||||
SELECT M_CompanyID, M_CompanyName
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['companys'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'A' as statusid, 'Semua' as statusname
|
||||
UNION SELECT 'Y' as statusid, 'Expired' as statusname
|
||||
UNION SELECT 'N' as statusid, 'Coming Soon' as statusname
|
||||
";
|
||||
//echo $query;
|
||||
$rows['statuss'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function searchstaff(){
|
||||
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_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y'
|
||||
AND (Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')";
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_staff count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT * FROM(SELECT *, CONCAT(Nat_StaffName, ' [',Nat_StaffNIK,']') as Nat_StaffNames
|
||||
FROM nat_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y') a
|
||||
WHERE
|
||||
(Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')
|
||||
AND Nat_StaffIsActive = 'Y'
|
||||
ORDER BY Nat_StaffName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_staff rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
400
one-api/application/controllers/v1/masterdata/Mouexpiredv2.php
Normal file
400
one-api/application/controllers/v1/masterdata/Mouexpiredv2.php
Normal file
@@ -0,0 +1,400 @@
|
||||
<?php
|
||||
class Mouexpiredv2 extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Mou Expired API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$company = $prm['company'];
|
||||
$status = $prm['status'];
|
||||
// echo $norm;
|
||||
if($status === 'C'){
|
||||
$sql_status = " AND M_MouStatus = 'R' AND M_MouEndDate <= now() + INTERVAL + 30 DAY AND M_MouEndDate > now()";
|
||||
}elseif($status === 'Y'){
|
||||
$sql_status = " AND M_MouStatus = 'R' AND M_MouEndDate < now()";
|
||||
}elseif($status === 'N'){
|
||||
$sql_status = " AND M_MouStatus = 'R' AND M_MouEndDate > now()";
|
||||
}elseif($status === 'A'){
|
||||
$sql_status = " AND M_MouStatus = 'R'";
|
||||
}
|
||||
$sql_where = "WHERE M_MouIsActive = 'Y'";
|
||||
if(intval($company) > 0){
|
||||
$sql_where = "$sql_where AND M_MouM_CompanyID = {$company}";
|
||||
}
|
||||
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM m_mou
|
||||
|
||||
$sql_where $sql_status
|
||||
";
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
$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_mou count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$doctor_field = "
|
||||
M_MouID as id,
|
||||
M_MouM_CompanyID as companyid,
|
||||
M_MouM_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,
|
||||
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,
|
||||
M_MouAllowVerify as isallowverified,
|
||||
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
|
||||
";
|
||||
$sql = "SELECT $doctor_field, M_CompanyName,
|
||||
IF(M_MouEndDate <= now() + INTERVAL + 30 DAY AND M_MouEndDate > now(),'C','N') as isexpired
|
||||
from m_mou
|
||||
JOIN m_company On M_MouM_CompanyID = M_CompanyID
|
||||
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
|
||||
$sql_where $sql_status
|
||||
GROUP BY M_MouID
|
||||
ORDER BY M_CompanyName ASC, M_MouEndDate ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
//echo $this->db_regional->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_PatientID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_sex
|
||||
WHERE
|
||||
M_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_regional->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM m_religion
|
||||
WHERE
|
||||
M_ReligionIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['religions'] = $this->db_regional->query($query)->result_array();
|
||||
$query ="
|
||||
SELECT 0 as M_CompanyID, 'Semua' as M_CompanyName
|
||||
UNION
|
||||
SELECT M_CompanyID, M_CompanyName
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['companys'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'A' as statusid, 'Semua' as statusname
|
||||
UNION SELECT 'Y' as statusid, 'Expired' as statusname
|
||||
UNION SELECT 'N' as statusid, 'Coming Soon' as statusname
|
||||
";
|
||||
//echo $query;
|
||||
$rows['statuss'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function searchstaff(){
|
||||
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_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y'
|
||||
AND (Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')";
|
||||
$query = $this->db_regional->query($sql);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_staff count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT * FROM(SELECT *, CONCAT(Nat_StaffName, ' [',Nat_StaffNIK,']') as Nat_StaffNames
|
||||
FROM nat_staff
|
||||
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
||||
WHERE
|
||||
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y') a
|
||||
WHERE
|
||||
(Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')
|
||||
AND Nat_StaffIsActive = 'Y'
|
||||
ORDER BY Nat_StaffName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("nat_staff rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function extendmou()
|
||||
{
|
||||
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'];
|
||||
$startdate = date('Y-m-d',strtotime($prm['startdate']));
|
||||
$enddate = date('Y-m-d',strtotime($prm['enddate']));
|
||||
$sql = "update m_mou SET
|
||||
M_MouStartDate = '{$startdate}',
|
||||
M_MouEndDate = '{$enddate}',
|
||||
M_MouUserID = '{$userid}',
|
||||
M_MouLastUpdated = now()
|
||||
WHERE
|
||||
M_MouID = ?";
|
||||
|
||||
$query = $this->db_regional->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
$result = $this->upload_mou($id);
|
||||
if ($result[0] ) {
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error($result);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function upload_mou($mouID) {
|
||||
//upload aggrement , ss_price_mou
|
||||
$sql = "select M_MouID,M_MouStartDate,M_MouEndDate from m_mou where M_MouID = ?";
|
||||
$qry = $this->db_regional->query($sql, array($mouID));
|
||||
if (! $qry) {
|
||||
return array(false, print_r($this->db_regional->error(),true));
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0) {
|
||||
return array(false, "No MOU : " . $this->db_regional->last_query());
|
||||
}
|
||||
$mou = $rows[0];
|
||||
|
||||
$sql = "select * from m_company where M_CompanyID = ?";
|
||||
$qry = $this->db_regional->query($sql, array($mou["M_MouM_CompanyID"]));
|
||||
if (! $qry) {
|
||||
return array(false, print_r($this->db_regional->error(),true));
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return array(false, "No Company");
|
||||
}
|
||||
$company = $rows[0];
|
||||
|
||||
|
||||
|
||||
$param = array (
|
||||
"mou" => $mou
|
||||
);
|
||||
$param_md5 = md5(json_encode($param));
|
||||
$j_param = json_encode(array("param" => $param, "md5" => $param_md5 ));
|
||||
$sql = "select * from m_branch
|
||||
JOIN s_regional ON M_BranchS_RegionalID = S_RegionalID AND S_RegionalIsDefault = 'Y'
|
||||
where M_BranchIsActive = 'Y'";
|
||||
$qry = $this->db_regional->query($sql);
|
||||
if (! $qry) {
|
||||
return array(false, print_r($this->db_regional->error(),true));
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
return array(false, "No Ss Price Mou");
|
||||
}
|
||||
|
||||
$sql = "insert into tx_mou(TxMouM_BranchIPAddress, TxMouM_BranchCode,TxMouM_MouID, TxMouJson,TxMouM_UserID,TxMouT_TestID )
|
||||
values(?,?,?,?,?,'-1')";
|
||||
//$sql_del = "delete from tx_mou where TxMouM_MouID=? and TxMouM_BranchCode=?";
|
||||
$flag_error = false;
|
||||
$err_msg = array();
|
||||
$userID = $this->sys_user["M_UserID"];
|
||||
foreach($rows as $r ) {
|
||||
$branchCode = $r["M_BranchCode"];
|
||||
$ipAddress = $r["M_BranchIPAddress"];
|
||||
$qry = $this->db_regional->query($sql_del, array($mouID,$branchCode));
|
||||
/* if (! $qry) {
|
||||
return array(false, print_r($this->db_regional->error(),true));
|
||||
}
|
||||
*/
|
||||
$qry = $this->db_regional->query($sql, array($ipAddress, $branchCode,$mouID,$j_param,$userID));
|
||||
if (! $qry) {
|
||||
return array(false, print_r($this->db_regional->error(),true));
|
||||
}
|
||||
try {
|
||||
$txMouID = $this->db_regional->insert_id();
|
||||
$url = "http://$ipAddress/one-api/tools/price/extendmou/verify";
|
||||
$post_rst = $this->post($url,$j_param);
|
||||
$j_rst = json_decode($post_rst,true);
|
||||
if ($j_rst["status"] != "OK" ) {
|
||||
$err_msg[] = $post_rst;
|
||||
$flag_error = true;
|
||||
$this->db_regional->query("update tx_mou set TxMouRetry = 1 where TxMouID = ? ", array($txMouID));
|
||||
} else {
|
||||
$this->db_regional->query("update tx_mou set TxMouStatus = 'Y' , TxMouRetry = 1 where TxMouID = ? ", array($txMouID));
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$err_msg[] = $e->getMessage();
|
||||
$flag_error = true;
|
||||
}
|
||||
}
|
||||
if ( $flag_error) {
|
||||
return array(false, join(",",$err_msg));
|
||||
}
|
||||
return array(true,"OK");
|
||||
}
|
||||
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 12);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
2540
one-api/application/controllers/v1/masterdata/Moureadytoverif.php
Normal file
2540
one-api/application/controllers/v1/masterdata/Moureadytoverif.php
Normal file
File diff suppressed because it is too large
Load Diff
2599
one-api/application/controllers/v1/masterdata/Moureadytoverifv2.php
Normal file
2599
one-api/application/controllers/v1/masterdata/Moureadytoverifv2.php
Normal file
File diff suppressed because it is too large
Load Diff
2728
one-api/application/controllers/v1/masterdata/Moureadytoverifv4.php
Normal file
2728
one-api/application/controllers/v1/masterdata/Moureadytoverifv4.php
Normal file
File diff suppressed because it is too large
Load Diff
2799
one-api/application/controllers/v1/masterdata/Moureadytoverifv5.php
Normal file
2799
one-api/application/controllers/v1/masterdata/Moureadytoverifv5.php
Normal file
File diff suppressed because it is too large
Load Diff
2626
one-api/application/controllers/v1/masterdata/Mouresend.php
Normal file
2626
one-api/application/controllers/v1/masterdata/Mouresend.php
Normal file
File diff suppressed because it is too large
Load Diff
1501
one-api/application/controllers/v1/masterdata/Multirule.php
Normal file
1501
one-api/application/controllers/v1/masterdata/Multirule.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,301 @@
|
||||
<?php
|
||||
class Natinstrumentmethode extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "NatInstrumentMethode API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_one= $this->load->database("regional", true);
|
||||
}
|
||||
function list_instrument() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$search= "%" . $prm["search"] . "%";
|
||||
try {
|
||||
$sql = "select * from nat_instrument where Nat_InstrumentIsActive='Y' and Nat_InstrumentName like ?";
|
||||
$qry = $this->db_one->query($sql, array($search));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatInstrument List", $this->db_one);
|
||||
}
|
||||
}
|
||||
function list_test() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$search= "%" . $prm["search"] . "%";
|
||||
try {
|
||||
$sql = "select * from nat_test where Nat_TestIsResult = 'Y'
|
||||
and Nat_TestIsActive='Y' and Nat_TestName like ?";
|
||||
$qry = $this->db_one->query($sql, array($search));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatTest List", $this->db_one);
|
||||
}
|
||||
}
|
||||
function delete_instrument() {
|
||||
$param = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
try {
|
||||
$sql = "update nat_instrument
|
||||
set
|
||||
Nat_InstrumentIsActive = 'N'
|
||||
,Nat_InstrumentUserID = ?
|
||||
where
|
||||
Nat_InstrumentID= ?";
|
||||
|
||||
$id = $param["Nat_InstrumentID"];
|
||||
|
||||
$qry = $this->db_one->query($sql, array($userid,$id));
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("Nat_Instrument save", $this->db_one);
|
||||
}
|
||||
}
|
||||
|
||||
function save_instrument() {
|
||||
$param = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($param["Nat_InstrumentID"] == 0 ) {
|
||||
//add
|
||||
try {
|
||||
$sql = "insert into nat_instrument( Nat_InstrumentCode, Nat_InstrumentName
|
||||
,Nat_InstrumentUserID)
|
||||
values (?, ?, ? )
|
||||
";
|
||||
$code= $param["Nat_InstrumentCode"];
|
||||
$name = $param["Nat_InstrumentName"];
|
||||
$qry = $this->db_one->query($sql, array($code, $name, $userid ));
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$sql = "update nat_instrument
|
||||
set
|
||||
Nat_InstrumentCode = ?
|
||||
,Nat_InstrumentName = ?
|
||||
,Nat_InstrumentUserID = ?
|
||||
where
|
||||
Nat_InstrumentID= ?";
|
||||
|
||||
$id = $param["Nat_InstrumentID"];
|
||||
$code= $param["Nat_InstrumentCode"];
|
||||
$name = $param["Nat_InstrumentName"];
|
||||
|
||||
$qry = $this->db_one->query($sql, array($code, $name, $userid,
|
||||
$id));
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("Nat_Instrument save", $this->db_one);
|
||||
}
|
||||
}
|
||||
}
|
||||
function save() {
|
||||
$param = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($param["M_InstrumentMethodeID"] == 0 ) {
|
||||
//add
|
||||
try {
|
||||
$sql = "insert into m_instrumentmethode(M_InstrumentMethodeNat_InstrumentID,
|
||||
M_InstrumentMethodeNat_MethodeID, M_InstrumentMethodeNat_TestID,
|
||||
M_InstrumentMethodeResultFormatSF, M_InstrumentMethodeResultFormatAboveSF,
|
||||
M_InstrumentMethodePriority,
|
||||
M_InstrumentMethodeUserID)
|
||||
values (?, ?, ?, ?, ?, ?, ? ) ";
|
||||
$instrumentID = $param["Nat_InstrumentID"];
|
||||
$methodeID= $param["Nat_MethodeID"];
|
||||
$testID= $param["Nat_TestID"];
|
||||
$resultFormatSF= $param["ResultFormatSF"];
|
||||
$resultFormatAboveSF= $param["ResultFormatAboveSF"];
|
||||
$priority = $param["Priority"];
|
||||
$sql_param = array($instrumentID, $methodeID, $testID,
|
||||
$resultFormatSF, $resultFormatAboveSF,
|
||||
$priority, $userid);
|
||||
|
||||
$qry = $this->db_one->query($sql, $sql_param );
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$sql = "update m_instrumentmethode set M_InstrumentMethodeNat_InstrumentID = ?, M_InstrumentMethodeNat_MethodeID =?,
|
||||
M_InstrumentMethodeNat_TestID =?, M_InstrumentMethodeResultFormatSF = ?,M_InstrumentMethodeResultFormatAboveSF = ? ,
|
||||
M_InstrumentMethodePriority = ? , M_InstrumentMethodeUserID = ?
|
||||
where M_InstrumentMethodeID = ? ";
|
||||
|
||||
$methodePxID = $param["M_InstrumentMethodeID"];
|
||||
$instrumentID = $param["Nat_InstrumentID"];
|
||||
$methodeID= $param["Nat_MethodeID"];
|
||||
$testID= $param["Nat_TestID"];
|
||||
$resultFormatSF= $param["ResultFormatSF"];
|
||||
$resultFormatAboveSF= $param["ResultFormatAboveSF"];
|
||||
$priority = $param["Priority"];
|
||||
if ($resultFormatSF == "") $resultFormatSF = "0.00";
|
||||
if ($resultFormatAboveSF == "") $resultFormatAboveSF = "0";
|
||||
|
||||
$sql_param = array($instrumentID, $methodeID, $testID, $resultFormatSF,
|
||||
$resultFormatAboveSF, $priority, $userID, $methodePxID);
|
||||
$qry = $this->db_one->query($sql,$sql_param );
|
||||
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
}
|
||||
}
|
||||
function list_methode() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$search= "%" . $prm["search"] . "%";
|
||||
try {
|
||||
$sql = "select * from nat_methode where Nat_MethodeIsActive='Y' and Nat_MethodeName like ?";
|
||||
$qry = $this->db_one->query($sql, array($search));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
}
|
||||
function list_methodepx() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$instrumentID = $prm["Nat_InstrumentID"] ;
|
||||
try {
|
||||
$sql = "select * , Nat_TestName, Nat_MethodeName
|
||||
from m_instrumentmethode
|
||||
join nat_test on Nat_TestID = M_InstrumentMethodeNat_TestID
|
||||
join nat_methode on Nat_MethodeID = M_InstrumentMethodeNat_MethodeID
|
||||
where M_InstrumentMethodeIsActive='Y'
|
||||
and M_InstrumentMethodeNat_InstrumentID = ?";
|
||||
$qry = $this->db_one->query($sql, array($instrumentID));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
}
|
||||
|
||||
function get_test_methode() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$id= $prm["Nat_TestID"] ;
|
||||
try {
|
||||
$sql = "select * from nat_test where Nat_TestID = ?";
|
||||
$qry = $this->db_one->query($sql, array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) $test= $rows[0];
|
||||
|
||||
$id= $prm["Nat_MethodeID"] ;
|
||||
$sql = "select * from nat_methode where Nat_MethodeID= ?";
|
||||
$qry = $this->db_one->query($sql, array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) $methode = $rows[0];
|
||||
|
||||
$result = array("status" => "OK" ,
|
||||
"data" => array("test" => $test , "methode" => $methode )
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$result = $this->sys_ok( array("status" => "ERR") );
|
||||
}
|
||||
} else {
|
||||
$result = $this->sys_ok( array("status" => "ERR") );
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("MethodePx delete", $this->db_one);
|
||||
}
|
||||
}
|
||||
function delete_methodepx() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$id= $prm["id"] ;
|
||||
try {
|
||||
$sql = "update
|
||||
m_instrumentmethode
|
||||
set M_InstrumentMethodeIsActive = 'N'
|
||||
where M_InstrumentMethodeID = ? ";
|
||||
$qry = $this->db_one->query($sql, array($id));
|
||||
if ($qry) {
|
||||
$result = array("records" => "");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("MethodePx delete", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("MethodePx delete", $this->db_one);
|
||||
}
|
||||
}
|
||||
}
|
||||
997
one-api/application/controllers/v1/masterdata/Normalvalue.php
Normal file
997
one-api/application/controllers/v1/masterdata/Normalvalue.php
Normal file
@@ -0,0 +1,997 @@
|
||||
<?php
|
||||
class Normalvalue extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "Normal Value API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$code = $prm["code"];
|
||||
$nama = $prm["nama"];
|
||||
|
||||
// echo $norm;
|
||||
|
||||
$sql_where = "WHERE Nat_TestIsActive = 'Y' AND Nat_TestIsResult = 'Y'";
|
||||
$sql_param = array();
|
||||
if ($code != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " Nat_TestCode like ? ";
|
||||
$sql_param[] = "%$code%";
|
||||
}
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " Nat_TestName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_PatientIsActive = 'Y' ";
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM nat_test
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_test count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM nat_test
|
||||
$sql_where
|
||||
ORDER BY Nat_TestCode ASC
|
||||
limit 0,$tot_count";
|
||||
//echo $sql;
|
||||
$query = $this->db_regional->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
function searchmethode(){
|
||||
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_regional->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);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->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);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcompany(){
|
||||
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_company
|
||||
WHERE
|
||||
Nat_TestName like ?
|
||||
AND Nat_TestIsActive = 'Y' AND Nat_TestIsLabFrom = 'Y'";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_company
|
||||
WHERE
|
||||
Nat_TestName like ?
|
||||
AND Nat_TestIsActive = 'Y' AND Nat_TestIsLabFrom = 'Y'
|
||||
ORDER BY Nat_TestName DESC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function getmou(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouIsActive = 'Y' AND M_MouNat_TestID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_normalvaluetype
|
||||
WHERE
|
||||
Nat_NormalValueTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['normalvaluetypees'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['flages'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['ageunites'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 0 as Nat_SexID, 'Semua' as Nat_SexName
|
||||
UNION
|
||||
SELECT Nat_SexID, Nat_SexName
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_sexs'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 0 as Nat_FlagID, 'Semua' as Nat_FlagName
|
||||
UNION
|
||||
SELECT Nat_FlagID, Nat_FlagName
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows['f_flags'] = $this->db_regional->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
||||
$query ="UPDATE m_patient SET
|
||||
M_PatientM_TitleID = '{$prm['M_PatientM_TitleID']}',
|
||||
M_PatientName = '{$prm['M_PatientName']}',
|
||||
M_PatientDOB = '{$pdob}',
|
||||
M_PatientM_SexID = '{$prm['M_PatientM_SexID']}',
|
||||
M_PatientM_ReligionID = '{$prm['M_PatientM_ReligionID']}',
|
||||
M_PatientEmail = '{$prm['M_PatientEmail']}',
|
||||
M_PatientHP = '{$prm['M_PatientHP']}',
|
||||
M_PatientPhone = '{$prm['M_PatientPhone']}',
|
||||
M_PatientM_IdTypeID = '{$prm['M_PatientM_IdTypeID']}',
|
||||
M_PatientIDNumber = '{$prm['M_PatientIDNumber']}',
|
||||
M_PatientNote = '{$prm['M_PatientNote']}'
|
||||
WHERE
|
||||
M_PatientID = '{$prm['M_PatientID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newreceivereference(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pdate = date('Y-m-d',strtotime($prm['sdate']));
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO nat_test (
|
||||
Nat_TestNat_TestID,
|
||||
Nat_TestM_MouID,
|
||||
Nat_TestDate,
|
||||
Nat_TestNote,
|
||||
Nat_TestUserID,
|
||||
Nat_TestCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['companyid']}',
|
||||
'{$prm['mouid']}',
|
||||
'{$pdate}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$last_id = $this->db_regional->insert_id();
|
||||
|
||||
$querylog ="INSERT INTO g_receivereferenceheaderstatuslog (
|
||||
G_ReceiveReferenceHeaderStatusLogDate,
|
||||
G_ReceiveReferenceHeaderStatusLogNat_TestID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_StatusReferenceID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_UserID,
|
||||
G_ReceiveReferenceHeaderStatusLogUserID,
|
||||
G_ReceiveReferenceHeaderStatusLogCreated,
|
||||
G_ReceiveReferenceHeaderStatusLogLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$last_id}',
|
||||
'1',
|
||||
'{$userid}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $querylog;
|
||||
$insert_new_log = $this->db_regional->query($querylog);
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function sendorder(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE nat_test SET
|
||||
Nat_TestIsSent = 'Y',
|
||||
Nat_TestSentDate = now(),
|
||||
Nat_TestUserID = '{$userid}'
|
||||
WHERE
|
||||
Nat_TestID = '{$prm['Nat_TestID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$querylog ="INSERT INTO g_receivereferenceheaderstatuslog (
|
||||
G_ReceiveReferenceHeaderStatusLogDate,
|
||||
G_ReceiveReferenceHeaderStatusLogNat_TestID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_StatusReferenceID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_UserID,
|
||||
G_ReceiveReferenceHeaderStatusLogUserID,
|
||||
G_ReceiveReferenceHeaderStatusLogCreated,
|
||||
G_ReceiveReferenceHeaderStatusLogLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$prm['Nat_TestID']}',
|
||||
'2',
|
||||
'{$userid}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $querylog;
|
||||
$insert_new_log = $this->db_regional->query($querylog);
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getnilainormal(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$methodename = $prm['methodename'];
|
||||
$sexid = $prm['sexid'];
|
||||
$flagid = $prm['flagid'];
|
||||
$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))";
|
||||
}
|
||||
$query =" SELECT nat_normalvalue.*,
|
||||
Nat_TestName,
|
||||
Nat_SexID,
|
||||
Nat_SexName,
|
||||
Nat_MethodeID,
|
||||
Nat_MethodeName,
|
||||
Nat_NormalValueTypeID,
|
||||
Nat_NormalValueTypeName,
|
||||
Nat_FlagID,
|
||||
Nat_FlagName,
|
||||
CASE
|
||||
WHEN Nat_NormalValueMinAgeInclusive = 'Y' AND Nat_NormalValueMaxAgeInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinAge,' - ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')')
|
||||
WHEN Nat_NormalValueMinAgeInclusive = 'Y' AND Nat_NormalValueMaxAgeInclusive = 'N' THEN CONCAT(Nat_NormalValueMinAge,' > ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')')
|
||||
WHEN Nat_NormalValueMinAgeInclusive = 'N' AND Nat_NormalValueMaxAgeInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinAge,' < ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')')
|
||||
ELSE '-'
|
||||
END as Nat_NormalValueAge,
|
||||
CASE
|
||||
WHEN Nat_NormalValueMinValueInclusive = 'Y' AND Nat_NormalValueMaxValueInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinValue,' - ',Nat_NormalValueMaxValue)
|
||||
WHEN Nat_NormalValueMinValueInclusive = 'Y' AND Nat_NormalValueMaxValueInclusive = 'N' THEN CONCAT(Nat_NormalValueMinValue,' > ',Nat_NormalValueMaxValue)
|
||||
WHEN Nat_NormalValueMinValueInclusive = 'N' AND Nat_NormalValueMaxValueInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinValue,' < ',Nat_NormalValueMaxValue)
|
||||
ELSE '-'
|
||||
END as Nat_NormalValueValue,
|
||||
CASE
|
||||
WHEN Nat_NormalValueAgeUnit = 'HARI' THEN '1'
|
||||
WHEN Nat_NormalValueAgeUnit = 'BULAN' THEN '2'
|
||||
WHEN Nat_NormalValueAgeUnit = 'TAHUN' THEN '3'
|
||||
ELSE '4'
|
||||
END as ageunit,
|
||||
IF(Nat_NormalValueIsAbnormal = 'N',Nat_NormalValueID,Nat_NormalValueParentID) as parentid,
|
||||
DATE_FORMAT(Nat_NormalValueValidDate,'%d-%m-%Y') as Nat_NormalValueValidDatex,
|
||||
'' as tes,
|
||||
'xxx' as tests,
|
||||
'' as action,
|
||||
'N' as show_detail
|
||||
|
||||
FROM nat_normalvalue
|
||||
LEFT JOIN nat_sex ON Nat_NormalValueNat_SexID = Nat_SexID
|
||||
JOIN nat_test ON Nat_NormalValueNat_TestID = Nat_TestID
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID AND Nat_MethodeIsActive = 'Y'
|
||||
JOIN nat_normalvaluetype ON Nat_NormalValueNat_NormalValueTypeID = Nat_NormalValueTypeID
|
||||
LEFT JOIN nat_flag ON Nat_NormalValueNat_FlagID = Nat_FlagID
|
||||
WHERE
|
||||
Nat_NormalValueIsActive = 'Y' AND Nat_NormalValueNat_TestID = {$prm['id']} AND
|
||||
Nat_MethodeName like '%{$methodename}%'
|
||||
$filter
|
||||
GROUP BY Nat_NormalValueID
|
||||
ORDER BY Nat_NormalValueNat_SexID ASC, ageunit ASC, Nat_NormalValueMinAge ASC, Nat_NormalValueMaxAge ASC, parentid ASC
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query)->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
if($rows){
|
||||
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['tesx'] = json_decode($x->n);
|
||||
$rows[$k]['tests'] = $this->add_test($v['Nat_NormalValueID']);
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function add_test($orderid){
|
||||
$query ="SELECT IFNULL(Nat_NormalValueLangID,0) as id,
|
||||
IFNULL(Nat_NormalValueLangNat_NormalValueID,$orderid) as Nat_NormalValueLangNat_NormalValueID,
|
||||
Nat_LangName,
|
||||
IFNULL(Nat_NormalValueLangNote, '') as Nat_NormalValueLangNote,
|
||||
IFNULL(Nat_NormalValueLangNoteSI, '') as Nat_NormalValueLangNoteSI,
|
||||
IFNULL(Nat_NormalValueLangDescription, '') as Nat_NormalValueLangDescription,
|
||||
IFNULL(Nat_NormalValueLangDescriptionSI, '') as Nat_NormalValueLangDescriptionSI,
|
||||
IFNULL(Nat_NormalValueLangNat_LangID, Nat_LangID) as Nat_NormalValueLangNat_LangID,
|
||||
'xxx' as action,
|
||||
'Y' as show_detail,
|
||||
Nat_LangID as idx,
|
||||
Nat_LangID
|
||||
from nat_lang
|
||||
left join nat_normalvaluelang ON Nat_LangID = Nat_NormalValueLangNat_LangID AND Nat_NormalValueLangNat_NormalValueID = {$orderid}
|
||||
left join nat_normalvalue ON Nat_NormalValueLangNat_NormalValueID = Nat_NormalValueID
|
||||
where
|
||||
Nat_LangIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query)->result_array();
|
||||
if(!$rows)
|
||||
$rows = array();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function savenewnilainormal(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pvaliddate = date('Y-m-d',strtotime($prm['Nat_NormalValueValidDate ']));
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO nat_normalvalue (
|
||||
Nat_NormalValueNat_TestID,
|
||||
Nat_NormalValueNat_MethodeID,
|
||||
Nat_NormalValueNat_NormalValueTypeID,
|
||||
Nat_NormalValueNat_FlagID,
|
||||
Nat_NormalValueValidDate,
|
||||
Nat_NormalValueMinAge,
|
||||
Nat_NormalValueMaxAge,
|
||||
Nat_NormalValueMinAgeInclusive,
|
||||
Nat_NormalValueMaxAgeInclusive,
|
||||
Nat_NormalValueAgeUnit,
|
||||
Nat_NormalValueNat_SexID,
|
||||
Nat_NormalValueNote,
|
||||
Nat_NormalValueMinValue,
|
||||
Nat_NormalValueMaxValue,
|
||||
Nat_NormalValueMinValueInclusive,
|
||||
Nat_NormalValueMaxValueInclusive,
|
||||
Nat_NormalValueDescription,
|
||||
Nat_NormalValueIsAbnormal,
|
||||
Nat_NormalValueUserID,
|
||||
Nat_NormalValueLastUpdated
|
||||
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['Nat_NormalValueNat_TestID']}',
|
||||
'{$prm['Nat_NormalValueNat_MethodeID']}',
|
||||
'{$prm['Nat_NormalValueNat_NormalValueTypeID']}',
|
||||
'{$prm['Nat_NormalValueNat_FlagID']}',
|
||||
'{$prm['Nat_NormalValueValidDate']}',
|
||||
'{$prm['Nat_NormalValueMinAge']}',
|
||||
'{$prm['Nat_NormalValueMaxAge']}',
|
||||
'{$prm['Nat_NormalValueMinAgeInclusive']}',
|
||||
'{$prm['Nat_NormalValueMaxAgeInclusive']}',
|
||||
'{$prm['Nat_NormalValueAgeUnit']}',
|
||||
'{$prm['Nat_NormalValueNat_SexID']}',
|
||||
'{$prm['Nat_NormalValueNote']}',
|
||||
'{$prm['Nat_NormalValueMinValue']}',
|
||||
'{$prm['Nat_NormalValueMaxValue']}',
|
||||
'{$prm['Nat_NormalValueMinValueInclusive']}',
|
||||
'{$prm['Nat_NormalValueMaxValueInclusive']}',
|
||||
'{$prm['Nat_NormalValueDescription']}',
|
||||
'{$prm['Nat_NormalValueIsAbnormal']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$ordernormalvalue_id = $this->db_regional->insert_id();
|
||||
$sql_param = $ordernormalvalue_id;
|
||||
$sql = "select * from nat_normalvalue
|
||||
where Nat_NormalValueID= ?";
|
||||
$query = $this->db_regional->query($sql,$sql_param);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_normalvalue select by normalvalue");
|
||||
exit;
|
||||
}
|
||||
/*$sql = "insert into nasional_log.log_normalvalue(Log_NormalValueCode,
|
||||
Log_NormalValueData, Log_NormalValueUserID) values(?,?,?)";
|
||||
$data = json_encode($rows);
|
||||
$userID = $this->sys_user["M_UserID"];
|
||||
$sql_param = array("NormalValue.Add", $data , $userID);
|
||||
$query = $this->db_regional->query($sql,$sql_param);
|
||||
if (! $query) {
|
||||
$this->sys_error_db( $this->db_regional->last_query());
|
||||
exit;
|
||||
}*/
|
||||
$querylang ="INSERT INTO nat_normalvaluelang (
|
||||
Nat_NormalValueLangNat_NormalValueID,
|
||||
Nat_NormalValueLangNat_LangID,
|
||||
Nat_NormalValueLangNote,
|
||||
Nat_NormalValueLangDescription,
|
||||
Nat_NormalValueLangUserID,
|
||||
Nat_NormalValueLangCreated,
|
||||
Nat_NormalValueLangLastUpdated
|
||||
|
||||
)
|
||||
VALUES(
|
||||
'{$ordernormalvalue_id}',
|
||||
'1',
|
||||
'{$prm['Nat_NormalValueNote']}',
|
||||
'{$prm['Nat_NormalValueDescription']}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
now()
|
||||
)
|
||||
";
|
||||
$rows = $this->db_regional->query($querylang);
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditnilainormal(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$order_id = $prm['Nat_NormalValueID'];
|
||||
$pvaliddate = date('Y-m-d',strtotime($prm['Nat_NormalValueValidDate ']));
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($prm['Nat_NormalValueNat_NormalValueTypeID'] == '4'){
|
||||
$prm['Nat_NormalValueMinAge'] = 0;
|
||||
$prm['Nat_NormalValueMaxAge'] = 0;
|
||||
$prm['Nat_NormalValueMinAgeInclusive'] = 'N';
|
||||
$prm['Nat_NormalValueMaxAgeInclusive'] = 'N';
|
||||
$prm['Nat_NormalValueAgeUnit'] = '';
|
||||
$prm['Nat_NormalValueNat_SexID'] = 0;
|
||||
|
||||
}
|
||||
if($prm['Nat_NormalValueNat_NormalValueTypeID'] == '2'){
|
||||
$prm['Nat_NormalValueNat_SexID'] = 0;
|
||||
|
||||
}
|
||||
if($prm['Nat_NormalValueNat_NormalValueTypeID'] == '3'){
|
||||
$prm['Nat_NormalValueMinAge'] = 0;
|
||||
$prm['Nat_NormalValueMaxAge'] = 0;
|
||||
$prm['Nat_NormalValueMinAgeInclusive'] = 'N';
|
||||
$prm['Nat_NormalValueMaxAgeInclusive'] = 'N';
|
||||
$prm['Nat_NormalValueAgeUnit'] = '';
|
||||
}
|
||||
|
||||
$query ="UPDATE nat_normalvalue SET
|
||||
Nat_NormalValueNat_TestID = '{$prm['Nat_NormalValueNat_TestID']}',
|
||||
Nat_NormalValueNat_MethodeID = '{$prm['Nat_NormalValueNat_MethodeID']}',
|
||||
Nat_NormalValueNat_NormalValueTypeID = '{$prm['Nat_NormalValueNat_NormalValueTypeID']}',
|
||||
Nat_NormalValueNat_FlagID = '{$prm['Nat_NormalValueNat_FlagID']}',
|
||||
Nat_NormalValueValidDate = '{$prm['Nat_NormalValueValidDate']}',
|
||||
Nat_NormalValueMinAge = '{$prm['Nat_NormalValueMinAge']}',
|
||||
Nat_NormalValueMaxAge = '{$prm['Nat_NormalValueMaxAge']}',
|
||||
Nat_NormalValueMinAgeInclusive = '{$prm['Nat_NormalValueMinAgeInclusive']}',
|
||||
Nat_NormalValueMaxAgeInclusive = '{$prm['Nat_NormalValueMaxAgeInclusive']}',
|
||||
Nat_NormalValueAgeUnit = '{$prm['Nat_NormalValueAgeUnit']}',
|
||||
Nat_NormalValueNat_SexID = '{$prm['Nat_NormalValueNat_SexID']}',
|
||||
Nat_NormalValueNote = '{$prm['Nat_NormalValueNote']}',
|
||||
Nat_NormalValueMinValue = '{$prm['Nat_NormalValueMinValue']}',
|
||||
Nat_NormalValueMaxValue = '{$prm['Nat_NormalValueMaxValue']}',
|
||||
Nat_NormalValueMinValueInclusive = '{$prm['Nat_NormalValueMinValueInclusive']}',
|
||||
Nat_NormalValueMaxValueInclusive = '{$prm['Nat_NormalValueMaxValueInclusive']}',
|
||||
Nat_NormalValueDescription = '{$prm['Nat_NormalValueDescription']}',
|
||||
Nat_NormalValueIsAbnormal = '{$prm['Nat_NormalValueIsAbnormal']}',
|
||||
Nat_NormalValueUserID = '{$userid}',
|
||||
Nat_NormalValueLastUpdated = now()
|
||||
WHERE
|
||||
Nat_NormalValueID = '{$prm['Nat_NormalValueID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$sql_param = $order_id;
|
||||
$sql = "select * from nat_normalvalue
|
||||
where Nat_NormalValueID= ?";
|
||||
$query = $this->db_regional->query($sql,$sql_param);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_normalvalue select by normalvalue");
|
||||
exit;
|
||||
}
|
||||
/* $sql = "insert into nasional_log.log_normalvalue(Log_NormalValueCode,
|
||||
Log_NormalValueData, Log_NormalValueUserID) values(?,?,?)";
|
||||
$data = json_encode($rows);
|
||||
$userID = $this->sys_user["M_UserID"];
|
||||
$sql_param = array("NormalValue.Update", $data , $userID);
|
||||
$query = $this->db_regional->query($sql,$sql_param);
|
||||
if (! $query) {
|
||||
$this->sys_error_db( $this->db_regional->last_query());
|
||||
exit;
|
||||
}*/
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function savenewnilaiabnormal(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pvaliddate = date('Y-m-d',strtotime($prm['Nat_NormalValueValidDate ']));
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO nat_normalvalue (
|
||||
Nat_NormalValueNat_TestID,
|
||||
Nat_NormalValueNat_MethodeID,
|
||||
Nat_NormalValueNat_NormalValueTypeID,
|
||||
Nat_NormalValueNat_FlagID,
|
||||
Nat_NormalValueValidDate,
|
||||
Nat_NormalValueMinAge,
|
||||
Nat_NormalValueMaxAge,
|
||||
Nat_NormalValueMinAgeInclusive,
|
||||
Nat_NormalValueMaxAgeInclusive,
|
||||
Nat_NormalValueAgeUnit,
|
||||
Nat_NormalValueNat_SexID,
|
||||
Nat_NormalValueNote,
|
||||
Nat_NormalValueMinValue,
|
||||
Nat_NormalValueMaxValue,
|
||||
Nat_NormalValueMinValueInclusive,
|
||||
Nat_NormalValueMaxValueInclusive,
|
||||
Nat_NormalValueDescription,
|
||||
Nat_NormalValueParentID,
|
||||
Nat_NormalValueIsAbnormal,
|
||||
Nat_NormalValueUserID,
|
||||
Nat_NormalValueLastUpdated
|
||||
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['Nat_NormalValueNat_TestID']}',
|
||||
'{$prm['Nat_NormalValueNat_MethodeID']}',
|
||||
'{$prm['Nat_NormalValueNat_NormalValueTypeID']}',
|
||||
'{$prm['Nat_NormalValueNat_FlagID']}',
|
||||
'{$prm['Nat_NormalValueValidDate']}',
|
||||
'{$prm['Nat_NormalValueMinAge']}',
|
||||
'{$prm['Nat_NormalValueMaxAge']}',
|
||||
'{$prm['Nat_NormalValueMinAgeInclusive']}',
|
||||
'{$prm['Nat_NormalValueMaxAgeInclusive']}',
|
||||
'{$prm['Nat_NormalValueAgeUnit']}',
|
||||
'{$prm['Nat_NormalValueNat_SexID']}',
|
||||
'{$prm['Nat_NormalValueNote']}',
|
||||
'{$prm['Nat_NormalValueMinValue']}',
|
||||
'{$prm['Nat_NormalValueMaxValue']}',
|
||||
'{$prm['Nat_NormalValueMinValueInclusive']}',
|
||||
'{$prm['Nat_NormalValueMaxValueInclusive']}',
|
||||
'{$prm['Nat_NormalValueDescription']}',
|
||||
'{$prm['Nat_NormalValueParentID']}',
|
||||
'{$prm['Nat_NormalValueIsAbnormal']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$ordernormalvalue_id = $this->db_regional->insert_id();
|
||||
$sql_param = $ordernormalvalue_id;
|
||||
$sql = "select * from nat_normalvalue
|
||||
where Nat_NormalValueID= ?";
|
||||
$query = $this->db_regional->query($sql,$sql_param);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_normalvalue select by normalvalue");
|
||||
exit;
|
||||
}
|
||||
/*$sql = "insert into nasional_log.log_normalvalue(Log_NormalValueCode,
|
||||
Log_NormalValueData, Log_NormalValueUserID) values(?,?,?)";
|
||||
$data = json_encode($rows);
|
||||
$userID = $this->sys_user["M_UserID"];
|
||||
$sql_param = array("NormalValue.Add", $data , $userID);
|
||||
$query = $this->db_regional->query($sql,$sql_param);
|
||||
if (! $query) {
|
||||
$this->sys_error_db( $this->db_regional->last_query());
|
||||
exit;
|
||||
}*/
|
||||
$querylang ="INSERT INTO nat_normalvaluelang (
|
||||
Nat_NormalValueLangNat_NormalValueID,
|
||||
Nat_NormalValueLangNat_LangID,
|
||||
Nat_NormalValueLangNote,
|
||||
Nat_NormalValueLangDescription,
|
||||
Nat_NormalValueLangUserID,
|
||||
Nat_NormalValueLangCreated,
|
||||
Nat_NormalValueLangLastUpdated
|
||||
|
||||
)
|
||||
VALUES(
|
||||
'{$ordernormalvalue_id}',
|
||||
'1',
|
||||
'{$prm['Nat_NormalValueNote']}',
|
||||
'{$prm['Nat_NormalValueDescription']}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
now()
|
||||
)
|
||||
";
|
||||
$rows = $this->db_regional->query($querylang);
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function deletenilainormal(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="UPDATE nat_normalvalue SET
|
||||
Nat_NormalValueIsActive = 'N',
|
||||
Nat_NormalValueUserID = '{$userid}'
|
||||
WHERE
|
||||
Nat_NormalValueID = '{$prm['Nat_NormalValueID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
$sql_param = $prm['Nat_NormalValueID'];
|
||||
$sql = "select * from nat_normalvalue
|
||||
where Nat_NormalValueID= ?";
|
||||
$query = $this->db_regional->query($sql,$sql_param);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_normalvalue select by normalvalue");
|
||||
exit;
|
||||
}
|
||||
/* $sql = "insert into nasional_log.log_normalvalue(Log_NormalValueCode,
|
||||
Log_NormalValueData, Log_NormalValueUserID) values(?,?,?)";
|
||||
$data = json_encode($rows);
|
||||
$userID = $this->sys_user["M_UserID"];
|
||||
$sql_param = array("NormalValue.Delete", $data , $userID);
|
||||
$query = $this->db_regional->query($sql,$sql_param);
|
||||
if (! $query) {
|
||||
$this->sys_error_db( $this->db_regional->last_query());
|
||||
exit;
|
||||
}*/
|
||||
$query ="UPDATE nat_normalvaluelang SET
|
||||
Nat_NormalValueLangIsActive = 'N',
|
||||
Nat_NormalValueLangUserID = '{$userid}'
|
||||
WHERE
|
||||
Nat_NormalValueLangNat_NormalValueID = '{$prm['Nat_NormalValueID']}' AND Nat_NormalValueLangIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_regional->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function savenormalvaluelang(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$normalvalue_id = $prm['normalvalueid'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
foreach($prm['ordertests'] as $k=>$v){
|
||||
if($v['id'] == 0 || $v['id'] == '0'){
|
||||
$query = "INSERT INTO nat_normalvaluelang (
|
||||
Nat_NormalValueLangNat_NormalValueID,
|
||||
Nat_NormalValueLangNat_LangID,
|
||||
Nat_NormalValueLangNote,
|
||||
Nat_NormalValueLangNoteSI,
|
||||
Nat_NormalValueLangDescription,
|
||||
Nat_NormalValueLangDescriptionSI,
|
||||
Nat_NormalValueLangUserID,
|
||||
Nat_NormalValueLangCreated,
|
||||
Nat_NormalValueLangLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
?,?,?,?,?,?,?,now(),now()
|
||||
)";
|
||||
$insert_new_normalvaluelang = $this->db_regional->query($query,array(
|
||||
$normalvalue_id,
|
||||
$v['Nat_LangID'],
|
||||
$v['Nat_NormalValueLangNote'],
|
||||
$v['Nat_NormalValueLangNoteSI'],
|
||||
$v['Nat_NormalValueLangDescription'],
|
||||
$v['Nat_NormalValueLangDescriptionSI'],
|
||||
$userid
|
||||
));
|
||||
} else {
|
||||
$query = "UPDATE nat_normalvaluelang SET
|
||||
Nat_NormalValueLangNat_LangID = ?,
|
||||
Nat_NormalValueLangNote = ?,
|
||||
Nat_NormalValueLangNoteSI = ?,
|
||||
Nat_NormalValueLangDescription = ?,
|
||||
Nat_NormalValueLangDescriptionSI = ?,
|
||||
Nat_NormalValueLangUserID = ?
|
||||
WHERE
|
||||
Nat_NormalValueLangID = ?";
|
||||
$update_normalvaluelang = $this->db_regional->query($query,array($v['Nat_LangID'],$v['Nat_NormalValueLangNote'],$v['Nat_NormalValueLangNoteSI'],$v['Nat_NormalValueLangDescription'],$v['Nat_NormalValueLangDescriptionSI'],$userid,$v['id']));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function searchtest(){
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
$mou_id = $prm['mouid'];
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_test
|
||||
JOIN t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_MouID = '{$mou_id}'
|
||||
WHERE
|
||||
T_TestName like ? AND
|
||||
T_TestIsActive = 'Y'
|
||||
ORDER BY T_TestName ASC";
|
||||
$query = $this->db_regional->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("test count",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT 'Y' as editable, 0 as xid, T_TestID, T_TestCode, T_TestName, T_PriceAmount, T_PriceDisc, T_PriceDiscRp, T_PriceAmount - ((T_PriceDisc/100) * T_PriceAmount) - T_PriceDiscRp as total,
|
||||
Nat_TestID, Nat_TestIsBill, Nat_TestMinDP
|
||||
FROM one.t_test
|
||||
JOIN one.t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_MouID = '{$mou_id}'
|
||||
JOIN one.m_mou ON M_MouID = '{$mou_id}'
|
||||
JOIN one.m_company ON M_MouNat_TestID = Nat_TestID
|
||||
WHERE
|
||||
T_TestName like ? AND
|
||||
T_TestIsActive = 'Y'
|
||||
ORDER BY T_TestName ASC
|
||||
";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("test rows",$this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1030
one-api/application/controllers/v1/masterdata/Normalvalueanimal.php
Normal file
1030
one-api/application/controllers/v1/masterdata/Normalvalueanimal.php
Normal file
File diff suppressed because it is too large
Load Diff
613
one-api/application/controllers/v1/masterdata/Packet.php
Normal file
613
one-api/application/controllers/v1/masterdata/Packet.php
Normal file
@@ -0,0 +1,613 @@
|
||||
<?php
|
||||
|
||||
class Packet extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Packet API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search_packet($pxs = false)
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$mou = $prm['mou'];
|
||||
$search = '%'. $prm['search'] . '%';
|
||||
$type = $prm['type'];
|
||||
|
||||
$qtype = ($type == null ? "<> ''" : "= '{$type}'");
|
||||
// QUERY TOTAL
|
||||
if ($pxs)
|
||||
{
|
||||
$sql = "select count(distinct T_PacketID) total
|
||||
from t_packet
|
||||
join t_packetdetail on t_packetdetailt_packetid = t_packetid
|
||||
and t_packetdetailisactive = 'Y'
|
||||
join t_test on t_packetdetailt_testid = t_testid
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketName ASC";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "select count(*) total
|
||||
from t_packet
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketName ASC";
|
||||
|
||||
}
|
||||
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $mou, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($pxs)
|
||||
{
|
||||
$sql = "select T_PacketID, T_PacketName, T_PacketType, T_PacketPrice, T_PacketOriginalPrice,
|
||||
GROUP_CONCAT(T_TestName SEPARATOR ', ') pxs, T_PacketIsNota
|
||||
from t_packet
|
||||
|
||||
join t_packetdetail on t_packetdetailt_packetid = t_packetid
|
||||
and t_packetdetailisactive = 'Y'
|
||||
join t_test on t_packetdetailt_testid = t_testid
|
||||
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
group by T_PacketID
|
||||
order by T_PacketName ASC
|
||||
limit 0, {$max_rst}";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "select T_PacketID, T_PacketName, T_PacketType, T_PacketPrice, T_PacketOriginalPrice, T_PacketIsNota
|
||||
from t_packet
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketName ASC
|
||||
limit 0, {$max_rst}";
|
||||
}
|
||||
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $mou, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query(), "type"=>$type);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = '%'.$prm['search'].'%';
|
||||
|
||||
$max_rst = 12;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(DISTINCT M_CompanyID) total
|
||||
from m_company
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName LIKE ?
|
||||
order by M_CompanyName ASC";
|
||||
$query = $this->db_regional->query($sql, [$search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_CompanyID, M_CompanyName,
|
||||
IFNULL( concat('[', group_concat( json_object('M_MouID', M_MouID, 'M_MouName', M_MouName, 'M_MouStartDate', M_MouStartDate, 'M_MouEndDate', M_MouEndDate, 'M_MouIsReleased', M_MouIsReleased, 'M_MouIsVerified', M_MouIsVerified) ), ']'), '[]') as mou
|
||||
from m_company
|
||||
left join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now())
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName LIKE ?
|
||||
group by m_companyid
|
||||
order by M_CompanyName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_mou()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$company = $prm["company_id"];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
order by M_MouName ASC";
|
||||
$query = $this->db_regional->query($sql, [$company, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_MouID, M_MouName, M_MouStartDate, M_MouEndDate
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
order by M_MouName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$company, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// public function search_packet()
|
||||
// {
|
||||
// $prm = $this->sys_input;
|
||||
// $max_rst = 12;
|
||||
|
||||
// $search = '%' . $prm["search"] . '%';
|
||||
// $mou = $prm["mou_id"];
|
||||
|
||||
// // QUERY TOTAL
|
||||
// $sql = "select count(*) total
|
||||
// from t_price
|
||||
// join t_test on t_pricet_testid = t_testid
|
||||
|
||||
// where T_PriceIsActive = 'Y'
|
||||
// and T_PriceM_MouID = ?
|
||||
// and T_TestName LIKE ?
|
||||
// order by T_TestName ASC";
|
||||
// $query = $this->db_regional->query($sql, [$mou, $search]);
|
||||
|
||||
// if ($query) {
|
||||
// $tot_count = $query->result_array()[0]["total"];
|
||||
// }
|
||||
// else {
|
||||
// $this->sys_error_db("price mou count", $this->db_regional);
|
||||
// exit;
|
||||
// }
|
||||
|
||||
// $sql = "select T_PriceID, T_TestID, T_TestCode, T_TestName, T_PriceIsCito,
|
||||
// T_PriceM_CompanyID,
|
||||
// T_PriceM_MouID,
|
||||
// T_PricePriority,
|
||||
// T_PriceAmount,
|
||||
// T_PriceDisc,
|
||||
// T_PriceDiscRp,
|
||||
// T_PriceSubTotal,
|
||||
// T_PriceOther,
|
||||
// T_PriceTotal,
|
||||
// JSON_OBJECT('T_TestID', T_TestID, 'T_TestCode', T_TestCode, 'T_TestName', T_TestName) px
|
||||
// from t_price
|
||||
// join t_test on t_pricet_testid = t_testid
|
||||
|
||||
// where T_PriceIsActive = 'Y'
|
||||
// and T_PriceM_MouID = ?
|
||||
// and T_TestName LIKE ?
|
||||
// order by T_TestName ASC
|
||||
// limit 0, {$max_rst}";
|
||||
// $query = $this->db_regional->query($sql, [$mou, $search]);
|
||||
|
||||
// if ($query)
|
||||
// {
|
||||
// $rows = $query->result_array();
|
||||
|
||||
// foreach ($rows as $k => $v)
|
||||
// {
|
||||
// $rows[$k]['px'] = json_decode($v['px']);
|
||||
|
||||
// $sql = "select t_addonid id, t_addonname name, t_priceaddonamount price
|
||||
// from t_priceaddon
|
||||
// join t_addon on t_priceaddont_addonid = t_addonid
|
||||
// where t_priceaddont_priceid = ?
|
||||
// and t_priceaddonisactive = 'Y'";
|
||||
|
||||
// $query = $this->db_regional->query($sql, [$v['T_PriceID']]);
|
||||
|
||||
// $rows2 = [];
|
||||
// if ($query)
|
||||
// {
|
||||
// $rows2 = $query->result_array();
|
||||
// }
|
||||
|
||||
// $rows[$k]['others'] = $rows2;
|
||||
// }
|
||||
|
||||
|
||||
// $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
// $this->sys_ok($result);
|
||||
// }
|
||||
// else {
|
||||
// $this->sys_error_db("price mou rows", $this->db_regional);
|
||||
// exit;
|
||||
// }
|
||||
// }
|
||||
|
||||
public function del_packet()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = "update t_packet
|
||||
set t_packetisactive = 'N'
|
||||
where T_PacketIsActive = 'Y'
|
||||
and T_PacketID = ?";
|
||||
$query = $this->db_regional->query($sql, [$id]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$sql = "update t_packetdetail
|
||||
set t_packetdetailisactive = 'N'
|
||||
where T_PacketdetailIsActive = 'Y'
|
||||
and t_packetdetailt_packetid = ?";
|
||||
$query = $this->db_regional->query($sql, [$id]);
|
||||
|
||||
$result = array("query"=>$this->db_regional->last_query(), "id"=>$id);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("packet delete rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 50;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_packetdetail
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
where T_PacketDetailIsActive = 'Y'
|
||||
and T_PacketDetailT_PacketID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_PacketDetailID, T_TestID, T_TestCode, T_TestName, T_PacketDetailPrice, T_TestNat_TestID,
|
||||
IFNULL(Helper_NatTestsJson, '[]') nat_tests
|
||||
from t_packetdetail
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
left join helper_nattests on helper_nattestst_testid = t_testid
|
||||
and helper_natteststype = 'PX'
|
||||
and helper_nattestsisactive = 'Y'
|
||||
where T_PacketDetailIsActive = 'Y'
|
||||
and T_PacketDetailT_PacketID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestSasCode ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['nat_tests'] = json_decode($v['nat_tests']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = (array) json_decode($prm["data"]);
|
||||
|
||||
// QUERY
|
||||
$sql = "INSERT INTO t_packet(T_PacketM_CompanyID,
|
||||
T_PacketM_MouID,
|
||||
T_PacketType,
|
||||
T_PacketName,
|
||||
T_PacketSequence,
|
||||
T_PacketSasCode,
|
||||
T_PacketIsNota)
|
||||
values(?, ?, ?, ?, '', '', ?)";
|
||||
$query = $this->db_regional->query($sql, [$data['packet_company'], $data['packet_mou'], $data['packet_type'], $data['packet_name'], $data['packet_is_nota']]);
|
||||
|
||||
if ($query) {
|
||||
|
||||
$result = $this->db_regional->insert_id();
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("addon new", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_edit()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = (array) json_decode($prm["data"]);
|
||||
|
||||
// QUERY
|
||||
$sql = "UPDATE t_packet SET T_PacketName = ?, T_PacketIsNota = ? WHERE T_PacketID = ?";
|
||||
$query = $this->db_regional->query($sql, [$data['packet_name'], $data['packet_is_nota'], $data['packet_id']]);
|
||||
|
||||
if ($query) {
|
||||
$result = $data['packet_id'];
|
||||
|
||||
// UPDATE HELPER
|
||||
$sql = "sp_helper_nattests_create_packet(?)";
|
||||
$query = $this->db_regional->query($sql, [$result]);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("edit", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$json_test = $prm['json_px'];
|
||||
$packet_id = $prm['packet_id'];
|
||||
$packet_price = $prm['packet_price'];
|
||||
|
||||
// QUERY
|
||||
$sql = "CALL sp_master_packet_px_save(?, ?, ?)";
|
||||
$query = $this->db_regional->query($sql, [$packet_id, $packet_price, $json_test])
|
||||
->row();
|
||||
|
||||
if ($query->status == 'OK') {
|
||||
$result = $query->data;
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Save Px : " . $query->message, $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_test()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 5000;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$mou = $prm['mou_id'];
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
$exclude = $prm['exclude'];
|
||||
$include = $prm['include'];
|
||||
|
||||
$q_exc = $exclude == "" ? "" : "and T_TestID NOT IN ({$exclude})";
|
||||
$q_inc = $include == "" ? "" : "or (T_TestID IN ({$include}))";
|
||||
|
||||
// Packet Type
|
||||
$pck = $this->db_regional->select('T_PacketType', false)
|
||||
->where('T_PacketID', $packet_id)
|
||||
->get('t_packet')->row();
|
||||
if ($pck->T_PacketType == 'PN')
|
||||
{
|
||||
$moud = $this->db_regional->select('M_MouID')
|
||||
->where('M_MouIsDefault', 'Y')
|
||||
->where('M_MouIsActive', 'Y')
|
||||
->limit(1)
|
||||
->get('m_mou')->row();
|
||||
$mou = $moud->M_MouID;
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(distinct t_testid) total
|
||||
from t_test
|
||||
join t_price on t_pricet_testid = t_testid
|
||||
and t_pricem_mouid = ? and t_priceisactive = 'Y'
|
||||
|
||||
JOIN (
|
||||
SELECT MAX(CONCAT(T_PriceT_TestID, '-', T_PricePriority)) m
|
||||
FROM t_price
|
||||
WHERE T_PriceIsActive = 'Y' AND T_PriceM_MouID = ? AND T_PriceIsCito = 'N'
|
||||
GROUP BY T_PriceT_TestID, T_PriceIsCito, T_PriceM_MouID
|
||||
ORDER BY t_pricet_testid
|
||||
) b ON t_pricet_testid = SUBSTRING_INDEX(m, '-', 1) AND t_pricepriority = SUBSTRING_INDEX(m, '-', -1)
|
||||
|
||||
left join t_packetdetail on t_packetdetailisactive = 'Y'
|
||||
and t_packetdetailt_packetid = ?
|
||||
and t_packetdetailt_testid = t_testid
|
||||
where T_TestIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
and (t_packetdetailid is null {$q_inc})
|
||||
{$q_exc}
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $packet, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_TestID, T_TestCode, T_TestName, T_PriceTotal T_PriceAmount, T_TestNat_TestID,
|
||||
IFNULL(Helper_NatTestsJson, '[]') nat_tests
|
||||
from t_test
|
||||
join t_price on t_pricet_testid = t_testid
|
||||
and t_pricem_mouid = ? and t_priceisactive = 'Y'
|
||||
|
||||
JOIN (
|
||||
SELECT MAX(CONCAT(T_PriceT_TestID, '-', T_PricePriority)) m
|
||||
FROM t_price
|
||||
WHERE T_PriceIsActive = 'Y' AND T_PriceM_MouID = ? AND T_PriceIsCito = 'N'
|
||||
GROUP BY T_PriceT_TestID, T_PriceIsCito, T_PriceM_MouID
|
||||
ORDER BY t_pricet_testid
|
||||
) b ON t_pricet_testid = SUBSTRING_INDEX(m, '-', 1) AND t_pricepriority = SUBSTRING_INDEX(m, '-', -1)
|
||||
|
||||
left join t_packetdetail on t_packetdetailisactive = 'Y'
|
||||
and t_packetdetailt_packetid = ?
|
||||
and t_packetdetailt_testid = t_testid
|
||||
left join helper_nattests on helper_nattestst_testid = t_testid
|
||||
and helper_natteststype = 'PX'
|
||||
and helper_nattestsisactive = 'Y'
|
||||
where T_TestIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
and (t_packetdetailid is null {$q_inc})
|
||||
{$q_exc}
|
||||
order by T_TestName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['nat_tests'] = json_decode($v['nat_tests']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_mou_default()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
|
||||
|
||||
$sql = "select JSON_OBJECT('M_CompanyID', M_CompanyID, 'M_CompanyName', M_CompanyName) company,
|
||||
JSON_OBJECT('M_MouID', M_MouID, 'M_MouName', M_MouName) mou
|
||||
from m_mou
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID and M_CompanyIsDefault = 'Y'
|
||||
where M_MouIsDefault = 'Y'
|
||||
and M_MouIsActive = 'Y'
|
||||
limit 1";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->row();
|
||||
|
||||
$result = array("company" => json_decode($rows->company), "mou" => json_decode($rows->mou));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("MOU Default", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_copy() { return $this->packet_copy(); }
|
||||
public function packet_copy()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$source_id = $prm['source_id'];
|
||||
$target_id = $prm['target_id'];
|
||||
|
||||
// QUERY
|
||||
$sql = "CALL sp_master_packet_copy(?, ?)";
|
||||
$query = $this->db_regional->query($sql, [$source_id, $target_id])
|
||||
->row();
|
||||
|
||||
if ($query->status == 'OK') {
|
||||
$result = $query->data;
|
||||
$this->sys_ok(json_decode($result));
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet Copy : " . $query->message, $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
615
one-api/application/controllers/v1/masterdata/Packet_v2.php
Normal file
615
one-api/application/controllers/v1/masterdata/Packet_v2.php
Normal file
@@ -0,0 +1,615 @@
|
||||
<?php
|
||||
|
||||
class Packet_v2 extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Packet API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search_packet($pxs = false)
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$mou = $prm['mou'];
|
||||
$search = '%'. $prm['search'] . '%';
|
||||
$type = $prm['type'];
|
||||
|
||||
$qtype = ($type == null ? "<> ''" : "= '{$type}'");
|
||||
// QUERY TOTAL
|
||||
if ($pxs)
|
||||
{
|
||||
$sql = "select count(distinct T_PacketID) total
|
||||
from t_packet
|
||||
join t_packetdetail on t_packetdetailt_packetid = t_packetid
|
||||
and t_packetdetailisactive = 'Y'
|
||||
join t_test on t_packetdetailt_testid = t_testid
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketName ASC";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "select count(*) total
|
||||
from t_packet
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketName ASC";
|
||||
|
||||
}
|
||||
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $mou, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($pxs)
|
||||
{
|
||||
$sql = "select T_PacketID, T_PacketName, T_PacketType, T_PacketPrice, T_PacketOriginalPrice,
|
||||
GROUP_CONCAT(T_TestName SEPARATOR ', ') pxs, T_PacketIsNota
|
||||
from t_packet
|
||||
|
||||
join t_packetdetail on t_packetdetailt_packetid = t_packetid
|
||||
and t_packetdetailisactive = 'Y'
|
||||
join t_test on t_packetdetailt_testid = t_testid
|
||||
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
group by T_PacketID
|
||||
order by T_PacketName ASC
|
||||
limit 0, {$max_rst}";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "select T_PacketID, T_PacketName, T_PacketType, T_PacketPrice, T_PacketOriginalPrice, T_PacketIsNota
|
||||
from t_packet
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketName ASC
|
||||
limit 0, {$max_rst}";
|
||||
}
|
||||
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $mou, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query(), "type"=>$type);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = '%'.$prm['search'].'%';
|
||||
|
||||
$max_rst = 12;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(DISTINCT M_CompanyID) total
|
||||
from m_company
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName LIKE ?
|
||||
order by M_CompanyName ASC";
|
||||
$query = $this->db_regional->query($sql, [$search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_CompanyID, M_CompanyName,
|
||||
IFNULL( concat('[', group_concat( json_object('M_MouID', M_MouID, 'M_MouName', M_MouName, 'M_MouStartDate', M_MouStartDate, 'M_MouEndDate', M_MouEndDate, 'M_MouIsReleased', M_MouIsReleased, 'M_MouIsVerified', M_MouIsVerified) ), ']'), '[]') as mou
|
||||
from m_company
|
||||
left join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now())
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName LIKE ?
|
||||
group by m_companyid
|
||||
order by M_CompanyName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_mou()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$company = $prm["company_id"];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
order by M_MouName ASC";
|
||||
$query = $this->db_regional->query($sql, [$company, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_MouID, M_MouName, M_MouStartDate, M_MouEndDate
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
order by M_MouName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$company, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// public function search_packet()
|
||||
// {
|
||||
// $prm = $this->sys_input;
|
||||
// $max_rst = 12;
|
||||
|
||||
// $search = '%' . $prm["search"] . '%';
|
||||
// $mou = $prm["mou_id"];
|
||||
|
||||
// // QUERY TOTAL
|
||||
// $sql = "select count(*) total
|
||||
// from t_price
|
||||
// join t_test on t_pricet_testid = t_testid
|
||||
|
||||
// where T_PriceIsActive = 'Y'
|
||||
// and T_PriceM_MouID = ?
|
||||
// and T_TestName LIKE ?
|
||||
// order by T_TestName ASC";
|
||||
// $query = $this->db_regional->query($sql, [$mou, $search]);
|
||||
|
||||
// if ($query) {
|
||||
// $tot_count = $query->result_array()[0]["total"];
|
||||
// }
|
||||
// else {
|
||||
// $this->sys_error_db("price mou count", $this->db_regional);
|
||||
// exit;
|
||||
// }
|
||||
|
||||
// $sql = "select T_PriceID, T_TestID, T_TestCode, T_TestName, T_PriceIsCito,
|
||||
// T_PriceM_CompanyID,
|
||||
// T_PriceM_MouID,
|
||||
// T_PricePriority,
|
||||
// T_PriceAmount,
|
||||
// T_PriceDisc,
|
||||
// T_PriceDiscRp,
|
||||
// T_PriceSubTotal,
|
||||
// T_PriceOther,
|
||||
// T_PriceTotal,
|
||||
// JSON_OBJECT('T_TestID', T_TestID, 'T_TestCode', T_TestCode, 'T_TestName', T_TestName) px
|
||||
// from t_price
|
||||
// join t_test on t_pricet_testid = t_testid
|
||||
|
||||
// where T_PriceIsActive = 'Y'
|
||||
// and T_PriceM_MouID = ?
|
||||
// and T_TestName LIKE ?
|
||||
// order by T_TestName ASC
|
||||
// limit 0, {$max_rst}";
|
||||
// $query = $this->db_regional->query($sql, [$mou, $search]);
|
||||
|
||||
// if ($query)
|
||||
// {
|
||||
// $rows = $query->result_array();
|
||||
|
||||
// foreach ($rows as $k => $v)
|
||||
// {
|
||||
// $rows[$k]['px'] = json_decode($v['px']);
|
||||
|
||||
// $sql = "select t_addonid id, t_addonname name, t_priceaddonamount price
|
||||
// from t_priceaddon
|
||||
// join t_addon on t_priceaddont_addonid = t_addonid
|
||||
// where t_priceaddont_priceid = ?
|
||||
// and t_priceaddonisactive = 'Y'";
|
||||
|
||||
// $query = $this->db_regional->query($sql, [$v['T_PriceID']]);
|
||||
|
||||
// $rows2 = [];
|
||||
// if ($query)
|
||||
// {
|
||||
// $rows2 = $query->result_array();
|
||||
// }
|
||||
|
||||
// $rows[$k]['others'] = $rows2;
|
||||
// }
|
||||
|
||||
|
||||
// $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
// $this->sys_ok($result);
|
||||
// }
|
||||
// else {
|
||||
// $this->sys_error_db("price mou rows", $this->db_regional);
|
||||
// exit;
|
||||
// }
|
||||
// }
|
||||
|
||||
public function del_packet()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = "update t_packet
|
||||
set t_packetisactive = 'N'
|
||||
where T_PacketIsActive = 'Y'
|
||||
and T_PacketID = ?";
|
||||
$query = $this->db_regional->query($sql, [$id]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$sql = "update t_packetdetail
|
||||
set t_packetdetailisactive = 'N'
|
||||
where T_PacketdetailIsActive = 'Y'
|
||||
and t_packetdetailt_packetid = ?";
|
||||
$query = $this->db_regional->query($sql, [$id]);
|
||||
|
||||
$result = array("query"=>$this->db_regional->last_query(), "id"=>$id);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("packet delete rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 50;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_packetdetail
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
where T_PacketDetailIsActive = 'Y'
|
||||
and T_PacketDetailT_PacketID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_PacketDetailID, T_TestID, T_TestCode, T_TestName, T_PriceAmount, T_PacketDetailPrice, T_TestNat_TestID,
|
||||
IFNULL(Helper_NatTestsJson, '[]') nat_tests
|
||||
from t_packetdetail
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
join t_packet on T_PacketDetailT_PacketID = T_PacketID
|
||||
join t_price on T_PacketM_MouID = T_PriceM_MouID AND T_PacketDetailT_TestID = T_PriceT_TestID AND T_PriceIsActive = 'Y'
|
||||
left join helper_nattests on helper_nattestst_testid = t_testid
|
||||
and helper_natteststype = 'PX'
|
||||
and helper_nattestsisactive = 'Y'
|
||||
where T_PacketDetailIsActive = 'Y'
|
||||
and T_PacketDetailT_PacketID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestSasCode ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['nat_tests'] = json_decode($v['nat_tests']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = (array) json_decode($prm["data"]);
|
||||
|
||||
// QUERY
|
||||
$sql = "INSERT INTO t_packet(T_PacketM_CompanyID,
|
||||
T_PacketM_MouID,
|
||||
T_PacketType,
|
||||
T_PacketName,
|
||||
T_PacketSequence,
|
||||
T_PacketSasCode,
|
||||
T_PacketIsNota)
|
||||
values(?, ?, ?, ?, '', '', ?)";
|
||||
$query = $this->db_regional->query($sql, [$data['packet_company'], $data['packet_mou'], $data['packet_type'], $data['packet_name'], $data['packet_is_nota']]);
|
||||
|
||||
if ($query) {
|
||||
|
||||
$result = $this->db_regional->insert_id();
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("addon new", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_edit()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = (array) json_decode($prm["data"]);
|
||||
|
||||
// QUERY
|
||||
$sql = "UPDATE t_packet SET T_PacketName = ?, T_PacketIsNota = ? WHERE T_PacketID = ?";
|
||||
$query = $this->db_regional->query($sql, [$data['packet_name'], $data['packet_is_nota'], $data['packet_id']]);
|
||||
|
||||
if ($query) {
|
||||
$result = $data['packet_id'];
|
||||
|
||||
// UPDATE HELPER
|
||||
$sql = "sp_helper_nattests_create_packet(?)";
|
||||
$query = $this->db_regional->query($sql, [$result]);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("edit", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$json_test = $prm['json_px'];
|
||||
$packet_id = $prm['packet_id'];
|
||||
$packet_price = $prm['packet_price'];
|
||||
|
||||
// QUERY
|
||||
$sql = "CALL sp_master_packet_px_save_v2(?, ?, ?)";
|
||||
$query = $this->db_regional->query($sql, [$packet_id, $packet_price, $json_test])
|
||||
->row();
|
||||
|
||||
if ($query->status == 'OK') {
|
||||
$result = $query->data;
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Save Px : " . $query->message, $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_test()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 5000;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$mou = $prm['mou_id'];
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
$exclude = $prm['exclude'];
|
||||
$include = $prm['include'];
|
||||
|
||||
$q_exc = $exclude == "" ? "" : "and T_TestID NOT IN ({$exclude})";
|
||||
$q_inc = $include == "" ? "" : "or (T_TestID IN ({$include}))";
|
||||
|
||||
// Packet Type
|
||||
$pck = $this->db_regional->select('T_PacketType', false)
|
||||
->where('T_PacketID', $packet_id)
|
||||
->get('t_packet')->row();
|
||||
if ($pck->T_PacketType == 'PN')
|
||||
{
|
||||
$moud = $this->db_regional->select('M_MouID')
|
||||
->where('M_MouIsDefault', 'Y')
|
||||
->where('M_MouIsActive', 'Y')
|
||||
->limit(1)
|
||||
->get('m_mou')->row();
|
||||
$mou = $moud->M_MouID;
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(distinct t_testid) total
|
||||
from t_test
|
||||
join t_price on t_pricet_testid = t_testid
|
||||
and t_pricem_mouid = ? and t_priceisactive = 'Y'
|
||||
|
||||
JOIN (
|
||||
SELECT MAX(CONCAT(T_PriceT_TestID, '-', T_PricePriority)) m
|
||||
FROM t_price
|
||||
WHERE T_PriceIsActive = 'Y' AND T_PriceM_MouID = ? AND T_PriceIsCito = 'N'
|
||||
GROUP BY T_PriceT_TestID, T_PriceIsCito, T_PriceM_MouID
|
||||
ORDER BY t_pricet_testid
|
||||
) b ON t_pricet_testid = SUBSTRING_INDEX(m, '-', 1) AND t_pricepriority = SUBSTRING_INDEX(m, '-', -1)
|
||||
|
||||
left join t_packetdetail on t_packetdetailisactive = 'Y'
|
||||
and t_packetdetailt_packetid = ?
|
||||
and t_packetdetailt_testid = t_testid
|
||||
where T_TestIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
and (t_packetdetailid is null {$q_inc})
|
||||
{$q_exc}
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $packet, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_TestID, T_TestCode, T_TestName, T_PriceTotal, T_PriceAmount, T_TestNat_TestID,
|
||||
IFNULL(Helper_NatTestsJson, '[]') nat_tests
|
||||
from t_test
|
||||
join t_price on t_pricet_testid = t_testid
|
||||
and t_pricem_mouid = ? and t_priceisactive = 'Y'
|
||||
|
||||
JOIN (
|
||||
SELECT MAX(CONCAT(T_PriceT_TestID, '-', T_PricePriority)) m
|
||||
FROM t_price
|
||||
WHERE T_PriceIsActive = 'Y' AND T_PriceM_MouID = ? AND T_PriceIsCito = 'N'
|
||||
GROUP BY T_PriceT_TestID, T_PriceIsCito, T_PriceM_MouID
|
||||
ORDER BY t_pricet_testid
|
||||
) b ON t_pricet_testid = SUBSTRING_INDEX(m, '-', 1) AND t_pricepriority = SUBSTRING_INDEX(m, '-', -1)
|
||||
|
||||
left join t_packetdetail on t_packetdetailisactive = 'Y'
|
||||
and t_packetdetailt_packetid = ?
|
||||
and t_packetdetailt_testid = t_testid
|
||||
left join helper_nattests on helper_nattestst_testid = t_testid
|
||||
and helper_natteststype = 'PX'
|
||||
and helper_nattestsisactive = 'Y'
|
||||
where T_TestIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
and (t_packetdetailid is null {$q_inc})
|
||||
{$q_exc}
|
||||
order by T_TestName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['nat_tests'] = json_decode($v['nat_tests']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_mou_default()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
|
||||
|
||||
$sql = "select JSON_OBJECT('M_CompanyID', M_CompanyID, 'M_CompanyName', M_CompanyName) company,
|
||||
JSON_OBJECT('M_MouID', M_MouID, 'M_MouName', M_MouName) mou
|
||||
from m_mou
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID and M_CompanyIsDefault = 'Y'
|
||||
where M_MouIsDefault = 'Y'
|
||||
and M_MouIsActive = 'Y'
|
||||
limit 1";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->row();
|
||||
|
||||
$result = array("company" => json_decode($rows->company), "mou" => json_decode($rows->mou));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("MOU Default", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_copy() { return $this->packet_copy(); }
|
||||
public function packet_copy()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$source_id = $prm['source_id'];
|
||||
$target_id = $prm['target_id'];
|
||||
|
||||
// QUERY
|
||||
$sql = "CALL sp_master_packet_copy(?, ?)";
|
||||
$query = $this->db_regional->query($sql, [$source_id, $target_id])
|
||||
->row();
|
||||
|
||||
if ($query->status == 'OK') {
|
||||
$result = $query->data;
|
||||
$this->sys_ok(json_decode($result));
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet Copy : " . $query->message, $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
624
one-api/application/controllers/v1/masterdata/Packet_v3.php
Normal file
624
one-api/application/controllers/v1/masterdata/Packet_v3.php
Normal file
@@ -0,0 +1,624 @@
|
||||
<?php
|
||||
|
||||
class Packet_v3 extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Packet API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search_packet($pxs = false)
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 999999999;
|
||||
|
||||
$mou = $prm['mou'];
|
||||
$search = '%'. $prm['search'] . '%';
|
||||
$type = $prm['type'];
|
||||
|
||||
$qtype = ($type == null ? "<> ''" : "= '{$type}'");
|
||||
// QUERY TOTAL
|
||||
if ($pxs)
|
||||
{
|
||||
$sql = "select count(distinct T_PacketID) total
|
||||
from t_packet
|
||||
join t_packetdetail on t_packetdetailt_packetid = t_packetid
|
||||
and t_packetdetailisactive = 'Y'
|
||||
join t_test on t_packetdetailt_testid = t_testid
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketName ASC";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "select count(*) total
|
||||
from t_packet
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketName ASC";
|
||||
|
||||
}
|
||||
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $mou, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($pxs)
|
||||
{
|
||||
$sql = "select T_PacketID, T_PacketName, T_PacketType, T_PacketPrice, T_PacketOriginalPrice,
|
||||
T_PacketOriginalBruto,
|
||||
GROUP_CONCAT(T_TestName SEPARATOR ', ') pxs, T_PacketIsNota
|
||||
from t_packet
|
||||
|
||||
join t_packetdetail on t_packetdetailt_packetid = t_packetid
|
||||
and t_packetdetailisactive = 'Y'
|
||||
join t_test on t_packetdetailt_testid = t_testid
|
||||
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
group by T_PacketID
|
||||
order by T_PacketName ASC
|
||||
limit 0, {$max_rst}";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "select T_PacketID, T_PacketName, T_PacketType, T_PacketPrice, T_PacketOriginalPrice, T_PacketIsNota,
|
||||
T_PacketOriginalBruto
|
||||
from t_packet
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketName ASC
|
||||
limit 0, {$max_rst}";
|
||||
}
|
||||
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $mou, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query(), "type"=>$type);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = '%'.$prm['search'].'%';
|
||||
|
||||
$max_rst = 999999999;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(DISTINCT M_CompanyID) total
|
||||
from m_company
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName LIKE ?
|
||||
order by M_CompanyName ASC";
|
||||
$query = $this->db_regional->query($sql, [$search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_CompanyID, M_CompanyName,
|
||||
IFNULL( concat('[', group_concat( json_object('M_MouID', M_MouID, 'M_MouName', M_MouName, 'M_MouStartDate', M_MouStartDate, 'M_MouEndDate', M_MouEndDate, 'M_MouIsReleased', M_MouIsReleased, 'M_MouIsVerified', M_MouIsVerified) ), ']'), '[]') as mou
|
||||
from m_company
|
||||
left join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now())
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName LIKE ?
|
||||
group by m_companyid
|
||||
order by M_CompanyName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_mou()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 999999999;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$company = $prm["company_id"];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
order by M_MouName ASC";
|
||||
$query = $this->db_regional->query($sql, [$company, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_MouID, M_MouName, M_MouStartDate, M_MouEndDate
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
order by M_MouName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$company, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// public function search_packet()
|
||||
// {
|
||||
// $prm = $this->sys_input;
|
||||
// $max_rst = 999999999;
|
||||
|
||||
// $search = '%' . $prm["search"] . '%';
|
||||
// $mou = $prm["mou_id"];
|
||||
|
||||
// // QUERY TOTAL
|
||||
// $sql = "select count(*) total
|
||||
// from t_price
|
||||
// join t_test on t_pricet_testid = t_testid
|
||||
|
||||
// where T_PriceIsActive = 'Y'
|
||||
// and T_PriceM_MouID = ?
|
||||
// and T_TestName LIKE ?
|
||||
// order by T_TestName ASC";
|
||||
// $query = $this->db_regional->query($sql, [$mou, $search]);
|
||||
|
||||
// if ($query) {
|
||||
// $tot_count = $query->result_array()[0]["total"];
|
||||
// }
|
||||
// else {
|
||||
// $this->sys_error_db("price mou count", $this->db_regional);
|
||||
// exit;
|
||||
// }
|
||||
|
||||
// $sql = "select T_PriceID, T_TestID, T_TestCode, T_TestName, T_PriceIsCito,
|
||||
// T_PriceM_CompanyID,
|
||||
// T_PriceM_MouID,
|
||||
// T_PricePriority,
|
||||
// T_PriceAmount,
|
||||
// T_PriceDisc,
|
||||
// T_PriceDiscRp,
|
||||
// T_PriceSubTotal,
|
||||
// T_PriceOther,
|
||||
// T_PriceTotal,
|
||||
// JSON_OBJECT('T_TestID', T_TestID, 'T_TestCode', T_TestCode, 'T_TestName', T_TestName) px
|
||||
// from t_price
|
||||
// join t_test on t_pricet_testid = t_testid
|
||||
|
||||
// where T_PriceIsActive = 'Y'
|
||||
// and T_PriceM_MouID = ?
|
||||
// and T_TestName LIKE ?
|
||||
// order by T_TestName ASC
|
||||
// limit 0, {$max_rst}";
|
||||
// $query = $this->db_regional->query($sql, [$mou, $search]);
|
||||
|
||||
// if ($query)
|
||||
// {
|
||||
// $rows = $query->result_array();
|
||||
|
||||
// foreach ($rows as $k => $v)
|
||||
// {
|
||||
// $rows[$k]['px'] = json_decode($v['px']);
|
||||
|
||||
// $sql = "select t_addonid id, t_addonname name, t_priceaddonamount price
|
||||
// from t_priceaddon
|
||||
// join t_addon on t_priceaddont_addonid = t_addonid
|
||||
// where t_priceaddont_priceid = ?
|
||||
// and t_priceaddonisactive = 'Y'";
|
||||
|
||||
// $query = $this->db_regional->query($sql, [$v['T_PriceID']]);
|
||||
|
||||
// $rows2 = [];
|
||||
// if ($query)
|
||||
// {
|
||||
// $rows2 = $query->result_array();
|
||||
// }
|
||||
|
||||
// $rows[$k]['others'] = $rows2;
|
||||
// }
|
||||
|
||||
|
||||
// $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
// $this->sys_ok($result);
|
||||
// }
|
||||
// else {
|
||||
// $this->sys_error_db("price mou rows", $this->db_regional);
|
||||
// exit;
|
||||
// }
|
||||
// }
|
||||
|
||||
public function del_packet()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = "update t_packet
|
||||
set t_packetisactive = 'N'
|
||||
where T_PacketIsActive = 'Y'
|
||||
and T_PacketID = ?";
|
||||
$query = $this->db_regional->query($sql, [$id]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$sql = "update t_packetdetail
|
||||
set t_packetdetailisactive = 'N'
|
||||
where T_PacketdetailIsActive = 'Y'
|
||||
and t_packetdetailt_packetid = ?";
|
||||
$query = $this->db_regional->query($sql, [$id]);
|
||||
|
||||
$result = array("query"=>$this->db_regional->last_query(), "id"=>$id);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("packet delete rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 50;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_packetdetail
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
where T_PacketDetailIsActive = 'Y'
|
||||
and T_PacketDetailT_PacketID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_PacketDetailID, T_TestID, T_TestCode, T_TestName,
|
||||
T_PriceAmount, T_PacketDetailPrice, T_TestNat_TestID,
|
||||
IFNULL(Helper_NatTestsJson, '[]') nat_tests,
|
||||
T_PacketDetailPriceDisc, T_PacketDetailPriceDiscRp, T_PacketDetailPriceSubTotal ,
|
||||
T_PacketDetailPriceAmount,
|
||||
ifnull(T_PacketDetailPriceDisc,T_PriceDisc) T_PriceDisc, ifnull(T_PacketDetailPriceDiscRp,T_PriceDiscRp) T_PriceDiscRp,
|
||||
ifnull(T_PacketDetailPriceSubTotal,T_PriceSubTotal) T_PriceSubTotal, ifnull(T_PacketDetailPriceAmount,T_PriceAmount) T_PriceAmount,
|
||||
T_PacketDetailPrice T_PriceTotal
|
||||
from t_packetdetail
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
join t_packet on T_PacketDetailT_PacketID = T_PacketID
|
||||
join t_price on T_PacketM_MouID = T_PriceM_MouID AND T_PacketDetailT_TestID = T_PriceT_TestID AND T_PriceIsActive = 'Y' AND T_PriceIsCito = 'N'
|
||||
left join helper_nattests on helper_nattestst_testid = t_testid
|
||||
and helper_natteststype = 'PX'
|
||||
and helper_nattestsisactive = 'Y'
|
||||
where T_PacketDetailIsActive = 'Y'
|
||||
and T_PacketDetailT_PacketID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestSasCode ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['nat_tests'] = json_decode($v['nat_tests']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = (array) json_decode($prm["data"]);
|
||||
|
||||
// QUERY
|
||||
$sql = "INSERT INTO t_packet(T_PacketM_CompanyID,
|
||||
T_PacketM_MouID,
|
||||
T_PacketType,
|
||||
T_PacketName,
|
||||
T_PacketSequence,
|
||||
T_PacketSasCode,
|
||||
T_PacketIsNota)
|
||||
values(?, ?, ?, ?, '', '', ?)";
|
||||
$query = $this->db_regional->query($sql, [$data['packet_company'], $data['packet_mou'], $data['packet_type'], $data['packet_name'], $data['packet_is_nota']]);
|
||||
|
||||
if ($query) {
|
||||
|
||||
$result = $this->db_regional->insert_id();
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("addon new", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_edit()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = (array) json_decode($prm["data"]);
|
||||
|
||||
// QUERY
|
||||
$sql = "UPDATE t_packet SET T_PacketName = ?, T_PacketIsNota = ? WHERE T_PacketID = ?";
|
||||
$query = $this->db_regional->query($sql, [$data['packet_name'], $data['packet_is_nota'], $data['packet_id']]);
|
||||
|
||||
if ($query) {
|
||||
$result = $data['packet_id'];
|
||||
|
||||
// UPDATE HELPER
|
||||
$sql = "sp_helper_nattests_create_packet(?)";
|
||||
$query = $this->db_regional->query($sql, [$result]);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("edit", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$json_test = $prm['json_px'];
|
||||
$packet_id = $prm['packet_id'];
|
||||
$packet_price = $prm['packet_price'];
|
||||
|
||||
// QUERY
|
||||
$sql = "CALL sp_master_packet_px_save_v3(?, ?, ?)";
|
||||
$query = $this->db_regional->query($sql, [$packet_id, $packet_price, $json_test])
|
||||
->row();
|
||||
|
||||
if ($query->status == 'OK') {
|
||||
$result = $query->data;
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Save Px : " . $query->message, $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_test()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 5000;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$mou = $prm['mou_id'];
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
$exclude = $prm['exclude'];
|
||||
$include = $prm['include'];
|
||||
|
||||
$q_exc = $exclude == "" ? "" : "and T_TestID NOT IN ({$exclude})";
|
||||
$q_inc = $include == "" ? "" : "or (T_TestID IN ({$include}))";
|
||||
|
||||
// Packet Type
|
||||
$pck = $this->db_regional->select('T_PacketType', false)
|
||||
->where('T_PacketID', $packet_id)
|
||||
->get('t_packet')->row();
|
||||
if ($pck->T_PacketType == 'PN')
|
||||
{
|
||||
$moud = $this->db_regional->select('M_MouID')
|
||||
->where('M_MouIsDefault', 'Y')
|
||||
->where('M_MouIsActive', 'Y')
|
||||
->limit(1)
|
||||
->get('m_mou')->row();
|
||||
$mou = $moud->M_MouID;
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(distinct t_testid) total
|
||||
from t_test
|
||||
join t_price on t_pricet_testid = t_testid
|
||||
and t_pricem_mouid = ? and t_priceisactive = 'Y' AND T_PriceIsCito = 'N'
|
||||
|
||||
JOIN (
|
||||
SELECT MAX(CONCAT(T_PriceT_TestID, '-', T_PricePriority)) m
|
||||
FROM t_price
|
||||
WHERE T_PriceIsActive = 'Y' AND T_PriceM_MouID = ? AND T_PriceIsCito = 'N'
|
||||
GROUP BY T_PriceT_TestID, T_PriceIsCito, T_PriceM_MouID
|
||||
ORDER BY t_pricet_testid
|
||||
) b ON t_pricet_testid = SUBSTRING_INDEX(m, '-', 1) AND t_pricepriority = SUBSTRING_INDEX(m, '-', -1)
|
||||
|
||||
left join t_packetdetail on t_packetdetailisactive = 'Y'
|
||||
and t_packetdetailt_packetid = ?
|
||||
and t_packetdetailt_testid = t_testid
|
||||
where T_TestIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
and (t_packetdetailid is null {$q_inc})
|
||||
{$q_exc}
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $packet, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_TestID, T_TestCode, T_TestName, T_PriceTotal, T_PriceAmount, T_TestNat_TestID,
|
||||
T_PriceDisc, T_PriceDiscRp,T_PriceSubTotal,
|
||||
IFNULL(Helper_NatTestsJson, '[]') nat_tests
|
||||
from t_test
|
||||
join t_price on t_pricet_testid = t_testid
|
||||
and t_pricem_mouid = ? and t_priceisactive = 'Y' AND T_PriceIsCito = 'N'
|
||||
|
||||
JOIN (
|
||||
SELECT MAX(CONCAT(T_PriceT_TestID, '-', T_PricePriority)) m
|
||||
FROM t_price
|
||||
WHERE T_PriceIsActive = 'Y' AND T_PriceM_MouID = ? AND T_PriceIsCito = 'N'
|
||||
GROUP BY T_PriceT_TestID, T_PriceIsCito, T_PriceM_MouID
|
||||
ORDER BY t_pricet_testid
|
||||
) b ON t_pricet_testid = SUBSTRING_INDEX(m, '-', 1) AND t_pricepriority = SUBSTRING_INDEX(m, '-', -1)
|
||||
|
||||
left join t_packetdetail on t_packetdetailisactive = 'Y'
|
||||
and t_packetdetailt_packetid = ?
|
||||
and t_packetdetailt_testid = t_testid
|
||||
left join helper_nattests on helper_nattestst_testid = t_testid
|
||||
and helper_natteststype = 'PX'
|
||||
and helper_nattestsisactive = 'Y'
|
||||
where T_TestIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
and (t_packetdetailid is null {$q_inc})
|
||||
{$q_exc}
|
||||
order by T_TestName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['nat_tests'] = json_decode($v['nat_tests']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_mou_default()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
|
||||
|
||||
$sql = "select JSON_OBJECT('M_CompanyID', M_CompanyID, 'M_CompanyName', M_CompanyName) company,
|
||||
JSON_OBJECT('M_MouID', M_MouID, 'M_MouName', M_MouName) mou
|
||||
from m_mou
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID and M_CompanyIsDefault = 'Y'
|
||||
where M_MouIsDefault = 'Y'
|
||||
and M_MouIsActive = 'Y'
|
||||
limit 1";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->row();
|
||||
|
||||
$result = array("company" => json_decode($rows->company), "mou" => json_decode($rows->mou));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("MOU Default", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_copy() { return $this->packet_copy(); }
|
||||
public function packet_copy()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$source_id = $prm['source_id'];
|
||||
$target_id = $prm['target_id'];
|
||||
|
||||
// QUERY
|
||||
$sql = "CALL sp_master_packet_copy_v3(?, ?)";
|
||||
$query = $this->db_regional->query($sql, [$source_id, $target_id])
|
||||
->row();
|
||||
|
||||
if ($query->status == 'OK') {
|
||||
$result = $query->data;
|
||||
$this->sys_ok(json_decode($result));
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet Copy : " . $query->message, $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
639
one-api/application/controllers/v1/masterdata/Packet_v4.php
Normal file
639
one-api/application/controllers/v1/masterdata/Packet_v4.php
Normal file
@@ -0,0 +1,639 @@
|
||||
<?php
|
||||
|
||||
class Packet_v4 extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Packet API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
$this->db_regionallog = $this->load->database("regional_log", true);
|
||||
}
|
||||
|
||||
public function search_packet($pxs = false)
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$mou = $prm['mou'];
|
||||
$search = '%'. $prm['search'] . '%';
|
||||
$type = $prm['type'];
|
||||
|
||||
$qtype = ($type == null ? "<> ''" : "= '{$type}'");
|
||||
// QUERY TOTAL
|
||||
if ($pxs)
|
||||
{
|
||||
$sql = "select count(distinct T_PacketID) total
|
||||
from t_packet
|
||||
join t_packetdetail on t_packetdetailt_packetid = t_packetid
|
||||
and t_packetdetailisactive = 'Y'
|
||||
join t_test on t_packetdetailt_testid = t_testid
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketName ASC";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "select count(*) total
|
||||
from t_packet
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketName ASC";
|
||||
|
||||
}
|
||||
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $mou, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($pxs)
|
||||
{
|
||||
$sql = "select T_PacketID, T_PacketName, T_PacketType, T_PacketPrice, T_PacketOriginalPrice,
|
||||
T_PacketOriginalBruto,
|
||||
GROUP_CONCAT(T_TestName SEPARATOR ', ') pxs, T_PacketIsNota
|
||||
from t_packet
|
||||
|
||||
join t_packetdetail on t_packetdetailt_packetid = t_packetid
|
||||
and t_packetdetailisactive = 'Y'
|
||||
join t_test on t_packetdetailt_testid = t_testid
|
||||
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
group by T_PacketID
|
||||
order by T_PacketName ASC
|
||||
limit 0, {$max_rst}";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "select T_PacketID, T_PacketName, T_PacketType, T_PacketPrice, T_PacketOriginalPrice, T_PacketIsNota,
|
||||
T_PacketOriginalBruto
|
||||
from t_packet
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketName ASC
|
||||
limit 0, {$max_rst}";
|
||||
}
|
||||
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $mou, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query(), "type"=>$type);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = '%'.$prm['search'].'%';
|
||||
|
||||
$max_rst = 12;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(DISTINCT M_CompanyID) total
|
||||
from m_company
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName LIKE ?
|
||||
order by M_CompanyName ASC";
|
||||
$query = $this->db_regional->query($sql, [$search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_CompanyID, M_CompanyName,
|
||||
IFNULL( concat('[', group_concat( json_object('M_MouID', M_MouID, 'M_MouName', M_MouName, 'M_MouStartDate', M_MouStartDate, 'M_MouEndDate', M_MouEndDate, 'M_MouIsReleased', M_MouIsReleased, 'M_MouIsVerified', M_MouIsVerified) ), ']'), '[]') as mou
|
||||
from m_company
|
||||
left join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now())
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName LIKE ?
|
||||
group by m_companyid
|
||||
order by M_CompanyName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_mou()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$company = $prm["company_id"];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
order by M_MouName ASC";
|
||||
$query = $this->db_regional->query($sql, [$company, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_MouID, M_MouName, M_MouStartDate, M_MouEndDate
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
order by M_MouName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$company, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// public function search_packet()
|
||||
// {
|
||||
// $prm = $this->sys_input;
|
||||
// $max_rst = 12;
|
||||
|
||||
// $search = '%' . $prm["search"] . '%';
|
||||
// $mou = $prm["mou_id"];
|
||||
|
||||
// // QUERY TOTAL
|
||||
// $sql = "select count(*) total
|
||||
// from t_price
|
||||
// join t_test on t_pricet_testid = t_testid
|
||||
|
||||
// where T_PriceIsActive = 'Y'
|
||||
// and T_PriceM_MouID = ?
|
||||
// and T_TestName LIKE ?
|
||||
// order by T_TestName ASC";
|
||||
// $query = $this->db_regional->query($sql, [$mou, $search]);
|
||||
|
||||
// if ($query) {
|
||||
// $tot_count = $query->result_array()[0]["total"];
|
||||
// }
|
||||
// else {
|
||||
// $this->sys_error_db("price mou count", $this->db_regional);
|
||||
// exit;
|
||||
// }
|
||||
|
||||
// $sql = "select T_PriceID, T_TestID, T_TestCode, T_TestName, T_PriceIsCito,
|
||||
// T_PriceM_CompanyID,
|
||||
// T_PriceM_MouID,
|
||||
// T_PricePriority,
|
||||
// T_PriceAmount,
|
||||
// T_PriceDisc,
|
||||
// T_PriceDiscRp,
|
||||
// T_PriceSubTotal,
|
||||
// T_PriceOther,
|
||||
// T_PriceTotal,
|
||||
// JSON_OBJECT('T_TestID', T_TestID, 'T_TestCode', T_TestCode, 'T_TestName', T_TestName) px
|
||||
// from t_price
|
||||
// join t_test on t_pricet_testid = t_testid
|
||||
|
||||
// where T_PriceIsActive = 'Y'
|
||||
// and T_PriceM_MouID = ?
|
||||
// and T_TestName LIKE ?
|
||||
// order by T_TestName ASC
|
||||
// limit 0, {$max_rst}";
|
||||
// $query = $this->db_regional->query($sql, [$mou, $search]);
|
||||
|
||||
// if ($query)
|
||||
// {
|
||||
// $rows = $query->result_array();
|
||||
|
||||
// foreach ($rows as $k => $v)
|
||||
// {
|
||||
// $rows[$k]['px'] = json_decode($v['px']);
|
||||
|
||||
// $sql = "select t_addonid id, t_addonname name, t_priceaddonamount price
|
||||
// from t_priceaddon
|
||||
// join t_addon on t_priceaddont_addonid = t_addonid
|
||||
// where t_priceaddont_priceid = ?
|
||||
// and t_priceaddonisactive = 'Y'";
|
||||
|
||||
// $query = $this->db_regional->query($sql, [$v['T_PriceID']]);
|
||||
|
||||
// $rows2 = [];
|
||||
// if ($query)
|
||||
// {
|
||||
// $rows2 = $query->result_array();
|
||||
// }
|
||||
|
||||
// $rows[$k]['others'] = $rows2;
|
||||
// }
|
||||
|
||||
|
||||
// $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
// $this->sys_ok($result);
|
||||
// }
|
||||
// else {
|
||||
// $this->sys_error_db("price mou rows", $this->db_regional);
|
||||
// exit;
|
||||
// }
|
||||
// }
|
||||
|
||||
public function del_packet()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = "update t_packet
|
||||
set t_packetisactive = 'N'
|
||||
where T_PacketIsActive = 'Y'
|
||||
and T_PacketID = ?";
|
||||
$query = $this->db_regional->query($sql, [$id]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$sql = "update t_packetdetail
|
||||
set t_packetdetailisactive = 'N'
|
||||
where T_PacketdetailIsActive = 'Y'
|
||||
and t_packetdetailt_packetid = ?";
|
||||
$query = $this->db_regional->query($sql, [$id]);
|
||||
|
||||
$result = array("query"=>$this->db_regional->last_query(), "id"=>$id);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("packet delete rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 50;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_packetdetail
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
where T_PacketDetailIsActive = 'Y'
|
||||
and T_PacketDetailT_PacketID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_PacketDetailID, T_TestID, T_TestCode, T_TestName,
|
||||
T_PriceAmount, T_PacketDetailPrice, T_TestNat_TestID,
|
||||
IFNULL(Helper_NatTestsJson, '[]') nat_tests,
|
||||
T_PacketDetailPriceDisc, T_PacketDetailPriceDiscRp, T_PacketDetailPriceSubTotal ,
|
||||
T_PacketDetailPriceAmount,
|
||||
ifnull(T_PacketDetailPriceDisc,T_PriceDisc) T_PriceDisc, ifnull(T_PacketDetailPriceDiscRp,T_PriceDiscRp) T_PriceDiscRp,
|
||||
ifnull(T_PacketDetailPriceSubTotal,T_PriceSubTotal) T_PriceSubTotal, ifnull(T_PacketDetailPriceAmount,T_PriceAmount) T_PriceAmount,
|
||||
T_PacketDetailPrice T_PriceTotal
|
||||
from t_packetdetail
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
join t_packet on T_PacketDetailT_PacketID = T_PacketID
|
||||
join t_price on T_PacketM_MouID = T_PriceM_MouID AND T_PacketDetailT_TestID = T_PriceT_TestID AND T_PriceIsActive = 'Y' AND T_PriceIsCito = 'N'
|
||||
left join helper_nattests on helper_nattestst_testid = t_testid
|
||||
and helper_natteststype = 'PX'
|
||||
and helper_nattestsisactive = 'Y'
|
||||
where T_PacketDetailIsActive = 'Y'
|
||||
and T_PacketDetailT_PacketID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestSasCode ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['nat_tests'] = json_decode($v['nat_tests']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = (array) json_decode($prm["data"]);
|
||||
|
||||
// QUERY
|
||||
$sql = "INSERT INTO t_packet(T_PacketM_CompanyID,
|
||||
T_PacketM_MouID,
|
||||
T_PacketType,
|
||||
T_PacketName,
|
||||
T_PacketSequence,
|
||||
T_PacketSasCode,
|
||||
T_PacketIsNota)
|
||||
values(?, ?, ?, ?, '', '', ?)";
|
||||
$query = $this->db_regional->query($sql, [$data['packet_company'], $data['packet_mou'], $data['packet_type'], $data['packet_name'], $data['packet_is_nota']]);
|
||||
|
||||
if ($query) {
|
||||
|
||||
$result = $this->db_regional->insert_id();
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("addon new", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_edit()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = (array) json_decode($prm["data"]);
|
||||
|
||||
// QUERY
|
||||
$sql = "UPDATE t_packet SET T_PacketName = ?, T_PacketIsNota = ? WHERE T_PacketID = ?";
|
||||
$query = $this->db_regional->query($sql, [$data['packet_name'], $data['packet_is_nota'], $data['packet_id']]);
|
||||
|
||||
if ($query) {
|
||||
$result = $data['packet_id'];
|
||||
|
||||
// UPDATE HELPER
|
||||
$sql = "sp_helper_nattests_create_packet(?)";
|
||||
$query = $this->db_regional->query($sql, [$result]);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("edit", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$json_test = $prm['json_px'];
|
||||
$packet_id = $prm['packet_id'];
|
||||
$packet_price = $prm['packet_price'];
|
||||
|
||||
// QUERY
|
||||
$sql = "CALL sp_master_packet_px_save_v3(?, ?, ?)";
|
||||
|
||||
$query = $this->db_regional->query($sql, [$packet_id, $packet_price, $json_test])
|
||||
->row();
|
||||
if (!$query) {
|
||||
$this->sys_error_db( $this->db_regional->last_query());
|
||||
exit;
|
||||
}
|
||||
$querylog = $this->db_regionallog->query("insert into log_packet(Log_PacketCode,Log_PacketJson, Log_PacketUserID) values('ADD.EDIT.PACKET','{$json_test}','{$userID}')");
|
||||
if (!$querylog) {
|
||||
$this->sys_error_db( $this->db_regionallog->last_query());
|
||||
exit;
|
||||
}
|
||||
if ($query->status == 'OK') {
|
||||
$result = $query->data;
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Save Px : " . $query->message, $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_test()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 5000;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$mou = $prm['mou_id'];
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
$exclude = $prm['exclude'];
|
||||
$include = $prm['include'];
|
||||
|
||||
$q_exc = $exclude == "" ? "" : "and T_TestID NOT IN ({$exclude})";
|
||||
$q_inc = $include == "" ? "" : "or (T_TestID IN ({$include}))";
|
||||
|
||||
// Packet Type
|
||||
$pck = $this->db_regional->select('T_PacketType', false)
|
||||
->where('T_PacketID', $packet_id)
|
||||
->get('t_packet')->row();
|
||||
if ($pck->T_PacketType == 'PN')
|
||||
{
|
||||
$moud = $this->db_regional->select('M_MouID')
|
||||
->where('M_MouIsDefault', 'Y')
|
||||
->where('M_MouIsActive', 'Y')
|
||||
->limit(1)
|
||||
->get('m_mou')->row();
|
||||
$mou = $moud->M_MouID;
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(distinct t_testid) total
|
||||
from t_test
|
||||
join t_price on t_pricet_testid = t_testid
|
||||
and t_pricem_mouid = ? and t_priceisactive = 'Y'
|
||||
|
||||
JOIN (
|
||||
SELECT MAX(CONCAT(T_PriceT_TestID, '-', T_PricePriority)) m
|
||||
FROM t_price
|
||||
WHERE T_PriceIsActive = 'Y' AND T_PriceM_MouID = ? AND T_PriceIsCito = 'N'
|
||||
GROUP BY T_PriceT_TestID, T_PriceIsCito, T_PriceM_MouID
|
||||
ORDER BY t_pricet_testid
|
||||
) b ON t_pricet_testid = SUBSTRING_INDEX(m, '-', 1) AND t_pricepriority = SUBSTRING_INDEX(m, '-', -1)
|
||||
|
||||
left join t_packetdetail on t_packetdetailisactive = 'Y'
|
||||
and t_packetdetailt_packetid = ?
|
||||
and t_packetdetailt_testid = t_testid
|
||||
where T_TestIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
and (t_packetdetailid is null {$q_inc})
|
||||
{$q_exc}
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $packet, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_TestID, T_TestCode, T_TestName, T_PriceTotal, T_PriceAmount, T_TestNat_TestID,
|
||||
T_PriceDisc, T_PriceDiscRp,T_PriceSubTotal,
|
||||
IFNULL(Helper_NatTestsJson, '[]') nat_tests
|
||||
from t_test
|
||||
join t_price on t_pricet_testid = t_testid
|
||||
and t_pricem_mouid = ? and t_priceisactive = 'Y'
|
||||
|
||||
JOIN (
|
||||
SELECT MAX(CONCAT(T_PriceT_TestID, '-', T_PricePriority)) m
|
||||
FROM t_price
|
||||
WHERE T_PriceIsActive = 'Y' AND T_PriceM_MouID = ? AND T_PriceIsCito = 'N'
|
||||
GROUP BY T_PriceT_TestID, T_PriceIsCito, T_PriceM_MouID
|
||||
ORDER BY t_pricet_testid
|
||||
) b ON t_pricet_testid = SUBSTRING_INDEX(m, '-', 1) AND t_pricepriority = SUBSTRING_INDEX(m, '-', -1)
|
||||
|
||||
left join t_packetdetail on t_packetdetailisactive = 'Y'
|
||||
and t_packetdetailt_packetid = ?
|
||||
and t_packetdetailt_testid = t_testid
|
||||
left join helper_nattests on helper_nattestst_testid = t_testid
|
||||
and helper_natteststype = 'PX'
|
||||
and helper_nattestsisactive = 'Y'
|
||||
where T_TestIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
and (t_packetdetailid is null {$q_inc})
|
||||
{$q_exc}
|
||||
order by T_TestName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['nat_tests'] = json_decode($v['nat_tests']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_mou_default()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
|
||||
|
||||
$sql = "select JSON_OBJECT('M_CompanyID', M_CompanyID, 'M_CompanyName', M_CompanyName) company,
|
||||
JSON_OBJECT('M_MouID', M_MouID, 'M_MouName', M_MouName) mou
|
||||
from m_mou
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID and M_CompanyIsDefault = 'Y'
|
||||
where M_MouIsDefault = 'Y'
|
||||
and M_MouIsActive = 'Y'
|
||||
limit 1";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->row();
|
||||
|
||||
$result = array("company" => json_decode($rows->company), "mou" => json_decode($rows->mou));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("MOU Default", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_copy() { return $this->packet_copy(); }
|
||||
public function packet_copy()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$source_id = $prm['source_id'];
|
||||
$target_id = $prm['target_id'];
|
||||
|
||||
// QUERY
|
||||
$sql = "CALL sp_master_packet_copy_v3(?, ?)";
|
||||
$query = $this->db_regional->query($sql, [$source_id, $target_id])
|
||||
->row();
|
||||
$data = json_encode(array("sourcepacket_id" => $source_id, "packet_id" => $target_id ));
|
||||
$querylog = $this->db_regionallog->query("insert into log_packet(Log_PacketCode,Log_PacketJson, Log_PacketUserID) values('COPY.PACKET','{$data}','{$userID}')");
|
||||
if (!$querylog) {
|
||||
$this->sys_error_db( $this->db_regionallog->last_query());
|
||||
exit;
|
||||
}
|
||||
if ($query->status == 'OK') {
|
||||
$result = $query->data;
|
||||
$this->sys_ok(json_decode($result));
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet Copy : " . $query->message, $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
631
one-api/application/controllers/v1/masterdata/Packet_v5.php
Normal file
631
one-api/application/controllers/v1/masterdata/Packet_v5.php
Normal file
@@ -0,0 +1,631 @@
|
||||
<?php
|
||||
|
||||
class Packet_v5 extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Packet API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search_packet($pxs = false)
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 999999999;
|
||||
|
||||
$mou = $prm['mou'];
|
||||
$search = '%'. $prm['search'] . '%';
|
||||
$type = $prm['type'];
|
||||
|
||||
$queryverif = "SELECT IF(COUNT(*) > 0, 'Y','N') as exist FROM g_moustatuslog WHERE G_MouStatusLogStatus = 'V' AND G_MouStatusLogM_MouID = '{$mou}'";
|
||||
$rowverif = $this->db_regional->query($queryverif)->row()->exist;
|
||||
|
||||
$qtype = ($type == null ? "<> ''" : "= '{$type}'");
|
||||
// QUERY TOTAL
|
||||
if ($pxs)
|
||||
{
|
||||
$sql = "select count(distinct T_PacketID) total
|
||||
from t_packet
|
||||
join t_packetdetail on t_packetdetailt_packetid = t_packetid
|
||||
and t_packetdetailisactive = 'Y'
|
||||
join t_test on t_packetdetailt_testid = t_testid
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketID DESC";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "select count(*) total
|
||||
from t_packet
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketID DESC";
|
||||
|
||||
}
|
||||
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $mou, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($pxs)
|
||||
{
|
||||
$sql = "select T_PacketID, T_PacketName, T_PacketType, T_PacketPrice, T_PacketOriginalPrice,
|
||||
T_PacketOriginalBruto,
|
||||
GROUP_CONCAT(T_TestName SEPARATOR ', ') pxs, T_PacketIsNota,
|
||||
IF(Ss_PriceMouID IS NULL,'N','Y') as isverif
|
||||
from t_packet
|
||||
|
||||
join t_packetdetail on t_packetdetailt_packetid = t_packetid
|
||||
and t_packetdetailisactive = 'Y'
|
||||
join t_test on t_packetdetailt_testid = t_testid
|
||||
LEFT JOIN ss_price_mou ON Ss_PriceMouM_MouID = $mou AND is_packet = 'Y' AND T_TestID = T_PacketID
|
||||
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
group by T_PacketID
|
||||
order by T_PacketID DESC
|
||||
limit 0, {$max_rst}";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "select T_PacketID, T_PacketName, T_PacketType, T_PacketPrice, T_PacketOriginalPrice, T_PacketIsNota,
|
||||
T_PacketOriginalBruto,
|
||||
IF(Ss_PriceMouID IS NULL,'N','Y') as isverif
|
||||
from t_packet
|
||||
LEFT JOIN ss_price_mou ON Ss_PriceMouM_MouID = $mou AND is_packet = 'Y' AND T_TestID = T_PacketID
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
order by T_PacketID DESC
|
||||
limit 0, {$max_rst}";
|
||||
}
|
||||
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $mou, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count,"isverif" => $rowverif, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query(), "type"=>$type);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = '%'.$prm['search'].'%';
|
||||
|
||||
$max_rst = 999999999;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(DISTINCT M_CompanyID) total
|
||||
from m_company
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName LIKE ?
|
||||
order by M_CompanyName ASC";
|
||||
$query = $this->db_regional->query($sql, [$search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_CompanyID, M_CompanyName,
|
||||
IFNULL( concat('[', group_concat( json_object('M_MouID', M_MouID, 'M_MouName', M_MouName, 'M_MouStartDate', M_MouStartDate, 'M_MouEndDate', M_MouEndDate, 'M_MouIsReleased', M_MouIsReleased, 'M_MouIsVerified', M_MouIsVerified) ), ']'), '[]') as mou
|
||||
from m_company
|
||||
left join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y' AND M_MouIsOnline = 'N'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now())
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName LIKE ?
|
||||
group by m_companyid
|
||||
order by M_CompanyName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_mou()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 999999999;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$company = $prm["company_id"];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y' AND M_MouIsOnline = 'N'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
order by M_MouName ASC";
|
||||
$query = $this->db_regional->query($sql, [$company, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_MouID, M_MouName, M_MouStartDate, M_MouEndDate
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y' AND M_MouIsOnline = 'N'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
order by M_MouName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$company, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// public function search_packet()
|
||||
// {
|
||||
// $prm = $this->sys_input;
|
||||
// $max_rst = 999999999;
|
||||
|
||||
// $search = '%' . $prm["search"] . '%';
|
||||
// $mou = $prm["mou_id"];
|
||||
|
||||
// // QUERY TOTAL
|
||||
// $sql = "select count(*) total
|
||||
// from t_price
|
||||
// join t_test on t_pricet_testid = t_testid
|
||||
|
||||
// where T_PriceIsActive = 'Y'
|
||||
// and T_PriceM_MouID = ?
|
||||
// and T_TestName LIKE ?
|
||||
// order by T_TestName ASC";
|
||||
// $query = $this->db_regional->query($sql, [$mou, $search]);
|
||||
|
||||
// if ($query) {
|
||||
// $tot_count = $query->result_array()[0]["total"];
|
||||
// }
|
||||
// else {
|
||||
// $this->sys_error_db("price mou count", $this->db_regional);
|
||||
// exit;
|
||||
// }
|
||||
|
||||
// $sql = "select T_PriceID, T_TestID, T_TestCode, T_TestName, T_PriceIsCito,
|
||||
// T_PriceM_CompanyID,
|
||||
// T_PriceM_MouID,
|
||||
// T_PricePriority,
|
||||
// T_PriceAmount,
|
||||
// T_PriceDisc,
|
||||
// T_PriceDiscRp,
|
||||
// T_PriceSubTotal,
|
||||
// T_PriceOther,
|
||||
// T_PriceTotal,
|
||||
// JSON_OBJECT('T_TestID', T_TestID, 'T_TestCode', T_TestCode, 'T_TestName', T_TestName) px
|
||||
// from t_price
|
||||
// join t_test on t_pricet_testid = t_testid
|
||||
|
||||
// where T_PriceIsActive = 'Y'
|
||||
// and T_PriceM_MouID = ?
|
||||
// and T_TestName LIKE ?
|
||||
// order by T_TestName ASC
|
||||
// limit 0, {$max_rst}";
|
||||
// $query = $this->db_regional->query($sql, [$mou, $search]);
|
||||
|
||||
// if ($query)
|
||||
// {
|
||||
// $rows = $query->result_array();
|
||||
|
||||
// foreach ($rows as $k => $v)
|
||||
// {
|
||||
// $rows[$k]['px'] = json_decode($v['px']);
|
||||
|
||||
// $sql = "select t_addonid id, t_addonname name, t_priceaddonamount price
|
||||
// from t_priceaddon
|
||||
// join t_addon on t_priceaddont_addonid = t_addonid
|
||||
// where t_priceaddont_priceid = ?
|
||||
// and t_priceaddonisactive = 'Y'";
|
||||
|
||||
// $query = $this->db_regional->query($sql, [$v['T_PriceID']]);
|
||||
|
||||
// $rows2 = [];
|
||||
// if ($query)
|
||||
// {
|
||||
// $rows2 = $query->result_array();
|
||||
// }
|
||||
|
||||
// $rows[$k]['others'] = $rows2;
|
||||
// }
|
||||
|
||||
|
||||
// $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
// $this->sys_ok($result);
|
||||
// }
|
||||
// else {
|
||||
// $this->sys_error_db("price mou rows", $this->db_regional);
|
||||
// exit;
|
||||
// }
|
||||
// }
|
||||
|
||||
public function del_packet()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = "update t_packet
|
||||
set t_packetisactive = 'N'
|
||||
where T_PacketIsActive = 'Y'
|
||||
and T_PacketID = ?";
|
||||
$query = $this->db_regional->query($sql, [$id]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$sql = "update t_packetdetail
|
||||
set t_packetdetailisactive = 'N'
|
||||
where T_PacketdetailIsActive = 'Y'
|
||||
and t_packetdetailt_packetid = ?";
|
||||
$query = $this->db_regional->query($sql, [$id]);
|
||||
|
||||
$result = array("query"=>$this->db_regional->last_query(), "id"=>$id);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("packet delete rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 50;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_packetdetail
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
where T_PacketDetailIsActive = 'Y'
|
||||
and T_PacketDetailT_PacketID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_PacketDetailID, T_TestID,T_TestSasCode T_TestCode, T_TestName,
|
||||
T_PriceAmount, T_PacketDetailPrice, T_TestNat_TestID,
|
||||
IFNULL(Helper_NatTestsJson, '[]') nat_tests,
|
||||
T_PacketDetailPriceDisc, T_PacketDetailPriceDiscRp, T_PacketDetailPriceSubTotal ,
|
||||
T_PacketDetailPriceAmount,
|
||||
ifnull(T_PacketDetailPriceDisc,T_PriceDisc) T_PriceDisc, ifnull(T_PacketDetailPriceDiscRp,T_PriceDiscRp) T_PriceDiscRp,
|
||||
ifnull(T_PacketDetailPriceSubTotal,T_PriceSubTotal) T_PriceSubTotal, ifnull(T_PacketDetailPriceAmount,T_PriceAmount) T_PriceAmount,
|
||||
T_PacketDetailPrice T_PriceTotal
|
||||
from t_packetdetail
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
join t_packet on T_PacketDetailT_PacketID = T_PacketID
|
||||
join t_price on T_PacketM_MouID = T_PriceM_MouID AND T_PacketDetailT_TestID = T_PriceT_TestID AND T_PriceIsActive = 'Y' AND T_PriceIsCito = 'N'
|
||||
left join helper_nattests on helper_nattestst_testid = t_testid
|
||||
and helper_natteststype = 'PX'
|
||||
and helper_nattestsisactive = 'Y'
|
||||
where T_PacketDetailIsActive = 'Y'
|
||||
and T_PacketDetailT_PacketID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestSasCode ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['nat_tests'] = json_decode($v['nat_tests']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = (array) json_decode($prm["data"]);
|
||||
|
||||
// QUERY
|
||||
$sql = "INSERT INTO t_packet(T_PacketM_CompanyID,
|
||||
T_PacketM_MouID,
|
||||
T_PacketType,
|
||||
T_PacketName,
|
||||
T_PacketSequence,
|
||||
T_PacketSasCode,
|
||||
T_PacketIsNota)
|
||||
values(?, ?, ?, ?, '', '', ?)";
|
||||
$query = $this->db_regional->query($sql, [$data['packet_company'], $data['packet_mou'], $data['packet_type'], $data['packet_name'], $data['packet_is_nota']]);
|
||||
|
||||
if ($query) {
|
||||
|
||||
$result = $this->db_regional->insert_id();
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("addon new", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_edit()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = (array) json_decode($prm["data"]);
|
||||
|
||||
// QUERY
|
||||
$sql = "UPDATE t_packet SET T_PacketName = ?, T_PacketIsNota = ? WHERE T_PacketID = ?";
|
||||
$query = $this->db_regional->query($sql, [$data['packet_name'], $data['packet_is_nota'], $data['packet_id']]);
|
||||
|
||||
if ($query) {
|
||||
$result = $data['packet_id'];
|
||||
|
||||
// UPDATE HELPER
|
||||
$sql = "sp_helper_nattests_create_packet(?)";
|
||||
$query = $this->db_regional->query($sql, [$result]);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("edit", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$json_test = $prm['json_px'];
|
||||
$packet_id = $prm['packet_id'];
|
||||
$packet_price = $prm['packet_price'];
|
||||
|
||||
// QUERY
|
||||
$sql = "CALL sp_master_packet_px_save_v3(?, ?, ?)";
|
||||
$query = $this->db_regional->query($sql, [$packet_id, $packet_price, $json_test])
|
||||
->row();
|
||||
|
||||
if ($query->status == 'OK') {
|
||||
$result = $query->data;
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Save Px : " . $query->message, $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_test()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 5000;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$mou = $prm['mou_id'];
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
$exclude = $prm['exclude'];
|
||||
$include = $prm['include'];
|
||||
|
||||
$q_exc = $exclude == "" ? "" : "and T_TestID NOT IN ({$exclude})";
|
||||
$q_inc = $include == "" ? "" : "or (T_TestID IN ({$include}))";
|
||||
|
||||
// Packet Type
|
||||
$pck = $this->db_regional->select('T_PacketType', false)
|
||||
->where('T_PacketID', $packet_id)
|
||||
->get('t_packet')->row();
|
||||
if ($pck->T_PacketType == 'PN')
|
||||
{
|
||||
$moud = $this->db_regional->select('M_MouID')
|
||||
->where('M_MouIsDefault', 'Y')
|
||||
->where('M_MouIsActive', 'Y')
|
||||
->limit(1)
|
||||
->get('m_mou')->row();
|
||||
$mou = $moud->M_MouID;
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(distinct t_testid) total
|
||||
from t_test
|
||||
join t_price on t_pricet_testid = t_testid
|
||||
and t_pricem_mouid = ? and t_priceisactive = 'Y' AND T_PriceIsCito = 'N'
|
||||
|
||||
JOIN (
|
||||
SELECT MAX(CONCAT(T_PriceT_TestID, '-', T_PricePriority)) m
|
||||
FROM t_price
|
||||
WHERE T_PriceIsActive = 'Y' AND T_PriceM_MouID = ? AND T_PriceIsCito = 'N'
|
||||
GROUP BY T_PriceT_TestID, T_PriceIsCito, T_PriceM_MouID
|
||||
ORDER BY t_pricet_testid
|
||||
) b ON t_pricet_testid = SUBSTRING_INDEX(m, '-', 1) AND t_pricepriority = SUBSTRING_INDEX(m, '-', -1)
|
||||
|
||||
left join t_packetdetail on t_packetdetailisactive = 'Y'
|
||||
and t_packetdetailt_packetid = ?
|
||||
and t_packetdetailt_testid = t_testid
|
||||
where T_TestIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
and (t_packetdetailid is null {$q_inc})
|
||||
{$q_exc}
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $packet, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_TestID, T_TestCode, T_TestName, T_PriceTotal, T_PriceAmount, T_TestNat_TestID,
|
||||
T_PriceDisc, T_PriceDiscRp,T_PriceSubTotal,
|
||||
IFNULL(Helper_NatTestsJson, '[]') nat_tests
|
||||
from t_test
|
||||
join t_price on t_pricet_testid = t_testid
|
||||
and t_pricem_mouid = ? and t_priceisactive = 'Y' AND T_PriceIsCito = 'N'
|
||||
|
||||
JOIN (
|
||||
SELECT MAX(CONCAT(T_PriceT_TestID, '-', T_PricePriority)) m
|
||||
FROM t_price
|
||||
WHERE T_PriceIsActive = 'Y' AND T_PriceM_MouID = ? AND T_PriceIsCito = 'N'
|
||||
GROUP BY T_PriceT_TestID, T_PriceIsCito, T_PriceM_MouID
|
||||
ORDER BY t_pricet_testid
|
||||
) b ON t_pricet_testid = SUBSTRING_INDEX(m, '-', 1) AND t_pricepriority = SUBSTRING_INDEX(m, '-', -1)
|
||||
|
||||
left join t_packetdetail on t_packetdetailisactive = 'Y'
|
||||
and t_packetdetailt_packetid = ?
|
||||
and t_packetdetailt_testid = t_testid
|
||||
left join helper_nattests on helper_nattestst_testid = t_testid
|
||||
and helper_natteststype = 'PX'
|
||||
and helper_nattestsisactive = 'Y'
|
||||
where T_TestIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
and (t_packetdetailid is null {$q_inc})
|
||||
{$q_exc}
|
||||
order by T_TestName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['nat_tests'] = json_decode($v['nat_tests']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_mou_default()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
|
||||
|
||||
$sql = "select JSON_OBJECT('M_CompanyID', M_CompanyID, 'M_CompanyName', M_CompanyName) company,
|
||||
JSON_OBJECT('M_MouID', M_MouID, 'M_MouName', M_MouName) mou
|
||||
from m_mou
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID and M_CompanyIsDefault = 'Y'
|
||||
where M_MouIsDefault = 'Y'
|
||||
and M_MouIsActive = 'Y' AND M_MouIsOnline = 'N'
|
||||
limit 1";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->row();
|
||||
|
||||
$result = array("company" => json_decode($rows->company), "mou" => json_decode($rows->mou));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("MOU Default", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_copy() { return $this->packet_copy(); }
|
||||
public function packet_copy()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$source_id = $prm['source_id'];
|
||||
$target_id = $prm['target_id'];
|
||||
|
||||
// QUERY
|
||||
$sql = "CALL sp_master_packet_copy_v3(?, ?)";
|
||||
$query = $this->db_regional->query($sql, [$source_id, $target_id])
|
||||
->row();
|
||||
|
||||
if ($query->status == 'OK') {
|
||||
$result = $query->data;
|
||||
$this->sys_ok(json_decode($result));
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet Copy : " . $query->message, $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
634
one-api/application/controllers/v1/masterdata/Packet_v6.php
Normal file
634
one-api/application/controllers/v1/masterdata/Packet_v6.php
Normal file
@@ -0,0 +1,634 @@
|
||||
<?php
|
||||
|
||||
class Packet_v6 extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Packet API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function search_packet($pxs = false)
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 999999999;
|
||||
|
||||
$mou = $prm['mou'];
|
||||
$search = '%'. $prm['search'] . '%';
|
||||
$type = $prm['type'];
|
||||
$cito = $prm['iscito'];
|
||||
|
||||
$qtype = ($type == null ? "<> ''" : "= '{$type}'");
|
||||
$iscito = ($cito == null ? "<> ''" : "= '{$cito}'");
|
||||
// QUERY TOTAL
|
||||
if ($pxs)
|
||||
{
|
||||
$sql = "select count(distinct T_PacketID) total
|
||||
from t_packet
|
||||
join t_packetdetail on t_packetdetailt_packetid = t_packetid
|
||||
and t_packetdetailisactive = 'Y'
|
||||
join t_test on t_packetdetailt_testid = t_testid
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
and T_PacketIsCito {$iscito}
|
||||
order by T_PacketName ASC";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "select count(*) total
|
||||
from t_packet
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
and T_PacketIsCito {$iscito}
|
||||
order by T_PacketName ASC";
|
||||
|
||||
}
|
||||
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $mou, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($pxs)
|
||||
{
|
||||
$sql = "select T_PacketID, T_PacketName, T_PacketType, T_PacketPrice, T_PacketOriginalPrice,
|
||||
T_PacketOriginalBruto,
|
||||
GROUP_CONCAT(T_TestName SEPARATOR ', ') pxs, T_PacketIsNota, T_PacketIsCito, T_PacketOnlineDesc
|
||||
from t_packet
|
||||
|
||||
join t_packetdetail on t_packetdetailt_packetid = t_packetid
|
||||
and t_packetdetailisactive = 'Y'
|
||||
join t_test on t_packetdetailt_testid = t_testid
|
||||
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
and T_PacketIsCito {$iscito}
|
||||
group by T_PacketID
|
||||
order by T_PacketName ASC
|
||||
limit 0, {$max_rst}";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "select T_PacketID, T_PacketName, T_PacketType, T_PacketPrice, T_PacketOriginalPrice, T_PacketIsNota,
|
||||
T_PacketIsCito, T_PacketOriginalBruto, T_PacketOnlineDesc
|
||||
from t_packet
|
||||
where T_PacketIsActive = 'Y'
|
||||
and ((T_PacketM_MouID = ? AND ? <> 0) OR ? = 0)
|
||||
and T_PacketName LIKE ?
|
||||
and T_PacketType {$qtype}
|
||||
and T_PacketIsCito {$iscito}
|
||||
order by T_PacketName ASC
|
||||
limit 0, {$max_rst}";
|
||||
}
|
||||
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $mou, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query(), "type"=>$type);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = '%'.$prm['search'].'%';
|
||||
|
||||
$max_rst = 999999999;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(DISTINCT M_CompanyID) total
|
||||
from m_company
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName LIKE ?
|
||||
order by M_CompanyName ASC";
|
||||
$query = $this->db_regional->query($sql, [$search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_CompanyID, M_CompanyName,
|
||||
IFNULL( concat('[', group_concat( json_object('M_MouID', M_MouID, 'M_MouName', M_MouName, 'M_MouStartDate', M_MouStartDate, 'M_MouEndDate', M_MouEndDate, 'M_MouIsReleased', M_MouIsReleased, 'M_MouIsVerified', M_MouIsVerified) ), ']'), '[]') as mou
|
||||
from m_company
|
||||
left join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
-- AND M_MouIsReleased = 'Y'
|
||||
and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now())
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName LIKE ?
|
||||
group by m_companyid
|
||||
order by M_CompanyName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_mou()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 999999999;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$company = $prm["company_id"];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
order by M_MouName ASC";
|
||||
$query = $this->db_regional->query($sql, [$company, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_MouID, M_MouName, M_MouStartDate, M_MouEndDate
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
order by M_MouName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$company, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// public function search_packet()
|
||||
// {
|
||||
// $prm = $this->sys_input;
|
||||
// $max_rst = 999999999;
|
||||
|
||||
// $search = '%' . $prm["search"] . '%';
|
||||
// $mou = $prm["mou_id"];
|
||||
|
||||
// // QUERY TOTAL
|
||||
// $sql = "select count(*) total
|
||||
// from t_price
|
||||
// join t_test on t_pricet_testid = t_testid
|
||||
|
||||
// where T_PriceIsActive = 'Y'
|
||||
// and T_PriceM_MouID = ?
|
||||
// and T_TestName LIKE ?
|
||||
// order by T_TestName ASC";
|
||||
// $query = $this->db_regional->query($sql, [$mou, $search]);
|
||||
|
||||
// if ($query) {
|
||||
// $tot_count = $query->result_array()[0]["total"];
|
||||
// }
|
||||
// else {
|
||||
// $this->sys_error_db("price mou count", $this->db_regional);
|
||||
// exit;
|
||||
// }
|
||||
|
||||
// $sql = "select T_PriceID, T_TestID, T_TestCode, T_TestName, T_PriceIsCito,
|
||||
// T_PriceM_CompanyID,
|
||||
// T_PriceM_MouID,
|
||||
// T_PricePriority,
|
||||
// T_PriceAmount,
|
||||
// T_PriceDisc,
|
||||
// T_PriceDiscRp,
|
||||
// T_PriceSubTotal,
|
||||
// T_PriceOther,
|
||||
// T_PriceTotal,
|
||||
// JSON_OBJECT('T_TestID', T_TestID, 'T_TestCode', T_TestCode, 'T_TestName', T_TestName) px
|
||||
// from t_price
|
||||
// join t_test on t_pricet_testid = t_testid
|
||||
|
||||
// where T_PriceIsActive = 'Y'
|
||||
// and T_PriceM_MouID = ?
|
||||
// and T_TestName LIKE ?
|
||||
// order by T_TestName ASC
|
||||
// limit 0, {$max_rst}";
|
||||
// $query = $this->db_regional->query($sql, [$mou, $search]);
|
||||
|
||||
// if ($query)
|
||||
// {
|
||||
// $rows = $query->result_array();
|
||||
|
||||
// foreach ($rows as $k => $v)
|
||||
// {
|
||||
// $rows[$k]['px'] = json_decode($v['px']);
|
||||
|
||||
// $sql = "select t_addonid id, t_addonname name, t_priceaddonamount price
|
||||
// from t_priceaddon
|
||||
// join t_addon on t_priceaddont_addonid = t_addonid
|
||||
// where t_priceaddont_priceid = ?
|
||||
// and t_priceaddonisactive = 'Y'";
|
||||
|
||||
// $query = $this->db_regional->query($sql, [$v['T_PriceID']]);
|
||||
|
||||
// $rows2 = [];
|
||||
// if ($query)
|
||||
// {
|
||||
// $rows2 = $query->result_array();
|
||||
// }
|
||||
|
||||
// $rows[$k]['others'] = $rows2;
|
||||
// }
|
||||
|
||||
|
||||
// $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
// $this->sys_ok($result);
|
||||
// }
|
||||
// else {
|
||||
// $this->sys_error_db("price mou rows", $this->db_regional);
|
||||
// exit;
|
||||
// }
|
||||
// }
|
||||
|
||||
public function del_packet()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = "update t_packet
|
||||
set t_packetisactive = 'N'
|
||||
where T_PacketIsActive = 'Y'
|
||||
and T_PacketID = ?";
|
||||
$query = $this->db_regional->query($sql, [$id]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$sql = "update t_packetdetail
|
||||
set t_packetdetailisactive = 'N'
|
||||
where T_PacketdetailIsActive = 'Y'
|
||||
and t_packetdetailt_packetid = ?";
|
||||
$query = $this->db_regional->query($sql, [$id]);
|
||||
|
||||
$result = array("query"=>$this->db_regional->last_query(), "id"=>$id);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("packet delete rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 50;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_packetdetail
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
where T_PacketDetailIsActive = 'Y'
|
||||
and T_PacketDetailT_PacketID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_PacketDetailID, T_TestID, T_TestCode, T_TestName,
|
||||
T_PriceAmount, T_PacketDetailPrice, T_TestNat_TestID,
|
||||
IFNULL(Helper_NatTestsJson, '[]') nat_tests,
|
||||
T_PacketDetailPriceDisc, T_PacketDetailPriceDiscRp, T_PacketDetailPriceSubTotal ,
|
||||
T_PacketDetailPriceAmount,
|
||||
ifnull(T_PacketDetailPriceDisc,T_PriceDisc) T_PriceDisc, ifnull(T_PacketDetailPriceDiscRp,T_PriceDiscRp) T_PriceDiscRp,
|
||||
ifnull(T_PacketDetailPriceSubTotal,T_PriceSubTotal) T_PriceSubTotal, ifnull(T_PacketDetailPriceAmount,T_PriceAmount) T_PriceAmount,
|
||||
T_PacketDetailPrice T_PriceTotal
|
||||
from t_packetdetail
|
||||
join t_test on T_PacketDetailT_TestID = T_TestID
|
||||
join t_packet on T_PacketDetailT_PacketID = T_PacketID
|
||||
join t_price on T_PacketM_MouID = T_PriceM_MouID AND T_PacketDetailT_TestID = T_PriceT_TestID AND T_PriceIsActive = 'Y' AND T_PriceIsCito = 'N'
|
||||
left join helper_nattests on helper_nattestst_testid = t_testid
|
||||
and helper_natteststype = 'PX'
|
||||
and helper_nattestsisactive = 'Y'
|
||||
where T_PacketDetailIsActive = 'Y'
|
||||
and T_PacketDetailT_PacketID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestSasCode ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
//echo $this->db_regional->last_query();
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['nat_tests'] = json_decode($v['nat_tests']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = (array) json_decode($prm["data"]);
|
||||
|
||||
// QUERY
|
||||
$sql = "INSERT INTO t_packet(T_PacketM_CompanyID,
|
||||
T_PacketM_MouID,
|
||||
T_PacketType,
|
||||
T_PacketName,
|
||||
T_PacketOnlineDesc,
|
||||
T_PacketSequence,
|
||||
T_PacketSasCode,
|
||||
T_PacketIsNota,
|
||||
T_PacketIsCito)
|
||||
values(?, ?, ?, ?, ?, '', '', ?,?)";
|
||||
$query = $this->db_regional->query($sql, [$data['packet_company'], $data['packet_mou'], $data['packet_type'], $data['packet_name'], $data['packet_note'], $data['packet_is_nota'], $data['packet_is_cito']]);
|
||||
|
||||
if ($query) {
|
||||
|
||||
$result = $this->db_regional->insert_id();
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("addon new", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_edit()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = (array) json_decode($prm["data"]);
|
||||
|
||||
// QUERY
|
||||
$sql = "UPDATE t_packet SET T_PacketName = ?, T_PacketOnlineDesc = ?, T_PacketIsNota = ?, T_PacketIsCito = ? WHERE T_PacketID = ?";
|
||||
$query = $this->db_regional->query($sql, [$data['packet_name'],$data['packet_note'], $data['packet_is_nota'],$data['packet_is_cito'], $data['packet_id']]);
|
||||
|
||||
if ($query) {
|
||||
$result = $data['packet_id'];
|
||||
|
||||
// UPDATE HELPER
|
||||
$sql = "sp_helper_nattests_create_packet(?)";
|
||||
$query = $this->db_regional->query($sql, [$result]);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("edit", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$json_test = $prm['json_px'];
|
||||
$packet_id = $prm['packet_id'];
|
||||
$packet_price = $prm['packet_price'];
|
||||
|
||||
// QUERY
|
||||
$sql = "CALL sp_master_packet_px_save_v3(?, ?, ?)";
|
||||
$query = $this->db_regional->query($sql, [$packet_id, $packet_price, $json_test])
|
||||
->row();
|
||||
|
||||
if ($query->status == 'OK') {
|
||||
$result = $query->data;
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Save Px : " . $query->message, $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_test()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 5000;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$mou = $prm['mou_id'];
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
$exclude = $prm['exclude'];
|
||||
$include = $prm['include'];
|
||||
|
||||
$iscito = $prm['iscito'];
|
||||
|
||||
$q_exc = $exclude == "" ? "" : "and T_TestID NOT IN ({$exclude})";
|
||||
$q_inc = $include == "" ? "" : "or (T_TestID IN ({$include}))";
|
||||
|
||||
// Packet Type
|
||||
$pck = $this->db_regional->select('T_PacketType', false)
|
||||
->where('T_PacketID', $packet_id)
|
||||
->get('t_packet')->row();
|
||||
if ($pck->T_PacketType == 'PN')
|
||||
{
|
||||
$moud = $this->db_regional->select('M_MouID')
|
||||
->where('M_MouIsDefault', 'Y')
|
||||
->where('M_MouIsActive', 'Y')
|
||||
->limit(1)
|
||||
->get('m_mou')->row();
|
||||
$mou = $moud->M_MouID;
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(distinct t_testid) total
|
||||
from t_test
|
||||
join t_price on t_pricet_testid = t_testid
|
||||
and t_pricem_mouid = ? and t_priceisactive = 'Y' AND T_PriceIsCito = '{$iscito}'
|
||||
|
||||
JOIN (
|
||||
SELECT MAX(CONCAT(T_PriceT_TestID, '-', T_PricePriority)) m
|
||||
FROM t_price
|
||||
WHERE T_PriceIsActive = 'Y' AND T_PriceM_MouID = ? AND T_PriceIsCito = '{$iscito}'
|
||||
GROUP BY T_PriceT_TestID, T_PriceIsCito, T_PriceM_MouID
|
||||
ORDER BY t_pricet_testid
|
||||
) b ON t_pricet_testid = SUBSTRING_INDEX(m, '-', 1) AND t_pricepriority = SUBSTRING_INDEX(m, '-', -1)
|
||||
|
||||
left join t_packetdetail on t_packetdetailisactive = 'Y'
|
||||
and t_packetdetailt_packetid = ?
|
||||
and t_packetdetailt_testid = t_testid
|
||||
where T_TestIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
and (t_packetdetailid is null {$q_inc})
|
||||
{$q_exc}
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $packet, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px count", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_TestID, T_TestCode, T_TestName, T_PriceTotal, T_PriceAmount, T_TestNat_TestID,
|
||||
T_PriceDisc, T_PriceDiscRp,T_PriceSubTotal,
|
||||
IFNULL(Helper_NatTestsJson, '[]') nat_tests
|
||||
from t_test
|
||||
join t_price on t_pricet_testid = t_testid
|
||||
and t_pricem_mouid = ? and t_priceisactive = 'Y' AND T_PriceIsCito = '{$iscito}'
|
||||
|
||||
JOIN (
|
||||
SELECT MAX(CONCAT(T_PriceT_TestID, '-', T_PricePriority)) m
|
||||
FROM t_price
|
||||
WHERE T_PriceIsActive = 'Y' AND T_PriceM_MouID = ? AND T_PriceIsCito = '{$iscito}'
|
||||
GROUP BY T_PriceT_TestID, T_PriceIsCito, T_PriceM_MouID
|
||||
ORDER BY t_pricet_testid
|
||||
) b ON t_pricet_testid = SUBSTRING_INDEX(m, '-', 1) AND t_pricepriority = SUBSTRING_INDEX(m, '-', -1)
|
||||
|
||||
left join t_packetdetail on t_packetdetailisactive = 'Y'
|
||||
and t_packetdetailt_packetid = ?
|
||||
and t_packetdetailt_testid = t_testid
|
||||
left join helper_nattests on helper_nattestst_testid = t_testid
|
||||
and helper_natteststype = 'PX'
|
||||
and helper_nattestsisactive = 'Y'
|
||||
where T_TestIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
and (t_packetdetailid is null {$q_inc})
|
||||
{$q_exc}
|
||||
order by T_TestName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_regional->query($sql, [$mou, $mou, $packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['nat_tests'] = json_decode($v['nat_tests']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_regional->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px rows", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_mou_default()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$packet = $prm['packet_id'];
|
||||
|
||||
|
||||
|
||||
$sql = "select JSON_OBJECT('M_CompanyID', M_CompanyID, 'M_CompanyName', M_CompanyName) company,
|
||||
JSON_OBJECT('M_MouID', M_MouID, 'M_MouName', M_MouName) mou
|
||||
from m_mou
|
||||
join m_company on M_MouM_CompanyID = M_CompanyID and M_CompanyIsDefault = 'Y'
|
||||
where M_MouIsDefault = 'Y'
|
||||
and M_MouIsActive = 'Y'
|
||||
limit 1";
|
||||
$query = $this->db_regional->query($sql, [$packet, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->row();
|
||||
|
||||
$result = array("company" => json_decode($rows->company), "mou" => json_decode($rows->mou));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("MOU Default", $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_copy() { return $this->packet_copy(); }
|
||||
public function packet_copy()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$source_id = $prm['source_id'];
|
||||
$target_id = $prm['target_id'];
|
||||
|
||||
// QUERY
|
||||
$sql = "CALL sp_master_packet_copy_v3(?, ?)";
|
||||
$query = $this->db_regional->query($sql, [$source_id, $target_id])
|
||||
->row();
|
||||
|
||||
if ($query->status == 'OK') {
|
||||
$result = $query->data;
|
||||
$this->sys_ok(json_decode($result));
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Packet Copy : " . $query->message, $this->db_regional);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user