ShuanghongS 10 tháng trước cách đây
mục cha
commit
7a8f219fa9

BIN
DOC/APEXTAO/20250205/A1601350035_I_V4.pdf


+ 2 - 2
service/ajax.class.php

@@ -429,7 +429,7 @@ class ajax {
                 $textSearch_arr = str_replace(",", ";", $textSearch_arr);
                 $textSearch_arr = array($textSearch_arr);
             }
-            $more_param = common::getInNotInSqlForSearch(strtolower(implode(';',$textSearch_arr)));
+            $more_param = common::getInNotInSqlForSearch(strtolower(utils::implode(';',$textSearch_arr)));
             //$sqlWhere .= " and (ARRAY[$more_param] && array_append(array[lower(booking_no)::text,lower(h_bol)::text, lower(po_no),lower(carrier_booking),lower(tracking_no)],''))";
             $sqlWhere .= " and ((ARRAY[$more_param] && array_append(ARRAY[lower(booking_no::text), lower(h_bol::text), lower(m_bol), lower(carrier_booking), lower(quote_no), lower(tracking_no)]||string_to_array(lower(ctnrs),','), ''::text))
                 or lower(po_no) like '%" . strtolower(common::check_input($_POST["_textSearch"])) . "%'
@@ -453,7 +453,7 @@ class ajax {
                 $textSearch_arr = str_replace(",", ";", $textSearch_arr);
                 $textSearch_arr = array($textSearch_arr);
             }
-            $more_param = common::getInNotInSqlForSearch(strtolower(implode(';',$textSearch_arr)));
+            $more_param = common::getInNotInSqlForSearch(strtolower(utils::implode(';',$textSearch_arr)));
             $sqlWhere .= " and ((ARRAY[$more_param] && array_append(array[lower(booking_no)::text,lower(h_bol)::text, lower(po_no),lower(carrier_booking)],''))
                 or lower(po_no) like '%" . strtolower(common::check_input($_POST["_textSearch"])) . "%')"; 
         } 

+ 2 - 2
service/login.class.php

