Initial import
This commit is contained in:
457
one-api/application/controllers/mockup/regonline/Carousel.php
Normal file
457
one-api/application/controllers/mockup/regonline/Carousel.php
Normal file
@@ -0,0 +1,457 @@
|
||||
<?php
|
||||
class Carousel extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_param = array();
|
||||
|
||||
|
||||
$limit = '';
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
|
||||
|
||||
$sql = "SELECT m_carousel.*, CONCAT('/one-media/one-regonline/',M_CarouselImageUrl) as xurl
|
||||
FROM m_carousel
|
||||
WHERE
|
||||
M_CarouselIsActive = 'Y'
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => 1, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function uploadimage(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$data = [];
|
||||
$errors = [];
|
||||
//print_r($_SERVER);
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//$config['upload_path'] = 'assets/';
|
||||
|
||||
$path = '/home/one/project/one/one-media/one-regonline/';
|
||||
//echo $path;
|
||||
$config['upload_path'] = $path;
|
||||
$config['allowed_types'] = 'jpg|jpeg|png';
|
||||
|
||||
$config['max_size'] = '300';
|
||||
$count = count($_FILES['files']['name']);
|
||||
//echo $count;
|
||||
$this->load->library('upload',$config);
|
||||
|
||||
$error = [];
|
||||
for($i=0;$i<$count;$i++){
|
||||
|
||||
|
||||
if(!empty($_FILES['files']['name'][$i])){
|
||||
|
||||
|
||||
|
||||
$_FILES['file']['name'] = $_FILES['files']['name'][$i];
|
||||
|
||||
$_FILES['file']['type'] = $_FILES['files']['type'][$i];
|
||||
|
||||
$_FILES['file']['tmp_name'] = $_FILES['files']['tmp_name'][$i];
|
||||
|
||||
$_FILES['file']['error'] = $_FILES['files']['error'][$i];
|
||||
|
||||
$_FILES['file']['size'] = $_FILES['files']['size'][$i];
|
||||
|
||||
|
||||
$sql = "SELECT * FROM m_branch WHERE M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y' LIMIT 1";
|
||||
$data_branch = $this->db_onedev->query($sql)->row_array();
|
||||
$namex = 'carousel-'.$data_branch['M_BranchCode'].'-'.date("ymdHis").'-'.$this->generateRandomString(5);
|
||||
//echo $namex;
|
||||
|
||||
$config['file_name'] = $namex;
|
||||
$this->upload->initialize($config);
|
||||
//echo $config['file_name'] ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if($this->upload->do_upload('file')){
|
||||
|
||||
$uploadData = $this->upload->data();
|
||||
|
||||
$filename = $uploadData['file_name'];
|
||||
//echo $filename;
|
||||
|
||||
$sql = "INSERT INTO m_carousel (
|
||||
M_CarouselM_BranchID,
|
||||
M_CarouselImageUrl,
|
||||
M_CarouselUserID,
|
||||
M_CarouselCreated
|
||||
)
|
||||
VALUES(
|
||||
{$data_branch['M_BranchID']},
|
||||
'{$filename}',
|
||||
{$userid},
|
||||
NOW()
|
||||
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
$xlast_id = $this->db_onedev->insert_id();
|
||||
$data['totalFiles'][] = array('name' => $_FILES['files']['name'][$i] ,'image_url' => '/one-media/one-image-nonlab/'.$filename);
|
||||
|
||||
}
|
||||
else{
|
||||
$error = array('image'=>$_FILES['files']['name'][$i],'error' => $this->upload->display_errors());
|
||||
$errors[] = $error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$result = array("total" =>count( $data['totalFiles']), "records" => $data['totalFiles'],'errors'=>$errors);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
function generateRandomString($length = 10) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE m_carousel SET
|
||||
M_CarouselOrder = '{$prm['M_CarouselOrder']}',
|
||||
M_CarouselStatus = '{$prm['M_CarouselStatus']}',
|
||||
M_CarouselLastUpdated = NOW(),
|
||||
M_CarouselUserID = '{$userid}'
|
||||
WHERE
|
||||
M_CarouselID = '{$prm['M_CarouselID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function newpatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
||||
$prm['M_PatientName'] = str_replace("'", "\\'", $prm['M_PatientName']);
|
||||
$query ="INSERT INTO m_patient (
|
||||
M_PatientM_TitleID,
|
||||
M_PatientPrefix,
|
||||
M_PatientName,
|
||||
M_PatientSuffix,
|
||||
M_PatientDOB,
|
||||
M_PatientM_SexID,
|
||||
M_PatientM_ReligionID,
|
||||
M_PatientEmail,
|
||||
M_PatientPOB,
|
||||
M_PatientHP,
|
||||
M_PatientPhone,
|
||||
M_PatientM_IdTypeID,
|
||||
M_PatientIDNumber,
|
||||
M_PatientNote,
|
||||
M_PatientNIK,
|
||||
M_PatientJabatan,
|
||||
M_PatientKedudukan,
|
||||
M_PatientPJ,
|
||||
M_PatientLocation,
|
||||
M_PatientJob,
|
||||
M_PatientUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_PatientM_TitleID']}',
|
||||
'{$prm['M_PatientPrefix']}',
|
||||
'{$prm['M_PatientName']}',
|
||||
'{$prm['M_PatientSuffix']}',
|
||||
'{$pdob}',
|
||||
'{$prm['M_PatientM_SexID']}',
|
||||
'{$prm['M_PatientM_ReligionID']}',
|
||||
'{$prm['M_PatientEmail']}',
|
||||
'{$prm['M_PatientPOB']}',
|
||||
'{$prm['M_PatientHP']}',
|
||||
'{$prm['M_PatientPhone']}',
|
||||
'{$prm['M_PatientM_IdTypeID']}',
|
||||
'{$prm['M_PatientIDNumber']}',
|
||||
'{$prm['M_PatientNote']}',
|
||||
'{$prm['M_PatientNIK']}',
|
||||
'{$prm['M_PatientJabatan']}',
|
||||
'{$prm['M_PatientKedudukan']}',
|
||||
'{$prm['M_PatientPJ']}',
|
||||
'{$prm['M_PatientLocation']}',
|
||||
'{$prm['M_PatientJob']}',
|
||||
$userid
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_PatientID"] = $last_id;
|
||||
$ptn["M_PatientDOB"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADD', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletepatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE m_carousel SET
|
||||
M_CarouselIsActive = 'N',
|
||||
M_CarouselLastUpdated = NOW(),
|
||||
M_CarouselUserID = {$userid}
|
||||
WHERE
|
||||
M_CarouselID = '{$prm['M_CarouselID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.DELETE', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_patientaddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,
|
||||
'' as action
|
||||
FROM m_patientaddress
|
||||
JOIN m_kelurahan ON M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
WHERE
|
||||
M_PatientAddressIsActive = 'Y' AND M_PatientAddressM_PatientID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['M_PatientAddressDescription'] = stripslashes($v['M_PatientAddressDescription']);
|
||||
$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_onedev->query("SELECT COUNT(*) as countx FROM m_patientaddress WHERE M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}' AND M_PatientAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_PatientAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_patientaddress WHERE M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}' AND M_PatientAddressNote = 'Utama' AND M_PatientAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_PatientAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_PatientAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$prm['M_PatientAddressDescription'] = str_replace("'", "\\'", $prm['M_PatientAddressDescription']);
|
||||
$query ="INSERT INTO m_patientaddress (
|
||||
M_PatientAddressM_PatientID,
|
||||
M_PatientAddressNote,
|
||||
M_PatientAddressDescription,
|
||||
M_PatientAddressM_KelurahanID,
|
||||
M_PatientAddressCreated,
|
||||
M_PatientAddressUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_PatientAddressM_PatientID']}',
|
||||
'{$prm['M_PatientAddressNote']}',
|
||||
'{$prm['M_PatientAddressDescription']}',
|
||||
'{$prm['M_PatientAddressM_KelurahanID']}',
|
||||
NOW(),
|
||||
'{$userid}'
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_UserID"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_ADD', '{$ptn}', $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;
|
||||
$prm['M_PatientAddressDescription'] = str_replace("'", "\\'", $prm['M_PatientAddressDescription']);
|
||||
$sql = "SELECT * FROM m_patientaddress WHERE M_PatientAddressID = {$prm['M_PatientAddressID']}";
|
||||
$rows_before = $this->db_onedev->query($sql)->row_array();
|
||||
$query ="UPDATE m_patientaddress SET
|
||||
M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}',
|
||||
M_PatientAddressNote = '{$prm['M_PatientAddressNote']}',
|
||||
M_PatientAddressDescription = '{$prm['M_PatientAddressDescription']}',
|
||||
M_PatientAddressM_KelurahanID = '{$prm['M_PatientAddressM_KelurahanID']}',
|
||||
M_PatientAddressUserID = {$userid}
|
||||
WHERE
|
||||
M_PatientAddressID = '{$prm['M_PatientAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_UserID"] = $pdob;
|
||||
$xbefore = json_encode($rows_before);
|
||||
$ptn = json_encode($ptn);
|
||||
/*$this->db_onedev->query("INSERT INTO one_log.log_patient (
|
||||
Log_PatientCode,
|
||||
Log_PatientJson,
|
||||
Log_PatientJsonBefore,
|
||||
Log_PatientUserID
|
||||
)
|
||||
VALUES(
|
||||
'PATIENT.ADDR_EDIT',
|
||||
'{$ptn}',
|
||||
'{$xbefore}',
|
||||
'{$userid}'
|
||||
)");*/
|
||||
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_EDIT', '{$ptn}', $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_patientaddress SET
|
||||
M_PatientAddressIsActive = 'N',
|
||||
M_PatientAddressUserID = {$userid}
|
||||
WHERE
|
||||
M_PatientAddressID = '{$prm['M_PatientAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_UserID"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_DELETE', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,488 @@
|
||||
<?php
|
||||
class Categorypacket extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient 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;
|
||||
}
|
||||
|
||||
$sql_param = array();
|
||||
|
||||
|
||||
$limit = '';
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
|
||||
|
||||
$sql = "SELECT m_packetcategory.*, CONCAT('/one-media/one-regonline/',M_PacketCategoryImageUrl) as xurl
|
||||
FROM m_packetcategory
|
||||
WHERE
|
||||
M_PacketCategoryIsActive = 'Y'
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => 1, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function uploadimage($xid,$files){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$_FILES['files'] = $files;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$data = [];
|
||||
$errors = [];
|
||||
//print_r($_SERVER);
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//$config['upload_path'] = 'assets/';
|
||||
|
||||
$path = '/home/regional/project/regional/one-media/one-regonline/';
|
||||
//echo $path;
|
||||
$config['upload_path'] = $path;
|
||||
$config['allowed_types'] = 'jpg|jpeg|png';
|
||||
|
||||
$config['max_size'] = '300';
|
||||
$count = count($_FILES['files']['name']);
|
||||
//echo $count;
|
||||
$this->load->library('upload',$config);
|
||||
|
||||
$error = [];
|
||||
for($i=0;$i<$count;$i++){
|
||||
|
||||
//echo $_FILES['files']['name'][$i];
|
||||
if(!empty($_FILES['files']['name'][$i])){
|
||||
|
||||
|
||||
|
||||
$_FILES['file']['name'] = $_FILES['files']['name'][$i];
|
||||
|
||||
$_FILES['file']['type'] = $_FILES['files']['type'][$i];
|
||||
|
||||
$_FILES['file']['tmp_name'] = $_FILES['files']['tmp_name'][$i];
|
||||
|
||||
$_FILES['file']['error'] = $_FILES['files']['error'][$i];
|
||||
|
||||
$_FILES['file']['size'] = $_FILES['files']['size'][$i];
|
||||
|
||||
|
||||
|
||||
$namex = 'catpacket-'.date("ymdHis").'-'.$this->generateRandomString(5);
|
||||
//echo $namex;
|
||||
|
||||
$config['file_name'] = $namex;
|
||||
$this->upload->initialize($config);
|
||||
//echo $config['file_name'] ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if($this->upload->do_upload('file')){
|
||||
|
||||
$uploadData = $this->upload->data();
|
||||
|
||||
$filename = $uploadData['file_name'];
|
||||
//echo $filename;
|
||||
|
||||
|
||||
$sql = "UPDATE m_packetcategory SET M_PacketCategoryImageUrl = '{$filename}' WHERE M_PacketCategoryID = {$xid}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
|
||||
|
||||
|
||||
$data['totalFiles'][] = array('name' => $_FILES['files']['name'][$i] ,'image_url' => '/one-media/one-regonline/'.$filename);
|
||||
|
||||
}
|
||||
else{
|
||||
$error = array('image'=>$_FILES['files']['name'][$i],'error' => $this->upload->display_errors());
|
||||
$errors[] = $error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$result = array("total" =>count( $data['totalFiles']), "records" => $data['totalFiles'],'errors'=>$errors);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function generateRandomString($length = 10) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "SELECT * FROM s_regional WHERE S_RegionalIsDefault = 'Y' LIMIT 1";
|
||||
$data_regional = $this->db_onedev->query($sql)->row_array();
|
||||
$xid = $prm['xid'];
|
||||
if(intval($prm['xid']) === 0){
|
||||
$query ="INSERT INTO m_packetcategory (
|
||||
M_PacketCategoryS_RegionalID,
|
||||
M_PacketCategoryName,
|
||||
M_PacketCategoryDescription,
|
||||
M_PacketCategoryOrder,
|
||||
M_PacketCategoryCreated,
|
||||
M_PacketCategoryUserID
|
||||
)VALUES(
|
||||
{$data_regional['S_RegionalID']},
|
||||
'{$prm['xname']}',
|
||||
'{$prm['xdescription']}',
|
||||
'{$prm['xorder']}',
|
||||
NOW(),
|
||||
$userid
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$xid = $this->db_onedev->insert_id();
|
||||
}else{
|
||||
$query ="UPDATE m_packetcategory SET
|
||||
M_PacketCategoryName = '{$prm['xname']}',
|
||||
M_PacketCategoryDescription = '{$prm['xdescription']}',
|
||||
M_PacketCategoryOrder = '{$prm['xorder']}',
|
||||
M_PacketCategoryLastUpdated = NOW(),
|
||||
M_PacketCategoryUserID = '{$userid}'
|
||||
WHERE
|
||||
M_PacketCategoryID = '{$prm['xid']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//echo count($_FILES['files']);
|
||||
if($_FILES['files']){
|
||||
// echo 'dasdas';
|
||||
$result = $this->uploadimage($xid,$_FILES['files']);
|
||||
}
|
||||
else{
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"errors" => array()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function newpatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
||||
$prm['M_PatientName'] = str_replace("'", "\\'", $prm['M_PatientName']);
|
||||
$query ="INSERT INTO m_patient (
|
||||
M_PatientM_TitleID,
|
||||
M_PatientPrefix,
|
||||
M_PatientName,
|
||||
M_PatientSuffix,
|
||||
M_PatientDOB,
|
||||
M_PatientM_SexID,
|
||||
M_PatientM_ReligionID,
|
||||
M_PatientEmail,
|
||||
M_PatientPOB,
|
||||
M_PatientHP,
|
||||
M_PatientPhone,
|
||||
M_PatientM_IdTypeID,
|
||||
M_PatientIDNumber,
|
||||
M_PatientNote,
|
||||
M_PatientNIK,
|
||||
M_PatientJabatan,
|
||||
M_PatientKedudukan,
|
||||
M_PatientPJ,
|
||||
M_PatientLocation,
|
||||
M_PatientJob,
|
||||
M_PatientUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_PatientM_TitleID']}',
|
||||
'{$prm['M_PatientPrefix']}',
|
||||
'{$prm['M_PatientName']}',
|
||||
'{$prm['M_PatientSuffix']}',
|
||||
'{$pdob}',
|
||||
'{$prm['M_PatientM_SexID']}',
|
||||
'{$prm['M_PatientM_ReligionID']}',
|
||||
'{$prm['M_PatientEmail']}',
|
||||
'{$prm['M_PatientPOB']}',
|
||||
'{$prm['M_PatientHP']}',
|
||||
'{$prm['M_PatientPhone']}',
|
||||
'{$prm['M_PatientM_IdTypeID']}',
|
||||
'{$prm['M_PatientIDNumber']}',
|
||||
'{$prm['M_PatientNote']}',
|
||||
'{$prm['M_PatientNIK']}',
|
||||
'{$prm['M_PatientJabatan']}',
|
||||
'{$prm['M_PatientKedudukan']}',
|
||||
'{$prm['M_PatientPJ']}',
|
||||
'{$prm['M_PatientLocation']}',
|
||||
'{$prm['M_PatientJob']}',
|
||||
$userid
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_PatientID"] = $last_id;
|
||||
$ptn["M_PatientDOB"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADD', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletepatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE m_packetcategory SET
|
||||
M_PacketCategoryIsActive = 'N',
|
||||
M_PacketCategoryLastUpdated = NOW(),
|
||||
M_PacketCategoryUserID = {$userid}
|
||||
WHERE
|
||||
M_PacketCategoryID = '{$prm['M_PacketCategoryID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.DELETE', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_patientaddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,
|
||||
'' as action
|
||||
FROM m_patientaddress
|
||||
JOIN m_kelurahan ON M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
WHERE
|
||||
M_PatientAddressIsActive = 'Y' AND M_PatientAddressM_PatientID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['M_PatientAddressDescription'] = stripslashes($v['M_PatientAddressDescription']);
|
||||
$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_onedev->query("SELECT COUNT(*) as countx FROM m_patientaddress WHERE M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}' AND M_PatientAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_PatientAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_patientaddress WHERE M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}' AND M_PatientAddressNote = 'Utama' AND M_PatientAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_PatientAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_PatientAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$prm['M_PatientAddressDescription'] = str_replace("'", "\\'", $prm['M_PatientAddressDescription']);
|
||||
$query ="INSERT INTO m_patientaddress (
|
||||
M_PatientAddressM_PatientID,
|
||||
M_PatientAddressNote,
|
||||
M_PatientAddressDescription,
|
||||
M_PatientAddressM_KelurahanID,
|
||||
M_PatientAddressCreated,
|
||||
M_PatientAddressUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_PatientAddressM_PatientID']}',
|
||||
'{$prm['M_PatientAddressNote']}',
|
||||
'{$prm['M_PatientAddressDescription']}',
|
||||
'{$prm['M_PatientAddressM_KelurahanID']}',
|
||||
NOW(),
|
||||
'{$userid}'
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_UserID"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_ADD', '{$ptn}', $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;
|
||||
$prm['M_PatientAddressDescription'] = str_replace("'", "\\'", $prm['M_PatientAddressDescription']);
|
||||
$sql = "SELECT * FROM m_patientaddress WHERE M_PatientAddressID = {$prm['M_PatientAddressID']}";
|
||||
$rows_before = $this->db_onedev->query($sql)->row_array();
|
||||
$query ="UPDATE m_patientaddress SET
|
||||
M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}',
|
||||
M_PatientAddressNote = '{$prm['M_PatientAddressNote']}',
|
||||
M_PatientAddressDescription = '{$prm['M_PatientAddressDescription']}',
|
||||
M_PatientAddressM_KelurahanID = '{$prm['M_PatientAddressM_KelurahanID']}',
|
||||
M_PatientAddressUserID = {$userid}
|
||||
WHERE
|
||||
M_PatientAddressID = '{$prm['M_PatientAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_UserID"] = $pdob;
|
||||
$xbefore = json_encode($rows_before);
|
||||
$ptn = json_encode($ptn);
|
||||
/*$this->db_onedev->query("INSERT INTO one_log.log_patient (
|
||||
Log_PatientCode,
|
||||
Log_PatientJson,
|
||||
Log_PatientJsonBefore,
|
||||
Log_PatientUserID
|
||||
)
|
||||
VALUES(
|
||||
'PATIENT.ADDR_EDIT',
|
||||
'{$ptn}',
|
||||
'{$xbefore}',
|
||||
'{$userid}'
|
||||
)");*/
|
||||
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_EDIT', '{$ptn}', $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_patientaddress SET
|
||||
M_PatientAddressIsActive = 'N',
|
||||
M_PatientAddressUserID = {$userid}
|
||||
WHERE
|
||||
M_PatientAddressID = '{$prm['M_PatientAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_UserID"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_DELETE', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,576 @@
|
||||
<?php
|
||||
class Categorypacketmap extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient 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;
|
||||
}
|
||||
|
||||
$sql_param = array();
|
||||
$mouid = $prm['mouid'];
|
||||
|
||||
$limit = '';
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
|
||||
|
||||
$sql = "SELECT m_packetcategory.*, CONCAT('/one-media/one-regonline/',M_PacketCategoryImageUrl) as xurl,
|
||||
IF(ISNULL(M_PacketCategoryMouID),'N','Y') as xstatus, '' as details
|
||||
FROM m_packetcategory
|
||||
LEFT JOIN m_packetcategorymou ON M_PacketCategoryMouM_PacketCategoryID = M_PacketCategoryID AND
|
||||
M_PacketCategoryMouIsActive = 'Y' AND M_PacketCategoryMouM_MouID = {$mouid}
|
||||
WHERE
|
||||
M_PacketCategoryIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key]['details'] = array();
|
||||
$sql = "SELECT M_PacketCategoryDetailID as trx_id,T_PacketID as id, T_PacketName as name, T_PacketSasCode as code
|
||||
FROM m_packetcategorydetail
|
||||
JOIN m_packetcategorymou ON M_PacketCategoryMouM_PacketCategoryID = M_PacketCategoryDetailM_PacketCategoryID AND
|
||||
M_PacketCategoryMouIsActive = 'Y' AND M_PacketCategoryMouM_MouID = {$mouid}
|
||||
JOIN t_packet ON M_PacketCategoryDetailT_PacketID = T_PacketID AND T_PacketIsActive = 'Y'
|
||||
WHERE M_PacketCategoryDetailM_PacketCategoryID = {$value['M_PacketCategoryID']} AND
|
||||
M_PacketCategoryDetailIsActive = 'Y'";
|
||||
$rst = $this->db_onedev->query($sql)->result_array();
|
||||
if($rst)
|
||||
$rows[$key]['details'] = $rst;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => 1, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function uploadimage($xid,$files){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$_FILES['files'] = $files;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$data = [];
|
||||
$errors = [];
|
||||
//print_r($_SERVER);
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//$config['upload_path'] = 'assets/';
|
||||
|
||||
$path = '/home/one/project/one/one-media/one-regonline/';
|
||||
//echo $path;
|
||||
$config['upload_path'] = $path;
|
||||
$config['allowed_types'] = 'jpg|jpeg|png';
|
||||
|
||||
$config['max_size'] = '300';
|
||||
$count = count($_FILES['files']['name']);
|
||||
//echo $count;
|
||||
$this->load->library('upload',$config);
|
||||
|
||||
$error = [];
|
||||
for($i=0;$i<$count;$i++){
|
||||
|
||||
//echo $_FILES['files']['name'][$i];
|
||||
if(!empty($_FILES['files']['name'][$i])){
|
||||
|
||||
|
||||
|
||||
$_FILES['file']['name'] = $_FILES['files']['name'][$i];
|
||||
|
||||
$_FILES['file']['type'] = $_FILES['files']['type'][$i];
|
||||
|
||||
$_FILES['file']['tmp_name'] = $_FILES['files']['tmp_name'][$i];
|
||||
|
||||
$_FILES['file']['error'] = $_FILES['files']['error'][$i];
|
||||
|
||||
$_FILES['file']['size'] = $_FILES['files']['size'][$i];
|
||||
|
||||
|
||||
|
||||
$namex = 'catpacket-'.date("ymdHis").'-'.$this->generateRandomString(5);
|
||||
//echo $namex;
|
||||
|
||||
$config['file_name'] = $namex;
|
||||
$this->upload->initialize($config);
|
||||
//echo $config['file_name'] ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if($this->upload->do_upload('file')){
|
||||
|
||||
$uploadData = $this->upload->data();
|
||||
|
||||
$filename = $uploadData['file_name'];
|
||||
//echo $filename;
|
||||
|
||||
|
||||
$sql = "UPDATE m_packetcategory SET M_PacketCategoryImageUrl = '{$filename}' WHERE M_PacketCategoryID = {$xid}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
|
||||
|
||||
|
||||
$data['totalFiles'][] = array('name' => $_FILES['files']['name'][$i] ,'image_url' => '/one-media/one-regonline/'.$filename);
|
||||
|
||||
}
|
||||
else{
|
||||
$error = array('image'=>$_FILES['files']['name'][$i],'error' => $this->upload->display_errors());
|
||||
$errors[] = $error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$result = array("total" =>count( $data['totalFiles']), "records" => $data['totalFiles'],'errors'=>$errors);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function generateRandomString($length = 10) {
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
|
||||
function getdatapackets(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT T_PacketID as id, T_PacketName as name, T_PacketSasCode as code
|
||||
FROM t_packet
|
||||
WHERE
|
||||
T_PacketM_MouID = {$prm['M_MouID']} AND
|
||||
( T_PacketName LIKE CONCAT('%','{$search}','%') )
|
||||
AND T_PacketIsActive = 'Y'
|
||||
) x
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->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_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$query ="
|
||||
SELECT 0 as trx_id,T_PacketID as id, T_PacketName as name, T_PacketSasCode as code
|
||||
FROM t_packet
|
||||
WHERE
|
||||
T_PacketM_MouID = {$prm['M_MouID']} AND
|
||||
( T_PacketName LIKE CONCAT('%','{$search}','%') )
|
||||
AND T_PacketIsActive = 'Y'
|
||||
ORDER BY T_PacketSasCode ASC
|
||||
limit $number_limit offset $number_offset
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page ,
|
||||
"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"];
|
||||
|
||||
if($prm['xstatus'] == 'N'){
|
||||
$sql = "UPDATE m_packetcategorymou SET M_PacketCategoryMouIsActive = 'N',
|
||||
M_PacketCategoryMouLastUpdated = NOW(), M_PacketCategoryMouUserID = {$userid}
|
||||
WHERE M_PacketCategoryMouM_PacketCategoryID = {$prm['selected_grup']['M_PacketCategoryID']} AND
|
||||
M_PacketCategoryMouM_MouID = {$prm['selected_mou']['M_MouID']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
else{
|
||||
$xid = 0;
|
||||
$sql = "SELECT M_PacketCategoryMouID
|
||||
FROM m_packetcategorymou
|
||||
WHERE
|
||||
M_PacketCategoryMouM_MouID = {$prm['selected_mou']['M_MouID']} AND
|
||||
M_PacketCategoryMouM_PacketCategoryID = {$prm['selected_grup']['M_PacketCategoryID']} AND
|
||||
M_PacketCategoryMouIsActive = 'Y' LIMIT 1";
|
||||
$xdata = $this->db_onedev->query($sql)->row_array();
|
||||
if($xdata){
|
||||
$xid = $xdata['M_PacketCategoryMouID'];
|
||||
}
|
||||
if(intval($xid) == 0){
|
||||
$sql = "INSERT INTO m_packetcategorymou (
|
||||
M_PacketCategoryMouM_MouID,
|
||||
M_PacketCategoryMouM_PacketCategoryID,
|
||||
M_PacketCategoryMouCreated,
|
||||
M_PacketCategoryMouLastUpdated,
|
||||
M_PacketCategoryMouUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['selected_mou']['M_MouID']},
|
||||
{$prm['selected_grup']['M_PacketCategoryID']},
|
||||
NOW(),
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$sql = "UPDATE m_packetcategorydetail SET M_PacketCategoryDetailIsActive = 'N',
|
||||
M_PacketCategoryDetailLastUpdated = NOW(),
|
||||
M_PacketCategoryDetailUserID = {$userid}
|
||||
WHERE
|
||||
M_PacketCategoryDetailM_PacketCategoryID = {$prm['selected_grup']['M_PacketCategoryID']} AND
|
||||
M_PacketCategoryDetailIsActive = 'Y'";
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
if($prm['selected_packets'] && count($prm['selected_packets']) > 0){
|
||||
foreach ($prm['selected_packets'] as $key => $value) {
|
||||
$sql = "INSERT INTO m_packetcategorydetail (
|
||||
M_PacketCategoryDetailM_PacketCategoryID,
|
||||
M_PacketCategoryDetailT_PacketID,
|
||||
M_PacketCategoryDetailCreated,
|
||||
M_PacketCategoryDetailLastUpdated,
|
||||
M_PacketCategoryDetailUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['selected_grup']['M_PacketCategoryID']},
|
||||
{$value['id']},
|
||||
NOW(),
|
||||
NOW(),
|
||||
{$userid}
|
||||
)";
|
||||
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"errors" => array()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function newpatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
||||
$prm['M_PatientName'] = str_replace("'", "\\'", $prm['M_PatientName']);
|
||||
$query ="INSERT INTO m_patient (
|
||||
M_PatientM_TitleID,
|
||||
M_PatientPrefix,
|
||||
M_PatientName,
|
||||
M_PatientSuffix,
|
||||
M_PatientDOB,
|
||||
M_PatientM_SexID,
|
||||
M_PatientM_ReligionID,
|
||||
M_PatientEmail,
|
||||
M_PatientPOB,
|
||||
M_PatientHP,
|
||||
M_PatientPhone,
|
||||
M_PatientM_IdTypeID,
|
||||
M_PatientIDNumber,
|
||||
M_PatientNote,
|
||||
M_PatientNIK,
|
||||
M_PatientJabatan,
|
||||
M_PatientKedudukan,
|
||||
M_PatientPJ,
|
||||
M_PatientLocation,
|
||||
M_PatientJob,
|
||||
M_PatientUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_PatientM_TitleID']}',
|
||||
'{$prm['M_PatientPrefix']}',
|
||||
'{$prm['M_PatientName']}',
|
||||
'{$prm['M_PatientSuffix']}',
|
||||
'{$pdob}',
|
||||
'{$prm['M_PatientM_SexID']}',
|
||||
'{$prm['M_PatientM_ReligionID']}',
|
||||
'{$prm['M_PatientEmail']}',
|
||||
'{$prm['M_PatientPOB']}',
|
||||
'{$prm['M_PatientHP']}',
|
||||
'{$prm['M_PatientPhone']}',
|
||||
'{$prm['M_PatientM_IdTypeID']}',
|
||||
'{$prm['M_PatientIDNumber']}',
|
||||
'{$prm['M_PatientNote']}',
|
||||
'{$prm['M_PatientNIK']}',
|
||||
'{$prm['M_PatientJabatan']}',
|
||||
'{$prm['M_PatientKedudukan']}',
|
||||
'{$prm['M_PatientPJ']}',
|
||||
'{$prm['M_PatientLocation']}',
|
||||
'{$prm['M_PatientJob']}',
|
||||
$userid
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_PatientID"] = $last_id;
|
||||
$ptn["M_PatientDOB"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADD', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletepatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE m_packetcategory SET
|
||||
M_PacketCategoryIsActive = 'N',
|
||||
M_PacketCategoryLastUpdated = NOW(),
|
||||
M_PacketCategoryUserID = {$userid}
|
||||
WHERE
|
||||
M_PacketCategoryID = '{$prm['M_PacketCategoryID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.DELETE', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_patientaddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,
|
||||
'' as action
|
||||
FROM m_patientaddress
|
||||
JOIN m_kelurahan ON M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
WHERE
|
||||
M_PatientAddressIsActive = 'Y' AND M_PatientAddressM_PatientID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['M_PatientAddressDescription'] = stripslashes($v['M_PatientAddressDescription']);
|
||||
$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_onedev->query("SELECT COUNT(*) as countx FROM m_patientaddress WHERE M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}' AND M_PatientAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_PatientAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_patientaddress WHERE M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}' AND M_PatientAddressNote = 'Utama' AND M_PatientAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_PatientAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_PatientAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$prm['M_PatientAddressDescription'] = str_replace("'", "\\'", $prm['M_PatientAddressDescription']);
|
||||
$query ="INSERT INTO m_patientaddress (
|
||||
M_PatientAddressM_PatientID,
|
||||
M_PatientAddressNote,
|
||||
M_PatientAddressDescription,
|
||||
M_PatientAddressM_KelurahanID,
|
||||
M_PatientAddressCreated,
|
||||
M_PatientAddressUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_PatientAddressM_PatientID']}',
|
||||
'{$prm['M_PatientAddressNote']}',
|
||||
'{$prm['M_PatientAddressDescription']}',
|
||||
'{$prm['M_PatientAddressM_KelurahanID']}',
|
||||
NOW(),
|
||||
'{$userid}'
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_UserID"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_ADD', '{$ptn}', $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;
|
||||
$prm['M_PatientAddressDescription'] = str_replace("'", "\\'", $prm['M_PatientAddressDescription']);
|
||||
$sql = "SELECT * FROM m_patientaddress WHERE M_PatientAddressID = {$prm['M_PatientAddressID']}";
|
||||
$rows_before = $this->db_onedev->query($sql)->row_array();
|
||||
$query ="UPDATE m_patientaddress SET
|
||||
M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}',
|
||||
M_PatientAddressNote = '{$prm['M_PatientAddressNote']}',
|
||||
M_PatientAddressDescription = '{$prm['M_PatientAddressDescription']}',
|
||||
M_PatientAddressM_KelurahanID = '{$prm['M_PatientAddressM_KelurahanID']}',
|
||||
M_PatientAddressUserID = {$userid}
|
||||
WHERE
|
||||
M_PatientAddressID = '{$prm['M_PatientAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_UserID"] = $pdob;
|
||||
$xbefore = json_encode($rows_before);
|
||||
$ptn = json_encode($ptn);
|
||||
/*$this->db_onedev->query("INSERT INTO one_log.log_patient (
|
||||
Log_PatientCode,
|
||||
Log_PatientJson,
|
||||
Log_PatientJsonBefore,
|
||||
Log_PatientUserID
|
||||
)
|
||||
VALUES(
|
||||
'PATIENT.ADDR_EDIT',
|
||||
'{$ptn}',
|
||||
'{$xbefore}',
|
||||
'{$userid}'
|
||||
)");*/
|
||||
//$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_EDIT', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getmous(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$query ="SELECT * FROM `m_mou` WHERE `M_MouIsOnline` = 'Y' AND `M_MouIsActive` = 'Y'";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rows
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user