Flatten nested repos

This commit is contained in:
sas.fajri
2026-04-27 10:13:31 +07:00
parent 01c2963a43
commit 8347aef8f4
17935 changed files with 5015229 additions and 3 deletions

View File

@@ -0,0 +1,569 @@
<?php
class Walkletterimage extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Walkletterimage API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
$this->load->helper(array('form', 'url'));
}
function getphotos($orderid,$sampletypeid){
$rows = [];
//print_r($_SERVER);
$urlbase = 'http://'.$_SERVER['SERVER_NAME']."/one-media/one-image-nonlab/";
$sql = "SELECT So_ImageUploadID as id,
So_ImageUploadOldName as oldname,
CONCAT('{$urlbase}',So_ImageUploadNewName) as newname
FROM so_imageupload
WHERE
So_ImageUploadT_OrderHeaderID = {$orderid} AND So_ImageUploadT_SampleTypeID = {$sampletypeid} AND So_ImageUploadIsActive = 'Y'";
//echo $sql;
$rows = $this->db_onedev->query($sql)->result_array();
return $rows;
}
function getdoctorcouriers(){
$rows = [];
$sql = "SELECT M_DoctorID as id,
CONCAT(M_DoctorPrefix,M_DoctorPrefix2,' ',M_DoctorName,'...') as name
FROM m_doctorso
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID
JOIN t_samplingso ON T_SamplingSoM_DoctorID = M_DoctorID AND T_SamplingSoFlagDoctorInOffice = 'N' AND T_SamplingSoFlagWL = 'N' AND T_SamplingSoIsDone = 'N'
WHERE
M_DoctorSOIsActive = 'Y'
GROUP BY M_DoctorID";
//echo $sql;
$rows['doctors'] = $this->db_onedev->query($sql)->result_array();
$sql = "SELECT M_StaffID as id,
M_StaffName as name
FROM m_courier
JOIN m_staff ON M_StaffID = M_CourierM_StaffID
WHERE
M_CourierIsActive = 'Y'";
//echo $sql;
$rows['couriers'] = $this->db_onedev->query($sql)->result_array();
$result = array(
"total" => count($rows) ,
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
function getsetdoctoraddress($doctorid){
$rows = [];
$sql = "SELECT M_DoctorAddressID as id, M_DoctorAddressDescription as name
FROM m_doctoraddress
WHERE
M_DoctorAddressM_DoctorID = {$doctorid} AND M_DoctorAddressIsActive = 'Y'";
//echo $sql;
$rows = $this->db_onedev->query($sql)->result_array();
return $rows;
}
function getdetails($id){
$rows = [];
$sql = "SELECT so_walklettercourierdetail.*, M_SexName,
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
T_TestName as samplename,
T_OrderHeaderLabNumber as labnumber,
'Y' as active,
So_WalkLetterCourierDetailFlagImage as flag_image,
So_WalkLetterCourierDetailFlagReceiveImage as flag_image_receive,
So_WalkLetterCourierDetailFlagReceiveResult as flag_result_receive,
So_WalkLetterCourierDetailID as idx,
T_OrderHeaderID as orderid,
T_TestID as sampleid
FROM so_walklettercourierdetail
JOIN t_orderheader ON So_WalkLetterCourierDetailT_OrderHeaderID = T_OrderHeaderID
JOIN t_test ON So_WalkLetterCourierDetailT_SampleTypeID = T_TestID
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
So_WalkLetterCourierDetailSo_WalkLetterCourierID = {$id} AND So_WalkLetterCourierDetailIsActive = '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["namelab"];
$status = $prm["stationid"];
$startdate = $prm["startdate"];
$enddate = $prm["enddate"];
if(!isset($prm['current_page']))
$prm['current_page'] = 1;
$sql_where = "WHERE So_WalkLetterCourierStatus = '{$status}' AND ( So_WalkLetterCourierDate BETWEEN '{$startdate} 00:00:00' AND '{$enddate} 23:59:59' ) AND So_WalkLetterCourierIsActive = 'Y'";
//$sql_param = array();
if ($search != "") {
if ($sql_where != "") {
$sql_where .=" and ";
}
$sql_where .= " ( So_WalkLetterCourierNumbering like '%$search%' ) ";
//$sql_param[] = "%$nama%";
}
$number_limit = 10;
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
$sql = " SELECT count(*) as total
FROM so_walklettercourier
JOIN m_doctor ON So_WalkLetterCourierM_DoctorID = M_DoctorID
JOIN m_doctoraddress ON So_WalkLetterCourierM_DoctorAddressID = M_DoctorAddressID
LEFT JOIN m_staff ON So_WalkLetterCourierM_StaffID = M_StaffID
$sql_where
";
//echo $sql;
$query = $this->db_onedev->query($sql);
$tot_count = 0;
$tot_page = 0;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
$tot_page = ceil($tot_count/$number_limit);
} else {
$this->sys_error_db("m_doctor count", $this->db_onedev);
exit;
}
$sql = "SELECT so_walklettercourier.*, IFNULL(M_StaffName,'-') as courier_name,
So_WalkLetterCourierID as trx_id,
So_WalkLetterCourierNumbering as trx_numbering,
So_WalkLetterCourierDate as trx_date,
DATE_FORMAT(So_WalkLetterCourierDate,'%d-%m-%Y') as trx_date_ina,
So_WalkLetterCourierNote as trx_note,
So_WalkLetterCourierStatus as status,
CONCAT(M_DoctorPrefix,M_DoctorPrefix2,' ',M_DoctorName,'...') as doctor_fullname,
M_DoctorAddressDescription as doctor_address,
'' as doctoraddress,
'' as details,
CASE
WHEN So_WalkLetterCourierStatus = 'CREATED' THEN 'BARU'
WHEN So_WalkLetterCourierStatus = 'RELEASEC' THEN 'DISERAHKAN KURIR'
WHEN So_WalkLetterCourierStatus = 'RCVDOC' THEN 'DITERIMA DOKTER'
WHEN So_WalkLetterCourierStatus = 'PARTDONE' THEN 'SELESAI SEBAGIAN'
ELSE 'SELESAI'
END as status_name
FROM so_walklettercourier
JOIN m_doctor ON So_WalkLetterCourierM_DoctorID = M_DoctorID
JOIN m_doctoraddress ON So_WalkLetterCourierM_DoctorAddressID = M_DoctorAddressID
LEFT JOIN m_staff ON So_WalkLetterCourierM_StaffID = M_StaffID
$sql_where
ORDER BY So_WalkLetterCourierID DESC
limit $number_limit offset $number_offset";
//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]['doctors'] = $this->getdoctors();
$rows[$k]['doctoraddress'] = $this->getsetdoctoraddress($v['So_WalkLetterCourierM_DoctorID']);
$rows[$k]['details'] = $this->getdetails($v['So_WalkLetterCourierID']);
}
}
//$this->_add_address($rows);
$result = array("total" => $tot_page, "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_TestName as samplename,
T_OrderHeaderLabNumber as labnumber,
T_OrderHeaderID as orderid,
T_TestID as sampleid,
'Y' as active,
'N' as flag_image
FROM t_samplingso
JOIN t_orderheader ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID
JOIN t_test ON T_SamplingSoT_TestID = T_TestID
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 fn_numbering('WLI') as numbering")->row()->numbering;
$query ="INSERT INTO so_walklettercourier (
So_WalkLetterCourierNumbering,
So_WalkLetterCourierDate,
So_WalkLetterCourierNote,
So_WalkLetterCourierM_StaffID,
So_WalkLetterCourierM_DoctorID,
So_WalkLetterCourierM_DoctorAddressID,
So_WalkLetterCourierCreated,
So_WalkLetterCourierUserID
)
VALUES(
'{$numbering}',
'{$xdate}',
'{$prm['trx_note']}',
'{$prm['courier']['id']}',
'{$prm['doctor']['id']}',
'{$prm['doctoraddress']['id']}',
NOW(),
'{$userid}'
)
";
//echo $query;
$saveheader = $this->db_onedev->query($query);
$last_id = $this->db_onedev->insert_id();
}else{
$numbering = $this->db_onedev->query("SELECT So_WalkLetterCourierNumbering as numbering FROM so_walklettercourier WHERE So_WalkLetterCourierID = {$prm['trx_id']}")->row()->numbering;
$query ="UPDATE so_walklettercourier SET
So_WalkLetterCourierDate = '{$xdate}',
So_WalkLetterCourierNote = '{$prm['trx_note']}',
So_WalkLetterCourierM_StaffID = '{$prm['courier']['id']}',
So_WalkLetterCourierM_DoctorID = '{$prm['doctor']['id']}',
So_WalkLetterCourierM_DoctorAddressID = '{$prm['doctoraddress']['id']}',
So_WalkLetterCourierLastUpdated = NOW(),
So_WalkLetterCourierUserID = '{$userid}'
WHERE
So_WalkLetterCourierID = {$prm['trx_id']}
";
//echo $query;
$saveheader = $this->db_onedev->query($query);
$last_id = $prm['trx_id'];
}
if($saveheader){
foreach($prm['details'] as $k => $v){
if($v['active'] === 'Y' && ($v['idx'] == 0 || $v['idx'] == '0')){
$query ="INSERT INTO so_walklettercourierdetail (
So_WalkLetterCourierDetailSo_WalkLetterCourierID,
So_WalkLetterCourierDetailT_OrderHeaderID,
So_WalkLetterCourierDetailT_SampleTypeID,
So_WalkLetterCourierDetailFlagImage,
So_WalkLetterCourierDetailCreated,
So_WalkLetterCourierDetailUserID
)
VALUES(
'{$last_id}',
'{$v['orderid']}',
'{$v['sampleid']}',
'{$v['flag_image']}',
NOW(),
'{$userid}'
)";
//echo $query;
$savedetail = $this->db_onedev->query($query);
}
if($v['active'] === 'Y' && ($v['idx'] != 0 || $v['idx'] != '0')){
$query ="UPDATE so_walklettercourierdetail SET
So_WalkLetterCourierDetailSo_WalkLetterCourierID = '{$last_id}',
So_WalkLetterCourierDetailT_OrderHeaderID = '{$v['orderid']}',
So_WalkLetterCourierDetailT_SampleTypeID = '{$v['sampleid']}',
So_WalkLetterCourierDetailFlagImage = '{$v['flag_image']}',
So_WalkLetterCourierDetailUserID = '{$userid}'
WHERE
So_WalkLetterCourierDetailID = {$v['idx']}
";
//echo $query;
$savedetail = $this->db_onedev->query($query);
}
if($v['active'] === 'N' && $v['idx'] != 0){
$query ="UPDATE so_walklettercourierdetail SET
So_WalkLetterCourierDetailIsActive = 'N',
So_WalkLetterCourierDetailUserID = '{$userid}'
WHERE
So_WalkLetterCourierDetailID = {$v['idx']}
";
//echo $query;
$savedetail = $this->db_onedev->query($query);
}
}
}
$sql = "SELECT * FROM so_walklettercourier WHERE So_WalkLetterCourierID = {$last_id}";
$data_log_header = $this->db_onedev->query($sql)->result();
$sql = "SELECT * FROM so_walklettercourierdetail WHERE So_WalkLetterCourierDetailSo_WalkLetterCourierID = {$last_id}";
$data_log_details = $this->db_onedev->query($sql)->result();
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
$sql = "INSERT INTO one_log.log_walkletter (
Log_WalkLetterCode,
Log_WalkLetterDate,
Log_WalkLetterJSON,
Log_WalkLetterUserID
)
VALUES(
'SAMPLE',
CURDATE(),
'{$data_log}',
{$userid}
)";
//echo $sql;
$this->db_onedev->query($sql);
$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 so_walklettercourier SET
So_WalkLetterCourierIsActive = 'N',
So_WalkLetterCourierUserID = '{$userid}'
WHERE
So_WalkLetterCourierID = {$prm['trx_id']}
";
//echo $query;
$saveheader = $this->db_onedev->query($query);
$last_id = $prm['trx_id'];
$sql = "SELECT * FROM so_walklettercourier WHERE So_WalkLetterCourierID = {$last_id}";
$data_log_header = $this->db_onedev->query($sql)->result();
$sql = "SELECT * FROM so_walklettercourierdetail WHERE So_WalkLetterCourierDetailSo_WalkLetterCourierID = {$last_id}";
$data_log_details = $this->db_onedev->query($sql)->result();
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
$sql = "INSERT INTO one_log.log_walkletter (
Log_WalkLetterCode,
Log_WalkLetterDate,
Log_WalkLetterJSON,
Log_WalkLetterUserID
)
VALUES(
'SAMPLE',
CURDATE(),
'{$data_log}',
{$userid}
)";
$this->db_onedev->query($sql);
$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);
}
$last_id = $prm['trx']['trx_id'];
$sql = "SELECT * FROM so_walklettercourier WHERE So_WalkLetterCourierID = {$last_id}";
$data_log_header = $this->db_onedev->query($sql)->result();
$sql = "SELECT * FROM so_walklettercourierdetail WHERE So_WalkLetterCourierDetailSo_WalkLetterCourierID = {$last_id}";
$data_log_details = $this->db_onedev->query($sql)->result();
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
$sql = "INSERT INTO one_log.log_walkletter (
Log_WalkLetterCode,
Log_WalkLetterDate,
Log_WalkLetterJSON,
Log_WalkLetterUserID
)
VALUES(
'SAMPLE',
CURDATE(),
'{$data_log}',
{$userid}
)";
//echo $sql;
$this->db_onedev->query($sql);
$result = array(
"total" => 1 ,
"records" => array('status'=>'OK')
);
$this->sys_ok($result);
exit;
}
}

