ShuanghongS 1 жил өмнө
parent
commit
44ebe6a6c3

+ 22 - 10
main_new_version.php

@@ -430,11 +430,11 @@ switch ($action) {
         // $_POST['is_default'] = "no";
         // $_POST['date_start'] =null;
         // $_POST['date_end'] = null;
-        //默认初始条件:ALL& ETD& Current Month 当前月的1号到最后一天
-        if (isset($_POST['is_default']) && strtolower($_POST['is_default']) == "yes"){
+        //默认初始条件:ALL& ETD& Current Month 当前月的1号到最后一天 这个移除默认条件
+        if (isset($_POST['is_default']) && strtolower($_POST['is_default']) == "yes" && false){
             $sqlWhere .= "and etd>='" . date("Y-m") . "-01' and etd<='" . date("Y-m") . "-01'::date + interval '1 month'";
         } else {
-            $date_type = common::check_input($_POST ['date_type']);
+            $date_type = strtolower(common::check_input($_POST ['date_type']));
             if (isset($_POST['date_start']) && !empty($_POST['date_start']))
                 $sqlWhere .= " and $date_type >= '" . common::usDate2sqlDate($_POST['date_start']) . " 00:00:00'";
             if (isset($_POST['date_end']) && !empty($_POST['date_end']))
@@ -460,15 +460,27 @@ switch ($action) {
                     to_char(last_status_315_date, 'MM/DD/YYYY'::text) as last_status_315_date,last_status_315_code, last_status_loc, last_status_city, order_from,
                     f_vessel,f_voyage,
                     CASE
-	    	            WHEN ((m_iffbcf is not null or m_iffbcf is null) and m_iffcpu is null and m_iffrec is null and m_iffdep is null and m_iffarr is null and m_iffafd is null) THEN 'Created'::text
-                        WHEN ((m_iffcpu is not null or m_iffrec is not null) and m_iffdep is null and m_iffarr is null and m_iffafd is null) THEN 'Cargo Received'::text
-                        WHEN (m_iffdep is not null and m_iffarr is null and m_iffafd is null) THEN 'Departed'::text
-                        WHEN (m_iffarr is not null and m_iffafd is null) THEN 'Arrived'::text
-                        WHEN (m_iffafd is not null) THEN 'Completed'::text
-	    	            ELSE 'Created'
+	    	            WHEN dd.status is null THEN 'Created'::text
+	    	            ELSE dd.status::text
 		            END AS new_status,
                     dd.act_date,dd.description,dd.timezone,dd.act_time
-                    FROM public.online_ocean 
+                    FROM public.online_ocean
+                    left join LATERAL (select case when a.code='IFFBCF' then 'Created'
+                                    when a.code='IFFCPU' then 'Cargo Received'
+                                    when a.code='IFFREC' then 'Cargo Received'
+                                    when a.code='IFFDEP' then 'Departed'
+                                    when a.code='IFFARR' then 'Arrived'
+                                    when a.code='IFFAFD' then 'Completed'
+                                    else 'Created' END as status,
+                                    act_date,act_time,
+                                    _dd.description as description,
+                                    timezone
+                            from  ocean_milestone a 
+                                left join LATERAL (select sno,description  from  milestone where code=a.code and project_no = '*'  order by sno limit 1) _dd on true
+                    where a.serial_no=online_ocean.serial_no 
+                        and a.code in (select regexp_split_to_table('IFFBCF,IFFCPU,IFFREC,IFFDEP,IFFARR,IFFAFD', ','))
+                        and a.act_date is not null
+                    order by id desc limit 1) dd on true 
                     $sqlWhere  and last_status_315_update_time is not null";
             if (_isDemo()) {
                 $sql .= " ORDER BY eta DESC limit " . $ps . " offset " . ($cp - 1) * $ps;

+ 75 - 64
service/ajax.class.php

@@ -92,31 +92,42 @@ class ajax {
                 "Voyage/Flight_tracking"=>"voyage as code,f_voyage as code_2",
                 "Vessel_tracking"=>"vessel as code,f_vessel as code_2");
 
-            $sql_where_mapping = array("Origin Agent"=>" and (origin ilike '" . common::check_input($term) . "%')",
-                "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) . "%')",
-                "Voyage/Flight_tracking"=>" and (voyage ilike '" . common::check_input($term) . "%' or f_voyage ilike '" . common::check_input($term) . "%')",
-                "Vessel_tracking"=>" and (vessel ilike '" . common::check_input($term) . "%' or f_vessel ilike '" . common::check_input($term) . "%')");    
+            $sql_where_mapping = array("Origin Agent"=>" and (origin ilike '%" . common::check_input($term) . "%')",
+                "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 'v" . 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) . "%')",
+                "Voyage/Flight_tracking"=>" and (voyage ilike '%" . common::check_input($term) . "%' or f_voyage ilike '%" . common::check_input($term) . "%')",
+                "Vessel_tracking"=>" and (vessel ilike '%" . common::check_input($term) . "%' or f_vessel ilike '%" . common::check_input($term) . "%')");    
 
             //特殊处理一下合并Voyage和Vessel
+            $_search_field  = $search_field;
             if ($search_field == "Voyage/Flight" || $search_field == "Vessel"){
                 $_str = $search_mode == "tracking" ? "tracking" : "booking";
-                $search_field  = $search_field ."_".$_str;
+                $_search_field  = $search_field ."_".$_str;
             }    
-            $str = $search_field_mapping[$search_field];
-            $sql_where = $sql_where_mapping[$search_field];
+            $str = $search_field_mapping[$_search_field];
+            $sql_where = $sql_where_mapping[$_search_field];
 
             $table = $search_mode == "tracking" ? "public.online_ocean " : "public.online_booking ";
+
+            if($search_mode == "booking"){
+                $order_by = " f_etd desc NULLS LAST";
+            }else{
+                $order_by = " etd desc NULLS LAST";
+                if (_isCustomerLogin()) {
+                    $order_by = " eta desc NULLS LAST";
+                }
+            }
      
-            $sql = "select * from (select DISTINCT $str from $table $sqlWhere $sql_where) as temp";
+            $sql = "select DISTINCT * from (select $str from $table $sqlWhere $sql_where order by $order_by ) as temp";
             $sql .= " order by code limit 20";
+            error_log($sql);
             $rs = common::excuteListSql($sql);
         }
         $rs = common::excuteListSql($sql);
@@ -462,14 +473,14 @@ class ajax {
             $count_sql = "select COUNT(DISTINCT shipper_city)
                 from public.online_booking $sqlWhere 
                     and COALESCE(shippr_uncode)<>''
-                    and  (shipper_city ilike '" . common::check_input($term) . "%' 
-                    or shippr_uncode ilike '" . common::check_input($term) . "%') ";
+                    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 COALESCE(shippr_uncode)<>''
-                    and  (shipper_city ilike '" . common::check_input($term) . "%' 
-                    or shippr_uncode ilike '" . common::check_input($term) . "%') ";
+                    and  (shipper_city ilike '%" . common::check_input($term) . "%' 
+                    or shippr_uncode ilike '%" . common::check_input($term) . "%') ";
             return  array("count_sql"=>$count_sql,"sql"=>$sql);      
         }
 
@@ -478,14 +489,14 @@ class ajax {
             $count_sql = "select count(DISTINCT consignee_city)
                 from public.online_booking $sqlWhere
                     and COALESCE(consignee_uncode)<>'' 
-                    and  (consignee_city ilike '" . common::check_input($term) . "%' 
-                    or consignee_uncode ilike '" . common::check_input($term) . "%') ";
+                    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 COALESCE(consignee_uncode)<>'' 
-                    and  (consignee_city ilike '" . common::check_input($term) . "%' 
-                    or consignee_uncode ilike '" . common::check_input($term) . "%')";
+                    and  (consignee_city ilike '%" . common::check_input($term) . "%' 
+                    or consignee_uncode ilike '%" . common::check_input($term) . "%')";
             return  array("count_sql"=>$count_sql,"sql"=>$sql);
         }
 
@@ -494,14 +505,14 @@ class ajax {
             $count_sql = "select COUNT(DISTINCT place_of_receipt_exp)
                 from public.online_booking $sqlWhere
                     and COALESCE(place_of_receipt_uncode)<>'' 
-                    and  (place_of_receipt_exp ilike '" . common::check_input($term) . "%' 
-                    or place_of_receipt_uncode ilike '" . common::check_input($term) . "%')";
+                    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 COALESCE(place_of_receipt_uncode)<>'' 
-                    and  (place_of_receipt_exp ilike '" . common::check_input($term) . "%' 
-                    or place_of_receipt_uncode ilike '" . common::check_input($term) . "%')";
+                    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);
         }
 
@@ -510,14 +521,14 @@ class ajax {
             $count_sql = "select COUNT(DISTINCT fport_of_loading_exp)
                 from public.online_booking $sqlWhere
                     and COALESCE(fport_of_loading_uncode)<>''  
-                    and  (fport_of_loading_exp ilike '" . common::check_input($term) . "%' 
-                    or fport_of_loading_uncode ilike '" . common::check_input($term) . "%')";
+                    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 COALESCE(fport_of_loading_uncode)<>'' 
-                    and  (fport_of_loading_exp ilike '" . common::check_input($term) . "%' 
-                    or fport_of_loading_uncode ilike '" . common::check_input($term) . "%')";
+                    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);
         }
 
@@ -526,14 +537,14 @@ class ajax {
             $count_sql = "select COUNT(DISTINCT place_of_delivery_exp)
                 from public.online_booking $sqlWhere
                     and COALESCE(place_of_delivery_uncode)<>'' 
-                    and  (place_of_delivery_exp ilike '" . common::check_input($term) . "%' 
-                    or place_of_delivery_uncode ilike '" . common::check_input($term) . "%')";
+                    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 COALESCE(place_of_delivery_uncode)<>'' 
-                    and  (place_of_delivery_exp ilike '" . common::check_input($term) . "%' 
-                    or place_of_delivery_uncode ilike '" . common::check_input($term) . "%')";
+                    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);        
         }
