1697 lines
52 KiB
PHP
1697 lines
52 KiB
PHP
<?php
|
|
class Order extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "ORDER 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;
|
|
}
|
|
|
|
$nama = str_replace("'", "\\'", $prm["name"]);
|
|
$status = $prm["status"];
|
|
$staff = $prm['staff'];
|
|
$startdate = $prm['startdate'];
|
|
$enddate = $prm['enddate'];
|
|
// echo $norm;
|
|
//echo 'dasdsa';
|
|
if($status == 'O'){
|
|
|
|
$sql_where = "WHERE Td_OrderIsActive = 'Y'
|
|
AND Td_OrderDate BETWEEN '{$startdate} 00:00:00' AND '{$enddate} 23:59:59'";
|
|
}else{
|
|
|
|
$sql_where = "WHERE Td_OrderIsActive = 'Y' AND Td_OrderStatus = '{$status}'
|
|
AND Td_OrderDate BETWEEN '{$startdate} 00:00:00' AND '{$enddate} 23:59:59'";
|
|
}
|
|
$sql_param = array();
|
|
if ($nama != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " (Td_OrderNumber like ? OR Td_DonorName like '%$nama%')";
|
|
$sql_param[] = "%$nama%";
|
|
//$prm['current_page'] = 1;
|
|
}
|
|
|
|
$number_limit = 10;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
|
|
$sql = " SELECT count(*) as total
|
|
FROM (
|
|
SELECT *
|
|
FROM one_bb.td_order
|
|
JOIN one_bb.td_donor ON Td_DonorID = Td_OrderTd_DonorID
|
|
LEFT JOIN one_bb.td_bloodcategory ON Td_BloodCategoryID = Td_OrderTd_BloodCategoryID
|
|
JOIN m_title ON M_TitleID = Td_DonorM_TitleID
|
|
JOIN m_sex ON M_SexID = Td_DonorM_SexID
|
|
JOIN m_religion ON M_ReligionID = Td_DonorM_ReligionID
|
|
LEFT JOIN one_bb.m_job ON M_JobID = Td_DonorM_JobID
|
|
JOIN m_idtype ON M_IdTypeID = Td_DonorM_IdTypeID
|
|
LEFT JOIN one_bb.td_bloodtype ON Td_BloodTypeID = Td_DonorTd_BloodTypeID
|
|
LEFT JOIN one_bb.td_bloodrhesus ON Td_BloodRhesusID = Td_DonorTd_BloodRhesusID
|
|
|
|
$sql_where
|
|
GROUP BY Td_OrderID
|
|
) 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("td_order count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
$server = $_SERVER['SERVER_NAME'];
|
|
|
|
$sql = "SELECT Td_OrderID as id,
|
|
Td_OrderID,
|
|
Td_OrderTd_DonorID,
|
|
Td_OrderDate,
|
|
DATE_FORMAT(Td_OrderDate,'%d-%m-%Y') as sdate,
|
|
Td_OrderNumber,
|
|
Td_DonorTd_BloodTypeID,
|
|
Td_BloodTypeID,
|
|
Td_BloodTypeCode,
|
|
Td_BloodTypeName,
|
|
CONCAT(Td_BloodTypeName,' Rhesus ',IFNULL(Td_BloodRhesusName,'-')) as goldar,
|
|
Td_DonorTd_BloodRhesusID,
|
|
Td_BloodRhesusID,
|
|
Td_BloodRhesusCode,
|
|
Td_BloodRhesusName,
|
|
Td_OrderTd_BloodCategoryID,
|
|
Td_BloodCategoryID,
|
|
Td_BloodCategoryCode,
|
|
Td_BloodCategoryName,
|
|
Td_OrderCMNumber,
|
|
Td_OrderDonorType,
|
|
Td_OrderIsScreening,
|
|
Td_OrderIsAftap,
|
|
Td_OrderIsImltd,
|
|
Td_OrderIsProcess,
|
|
Td_OrderIsResult,
|
|
Td_OrderIsReRun,
|
|
Td_OrderReRunDate,
|
|
Td_OrderReRunUserID,
|
|
Td_OrderIsReject,
|
|
Td_OrderRejectDate,
|
|
Td_OrderRejectUserID,
|
|
Td_OrderIsRelease,
|
|
Td_OrderReleaseDate,
|
|
Td_OrderReleaseUserID,
|
|
Td_OrderStatus,
|
|
Td_DonorID,
|
|
Td_DonorNoReg,
|
|
Td_DonorName,
|
|
Td_DonorM_TitleID,
|
|
M_TitleID,
|
|
M_TitleName,
|
|
Td_DonorM_SexID,
|
|
M_SexID,
|
|
M_SexName,
|
|
Td_DonorM_ReligionID,
|
|
M_ReligionID,
|
|
M_ReligionName,
|
|
Td_DonorM_JobID,
|
|
M_JobID,
|
|
M_JobName,
|
|
Td_DonorPOB,
|
|
DATE_FORMAT(Td_DonorDOB,'%d%m%Y') as Td_DonorDOB,
|
|
Td_DonorHP,
|
|
Td_DonorPhone,
|
|
Td_DonorEmail,
|
|
Td_DonorM_IdTypeID,
|
|
M_IdTypeID,
|
|
M_IdTypeName,
|
|
Td_DonorIDNumber,
|
|
Td_DonorNote,
|
|
Td_DonorJob,
|
|
Td_DonorAddress,
|
|
Td_DonorAddressOffice,
|
|
Td_DonorKesatuan,
|
|
Td_DonorBB,
|
|
Td_DonorTB,
|
|
CASE
|
|
WHEN Td_OrderStatus = 'N' THEN 'Baru'
|
|
WHEN Td_OrderStatus = 'S' THEN 'Screening'
|
|
WHEN Td_OrderStatus = 'A' THEN 'Aftap'
|
|
WHEN Td_OrderStatus = 'I' THEN 'IMLTD'
|
|
WHEN Td_OrderStatus = 'P' THEN 'Proses'
|
|
WHEN Td_OrderStatus = 'D' THEN 'Dimusnahkan'
|
|
ELSE ''
|
|
END as status,
|
|
Td_DonorPhoto,
|
|
Td_DonorPhotoThumb,
|
|
Td_DonorPhotoCounter,
|
|
Td_OrderPatientID,
|
|
Td_OrderPatientNoReg,
|
|
Td_OrderPatientName,
|
|
Td_OrderPatientRoom,
|
|
'{$server}' as url,
|
|
IFNULL(Td_OrderImltdIsValidate,'N') as Td_OrderImltdIsValidate
|
|
|
|
FROM one_bb.td_order
|
|
JOIN one_bb.td_donor ON Td_DonorID = Td_OrderTd_DonorID
|
|
LEFT JOIN one_bb.td_bloodcategory ON Td_BloodCategoryID = Td_OrderTd_BloodCategoryID
|
|
JOIN m_title ON M_TitleID = Td_DonorM_TitleID
|
|
JOIN m_sex ON M_SexID = Td_DonorM_SexID
|
|
JOIN m_religion ON M_ReligionID = Td_DonorM_ReligionID
|
|
LEFT JOIN one_bb.m_job ON M_JobID = Td_DonorM_JobID
|
|
JOIN m_idtype ON M_IdTypeID = Td_DonorM_IdTypeID
|
|
LEFT JOIN one_bb.td_bloodtype ON Td_BloodTypeID = Td_DonorTd_BloodTypeID
|
|
LEFT JOIN one_bb.td_bloodrhesus ON Td_BloodRhesusID = Td_DonorTd_BloodRhesusID
|
|
LEFT JOIN one_bb.td_orderpatient ON Td_OrderPatientTd_OrderID = Td_OrderID
|
|
LEFT JOIN one_bb.td_orderimltd ON Td_OrderImltdTd_OrderID = Td_OrderID AND Td_OrderImltdIsActive = 'Y'
|
|
|
|
$sql_where
|
|
GROUP BY Td_OrderID
|
|
ORDER BY Td_OrderNumber DESC
|
|
limit $number_limit offset $number_offset";
|
|
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
// echo $this->db_onedev->last_query();
|
|
$rows = $query->result_array();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_PatientID']);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//$this->_add_address($rows);
|
|
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->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_onedev->query($query)->result_array();
|
|
$query =" SELECT *
|
|
FROM m_religion
|
|
WHERE
|
|
M_ReligionIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['religions'] = $this->db_onedev->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_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT *
|
|
FROM nat_jpa
|
|
WHERE
|
|
Nat_JpaIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['jpas'] = $this->db_onedev->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_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT M_TitleID, M_TitleName
|
|
FROM m_title
|
|
WHERE
|
|
M_TitleIsActive = 'Y' AND M_TitleName IN('Tn','Ny','Nn')";
|
|
$rows['titles'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT Td_BloodTypeID,Td_BloodTypeCode, Td_BloodTypeName
|
|
FROM one_bb.td_bloodtype
|
|
WHERE
|
|
Td_BloodTypeIsActive = 'Y'";
|
|
$rows['bloodtypes'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT Td_BloodRhesusID,Td_BloodRhesusCode,Td_BloodRhesusName
|
|
FROM one_bb.td_bloodrhesus
|
|
WHERE
|
|
Td_BloodRhesusIsActive = 'Y'";
|
|
$rows['bloodrhesus'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT Td_BloodCategoryID,Td_BloodCategoryCode,Td_BloodCategoryName
|
|
FROM one_bb.td_bloodcategory
|
|
WHERE
|
|
Td_BloodCategoryIsActive = 'Y'";
|
|
$rows['bloodcategorys'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT M_RoomID,M_RoomCode,M_RoomName
|
|
FROM one_bb.m_room
|
|
WHERE
|
|
M_RoomIsActive = 'Y'";
|
|
$rows['rooms'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query ="SELECT M_IdTypeID,M_IdTypeName
|
|
FROM m_idtype
|
|
WHERE
|
|
M_IdTypeIsActive = 'Y'";
|
|
$rows['idtypes'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query ="SELECT M_JobID,M_JobName
|
|
FROM one_bb.m_job
|
|
WHERE
|
|
M_JobIsActive = 'Y'";
|
|
$rows['jobs'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function searchstaff(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
|
|
$name = $prm['name'];
|
|
$hirarkiid = intval($prm['id']) - 1;
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM nat_staff
|
|
left join m_position ON Nat_StaffM_PositionID = M_PositionID
|
|
WHERE
|
|
Nat_StaffIsActive = 'Y' and M_PositionIsMarketing = 'Y'
|
|
AND (Nat_StaffName like '%{$name}%' OR Nat_StaffNIK like '%{$name}%')";
|
|
$query = $this->db_onedev->query($sql);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("nat_staff count",$this->db_onedev);
|
|
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_onedev->query($sql);
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("nat_staff rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchcity(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM m_city
|
|
WHERE
|
|
M_CityName like ?
|
|
AND M_CityIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_city count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *
|
|
FROM m_city
|
|
WHERE
|
|
M_CityName like ?
|
|
AND M_CityIsActive = 'Y'
|
|
ORDER BY M_CityName DESC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_city rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
function 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_onedev->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_onedev->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_onedev->query($query)->result_array();
|
|
|
|
// $rows['jpas'] = $this->db_onedev->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"];
|
|
$xxdob = '0000-00-00';
|
|
if($prm['Td_DonorDOB'] != ''){
|
|
$x_dob = $prm['Td_DonorDOB'];
|
|
$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['Td_OrderID'] == '0'){
|
|
if($prm['Td_DonorID'] == '0' || !$prm['Td_DonorID']){
|
|
$query ="INSERT INTO one_bb.td_donor (
|
|
Td_DonorNoReg,
|
|
Td_DonorName,
|
|
Td_DonorM_TitleID,
|
|
Td_DonorM_SexID,
|
|
Td_DonorM_ReligionID,
|
|
Td_DonorPOB,
|
|
Td_DonorDOB,
|
|
Td_DonorHP,
|
|
Td_DonorPhone,
|
|
Td_DonorEmail,
|
|
Td_DonorM_IdTypeID,
|
|
Td_DonorIDNumber,
|
|
Td_DonorNote,
|
|
Td_DonorM_JobID,
|
|
Td_DonorAddress,
|
|
Td_DonorAddressOffice,
|
|
Td_DonorKesatuan,
|
|
Td_DonorBB,
|
|
Td_DonorTB,
|
|
Td_DonorUserID)
|
|
VALUES(
|
|
one_bb.fn_numbering('TD'),
|
|
'{$prm['Td_DonorName']}',
|
|
'{$prm['Td_DonorM_TitleID']}',
|
|
'{$prm['Td_DonorM_SexID']}',
|
|
'{$prm['Td_DonorM_ReligionID']}',
|
|
'{$prm['Td_DonorPOB']}',
|
|
'{$xxdob}',
|
|
'{$prm['Td_DonorHP']}',
|
|
'{$prm['Td_DonorPhone']}',
|
|
'{$prm['Td_DonorEmail']}',
|
|
'1',
|
|
'{$prm['Td_DonorIDNumber']}',
|
|
'{$prm['Td_DonorNote']}',
|
|
'{$prm['Td_DonorM_JobID']}',
|
|
'{$prm['Td_DonorAddress']}',
|
|
'{$prm['Td_DonorAddressOffice']}',
|
|
'{$prm['Td_DonorKesatuan']}',
|
|
'{$prm['Td_DonorBB']}',
|
|
'{$prm['Td_DonorTB']}',
|
|
'{$userid}'
|
|
);
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$last_id = $this->db_onedev->insert_id();
|
|
$td_donor = $this->db_onedev->query("SELECT Td_DonorNoReg FROM one_bb.td_donor WHERE Td_DonorID = $last_id")->row();
|
|
$nomor_donor = $td_donor->Td_DonorNoReg;
|
|
$querylog ="INSERT INTO one_bb.td_donorlog (
|
|
Td_DonorLogTd_DonorID,
|
|
Td_DonorLogNoReg,
|
|
Td_DonorLogName,
|
|
Td_DonorLogM_TitleID,
|
|
Td_DonorLogM_SexID,
|
|
Td_DonorLogM_ReligionID,
|
|
Td_DonorLogPOB,
|
|
Td_DonorLogDOB,
|
|
Td_DonorLogHP,
|
|
Td_DonorLogPhone,
|
|
Td_DonorLogEmail,
|
|
Td_DonorLogM_IdTypeID,
|
|
Td_DonorLogIDNumber,
|
|
Td_DonorLogNote,
|
|
Td_DonorLogM_JobID,
|
|
Td_DonorLogAddress,
|
|
Td_DonorLogAddressOffice,
|
|
Td_DonorKesatuan,
|
|
Td_DonorBB,
|
|
Td_DonorTB,
|
|
Td_DonorLogUserID)
|
|
VALUES(
|
|
'{$last_id}',
|
|
'{$nomor_donor}',
|
|
'{$prm['Td_DonorName']}',
|
|
'{$prm['Td_DonorM_TitleID']}',
|
|
'{$prm['Td_DonorM_SexID']}',
|
|
'{$prm['Td_DonorM_ReligionID']}',
|
|
'{$prm['Td_DonorPOB']}',
|
|
'{$xxdob}',
|
|
'{$prm['Td_DonorHP']}',
|
|
'{$prm['Td_DonorPhone']}',
|
|
'{$prm['Td_DonorEmail']}',
|
|
'1',
|
|
'{$prm['Td_DonorIDNumber']}',
|
|
'{$prm['Td_DonorNote']}',
|
|
'{$prm['Td_DonorM_JobID']}',
|
|
'{$prm['Td_DonorAddress']}',
|
|
'{$prm['Td_DonorAddressOffice']}',
|
|
'{$prm['Td_DonorKesatuan']}',
|
|
'{$prm['Td_DonorBB']}',
|
|
'{$prm['Td_DonorTB']}',
|
|
'{$userid}'
|
|
);
|
|
";
|
|
//echo $query;
|
|
$rowslog = $this->db_onedev->query($querylog);
|
|
}else{
|
|
$query ="UPDATE one_bb.td_donor SET
|
|
Td_DonorName = '{$prm['Td_DonorName']}',
|
|
Td_DonorM_TitleID = '{$prm['Td_DonorM_TitleID']}',
|
|
Td_DonorM_SexID = '{$prm['Td_DonorM_SexID']}',
|
|
Td_DonorM_ReligionID = '{$prm['Td_DonorM_ReligionID']}',
|
|
Td_DonorPOB = '{$prm['Td_DonorPOB']}',
|
|
Td_DonorDOB = '{$xxdob}',
|
|
Td_DonorHP = '{$prm['Td_DonorHP']}',
|
|
Td_DonorPhone = '{$prm['Td_DonorPhone']}',
|
|
Td_DonorEmail = '{$prm['Td_DonorEmail']}',
|
|
Td_DonorM_IdTypeID = '1',
|
|
Td_DonorIDNumber = '{$prm['Td_DonorIDNumber']}',
|
|
Td_DonorNote = '{$prm['Td_DonorNote']}',
|
|
Td_DonorM_JobID = '{$prm['Td_DonorM_JobID']}',
|
|
Td_DonorAddress = '{$prm['Td_DonorAddress']}',
|
|
Td_DonorAddressOffice = '{$prm['Td_DonorAddressOffice']}',
|
|
Td_DonorKesatuan = '{$prm['Td_DonorKesatuan']}',
|
|
Td_DonorBB = '{$prm['Td_DonorBB']}',
|
|
Td_DonorTB = '{$prm['Td_DonorTB']}',
|
|
Td_DonorUserID = {$userid}
|
|
WHERE
|
|
Td_DonorID = '{$prm['Td_DonorID']}'
|
|
";
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$querylog ="INSERT INTO one_bb.td_donorlog (
|
|
Td_DonorLogTd_DonorID,
|
|
Td_DonorLogNoReg,
|
|
Td_DonorLogName,
|
|
Td_DonorLogM_TitleID,
|
|
Td_DonorLogM_SexID,
|
|
Td_DonorLogM_ReligionID,
|
|
Td_DonorLogPOB,
|
|
Td_DonorLogDOB,
|
|
Td_DonorLogHP,
|
|
Td_DonorLogPhone,
|
|
Td_DonorLogEmail,
|
|
Td_DonorLogM_IdTypeID,
|
|
Td_DonorLogIDNumber,
|
|
Td_DonorLogNote,
|
|
Td_DonorLogM_JobID,
|
|
Td_DonorLogAddress,
|
|
Td_DonorLogAddressOffice,
|
|
Td_DonorKesatuan,
|
|
Td_DonorBB,
|
|
Td_DonorTB,
|
|
Td_DonorLogUserID)
|
|
VALUES('{$prm['Td_DonorID']}',
|
|
'{$prm['Td_DonorNoReg']}',
|
|
'{$prm['Td_DonorName']}',
|
|
'{$prm['Td_DonorM_TitleID']}',
|
|
'{$prm['Td_DonorM_SexID']}',
|
|
'{$prm['Td_DonorM_ReligionID']}',
|
|
'{$prm['Td_DonorPOB']}',
|
|
'{$xxdob}',
|
|
'{$prm['Td_DonorHP']}',
|
|
'{$prm['Td_DonorPhone']}',
|
|
'{$prm['Td_DonorEmail']}',
|
|
'1',
|
|
'{$prm['Td_DonorIDNumber']}',
|
|
'{$prm['Td_DonorNote']}',
|
|
'{$prm['Td_DonorM_JobID']}',
|
|
'{$prm['Td_DonorAddress']}',
|
|
'{$prm['Td_DonorAddressOffice']}',
|
|
'{$prm['Td_DonorKesatuan']}',
|
|
'{$prm['Td_DonorBB']}',
|
|
'{$prm['Td_DonorTB']}',
|
|
'{$userid}'
|
|
);
|
|
";
|
|
//echo $query;
|
|
$rowslog = $this->db_onedev->query($querylog);
|
|
$last_id = $prm['Td_DonorID'];
|
|
}
|
|
|
|
|
|
|
|
$queryorder ="INSERT INTO one_bb.td_order (
|
|
Td_OrderTd_DonorID,
|
|
Td_OrderDate,
|
|
Td_OrderNumber,
|
|
Td_OrderTd_BloodCategoryID,
|
|
Td_OrderCMNumber,
|
|
Td_OrderDonorType,
|
|
Td_OrderUserID)
|
|
VALUES(
|
|
'{$last_id}',
|
|
date(now()),
|
|
one_bb.fn_numbering('TO'),
|
|
'{$prm['Td_OrderTd_BloodCategoryID']}',
|
|
'{$prm['Td_OrderCMNumber']}',
|
|
'{$prm['Td_OrderDonorType']}',
|
|
'{$userid}'
|
|
);
|
|
";
|
|
//echo $query;
|
|
$rowsorder = $this->db_onedev->query($queryorder);
|
|
$order_id = $this->db_onedev->insert_id();
|
|
|
|
$querypatient ="INSERT INTO one_bb.td_orderpatient (
|
|
Td_OrderPatientTd_OrderID,
|
|
Td_OrderPatientNoReg,
|
|
Td_OrderPatientName,
|
|
Td_OrderPatientRoom,
|
|
Td_OrderPatientUserID)
|
|
VALUES(
|
|
'{$order_id}',
|
|
'{$prm['Td_OrderPatientNoReg']}',
|
|
'{$prm['Td_OrderPatientName']}',
|
|
'{$prm['Td_OrderPatientRoom']}',
|
|
'{$userid}'
|
|
);
|
|
";
|
|
//echo $query;
|
|
$rowspatient = $this->db_onedev->query($querypatient);
|
|
$patient_id = $this->db_onedev->insert_id();
|
|
|
|
$td_order = $this->db_onedev->query("SELECT Td_OrderNumber FROM one_bb.td_order WHERE Td_OrderID = $last_id")->row();
|
|
$nomor = $td_order->Td_OrderNumber;
|
|
$x = 1;
|
|
/*
|
|
while($x <= 2) {
|
|
$querybag ="INSERT INTO one_bb.td_orderbag (
|
|
Td_OrderBagTd_OrderID,
|
|
Td_OrderBagNumber,
|
|
Td_OrderBagUserID)
|
|
VALUES(
|
|
'{$last_id}',
|
|
'BAG{$nomor}$x',
|
|
'{$userid}'
|
|
);
|
|
";
|
|
//echo $querybag;
|
|
$rowsbag = $this->db_onedev->query($querybag);
|
|
$bag_id = $this->db_onedev->insert_id();
|
|
$x++;
|
|
}
|
|
*/
|
|
|
|
}else{
|
|
$query ="UPDATE one_bb.td_donor SET
|
|
Td_DonorName = '{$prm['Td_DonorName']}',
|
|
Td_DonorM_TitleID = '{$prm['Td_DonorM_TitleID']}',
|
|
Td_DonorM_SexID = '{$prm['Td_DonorM_SexID']}',
|
|
Td_DonorM_ReligionID = '{$prm['Td_DonorM_ReligionID']}',
|
|
Td_DonorPOB = '{$prm['Td_DonorPOB']}',
|
|
Td_DonorDOB = '{$xxdob}',
|
|
Td_DonorHP = '{$prm['Td_DonorHP']}',
|
|
Td_DonorPhone = '{$prm['Td_DonorPhone']}',
|
|
Td_DonorEmail = '{$prm['Td_DonorEmail']}',
|
|
Td_DonorM_IdTypeID = '1',
|
|
Td_DonorIDNumber = '{$prm['Td_DonorIDNumber']}',
|
|
Td_DonorNote = '{$prm['Td_DonorNote']}',
|
|
Td_DonorM_JobID = '{$prm['Td_DonorM_JobID']}',
|
|
Td_DonorAddress = '{$prm['Td_DonorAddress']}',
|
|
Td_DonorAddressOffice = '{$prm['Td_DonorAddressOffice']}',
|
|
Td_DonorKesatuan = '{$prm['Td_DonorKesatuan']}',
|
|
Td_DonorBB = '{$prm['Td_DonorBB']}',
|
|
Td_DonorTB = '{$prm['Td_DonorTB']}',
|
|
Td_DonorUserID = {$userid}
|
|
WHERE
|
|
Td_DonorID = '{$prm['Td_DonorID']}'
|
|
";
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$querylog ="INSERT INTO one_bb.td_donorlog (
|
|
Td_DonorLogTd_DonorID,
|
|
Td_DonorLogNoReg,
|
|
Td_DonorLogName,
|
|
Td_DonorLogM_TitleID,
|
|
Td_DonorLogM_SexID,
|
|
Td_DonorLogM_ReligionID,
|
|
Td_DonorLogPOB,
|
|
Td_DonorLogDOB,
|
|
Td_DonorLogHP,
|
|
Td_DonorLogPhone,
|
|
Td_DonorLogEmail,
|
|
Td_DonorLogM_IdTypeID,
|
|
Td_DonorLogIDNumber,
|
|
Td_DonorLogNote,
|
|
Td_DonorLogM_JobID,
|
|
Td_DonorLogAddress,
|
|
Td_DonorLogAddressOffice,
|
|
Td_DonorLogUserID)
|
|
VALUES('{$prm['Td_DonorID']}',
|
|
'{$prm['Td_DonorNoReg']}',
|
|
'{$prm['Td_DonorName']}',
|
|
'{$prm['Td_DonorM_TitleID']}',
|
|
'{$prm['Td_DonorM_SexID']}',
|
|
'{$prm['Td_DonorM_ReligionID']}',
|
|
'{$prm['Td_DonorPOB']}',
|
|
'{$xxdob}',
|
|
'{$prm['Td_DonorHP']}',
|
|
'{$prm['Td_DonorPhone']}',
|
|
'{$prm['Td_DonorEmail']}',
|
|
'1',
|
|
'{$prm['Td_DonorIDNumber']}',
|
|
'{$prm['Td_DonorNote']}',
|
|
'{$prm['Td_DonorM_JobID']}',
|
|
'{$prm['Td_DonorAddress']}',
|
|
'{$prm['Td_DonorAddressOffice']}',
|
|
'{$userid}'
|
|
);
|
|
";
|
|
//echo $query;
|
|
$rowslog = $this->db_onedev->query($querylog);
|
|
}
|
|
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function neworder(){
|
|
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;
|
|
$xxdob = '0000-00-00';
|
|
if($prm['Td_DonorDOB'] != ''){
|
|
$x_dob = $prm['Td_DonorDOB'];
|
|
$updated_dob = substr($x_dob, 0,2).'-'.substr($x_dob, 2,2).'-'.substr($x_dob, 4,4);
|
|
$xxdob = date("Y-m-d", strtotime($updated_dob));
|
|
}
|
|
$query ="INSERT INTO one_bb.td_donor (
|
|
Td_DonorNoReg,
|
|
Td_DonorName,
|
|
Td_DonorM_TitleID,
|
|
Td_DonorM_SexID,
|
|
Td_DonorM_ReligionID,
|
|
Td_DonorPOB,
|
|
Td_DonorDOB,
|
|
Td_DonorHP,
|
|
Td_DonorPhone,
|
|
Td_DonorEmail,
|
|
Td_DonorM_IdTypeID,
|
|
Td_DonorIDNumber,
|
|
Td_DonorNote,
|
|
Td_DonorJob,
|
|
Td_DonorAddress,
|
|
Td_DonorAddressOffice,
|
|
Td_DonorTd_BloodRhesusID,
|
|
Td_DonorTd_BloodTypeID,
|
|
Td_DonorKesatuan,
|
|
Td_DonorBB,
|
|
Td_DonorTB,
|
|
Td_DonorUserID)
|
|
VALUES(
|
|
one_bb.fn_numbering('TD'),
|
|
'{$prm['Td_DonorName']}',
|
|
'{$prm['Td_DonorM_TitleID']}',
|
|
'{$prm['Td_DonorM_SexID']}',
|
|
'{$prm['Td_DonorM_ReligionID']}',
|
|
'{$prm['Td_DonorPOB']}',
|
|
'{$xxdob}',
|
|
'{$prm['Td_DonorHP']}',
|
|
'{$prm['Td_DonorPhone']}',
|
|
'{$prm['Td_DonorEmail']}',
|
|
'1',
|
|
'{$prm['Td_DonorIDNumber']}',
|
|
'{$prm['Td_DonorNote']}',
|
|
'{$prm['Td_DonorJob']}',
|
|
'{$prm['Td_DonorAddress']}',
|
|
'{$prm['Td_DonorAddressOffice']}',
|
|
'{$prm['Td_DonorTd_BloodRhesusID']}',
|
|
'{$prm['Td_DonorTd_BloodTypeID']}',
|
|
'{$prm['Td_DonorKesatuan']}',
|
|
'{$prm['Td_DonorBB']}',
|
|
'{$prm['Td_DonorTB']}',
|
|
'{$userid}'
|
|
);
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$last_id = $this->db_onedev->insert_id();
|
|
$td_donor = $this->db_onedev->query("SELECT Td_DonorNoReg FROM one_bb.td_donor WHERE Td_DonorID = $last_id")->row();
|
|
$nomor_donor = $td_donor->Td_DonorNoReg;
|
|
$querylog ="INSERT INTO one_bb.td_donorlog (
|
|
Td_DonorLogTd_DonorID,
|
|
Td_DonorLogNoReg,
|
|
Td_DonorLogName,
|
|
Td_DonorLogM_TitleID,
|
|
Td_DonorLogM_SexID,
|
|
Td_DonorLogM_ReligionID,
|
|
Td_DonorLogPOB,
|
|
Td_DonorLogDOB,
|
|
Td_DonorLogHP,
|
|
Td_DonorLogPhone,
|
|
Td_DonorLogEmail,
|
|
Td_DonorLogM_IdTypeID,
|
|
Td_DonorLogIDNumber,
|
|
Td_DonorLogNote,
|
|
Td_DonorLogJob,
|
|
Td_DonorLogAddress,
|
|
Td_DonorLogAddressOffice,
|
|
Td_DonorLogTd_BloodRhesusID,
|
|
Td_DonorLogTd_BloodTypeID,
|
|
Td_DonorLogUserID)
|
|
VALUES(
|
|
'{$last_id}',
|
|
'{$nomor_donor}',
|
|
'{$prm['Td_DonorName']}',
|
|
'{$prm['Td_DonorM_TitleID']}',
|
|
'{$prm['Td_DonorM_SexID']}',
|
|
'{$prm['Td_DonorM_ReligionID']}',
|
|
'{$prm['Td_DonorPOB']}',
|
|
'{$xxdob}',
|
|
'{$prm['Td_DonorHP']}',
|
|
'{$prm['Td_DonorPhone']}',
|
|
'{$prm['Td_DonorEmail']}',
|
|
'1',
|
|
'{$prm['Td_DonorIDNumber']}',
|
|
'{$prm['Td_DonorNote']}',
|
|
'{$prm['Td_DonorJob']}',
|
|
'{$prm['Td_DonorAddress']}',
|
|
'{$prm['Td_DonorAddressOffice']}',
|
|
'{$prm['Td_DonorTd_BloodRhesusID']}',
|
|
'{$prm['Td_DonorTd_BloodTypeID']}',
|
|
'{$userid}'
|
|
);
|
|
";
|
|
//echo $query;
|
|
$rowslog = $this->db_onedev->query($querylog);
|
|
|
|
|
|
$queryorder ="INSERT INTO one_bb.td_order (
|
|
Td_OrderTd_DonorID,
|
|
Td_OrderDate,
|
|
Td_OrderNumber,
|
|
Td_OrderTd_BloodCategoryID,
|
|
Td_OrderCMNumber,
|
|
Td_OrderDonorType,
|
|
Td_OrderUserID)
|
|
VALUES(
|
|
'{$last_id}',
|
|
date(now()),
|
|
one_bb.fn_numbering('TO'),
|
|
'{$prm['Td_OrderTd_BloodCategoryID']}',
|
|
'{$prm['Td_OrderCMNumber']}',
|
|
'{$prm['Td_OrderDonorType']}',
|
|
'{$userid}'
|
|
);
|
|
";
|
|
//echo $query;
|
|
$rowsorder = $this->db_onedev->query($queryorder);
|
|
$order_id = $this->db_onedev->insert_id();
|
|
|
|
$querypatient ="INSERT INTO one_bb.td_orderpatient (
|
|
Td_OrderPatientTd_OrderID,
|
|
Td_OrderPatientNoReg,
|
|
Td_OrderPatientName,
|
|
Td_OrderPatientRoom,
|
|
Td_OrderPatientUserID)
|
|
VALUES(
|
|
'{$last_id}',
|
|
'{$prm['Td_OrderPatientNoReg']}',
|
|
'{$prm['Td_OrderPatientName']}',
|
|
'{$prm['Td_OrderPatientRoom']}',
|
|
'{$userid}'
|
|
);
|
|
";
|
|
//echo $query;
|
|
$rowspatient = $this->db_onedev->query($querypatient);
|
|
$patient_id = $this->db_onedev->insert_id();
|
|
|
|
$td_order = $this->db_onedev->query("SELECT Td_OrderNumber FROM one_bb.td_order WHERE Td_OrderID = $last_id")->row();
|
|
$nomor = $td_order->Td_OrderNumber;
|
|
$x = 1;
|
|
|
|
/*while($x <= 2) {
|
|
$querybag ="INSERT INTO one_bb.td_orderbag (
|
|
Td_OrderBagTd_OrderID,
|
|
Td_OrderBagNumber,
|
|
Td_OrderBagUserID)
|
|
VALUES(
|
|
'{$last_id}',
|
|
'BAG{$nomor}$x',
|
|
'{$userid}'
|
|
);
|
|
";
|
|
//echo $querybag;
|
|
$rowsbag = $this->db_onedev->query($querybag);
|
|
$bag_id = $this->db_onedev->insert_id();
|
|
$x++;
|
|
}
|
|
*/
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK'),
|
|
"id" => $last_id
|
|
);
|
|
//sipe tambah log doctor
|
|
$prm["Td_OrderID"] = $last_id;
|
|
$prm["Td_OrderM_UserID"] = $userid;
|
|
|
|
/* $sql = "SELECT * FROM td_order WHERE Td_OrderID = {$last_id}";
|
|
$row_log_now = $this->db_onedev->query($sql)->row_array();
|
|
$data_log = array('before'=>array(),'now'=>$row_log_now );
|
|
$d_doctor = json_encode($data_log);
|
|
$this->db_onedev->query("call makasar_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_onedev->query("SELECT COUNT(*) as countx FROM td_orderaddress WHERE Td_OrderAddressTd_OrderOldCode = '{$prm['Td_OrderAddressTd_OrderOldCode']}' AND Td_OrderAddressIsActive = 'Y'")->row()->countx;
|
|
|
|
//echo $this->db_onedev->last_query();
|
|
/*if($count_addrs == 0){
|
|
$prm['Td_OrderAddressNote'] = 'Utama';
|
|
}
|
|
else{
|
|
$count_addrs_utama = $this->db_onedev->query("SELECT COUNT(*) as countx FROM td_orderaddress WHERE Td_OrderAddressTd_OrderOldCode = '{$prm['Td_OrderAddressTd_OrderOldCode']}' AND Td_OrderAddressNote = 'Utama' AND Td_OrderAddressIsActive = 'Y'")->row()->countx;
|
|
if($count_addrs_utama > 0 && strtolower($prm['Td_OrderAddressNote']) == 'utama'){
|
|
$rx = date('YmdHis');
|
|
$prm['Td_OrderAddressNote'] = 'Utama_'.$rx;
|
|
}
|
|
}*/
|
|
$query ="INSERT INTO td_orderaddress (
|
|
Td_OrderAddressTd_OrderID,
|
|
Td_OrderAddressNote,
|
|
Td_OrderAddressDescription,
|
|
Td_OrderAddressM_KelurahanID,
|
|
Td_OrderAddressNat_JpaID,
|
|
Td_OrderAddressLastUpdated,
|
|
Td_OrderAddressCreated,
|
|
Td_OrderAddressM_UserID
|
|
)
|
|
VALUES(
|
|
'{$prm['Td_OrderAddressTd_OrderID']}',
|
|
'{$prm['Td_OrderAddressNote']}',
|
|
'{$prm['Td_OrderAddressDescription']}',
|
|
'{$prm['Td_OrderAddressM_KelurahanID']}',
|
|
'{$prm['Td_OrderAddressNat_JpaID']}',
|
|
NOW(),
|
|
NOW(),
|
|
$userid
|
|
)
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$last_id = $this->db_onedev->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_onedev->query($sql)->result_array();
|
|
foreach($branches as $k => $v){
|
|
try {
|
|
$array_prm = array();
|
|
$array_ids = array();
|
|
$sql = "SELECT *
|
|
FROM doctortobranch
|
|
JOIN td_orderaddress ON DoctorToBranchTd_OrderID = Td_OrderAddressID
|
|
WHERE
|
|
DoctorToBranchType = 'A' AND
|
|
DoctorToBranchStatus = 'N' AND
|
|
DoctorToBranchM_BranchIPAddress = '{$v['M_BranchIPAddress']}'";
|
|
$data_not_sending = $this->db_onedev->query($sql)->result_array();
|
|
if($data_not_sending){
|
|
foreach($data_not_sending as $kx => $vx){
|
|
$x_arr = array(
|
|
'Td_OrderAddressID' => $vx['Td_OrderAddressID'],
|
|
'Td_OrderAddressTd_OrderID' => $vx['Td_OrderAddressTd_OrderID'],
|
|
'Td_OrderAddressNote' => $vx['Td_OrderAddressNote'],
|
|
'Td_OrderAddressDescription' => $vx['Td_OrderAddressDescription'],
|
|
'Td_OrderAddressM_KelurahanID' => $vx['Td_OrderAddressM_KelurahanID'] ,
|
|
'Td_OrderAddressNat_JpaID' => $vx['Td_OrderAddressNat_JpaID'],
|
|
'Td_OrderAddressM_UserID' => $userid
|
|
);
|
|
array_push($array_prm,$x_arr);
|
|
array_push($array_ids,$vx['DoctorToBranchID']);
|
|
}
|
|
}
|
|
|
|
$x_arr = array(
|
|
'Td_OrderAddressID' => $last_id,
|
|
'Td_OrderAddressTd_OrderID' => $prm['Td_OrderAddressTd_OrderID'],
|
|
'Td_OrderAddressNote' => $prm['Td_OrderAddressNote'],
|
|
'Td_OrderAddressDescription' => $prm['Td_OrderAddressDescription'],
|
|
'Td_OrderAddressM_KelurahanID' => $prm['Td_OrderAddressM_KelurahanID'] ,
|
|
'Td_OrderAddressNat_JpaID' => $prm['Td_OrderAddressNat_JpaID'],
|
|
'Td_OrderAddressM_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 (
|
|
DoctorToBranchTd_OrderID,
|
|
DoctorToBranchM_BranchIPAddress,
|
|
DoctorToBranchType,
|
|
DoctorToBranchCreated,
|
|
DoctorToBranchUserID
|
|
)
|
|
VALUES(
|
|
{$last_id},
|
|
'{$v['M_BranchIPAddress']}',
|
|
'A',
|
|
NOW(),
|
|
{$userid}
|
|
)";
|
|
//echo $sql;
|
|
$this->db_onedev->query($sql);
|
|
$last_xid = $this->db_onedev->insert_id();
|
|
//echo $last_xid;
|
|
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/newaddressdoctor/";
|
|
//echo $url;
|
|
//echo "Uploading : ".$prm['Td_OrderName'];
|
|
$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_onedev->query($sql);
|
|
if(count($array_ids) > 0){
|
|
foreach($array_ids as $ku => $vu){
|
|
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
|
WHERE
|
|
DoctorToBranchID = {$vu}";
|
|
$this->db_onedev->query($sql);
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
|
WHERE
|
|
DoctorToBranchID = {$last_xid}";
|
|
$this->db_onedev->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["Td_OrderM_UserID"] = $userid;
|
|
|
|
$sql = "SELECT * FROM td_orderaddress WHERE Td_OrderAddressID = {$last_id}";
|
|
$row_log_now = $this->db_onedev->query($sql)->row_array();
|
|
$data_log = array('before'=>array(),'now'=>$row_log_now );
|
|
$d_doctor = json_encode($data_log);
|
|
$this->db_onedev->query("call makasar_log.log_me('DOCTOR',{$prm['Td_OrderAddressTd_OrderID']},'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 td_order SET
|
|
Td_OrderIsActive = 'N'
|
|
WHERE
|
|
Td_OrderID = '{$prm['Td_OrderID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
/*if($rows){
|
|
$query ="UPDATE td_orderaddress SET
|
|
Td_OrderAddressIsActive = 'N',
|
|
Td_OrderAddressLastUpdated = now(),
|
|
Td_OrderUserID = {$userid}
|
|
WHERE
|
|
Td_OrderAddressTd_OrderID = '{$prm['Td_OrderID']}'
|
|
";
|
|
//echo $query;
|
|
$del_addr = $this->db_onedev->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_onedev->query($sql)->result_array();
|
|
foreach($branches as $k => $v){
|
|
try {
|
|
$sql = "INSERT INTO doctortobranch (
|
|
DoctorToBranchTd_OrderID,
|
|
DoctorToBranchM_BranchIPAddress,
|
|
DoctorToBranchType,
|
|
DoctorToBranchCreated,
|
|
DoctorToBranchUserID
|
|
)
|
|
VALUES(
|
|
{$last_id},
|
|
'{$v['M_BranchIPAddress']}',
|
|
'DD',
|
|
NOW(),
|
|
{$userid}
|
|
)";
|
|
//echo $sql;
|
|
$this->db_onedev->query($sql);
|
|
$last_xid = $this->db_onedev->insert_id();
|
|
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/deletedoctor/";
|
|
//echo "Uploading : ".$prm['Td_OrderName'];
|
|
$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_onedev->query($sql);
|
|
}
|
|
else{
|
|
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
|
WHERE
|
|
DoctorToBranchID = {$last_xid}";
|
|
$this->db_onedev->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["Td_OrderM_UserID"] = $userid;
|
|
$d_doctor = json_encode($prm);
|
|
$this->db_onedev->query("call makasar_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 td_orderaddress.*,
|
|
M_KelurahanName,
|
|
M_DistrictID,
|
|
M_DistrictName,
|
|
M_CityID,
|
|
M_CityName,Nat_JpaName,
|
|
'' as action
|
|
FROM td_orderaddress
|
|
JOIN m_kelurahan ON Td_OrderAddressM_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 Td_OrderAddressNat_JpaID = Nat_JpaID
|
|
WHERE
|
|
Td_OrderAddressIsActive = 'Y' AND Td_OrderAddressTd_OrderID = ?
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
|
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
|
|
|
}
|
|
}
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function savenewaddress(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$prm = $this->sys_input;
|
|
$count_addrs = $this->db_onedev->query("SELECT COUNT(*) as countx FROM td_orderaddress WHERE Td_OrderAddressTd_OrderOldCode = '{$prm['Td_OrderAddressTd_OrderOldCode']}' AND Td_OrderAddressIsActive = 'Y'")->row()->countx;
|
|
|
|
//echo $this->db_onedev->last_query();
|
|
/*if($count_addrs == 0){
|
|
$prm['Td_OrderAddressNote'] = 'Utama';
|
|
}
|
|
else{
|
|
$count_addrs_utama = $this->db_onedev->query("SELECT COUNT(*) as countx FROM td_orderaddress WHERE Td_OrderAddressTd_OrderOldCode = '{$prm['Td_OrderAddressTd_OrderOldCode']}' AND Td_OrderAddressNote = 'Utama' AND Td_OrderAddressIsActive = 'Y'")->row()->countx;
|
|
if($count_addrs_utama > 0 && strtolower($prm['Td_OrderAddressNote']) == 'utama'){
|
|
$rx = date('YmdHis');
|
|
$prm['Td_OrderAddressNote'] = 'Utama_'.$rx;
|
|
}
|
|
}*/
|
|
$query ="INSERT INTO td_orderaddress (
|
|
Td_OrderAddressTd_OrderID,
|
|
Td_OrderAddressNote,
|
|
Td_OrderAddressDescription,
|
|
Td_OrderAddressM_KelurahanID,
|
|
Td_OrderAddressNat_JpaID,
|
|
Td_OrderAddressLastUpdated,
|
|
Td_OrderAddressCreated,
|
|
Td_OrderAddressM_UserID
|
|
)
|
|
VALUES(
|
|
'{$prm['Td_OrderAddressTd_OrderID']}',
|
|
'{$prm['Td_OrderAddressNote']}',
|
|
'{$prm['Td_OrderAddressDescription']}',
|
|
'{$prm['Td_OrderAddressM_KelurahanID']}',
|
|
'{$prm['Td_OrderAddressNat_JpaID']}',
|
|
NOW(),
|
|
NOW(),
|
|
$userid
|
|
)
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$last_id = $this->db_onedev->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_onedev->query($sql)->result_array();
|
|
foreach($branches as $k => $v){
|
|
try {
|
|
$array_prm = array();
|
|
$array_ids = array();
|
|
$sql = "SELECT *
|
|
FROM doctortobranch
|
|
JOIN td_orderaddress ON DoctorToBranchTd_OrderID = Td_OrderAddressID
|
|
WHERE
|
|
DoctorToBranchType = 'A' AND
|
|
DoctorToBranchStatus = 'N' AND
|
|
DoctorToBranchM_BranchIPAddress = '{$v['M_BranchIPAddress']}'";
|
|
$data_not_sending = $this->db_onedev->query($sql)->result_array();
|
|
if($data_not_sending){
|
|
foreach($data_not_sending as $kx => $vx){
|
|
$x_arr = array(
|
|
'Td_OrderAddressID' => $vx['Td_OrderAddressID'],
|
|
'Td_OrderAddressTd_OrderID' => $vx['Td_OrderAddressTd_OrderID'],
|
|
'Td_OrderAddressNote' => $vx['Td_OrderAddressNote'],
|
|
'Td_OrderAddressDescription' => $vx['Td_OrderAddressDescription'],
|
|
'Td_OrderAddressM_KelurahanID' => $vx['Td_OrderAddressM_KelurahanID'] ,
|
|
'Td_OrderAddressNat_JpaID' => $vx['Td_OrderAddressNat_JpaID'],
|
|
'Td_OrderAddressM_UserID' => $userid
|
|
);
|
|
array_push($array_prm,$x_arr);
|
|
array_push($array_ids,$vx['DoctorToBranchID']);
|
|
}
|
|
}
|
|
|
|
$x_arr = array(
|
|
'Td_OrderAddressID' => $last_id,
|
|
'Td_OrderAddressTd_OrderID' => $prm['Td_OrderAddressTd_OrderID'],
|
|
'Td_OrderAddressNote' => $prm['Td_OrderAddressNote'],
|
|
'Td_OrderAddressDescription' => $prm['Td_OrderAddressDescription'],
|
|
'Td_OrderAddressM_KelurahanID' => $prm['Td_OrderAddressM_KelurahanID'] ,
|
|
'Td_OrderAddressNat_JpaID' => $prm['Td_OrderAddressNat_JpaID'],
|
|
'Td_OrderAddressM_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 (
|
|
DoctorToBranchTd_OrderID,
|
|
DoctorToBranchM_BranchIPAddress,
|
|
DoctorToBranchType,
|
|
DoctorToBranchCreated,
|
|
DoctorToBranchUserID
|
|
)
|
|
VALUES(
|
|
{$last_id},
|
|
'{$v['M_BranchIPAddress']}',
|
|
'A',
|
|
NOW(),
|
|
{$userid}
|
|
)";
|
|
//echo $sql;
|
|
$this->db_onedev->query($sql);
|
|
$last_xid = $this->db_onedev->insert_id();
|
|
//echo $last_xid;
|
|
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/newaddressdoctor/";
|
|
//echo $url;
|
|
//echo "Uploading : ".$prm['Td_OrderName'];
|
|
$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_onedev->query($sql);
|
|
if(count($array_ids) > 0){
|
|
foreach($array_ids as $ku => $vu){
|
|
$sql = "UPDATE doctortobranch set DoctorToBranchStatus = 'Y'
|
|
WHERE
|
|
DoctorToBranchID = {$vu}";
|
|
$this->db_onedev->query($sql);
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
|
WHERE
|
|
DoctorToBranchID = {$last_xid}";
|
|
$this->db_onedev->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["Td_OrderM_UserID"] = $userid;
|
|
$sql = "SELECT * FROM td_orderaddress WHERE Td_OrderAddressID = {$last_id}";
|
|
$row_log_now = $this->db_onedev->query($sql)->row_array();
|
|
$data_log = array('before'=>array(),'now'=>$row_log_now );
|
|
$d_doctor = json_encode($data_log);
|
|
$this->db_onedev->query("call makasar_log.log_me('DOCTOR',{$prm['Td_OrderAddressTd_OrderID']},'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 td_orderaddress WHERE Td_OrderAddressID = {$prm['Td_OrderAddressID']}";
|
|
$row_log_before = $this->db_onedev->query($sql)->row_array();
|
|
|
|
$query ="UPDATE td_orderaddress SET
|
|
Td_OrderAddressTd_OrderID = '{$prm['Td_OrderAddressTd_OrderID']}',
|
|
Td_OrderAddressNote = '{$prm['Td_OrderAddressNote']}',
|
|
Td_OrderAddressDescription = '{$prm['Td_OrderAddressDescription']}',
|
|
Td_OrderAddressM_KelurahanID = '{$prm['Td_OrderAddressM_KelurahanID']}',
|
|
Td_OrderAddressNat_JpaID = '{$prm['Td_OrderAddressNat_JpaID']}',
|
|
Td_OrderAddressLastUpdated = now(),
|
|
Td_OrderAddressM_UserID = {$userid}
|
|
WHERE
|
|
Td_OrderAddressID = '{$prm['Td_OrderAddressID']}'
|
|
";
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$last_id = $prm['Td_OrderAddressID'];
|
|
/*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_onedev->query($sql)->result_array();
|
|
foreach($branches as $k => $v){
|
|
try {
|
|
$sql = "INSERT INTO doctortobranch (
|
|
DoctorToBranchTd_OrderID,
|
|
DoctorToBranchM_BranchIPAddress,
|
|
DoctorToBranchType,
|
|
DoctorToBranchCreated,
|
|
DoctorToBranchUserID
|
|
)
|
|
VALUES(
|
|
{$prm['Td_OrderAddressID']},
|
|
'{$v['M_BranchIPAddress']}',
|
|
'UA',
|
|
NOW(),
|
|
{$userid}
|
|
)";
|
|
//echo $sql;
|
|
$this->db_onedev->query($sql);
|
|
$last_xid = $this->db_onedev->insert_id();
|
|
//echo $last_xid;
|
|
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/updateaddressdoctor/";
|
|
//echo $url;
|
|
//echo "Uploading : ".$prm['Td_OrderName'];
|
|
$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_onedev->query($sql);
|
|
}
|
|
else{
|
|
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
|
WHERE
|
|
DoctorToBranchID = {$last_xid}";
|
|
$this->db_onedev->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["Td_OrderM_UserID"] = $userid;
|
|
|
|
$sql = "SELECT * FROM td_orderaddress WHERE Td_OrderAddressID = {$last_id}";
|
|
$row_log_now = $this->db_onedev->query($sql)->row_array();
|
|
$data_log = array('before'=>$row_log_before,'now'=>$row_log_now );
|
|
$d_doctor = json_encode($data_log);
|
|
$this->db_onedev->query("call makasar_log.log_me('DOCTOR',{$prm['Td_OrderAddressTd_OrderID']},'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 td_orderaddress WHERE Td_OrderAddressID = {$prm['Td_OrderAddressID']}";
|
|
$row_log_before = $this->db_onedev->query($sql)->row_array();
|
|
|
|
$query ="UPDATE td_orderaddress SET
|
|
Td_OrderAddressIsActive = 'N',
|
|
Td_OrderAddressLastUpdated = now(),
|
|
Td_OrderAddressM_UserID = {$userid}
|
|
WHERE
|
|
Td_OrderAddressID = '{$prm['Td_OrderAddressID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->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_onedev->query($sql)->result_array();
|
|
foreach($branches as $k => $v){
|
|
try {
|
|
$sql = "INSERT INTO doctortobranch (
|
|
DoctorToBranchTd_OrderID,
|
|
DoctorToBranchM_BranchIPAddress,
|
|
DoctorToBranchType,
|
|
DoctorToBranchCreated,
|
|
DoctorToBranchUserID
|
|
)
|
|
VALUES(
|
|
{$last_id},
|
|
'{$v['M_BranchIPAddress']}',
|
|
'DA',
|
|
NOW(),
|
|
{$userid}
|
|
)";
|
|
//echo $sql;
|
|
$this->db_onedev->query($sql);
|
|
$last_xid = $this->db_onedev->insert_id();
|
|
//echo $last_xid;
|
|
$url = "http://".$v['M_BranchIPAddress']."/one-api/tools/marketing/deleteaddressdoctor/";
|
|
//echo $url;
|
|
//echo "Uploading : ".$prm['Td_OrderName'];
|
|
$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_onedev->query($sql);
|
|
}
|
|
else{
|
|
$sql = "UPDATE doctortobranch set DoctorToBranchRetry = DoctorToBranchRetry + 1
|
|
WHERE
|
|
DoctorToBranchID = {$last_xid}";
|
|
$this->db_onedev->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["Td_OrderM_UserID"] = $userid;
|
|
//$d_doctor = json_encode($prm);
|
|
//$this->db_onedev->query("call makasar_log.log_me('DOCTOR','DOCTOR_ADDR_DELETE','{$d_doctor}',$userid)");
|
|
$sql = "SELECT * FROM td_orderaddress WHERE Td_OrderAddressID = {$prm['Td_OrderAddressID']}";
|
|
$row_log_now = $this->db_onedev->query($sql)->row_array();
|
|
$data_log = array('before'=>$row_log_before,'now'=>$row_log_now );
|
|
$d_doctor = json_encode($data_log);
|
|
$this->db_onedev->query("call makasar_log.log_me('DOCTOR',{$prm['Td_OrderAddressTd_OrderID']},'DOCTOR_ADDR_EDIT','{$d_doctor}',$userid)");
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
}
|