1616 lines
53 KiB
PHP
1616 lines
53 KiB
PHP
<?php
|
|
class Downloadagreement extends MY_Controller
|
|
{
|
|
var $db_regional;
|
|
public function index()
|
|
{
|
|
echo "Doctor API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_regional = $this->load->database("nasional", true);
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$nama = str_replace("'", "\\'", $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_StaffID = Nat_StaffID AND Nat_StaffIsActive = 'Y'
|
|
|
|
$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,
|
|
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_StaffID = Nat_StaffID AND Nat_StaffIsActive = 'Y'
|
|
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]['M_DoctorName'] =stripslashes($v['M_DoctorName']);
|
|
$rows[$k]['doctor_fullname'] = stripslashes($v['doctor_fullname']);
|
|
//$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 searchagreement(){
|
|
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_mou
|
|
WHERE
|
|
nat_mouIsActive = 'Y'
|
|
AND (nat_mouName like '%{$name}%' OR nat_mouNumber like '%{$name}%')";
|
|
$query = $this->db_regional->query($sql);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("agreement count",$this->db_regional);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *, CONCAT(Nat_MouName,' (',Nat_MouNumber,')') as text_selected
|
|
FROM nat_mou
|
|
JOIN nat_company ON Nat_CompanyID = Nat_MouNat_CompanyID
|
|
WHERE
|
|
nat_mouIsActive = 'Y'
|
|
AND (nat_mouName like '%{$name}%' OR nat_mouNumber like '%{$name}%' OR CONCAT(Nat_MouName,' (',Nat_MouNumber,')') LIKE '%{$name}%' )
|
|
ORDER BY nat_mouName 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("agreement 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 getregional(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$query =" SELECT nat_regional.*,'' as selected
|
|
FROM nat_regional
|
|
WHERE
|
|
Nat_RegionalIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_regional->query($query)->result_array();
|
|
foreach ($rows as $key => $value) {
|
|
$rows[$key]['selected'] = false;
|
|
}
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
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';
|
|
}
|
|
$xxdob = '0000-00-00';
|
|
if($prm['M_DoctorDOB'] != ''){
|
|
$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));
|
|
}
|
|
|
|
if(!$prm['M_DoctorM_SpecialistID'])
|
|
{
|
|
$prm['M_DoctorM_SpecialistID'] = 0;
|
|
}
|
|
$prm['M_DoctorName'] = str_replace("'", "\\'", $prm['M_DoctorName']);
|
|
|
|
$sql = "SELECT * FROM m_doctor WHERE M_DoctorID = {$prm['M_DoctorID']}";
|
|
$row_log_before = $this->db_regional->query($sql)->row_array();
|
|
$query ="UPDATE m_doctor SET
|
|
M_DoctorPrefix = '{$prm['M_DoctorPrefix']}',
|
|
M_DoctorCode = '{$prm['M_DoctorCode']}',
|
|
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']},
|
|
M_DoctorUserID = {$userid},
|
|
M_DoctorM_UserID = {$userid}
|
|
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
|
|
JOIN s_regional ON M_BranchS_RegionalID = S_RegionalID AND
|
|
S_RegionalIsDefault = 'Y' AND
|
|
S_RegionalIsActive = 'Y'
|
|
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(
|
|
{$prm['M_DoctorID']},
|
|
'{$v['M_BranchIPAddress']}',
|
|
'UD',
|
|
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));
|
|
|
|
$sql = "SELECT * FROM m_doctor WHERE M_DoctorID = {$prm['M_DoctorID']}";
|
|
$row_log_now = $this->db_regional->query($sql)->row_array();
|
|
$data_log = array('before'=>$row_log_before,'now'=>$row_log_now );
|
|
$d_doctor = json_encode($data_log);
|
|
$this->db_regional->query("call palembang_log.log_me('DOCTOR',{$prm['M_DoctorID']},'DOCTOR_EDT','{$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;
|
|
$xxdob = '0000-00-00';
|
|
if($prm['M_DoctorDOB'] != ''){
|
|
$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));
|
|
}
|
|
|
|
if(!$prm['M_DoctorM_SpecialistID'])
|
|
{
|
|
$prm['M_DoctorM_SpecialistID'] = 0;
|
|
}
|
|
$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,
|
|
M_DoctorUserID
|
|
)
|
|
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}',
|
|
'{$userid}'
|
|
)
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_regional->query($query);
|
|
$last_id = $this->db_regional->insert_id();
|
|
/*if($rows){
|
|
$sql = "SELECT *
|
|
FROM m_branch
|
|
JOIN s_regional ON M_BranchS_RegionalID = S_RegionalID AND
|
|
S_RegionalIsDefault = 'Y' AND
|
|
S_RegionalIsActive = 'Y'
|
|
WHERE
|
|
M_BranchIsActive = 'Y'";
|
|
$branches = $this->db_regional->query($sql)->result_array();
|
|
foreach($branches as $k => $v){
|
|
try {
|
|
$array_prm = array();
|
|
$array_ids = array();
|
|
$sql = "SELECT *
|
|
FROM doctortobranch
|
|
JOIN m_doctor ON DoctorToBranchM_DoctorID = M_DoctorID
|
|
WHERE
|
|
DoctorToBranchType = 'D' AND
|
|
DoctorToBranchStatus = 'N' AND
|
|
DoctorToBranchM_BranchIPAddress = '{$v['M_BranchIPAddress']}'";
|
|
$data_not_sending = $this->db_regional->query($sql)->result_array();
|
|
if($data_not_sending){
|
|
foreach($data_not_sending as $kx => $vx){
|
|
$x_arr = array(
|
|
'M_DoctorID' => $vx['M_DoctorID'],
|
|
'M_DoctorPrefix' => $vx['M_DoctorPrefix'],
|
|
'M_DoctorPrefix2' => $vx['M_DoctorPrefix2'],
|
|
'M_DoctorName' => $vx['M_DoctorName'],
|
|
'M_DoctorSufix' => $vx['M_DoctorSufix'] ,
|
|
'M_DoctorSufix2' => $vx['M_DoctorSufix2'],
|
|
'M_DoctorSufix3' => $vx['M_DoctorSufix3'],
|
|
'M_DoctorM_SexID' => $vx['M_DoctorM_SexID'],
|
|
'M_DoctorM_ReligionID' => $vx['M_DoctorM_ReligionID'],
|
|
'M_DoctorM_StaffID' => $vx['M_DoctorM_StaffID'],
|
|
'M_DoctorM_StaffNIK' => $vx['M_DoctorM_StaffNIK'],
|
|
'M_DoctorEmail' => $vx['M_DoctorEmail'],
|
|
'M_DoctorHP' => $vx['M_DoctorHP'],
|
|
'M_DoctorNote' => $vx['M_DoctorNote'],
|
|
'M_DoctorPhone' => $vx['M_DoctorPhone'],
|
|
'M_DoctorIsMarketingConfirm' => $vx['M_DoctorIsMarketingConfirm'],
|
|
'M_DoctorEmailIsDefault' => $vx['M_DoctorEmailIsDefault'],
|
|
'M_DoctorDOB' => $vx['M_DoctorDOB'],
|
|
'M_DoctorM_SpecialistID' => $vx['M_DoctorM_SpecialistID'],
|
|
'M_DoctorM_UserID' => $userid,
|
|
'M_DoctorUserID' => $userid
|
|
);
|
|
array_push($array_prm,$x_arr);
|
|
array_push($array_ids,$vx['DoctorToBranchID']);
|
|
}
|
|
}
|
|
|
|
$x_arr = array(
|
|
'M_DoctorID' => $last_id,
|
|
'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' => $prm['M_DoctorDOB'],
|
|
'M_DoctorM_SpecialistID' => $prm['M_DoctorM_SpecialistID'],
|
|
'M_DoctorM_UserID' => $prm['M_DoctorM_UserID'],
|
|
'M_DoctorUserID' => $userid
|
|
);
|
|
array_push($array_prm,$x_arr);
|
|
$data = json_encode($array_prm);
|
|
//print_r($prm);
|
|
$md5 = md5($data);
|
|
$param = array("data" => $data, "md5" => $md5);
|
|
$jparam = json_encode($param);
|
|
|
|
$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);
|
|
if(count($array_ids) > 0){
|
|
foreach($array_ids as $ku => $vu){
|
|
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
|
WHERE
|
|
DoctorToBranchID = {$vu}";
|
|
$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;
|
|
}
|
|
|
|
}
|
|
|
|
if(count($prm['addresses']) > 0){
|
|
foreach($prm['addresses'] as $k => $v){
|
|
$v['M_DoctorAddressM_DoctorID'] = $last_id;
|
|
$this->newaddress($v);
|
|
}
|
|
}
|
|
}*/
|
|
|
|
if(count($prm['addresses']) > 0){
|
|
foreach($prm['addresses'] as $k => $v){
|
|
$v['M_DoctorAddressM_DoctorID'] = $last_id;
|
|
$this->newaddress($v);
|
|
}
|
|
}
|
|
$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;
|
|
|
|
$sql = "SELECT * FROM m_doctor WHERE M_DoctorID = {$last_id}";
|
|
$row_log_now = $this->db_regional->query($sql)->row_array();
|
|
$data_log = array('before'=>array(),'now'=>$row_log_now );
|
|
$d_doctor = json_encode($data_log);
|
|
$this->db_regional->query("call palembang_log.log_me('DOCTOR',{$last_id},'DOCTOR_ADD','{$d_doctor}',$userid)");
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function newaddress($prm){
|
|
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;
|
|
}
|
|
}*/
|
|
$prm['M_DoctorAddressDescription'] = str_replace("'", "\\'", $prm['M_DoctorAddressDescription']);
|
|
$query ="INSERT INTO m_doctoraddress (
|
|
M_DoctorAddressM_DoctorID,
|
|
M_DoctorAddressNote,
|
|
M_DoctorAddressDescription,
|
|
M_DoctorAddressM_KelurahanID,
|
|
M_DoctorAddressNat_JpaID,
|
|
M_DoctorAddressLastUpdated,
|
|
M_DoctorAddressCreated,
|
|
M_DoctorAddressM_UserID
|
|
)
|
|
VALUES(
|
|
'{$prm['M_DoctorAddressM_DoctorID']}',
|
|
'{$prm['M_DoctorAddressNote']}',
|
|
'{$prm['M_DoctorAddressDescription']}',
|
|
'{$prm['M_DoctorAddressM_KelurahanID']}',
|
|
'{$prm['M_DoctorAddressNat_JpaID']}',
|
|
NOW(),
|
|
NOW(),
|
|
$userid
|
|
)
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_regional->query($query);
|
|
$last_id = $this->db_regional->insert_id();
|
|
/*if($rows){
|
|
|
|
$sql = "SELECT *
|
|
FROM m_branch
|
|
JOIN s_regional ON M_BranchS_RegionalID = S_RegionalID AND
|
|
S_RegionalIsDefault = 'Y' AND
|
|
S_RegionalIsActive = 'Y'
|
|
WHERE
|
|
M_BranchIsActive = 'Y'";
|
|
$branches = $this->db_regional->query($sql)->result_array();
|
|
foreach($branches as $k => $v){
|
|
try {
|
|
$array_prm = array();
|
|
$array_ids = array();
|
|
$sql = "SELECT *
|
|
FROM doctortobranch
|
|
JOIN m_doctoraddress ON DoctorToBranchM_DoctorID = M_DoctorAddressID
|
|
WHERE
|
|
DoctorToBranchType = 'A' AND
|
|
DoctorToBranchStatus = 'N' AND
|
|
DoctorToBranchM_BranchIPAddress = '{$v['M_BranchIPAddress']}'";
|
|
$data_not_sending = $this->db_regional->query($sql)->result_array();
|
|
if($data_not_sending){
|
|
foreach($data_not_sending as $kx => $vx){
|
|
$x_arr = array(
|
|
'M_DoctorAddressID' => $vx['M_DoctorAddressID'],
|
|
'M_DoctorAddressM_DoctorID' => $vx['M_DoctorAddressM_DoctorID'],
|
|
'M_DoctorAddressNote' => $vx['M_DoctorAddressNote'],
|
|
'M_DoctorAddressDescription' => $vx['M_DoctorAddressDescription'],
|
|
'M_DoctorAddressM_KelurahanID' => $vx['M_DoctorAddressM_KelurahanID'] ,
|
|
'M_DoctorAddressNat_JpaID' => $vx['M_DoctorAddressNat_JpaID'],
|
|
'M_DoctorAddressM_UserID' => $userid
|
|
);
|
|
array_push($array_prm,$x_arr);
|
|
array_push($array_ids,$vx['DoctorToBranchID']);
|
|
}
|
|
}
|
|
|
|
$x_arr = array(
|
|
'M_DoctorAddressID' => $last_id,
|
|
'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_DoctorAddressM_UserID' => $userid
|
|
);
|
|
array_push($array_prm,$x_arr);
|
|
$data = json_encode($array_prm);
|
|
//print_r($prm);
|
|
$md5 = md5($data);
|
|
$param = array("data" => $data, "md5" => $md5);
|
|
$jparam = json_encode($param);
|
|
|
|
$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);
|
|
if(count($array_ids) > 0){
|
|
foreach($array_ids as $ku => $vu){
|
|
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
|
WHERE
|
|
DoctorToBranchID = {$vu}";
|
|
$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;
|
|
|
|
$sql = "SELECT * FROM m_doctoraddress WHERE M_DoctorAddressID = {$last_id}";
|
|
$row_log_now = $this->db_regional->query($sql)->row_array();
|
|
$data_log = array('before'=>array(),'now'=>$row_log_now );
|
|
$d_doctor = json_encode($data_log);
|
|
$this->db_regional->query("call palembang_log.log_me('DOCTOR',{$prm['M_DoctorAddressM_DoctorID']},'DOCTOR_ADDR','{$d_doctor}',$userid)");
|
|
return $last_id;
|
|
}
|
|
|
|
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);
|
|
curl_close($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);
|
|
/*if($rows){
|
|
$query ="UPDATE m_doctoraddress SET
|
|
M_DoctorAddressIsActive = 'N',
|
|
M_DoctorAddressLastUpdated = now(),
|
|
M_DoctorUserID = {$userid}
|
|
WHERE
|
|
M_DoctorAddressM_DoctorID = '{$prm['M_DoctorID']}'
|
|
";
|
|
//echo $query;
|
|
$del_addr = $this->db_regional->query($query);
|
|
$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' AND M_BranchS_RegionalID = 1";
|
|
$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']}',
|
|
'DD',
|
|
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/deletedoctor/";
|
|
//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')
|
|
);
|
|
//adi tambah log doctor
|
|
$prm["M_DoctorM_UserID"] = $userid;
|
|
$d_doctor = json_encode($prm);
|
|
$this->db_regional->query("call palembang_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]['M_DoctorAddressDescription'] = stripslashes($v['M_DoctorAddressDescription']);
|
|
$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;
|
|
}
|
|
}*/
|
|
$prm['M_DoctorAddressDescription'] = str_replace("'", "\\'", $prm['M_DoctorAddressDescription']);
|
|
$query ="INSERT INTO m_doctoraddress (
|
|
M_DoctorAddressM_DoctorID,
|
|
M_DoctorAddressNote,
|
|
M_DoctorAddressDescription,
|
|
M_DoctorAddressM_KelurahanID,
|
|
M_DoctorAddressNat_JpaID,
|
|
M_DoctorAddressLastUpdated,
|
|
M_DoctorAddressCreated,
|
|
M_DoctorAddressM_UserID
|
|
)
|
|
VALUES(
|
|
'{$prm['M_DoctorAddressM_DoctorID']}',
|
|
'{$prm['M_DoctorAddressNote']}',
|
|
'{$prm['M_DoctorAddressDescription']}',
|
|
'{$prm['M_DoctorAddressM_KelurahanID']}',
|
|
'{$prm['M_DoctorAddressNat_JpaID']}',
|
|
NOW(),
|
|
NOW(),
|
|
$userid
|
|
)
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_regional->query($query);
|
|
$last_id = $this->db_regional->insert_id();
|
|
/*if($rows){
|
|
|
|
$sql = "SELECT *
|
|
FROM m_branch
|
|
JOIN s_regional ON M_BranchS_RegionalID = S_RegionalID AND
|
|
S_RegionalIsDefault = 'Y' AND
|
|
S_RegionalIsActive = 'Y'
|
|
WHERE
|
|
M_BranchIsActive = 'Y'";
|
|
$branches = $this->db_regional->query($sql)->result_array();
|
|
foreach($branches as $k => $v){
|
|
try {
|
|
$array_prm = array();
|
|
$array_ids = array();
|
|
$sql = "SELECT *
|
|
FROM doctortobranch
|
|
JOIN m_doctoraddress ON DoctorToBranchM_DoctorID = M_DoctorAddressID
|
|
WHERE
|
|
DoctorToBranchType = 'A' AND
|
|
DoctorToBranchStatus = 'N' AND
|
|
DoctorToBranchM_BranchIPAddress = '{$v['M_BranchIPAddress']}'";
|
|
$data_not_sending = $this->db_regional->query($sql)->result_array();
|
|
if($data_not_sending){
|
|
foreach($data_not_sending as $kx => $vx){
|
|
$x_arr = array(
|
|
'M_DoctorAddressID' => $vx['M_DoctorAddressID'],
|
|
'M_DoctorAddressM_DoctorID' => $vx['M_DoctorAddressM_DoctorID'],
|
|
'M_DoctorAddressNote' => $vx['M_DoctorAddressNote'],
|
|
'M_DoctorAddressDescription' => $vx['M_DoctorAddressDescription'],
|
|
'M_DoctorAddressM_KelurahanID' => $vx['M_DoctorAddressM_KelurahanID'] ,
|
|
'M_DoctorAddressNat_JpaID' => $vx['M_DoctorAddressNat_JpaID'],
|
|
'M_DoctorAddressM_UserID' => $userid
|
|
);
|
|
array_push($array_prm,$x_arr);
|
|
array_push($array_ids,$vx['DoctorToBranchID']);
|
|
}
|
|
}
|
|
|
|
$x_arr = array(
|
|
'M_DoctorAddressID' => $last_id,
|
|
'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_DoctorAddressM_UserID' => $userid
|
|
);
|
|
array_push($array_prm,$x_arr);
|
|
$data = json_encode($array_prm);
|
|
//print_r($prm);
|
|
$md5 = md5($data);
|
|
$param = array("data" => $data, "md5" => $md5);
|
|
$jparam = json_encode($param);
|
|
|
|
$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);
|
|
if(count($array_ids) > 0){
|
|
foreach($array_ids as $ku => $vu){
|
|
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
|
WHERE
|
|
DoctorToBranchID = {$vu}";
|
|
$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;
|
|
$sql = "SELECT * FROM m_doctoraddress WHERE M_DoctorAddressID = {$last_id}";
|
|
$row_log_now = $this->db_regional->query($sql)->row_array();
|
|
$data_log = array('before'=>array(),'now'=>$row_log_now );
|
|
$d_doctor = json_encode($data_log);
|
|
$this->db_regional->query("call palembang_log.log_me('DOCTOR',{$prm['M_DoctorAddressM_DoctorID']},'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;
|
|
|
|
$sql = "SELECT * FROM m_doctoraddress WHERE M_DoctorAddressID = {$prm['M_DoctorAddressID']}";
|
|
$row_log_before = $this->db_regional->query($sql)->row_array();
|
|
$prm['M_DoctorAddressDescription'] = str_replace("'", "\\'", $prm['M_DoctorAddressDescription']);
|
|
|
|
$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(),
|
|
M_DoctorAddressM_UserID = {$userid}
|
|
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
|
|
JOIN s_regional ON M_BranchS_RegionalID = S_RegionalID AND
|
|
S_RegionalIsDefault = 'Y' AND
|
|
S_RegionalIsActive = 'Y'
|
|
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(
|
|
{$prm['M_DoctorAddressID']},
|
|
'{$v['M_BranchIPAddress']}',
|
|
'UA',
|
|
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;
|
|
|
|
$sql = "SELECT * FROM m_doctoraddress WHERE M_DoctorAddressID = {$last_id}";
|
|
$row_log_now = $this->db_regional->query($sql)->row_array();
|
|
$data_log = array('before'=>$row_log_before,'now'=>$row_log_now );
|
|
$d_doctor = json_encode($data_log);
|
|
$this->db_regional->query("call palembang_log.log_me('DOCTOR',{$prm['M_DoctorAddressM_DoctorID']},'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;
|
|
$sql = "SELECT * FROM m_doctoraddress WHERE M_DoctorAddressID = {$prm['M_DoctorAddressID']}";
|
|
$row_log_before = $this->db_regional->query($sql)->row_array();
|
|
|
|
$query ="UPDATE m_doctoraddress SET
|
|
M_DoctorAddressIsActive = 'N',
|
|
M_DoctorAddressLastUpdated = now(),
|
|
M_DoctorAddressM_UserID = {$userid}
|
|
WHERE
|
|
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
|
";
|
|
//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
|
|
JOIN s_regional ON M_BranchS_RegionalID = S_RegionalID AND
|
|
S_RegionalIsDefault = 'Y' AND
|
|
S_RegionalIsActive = 'Y'
|
|
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']}',
|
|
'DA',
|
|
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/deleteaddressdoctor/";
|
|
//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 palembang_log.log_me('DOCTOR','DOCTOR_ADDR_DELETE','{$d_doctor}',$userid)");
|
|
$sql = "SELECT * FROM m_doctoraddress WHERE M_DoctorAddressID = {$prm['M_DoctorAddressID']}";
|
|
$row_log_now = $this->db_regional->query($sql)->row_array();
|
|
$data_log = array('before'=>$row_log_before,'now'=>$row_log_now );
|
|
$d_doctor = json_encode($data_log);
|
|
$this->db_regional->query("call palembang_log.log_me('DOCTOR',{$prm['M_DoctorAddressM_DoctorID']},'DOCTOR_ADDR_EDIT','{$d_doctor}',$userid)");
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function savedownload(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$regionals = $prm['regional'];
|
|
$agreement = $prm['agreement'];
|
|
$query ="
|
|
INSERT INTO download_agreement(
|
|
DownloadAgreementnat_mouID,
|
|
DownloadAgreementDate,
|
|
DownloadAgreementCreatedUserID,
|
|
DownloadAgreementUserID,
|
|
DownloadAgreementCreated
|
|
)
|
|
VALUES (
|
|
?,NOW(),?,?,NOW()
|
|
)";
|
|
//echo $query;
|
|
$save = $this->db_regional->query($query,array($agreement['nat_mouID'],$userid,$userid));
|
|
|
|
$last_id = $this->db_regional->insert_id();
|
|
|
|
if($regionals){
|
|
foreach ($regionals as $key => $value) {
|
|
$query ="
|
|
INSERT INTO download_agreement_details(
|
|
DownloadAgreementDetailsDownloadAgreementID,
|
|
DownloadAgreementDetailsNat_RegionalID,
|
|
DownloadAgreementDetailsUserID,
|
|
DownloadAgreementDetailsCreated
|
|
)
|
|
VALUES (
|
|
?,?,?,NOW()
|
|
)";
|
|
//echo $query;
|
|
$save = $this->db_regional->query($query,array($last_id, $value['Nat_RegionalID'], $userid));
|
|
}
|
|
}
|
|
|
|
$result = array("status" => "SUCCESS");
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function checkexist(){
|
|
try {
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$sql = "select count(*) as x
|
|
from nat_company
|
|
JOIN nat_mou ON Nat_MouNat_CompanyID = Nat_CompanyID AND nat_mouID = {$prm['mou']['Nat_MouID']}
|
|
where
|
|
Nat_CompanyIsActive = 'Y'";
|
|
//echo $sql;
|
|
$row = $this->db_regional->query($sql)->row();
|
|
//echo $this->db_regional->last_query();
|
|
$rtn = FALSE;
|
|
if($row->x > 0 )
|
|
$rtn = TRUE;
|
|
|
|
$result = array ("status" => $rtn);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
}
|