@@ -545,26 +556,26 @@ class ajax {
             $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 COALESCE(shippr_uncode)<>''
-                    and  (shipper_city ilike '" . common::check_input($term) . "%' 
-                    or shippr_uncode ilike '" . common::check_input($term) . "%') 
+                    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 COALESCE(consignee_uncode)<>'' 
-                    and  (consignee_city ilike '" . common::check_input($term) . "%' 
-                    or consignee_uncode ilike '" . common::check_input($term) . "%')) as temp";
+                    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 COALESCE(shippr_uncode)<>'' 
-                    and  (shipper_city ilike '" . common::check_input($term) . "%' 
-                    or shippr_uncode ilike '" . common::check_input($term) . "%') 
+                    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 COALESCE(consignee_uncode)<>''  
-                    and  (consignee_city ilike '" . common::check_input($term) . "%' 
-                    or consignee_uncode ilike '" . common::check_input($term) . "%')) as temp";
+                    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);        
         }
 
@@ -573,14 +584,14 @@ class ajax {
             $count_sql = "select COUNT(DISTINCT final_desination_exp)
                 from public.online_ocean $sqlWhere
                     and COALESCE(final_desination_uncode)<>'' 
-                    and  (final_desination_exp ilike '" . common::check_input($term) . "%' 
-                    or final_desination_uncode ilike '" . common::check_input($term) . "%')";
+                    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 COALESCE(final_desination_uncode)<>'' 
-                    and  (final_desination_exp ilike '" . common::check_input($term) . "%' 
-                    or final_desination_uncode ilike '" . common::check_input($term) . "%')";
+                    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);             
         }
 
