Initial import
This commit is contained in:
50
one-api/application/controllers/v1/preorder/Imgqrcode.php
Normal file
50
one-api/application/controllers/v1/preorder/Imgqrcode.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
use Endroid\QrCode\ErrorCorrectionLevel;
|
||||
use Endroid\QrCode\LabelAlignment;
|
||||
use Endroid\QrCode\QrCode;
|
||||
use Endroid\QrCode\Response\QrCodeResponse;
|
||||
|
||||
class Imgqrcode extends CI_Controller {
|
||||
function test() {
|
||||
$qrCode = new QrCode('Life is too short to be generating QR codes');
|
||||
|
||||
header('Content-Type: '.$qrCode->getContentType());
|
||||
echo $qrCode->writeString();
|
||||
}
|
||||
function show($qrcode) {
|
||||
$qrCode = new QrCode("pre-order qrcode\ngenerated by s.a.s\n" . "[". $qrcode ."]");
|
||||
$qrCode->setSize(300);
|
||||
// Set advanced options
|
||||
$qrCode->setWriterByName('png');
|
||||
$qrCode->setMargin(10);
|
||||
$qrCode->setEncoding('UTF-8');
|
||||
$qrCode->setErrorCorrectionLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::HIGH));
|
||||
$qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]);
|
||||
$qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]);
|
||||
$qrCode->setLabel('S.A.S PreOrder', 16, FCPATH .'/assets/fonts/noto_sans.otf', LabelAlignment::CENTER);
|
||||
$qrCode->setLogoPath(FCPATH . '/assets/images/logo-sas.jpg');
|
||||
$qrCode->setLogoWidth(150);
|
||||
$qrCode->setValidateResult(false);
|
||||
header('Content-Type: '.$qrCode->getContentType());
|
||||
echo $qrCode->writeString();
|
||||
}
|
||||
function index() {
|
||||
$qrCode = new QrCode("TUV345");
|
||||
$qrCode->setSize(300);
|
||||
//
|
||||
// Set advanced options
|
||||
$qrCode->setWriterByName('png');
|
||||
$qrCode->setMargin(10);
|
||||
$qrCode->setEncoding('UTF-8');
|
||||
$qrCode->setErrorCorrectionLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::HIGH));
|
||||
$qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]);
|
||||
$qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]);
|
||||
$qrCode->setLabel('S.A.S PreOrder', 16, FCPATH .'/assets/fonts/noto_sans.otf', LabelAlignment::CENTER);
|
||||
$qrCode->setLogoPath(FCPATH . '/assets/images/logo-sas.jpg');
|
||||
$qrCode->setLogoWidth(150);
|
||||
$qrCode->setValidateResult(false);
|
||||
header('Content-Type: '.$qrCode->getContentType());
|
||||
echo $qrCode->writeString();
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
class Android extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
var $staffID, $userID;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->staffID = 0;
|
||||
$sql = "select M_UserM_StaffID from m_user where M_UserID = ?";
|
||||
$qry = $this->db_onedev->query($sql,array($this->sys_user["M_UserID"]));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if(count($rows) > 0 ) $this->staffID = $rows[0]["M_UserM_StaffID"];
|
||||
}
|
||||
$this->userID = $this->sys_user["M_UserID"];
|
||||
}
|
||||
// data yg di upload
|
||||
// status : Arrival , Cancel / Serve , Lokasi
|
||||
// data lain : Catatan tambahan
|
||||
/*
|
||||
drop table if exists address_loc;
|
||||
create table address_loc (
|
||||
Addres_LocID int not null auto_increment primary key,
|
||||
Address_LocM_PatientID int ,
|
||||
Address_LocM_PatientAddressID int,
|
||||
Address_LocLat decimal(12,9),
|
||||
Address_LocLng decimal(12,9),
|
||||
Address_LocM_UserID int,
|
||||
Address_LocCreated datetime default current_timestamp(),
|
||||
Address_LocUpdated datetime default current_timestamp()
|
||||
on update current_timestamp(),
|
||||
Address_LocIsActive varchar(1) default 'Y',
|
||||
key(Address_LocM_PatientID),
|
||||
key(Address_LocM_PatientAddressID),
|
||||
key(Address_LocIsActive),
|
||||
unique(Address_LocM_PatientAddressID)
|
||||
);
|
||||
*/
|
||||
function upload_order() {
|
||||
$orders = array();
|
||||
try {
|
||||
$orders= $this->sys_input["orders"];
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
$updated_no = "";
|
||||
$this->db_onedev->trans_start();
|
||||
|
||||
foreach($orders as $order) {
|
||||
$id = $order["PreOrder_HeaderID"];
|
||||
$patientID = $order["PreOrder_HeaderM_PatientID"];
|
||||
$addressID = $order["PreOrder_HeaderM_PatientAdrressID"];
|
||||
if ($updated_no != "") $updated_no .= ", ";
|
||||
$updated_no .= $order["PreOrder_HeaderNumber"];
|
||||
$updated_mark = "";
|
||||
if (isset($order["arrived"]) ) {
|
||||
//update arrival and lat lng
|
||||
if ($updated_mark != "") $updated_mark .= ",";
|
||||
$updated_mark .= "Dtg";
|
||||
}
|
||||
if (isset($order["note"])) {
|
||||
//add note
|
||||
if ($updated_mark != "") $updated_mark .= ",";
|
||||
$updated_mark .= "Cat";
|
||||
}
|
||||
if (isset($order["latlng"])) {
|
||||
$lat = $order["latlng"]["lat"];
|
||||
$lng = $order["latlng"]["lng"];
|
||||
$sql = "insert into address_loc(Address_LocM_PatientID, Address_LocM_PatientAddressID,
|
||||
Address_LocLat,Address_LocLng, Address_LocM_UserID)
|
||||
values(?,?,?,?,?)
|
||||
on duplicate key update
|
||||
set Address_LocLat = ? , Address_LocLng = ? , Address_LocM_UserID=?
|
||||
where Address_LocM_PatientAddressID = ? ";
|
||||
$this->db_onedev->query($sql, array($patientID, $addressID,
|
||||
$lat, $lng, $this->userID, $lat, $lng, $this->userID, $patientID) );
|
||||
}
|
||||
if (isset($order["status"])) {
|
||||
$status = $order["status"];
|
||||
foreach($status as $s) {
|
||||
$statusID = $s["statusID"];
|
||||
// 6 - ARRIVED , 3 - SERVE , 4 - DONE , 5 - CANCELLED
|
||||
// insert to log
|
||||
if ($status == 4 || $id == 5) {
|
||||
//update status
|
||||
$sql = "update one_preorder_dev.preorder_header
|
||||
set PreOrder_HeaderM_PreOrderStatusID = ?
|
||||
PreOrderM_UserID = ?
|
||||
where PreOrder_HeaderID = ?";
|
||||
}
|
||||
}
|
||||
//update status serve / cancel
|
||||
if ($updated_mark != "") $updated_mark .= ",";
|
||||
$is_cancel = false;
|
||||
if ($is_cancel) $updated_mark = "Cancel";
|
||||
$updated_mark .= "Serve";
|
||||
}
|
||||
}
|
||||
}
|
||||
function mark_order() {
|
||||
$ids = array();
|
||||
try {
|
||||
$ids= $this->sys_input["ids"];
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
foreach($ids as $id) {
|
||||
$sql = "update one_preorder_dev.preorder_header set PreOrder_HeaderDownloadedMobile='Y',
|
||||
PreOrder_HeaderM_UserID = ?
|
||||
where PreOrder_HeaderID = ?";
|
||||
$this->db_onedev->query($sql,array($this->sys_user["M_UserID"],$id));
|
||||
}
|
||||
echo json_encode( array(
|
||||
"status" => "OK"
|
||||
));
|
||||
}
|
||||
function download_order() {
|
||||
$date = date("Y-m-d");
|
||||
try {
|
||||
$date = $this->sys_input["date"];
|
||||
} catch(Exception $e) {
|
||||
|
||||
}
|
||||
$sql = "select PreOrder_HeaderID,PreOrder_HeaderNumbering, PreOrder_HeaderDate, PreOrder_HeaderTime,
|
||||
M_PatientAddressDescription,M_PatientAddressLat, M_PatientAddressLng,
|
||||
concat(M_TitleName,' ',M_PatientName) M_PatientName,
|
||||
PreOrder_HeaderPhone,M_KelurahanLat, M_KelurahanLng,
|
||||
concat(M_DoctorPrefix,' ',M_DoctorName,' ',M_DoctorSufix) M_DoctorName,
|
||||
M_KelurahanName,M_DistrictName,M_CityName
|
||||
from
|
||||
one_preorder_dev.preorder_header
|
||||
join m_patientaddress on M_PatientAddressID = PreOrder_HeaderM_PatientAdrressID
|
||||
join m_patient on PreOrder_HeaderM_PatientID = M_PatientID
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join m_doctor on PreOrder_HeaderM_DoctorID = M_DoctorID
|
||||
left join m_kelurahan on PreOrder_HeaderM_KelurahanID = M_KelurahanID
|
||||
left join m_district on M_KelurahanM_DistrictID= M_DistrictID
|
||||
left join m_city on M_DistrictM_CityID = M_CityID
|
||||
where
|
||||
PreOrder_HeaderDate = ?
|
||||
and PreOrder_HeaderM_PreOrderStatusID=2
|
||||
and PreOrder_HeaderDownloadedMobile = 'N'
|
||||
and PreOrder_HeaderM_StaffID = ?";
|
||||
|
||||
$qry = $this->db_onedev->query($sql,array($date,$this->staffID));
|
||||
$order = array();
|
||||
if ($qry) {
|
||||
$order = $qry->result_array();
|
||||
foreach($order as $idx => $o) {
|
||||
$id = $o["PreOrder_HeaderID"];
|
||||
$order[$idx]["test"] = $this->get_test($id);
|
||||
$order[$idx]["delivery"] = $this->get_delivery($id);
|
||||
}
|
||||
}
|
||||
echo json_encode( array(
|
||||
"status" => "OK",
|
||||
"data" => $order
|
||||
));
|
||||
}
|
||||
function get_test($id) {
|
||||
$sql = "select PreOrder_TestID, PreOrder_TestT_TestCode, PreOrder_TestT_TestName,
|
||||
PreOrder_TestPrice, PreOrder_TestDisc , PreOrder_TestDiscRp , PreOrder_TestTotal
|
||||
from
|
||||
one_preorder_dev.preorder_test
|
||||
where
|
||||
PreOrder_TestPreOrder_HeaderID = ?
|
||||
and PreOrder_TestIsActive = 'Y'";
|
||||
$qry = $this->db_onedev->query($sql,array($id));
|
||||
if ($qry) {
|
||||
return $qry->result_array();
|
||||
}
|
||||
return array();
|
||||
}
|
||||
function get_delivery($id) {
|
||||
$sql = "select PreOrder_DeliveryID, M_DeliveryName, PreOrder_DeliveryDestination
|
||||
from
|
||||
one_preorder_dev.preorder_delivery
|
||||
join m_delivery on PreOrder_DeliveryM_DeliveryID = M_DeliveryID
|
||||
where PreOrder_DeliveryPreOrder_HeaderID = ?
|
||||
and PreOrder_DeliveryIsActive = 'Y'";
|
||||
$qry = $this->db_onedev->query($sql,array($id));
|
||||
if ($qry) {
|
||||
return $qry->result_array();
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
1652
one-api/application/controllers/v1/preorder/home-service/Order.php
Normal file
1652
one-api/application/controllers/v1/preorder/home-service/Order.php
Normal file
File diff suppressed because it is too large
Load Diff
1671
one-api/application/controllers/v1/preorder/home-service/Receive.php
Normal file
1671
one-api/application/controllers/v1/preorder/home-service/Receive.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,481 @@
|
||||
<?php
|
||||
class Staff extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Staff Home Service 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 = $prm["nama"];
|
||||
$status = $prm["status"];
|
||||
|
||||
// echo $norm;
|
||||
|
||||
$sql_where = "WHERE M_StaffIsActive = 'Y' ";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_StaffName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM one.m_staff
|
||||
LEFT JOIN one_preorder_dev.m_staffhomeservice ON M_StaffID = M_StaffHomeServiceM_StaffID AND M_StaffHomeServiceIsActive = 'Y'
|
||||
$sql_where
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT one.m_staff.*,IFNULL(M_StaffHomeServiceID,0) as status
|
||||
FROM one.m_staff
|
||||
LEFT JOIN one_preorder_dev.m_staffhomeservice ON M_StaffID = M_StaffHomeServiceM_StaffID AND M_StaffHomeServiceIsActive = 'Y'
|
||||
$sql_where
|
||||
ORDER BY M_StaffName ASC
|
||||
limit 0,20";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows['all'] = $query->result_array();
|
||||
|
||||
$sql = "SELECT one.m_staff.*
|
||||
FROM one.m_staff
|
||||
JOIN one_preorder_dev.m_staffhomeservice ON M_StaffID = M_StaffHomeServiceM_StaffID AND M_StaffHomeServiceIsActive = 'Y'
|
||||
WHERE M_StaffIsActive = 'Y'
|
||||
ORDER BY M_StaffName ASC";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows['homeservice'] = $query->result_array();
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total_all" => $tot_count,"total_homeservice" => count($rows['homeservice']), "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();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function searchcity(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'";
|
||||
$query = $this->db_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 save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorPrefix = '{$prm['M_DoctorPrefix']}',
|
||||
M_DoctorName = '{$prm['M_DoctorName']}',
|
||||
M_DoctorSufix = '{$prm['M_DoctorSufix']}',
|
||||
M_DoctorM_SexID = '{$prm['M_DoctorM_SexID']}',
|
||||
M_DoctorM_ReligionID = '{$prm['M_DoctorM_ReligionID']}',
|
||||
M_DoctorEmail = '{$prm['M_DoctorEmail']}',
|
||||
M_DoctorHP = '{$prm['M_DoctorHP']}',
|
||||
M_DoctorPhone = '{$prm['M_DoctorPhone']}',
|
||||
M_DoctorIsMarketingConfirm = '{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
M_DoctorIsPJ = '{$prm['M_DoctorIsPJ']}',
|
||||
M_DoctorIsDefaultPJ = '{$prm['M_DoctorIsDefaultPJ']}',
|
||||
M_DoctorIsClinic = '{$prm['M_DoctorIsClinic']}',
|
||||
M_DoctorIsDefault = '{$prm['M_DoctorIsDefault']}'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query ="INSERT INTO m_doctor (
|
||||
M_DoctorPrefix,
|
||||
M_DoctorName,
|
||||
M_DoctorSufix,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorEmail,
|
||||
M_DoctorHP,
|
||||
M_DoctorPhone,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
M_DoctorIsPJ,
|
||||
M_DoctorIsDefaultPJ,
|
||||
M_DoctorIsClinic,
|
||||
M_DoctorIsDefault,
|
||||
M_DoctorCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorPrefix']}',
|
||||
'{$prm['M_DoctorName']}',
|
||||
'{$prm['M_DoctorSufix']}',
|
||||
'{$prm['M_DoctorM_SexID']}',
|
||||
'{$prm['M_DoctorM_ReligionID']}',
|
||||
'{$prm['M_DoctorEmail']}',
|
||||
'{$prm['M_DoctorHP']}',
|
||||
'{$prm['M_DoctorPhone']}',
|
||||
'{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
'{$prm['M_DoctorIsPJ']}',
|
||||
'{$prm['M_DoctorIsDefaultPJ']}',
|
||||
'{$prm['M_DoctorIsClinic']}',
|
||||
'{$prm['M_DoctorIsDefault']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletedoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$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,
|
||||
'' 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
|
||||
WHERE
|
||||
M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = ?
|
||||
";
|
||||
//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;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$count_addrs = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_DoctorAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}' AND M_DoctorAddressNote = 'Utama' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_DoctorAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_DoctorAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$query ="INSERT INTO m_doctoraddress (
|
||||
M_DoctorAddressM_DoctorID,
|
||||
M_DoctorAddressNote,
|
||||
M_DoctorAddressDescription,
|
||||
M_DoctorAddressM_KelurahanID,
|
||||
M_DoctorAddressCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorAddressM_DoctorID']}',
|
||||
'{$prm['M_DoctorAddressNote']}',
|
||||
'{$prm['M_DoctorAddressDescription']}',
|
||||
'{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}',
|
||||
M_DoctorAddressNote = '{$prm['M_DoctorAddressNote']}',
|
||||
M_DoctorAddressDescription = '{$prm['M_DoctorAddressDescription']}',
|
||||
M_DoctorAddressM_KelurahanID = '{$prm['M_DoctorAddressM_KelurahanID']}'
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function settohomeservice(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "SELECT COUNT(*) as xcount FROM one_preorder_dev.m_staffhomeservice WHERE M_StaffHomeServiceM_StaffID = '{$prm['M_StaffID']}' AND M_StaffHomeServiceIsActive = 'Y'";
|
||||
$check_exist = $this->db_onedev->query($query)->row()->xcount;
|
||||
if($check_exist == 0){
|
||||
$query = "INSERT INTO one_preorder_dev.m_staffhomeservice (M_StaffHomeServiceM_StaffID,M_StaffHomeServiceIsActive,M_StaffHomeServiceUserID)
|
||||
VALUES({$prm['M_StaffID']},'Y',{$userid})";
|
||||
$this->db_onedev->query($query);
|
||||
}
|
||||
else{
|
||||
$query ="UPDATE one_preorder_dev.m_staffhomeservice SET
|
||||
M_StaffHomeServiceIsActive = 'N',
|
||||
M_StaffHomeServiceUserID = {$userid}
|
||||
WHERE
|
||||
M_StaffHomeServiceM_StaffID = '{$prm['M_StaffID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class Status extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
public function lookup()
|
||||
{
|
||||
$query = " SELECT M_PreOrderStatusID as id, M_PreOrderStatusName as name, M_PreOrderStatusColor as color
|
||||
FROM one_preorder_dev.m_preorderstatus
|
||||
WHERE
|
||||
M_PreOrderStatusIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,659 @@
|
||||
<?php
|
||||
class Supplies extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Supplies API";
|
||||
/*
|
||||
truncate preorder_suppliestrx;
|
||||
truncate preorder_supplies;
|
||||
truncate preorder_suppliesbuffer;
|
||||
*/
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
function getallsupplies(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = " SELECT M_SuppliesID as supplies_id,
|
||||
M_SuppliesName as supplies_name,
|
||||
'N' as status
|
||||
FROM m_supplies
|
||||
WHERE
|
||||
M_SuppliesIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getstaffbydate(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$xdate = date('Y-m-d',strtotime($prm['xdate']));
|
||||
$sql = " SELECT PreOrder_HeaderM_StaffID as id,
|
||||
M_StaffName as name
|
||||
FROM one_preorder_dev.preorder_header
|
||||
JOIN m_staff ON PreOrder_HeaderM_StaffID = M_StaffID
|
||||
WHERE
|
||||
PreOrder_HeaderDate = '{$xdate}' AND PreOrder_HeaderIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function getorderbydatestaff(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$xdate = date('Y-m-d',strtotime($prm['xdate']));
|
||||
$staffid = $prm['staffid'];
|
||||
|
||||
$sql = "SELECT Preorder_SampleID as trx_id,
|
||||
PreOrder_HeaderNumbering as trx_numbering,
|
||||
DATE_FORMAT(PreOrder_HeaderDate,'%d-%m-%Y') as trx_date,
|
||||
DATE_FORMAT(PreOrder_HeaderTime,'%H:%i') as trx_time,
|
||||
GROUP_CONCAT(DISTINCT T_TestName separator ',') as tests,
|
||||
T_SampleTypeName as sampletype_name,
|
||||
T_SampleTypeID as sampletype_id,
|
||||
IFNULL(Preorder_SuppliesTrxID,0) as supplies_trx_id,
|
||||
M_StaffName as staffname,
|
||||
M_PatientName as patient_name,
|
||||
if(ISNULL(Preorder_SuppliesTrxID),'N','Y') as status
|
||||
FROM one_preorder_dev.preorder_sample
|
||||
JOIN one_preorder_dev.preorder_header ON Preorder_SamplePreOrder_HeaderID = PreOrder_HeaderID AND PreOrder_HeaderIsActive = 'Y'
|
||||
JOIN m_patient ON PreOrder_HeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN one_preorder_dev.preorder_suppliestrx ON Preorder_SamplePreorder_SuppliesTrxID = Preorder_SuppliesTrxID AND
|
||||
Preorder_SuppliesTrxIsActive = 'Y'
|
||||
JOIN m_staff ON PreOrder_HeaderM_StaffID = M_StaffID
|
||||
JOIN one_preorder_dev.preorder_test ON PreOrder_TestPreOrder_HeaderID = PreOrder_HeaderID
|
||||
JOIN t_test ON PreOrder_TestT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID AND Preorder_SampleT_SampleTypeID = T_SampleTypeID
|
||||
WHERE
|
||||
PreOrder_HeaderM_StaffID = {$staffid} AND PreOrder_HeaderDate = '{$xdate}' AND PreOrder_HeaderFlagReceivedSupplies = 'N' AND Preorder_SampleIsActive = 'Y'
|
||||
GROUP BY Preorder_SampleID";
|
||||
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function getdetails($id,$xdate,$status){
|
||||
$rows = [];
|
||||
$joinheader = "LEFT JOIN one_preorder_dev.preorder_suppliestrx ON Preorder_SamplePreorder_SuppliesTrxID = Preorder_SuppliesTrxID AND
|
||||
Preorder_SuppliesTrxID = {$id} AND
|
||||
Preorder_SuppliesTrxIsActive = 'Y'";
|
||||
if($status == 'RCV'){
|
||||
$joinheader = "JOIN one_preorder_dev.preorder_suppliestrx ON Preorder_SamplePreorder_SuppliesTrxID = Preorder_SuppliesTrxID AND
|
||||
Preorder_SuppliesTrxID = {$id} AND
|
||||
Preorder_SuppliesTrxIsActive = 'Y'";
|
||||
}
|
||||
$sql = "SELECT Preorder_SampleID as trx_id,
|
||||
PreOrder_HeaderNumbering as trx_numbering,
|
||||
DATE_FORMAT(PreOrder_HeaderDate,'%d-%m-%Y') as trx_date,
|
||||
DATE_FORMAT(PreOrder_HeaderTime,'%H:%i') as trx_time,
|
||||
GROUP_CONCAT(DISTINCT T_TestName separator ',') as tests,
|
||||
T_SampleTypeName as sampletype_name,
|
||||
T_SampleTypeID as sampletype_id,
|
||||
IFNULL(Preorder_SuppliesTrxID,0) as supplies_trx_id,
|
||||
M_StaffName as staffname,
|
||||
M_PatientName as patient_name,
|
||||
if(ISNULL(Preorder_SuppliesTrxID),'N','Y') as status
|
||||
FROM one_preorder_dev.preorder_sample
|
||||
JOIN one_preorder_dev.preorder_header ON Preorder_SamplePreOrder_HeaderID = PreOrder_HeaderID AND PreOrder_HeaderIsActive = 'Y'
|
||||
JOIN m_patient ON PreOrder_HeaderM_PatientID = M_PatientID
|
||||
$joinheader
|
||||
JOIN m_staff ON PreOrder_HeaderM_StaffID = M_StaffID
|
||||
JOIN one_preorder_dev.preorder_test ON PreOrder_TestPreOrder_HeaderID = PreOrder_HeaderID
|
||||
JOIN t_test ON PreOrder_TestT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID AND Preorder_SampleT_SampleTypeID = T_SampleTypeID
|
||||
WHERE
|
||||
PreOrder_HeaderDate = '{$xdate}' AND Preorder_SampleIsActive = 'Y'
|
||||
GROUP BY Preorder_SampleID";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
function getsupplies($id){
|
||||
$rows = [];
|
||||
|
||||
$sql = "SELECT
|
||||
M_SuppliesID as supplies_id,
|
||||
M_SuppliesName as supplies_name,
|
||||
Preorder_SuppliesID as trx_id,
|
||||
Preorder_SuppliesQty as qty,
|
||||
'Y' as status
|
||||
FROM one_preorder_dev.preorder_supplies
|
||||
JOIN m_supplies ON Preorder_SuppliesM_SuppliesID = M_SuppliesID
|
||||
WHERE
|
||||
Preorder_SuppliesPreorder_SuppliesTrxID = {$id} AND Preorder_SuppliesIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
function getsuppliesbuffer($id){
|
||||
$rows = [];
|
||||
|
||||
$sql = "SELECT
|
||||
M_SuppliesID as supplies_id,
|
||||
M_SuppliesName as supplies_name,
|
||||
Preorder_SuppliesBufferID as trx_id,
|
||||
Preorder_SuppliesBufferQty as qty,
|
||||
'Y' as status
|
||||
FROM one_preorder_dev.preorder_suppliesbuffer
|
||||
JOIN m_supplies ON Preorder_SuppliesBufferM_SuppliesID = M_SuppliesID
|
||||
WHERE
|
||||
Preorder_SuppliesBufferPreorder_SuppliesTrxID = {$id} AND Preorder_SuppliesBufferIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$search = $prm["search"];
|
||||
$status = $prm["stationid"];
|
||||
$startdate = $prm["startdate"];
|
||||
$enddate = $prm["enddate"];
|
||||
|
||||
$sql_where = "WHERE Preorder_SuppliesTrxStatus = '{$status}' AND ( Preorder_SuppliesTrxDate BETWEEN '{$startdate} 00:00:00' AND '{$enddate} 23:59:59' ) AND Preorder_SuppliesTrxIsActive = 'Y'";
|
||||
|
||||
//$sql_param = array();
|
||||
if ($search != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " ( Preorder_SuppliesTrxNumbering like '%$search%' OR penerima.M_StaffName like '%$search%' ) ";
|
||||
//$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT Preorder_SuppliesTrxID
|
||||
FROM one_preorder_dev.preorder_suppliestrx
|
||||
JOIN m_staff penyampling ON Preorder_SuppliesTrxM_StaffID = penyampling.M_StaffID
|
||||
LEFT JOIN m_staff penerima ON Preorder_SuppliesTrxReceiveM_StaffID = penerima.M_StaffID
|
||||
$sql_where
|
||||
GROUP BY Preorder_SuppliesTrxID
|
||||
) x
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT one_preorder_dev.preorder_suppliestrx.*,
|
||||
Preorder_SuppliesTrxID as trx_id,
|
||||
Preorder_SuppliesTrxNumbering as trx_numbering,
|
||||
Preorder_SuppliesTrxDate as trx_date,
|
||||
DATE_FORMAT(Preorder_SuppliesTrxDate ,'%d-%m-%Y') as trx_date_ina,
|
||||
Preorder_SuppliesTrxNote as trx_note,
|
||||
Preorder_SuppliesTrxStatus as status,
|
||||
penyampling.M_StaffName as penyampling_name,
|
||||
IFNULL(penerima.M_StaffName,'-') as penerima_name,
|
||||
'' as details,
|
||||
'' as supplies,
|
||||
'' as buffers,
|
||||
'' as staffs,
|
||||
CASE
|
||||
WHEN Preorder_SuppliesTrxStatus = 'NEW' THEN 'BARU'
|
||||
WHEN Preorder_SuppliesTrxStatus = 'RCV' THEN 'DITERIMA PETUGAS'
|
||||
END as status_name
|
||||
FROM one_preorder_dev.preorder_suppliestrx
|
||||
JOIN m_staff penyampling ON Preorder_SuppliesTrxM_StaffID = penyampling.M_StaffID
|
||||
LEFT JOIN m_staff penerima ON Preorder_SuppliesTrxReceiveM_StaffID = penerima.M_StaffID
|
||||
|
||||
$sql_where
|
||||
GROUP BY Preorder_SuppliesTrxID
|
||||
ORDER BY Preorder_SuppliesTrxID DESC
|
||||
limit 0,20";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['details'] = $this->getdetails($v['trx_id'],$v['trx_date'],$v['status']);
|
||||
$rows[$k]['supplies'] = $this->getsupplies($v['trx_id']);
|
||||
$rows[$k]['buffers'] = $this->getsuppliesbuffer($v['trx_id']);
|
||||
$rows[$k]['staffs'] = array(array('id'=>$v['Preorder_SuppliesTrxM_StaffID'],'name'=>$v['penyampling_name']));
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getordersamples(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$doctorid = $prm['doctorid'];
|
||||
$doctoraddressid = $prm['doctoraddressid'];
|
||||
$sql = "SELECT
|
||||
0 as idx,
|
||||
M_SexName,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
||||
T_SampleTypeName as samplename,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
T_OrderHeaderID as orderid,
|
||||
T_SampleTypeID as sampleid,
|
||||
'Y' as active,
|
||||
'N' as flag_image
|
||||
FROM t_samplingso
|
||||
JOIN t_orderheader ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_sampletype ON T_SamplingSoT_SampleTypeID = T_SampleTypeID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
WHERE
|
||||
T_SamplingSoM_DoctorID = {$doctorid} AND T_SamplingSoM_DoctorAddressID = {$doctoraddressid} AND T_SamplingSoFlagWL = 'N' AND T_SamplingSoIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function getstation(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT T_SampleStationID as id, T_SampleStationName as name
|
||||
FROM t_samplestation
|
||||
WHERE
|
||||
T_SampleStationIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['stations'] = $this->db_onedev->query($query)->result_array();
|
||||
//print_r($statuses);
|
||||
foreach($statuses as $k=>$v){
|
||||
array_push($rows['statuses'],$v);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdoctoraddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT M_DoctorAddressID as id, M_DoctorAddressDescription as name
|
||||
FROM m_doctoraddress
|
||||
WHERE
|
||||
M_DoctorAddressM_DoctorID = {$prm['id']} AND M_DoctorAddressIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $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"];
|
||||
|
||||
$xdate = date('Y-m-d',strtotime($prm["trx_date"]));
|
||||
if($prm['trx_id'] == '0' || $prm['trx_id'] == 0){
|
||||
$numbering = $this->db_onedev->query("SELECT one_preorder_dev.fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$query ="INSERT INTO one_preorder_dev.preorder_suppliestrx (
|
||||
Preorder_SuppliesTrxNumbering,
|
||||
Preorder_SuppliesTrxDate,
|
||||
Preorder_SuppliesTrxNote,
|
||||
Preorder_SuppliesTrxM_StaffID,
|
||||
Preorder_SuppliesTrxCreated,
|
||||
Preorder_SuppliesTrxLastUpdated,
|
||||
Preorder_SuppliesTrxUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['trx_note']}',
|
||||
'{$prm['staff']['id']}',
|
||||
NOW(),
|
||||
NOW(),
|
||||
'{$userid}'
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
}else{
|
||||
$numbering = $this->db_onedev->query("SELECT Preorder_SuppliesTrxNumbering as numbering FROM one_preorder_dev.preorder_suppliestrx WHERE Preorder_SuppliesTrxID = {$prm['trx_id']}")->row()->numbering;
|
||||
$query ="UPDATE one_preorder_dev.preorder_suppliestrx SET
|
||||
Preorder_SuppliesTrxNote = '{$prm['trx_note']}',
|
||||
Preorder_SuppliesTrxLastUpdated = NOW(),
|
||||
Preorder_SuppliesTrxUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SuppliesTrxID = {$prm['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $prm['trx_id'];
|
||||
}
|
||||
|
||||
if($saveheader){
|
||||
if($prm['details']){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
if($v['status'] === 'Y'){
|
||||
$query ="UPDATE one_preorder_dev.preorder_sample SET
|
||||
Preorder_SamplePreorder_SuppliesTrxID = {$last_id},
|
||||
Preorder_SampleLastUpdated = NOW(),
|
||||
Preorder_SampleUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SampleID = {$v['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($v['status'] === 'N'){
|
||||
$query ="UPDATE one_preorder_dev.preorder_sample SET
|
||||
Preorder_SamplePreorder_SuppliesTrxID = 0,
|
||||
Preorder_SampleLastUpdated = NOW(),
|
||||
Preorder_SampleUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SampleID = {$v['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($prm['supplies']){
|
||||
foreach($prm['supplies'] as $k => $v){
|
||||
if($v['status'] === 'Y' && ( $v['trx_id'] == 0 || $v['trx_id'] == '0')){
|
||||
$query ="INSERT INTO one_preorder_dev.preorder_supplies (
|
||||
Preorder_SuppliesPreorder_SuppliesTrxID,
|
||||
Preorder_SuppliesM_SuppliesID,
|
||||
Preorder_SuppliesQty,
|
||||
Preorder_SuppliesUserID,
|
||||
Preorder_SuppliesCreated,
|
||||
Preorder_SuppliesLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
{$last_id},
|
||||
{$v['supplies_id']},
|
||||
{$v['qty']},
|
||||
{$userid},
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savesupplies = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($v['status'] === 'Y' && ( $v['trx_id'] != 0 || $v['trx_id'] != '0')){
|
||||
$query ="UPDATE one_preorder_dev.preorder_supplies SET
|
||||
Preorder_SuppliesQty = {$v['qty']},
|
||||
Preorder_SuppliesLastUpdated = NOW(),
|
||||
Preorder_SuppliesUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SuppliesID = {$v['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$savesupplies = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($v['status'] === 'N' && ( $v['trx_id'] != 0 || $v['trx_id'] != '0')){
|
||||
$query ="UPDATE one_preorder_dev.preorder_supplies SET
|
||||
Preorder_SuppliesIsActive = 'N',
|
||||
Preorder_SuppliesLastUpdated = NOW(),
|
||||
Preorder_SuppliesUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SuppliesID = {$v['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$savesupplies = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($prm['buffers']){
|
||||
foreach($prm['buffers'] as $k => $v){
|
||||
if($v['status'] === 'Y' && ( $v['trx_id'] == 0 || $v['trx_id'] == '0')){
|
||||
$query ="INSERT INTO one_preorder_dev.preorder_suppliesbuffer (
|
||||
Preorder_SuppliesBufferPreorder_SuppliesTrxID,
|
||||
Preorder_SuppliesBufferM_SuppliesID,
|
||||
Preorder_SuppliesBufferQty,
|
||||
Preorder_SuppliesBufferUserID,
|
||||
Preorder_SuppliesBufferCreated,
|
||||
Preorder_SuppliesBufferLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
{$last_id},
|
||||
{$v['supplies_id']},
|
||||
{$v['qty']},
|
||||
{$userid},
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savebuffers = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($v['status'] === 'Y' && ( $v['trx_id'] != 0 || $v['trx_id'] != '0')){
|
||||
$query ="UPDATE one_preorder_dev.preorder_suppliesbuffer SET
|
||||
Preorder_SuppliesBufferQty = {$v['qty']},
|
||||
Preorder_SuppliesBufferLastUpdated = NOW(),
|
||||
Preorder_SuppliesBufferUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SuppliesBufferID = {$v['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$savebuffers = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($v['status'] === 'N' && ( $v['trx_id'] != 0 || $v['trx_id'] != '0')){
|
||||
$query ="UPDATE one_preorder_dev.preorder_suppliesbuffer SET
|
||||
Preorder_SuppliesBufferIsActive = 'N',
|
||||
Preorder_SuppliesBufferLastUpdated = NOW(),
|
||||
Preorder_SuppliesBufferUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SuppliesBufferID = {$v['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$savebuffers = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function deletetrx(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE one_preorder_dev.preorder_suppliestrx SET
|
||||
Preorder_SuppliesTrxIsActive = 'N',
|
||||
Preorder_SuppliesTrxUserID = '{$userid}'
|
||||
WHERE
|
||||
Preorder_SuppliesTrxID = {$prm['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $prm['trx_id'];
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $prm['trx_numbering'],
|
||||
"id" => $prm['trx_id']
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function doaction(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($prm['act'] == 'RELEASEC' || $prm['act'] === 'RCVDOC' ){
|
||||
$sql = "UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierStatus = '{$prm['act']}',
|
||||
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
||||
So_WalkLetterCourierUserID = {$userid}
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
if($prm['act'] === 'DONE'){
|
||||
$details = $prm['details'];
|
||||
$count_n = 0;
|
||||
foreach($details as $k => $v){
|
||||
if($v['flag_image_receive'] === 'N'){
|
||||
$count_n++;
|
||||
}
|
||||
if($v['flag_result_receive'] === 'N'){
|
||||
$count_n++;
|
||||
}
|
||||
$query ="UPDATE so_walklettercourierdetail SET
|
||||
So_WalkLetterCourierDetailFlagReceiveImage = '{$v['flag_image_receive']}',
|
||||
So_WalkLetterCourierDetailFlagReceiveResult = '{$v['flag_result_receive']}',
|
||||
So_WalkLetterCourierDetailUserID = '{$userid}'
|
||||
WHERE
|
||||
So_WalkLetterCourierDetailID = {$v['idx']}
|
||||
";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
$status = 'DONE';
|
||||
if($count_n > 0){
|
||||
$status = 'PARTDONE';
|
||||
}
|
||||
$sql = "UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierStatus = '{$status}',
|
||||
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
||||
So_WalkLetterCourierUserID = {$userid}
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
if($prm['act'] == 'FORCEDONE'){
|
||||
$sql = "UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
||||
So_WalkLetterCourierStatus = 'DONE',
|
||||
So_WalkLetterCourierUserID = {$userid}
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
class Type extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
public function lookup()
|
||||
{
|
||||
$query = " SELECT M_PreOrderTypeID as id, M_PreOrderTypeName as name
|
||||
FROM one_preorder_dev.m_preordertype
|
||||
WHERE
|
||||
M_PreOrderTypeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function lookup_outbox()
|
||||
{
|
||||
$query = " SELECT typeID as id, typeCode as name
|
||||
FROM one_gateway.type
|
||||
WHERE
|
||||
typeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user