Files
BE_IBL/application/controllers/mockup/mcuoffline-v2/Xcopy_subcon.php
2026-04-15 15:24:12 +07:00

539 lines
24 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_subcon extends MY_Controller
{
public function __construct()
{
parent::__construct();
}
function get_foto_file($mcuCode)
{
$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();
$arr_patient = array();
if (count($rows) > 0) {
$r = $rows[0];
$mcuOfflineID = $r["McuOfflinePrepareID"];
$sql = "
select distinct M_PatientPhoto , M_PatientPhotoThumb
from
mcu_preregister_patients
join m_patient on Mcu_PreregisterDetailsM_PatientID = M_PatientID
where Mcu_PreregisterDetailsMcuOfflinePrepareID = ?
and Mcu_PreregisterDetailsIsActive = 'Y'
and M_PatientPhoto is not null
and M_PatientPhoto <> ''";
$qry = $this->db->query($sql, array($mcuOfflineID));
if ($qry) {
$rows = $qry->result_array();
foreach ($rows as $r) {
$arr_patient[] = $r["M_PatientPhoto"];
if ($r["M_PatientPhotoThumb"] != "") {
$arr_patient[] = $r["M_PatientPhotoThumb"];
}
}
}
}
if (count($arr_patient) == 0 ) return array();
$arr_patient = array_filter($arr_patient, function ($p) {
$file = "/home/one/project/one" . $p;
return file_exists($file);
});
$result = array_map(function ($p) {
return str_replace("/one-media/one-photo/patient/", "", $p);
}, $arr_patient);
return $result;
}
public function db($mcuCode)
{
$file_one = $this->gen_db($mcuCode);
$file_log = $this->gen_log($mcuCode);
$foto_files = $this->get_foto_file($mcuCode);
// print_r($foto_files); exit;
$zip_file = tempnam(sys_get_temp_dir(), "mcu-prep-db") . "-{$mcuCode}" . ".zip";
if (file_exists($zip_file)) {
unlink($zip_file);
}
$cmd = "zip -j $zip_file $file_one $file_log";
exec($cmd);
if (count($foto_files) > 0) {
$a_files = array_chunk($foto_files, 10);
foreach($a_files as $files) {
$cmd = "cd /home/one/project/one/one-media/one-photo/patient";
$s_files = implode(" ", $files);
$cmd .= "; zip -u $zip_file $s_files";
exec($cmd);
}
}
if (file_exists($zip_file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($zip_file) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($zip_file));
readfile($zip_file);
unlink($zip_file);
exit;
}
}
public function gen_log($mcuCode)
{
$xdb = $this->load->database("onedev", true);
$pwd = $xdb->password;
$temp_file = tempnam(sys_get_temp_dir(), "log-db") . "-{$mcuCode}.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);
return $temp_file;
}
public function gen_db($mcuCode)
{
global $FO_REGISTRATION_ID;
$xdb = $this->load->database("onedev", true);
$pwd = $xdb->password;
$the_database_name = $xdb->database;
$temp_c = tempnam(sys_get_temp_dir(), "one-db") . "-{$mcuCode}.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 {$the_database_name} $p >> $temp_c";
} else {
$cmd = "mysqldump --triggers -u root -p$pwd -w \"$where\" {$the_database_name} $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 ";
$cmd = "mysqldump --triggers -u root -p$pwd {$the_database_name} $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 {$the_database_name} $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 {$the_database_name} $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 {$the_database_name} $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 {$the_database_name} $tables_c >> $temp_c";
exec($cmd);
$tables_c2 = "m_noteextra t_orderrefout t_testref 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 {$the_database_name} $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 {$the_database_name} $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 ";
$cmd = "mysqldump --triggers --no-data -u root -p$pwd {$the_database_name} $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 {$the_database_name} $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 {$the_database_name} $tables_cx2 >> $temp_c";
exec($cmd);
// add routines
$cmd = "mysqldump --skip-triggers --routines -n -t -d -u root -p$pwd {$the_database_name} >> $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);
return $temp_c;
}
}