View File

@@ -0,0 +1,508 @@
// 1 => LOADING
// 2 => DONE
// 3 => ERROR
import * as api from "../api/sample.js"
export default {
namespaced: true,
state: {
last_id:-1,
last_saved_id:-1,
x_addr_id:0,
act:'new',
act_addr:'new',
get_data_status:0,
search_trx: 0,
search_status: 0,
search_error_message: '',
start_date:moment(new Date()).format('YYYY-MM-DD'),
end_date:moment(new Date()).format('YYYY-MM-DD'),
total_transaction: 0,
transactions:[],
details:[],
selected_detai:{},
stations:[{id:"CREATED",name:"BARU"},{id:"RELEASEC",name:"DISERAHKAN KURIR"},{id:"RCVDOC",name:"DITERIMA DOKTER"},{id:"PARTDONE",name:"SELESAI SEBAGIAN"},{id:"DONE",name:"SELESAI"}],
selected_station:{id:"CREATED",name:"BARU"},
selected_transaction: {},
save_status: 0,
name_lab:'',
btn_save_seen: true,
pgrs_save: false,
save_error_message: '',
no_save: 0,
open_alert_confirmation:false,
alert_success: false,
msg_success: "",
dialog_success: false,
dialog_confirmation_delete: false,
msg_confirmation_delete: "",
autocomplete_status:0,
dialog_form_address: false,
errors:[],
open_dialog_info:false,
msg_info:'',
dialog_action:false,
msg_action:'',
current_status:null,
uploaded_files:[],
uploaded_error:null,
photos:[],
selected_photo:{},
dialog_image:false,
image:'',
doctors:[],
selected_doctor:{},
doctor_address:[],
selected_doctor_address:{},
trx_date:moment(new Date()).format('YYYY-MM-DD'),
couriers:[],
selected_courier:{},
trx_note:'',
current_page:1,
total_page:1
},
mutations: {
update_total_page(state, val) {
state.total_page = val
},
update_current_page(state, val) {
state.current_page = val
},
update_x_addr_id(state, val) {
state.x_addr_id = val
},
update_last_id(state, val) {
state.last_id = val
},
update_last_saved_id(state, val) {
state.last_saved_id = val
},
update_act(state, val) {
state.act = val
},
update_start_date(state, val) {
state.start_date = val
},
update_end_date(state, val) {
state.end_date = val
},
update_name_lab(state, val) {
state.name_lab = val
},
update_stations(state, val) {
state.stations = val
},
update_selected_station(state, val) {
state.selected_station = val
},
update_act_addr(state, val) {
state.act_addr = val
},
update_get_data_status(state, val) {
state.get_data_status = val
},
update_search_error_message(state, patient) {
state.search_error_message = patient
},
update_search_transaction(state, val) {
state.search_transaction = val
},
update_transactions(state, data) {
state.transactions = data
},
update_selected_transaction(state, val) {
state.selected_transaction = val
},
update_details(state, data) {
state.details = data
},
update_selected_detail(state, val) {
state.selected_detail = val
},
update_save_status(state, val) {
state.save_status = val
},
update_btn_save_seen(state, val) {
state.btn_save_seen = val
},
update_pgrs_save(state, val) {
state.pgrs_save = val
},
update_save_error_message(state, msg) {
state.save_error_message = ''
},
update_no_save(state, val) {
state.no_save = val
},
update_open_alert_confirmation(state, val) {
state.open_alert_confirmation = val
},
update_alert_success(state, val) {
state.alert_success = val
},
update_msg_success(state, val) {
state.msg_success = val
},
update_dialog_success(state, val) {
state.dialog_success = val
},
update_dialog_confirmation_delete(state, val) {
state.dialog_confirmation_delete = val
},
update_msg_confirmation_delete(state, val) {
state.msg_confirmation_delete = val
},
update_search_status(state, val) {
state.search_status = val
},
update_errors(state, val) {
state.errors = val
},
update_total_transactions(state, val) {
state.total_transactions = val
},
update_open_dialog_info(state, val) {
state.open_dialog_info = val
},
update_msg_info(state, val) {
state.msg_info = val
},
update_dialog_action(state, val) {
state.dialog_action = val
},
update_msg_action(state, val) {
state.msg_action = val
},
update_current_status(state, val) {
state.current_status = val
},
update_uploaded_files(state, val) {
state.uploaded_files = val
},
update_uploaded_error(state, val) {
state.uploaded_error = val
},
update_photos(state, val) {
state.photos = val
},
update_selected_photo(state, val) {
state.selected_photo = val
},
update_dialog_image(state, val) {
state.dialog_image = val
},
update_image(state, val) {
state.image = val
},
update_doctors(state, val) {
state.doctors = val
},
update_selected_doctor(state, val) {
state.selected_doctor = val
},
update_doctor_address(state, val) {
state.doctor_address = val
},
update_selected_doctor_address(state, val) {
state.selected_doctor_address = val
},
update_trx_date(state, val) {
state.trx_date = val
},
update_couriers(state, val) {
state.couriers = val
},
update_selected_courier(state, val) {
state.selected_courier = val
},
update_trx_note(state, val) {
state.trx_note = val
},
},
actions: {
async search(context, prm) {
context.commit("update_search_transaction", 1)
try {
prm.token = one_token()
let resp = await api.search(prm)
if (resp.status != "OK") {
context.commit("update_search_transaction", 3)
context.commit("update_search_error_message", resp.message)
} else {
context.commit("update_search_transaction", 2)
context.commit("update_search_error_message", "")
let data = {
records: resp.data.records,
total: resp.data.total
}
var trx = []
if(data.records.length > 0){
context.commit("update_transactions", resp.data.records)
if(prm.lastid === -1){
trx = resp.data.records[0]
}
else{
trx = resp.data.records[prm.lastid]
}
context.commit("update_selected_transaction", trx)
context.commit("update_trx_note",trx.trx_note)
context.commit("update_trx_date",trx.trx_date)
if(!_.isEmpty(trx.details)){
context.commit("update_details", trx.details)
}
else{
context.commit("update_details", [])
}
if(trx.doctor_fulname !== null){
context.commit("update_doctors",[{id:trx.So_WalkLetterCourierM_DoctorID,name:trx.doctor_fullname}])
context.commit("update_selected_doctor",{id:trx.So_WalkLetterCourierM_DoctorID,name:trx.doctor_fullname})
context.commit("update_doctor_address",trx.doctoraddress)
context.commit("update_selected_doctor_address",{id:trx.So_WalkLetterCourierM_DoctorAddressID,name:trx.doctor_address})
context.commit("update_selected_courier",{id:trx.So_WalkLetterCourierM_StaffID,name:trx.courier_name})
}
else{
context.commit("update_selected_doctor",{})
}
}
else{
context.commit("update_transactions", [])
context.commit("update_selected_transaction", {status:'NONE',numbering:'-'})
context.commit("update_trx_note",'')
context.commit("update_trx_date",moment(new Date()).format('YYYY-MM-DD'))
context.commit("update_details", [])
context.commit("update_selected_doctor",{})
context.commit("update_selected_courier",{})
}
context.commit("update_total_transactions", data.total)
context.commit("update_total_page", data.total)
context.commit("update_no_save", 0)
context.commit("update_act",'edit')
}
} catch (e) {
context.commit("update_search_transaction", 3)
context.commit("update_search_error_message", e.message)
console.log(e)
}
},
async getdoctorcouriers(context,prm) {
context.commit("update_get_data_status",1)
try {
prm.token = one_token()
prm.trx_date = context.state.trx_date
let resp= await api.getdoctorcouriers(prm)
if (resp.status != "OK") {
context.commit("update_get_data_status",3)
} else {
context.commit("update_get_data_status",2)
let data = {
records : resp.data.records,
total: resp.data.total
}
context.commit("update_doctors",data.records['doctors'])
context.commit("update_couriers",data.records['couriers'])
context.dispatch("search",prm)
}
} catch(e) {
context.commit("update_get_data_status",3)
}
},
async getdoctorcouriers_add(context,prm) {
context.commit("update_get_data_status",1)
try {
prm.token = one_token()
prm.trx_date = context.state.trx_date
let resp= await api.getdoctorcouriers(prm)
if (resp.status != "OK") {
context.commit("update_get_data_status",3)
} else {
context.commit("update_get_data_status",2)
let data = {
records : resp.data.records,
total: resp.data.total
}
context.commit("update_doctors",data.records['doctors'])
context.commit("update_couriers",data.records['couriers'])
//context.dispatch("search",prm)
}
} catch(e) {
context.commit("update_get_data_status",3)
}
},
async upload(context,prm) {
context.commit("update_get_data_status",1)
try {
let resp= await api.upload(prm)
if (resp.status != "OK") {
context.commit("update_get_data_status",3)
} else {
context.commit("update_get_data_status",2)
let data = {
records : resp.data.records,
total: resp.data.total,
error:resp.data.errors.error
}
context.commit("update_uploaded_files",data.records)
var msg = "Photo telah berhasil diupload"
if(data.error){
msg = data.error
context.commit("update_current_status",'STATUS_FAILED')
}
else{
context.commit("update_current_status",'STATUS_SUCCESS')
}
context.commit("update_msg_info",msg)
context.commit("update_open_dialog_info",true)
}
} catch(e) {
context.commit("update_get_data_status",3)
}
},
async doaction(context,prm) {
context.commit("update_save_status",1)
try {
prm.token = one_token()
let resp= await api.doaction(prm)
if (resp.status != "OK") {
context.commit("update_save_status",3)
} else {
context.commit("update_save_status",2)
context.commit("update_dialog_action",false)
var prmx = {
startdate:context.state.start_date,
enddate:context.state.end_date,
search:context.state.name_lab,
stationid:context.state.selected_station.id,
current_page:1,
lastid:-1
}
context.dispatch("search",prmx)
}
} catch(e) {
context.commit("update_save_status",3)
}
},
async deletephoto(context,prm) {
context.commit("update_save_status",1)
try {
prm.token = one_token()
let resp= await api.deletephoto(prm)
if (resp.status != "OK") {
context.commit("update_save_status",3)
} else {
context.commit("update_save_status",2)
context.commit("update_act",'-')
context.commit("update_dialog_confirmation_delete",false)
context.commit("update_selected_photo",{})
context.dispatch("search",prm)
}
} catch(e) {
context.commit("update_save_status",3)
}
},
async getdoctoraddress(context,prm) {
context.commit("update_get_data_status",1)
try {
prm.token = one_token()
let resp= await api.getdoctoraddress(prm)
if (resp.status != "OK") {
context.commit("update_get_data_status",3)
} else {
context.commit("update_get_data_status",2)
let data = {
records : resp.data.records,
total: resp.data.total
}
context.commit("update_doctor_address",data.records)
context.commit("update_selected_doctor_address",{})
}
} catch(e) {
context.commit("update_save_status",3)
}
},
async getordersamples(context,prm) {
context.commit("update_get_data_status",1)
try {
prm.token = one_token()
let resp= await api.getordersamples(prm)
if (resp.status != "OK") {
context.commit("update_get_data_status",3)
} else {
context.commit("update_get_data_status",2)
let data = {
records : resp.data.records,
total: resp.data.total
}
context.commit("update_details",data.records)
context.commit("update_selected_detail",{})
}
} catch(e) {
context.commit("update_get_data_status",3)
}
},
async save(context,prm) {
context.commit("update_save_status",1)
try {
prm.token = one_token()
let resp= await api.save(prm)
if (resp.status != "OK") {
context.commit("update_save_status",3)
} else {
context.commit("update_save_status",2)
context.commit("update_selected_transaction",{})
context.commit("update_details",[])
context.commit("update_errors",[])
context.commit("update_selected_detail",{})
context.commit("update_selected_doctor",{})
context.commit("update_selected_doctor_address",{})
context.commit("update_selected_courier",{})
context.commit("update_trx_date",moment(new Date()).format('YYYY-MM-DD'))
context.commit("update_trx_note",'')
context.commit("update_act",'new')
context.commit("update_dialog_success", true)
context.commit("update_last_id", -1)
var msg = "Transaksi penyimpanan " + resp.data.numbering + " berhasil dong ..."
context.commit("update_msg_success", msg)
}
} catch(e) {
context.commit("update_save_status",3)
}
},
async deletetrx(context,prm) {
context.commit("update_save_status",1)
try {
prm.token = one_token()
let resp= await api.deletetrx(prm)
if (resp.status != "OK") {
context.commit("update_save_status",3)
} else {
context.commit("update_save_status",2)
context.commit("update_selected_transaction",{})
context.commit("update_details",[])
context.commit("update_selected_detail",{})
context.commit("update_selected_doctor",{})
context.commit("update_selected_doctor_address",{})
context.commit("update_selected_courier",{})
context.commit("update_trx_date",moment(new Date()).format('YYYY-MM-DD'))
context.commit("update_trx_note",'')
context.commit("update_act",'new')
context.commit("update_dialog_confirmation_delete",false)
context.commit("update_dialog_success", true)
var msg = "Transaksi hapus " + prm.trx_numbering + " berhasil dong ..."
context.commit("update_msg_success", msg)
}
} catch(e) {
context.commit("update_save_status",3)
}
},
}
}