ShuanghongS 1 жил өмнө
parent
commit
7821ccbc7d

+ 156 - 105
service/ajax.class.php

@@ -78,10 +78,14 @@ class ajax {
                 $sqlWhere = $this->getBookingSearchWhere();
             }
 
+            //Notify Party Bill to Destination Operator 是tracking里的,但booking没有,所以不影响
             $search_field_mapping = array("Origin Agent"=>"origin as code",
                 "Destination Agent"=>"agent as code",
                 "Shipper Name"=>"shipper as code",
                 "Consignee Name"=>"consignee as code",
+                "Notify Party" =>"notify_party as code",
+                "Bill to" =>"billto as code",
+                "Destination Operator"=>"dest_op as code",
                 "Sales"=>"sales_rep as code",
                 "Voyage/Flight_booking"=>"f_voyage as code,m_voyage as code_2",
                 "Vessel_booking"=>"f_vessel as code,m_vessel as code_2",
@@ -92,6 +96,9 @@ class ajax {
                 "Destination Agent"=>" and (agent ilike '" . common::check_input($term) . "%')",
                 "Shipper Name"=>" and (shipper ilike '" . common::check_input($term) . "%')",
                 "Consignee Name"=>" and (consignee ilike '" . common::check_input($term) . "%')",
+                "Notify Party"=>" and (notify_party ilike '" . common::check_input($term) . "%')",
+                "Bill to"=>" and (billto ilike '" . common::check_input($term) . "%')",
+                "Destination Operator"=>" and (dest_op ilike '" . common::check_input($term) . "%')",
                 "Sales"=>" and (sales_rep ilike '" . common::check_input($term) . "%')",
                 "Voyage/Flight_booking"=>" and (f_voyage ilike '" . common::check_input($term) . "%' or m_voyage ilike '" . common::check_input($term) . "%')",
                 "Vessel_booking"=>" and (f_vessel ilike '" . common::check_input($term) . "%' or m_vessel ilike '" . common::check_input($term) . "%')",
@@ -107,9 +114,9 @@ class ajax {
             $sql_where = $sql_where_mapping[$search_field];
 
             $table = $search_mode == "tracking" ? "public.online_ocean " : "public.online_booking ";
-
-            $sql = "select $str from $table $sqlWhere $sql_where ";
-            $sql .= " order by id limit 20";
+     
+            $sql = "select * from (select DISTINCT $str from $table $sqlWhere $sql_where) as temp";
+            $sql .= " order by code limit 20";
             $rs = common::excuteListSql($sql);
         }
         $rs = common::excuteListSql($sql);
@@ -137,30 +144,38 @@ class ajax {
         $term = trim($term);
         $search_field = $_POST['search_field'];
         $search_mode = $_POST['search_mode'];
-        $in_sql = $this->getPortsUncity($search_field,$search_mode);
+        $_sql_arr = $this->getPortsUncity($search_field,$search_mode,$term);
 
         $rc = $_POST ['rc'];
         if ($rc == - 1) {
-            $sql = "SELECT count(1) from public.ports where (isoname ilike '" . common::check_input($term) . "%' 
-                or uncity ilike '" . common::check_input($term) . "%' or uncode ilike '" . common::check_input($term) . "%') 
-                and $in_sql";
+            $sql = $_sql_arr['count_sql'];
             $rc = common::excuteOneSql($sql);
+            error_log($sql);
         }
         $tp = ceil($rc / $ps);
         if ($rc > 0) {
-            $sql = "SELECT isoname as country, uncity as city,uncode from public.ports where (isoname ilike '" . common::check_input($term) . "%' 
-                    or uncity ilike '" . common::check_input($term) . "%' or uncode ilike '" . common::check_input($term) . "%')
-                    and $in_sql";
-            $sql .= " order by code limit " . $ps . " offset " . ($cp - 1) * $ps;
-
+            $sql = $_sql_arr['sql'];
+            $sql = "select * from ($sql) as temp ";
+            $sql .= " order by city limit " . $ps . " offset " . ($cp - 1) * $ps;
+            
             $rs = common::excuteListSql($sql);
             //前端要加上id 从1开始
             $retData = array();
+            $i = 0;
             foreach($rs as $key => $val){
-                if(!empty($val['country'])){
-                    $val["id"] = $key +1;
-                    $retData[] = $val;
-                }
+                if($search_field == "Port of Loading"){
+                    if(!empty($val['uncode'])){
+                        $val["id"] = $i +1;
+                        $retData[] = $val;
+                        $i = $i +1;
+                    }
+                }else{
+                    if(!empty($val['city'])){
+                        $val["id"] = $i +1;
+                        $retData[] = $val;
+                        $i = $i +1;
+                    }
+                }   
             }
             $arrTmp = array('searchData' => $retData, 
                     'rc' => $rc,
@@ -440,138 +455,174 @@ class ajax {
         return $sqlWhere;
     }
 
-    PUBLIC function getPortsUncity($search_field,$search_mode){
-        $uncity = array();
+    PUBLIC function getPortsUncity($search_field,$search_mode,$term){
+        //uncode 前两位便是 isoname,不用模糊查询这个了
         if($search_field == "Origin" && $search_mode == "booking"){
             $sqlWhere = $this->getBookingSearchWhere();
-            $sql = "select shipper_city from public.online_booking $sqlWhere";
-            $city_temp = common::excuteListSql($sql);
-            foreach($city_temp as $city){
-                if(!empty($city['shipper_city'])){
-                    $uncity[] = $city['shipper_city'];
-                }
-
-            }
+            $count_sql = "select COUNT(DISTINCT shipper_city)
+                from public.online_booking $sqlWhere 
+                    and  (shipper_city ilike '" . common::check_input($term) . "%' 
+                    or shippr_uncode ilike '" . common::check_input($term) . "%') ";
+
+            $sql = "select DISTINCT ON (shipper_city) left(shippr_uncode, 2) as country,shipper_city as city, shippr_uncode as uncode 
+                from public.online_booking $sqlWhere 
+                    and  (shipper_city ilike '" . common::check_input($term) . "%' 
+                    or shippr_uncode ilike '" . common::check_input($term) . "%') ";
+            return  array("count_sql"=>$count_sql,"sql"=>$sql);      
         }
+
         if($search_field == "Destination" && $search_mode == "booking"){
             $sqlWhere = $this->getBookingSearchWhere();
-            $sql = "select consignee_city from public.online_booking $sqlWhere";
-            $city_temp = common::excuteListSql($sql);
-            foreach($city_temp as $city){
-                if(!empty($city['consignee_city'])){
-                    $uncity[] = $city['consignee_city'];
-                }
-            }
+            $count_sql = "select count(DISTINCT consignee_city)
+                from public.online_booking $sqlWhere 
+                    and  (consignee_city ilike '" . common::check_input($term) . "%' 
+                    or consignee_uncode ilike '" . common::check_input($term) . "%') ";
+
+            $sql = "select DISTINCT ON (consignee_city) left(consignee_uncode, 2) as country,consignee_city as city, consignee_uncode as uncode 
+                from public.online_booking $sqlWhere 
+                    and  (consignee_city ilike '" . common::check_input($term) . "%' 
+                    or consignee_uncode ilike '" . common::check_input($term) . "%')";
+            return  array("count_sql"=>$count_sql,"sql"=>$sql);
         }
 
         if($search_field == "Place of Receipt" && $search_mode == "booking"){
             $sqlWhere = $this->getBookingSearchWhere();
-            $sql = "select place_of_receipt_exp from public.online_booking $sqlWhere";
-            $city_temp = common::excuteListSql($sql);
-            foreach($city_temp as $city){
-                if(!empty($city['place_of_receipt_exp'])){
-                    $uncity[] = $city['place_of_receipt_exp'];
-                }
-            }
+            $count_sql = "select COUNT(DISTINCT place_of_receipt_exp)
+                from public.online_booking $sqlWhere 
+                    and  (place_of_receipt_exp ilike '" . common::check_input($term) . "%' 
+                    or place_of_receipt_uncode ilike '" . common::check_input($term) . "%')";
+
+            $sql = "select DISTINCT ON (place_of_receipt_exp) left(place_of_receipt_uncode, 2) as country,place_of_receipt_exp as city, place_of_receipt_uncode as uncode 
+                from public.online_booking $sqlWhere 
+                    and  (place_of_receipt_exp ilike '" . common::check_input($term) . "%' 
+                    or place_of_receipt_uncode ilike '" . common::check_input($term) . "%')";
+            return  array("count_sql"=>$count_sql,"sql"=>$sql);
         }
 
         if($search_field == "Port of Loading" && $search_mode == "booking"){
             $sqlWhere = $this->getBookingSearchWhere();
-            $sql = "select fport_of_loading_exp from public.online_booking $sqlWhere";
-            $city_temp = common::excuteListSql($sql);
-            foreach($city_temp as $city){
-                if(!empty($city['fport_of_loading_exp'])){
-                    $uncity[] = $city['fport_of_loading_exp'];
-                }
-            }
+            $count_sql = "select COUNT(DISTINCT fport_of_loading_exp)
+                from public.online_booking $sqlWhere 
+                    and  (fport_of_loading_exp ilike '" . common::check_input($term) . "%' 
+                    or fport_of_loading_uncode ilike '" . common::check_input($term) . "%')";
+            
+            $sql = "select DISTINCT ON (fport_of_loading_exp) left(fport_of_loading_uncode, 2) as country,fport_of_loading_exp as city, fport_of_loading_uncode as uncode 
+                from public.online_booking $sqlWhere 
+                    and  (fport_of_loading_exp ilike '" . common::check_input($term) . "%' 
+                    or fport_of_loading_uncode ilike '" . common::check_input($term) . "%')";
+            return  array("count_sql"=>$count_sql,"sql"=>$sql);
         }
 
         if($search_field == "Place of delivery" && $search_mode == "booking"){
             $sqlWhere = $this->getBookingSearchWhere();
-            $sql = "select place_of_delivery_exp from public.online_booking $sqlWhere";
-            $city_temp = common::excuteListSql($sql);
-            foreach($city_temp as $city){
-                if(!empty($city['place_of_delivery_exp'])){
-                    $uncity[] = $city['place_of_delivery_exp'];
-                }
-            }
+            $count_sql = "select COUNT(DISTINCT place_of_delivery_exp)
+                from public.online_booking $sqlWhere 
+                    and  (place_of_delivery_exp ilike '" . common::check_input($term) . "%' 
+                    or place_of_delivery_uncode ilike '" . common::check_input($term) . "%')";
+
+            $sql = "select DISTINCT ON (place_of_delivery_exp) left(place_of_delivery_uncode, 2) as country,place_of_delivery_exp as city, place_of_delivery_uncode as uncode
+                from public.online_booking $sqlWhere 
+                    and  (place_of_delivery_exp ilike '" . common::check_input($term) . "%' 
+                    or place_of_delivery_uncode ilike '" . common::check_input($term) . "%')";
+
+            return  array("count_sql"=>$count_sql,"sql"=>$sql);        
         }
 
         //tracking
         if($search_field == "Origin" && $search_mode == "tracking"){
             $sqlWhere = $this->getTrackingSearchWhere();
-            $sql = "select shipper_city,consignee_city from public.online_ocean $sqlWhere";
-            $city_temp = common::excuteListSql($sql);
-            foreach($city_temp as $city){
-                if(!empty($city['shipper_city'])){
-                    $uncity[] = $city['shipper_city'];
-                }
-                if(!empty($city['consignee_city'])){
-                    $uncity[] = $city['consignee_city'];
-                }
-            }
+          
+            $count_sql = "select COUNT(DISTINCT city) from (select left(shippr_uncode, 2) as country,shipper_city as city, shippr_uncode as uncode
+                from public.online_ocean $sqlWhere 
+                    and  (shipper_city ilike '" . common::check_input($term) . "%' 
+                    or shippr_uncode ilike '" . common::check_input($term) . "%') 
+                union
+                    select left(consignee_uncode, 2) as country,consignee_city as city, consignee_uncode as uncode
+                from public.online_ocean $sqlWhere 
+                    and  (consignee_city ilike '" . common::check_input($term) . "%' 
+                    or consignee_uncode ilike '" . common::check_input($term) . "%')) as temp";
+
+            $sql = "select * from(select DISTINCT ON (shipper_city)  left(shippr_uncode, 2) as country,shipper_city as city, shippr_uncode as uncode
+                from public.online_ocean $sqlWhere 
+                    and  (shipper_city ilike '" . common::check_input($term) . "%' 
+                    or shippr_uncode ilike '" . common::check_input($term) . "%') 
+                union
+                    select DISTINCT ON (consignee_city) left(consignee_uncode, 2) as country,consignee_city as city, consignee_uncode as uncode
+                from public.online_ocean $sqlWhere 
+                    and  (consignee_city ilike '" . common::check_input($term) . "%' 
+                    or consignee_uncode ilike '" . common::check_input($term) . "%')) as temp";
+            return  array("count_sql"=>$count_sql,"sql"=>$sql);        
         }
 
         if($search_field == "Destination" && $search_mode == "tracking"){
             $sqlWhere = $this->getTrackingSearchWhere();
-            $sql = "select final_desination_exp from public.online_ocean $sqlWhere";
-            $city_temp = common::excuteListSql($sql);
-            foreach($city_temp as $city){
-                if(!empty($city['final_desination_exp'])){
-                    $uncity[] = $city['final_desination_exp'];
-                }
-            }
+            $count_sql = "select COUNT(DISTINCT final_desination_exp)
+                from public.online_ocean $sqlWhere 
+                    and  (final_desination_exp ilike '" . common::check_input($term) . "%' 
+                    or final_desination_uncode ilike '" . common::check_input($term) . "%')";
+
+            $sql = "select DISTINCT ON (final_desination_exp) left(final_desination_uncode, 2) as country,final_desination_exp as city, final_desination_uncode as uncode
+                from public.online_ocean $sqlWhere 
+                    and  (final_desination_exp ilike '" . common::check_input($term) . "%' 
+                    or final_desination_uncode ilike '" . common::check_input($term) . "%')";
+            return  array("count_sql"=>$count_sql,"sql"=>$sql);             
         }
 
         if($search_field == "Place of Receipt" && $search_mode == "tracking"){
             $sqlWhere = $this->getTrackingSearchWhere();
-            $sql = "select place_of_receipt_exp from public.online_ocean $sqlWhere";
-            $city_temp = common::excuteListSql($sql);
-            foreach($city_temp as $city){
-                if(!empty($city['place_of_receipt_exp'])){
-                    $uncity[] = $city['place_of_receipt_exp'];
-                }
-            }
+            $count_sql = "select COUNT(DISTINCT place_of_receipt_exp)
+                from public.online_ocean $sqlWhere 
+                    and  (place_of_receipt_exp ilike '" . common::check_input($term) . "%' 
+                    or place_of_receipt_un ilike '" . common::check_input($term) . "%')";
+
+            $sql = "select DISTINCT ON (place_of_receipt_exp) left(place_of_receipt_un, 2) as country,place_of_receipt_exp as city, place_of_receipt_un as uncode
+                from public.online_ocean $sqlWhere 
+                    and  (place_of_receipt_exp ilike '" . common::check_input($term) . "%' 
+                    or place_of_receipt_un ilike '" . common::check_input($term) . "%')";
+            return  array("count_sql"=>$count_sql,"sql"=>$sql);          
         }
 
         if($search_field == "Port of Loading" && $search_mode == "tracking"){
             $sqlWhere = $this->getTrackingSearchWhere();
-            $sql = "select port_of_loading from public.online_ocean $sqlWhere";
-            $city_temp = common::excuteListSql($sql);
-            foreach($city_temp as $city){
-                if(!empty($city['port_of_loading'])){
-                    $uncity[] = $city['port_of_loading'];
-                }
-            }
+            $count_sql = "select COUNT(DISTINCT port_of_loading)
+                from public.online_ocean $sqlWhere 
+                    and  (port_of_loading ilike '" . common::check_input($term) . "%' 
+                    or fport_of_loading_un ilike '" . common::check_input($term) . "%')";
+
+            $sql = "select DISTINCT ON (port_of_loading) left(fport_of_loading_un, 2) as country,port_of_loading as city, fport_of_loading_un as uncode
+                from public.online_ocean $sqlWhere 
+                    and  (port_of_loading ilike '" . common::check_input($term) . "%' 
+                    or fport_of_loading_un ilike '" . common::check_input($term) . "%')";
+            return  array("count_sql"=>$count_sql,"sql"=>$sql);
         }
 
         if($search_field == "Place of Discharge" && $search_mode == "tracking"){
             $sqlWhere = $this->getTrackingSearchWhere();
-            $sql = "select port_of_discharge from public.online_ocean $sqlWhere";
-            $city_temp = common::excuteListSql($sql);
-            foreach($city_temp as $city){
-                if(!empty($city['port_of_discharge'])){
-                    $uncity[] = $city['port_of_discharge'];
-                }
-            }
+            $count_sql = "select COUNT(DISTINCT port_of_discharge)
+                from public.online_ocean $sqlWhere 
+                    and  (port_of_discharge ilike '" . common::check_input($term) . "%' 
+                    or mport_of_discharge_un ilike '" . common::check_input($term) . "%')";
+
+            $sql = "select DISTINCT ON (port_of_discharge) left(mport_of_discharge_un, 2) as country,port_of_discharge as city, mport_of_discharge_un as uncode
+                from public.online_ocean $sqlWhere 
+                    and  (port_of_discharge ilike '" . common::check_input($term) . "%' 
+                    or mport_of_discharge_un ilike '" . common::check_input($term) . "%')";
+            return  array("count_sql"=>$count_sql,"sql"=>$sql);        
         }
 
         if($search_field == "Place of delivery" && $search_mode == "tracking"){
             $sqlWhere = $this->getTrackingSearchWhere();
-            $sql = "select place_of_delivery_exp from public.online_ocean $sqlWhere";
-            $city_temp = common::excuteListSql($sql);
-            foreach($city_temp as $city){
-                if(!empty($city['place_of_delivery_exp'])){
-                    $uncity[] = $city['place_of_delivery_exp'];
-                }
-            }
-        }
-        $uncity = utils::removeDuplicateArray($uncity);
-        $in_sql = utils::getInSql(utils::implode(';', $uncity));
-        if(!empty($uncity)){
-            $in_sql = " lower(uncity) ".$in_sql;
+            $count_sql = "select COUNT(DISTINCT place_of_delivery_exp)
+                from public.online_ocean $sqlWhere 
+                    and  (place_of_delivery_exp ilike '" . common::check_input($term) . "%' 
+                    or place_of_delivery_un ilike '" . common::check_input($term) . "%')";
+
+            $sql = "select DISTINCT ON (place_of_delivery_exp) left(place_of_delivery_un, 2) as country,place_of_delivery_exp as city, place_of_delivery_un as uncode
+                from public.online_ocean $sqlWhere 
+                    and  (place_of_delivery_exp ilike '" . common::check_input($term) . "%' 
+                    or place_of_delivery_un ilike '" . common::check_input($term) . "%')";
+            return  array("count_sql"=>$count_sql,"sql"=>$sql);        
         }
-        return $in_sql;
     }
 }
 

+ 13 - 3
service/login.class.php

@@ -522,7 +522,7 @@ class login {
         $email = common::check_input($_POST['email']);
         $verifcation_code = common::check_input($_POST['verifcation_code']);
         //首先校验验证码
-        if ($_SESSION['captcha'] != $verifcation_code) {    
+        if (strtolower($_SESSION['captcha']) != strtolower($verifcation_code)) {    
             $data = array(
                 'msg' => 'verifcation_error',
                 'data' => ''
@@ -1103,7 +1103,7 @@ class login {
         $is_verify = common::check_input($_POST['verifcation_code']);
         if($this->signUpAndTrackingChecked($is_verify)){
             $data = array("msg" =>"visit limit");
-            common::echo_json_encode(200, $data);
+            common::echo_json_encode(400, $data);
             exit();
         }else{
             $data =  $this->getTrackingInfo($reference_number);
@@ -1124,7 +1124,7 @@ class login {
             $db->Execute("INSERT INTO public.tracking_login_record(ip, visit_count,visit_time,type)VALUES ('$ip', '1', now(),'".common::check_input($_POST['type'])."');") or ( (!$db->ErrorMsg()) or error_log($db->ErrorMsg(), 0));
         }else{
             if ($ipInfo['visit_count'] > $Tracking_Search_Count){
-                if(strtolower($_SESSION['captcha']) == strtolower($is_verify) || true ){
+                if(true){
                     //归零验证次数
                     $db->Execute("update tracking_login_record set visit_count = 1 "
                         . " where ip = '$ip' and type ilike '".common::check_input($_POST['type'])."' and visit_time + '5 min' > NOW()::timestamp ") or ( (!$db->ErrorMsg()) or error_log($db->ErrorMsg(), 0));
@@ -1341,6 +1341,16 @@ class login {
             or exists (select 1 from oc_container oc where o.serial_no = oc.serial_no and oc.ctnr = '$reference_number'))";
         return $sql;
     }
+
+    private function AES_encrypted($encrypted_string){
+        $cipher = "aes-256-cbc"; // AES算法的一个实现,比如AES-256-CBC
+        $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($cipher)); // 生成初始化向量
+        $key = 'fT5!R1k$7Mv@4Q9X'; // 你的256位密钥
+        // 解密
+        $decrypted = openssl_decrypt($encrypted_string, $cipher, $key, $options=0, $iv);
+        
+        return $decrypted; // 输出解密后的字符串
+    }
 }
 
 ?>

+ 13 - 2
service/ocean_booking.class.php

@@ -225,8 +225,19 @@ class ocean_booking {
                 array("name"=>"Cancelled","number"=>intval($Concelled),"type"=>"cancelled","checked"=>false));
             }
 
-            $TransportList = array(
-                array("name"=>"Ocean Freight","number"=>intval($rc),"checked"=>true,"icon"=>"#icon-icon_ocean_b"));
+            if (!isset($_POST["transport_mode"])){
+                //代表初始
+                $TransportList = array(
+                    array("name"=>"Ocean Freight","number"=>intval($rc),"checked"=>true,"icon"=>"#icon-icon_ocean_b"));
+            }else{
+                if (strtolower($_POST["transport_mode"]) == "all") {
+                    $TransportList = array(
+                        array("name"=>"Ocean Freight","number"=>intval($rc),"checked"=>true,"icon"=>"#icon-icon_ocean_b"));
+                } else {
+                    $TransportList = array(
+                        array("name"=>"Ocean Freight","number"=>intval($rc),"checked"=>false,"icon"=>"#icon-icon_ocean_b"));
+                }
+            }
 
             //现在下载交给前端,后台预先只返回全部字段的列,
             $allColumn = column::getInstance()->getDisplayColumnAllReomveDefault('Booking_Search');

+ 13 - 2
service/ocean_order.class.php

@@ -488,8 +488,19 @@ class ocean_order {
                 array("name"=>"Completed","number"=>intval($Completed),"type"=>"completed","checked"=>false));
             }
 
-            $TransportList = array(
-                array("name"=>"Ocean Freight","number"=>intval($rc),"checked"=>true,"icon"=>"#icon-icon_ocean_b"));
+            if (!isset($_POST["transport_mode"])){
+                //代表初始
+                $TransportList = array(
+                    array("name"=>"Ocean Freight","number"=>intval($rc),"checked"=>true,"icon"=>"#icon-icon_ocean_b"));
+            }else{
+                if (strtolower($_POST["transport_mode"]) == "all") {
+                    $TransportList = array(
+                        array("name"=>"Ocean Freight","number"=>intval($rc),"checked"=>true,"icon"=>"#icon-icon_ocean_b"));
+                } else {
+                    $TransportList = array(
+                        array("name"=>"Ocean Freight","number"=>intval($rc),"checked"=>false,"icon"=>"#icon-icon_ocean_b"));
+                }
+            }
 
             //现在下载交给前端,后台预先只返回全部字段的列,
             $allColumn = column::getInstance()->getDisplayColumnAllReomveDefault('Ocean_Search');

+ 1 - 0
utils/common.class.php

@@ -1278,6 +1278,7 @@ class common {
             $shippr_uncode_10_sql = "select count(fport_of_loading_un) as num,fport_of_loading_un as shippr_uncode from online_ocean where 1=1 $sqlWhere group by fport_of_loading_un order by num desc limit 10";
             $shippr_uncode_10 = common::excuteListSql($shippr_uncode_10_sql);
         }
+        //$toporiginType = "fport_of_loading_un";
 
         $topdestinationinType = "consignee_uncode";
         $consignee_uncode_10_sql = "select count(consignee_uncode) as num,consignee_uncode from online_ocean  where 1=1 $sqlWhere group by consignee_uncode order by num desc limit 10";