ShuanghongS 1 месяц назад
Родитель
Сommit
db869b249b
2 измененных файлов с 93 добавлено и 27 удалено
  1. 40 19
      include.ini.php
  2. 53 8
      utils/common.class.php

+ 40 - 19
include.ini.php

@@ -183,11 +183,18 @@ function _customerFilerSearchHandNew($tableName,$user, $schemas = "public", $p =
     }
 
     //controlling_customer_code
+    // if (utils::checkExist($tt, 't')) {
+    //     if (empty($sqlWhere1)) {
+    //         $sqlWhere1 = " exists(select 1 from $schemas.ocean_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)."  limit 1)";
+    //     } else {
+    //         $sqlWhere1 .= " or exists(select 1 from $schemas.ocean_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
+    //     }
+    // }
     if (utils::checkExist($tt, 't')) {
         if (empty($sqlWhere1)) {
-            $sqlWhere1 = " exists(select 1 from $schemas.ocean_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)."  limit 1)";
+            $sqlWhere1 = " lower(customer_code) " . common::getInNotInSql($_contact_id);
         } else {
-            $sqlWhere1 .= " or exists(select 1 from $schemas.ocean_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
+            $sqlWhere1 .= " or lower(customer_code) " . common::getInNotInSql($_contact_id);
         }
     }
     if (empty($sqlWhere1))
@@ -412,11 +419,18 @@ function _customerAirFilerSearch($tableName,$schemas = "public", $s = 'shipper_i
         }
     }
     //controlling_customer_code
+    // if (utils::checkExist($tt, 't')) {
+    //     if (empty($sqlWhere1)) {
+    //         $sqlWhere1 = " exists(select 1 from $schemas.air_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)."  limit 1)";
+    //     } else {
+    //         $sqlWhere1 .= " or exists(select 1 from $schemas.air_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
+    //     }
+    // }
     if (utils::checkExist($tt, 't')) {
         if (empty($sqlWhere1)) {
-            $sqlWhere1 = " exists(select 1 from $schemas.air_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)."  limit 1)";
+            $sqlWhere1 = " lower(customer_code) " . common::getInNotInSql($_contact_id);
         } else {
-            $sqlWhere1 .= " or exists(select 1 from $schemas.air_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
+            $sqlWhere1 .= " or lower(customer_code) " . common::getInNotInSql($_contact_id);
         }
     }
     if (empty($sqlWhere1))
@@ -472,21 +486,28 @@ function _employeeFilerSearch($tableName,$ocean_air,$contact_field,$group_name_f
         }
     }
     //controlling_customer_code
-    if($ocean_air == "ocean"){
-        if (utils::checkExist($tt, 't')) {
-            if (empty($sqlWhere1)) {
-                $sqlWhere1 = " exists(select 1 from $schemas.ocean_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)."  limit 1)";
-            } else {
-                $sqlWhere1 .= " or exists(select 1 from $schemas.ocean_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
-            }
-        }
-    }else{
-        if (utils::checkExist($tt, 't')) {
-            if (empty($sqlWhere1)) {
-                $sqlWhere1 = " exists(select 1 from $schemas.air_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)."  limit 1)";
-            } else {
-                $sqlWhere1 .= " or exists(select 1 from $schemas.air_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
-            }
+    // if($ocean_air == "ocean"){
+    //     if (utils::checkExist($tt, 't')) {
+    //         if (empty($sqlWhere1)) {
+    //             $sqlWhere1 = " exists(select 1 from $schemas.ocean_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)."  limit 1)";
+    //         } else {
+    //             $sqlWhere1 .= " or exists(select 1 from $schemas.ocean_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
+    //         }
+    //     }
+    // }else{
+    //     if (utils::checkExist($tt, 't')) {
+    //         if (empty($sqlWhere1)) {
+    //             $sqlWhere1 = " exists(select 1 from $schemas.air_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)."  limit 1)";
+    //         } else {
+    //             $sqlWhere1 .= " or exists(select 1 from $schemas.air_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
+    //         }
+    //     }
+    // }
+    if (utils::checkExist($tt, 't')) {
+        if (empty($sqlWhere1)) {
+            $sqlWhere1 = " lower(customer_code) " . common::getInNotInSql($_contact_id);
+        } else {
+            $sqlWhere1 .= " or lower(customer_code) " . common::getInNotInSql($_contact_id);
         }
     }
     if (empty($sqlWhere1))

+ 53 - 8
utils/common.class.php

@@ -619,8 +619,19 @@ class common {
                     $sql .= utils::getInSql($o);
                 }
                 if (!empty($d) && strtolower($d) != 'all') {
-                    $sql .= " and lower(agent)";
-                    $sql .= utils::getInSql($d);
+                    //$sql .= " and lower(agent)";
+                    //$sql .= utils::getInSql($d);
+                    $inClause = utils::getInSql($d); 
+                    $sql .= " AND (";
+                    $sql .= " LOWER(agent) " . $inClause;
+                    //$sql .= " OR LOWER(to_other_stations) " . $inClause;
+                    $sql .= " OR EXISTS(SELECT 1 FROM ".$schemas.".ocean  where ocean.serial_no = ".$tableName.".serial_no AND LOWER(ocean.to_other_stations) " . $inClause.")" ;
+                    $sql .= " OR EXISTS (";
+                    $sql .= "     SELECT 1 FROM ".$schemas.".ocean_agent ";
+                    $sql .= "     WHERE ocean_agent.serial_no = ".$tableName.".serial_no ";
+                    $sql .= "       AND LOWER(ocean_agent.edi_agent) " . $inClause;
+                    $sql .= " )";
+                    $sql .= " )";
                 }
                 $sqlWhere .= " and (" . $sql . ")";
             }
