ShuanghongS 1 tydzień temu
rodzic
commit
bae5785a0a
2 zmienionych plików z 33 dodań i 13 usunięć
  1. 11 5
      service/destination_delivery.class.php
  2. 22 8
      utils/common.class.php

+ 11 - 5
service/destination_delivery.class.php

@@ -503,6 +503,7 @@ class destination_delivery {
                 //检查判断规则不能重合
                 $seaRule = [];
                 $airRule = [];
+                $startIndex = null;
 
                 foreach($_mode_type as $key => $v){
                     $mode_type = $v;
@@ -512,7 +513,9 @@ class destination_delivery {
                     $carrier = $_carrier[$key];
                     if( $mode_type == 'sea'){
                         $seaRule[] = explode(",",$_ports[$key]);
-                        ///$sea_carrier_index += 1;
+                        if(empty($startIndex)){
+                              $startIndex = $key;
+                        }
                     } else {
                         $airRule[] = explode(",",$_ports[$key]);  
                     }
@@ -544,7 +547,7 @@ class destination_delivery {
                 }
 
                 //检查规则不能重复
-                $errmsg .= common::checkOverlap($seaRule,"Sea Rule");
+                $errmsg .= common::checkOverlap($seaRule,"Sea Rule",$startIndex);
                 $errmsg .= common::checkOverlap($airRule,"Air Rule");
             }
 
@@ -1580,7 +1583,8 @@ class destination_delivery {
                     ooc.booking_no,
                     (select manifest_type from public.ocean o where o.serial_no = ooc.serial_no  limit 1) as manifest_type,
                     ooc.agent,
-                    ooc.order_from
+                    ooc.order_from,
+                    ooc.dest_op
                 from ooc  
                     LEFT JOIN public.oc_container oc ON oc.serial_no::text = ooc.serial_no::text  
                 where  ooc.order_from = 'public' and transport_mode = 'sea' ".$sqlCtnr."
@@ -1612,7 +1616,8 @@ class destination_delivery {
                     ooc.booking_no,
                     (select manifest_type from sfs.ocean o where o.serial_no = ooc.serial_no  limit 1) as manifest_type,
                     ooc.agent,
-                    ooc.order_from
+                    ooc.order_from,
+                    ooc.dest_op
                 from ooc  
                     LEFT JOIN sfs.oc_container oc ON oc.serial_no::text = ooc.serial_no::text  
                 where  ooc.order_from = 'sfs' and transport_mode = 'sea' ".$sqlCtnr."
@@ -1644,7 +1649,8 @@ class destination_delivery {
                     ooc.booking_no,
                     '' as manifest_type,
                     ooc.agent,
-                    ooc.order_from
+                    ooc.order_from,
+                    ooc.dest_op
                 from ooc
                 where ooc.transport_mode = 'air'
             )

+ 22 - 8
utils/common.class.php

@@ -3571,7 +3571,7 @@ class common {
         }
     }
 
-    public static function checkOverlap($post_arr,$name) {
+    public static function checkOverlap($post_arr,$name,$startIndex = 0) {
         $errors = "";
         $num = count($post_arr);
         //$_POST['rule_type'];
@@ -3580,12 +3580,12 @@ class common {
                 $set1 = $post_arr[$i] ?? [];
                 $set2 = $post_arr[$j] ?? [];
                 
-                $intersection = common::array_intersect_own($set1, $set2,$_POST['rule_type'][$i]);
+                $intersection = common::array_intersect_own($set1, $set2,$_POST['rule_type'][$i+$startIndex]);
                 $intersectionC = "";
                 //这个特殊。如果ports 存在一样的,那检查carrier 是否存在一样的。
                 if ($name == "Sea Rule") {
-                    $setC1 = explode(",",$_POST['carrier'][$i]) ?? [];
-                    $setC2 = explode(",",$_POST['carrier'][$j]) ?? [];
+                    $setC1 = explode(",",$_POST['carrier'][$i+$startIndex]) ?? [];
+                    $setC2 = explode(",",$_POST['carrier'][$j+$startIndex]) ?? [];
                     
                     $intersectionC = array_intersect($setC1, $setC2);
                     if (!empty($intersection) && !empty($intersectionC)) {
@@ -3610,16 +3610,19 @@ class common {
         return $errors;
     }
 
-    public static function array_intersect_own($set1, $set2,$rule_type){
+    public static function array_intersect_own($set1, $set2){
         $intersection = array_intersect($set1, $set2);
-        if ($rule_type <> '*Default Rule' && ($set1 == 'ALL' || $set2 == 'ALL')){
-            $intersection = "ALL";
-        }
+
+        //这个是无效的$set1是数组,不是字符串。
+        // if ($rule_type <> '*Default Rule' && ($set1 == 'ALL' || $set2 == 'ALL')){
+        //     $intersection = "ALL";
+        // }
         return $intersection;
     }
 
     public static function sendDestinationDeliveryReminder($data,$shipmentsData,$status){
         $html_tr = "";
+        $dest_op_arr = array();
         foreach($shipmentsData['data'] as $shipment){
             $html_tr .="<tr style=\"color: #ED6D00;\">
                 <td align=\"center\" style=\" width: 162px;padding: 10px;word-wrap: break-word; word-break: break-all; white-space: normal;\">".$shipment['h_bol']."</td>
@@ -3627,6 +3630,9 @@ class common {
                 <td align=\"center\" style=\" width: 162px;padding: 10px;word-wrap: break-word; word-break: break-all; white-space: normal;\">".$shipment['package_type']."</td>
                 <td align=\"center\" style=\" width: 162px;padding: 10px;word-wrap: break-word; word-break: break-all; white-space: normal;\">".$shipment['kgw']."</td>
             </tr>";
+            if(!empty($shipment['dest_op'])){
+                $dest_op_arr[] = $shipment['dest_op'];
+            }
         }
         
         $kln_pic_email = $data['kln_pic'];
@@ -3676,6 +3682,14 @@ class common {
         $email_from = "US.KApex.Online@kerryapex.com";
         $to_email = $customer_email;
         $cc_email = $kln_pic_email;
+        if(!empty($dest_op_arr)){
+            $dest_op_arr = array_values(array_unique($dest_op_arr));
+            $more_param = common::getInNotInSqlForSearch(strtolower(utils::implode(';',$dest_op_arr)));
+            $destOPEmail = common::excuteObjectSql("select string_agg(email,';') as email from employee where COALESCE(email,'') <> '' and  lower(employee_id) in (".$more_param.")");
+            if(!empty($destOPEmail['email'])){
+                $cc_email = $cc_email.";".$destOPEmail['email'];
+            }
+        }
         
         error_log($contents['content']);