@@ -589,14 +600,14 @@ class ajax {
             $count_sql = "select COUNT(DISTINCT place_of_receipt_exp)
                 from public.online_ocean $sqlWhere
                     and COALESCE(place_of_receipt_un)<>'' 
-                    and  (place_of_receipt_exp ilike '" . common::check_input($term) . "%' 
-                    or place_of_receipt_un ilike '" . common::check_input($term) . "%')";
+                    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 COALESCE(place_of_receipt_un)<>'' 
-                    and  (place_of_receipt_exp ilike '" . common::check_input($term) . "%' 
-                    or place_of_receipt_un ilike '" . common::check_input($term) . "%')";
+                    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);          
         }
 
@@ -605,14 +616,14 @@ class ajax {
             $count_sql = "select COUNT(DISTINCT port_of_loading)
                 from public.online_ocean $sqlWhere 
                     and COALESCE(fport_of_loading_un)<>''
-                    and  (port_of_loading ilike '" . common::check_input($term) . "%' 
-                    or fport_of_loading_un ilike '" . common::check_input($term) . "%')";
+                    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 COALESCE(fport_of_loading_un)<>'' 
-                    and  (port_of_loading ilike '" . common::check_input($term) . "%' 
-                    or fport_of_loading_un ilike '" . common::check_input($term) . "%')";
+                    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);
         }
 