@@ -1165,7 +1165,7 @@ class login {
             $online_ocean_arr = common::excuteListSql($online_ocean_sql);        
             if(empty($online_ocean_arr)){
                 $data = array("msg" =>"No matches");
-            }elseif(!empty($online_ocean_arr) && count($online_ocean_arr) > 1){
+            }elseif(!empty($online_ocean_arr) && utils::count($online_ocean_arr) > 1){
                 $data = array("msg" =>"Multiple results");
             }else{
                 $data =  $this->getTrackingInfo($online_ocean_arr[0]["serial_no"],$online_ocean_arr[0]["order_from"]);  
@@ -1230,7 +1230,7 @@ class login {
             $data = array("msg" =>"No matches");
             return $data;
         }
-        if(!empty($ocean_arr) && count($ocean_arr) > 1){
+        if(!empty($ocean_arr) && utils::count($ocean_arr) > 1){
             $data = array("msg" =>"Multiple results");
             return $data;
         }

+ 3 - 3
service/ocean_booking.class.php

@@ -148,7 +148,7 @@ class ocean_booking {
                 $textSearch_arr = str_replace(",", ";", $textSearch_arr);
                 $textSearch_arr = array($textSearch_arr);
             }
-            $more_param = common::getInNotInSqlForSearch(strtolower(implode(';',$textSearch_arr)));
+            $more_param = common::getInNotInSqlForSearch(strtolower(utils::implode(';',$textSearch_arr)));
             $sqlWhere .= " and ((ARRAY[$more_param] && array_append(array[lower(booking_no)::text,lower(h_bol)::text, lower(po_no),lower(carrier_booking)],''))
                 or lower(po_no) like '%" . strtolower(common::check_input($_POST["_textSearch"])) . "%')"; 
         } 
@@ -162,11 +162,11 @@ class ocean_booking {
         if(!is_array($transport_mode)){
             $transport_mode = array($transport_mode);
         }
-        if(count($transport_mode) == 1 && strtolower($transport_mode[0]) == 'all'){
+        if(utils::count($transport_mode) == 1 && strtolower($transport_mode[0]) == 'all'){
             $transport_mode = array("sea","air","road");         
         }
 
-        $transport_mode = implode(";",$transport_mode);
+        $transport_mode = utils::implode(";",$transport_mode);
         $mode_param = common::getInNotInSqlForSearch($transport_mode);
 
         

+ 34 - 38
service/ocean_order.class.php

@@ -107,7 +107,7 @@ class ocean_order {
                     $file_serial_nos[] = $type;
                 }
             }
-            $file_serial_nos = implode(';',$file_serial_nos);
+            $file_serial_nos = utils::implode(';',$file_serial_nos);
             if($transport_mode == 'sea'){
                 $sql = "select display_name,format_name as file_type,serial_no,m_h from public.ra_online_file_format where lower(serial_no) " . common::getInNotInSql($file_serial_nos) . " 
                         and active = true and client_upload = true";
@@ -128,7 +128,7 @@ class ocean_order {
             //checked from 
             if(empty($_POST['file_type']) || empty($_FILES['file']["name"])){
                 $data = array(
-                    'msg' => 'File Type or File must select'
+                    'msg' => 'File Type or File must select.'
                 );
                 common::echo_json_encode(500,$data);
                 exit();
@@ -141,9 +141,9 @@ class ocean_order {
             } elseif ($transport_mode == "air") {
                 $count = common::excuteObjectSql("select * from air where lower(hawb) = '" . strtolower($bol) . "'");
             }
-            if (empty($count) || count($count) <= 0){
+            if (empty($count) || utils::count($count) <= 0){
                 $data = array(
-                    'msg' => 'HBOL does not exist'
+                    'msg' => 'HBOL does not exist.'
                 );
                 common::echo_json_encode(500,$data);
                 exit();
@@ -157,7 +157,7 @@ class ocean_order {
             //查询存在的文件类型最大序号
             $num = common::excuteOneSql("select count(*) from $_table where lower(bol) = '" . strtolower($bol) . "' and  format_serailno = '".$format['serial_no']."'");
             try {
-                //$allow_extend = "|.pdf|.xls|.xlsx|.doc|.docx|";
+                //$allow_extend = "|.pdf|.xlsx|.docx|";
                 $allow_extend = "|.pdf|";
                 $file_name = $_FILES['file']["name"];
                 $errorMsg = "";
@@ -169,22 +169,18 @@ class ocean_order {
                     }
                     $size = floor($_FILES ["file"]['size'][$i] / 1024 / 1024);
                     if ($size > 5) {
-                        $errorMsg = $_FILES['file']["name"][$i] . "is larger than 5M.";
+                        $errorMsg = $_FILES['file']["name"][$i] ." is larger than 5M.";
                         continue;
                     }
                     if ($_FILES["file"]["error"][$i] > 0) {
-                        $errorMsg = " File Upload Error(" . $_FILES ["file"]["error"][$i] . ")";
+                        $errorMsg = " File Upload Error(". $_FILES ["file"]["error"][$i] .")";
                         continue;
                     }
-                    // if (utils::hasMacro($_FILES['file']['tmp_name'][$i])) {
-                    //     $errorMsg .= $_FILES['file']["name"][$i] . " has Macro,pls remove;";
-                    //     continue;
-                    // }
                     $path_parts = pathinfo($file_name[$i]);
                     $exten = $path_parts['extension'];
                     if (stristr($allow_extend, "|." . $exten . "|") === FALSE) {
-                        //$errorMsg .= ' Only can upload PDF/Excel/Doc file;';
-                        $errorMsg = $_FILES['file']["name"][$i].' must PDF Type.';
+                        $errorMsg = $_FILES['file']["name"][$i].', File type error.';
+                        //continue;
                     }
 
                     $filename = $bol."_".$format['standard']."_V".($i+1+$num). "." . $exten;
@@ -231,25 +227,26 @@ class ocean_order {
                             continue;
                         }
                     } else {
-                        //读取文件内容后,重新生成无宏版本文件,支持docx,xlsx 
-                        // $from_filename = $file_name[$i];
-                        // $inputFileName = $save_path . $from_filename;
-                        // $outputFileName = $save_path . $filename;
-                        // if(move_uploaded_file($_FILES['file']['tmp_name'][$i],$outputFileName)){
-                        //     $outputFileName = $save_path . $filename;
-                        //     //按outputFileName路径重新生成文件,并且删除旧文件(inputFileName)
-                        //     //utils::removeFIlemacro($inputFileName,$outputFileName,$exten);
-                        //     //utils::hasMacros($outputFileName);
-                        //     //utils::checkExcelMacros($outputFileName,$filename_no_exten);
-                        //     $sql .= "insert into $_schemas.$_table (file_name, file_path, upload_date, upload_ip, upload_by, bol, file_type, file_size, online_upload, 
-                        //             origin, destination, from_station, serial_no, 
-                        //             online_format,format_serailno,source_filename) 
-                        //         values ('" . common::check_input($filename) . "','" . common::check_input($save_path) . "', now(), '" . common::ip() . "', 
-                        //                 '" . common::check_input(_getLoginName()) . "','" . common::check_input(strtoupper($bol)) . "', '$order_type', '" . common::check_input($file_size) . "',
-                        //                 't', '" . common::check_input($origin_station) . "', '" .common::check_input($destination_station) . "',
-                        //                 '" . common::check_input($from_station) . "', '" . $serial_no . "',
-                        //                 '" . common::check_input($file_type) . "','" . common::check_input($format_serialno) . "','" . common::check_input($filename) . "');";
-                        // }
+                        $outputFileName = $save_path . $filename;
+                        if(move_uploaded_file($_FILES['file']['tmp_name'][$i],$outputFileName)){
+                            //判断文件时候待宏,如果则这删除
+                            if(utils::hasMacros($outputFileName)){
+                                unlink($outputFileName);
+                                $errorMsg = "Upload Filed Has Macros,Please remove and re-upload.";
+                                continue;
+                            }
+                            $sql .= "insert into $_schemas.$_table (file_name, file_path, upload_date, upload_ip, upload_by, bol, file_type, file_size, online_upload, 
+                                    origin, destination, from_station, serial_no, 
+                                    online_format,format_serailno,source_filename) 
+                                values ('" . common::check_input($filename) . "','" . common::check_input($save_path) . "', now(), '" . common::ip() . "', 
+                                        '" . common::check_input(_getLoginName()) . "','" . common::check_input(strtoupper($bol)) . "', '$order_type', '" . common::check_input($file_size) . "',
+                                        't', '" . common::check_input($origin_station) . "', '" .common::check_input($destination_station) . "',
+                                        '" . common::check_input($from_station) . "', '" . $serial_no . "',
+                                        '" . common::check_input($file_type) . "','" . common::check_input($format_serialno) . "','" . common::check_input($filename) . "');";
+                        } else {
+                            $errorMsg = "Upload Filed Failed.";
+                            continue;
+                        }
                     } 
                     //根据配置,看需要同步文件,
                     $doc_upload_log_table =  $transport_mode == "sea" ? "ra_online_doc_upload_log" : "air_doc_upload_log";
@@ -272,8 +269,6 @@ class ocean_order {
                         $sql .= "INSERT INTO public.$doc_upload_log_table(serial_no, station, download_time)
                                 VALUES ('".$serial_no."', '" .common::check_input($origin_station) . "', now());";       
                     }
-                    
-                    
                 }
                 //根据配置发送通知邮件 相同文件类型只提醒一次
                 if(!empty($format['notify_station'])  && empty($errorMsg)){
@@ -284,7 +279,7 @@ class ocean_order {
                     $ks_from = empty($ks_from)? 'f' : $ks_from;
                     $ks_to = empty($ks_to)? 'f' : $ks_to;
                     if($ks_from == "f" && $ks_to == "f"){
-                        $errorMsg = "Both Non Ksmart,pls checked";
+                        $errorMsg = "Both Non Ksmart,Please checked.";
                     }
                     
                     $curr_date_config = common::excuteObjectSql("SELECT to_char(now()::date,'Mon_DD_YYYY') as d1_day,to_char(now()::date,'Mon_DD_YYYY HH:MM') as d2_day");
@@ -440,6 +435,7 @@ class ocean_order {
                     }
                 }
 
+                //代表前面有错误发生,终止SQL的执行
                 if (!empty($errorMsg)) {
                     $data = array(
                         'msg' => $errorMsg
@@ -790,7 +786,7 @@ class ocean_order {
                 $textSearch_arr = str_replace(",", ";", $textSearch_arr);
                 $textSearch_arr = array($textSearch_arr);
             }
-            $more_param = common::getInNotInSqlForSearch(strtolower(implode(';',$textSearch_arr)));
+            $more_param = common::getInNotInSqlForSearch(strtolower(utils::implode(';',$textSearch_arr)));
             //$sqlWhere .= " and (ARRAY[$more_param] && array_append(array[lower(booking_no)::text,lower(h_bol)::text, lower(po_no),lower(carrier_booking),lower(tracking_no)],''))";
             $sqlWhere .= " and ((ARRAY[$more_param] && array_append(ARRAY[lower(booking_no::text), lower(h_bol::text), lower(m_bol), lower(carrier_booking), lower(quote_no), lower(tracking_no)]||string_to_array(lower(ctnrs),','), ''::text))
                 or lower(po_no) like '%" . strtolower(common::check_input($_POST["_textSearch"])) . "%'
@@ -804,10 +800,10 @@ class ocean_order {
         if(!is_array($transport_mode)){
             $transport_mode = array($transport_mode);
         }
-        if((count($transport_mode) == 1 && strtolower($transport_mode[0]) == 'all')){
+        if((utils::count($transport_mode) == 1 && strtolower($transport_mode[0]) == 'all')){
             $transport_mode = array("sea","air","road");         
         }
-        $transport_mode = implode(";",$transport_mode);
+        $transport_mode = utils::implode(";",$transport_mode);
 
         $mode_param = common::getInNotInSqlForSearch($transport_mode);
         $sqlWhere .= " and transport_mode in ($mode_param)";

+ 42 - 10
service/tools.class.php

@@ -136,12 +136,14 @@ class tools {
                 }
             }
             
-            $sql = "select first_name,last_name,user_login,email,
-                EXTRACT(DAY from (now() - last_pwd_change)) as last_pwd_change_date from ra_online_user where user_login = '"._getLoginName()."' ";
+            $sql = "select u.first_name,u.last_name,u.user_login,u.email,EXTRACT(DAY from (now() - u.last_pwd_change)) as last_pwd_change_date,
+                    k.date_format,k.numbers_format
+                from ra_online_user u
+                    left join  kln_user_extend ue on u.user_login = ue.user_login
+                where lower(u.user_login) = '".strtolower(_getLoginName())."' ";
+
             $data = common::excuteObjectSql($sql);
             $data["expire_day"] = $PASSWORD_CHANGE_CYCLE - $data['last_pwd_change_date'];
-            $data["date_fromat"] = "03/15/2024";
-            $data["numbers_format"] = "1,234.56(US/UK)";
             common::echo_json_encode(200,$data);
             exit();
         }
@@ -151,11 +153,17 @@ class tools {
             if ($save_model == "profile"){
                 $user_name = common::check_input($_POST['user_name']);
                 $email = common::check_input($_POST['email']);
-                $sql = "update public.ra_online_user set user_login = '$user_name',email = '$email'  where user_login = '"._getLoginName()."'";
+                $sql = "update public.ra_online_user set user_login = '$user_name',email = '$email'  where lower(user_login) = '".strtolower(_getLoginName())."'";
             }else{
                 $date_fromat = common::check_input($_POST['date_fromat']);
                 $numbers_format = common::check_input($_POST['numbers_format']);
-                $sql = "update public.ra_online_user set date_fromat = '$date_fromat',numbers_format = '$numbers_format'  where user_login = '"._getLoginName()."'";
+                $exist_kln_user = common::excuteObjectSql("select user_login from  public.kln_user_extend where  lower(user_login) = '".strtolower(_getLoginName())."'");
+                if (!empty($exist_kln_user['user_login'])){
+                    $sql = "update public.kln_user_extend set date_fromat = '$date_fromat',numbers_format = '$numbers_format'  where lower(user_login) = '".strtolower(_getLoginName())."'";
+                } else {
+                    $sql = "INSERT INTO public.kln_user_extend(user_login, date_format, numbers_format, subscribe_hbol)
+                        VALUES ('"._getLoginName()."', '$date_fromat', '$numbers_format', null);";
+                }
             }
             common::excuteUpdateSql($sql);
             $data = array("msg" => "save Successful");
@@ -164,11 +172,35 @@ class tools {
         }
 
         if ($operate == "subscribe_notification_init") {
-            $data =array();
-
-            //Milestone Update rule 
+            $subscribur_data =array();
+            //Milestone Update的页面初始渲染数据
+            $milestones = common::excuteListSql("select * from customer_service_milestone_sno order by type, sno");
+            $ocean_milestone = array();
+            $air_milestone = array();
+            foreach($milestones as $milestone){
+                if($milestone['type'] == "air"){
+                    $air_milestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
+                } 
+                if($milestone['type'] == "ocean"){
+                    $ocean_milestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
+                }
+            }
+            $subscribur_data["OceanCheckBoxList"] = $ocean_milestone;
+            $subscribur_data["AirCheckBoxList"] = $air_milestone;
+
+            $kln_user = common::excuteObjectSql("select * from  public.kln_user_extend where  lower(user_login) = '".strtolower(_getLoginName())."'");
+            //查询用户对应的Rule
+            $subscribe_rule_sql = "select * from public.notifications_rules where notifications_type = 'Subscribe' and lower(user_login) = '".strtolower(_getLoginName())."'";
+            $subscribe_rules = common::excuteListSql($subscribe_rule_sql);
+            foreach($subscribe_rules as $rules){
+                if($rules['rules_type'] == "Milestone Update"){
+                    $ocean_milestone = utils::implode(";",$rules['ocean_milestone']);
+                    //$rules["OceanCheckedList"] = 
+                }
+                $subscribur_data[$rules['rules_type']] = $rules;
+            }
 
-            common::echo_json_encode(200,$data);
+            common::echo_json_encode(200,$subscribur_data);
             exit();
         }
     }

+ 12 - 12
utils/common.class.php

@@ -158,7 +158,7 @@ class common {
     
     public static function getCompanySearch() {
         $sc_list = _get_schemas();
-        if (count($sc_list) == 1) {
+        if (utils::count($sc_list) == 1) {
             return "";
         }
         if (_isCustomerLogin()) {
@@ -245,7 +245,7 @@ class common {
             $sqlWhere .= " and order_from='" . $_POST["_apex_or_sfs"] . "'";
         }
 
-        if (count($schemas_list) == 1) {
+        if (utils::count($schemas_list) == 1) {
             $schames = $schemas_list[0]["schemas_name"];
             if(strtolower($type) == "air_booking" ||strtolower($type) == "air")
             {
@@ -282,7 +282,7 @@ class common {
                 $sqlWhere .= self::_air($schames);
             }
 
-        } elseif (count($schemas_list) == 2) {
+        } elseif (utils::count($schemas_list) == 2) {
             if(strtolower($type) == "air_booking" ){
                 
             }else{
@@ -1194,10 +1194,10 @@ class common {
             $transportation = array($transportation);
         }
         $mode_param = "";
-        if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
+        if(utils::count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
             $mode_param = "'sea','air','road'";         
         }else{
-            $transport_mode = implode(';', $transportation);
+            $transport_mode = utils::implode(';', $transportation);
             $mode_param = common::getInNotInSqlForSearch($transport_mode);
         }
         $sqlWhere .= " and transport_mode in ($mode_param)";
@@ -1294,10 +1294,10 @@ class common {
             $transportation = array($transportation);
         }
         $mode_param = "";
-        if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
+        if(utils::count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
             $mode_param = "'sea','air','road'";         
         }else{
-            $transport_mode = implode(';', $transportation);
+            $transport_mode = utils::implode(';', $transportation);
             $mode_param = common::getInNotInSqlForSearch($transport_mode);
         }
         $sqlWhere .= " and transport_mode in ($mode_param)";    
@@ -1315,7 +1315,7 @@ class common {
         //common::getTopBarSQL($toporiginType,$_REQUEST["transportation"]);    
         $shippr_uncode_10 = common::excuteListSql($shippr_uncode_10_sql);
         //如果值没有:客户地址-->站点地址-->Port地址(POL/POD) 
-        if(count($shippr_uncode_10) == 1 && empty($shippr_uncode_10[0]["shippr_uncode"])){
+        if(utils::count($shippr_uncode_10) == 1 && empty($shippr_uncode_10[0]["shippr_uncode"])){
             $toporiginType = "fport_of_loading_un";
             $shippr_uncode_10_sql = "with aa as  (select count(fport_of_loading_un) as num,fport_of_loading_un as shippr_uncode 
                     from public.kln_ocean where 1=1 and COALESCE(fport_of_loading_un,'')<>'' $sqlWhere group by fport_of_loading_un order by num desc limit 10)
@@ -1340,7 +1340,7 @@ class common {
 
         $consignee_uncode_10 = common::excuteListSql($consignee_uncode_10_sql);
         //如果值没有:客户地址-->站点地址-->Port地址(POL/POD) 
-        if(count($consignee_uncode_10) == 1 && empty($consignee_uncode_10[0]["consignee_uncode"])){
+        if(utils::count($consignee_uncode_10) == 1 && empty($consignee_uncode_10[0]["consignee_uncode"])){
             $topdestinationinType = "mport_of_discharge_un";
             $consignee_uncode_10_sql = "with aa as  (select count(mport_of_discharge_un) as num,mport_of_discharge_un as consignee_uncode from public.kln_ocean where 1=1 and COALESCE(mport_of_discharge_un,'')<>'' $sqlWhere group by mport_of_discharge_un order by num desc limit 10)
                 select   aa.*,dd.* from  aa  
@@ -1454,7 +1454,7 @@ class common {
         $barList = array();
         $groupedItems = array();
         foreach ($r2_data as $item) {
-            if(!in_array($item['month'],$barList)){
+            if(!utils::in_array($item['month'],$barList)){
                 $barList[] = $item['month'];
             }
             $groupedItems[$item['currency']][] = $item;
@@ -1959,10 +1959,10 @@ class common {
             $transportation = array($transportation);
         }
         $mode_param = "";
-        if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
+        if(utils::count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
             $mode_param = "'sea','air','road'";         
         }else{
-            $transport_mode = implode(';', $transportation);
+            $transport_mode = utils::implode(';', $transportation);
             $mode_param = common::getInNotInSqlForSearch($transport_mode);
         }
         return " and transport_mode in ($mode_param)";

+ 31 - 139
utils/utils.class.php

@@ -621,7 +621,7 @@ class utils {
                     $temp[] = $v;
                 }
             }
-            if(count($temp) <= 1){
+            if(utils::count($temp) <= 1){
                 return $company;
             }
         }
@@ -634,7 +634,7 @@ class utils {
                     $temp[] = $v;
                 }
             }
-            if(count($temp) == 1){
+            if(utils::count($temp) == 1){
                 if ($_schemas == "public") {//apex ocean和air 分开
                     $sql = "SELECT company  from ocean.contacts where contact_id = '" . common::check_input($temp[0]) . "' ";
                 } else {
@@ -712,148 +712,40 @@ class utils {
     public static function removeDuplicateArray($array){
         $result = array();
         foreach ($array as $value) {
-            if (!in_array($value, $result)) {
+            if (!utils::in_array($value, $result)) {
                 $result[] = $value;
             }
         }
         return $result;
     }
 
-    /**
-     * 读取文件内容后,重新生成无宏版本文件,支持docx,xlsx(这两个文件类型,被设计就是不能带宏的) 
-     * 估计废除了,除非转pdf去宏,没有其他办法。libreoffice可以通过软件里面的tools栏位按钮去点击去宏处理,但没有命令行。
-     * 使用unoconv转换文档,但是最新的unoconv,不支持unoconv -f docx --no-macro 命令,网上查询的命令有误
-     */
-    // public static function removeFIlemacro($inputFileName,$outputFileName,$file_type) {
-    //     include_once ONLINE_ROOT . 'thirdparty_vendors' . DS . 'vendor' . DS . 'autoload.php';  
-    //     if($file_type == "xlsx" || $file_type == "xls"){
-    //         // 读取文件
-    //         // $spreadsheet = PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
-    //         // // 生成新文件
-    //         // $writerType = ucfirst($file_type);
-    //         // $writer = PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, $writerType); // 使用 Xlsx 格式保存
-    //         // $writer->save($outputFileName);
-    //         // // 删除来源文件
-    //         // unlink($inputFileName);
-    //         // LibreOffice 的命令行命令
-    //         // $command = "soffice --headless --convert-to pdf --outdir " . dirname($outputFileName) . " " . $inputFileName;
-    //         // // 执行命令
-    //         // exec($command, $output, $return_var);
-    //         // // 检查命令是否成功执行
-    //         // if ($return_var === 0) {
-    //         //     echo "文档转换成功,已保存为无宏版本:$outputFile\n";
-    //         // } else {
-    //         //     echo "文档转换失败,返回代码:$return_var\n";
-    //         //     echo "输出:\n" . implode("\n", $output);
-    //         // }   
-    //     }
-    //     if($file_type == "docx" || $file_type == "doc"){
-    //         //加载现有的 Word 文档
-    //         // $phpWord = PhpOffice\PhpWord\IOFactory::load($inputFileName);
-    //         // // 保存新的 Word 文档
-
-    //         // // $newPhpWord = new PhpOffice\PhpWord\PhpWord();
-    //         // // $newSection = $newPhpWord->addSection();
-    //         // // $newSection->addText('Hello World !');
-    //         // $writer = PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); // 使用 DOCX 格式保存
-    //         // $writer->save($outputFileName);
-    //         // //删除来源文件
-    //         // unlink($inputFileName);
-
-    //         // 使用unoconv转换文档
-    //         //$command = "unoconv -f docx --no-macro '$inputFileName' -o '$outputFileName'";
-            
-    //         // $command = "libreoffice --headless --convert-to pdf $inputFileName --outdir D:\DOC\APEXTAO\20250127";
-    //         // $output = shell_exec($command);
- 
-    //         // if ($output) {
-    //         //     echo "文件转换成功!";
-    //         // } else {
-    //         //     echo "文件转换失败。";
-    //         // }
-
-    //         //LibreOffice 的命令行命令
-    //         $command = "soffice --headless --convert-to pdf --outdir " . dirname($outputFileName) . " " . $inputFileName;
-    //         // 执行命令
-    //         exec($command." 2>&1", $output, $return_var);
-    //         // 检查命令是否成功执行
-    //         if ($return_var === 0) {
-    //             echo "文档转换成功,已保存为无宏版本:$outputFile\n";
-    //         } else {
-    //             echo "文档转换失败,返回代码:$return_var\n";
-    //             echo "输出:\n" . implode("\n", $output);
-    //         }  
-
-            
-    //         // 移除宏的命令
-    //         //$command = "soffice --convert-to docx:writer_pdf_Export --infilter=MS Word 97 --outdir /path/to/output $inputFileName";
-    //         //exec($command);
-            
-    //         // 复制无宏的文档到新位置
-    //         //copy("/path/to/output/document.pdf", $outputFileName);
-    //     }
-    // }
-
-
-    // public static function hasMacros($filePath) {
-    //     $extension = pathinfo($filePath, PATHINFO_EXTENSION);
-    //     if ($extension === 'xlsx') {
-    //         // 检查 .xlsx 文件
-    //         $zip = new ZipArchive();
-    //         if ($zip->open($filePath) === TRUE) {
-    //             // 检查是否存在 vbaProject.bin 文件
-    //             $hasMacros = $zip->locateName('xl/vbaProject.bin') !== false;
-    //             $zip->close();
-    //             return $hasMacros;
-    //         } else {
-    //             return false; // 无法打开文件
-    //         }
-    //     } elseif ($extension === 'docx') {
-    //         // 检查 .docx 文件
-    //         $zip = new ZipArchive();
-    //         if ($zip->open($filePath) === TRUE) {
-    //             // 检查是否存在 vbaProject.bin 文件
-    //             $hasMacros = $zip->locateName('word/vbaProject.bin') !== false;
-    //             $zip->close();
-    //             return $hasMacros;
-    //         } else {
-    //             return false; // 无法打开文件
-    //         }
-    //     } else {
-    //         return false; // 不是支持的文件类型
-    //     }
-    // }
-    //$command = "soffice --headless --convert-to pdf --outdir " . dirname($outputFileName) . " " . $inputFileName;
-
-    // public static function checkExcelMacros($filePath,$file_name) {
-    //     // Construct the command to execute LibreOffice in headless mode.
-    //     // Replace with the actual path to your LibreOffice executable if needed.
-    //     $libreofficePath = '"C:\Program Files\LibreOffice\program\soffice.exe"'; // Example path, adjust as needed.
-    //     //$command = "$libreofficePath --headless --convert-to txt:Text -o /tmp/output.txt \"$filePath\"";
-    //     $command = "$libreofficePath --headless --convert-to txt --outdir " . dirname($filePath) . " " . $filePath;
-    //     $convert_file = dirname($filePath)."\\".$file_name.".txt";
-    //     // Execute the command.
-    //     exec($command, $output, $returnCode);
-    
-    //     // Check for errors.
-    //     if ($returnCode !== 0) {
-    //         return "Error converting file: " . implode("\n", $output); // Or handle the error as needed.
-    //     }
-    
-    //     // Read the (now text) representation of the file. We do this because the macro information is sometimes embedded in the file structure in a way that directly parsing the spreadsheet file is very difficult.
-    //     $textFile = file_get_contents($convert_file);
-    
-    //     // Clean up the temporary file (important!).
-    //     //unlink($convert_file);
-    
-    //     // Search for indicators of macros.  These are not foolproof, but they are a good start.
-    //     // More sophisticated methods might involve inspecting the file's internal structure.
-    //     // Look for VBA project stream.
-    //     if (strpos($textFile, "VBA Project") !== false || strpos($textFile, "PROJECT") !== false || strpos($textFile, "ThisDocument") !== false || strpos($textFile, "Module") !== false || strpos($textFile, "Sub ") !== false || strpos($textFile, "Function ") !== false) {  // Common macro indicators
-    //         return true; // Macros found.
-    //     } else {
-    //         return false; // No clear macro indicators found.
-    //     }
-    // }
+    public static function hasMacros($filePath) {
+        $extension = pathinfo($filePath, PATHINFO_EXTENSION);
+        if ($extension === 'xlsx') {
+            // 检查 .xlsx 文件
+            $zip = new ZipArchive();
+            if ($zip->open($filePath) === TRUE) {
+                // 检查是否存在 vbaProject.bin 文件
+                $hasMacros = $zip->locateName('xl/vbaProject.bin') !== false;
+                $zip->close();
+                return $hasMacros;
+            } else {
+                return false; // 无法打开文件
+            }
+        } elseif ($extension === 'docx') {
+            // 检查 .docx 文件
+            $zip = new ZipArchive();
+            if ($zip->open($filePath) === TRUE) {
+                // 检查是否存在 vbaProject.bin 文件
+                $hasMacros = $zip->locateName('word/vbaProject.bin') !== false;
+                $zip->close();
+                return $hasMacros;
+            } else {
+                return false; // 无法打开文件
+            }
+        } else {
+            return false; // 不是支持的文件类型
+        }
+    } 
 }
 ?>