Files
BE_IBL/application/controllers/tools/Xcopy.php
2026-04-15 15:23:57 +07:00

652 lines
29 KiB
PHP

<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
$SCRIPT_VERSION = "1.0.5";
$FO_REGISTRATION_ID = 2;
class Xcopy extends MY_Controller
{
public function __construct()
{
parent::__construct();
}
public function log()
{
$xdb = $this->load->database("onedev", true);
$pwd = $xdb->password;
$temp_file = tempnam(sys_get_temp_dir(), '-log-db') . ".sql";
if (file_exists($temp_file)) {
unlink($temp_file);
}
$cmd = "mysqldump --triggers --routines --no-data -u root -p$pwd one_log > $temp_file";
exec($cmd);
if (file_exists($temp_file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($temp_file).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($temp_file));
readfile($temp_file);
unlink($temp_file);
exit;
}
}
public function update($mcuCode)
{
$sql = "update mcu_offline_prepare set McuOfflinePrepareIsDownloaded = 'Y'
where McuOfflinePrepareCode = ?";
$query = $this->db->query($sql, array($mcuCode));
if (! $query) {
echo "ERR| MCU Code : $mcuCode is not found !";
echo $this->db->error()->message;
exit;
}
echo "OK |MCU Offline $mcuCode sudah ter download !";
}
public function info($branchCode, $mcuCode, $version = "")
{
global $SCRIPT_VERSION;
if ($version != $SCRIPT_VERSION) {
$url = "http://" . $_SERVER['HTTP_HOST'] . "/install-mcu.sh";
echo "ERR|Script belum versi terakhir, silahkan download script instalasi lagi $url";
exit;
}
$sql = "select * from m_branch where M_BranchIsActive = 'Y' and M_BranchCode = ? and M_BranchIsDefault = 'Y'";
$query = $this->db->query($sql, array($branchCode));
if (! $query) {
echo "ERR|$branchCode is not the default branch !";
echo $this->db->error()->message;
exit;
}
$rows = $query->result_array();
if (count($rows) == 0) {
echo "ERR|$branchCode is not the default branch !";
echo $this->db->error()->message;
exit;
}
$branchName = $rows[0]["M_BranchName"];
$sql = "select M_CompanyName, McuOfflinePrepareStartDate, McuOfflinePrepareEndDate , McuOfflinePrepareIsDownloaded
from mcu_offline_prepare join m_company on McuOfflinePrepareM_CompanyID = M_CompanyID
where McuOfflinePrepareCode = ? and McuOfflinePrepareIsActive = 'Y'";
$query = $this->db->query($sql, array($mcuCode));
if (! $query) {
echo "ERR|Kode MCU $mcuCode tidak ada";
echo $this->db->error()->message;
exit;
}
$rows = $query->result_array();
if (count($rows) == 0) {
echo "ERR|Kode MCU $mcuCode tidak ada";
exit;
}
if ($rows[0]["McuOfflinePrepareIsDownloaded"] == "Y") {
echo "ERR|Kode MCU $mcuCode sudah di download.";
exit;
}
$startDate = $rows[0]["McuOfflinePrepareStartDate"];
$endDate = $rows[0]["McuOfflinePrepareEndDate"];
$companyName = $rows[0]["M_CompanyName"];
echo "OK|Cabang\t\t: $branchName\nKode MCU\t: $mcuCode\nCompany\t\t: $companyName\nStart\t\t: $startDate\nEnd\t\t: $endDate";
}
public function db($mcuCode)
{
global $FO_REGISTRATION_ID;
$xdb = $this->load->database("onedev", true);
$pwd = $xdb->password;
$temp_c = tempnam(sys_get_temp_dir(), 'temp_c') . ".sql";
if (file_exists($temp_c)) {
unlink($temp_c);
}
$partials = ['address_loc','g_moustatuslog','m_doctor','m_doctoraddress','m_doctorpj','m_doctorso','m_patient','m_patientaddress','mcu_offline_prepare','ss_price_mou','t_packet','t_packetdetail','t_price','t_priceaddon','t_priceref','t_profile','t_profiledetail','ss_price_mou_px','m_mou','m_company', 'mcu_preregister_patients' ];
$sql = "select * from mcu_offline_prepare where McuOfflinePrepareCode=?";
$qry = $this->db->query($sql, array($mcuCode));
if (! $qry) {
echo "ERR : No MCU Offline Prepare $mcuCode \n";
exit;
}
$rows = $qry->result_array();
if (count($rows) > 0) {
$r = $rows[0];
$companyID = $r["McuOfflinePrepareM_CompanyID"];
$defaultMouID = $r["McuOfflinePrepareM_MouDefaultID"];
$s_doctor = "0";
$doctors = json_decode($r["McuOfflinePrepareDoctors"], true);
foreach ($doctors as $d) {
$s_doctor .= "," . $d["id"];
}
$s_mou = "0";
$mous = json_decode($r["McuOfflinePrepareMous"], true);
foreach ($mous as $m) {
$s_mou .= "," . $m["id"];
}
$mcuOfflineID = $r["McuOfflinePrepareID"];
$sql = "select T_OrderHeaderM_PatientID as id from t_orderheader
where T_OrderHeaderIsActive ='Y' and T_OrderHeaderM_CompanyID = ?
union
select Mcu_PreregisterDetailsM_PatientID as id
from
mcu_preregister_patients
where Mcu_PreregisterDetailsMcuOfflinePrepareID = ?
and Mcu_PreregisterDetailsIsActive = 'Y'
order by id";
$qry = $this->db->query($sql, array($companyID,$mcuOfflineID));
$s_patient = "0";
$s_patientMaxID = 0;
$arr_patient = array();
if ($qry) {
$rows = $qry->result_array();
foreach ($rows as $r) {
if (in_array($r["id"], $arr_patient)) {
continue;
}
if ($r["id"] == "") {
continue;
}
$s_patient .= "," . $r["id"];
$s_patientMaxID = $r["id"];
$arr_patient[] = $r["id"];
}
}
$s_packet = "0";
$sql = "select distinct T_PacketID as id from t_packet where T_PacketIsActive = 'Y' and T_PacketM_MouID in ($s_mou) ";
$qry = $this->db->query($sql);
if ($qry) {
$rows = $qry->result_array();
foreach ($rows as $r) {
$s_packet .= "," . $r["id"];
}
}
$s_price= "0";
$sql = "select distinct T_PriceID as id from t_price where T_PriceIsActive = 'Y' and T_PriceM_MouID in ($s_mou) ";
$qry = $this->db->query($sql);
if ($qry) {
$rows = $qry->result_array();
foreach ($rows as $r) {
$s_price .= "," . $r["id"];
}
}
} else {
echo "ERR : No MCU Offline Prepare $mcuCode \n";
exit;
}
foreach ($partials as $p) {
switch ($p) {
case "mcu_preregister_patients":
$where = " Mcu_PreregisterDetailsMcuOfflinePrepareID = $mcuOfflineID ";
break;
case "address_loc":
$where = " Address_LocM_PatientID in ( $s_patient ) ";
break;
case "g_moustatuslog":
$where = " G_MouStatusLogM_MouID in ( $s_mou ) ";
break;
case "m_doctor":
$where = " M_DoctorID in ( $s_doctor ) ";
break;
case "m_doctoraddress":
$where = " M_DoctorAddressM_DoctorID in ($s_doctor)";
break;
case "m_doctorpj":
$where = "M_DoctorPjM_DoctorID in ( $s_doctor)";
break;
case "m_doctorso":
$where = "M_DoctorSoM_DoctorID in ($s_doctor) ";
break;
case "m_patient":
$where = "M_PatientID in ($s_patient)";
break;
case "m_patientaddress":
$where = "M_PatientAddressM_PatientID in ($s_patient)";
break;
case "mcu_offline_prepare":
$where = "McuOfflinePrepareID = $mcuOfflineID";
break;
case "m_mou":
$where = "M_MouID in ($s_mou)";
break;
case "m_company":
$where = "M_CompanyID in ($companyID)";
break;
case "ss_price_mou":
$where = "Ss_PriceMouM_MouID in ($s_mou)";
break;
case "t_packet":
$where = "T_PacketM_MouID in ($s_mou)";
break;
case "t_packetdetail":
$where = "T_PacketDetailT_PacketID in ($s_packet)";
break;
case "t_price":
$where = "T_PriceM_MouID in ($s_mou)";
break;
case "t_priceaddon":
$where = "T_PriceAddonT_PriceID in ($s_price)";
break;
case "t_priceref":
$where = "T_PriceRefT_PriceID in ($s_price)";
break;
case "ss_price_mou_px":
$where = "Ss_PriceMouPxM_MouID in ($s_mou)";
break;
}
if ($where == "") {
$cmd = "mysqldump --triggers -u root -p$pwd one $p >> $temp_c";
} else {
$cmd = "mysqldump --triggers -u root -p$pwd -w \"$where\" one $p >> $temp_c";
}
exec($cmd);
}
$tables_a ="conf_clinic conf_default conf_refinternal conf_systems documentation_group documentation_group_detail fisik_templateresult fo_verificationslabel fo_verificationtype group_result group_resultdetail helper_nattests jpa_test lcprep_adekuasi lcprep_interpretasi lcprep_interpretasigroup lcprep_interpretasisubgroup lcprep_kategoriumum log_type m_advice_fisik m_agingtype m_almari m_bank_account m_branch m_city m_companybusiness m_companystaffposition m_companytype m_courier m_courier_area m_courierstatusreceive m_dayofweek m_delivery m_deliverytype m_dflt_allergy m_dflt_chestabdomen m_dflt_drugconsumption m_dflt_eyes m_dflt_generalcondition m_dflt_lifestyle m_dflt_medicalhistory m_dflt_nerve m_dflt_tht m_dflt_tooth m_dflt_vitalsign m_dflt_vitalsign_cbx m_difference m_district m_eksposi group_result_entry translate_word " ;
$cmd = "mysqldump --triggers -u root -p$pwd one $tables_a >> $temp_c";
exec($cmd);
$tables_a2 ="m_emailconfig m_idtype m_instrumentassay m_instrumentconvert m_instrumentmethode m_itemadditional m_itemadditionaltest m_k3_allergy m_k3_chestabdomen m_k3_drugconsumption m_k3_eyes m_k3_generalcondition m_k3_lifestyle m_k3_medicalhistory m_k3_nerve m_k3_tht m_k3_tooth m_k3_vitalsign m_k3_vitalsign_cbx m_k3_workplace_accident m_k3_workplace_hazards m_kelurahan m_labreference m_mcunonlab m_methode_priority m_moutype m_no_form m_nonsample m_omzettype m_papsmearbahan m_papsmearcategory m_papsmearcheck m_paymenttype m_position m_province m_rack m_religion m_samplingtime m_satellite m_schedule m_schedulegroup m_schedulegrouptest m_sex m_specialist m_staff m_status m_statusdetail m_statusref m_statusreference m_statussample m_subarea m_supplies m_template_msg m_time m_title m_user m_usergroup m_value m_vendorsample map_word map_word_lang mcu_reporttemplate mcu_reporttemplatedetail nat_advice nat_advice_abnormal nat_advice_fisik " ;
$cmd = "mysqldump --triggers -u root -p$pwd one $tables_a2 >> $temp_c";
exec($cmd);
// dikurangi nat_tat_group nat_tat_item
$tables_a3 ="nat_bahan nat_bank nat_cito nat_companylevel nat_delta_check nat_delta_type nat_flag nat_group nat_hierarchy nat_instrument nat_jpa nat_jpadetail nat_jpagroup nat_lang nat_mcunormalnolab nat_methode nat_multirule nat_multirule_detail nat_normalvalue nat_normalvaluelang nat_normalvaluetype nat_position nat_requirement nat_requirementposition nat_sampletype nat_sex nat_staff nat_subgroup nat_subsubgroup nat_test nat_testlang nat_testone nat_testrequirement nat_testtype nat_trend_analysis nat_unit nat_unitlang noreg_prefix number_map r_inputtype r_report r_reportdetail r_reportgroup m_lang " ;
$cmd = "mysqldump --triggers -u root -p$pwd one $tables_a3 >> $temp_c";
exec($cmd);
$tables_a4 ="result_handlingdifftime s_menu s_numbering s_privilege s_regional so_template so_templatedetail so_templatelabel so_templatevalue so_testtemplate sys_kapus t_addon t_antibiotic t_bacteria t_bahan t_favorite t_instrument t_instrument_used t_nonlab t_resulttemplate t_sampleimg t_samplestation t_sampletype t_specimenlocal t_test t_test_tat t_testcalculation t_testcalculation_detail t_testconclusion t_testtype t_worklist t_worklistdetail t_worklistdetailv2 usergroup_report vw_medical_history_left_right t_sampling_queue_status " ;
$cmd = "mysqldump --triggers -u root -p$pwd one $tables_a4 >> $temp_c";
exec($cmd);
$tables_c = "courier_adhoc cr_order debug f_bill f_bill_detail f_bill_payment f_bill_payment_detail f_dp_labreference f_payment f_payment_kasir f_payment_kasir_detail f_payment_orderheader f_payment_test f_paymentdetail f_returcharge fo_status fo_verificationsvalue helper_bahan helper_order helper_sst helper_sstcall incoming_ref incoming_ref_child incoming_ref_detail itf_raw itf_result last_sampling_so_status last_status last_statusgroup last_statuspayment last_statuspx last_statussample log_other_fna log_other_fnadetails log_other_lcprep log_other_lcprepadekuasi log_other_lcprepdetails log_other_lcprepinterpretasi log_other_lcprepkategoriumum log_other_papsmear log_other_papsmearbahan log_other_papsmearcategory log_other_papsmearcheck ";
$cmd = "mysqldump --triggers --no-data -u root -p$pwd one $tables_c >> $temp_c";
exec($cmd);
$tables_c2 = "log_other_papsmeardetails log_other_papsmearmaturasi management_courier mcu_agreement mcu_agreement_customer mcu_agreement_facility mcu_agreement_formula mcu_agreement_implementation mcu_agreement_marketing mcu_agreement_notes mcu_agreement_price mcu_agreement_promise mcu_agreement_result_type mcu_agreement_scopework mcu_agreement_send_result mcu_agreementtype mcu_download mcu_patient mcu_preregister mcu_preregister_details mcu_preregister_tests mcu_resume mcu_resumedetails mcu_resumeother mcu_screening order_attr order_delivery order_log order_px order_px_log other_cytologi other_cytologidetails other_fna other_fnadetails other_lcprep other_lcprepadekuasi other_lcprepdetails other_lcprepinterpretasi other_lcprepkategoriumum other_mikro other_mikrodetails other_papsmear other_papsmearbahan other_papsmearcategory other_papsmearcheck other_papsmeardetails other_papsmearmaturasi pre_analytic result_courier ";
$cmd = "mysqldump --triggers --no-data -u root -p$pwd one $tables_c2 >> $temp_c";
exec($cmd);
$tables_c3 = "result_couriercominghome result_couriercominghome_details result_courierspk result_courierspk_detail result_courierspk_detail_step_by_step result_email result_frontoffice result_frontoffice_by_step result_handover result_handoveremail result_handoveremail_log result_handoveremail_step result_handoverpatient result_handoverpatient_log result_office result_processtooffice result_processtooffice_log result_receive result_sendcourier result_sendcourier_by_step result_sendemail result_sendemail_by_step result_verification_by_step result_verifications result_verifications_value result_wa sample_by_step ";
$cmd = "mysqldump --triggers --no-data -u root -p$pwd one $tables_c3 >> $temp_c";
exec($cmd);
$tables_c4 = "sample_so_by_step sampling_note_station sampling_note_station_by_save snap_doctor_fee so_imageupload so_resultentry so_resultentry_fisik_umum so_resultentry_last_status so_resultentrydetail so_resultentrydetail_other so_walklettercourier so_walklettercourierdetail so_walkletterresult so_walkletterresultdetail ss_expertisi ss_mou_profile ss_no_promise ss_no_promise_mou ss_piutang ss_piutang_packet ss_piutang_payment ss_piutang_test ss_price_mou_del ss_price_mou_v2 ss_tat_v2 ss_tat_v2_nonlab ss_tat_v2b ss_tat_v2c ssr_mr01 ssr_mr03 ssr_mr04 ssr_mr05 ssr_mr05_piutang ssr_mr07 ssr_mr09 ssr_mr11 summary_samplestorage sys_f_kapus sys_f_kapus_sum future_map ";
$cmd = "mysqldump --triggers --no-data -u root -p$pwd one $tables_c4 >> $temp_c";
exec($cmd);
$tables_cx = "t_barcodelab t_email_nonlab t_order_calc t_orderdelivery t_orderdeliverynote t_orderdetail t_orderdetail_daily t_orderdetailaddon t_orderdetaillang t_orderheader t_orderheader_daily t_orderheaderaddon t_orderheaderuser t_ordermessage t_orderpromise t_orderreq t_ordersample t_ordersampleaddon t_ordersamplereq t_ordersupplies t_ordertx t_paymentdaily t_paymentdetail_daily t_receiverefacceptcourier t_receiverefacceptcourierdetail t_receiverefacceptcourierdp t_receiverefdistributcourier t_receiverefdistributcourierdetail t_receivereferencedelivery t_receivereferencedeliverydetail t_receivereferenceheader t_receivereferencepatient t_receivereferencetest t_ref_deliveryorder t_ref_deliveryorder_child t_ref_deliveryorder_detail ";
$cmd = "mysqldump --triggers --no-data -u root -p$pwd one $tables_cx >> $temp_c";
exec($cmd);
$tables_cx2 = "t_resultinstrument t_samplestorage t_samplestorage_detail t_samplestoragedestroy t_samplestoragedestroy_detail t_samplestoragedestroy_detailnonsample t_samplestorageempty t_samplestorageemptydetail t_samplestorageout t_samplestorageout_detail t_sampling_queue_by_action t_sampling_queue_last_status t_sampling_queue_last_status_so t_samplingso t_samplingso_film t_samplingso_form t_samplingso_requirement t_worklist_confirm t_worklist_ref_confirm t_worklist_ref_confirmdetail tx_branch_status tx_mou_release xfer_internal xfer_internaldetail fo_verification_delivery fo_verification_delivery_add print_barcode_so_log t_onlineorder t_onlinetx";
$cmd = "mysqldump --triggers --no-data -u root -p$pwd one $tables_cx2 >> $temp_c";
exec($cmd);
// add routines
$cmd = "mysqldump --skip-triggers --routines -n -t -d -u root -p$pwd one >> $temp_c";
exec($cmd);
// add maxID for m_kelurahan, m_district , m_city , m_province
$sql = "select max(M_PatientAddressID) mID from m_patientaddress
where M_PatientAddressM_PatientID in ( $s_patient )";
$qry = $this->db->query($sql);
$max_M_PatientAddressID= 0;
if ($qry) {
$row = $qry->row();
if (isset($row)) {
$max_M_PatientAddressID = $row->mID;
}
}
$sql = "select max(M_KelurahanID) mID from m_kelurahan where M_KelurahanIsActive = 'Y'";
$qry = $this->db->query($sql);
$maxKelurahanID = 0;
if ($qry) {
$row = $qry->row();
if (isset($row)) {
$maxKelurahanID = $row->mID;
}
}
$sql = "select max(M_DistrictID) mID from m_district where M_DistrictIsActive = 'Y'";
$qry = $this->db->query($sql);
$maxDistrictID = 0;
if ($qry) {
$row = $qry->row();
if (isset($row)) {
$maxDistrictID = $row->mID;
}
}
$sql = "select max(M_CityID) mID from m_city where M_CityIsActive = 'Y'";
$qry = $this->db->query($sql);
$maxCityID = 0;
if ($qry) {
$row = $qry->row();
if (isset($row)) {
$maxCityID=$row->mID;
}
}
$sql = "select max(M_ProvinceID) mID from m_province where M_ProvinceIsActive = 'Y'";
$qry = $this->db->query($sql);
$maxProvinceID = 0;
if ($qry) {
$row = $qry->row();
if (isset($row)) {
$maxProvinceID = $row->mID;
}
}
$add_max =<<<EOF
drop table if exists last_master_id;
create table last_master_id (
id int not null auto_increment primary key,
M_PatientID int,
M_PatientAddressID int,
M_KelurahanID int,
M_DistrictID int,
M_CityID int,
M_ProvinceID int
);
insert into last_master_id values ( NULL , $s_patientMaxID, $max_M_PatientAddressID, $maxKelurahanID, $maxDistrictID,
$maxCityID, $maxProvinceID);
update m_company set M_CompanyIsDefault = 'Y' where M_CompanyID = $companyID;
update m_mou set M_MouIsDefault = 'Y' where M_MouID = $defaultMouID;
update mcu_offline_prepare set McuOfflinePrepareIsDownloaded='Y' where McuOfflinePrepareID = $mcuOfflineID;
EOF
;
file_put_contents($temp_c, $add_max, FILE_APPEND);
//sipe : penambahan numbering mcu_offline
$fn_lookup_external =<<<EOF
delimiter ;;
drop function if exists fn_lookup_external;;
CREATE DEFINER=`root`@`localhost` FUNCTION `fn_lookup_external`(`pNo` varchar(32), `pType` varchar(1)) RETURNS varchar(32) CHARSET latin1
READS SQL DATA
begin
if pType = 'L' then
return pNo;
end if;
end;;
delimiter ;
EOF
;
file_put_contents($temp_c, $fn_lookup_external, FILE_APPEND);
$update_s_numbering =<<<EOF
update s_numbering set
S_NumberingPrefix = '', S_NumberingSufix = '',S_NumberingReset = 'Y',
S_NumberingDigit=4, S_NumberingCounter=1 where S_NumberingType = 'L';
update s_numbering set
S_NumberingCounter=1 where S_NumberingType = 'PAY';
EOF
;
file_put_contents($temp_c, $update_s_numbering, FILE_APPEND);
$fn_numbering =<<<EOF
delimiter ;;
drop function if exists fn_numbering;;
CREATE DEFINER=`root`@`localhost` FUNCTION `fn_numbering`(`type` char(30)) RETURNS varchar(25) CHARSET utf8mb4
READS SQL DATA
begin declare number varchar(50);
declare prefix varchar(50);
declare prefix_date varchar(50);
declare sufix varchar(50);
declare counter int;
declare dgt int;
declare rst varchar(5);
declare udt datetime;
select S_NumberingPrefix, S_NumberingPrefixDate, S_NumberingSufix, S_NumberingCounter, S_NumberingDigit, S_NumberingReset,
S_NumberingLastUpdated
into prefix, prefix_date, sufix, counter, dgt, rst, udt
from s_numbering where S_NumberingType = type for update;
if rst = 'D' then
if date_format(udt, '%Y-%m-%d') <> date_format(now(), '%Y-%m-%d') then
set counter = 1;
end if;
elseif rst = 'M' then
if date_format(udt, '%Y-%m') <> date_format(now(), '%Y-%m') then
set counter = 1;
end if;
elseif rst = 'Y' then
if date_format(udt, '%Y') <> date_format(now(), '%Y') then
set counter = 1;
end if;
end if;
set number = '';
if prefix is not null and prefix <> '' then
set number = trim(prefix);
end if;
if prefix_date is not null and prefix_date <> '' then
set number = concat(trim(number),date_format(now(),prefix_date));
if type = 'P' then
set number = concat( 'M-',prefix,fn_numbering_year(now()));
end if;
if type = 'L' then
-- set number = fn_get_prefix_nolab( now() );
set number = right(date_format(now(),'%y'),1);
set @mcu_code = (select right(McuOfflinePrepareCode,3) from mcu_offline_prepare where McuOfflinePrepareIsActive='Y' limit 0,1 );
set number = concat(number,@mcu_code);
end if;
if type = 'PAY' then
set @mcu_code = (select McuOfflinePrepareCode from mcu_offline_prepare where McuOfflinePrepareIsActive='Y' limit 0,1 );
set number = concat( @mcu_code, '-', trim(prefix) );
end if;
end if;
if rst = 'X' then
set number = counter;
else
if type='PAY' then
set @s_counter = lpad(counter,dgt,'0');
set @xternal = (
select numberMapTarget
from number_map
where
numberMapOrigin = @s_counter
limit 0,1
);
set number = concat(trim(number), trim(@xternal) );
else
set number = concat(trim(number), lpad(counter,dgt,'0'));
end if;
end if;
if sufix is not null and sufix <> '' then
set number = concat(trim(number),trim(sufix));
end if;
if type = 'L' then
set @branch_code = (select M_BranchCode from m_branch where M_BranchIsActive = 'Y'
and M_BranchIsDefault = 'Y' limit 0,1 );
set number = concat(@branch_code,number);
end if;
update s_numbering set S_NumberingCounter = counter + 1, S_NumberingLastUpdated = NOW() where S_NumberingType=type;
return trim(number);
END;;
delimiter ;
update s_menu set S_MenuUrl = 'test/vuex/one-fo-registration-v8' where S_MenuID = $FO_REGISTRATION_ID;
update s_menu set S_MenuIsActive ='Y' where S_MenuName like 'Screening';
update m_usergroup set M_UserGroupDashboard = 'one-ui/test/vuex/one-fo-registration-v8'
where M_UserGroupDashboard like '%one-ui/test/vuex/one-fo-registration-v%';
EOF
;
file_put_contents($temp_c, $fn_numbering, FILE_APPEND);
$cmd = "gzip $temp_c";
exec($cmd);
$temp_c .= ".gz";
if (file_exists($temp_c)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($temp_c).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($temp_c));
readfile($temp_c);
unlink($temp_c);
exit;
}
}
public function app_old()
{
$temp_file = tempnam(sys_get_temp_dir(), 'x-copy-tar') . "tar.gz";
if (file_exists($temp_file)) {
unlink($temp_file);
}
$cmd="tar --exclude=database.php --exclude-vcs -zcf $temp_file -C /home/one/project/one one-api one-ui -C /home/one/project/birt one";
exec($cmd);
if (file_exists($temp_file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($temp_file).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($temp_file));
readfile($temp_file);
unlink($temp_file);
exit;
}
}
public function app($mcuCode)
{
$temp_file = tempnam(sys_get_temp_dir(), 'x-copy-tar') . ".tar";
if (file_exists($temp_file)) {
unlink($temp_file);
}
$cmd="tar --exclude=database.php --exclude-vcs -cf $temp_file -C /home/one/project/one one-api one-ui -C /home/one/project/birt one";
exec($cmd);
//tambah photo
$sql = "select * from mcu_offline_prepare where McuOfflinePrepareCode=?";
$qry = $this->db->query($sql, array($mcuCode));
if (! $qry) {
echo "ERR : No MCU Offline Prepare $mcuCode \n";
exit;
}
$rows = $qry->result_array();
$companyID = 0;
$mcuOfflineID = 0;
if (count($rows) > 0) {
$r = $rows[0];
$companyID = $r["McuOfflinePrepareM_CompanyID"];
$mcuOfflineID = $r["McuOfflinePrepareID"];
}
$sql = "select *
from m_patient
join t_orderheader on M_PatientID = T_OrderHeaderM_PatientID
where
M_PatientPhoto is not null
and M_PatientID in (
select T_OrderHeaderM_PatientID as id from t_orderheader
where T_OrderHeaderIsActive ='Y' and T_OrderHeaderM_CompanyID = ?
union
select Mcu_PreregisterDetailsM_PatientID as id
from
mcu_preregister_patients
where Mcu_PreregisterDetailsMcuOfflinePrepareID = ?
and Mcu_PreregisterDetailsIsActive = 'Y'
)";
$qry = $this->db->query($sql, array($companyID,$mcuOfflineID));
if (! $qry) {
echo "ERR : Patient Photo \n";
exit;
}
$rows = $qry->result_array();
if ($qry) {
$rows = $qry->result_array();
$counter = 0;
$s_files = "";
foreach ($rows as $r) {
$photo = substr($r["M_PatientPhoto"], 1);
$thumb = substr($r["M_PatientPhotoThumb"], 1);
$s_files .= " $photo $thumb";
$counter++;
if ($counter == 10) {
$cmd="tar -rf $temp_file -C /home/one/project/one $s_files";
exec($cmd);
$counter = 0;
$s_files = "";
}
}
if ($counter > 0) {
$cmd="tar -rf $temp_file -C /home/one/project/one $s_files";
exec($cmd);
$counter = 0;
$s_files = "";
}
}
$cmd = "gzip $temp_file";
exec($cmd);
$counter = 0;
$temp_file = $temp_file . ".gz";
if (file_exists($temp_file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($temp_file).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($temp_file));
readfile($temp_file);
unlink($temp_file);
exit;
}
}
}