@@ -621,14 +632,14 @@ class ajax {
             $count_sql = "select COUNT(DISTINCT port_of_discharge)
                 from public.online_ocean $sqlWhere
                     and COALESCE(mport_of_discharge_un)<>'' 
-                    and  (port_of_discharge ilike '" . common::check_input($term) . "%' 
-                    or mport_of_discharge_un ilike '" . common::check_input($term) . "%')";
+                    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 COALESCE(mport_of_discharge_un)<>''
-                    and  (port_of_discharge ilike '" . common::check_input($term) . "%' 
-                    or mport_of_discharge_un ilike '" . common::check_input($term) . "%')";
+                    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);        
         }
 
@@ -637,14 +648,14 @@ class ajax {
             $count_sql = "select COUNT(DISTINCT place_of_delivery_exp)
                 from public.online_ocean $sqlWhere
                     and COALESCE(place_of_delivery_un)<>'' 
-                    and  (place_of_delivery_exp ilike '" . common::check_input($term) . "%' 
-                    or place_of_delivery_un ilike '" . common::check_input($term) . "%')";
+                    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 COALESCE(place_of_delivery_un)<>'' 
-                    and  (place_of_delivery_exp ilike '" . common::check_input($term) . "%' 
-                    or place_of_delivery_un ilike '" . common::check_input($term) . "%')";
+                    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);        
         }
     }

+ 3 - 0
service/column.class.php