@@ -667,8 +678,19 @@ class common {
                 $sqlWhere .= utils::getInSql($o_or);
             }
             if (!empty($d_or)) {
-                $sqlWhere .= " or lower(agent)";
-                $sqlWhere .= utils::getInSql($d_or);
+                //$sqlWhere .= " or lower(agent)";
+                //$sqlWhere .= utils::getInSql($d_or);
+                $inClause = utils::getInSql($d_or); 
+                $sqlWhere .= " OR (";
+                $sqlWhere .= " LOWER(agent) " . $inClause;
+                //$sqlWhere .= " OR LOWER(to_other_stations) " . $inClause;
+                $sqlWhere .= " OR EXISTS(SELECT 1 FROM ".$schemas.".ocean  where ocean.serial_no = ".$tableName.".serial_no AND LOWER(ocean.to_other_stations) " . $inClause.")" ;
+                $sqlWhere .= " OR EXISTS (";
+                $sqlWhere .= "     SELECT 1 FROM ".$schemas.".ocean_agent ";
+                $sqlWhere .= "     WHERE ocean_agent.serial_no = ".$tableName.".serial_no ";
+                $sqlWhere .= "       AND LOWER(ocean_agent.edi_agent) " . $inClause;
+                $sqlWhere .= " )";
+                $sqlWhere .= " )";
             }
             if (!empty($sales_or)) {
                 if (utils::checkExist($sales_or, ";")) {
@@ -748,8 +770,19 @@ class common {
                             $sql .= utils::getInSql($o);
                         }
                         if (!empty($d) && strtolower($d) != 'all') {
-                            $sql .= " and lower(agent)";
-                            $sql .= utils::getInSql($d);
+                            //$sql .= " and lower(agent)";
+                            //$sql .= utils::getInSql($d);
+                            $inClause = utils::getInSql($d); 
+                            $sql .= " AND (";
+                            $sql .= " LOWER(agent) " . $inClause;
+                            //$sql .= " OR LOWER(to_other_stations) " . $inClause;
+                            $sql .= " OR EXISTS(SELECT 1 FROM ".$schames.".ocean  where ocean.serial_no = ".$tableName.".serial_no AND LOWER(ocean.to_other_stations) " . $inClause.")" ;
+                            $sql .= " OR EXISTS (";
+                            $sql .= "     SELECT 1 FROM ".$schames.".ocean_agent ";
+                            $sql .= "     WHERE ocean_agent.serial_no = ".$tableName.".serial_no ";
+                            $sql .= "       AND LOWER(ocean_agent.edi_agent) " . $inClause;
+                            $sql .= " )";
+                            $sql .= " )";
                         }
                         $sqlWhere .= " and (" . $sql . ")";
                     }
@@ -790,8 +823,20 @@ class common {
                         $sqlWhere .= utils::getInSql($o_or);
                     }
                     if (!empty($d_or)) {
-                        $sqlWhere .= " or lower(agent)";
-                        $sqlWhere .= utils::getInSql($d_or);
+                        //$sqlWhere .= " or lower(agent)";
+                        //$sqlWhere .= utils::getInSql($d_or);
+                        
+                        $inClause = utils::getInSql($d_or); 
+                        $sqlWhere .= " OR (";
+                        $sqlWhere .= " LOWER(agent) " . $inClause;
+                        //$sqlWhere .= " OR LOWER(to_other_stations) " . $inClause;
+                        $sqlWhere .= " OR EXISTS(SELECT 1 FROM ".$schames.".ocean  where ocean.serial_no = ".$tableName.".serial_no AND LOWER(ocean.to_other_stations) " . $inClause.")" ;
+                        $sqlWhere .= " OR EXISTS (";
+                        $sqlWhere .= "     SELECT 1 FROM ".$schames.".ocean_agent ";
+                        $sqlWhere .= "     WHERE ocean_agent.serial_no = ".$tableName.".serial_no ";
+                        $sqlWhere .= "       AND LOWER(ocean_agent.edi_agent) " . $inClause;
+                        $sqlWhere .= " )";
+                        $sqlWhere .= " )";
                     }
                     if (!empty($sales_or)) {
                         if (utils::checkExist($sales_or, ";")) {