@@ -52,6 +52,9 @@ class column {
         $rs = null;
         $sql = "select ids from public.ra_online_search_display_config_cso where lower(login_name)='" . strtolower(_getLoginName()) . "' and lower(model_name) = '" . strtolower($model_name) . "'";
         $rs = common::excuteOneSql($sql);
+        if(!empty($_REQUEST['reset']) && $_REQUEST['reset'] == "yes"){
+            $rs = array();
+        }
         if (empty($rs)) {
             $sql = "select array_to_string(array(select id from public.ra_online_search_display_cso where active = true and default_display = true and lower(model_name) = '" . strtolower($model_name) . "'";
             if (_isCustomerLogin())

+ 4 - 1
service/ocean_booking.class.php

@@ -165,6 +165,9 @@ class ocean_booking {
             }
             $_sqlwhere = "1<>1";
             $filterTag_param = "1<>1";
+            if(strtolower($filterTag) == "all"){
+                $filterTag_param = "1=1";
+            }
             if (stripos($filterTag, "Confirmed") !== FALSE) {
                 $_sqlwhere .= " or (bol_type = 'BOOKING' and status!='Cancelled')";
                 $filterTag_param .= " or (bol_type = 'BOOKING' and status!='Cancelled')";
@@ -295,7 +298,7 @@ class ocean_booking {
                 'tagsList' => $tagsList,
                 'TransportList' => $TransportList,
                 'allColums' => $allBookingColumns,
-                'rc' => $rc,
+                'rc' => $seach_rc,
                 'ps' => $ps,
                 'cp' => $cp,
                 'tp' => $tp,

+ 83 - 56
service/ocean_order.class.php

@@ -415,6 +415,9 @@ class ocean_order {
 
             $_sqlwhere = "1<>1";
             $filterTag_param = "1<>1";
+            if(strtolower($filterTag) == "all"){
+                $filterTag_param = "1=1";
+            }
             if (stripos($filterTag, "Created") !== FALSE) {
                 $_sqlwhere .= " or ((m_iffbcf is not null or m_iffbcf is null) and m_iffcpu is null and m_iffrec is null and m_iffdep is null and m_iffarr is null and m_iffafd is null)";
                 $filterTag_param .= " or ((m_iffbcf is not null or m_iffbcf is null) and m_iffcpu is null and m_iffrec is null and m_iffdep is null and m_iffarr is null and m_iffafd is null)";
@@ -642,7 +645,10 @@ class ocean_order {
         //处理routes 转船可能有多个情况
         $routes = $vueData['routes']; 
         //处理marksAndDescription
-        $marksAndDescription = $vueData['marksAndDescription']; 
+        $marksAndDescription = $vueData['marksAndDescription'];
+        
+        //处理containerStatusData
+        $containerStatusData = $vueData['containerStatusData'];
 
         //处理ocean_reference
         $ref_no = array();
@@ -698,59 +704,7 @@ class ocean_order {
         $containers = array("container_column"=>$ocean_container_column,"container_data" =>$rss);
         //Packing信息
         $packing = array("Quantity/Unit"=>$quantity_tolal,"G. Weight" => $g_weight_tolal." KGS","Ch. Weight" => $ch_weight_tolal." LBS","Volume" => $cbm_tolal." CBM");
-       
-        /* Container Status */
-        //数据库里配置好
-        //$sql = "SELECT " . column::getInstance()->getSearchSql('Ocean_Container_Status') . " from oc_container_v where lower(serial_no) = '" . strtolower($serial_no) . "'";
-        $ctnr_sql = "SELECT oc.ctnr, oc.serial_no,oc.size FROM oc_container oc LEFT JOIN ocean o ON oc.serial_no = o.serial_no 
-                WHERE o.serial_no='$serial_no'";
-        $ctnr_data = common::excuteListSql($ctnr_sql); 
-        $containerStatusData = array();   
-        foreach ($ctnr_data as $cd){
-            $ctnr_status_sql = "select s.source_id, s.event_base as event,
-                    to_char(to_timestamp(s.event_date, 'YYYYMMDD'), 'YYYY-MM-DD') as eventdate,
-                    to_char(to_timestamp(s.event_time, 'HH24MI'), 'HH24:MI') as eventtime,
-                    e.description,s.event_type as eventtype, 
-                    s.event_code as eventcode, s.event_city as eventcity 
-                from public.ra_online_container_status_v s 
-                    left join ra_online_edi_event e on s.event_base = e.ra_name 
-                where s.serial_no = '" . pg_escape_string($cd['serial_no']) . "' 
-                    and s.container_no = '" . pg_escape_string($cd['ctnr']) . "' and is_display = true 
-                order by to_timestamp(s.event_date, 'YYYYMMDD') asc,
-                    to_timestamp(s.event_time, 'HH24MI') asc,
-                    e.ra_order asc";
-            $ctnr_status = common::excuteListSql($ctnr_status_sql);       
-
-            //Container_Status 新版只显示几个状态, CTNR# EE I AE VD VA
-            $container_status_column = array("EE","I","AE","VD","VA");
-            $containerStatusDataTemp = array();
-            $ctnr_uncodes = "";
-            $content = array();
-            foreach($container_status_column as $status){
-                foreach($ctnr_status as $event){
-                    if(strtolower($event['event']) == strtolower($status)){
-                        $eventdate = $event["eventdate"];
-                        if (empty($event["source_id"]) || $event["source_id"]==0) {
-                            $eventdate.= " " . $event["eventtime"];
-                        }
-                        $location_code = $event["eventcode"];
-                        $content[] = array("title" =>$event['description'],"date"=>$eventdate,"country"=>$location_code);
-                        $ctnr_uncodes .=$location_code.";";
-                    }
-                }
-            }
-            //查询全部uncode timezone
-            $uncode_rs = common::getCityPortsInfo($ctnr_uncodes);
-            //循环去回填时区
-            foreach($content as $ck => $cv){
-                $content[$ck]['timezone'] = $uncode_rs[$cv['country']];
-            }
-
-            $containerStatusDataTemp['label'] = $cd['ctnr']." / ".$cd['size'];
-            $containerStatusDataTemp['content'] = $content;
-            $containerStatusData[] = $containerStatusDataTemp;
-        } 
-
+        
         //Milestones info  列名固定
         $Milestones = common::getMilestonesInfo($ocean);
 
@@ -1202,6 +1156,71 @@ class ocean_order {
 
     private function returnOceanDetailData($ocean,$state){
         $data = array();
+
+        /* Container Status */
+        //数据库里配置好
+        //$sql = "SELECT " . column::getInstance()->getSearchSql('Ocean_Container_Status') . " from oc_container_v where lower(serial_no) = '" . strtolower($serial_no) . "'";
+        $serial_no = $ocean["serial_no"];
+        $ctnr_sql = "SELECT oc.ctnr, oc.serial_no,oc.size FROM oc_container oc LEFT JOIN ocean o ON oc.serial_no = o.serial_no 
+                WHERE o.serial_no='$serial_no'";
+        $ctnr_data = common::excuteListSql($ctnr_sql); 
+        $containerStatusData = array();
+        $VD = "";
+        $VA = "";    
+        foreach ($ctnr_data as $cd){
+            $ctnr_status_sql = "select s.source_id, s.event_base as event,
+                    to_char(to_timestamp(s.event_date, 'YYYYMMDD'), 'YYYY-MM-DD') as eventdate,
+                    to_char(to_timestamp(s.event_time, 'HH24MI'), 'HH24:MI') as eventtime,
+                    e.description,s.event_type as eventtype, 
+                    s.event_code as eventcode, s.event_city as eventcity 
+                from public.ra_online_container_status_v s 
+                    left join ra_online_edi_event e on s.event_base = e.ra_name 
+                where s.serial_no = '" . pg_escape_string($cd['serial_no']) . "' 
+                    and s.container_no = '" . pg_escape_string($cd['ctnr']) . "' and is_display = true 
+                order by to_timestamp(s.event_date, 'YYYYMMDD') asc,
+                    to_timestamp(s.event_time, 'HH24MI') asc,
+                    e.ra_order asc";
+            $ctnr_status = common::excuteListSql($ctnr_status_sql);       
+
+            //Container_Status 新版只显示几个状态, CTNR# EE I AE VD VA
+            $container_status_column = array("EE","I","AE","VD","VA");
+            $containerStatusDataTemp = array();
+            $ctnr_uncodes = "";
+            $content = array();
+            foreach($container_status_column as $status){
+                foreach($ctnr_status as $event){
+                    if(strtolower($event['event']) == strtolower($status)){
+                        $eventdate = $event["eventdate"];
+                        if (empty($event["source_id"]) || $event["source_id"]==0) {
+                            $eventdate.= " " . $event["eventtime"];
+                        }
+                        $location_code = $event["eventcode"];
+                        $content[] = array("code" =>$status,"title" =>$event['description'],"date"=>$eventdate,"country"=>$location_code);
+                        $ctnr_uncodes .=$location_code.";";
+                    }
+                }
+            }
+            //查询全部uncode timezone
+            $uncode_rs = common::getCityPortsInfo($ctnr_uncodes);
+            //循环去回填时区
+            foreach($content as $ck => $cv){
+                $content[$ck]['timezone'] = $uncode_rs[$cv['country']];
+                //记录vd
+                if($cv['code'] == "VD" && empty($cv['date'])){
+                    $VD = $cv['date'];
+                }
+                //记录vd
+                if($cv['code'] == "VA" && empty($cv['date'])){
+                    $VA = $cv['date'];
+                }
+            }
+
+            $containerStatusDataTemp['label'] = $cd['ctnr']." / ".$cd['size'];
+            $containerStatusDataTemp['content'] = $content;
+            $containerStatusData[] = $containerStatusDataTemp;
+        }
+        $data['containerStatusData'] = $containerStatusData;
+
         //处理shipment data
         $ocean_milestone_status = common::excuteListSql("select code,
                 act_date,est_date,timezone 
@@ -1213,6 +1232,14 @@ class ocean_order {
             $ocean_milestone_status_code[$oms['code']] = $oms;
         }
         
+        //当EDI315更新时,处理f_etd,m_eta(目前数据未同步,如果以后数据规范后,可以直接用milestone的值)
+        if(!empty($VD)){
+            $ocean['f_etd'] = $VD;
+        }
+        if(!empty($VA)){
+            $ocean['m_eta'] = $VA;
+        }
+
         if ($state < 1){
             //未发生前
             if(!empty($ocean_milestone_status_code['IFFDEP']['est_date'])){
@@ -1346,11 +1373,11 @@ class ocean_order {
             $routes = array(array("mode" =>"Ocean Freight","mode_label" =>"Sea", "origin" =>$ocean['shippr_uncode'],
                 "destination" => $ocean['port_of_transshipment_un'],
                 "etd" => $ocean['f_etd'],"atd" => $ocean['atd'],
-                "eta" =>$ocean['f_eta'],"ata" => $ocean['ata'],
+                "eta" =>$ocean['f_eta'],"ata" => $ocean['f_eta'],
                 "vessel" =>$ocean['f_vessel'],"voyageNo" =>$ocean['f_voyage']));
             $routes[] = array("mode" =>"Ocean Freight", "mode_label" =>"Sea","origin" =>$ocean['port_of_transshipment_un'],
                 "destination" => $ocean['consignee_uncode'],
-                "etd" => $ocean['m_etd'],"atd" => $ocean['atd'],
+                "etd" => $ocean['m_etd'],"atd" => $ocean['m_etd'],
                 "eta" =>$ocean['m_eta'],"ata" =>$ocean['ata'],
                 "vessel" =>$ocean['m_vessel'],"voyageNo" =>$ocean['m_voyage']);
         }else{

+ 1 - 1
utils/common.class.php

@@ -1390,7 +1390,7 @@ class common {
             "switchValue"=>true,
             "text"=>"Pie chart showing figures of shipments KPI of Departure and Arrival.");
         $Management[] = array("id"=>2 ,
-            "title"=>"Pending Departure & Arrival",
+            "title"=>"Pending",
             "switchValue"=>true,
             "text"=>"Pie chart showing figures of shipments which are soon to depart/arrive (Calculated from ETD/ETA).");
         $Management[] = array("id"=>3 ,

+ 3 - 0
utils/utils.class.php

@@ -164,6 +164,9 @@ class utils {
     }
 
     public static function outDisplayForMerge($frist,$last,$split = "/") {
+        if($frist == $last){
+            return $frist;
+        }
         if (!empty($frist)){
             if(!empty($last)){
                 return $frist.$split.$last;