ShuanghongS 1 rok temu
rodzic
commit
a7cc89207d

+ 16 - 6
main_new_version.php

@@ -264,7 +264,7 @@ switch ($action) {
             //这个type 是页面传过来的。这个固定r2
             $color = common::getItemStyle($type,$k);
             $total = $total + $v['total'];
-            $ContainerCounSeries_return[] = array("name"=>$k,"type"=>"bar","emphasis" => array("focus" =>"none"),
+            $ContainerCounSeries_return[] = array("name"=>strval($k),"type"=>"bar","emphasis" => array("focus" =>"none"),
                 "stack" =>"总计","data" =>$v['data'],"itemStyle" =>array("color" =>$color));
             $max_all = $max_all +  $v['max'];
         }
@@ -277,8 +277,10 @@ switch ($action) {
         $returnData = array("ContainerCount_Title"=>"Total: $total","ContainerCountList" =>$ContainerCount_Title,"ContainerCounSeries" =>$ContainerCounSeries_return,
             "min" => 0,"Max" =>$interval*5,"interval" =>$interval);
         //demo    
-        // $json = '{"code":200,"data":{"ContainerCount_Title":"Total: 463518","ContainerCountList":["OCT,23","NOV,23","DEC,23","JAN,24","FEB,24","MAR,24","APR,24","MAY,24","JUN,24","JUL,24","AUG,24","SEP,24","OCT,24"],"ContainerCounSeries":[{"name":20,"type":"bar","emphasis":{"focus":"none"},"stack":"\u603b\u8ba1","data":[4400,8600,8804,9271,8961,8793,8534,9476,9530,10277,10081,8997,5784],"itemStyle":{"color":"#FF7500"}},{"name":40,"type":"bar","emphasis":{"focus":"none"},"stack":"\u603b\u8ba1","data":[13652,28021,30422,30136,26320,27035,23979,26494,28406,33318,32318,30962,16369],"itemStyle":{"color":"#FFAC66"}},{"name":45,"type":"bar","emphasis":{"focus":"none"},"stack":"\u603b\u8ba1","data":[189,337,415,437,439,321,250,320,324,603,328,415,200],"itemStyle":{"color":"#FFE3CC"}}],"min":0,"Max":45000,"interval":9000}}';    
-        // $returnData = json_decode($json,true);
+        //  $json = '{"code":200,"data":{"ContainerCount_Title":"Total: 463518","ContainerCountList":["OCT,23","NOV,23","DEC,23","JAN,24","FEB,24","MAR,24","APR,24","MAY,24","JUN,24","JUL,24","AUG,24","SEP,24","OCT,24"],"ContainerCounSeries":[{"name":"20","type":"bar","emphasis":{"focus":"none"},"stack":"\u603b\u8ba1","data":[4400,8600,8804,9271,8961,8793,8534,9476,9530,10277,10081,8997,5784],"itemStyle":{"color":"#FF7500"}},{"name":"40","type":"bar","emphasis":{"focus":"none"},"stack":"\u603b\u8ba1","data":[13652,28021,30422,30136,26320,27035,23979,26494,28406,33318,32318,30962,16369],"itemStyle":{"color":"#FFAC66"}},{"name":"45","type":"bar","emphasis":{"focus":"none"},"stack":"\u603b\u8ba1","data":[189,337,415,437,439,321,250,320,324,603,328,415,200],"itemStyle":{"color":"#FFE3CC"}}],"min":0,"Max":45000,"interval":9000}}';    
+        //  $returnData = json_decode($json,true);
+        //  echo json_encode($returnData);
+        //  exit();
         common::echo_json_encode(200, $returnData);
         exit();
         break;
@@ -426,6 +428,8 @@ switch ($action) {
         $sqlWhere = ' where ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
         // test dome 
         // $_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"){
             $sqlWhere .= "and etd>='" . date("Y-m") . "-01' and etd<='" . date("Y-m") . "-01'::date + interval '1 month'";
@@ -454,18 +458,24 @@ switch ($action) {
                     to_char(etd, 'MM/DD/YYYY'::text) as etd, to_char(eta, 'MM/DD/YYYY'::text) AS eta, 
                     fport_of_loading_un, mport_of_discharge_un, place_of_receipt_un, place_of_delivery_un, ctnrs, count_cntr, last_status_ctnr,booking_no,
                     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,dd.*
+                    f_vessel,f_voyage,
+                    CASE
+	    	            WHEN dd.status is null THEN 'Created'::text
+	    	            ELSE dd.status::text
+		            END AS status,
+                    dd.act_date,dd.description
                     FROM public.online_ocean 
-                    left join LATERAL (select case when a.code='IFFBCF' then 'Booked'
+                    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 'Booked' END as status,act_date,act_date,description
+                                    else 'Created' END as status,act_date,description
                             from  ocean_milestone a 
                     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()) {

+ 46 - 0
service/ajax.class.php

@@ -62,6 +62,52 @@ class ajax {
         }
     }
 
+    //不查询全局的信息,查询该用户,最近3个月内输入过的信息自动补全
+    public function autody_new(){
+        $term = $_POST['term'];
+        $type = $_POST['type'];
+        $search_field = $_POST['search_field'];
+        $search_mode = $_POST['search_mode'];
+        
+        $term = trim($term);
+        if (strtolower($type) == "apex") {
+            $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
+            $sqlWhere = " " . $sqlWhere;
+            $search_field_mapping = array("Origin Agent"=>"origin",
+                "Destination Agent"=>"agent",
+                "Shipper Name"=>"shipper",
+                "Consignee Name"=>"consignee",
+                "Sales"=>"sales_rep",
+                "Voyage"=>"voyage",
+                "Vessel"=>"vessel");
+            
+            $str = $search_field_mapping['$search_field '];
+            $table = $search_mode == "Tracking" ? "public.online_ocean" : "public.online_ocean";
+
+            $sql = "select $str from  $table where 1=1 $sqlWhere and f_etd >= current_date - INTERVAL '3 months'";
+            $sql .= " order by contact_id limit 20";
+            $rs = common::excuteListSql($sql);
+        }
+
+        //Shipper 和Consignee  的查询,但是表contact_v ,从ocean和air. 如果不做区分的话,可以上面的apex的Origin Agent/Destination Agent,合并
+        if (strtolower($type) == "contanct") {
+            $sql = "SELECT company as code from contact_v where active = true and (contact_id ilike '" . common::check_input($term) . "%' or company ilike '" . common::check_input($term) . "%')";
+            $sql .= " order by contact_id limit 20";
+            $rs = common::excuteListSql($sql); 
+        }
+
+        $rs = common::excuteListSql($sql);
+        $array = array();
+        foreach($rs as $v){
+            if(!empty($v['code'])){
+                $array[] = $v['code'];
+            }
+        }
+        common::echo_json_encode(200,$array);
+        exit();
+
+    }
+
     public function autoPort() {
         $cp = common::check_input($_POST ['cp']); //current_page
         $ps = common::check_input($_POST ['ps']); //ps

+ 12 - 5
service/login.class.php

@@ -1145,18 +1145,24 @@ class login {
     }
 
     private function getTrackingInfo($reference_number){
-        $sql = "SELECT o.* ,sh.*, cn.* ,aa.*,dd.* ,cc.status as new_status
+        $sql = "SELECT o.* ,sh.*, cn.* ,aa.*,dd.*,
+                (select incoterms from online_ocean where online_ocean.serial_no = o.serial_no limit 1) as incoterms,
+                CASE
+	    	        WHEN cc.status is null THEN 'Created'::text
+	    	        ELSE cc.status::text
+		        END AS new_status
                 from public.ocean o 
-                left join LATERAL (select case when a.code='IFFBCF' then 'Booked'
+                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 'Booked' END as status
+                                else 'Created' END as status
                         from  ocean_milestone a 
                 where a.serial_no=o.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) cc on true
                 LEFT JOIN LATERAL ( SELECT company as cn_company,
                     address_1 as cn_address_1,
@@ -1200,7 +1206,8 @@ class login {
                 or exists (select 1 from oc_container oc where o.serial_no = oc.serial_no and oc.ctnr = '$reference_number'))";
         $ocean_arr = common::excuteListSql($sql);
         if(empty($ocean_arr)){
-            $ocean_arr = $this->trackingSfsSql($reference_number);
+            $sql = $this->trackingSfsSql($reference_number);
+            $ocean_arr = common::excuteListSql($sql);
             if(empty($ocean_arr)){
                 $data = array("msg" =>"No matches");
                 return $data;
@@ -1222,7 +1229,7 @@ class login {
         $voyage = utils::outDisplayForMerge($ocean['f_voyage'],$ocean['m_voyage']);
         $basicInfo = array("MAWB/MBL No." =>$ocean['m_bol'],"HAWB/HBOL" => $ocean['h_bol'],"Carrier_Booking_No" =>$ocean['carrier_booking'],
             "PO_NO" =>$ocean['po_no'],"Vessel/Airline" =>$vessel,"Voyage/Filght" =>$voyage,
-            "Incoterm" =>$ocean['terms'],"Service_Type" =>$ocean['service']);
+            "Incoterm" =>$ocean['incoterms'],"Service_Type" =>$ocean['service']);
 
         //处理 拼接地址 ocean表单exp 字段无法精准分割电话和地址信息,只能从contacts表里查询
         $shipper_address = common::retStationInfo($ocean['sh_address_1'], $ocean['sh_address_2'], $ocean['sh_address_3'], $ocean['sh_address_4'], 

+ 38 - 27
service/ocean_booking.class.php

@@ -128,7 +128,31 @@ class ocean_booking {
         }
         $sqlWhere = ' where ' . common::searchExtendHandNew("booking", $_SESSION["ONLINE_USER"]);
         $sqlWhere .= search::getInstance()->getSearchSQL("Booking_Search");
+        //新版要排除type2情况,总数才会对的上
+        $sqlWhere .= " and (not(bol_type != 'BOOKING' and booking_no is not null and booking_no <> ''))";
 
+        //移除掉全文检索 但保留代码
+        // if (!empty($_POST["_textSearch"])) {
+        //     $sqlWhere .= " and text_search @@ (str_to_tsquery('" . common::check_input($_POST["_textSearch"]) . "'))";
+        // }
+        //处理reference类型的组合查询  Search booking No./HBL No./PO No./Carrier Booking No.
+        if (!empty($_POST["_textSearch"])) {
+            $textSearch_arr = $_POST['_textSearch'];
+            if(!is_array($textSearch_arr)){
+                $textSearch_arr = array($textSearch_arr);
+            }
+            $more_sql = "1<>1";
+            foreach($textSearch_arr as $tsv){
+                $more_sql .= " or  booking_no ilike '%" . common::check_input(trim($tsv)) . "%'";
+                $more_sql .= " or  h_bol ilike '%" . common::check_input(trim($tsv)) . "%'";
+                $more_sql .= " or  po_no ilike '%" . common::check_input(trim($tsv)) . "%'";
+                $more_sql .= " or  carrier_booking ilike '%" . common::check_input(trim($tsv)) . "%'";
+            }
+            if ($more_sql <> "1<>1"){
+                $sqlWhere .= " and ($more_sql)";
+            } 
+        } 
+        $sqlWhere_befrom_filterTag  = $sqlWhere;
         //前端提交是数组
         if (!empty($_POST['filterTag']) && utils::count($_POST['filterTag']) < 4) {
             if (utils::count($_POST['filterTag']) == 1){
@@ -153,50 +177,37 @@ class ocean_booking {
                 $sqlWhere .= " and ($_sqlwhere)";
             }
         }
-        //移除掉全文检索 但保留代码
-        // if (!empty($_POST["_textSearch"])) {
-        //     $sqlWhere .= " and text_search @@ (str_to_tsquery('" . common::check_input($_POST["_textSearch"]) . "'))";
-        // }
-        //处理reference类型的组合查询  Search booking No./HBL No./PO No./Carrier Booking No.
-        if (!empty($_POST["_textSearch"])) {
-            $textSearch_arr = $_POST['_textSearch'];
-            if(!is_array($textSearch_arr)){
-                $textSearch_arr = array($textSearch_arr);
-            }
-            $more_sql = "1<>1";
-            foreach($textSearch_arr as $tsv){
-                $more_sql .= " or  booking_no ilike '%" . common::check_input(trim($tsv)) . "%'";
-                $more_sql .= " or  h_bol ilike '%" . common::check_input(trim($tsv)) . "%'";
-                $more_sql .= " or  po_no ilike '%" . common::check_input(trim($tsv)) . "%'";
-                $more_sql .= " or  carrier_booking ilike '%" . common::check_input(trim($tsv)) . "%'";
-            }
-            if ($more_sql <> "1<>1"){
-                $sqlWhere .= " and ($more_sql)";
-            } 
-        }
         $rc = $_POST ['rc'];
         //这里都要查询,除非多传几个参数回来
         if ($rc == - 1 || true) {
-            //查询ALL
+            //查询 earch ALL
             $sql = "SELECT count(1) from public.online_booking" . $sqlWhere;
+            $seach_rc = common::excuteOneSql($sql);
+            error_log("online_booking_count_ALL_SQL: ".$sql);
+
+            //移除filterTag
+            $sqlWhere_bk = $sqlWhere_befrom_filterTag;
+
+            //查询 ALL
+            $sql = "SELECT count(1) from public.online_booking" . $sqlWhere_bk;
             $rc = common::excuteOneSql($sql);
             error_log("online_booking_count_ALL_SQL: ".$sql);
             
             //查询Creatd
             $Creatd_sqlWhere = " and (1<>1 or (bol_type != 'BOOKING' and (booking_no is null or booking_no = '')))";
-            $Creatd_sql = "SELECT count(1) from public.online_booking" . $sqlWhere.$Creatd_sqlWhere;
+            $Creatd_sql = "SELECT count(1) from public.online_booking" . $sqlWhere_bk.$Creatd_sqlWhere;
             $Creatd = common::excuteOneSql($Creatd_sql);
             error_log("online_booking_count_Creatd_SQL: ".$sql);
 
             //查询Confirmed
             $Confirmed_sqlWhere = " and (1<>1 or (bol_type = 'BOOKING' and status!='Cancelled'))";
-            $Confirmed_sql = "SELECT count(1) from public.online_booking" . $sqlWhere.$Confirmed_sqlWhere;
+            $Confirmed_sql = "SELECT count(1) from public.online_booking" . $sqlWhere_bk.$Confirmed_sqlWhere;
             $Confirmed = common::excuteOneSql($Confirmed_sql);
             error_log("online_booking_count_Confirmed_SQL: ".$sql);
 
             //查询Concelled
             $Concelled_sqlWhere = " and (1<>1 or (status='Cancelled'))";
-            $Concelled_sql = "SELECT count(1) from public.online_booking" . $sqlWhere.$Concelled_sqlWhere;
+            $Concelled_sql = "SELECT count(1) from public.online_booking" . $sqlWhere_bk.$Concelled_sqlWhere;
             $Concelled = common::excuteOneSql($Concelled_sql);
             error_log("online_booking_count_Concelled_SQL: ".$sql);
 
@@ -272,7 +283,7 @@ class ocean_booking {
                 'tagsList' => $tagsList,
                 'TransportList' => $TransportList,
                 'allColums' => $allBookingColumns,
-                'rc' => $rc,
+                'rc' => $seach_rc,
                 'ps' => $ps,
                 'cp' => $cp,
                 'tp' => $tp,
@@ -474,7 +485,7 @@ class ocean_booking {
     private function returnBookingDetailData($ocean,$status){
         $data = array();
         //处理transportInfo信息数据
-        $transportInfo = array("bookingNo." =>$ocean['booking_no'],"status"=>$status,"mode" => "","origin" =>$ocean['origin_station'],"destination" =>$ocean['destination_station'],
+        $transportInfo = array("bookingNo." =>$ocean['booking_no'],"status"=>$status,"mode" => "Ocean Freight","origin" =>$ocean['origin_station'],"destination" =>$ocean['destination_station'],
             "etd" =>$ocean['f_etd'],"atd" =>"","eta" =>$ocean['m_eta'],"ata" =>"");
         $data["transportInfo"] = $transportInfo;
 

+ 102 - 71
service/ocean_order.class.php

@@ -329,10 +329,11 @@ class ocean_order {
             } else if ($_reportType == "top") {
                 if (!empty($_reportRef)) {
                     $_reportStationType = $_REQUEST["_reportStationType"];
+                    //先固定pol pod
                     if($_reportStationType == 'origin'){
-                        $sqlWhere .= " and  origin = '$_reportRef'";
+                        $sqlWhere .= " and  fport_of_loading_un = '$_reportRef'";
                     }else{
-                        $sqlWhere .= " and  agent = '$_reportRef'";
+                        $sqlWhere .= " and  mport_of_discharge_un = '$_reportRef'";
                     }
                     
                 } else {
@@ -366,9 +367,31 @@ class ocean_order {
                 }
             }
         }
-
+        //取消全文检索
+        // if (!empty($_POST["_textSearch"])) {
+        //     $sqlWhere .= " and text_search @@ (str_to_tsquery('" . common::check_input($_POST["_textSearch"]) . "'))";
+        // }
+        //处理reference类型的组合查询  Search booking No./HBL No./PO No./Carrier Booking No.
+        if (!empty($_POST["_textSearch"])) {
+            $textSearch_arr = $_POST['_textSearch'];
+            if(!is_array($textSearch_arr)){
+                $textSearch_arr = array($textSearch_arr);
+            }
+            $more_sql = "1<>1";
+            foreach($textSearch_arr as $tsv){
+                $more_sql .= " or  booking_no ilike '%" . common::check_input(trim($tsv)) . "%'";
+                $more_sql .= " or  h_bol ilike '%" . common::check_input(trim($tsv)) . "%'";
+                $more_sql .= " or  po_no ilike '%" . common::check_input(trim($tsv)) . "%'";
+                $more_sql .= " or  carrier_booking ilike '%" . common::check_input(trim($tsv)) . "%'";
+            }
+            if ($more_sql <> "1<>1"){
+                $sqlWhere .= " and ($more_sql)";
+            } 
+        }
+        $sqlWhere_befrom_filterTag  = $sqlWhere;
+        
         //查询tag
-        // IFFBCF  Booking Confirmation                      Booked
+        // IFFBCF  Booking Confirmation                      Created
         // IFFCPU  Cargo Pickup                              Cargo Received
         // IFFREC  Cargo Arrived at Origin                   Cargo Received
         // IFFDEP  Departure                                 Departed
@@ -382,8 +405,8 @@ class ocean_order {
             }
 
             $_sqlwhere = "1<>1";
-            if (stripos($filterTag, "Booked") !== FALSE) {
-                $_sqlwhere .= " or (dd.new_status = 'Booked')";
+            if (stripos($filterTag, "Created") !== FALSE) {
+                $_sqlwhere .= " or (dd.new_status = 'Created' or dd.new_status is null)";
             }
             if (stripos($filterTag, "Cargo Received") !== FALSE) {
                 $_sqlwhere .= " or (dd.new_status = 'Cargo Received')";
@@ -401,75 +424,49 @@ class ocean_order {
                 $sqlWhere .= " and ($_sqlwhere)";
             }
         }
-        //取消全文检索
-        // if (!empty($_POST["_textSearch"])) {
-        //     $sqlWhere .= " and text_search @@ (str_to_tsquery('" . common::check_input($_POST["_textSearch"]) . "'))";
-        // }
-        //处理reference类型的组合查询  Search booking No./HBL No./PO No./Carrier Booking No.
-        if (!empty($_POST["_textSearch"])) {
-            $textSearch_arr = $_POST['_textSearch'];
-            if(!is_array($textSearch_arr)){
-                $textSearch_arr = array($textSearch_arr);
-            }
-            $more_sql = "1<>1";
-            foreach($textSearch_arr as $tsv){
-                $more_sql .= " or  booking_no ilike '%" . common::check_input(trim($tsv)) . "%'";
-                $more_sql .= " or  h_bol ilike '%" . common::check_input(trim($tsv)) . "%'";
-                $more_sql .= " or  po_no ilike '%" . common::check_input(trim($tsv)) . "%'";
-                $more_sql .= " or  carrier_booking ilike '%" . common::check_input(trim($tsv)) . "%'";
-            }
-            if ($more_sql <> "1<>1"){
-                $sqlWhere .= " and ($more_sql)";
-            } 
-        }
 
         $rc = $_POST ['rc'];
         //这里都要查询,除非多传几个参数回来
         if ($rc == - 1 || true) {
-            $sql = "select count(1) from online_ocean
-	            left join LATERAL (select case when a.code='IFFBCF' then 'Booked'
-                                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 'Booked' END as new_status
-                        from  ocean_milestone a 
-                where a.serial_no=online_ocean.serial_no 
-                    and a.code in (select regexp_split_to_table('IFFBCF,IFFCPU,IFFREC,IFFDEP,IFFARR,IFFAFD', ','))
-                order by id desc limit 1) dd on true" . $sqlWhere;
-                
+            $sql = $this->getOcanOrderSearchSql("All",$sqlWhere);    
+            $search_rc = common::excuteOneSql($sql);
+            error_log("online_ocean_count_ALL_Search_SQL:".$sql);
+
+            //移除filterTag
+            $sqlWhere_bk = $sqlWhere_befrom_filterTag;
+
+            $sql = $this->getOcanOrderSearchSql("All",$sqlWhere_bk);    
             $rc = common::excuteOneSql($sql);
             error_log("online_ocean_count_ALL_SQL:".$sql);
 
-            //Booked
-            $sql = $this->getOcanOrderSearchSql("Booked",$sqlWhere);
-            $Booked = common::excuteOneSql($sql);
-            error_log("online_ocean_count_Booked_SQL: ".$sql);
+            //Created
+            $sql = $this->getOcanOrderSearchSql("Created",$sqlWhere_bk);
+            $Created = common::excuteOneSql($sql);
+            error_log("online_ocean_count_Created_SQL: ".$sql);
 
             //Cargo Received
-            $sql = $this->getOcanOrderSearchSql("Cargo Received",$sqlWhere);
+            $sql = $this->getOcanOrderSearchSql("Cargo Received",$sqlWhere_bk);
             $Cargo_Received = common::excuteOneSql($sql);
             error_log("online_ocean_count_Cargo_Received_SQL: ".$sql);
 
             //Departed
-            $sql = $this->getOcanOrderSearchSql("Departed",$sqlWhere);
+            $sql = $this->getOcanOrderSearchSql("Departed",$sqlWhere_bk);
             $Departed = common::excuteOneSql($sql);
             error_log("online_ocean_count_Departed_SQL: ".$sql);
 
             //Arrived
-            $sql = $this->getOcanOrderSearchSql("Arrived",$sqlWhere);
+            $sql = $this->getOcanOrderSearchSql("Arrived",$sqlWhere_bk);
             $Arrived = common::excuteOneSql($sql);
             error_log("online_ocean_count_Arrived_SQL: ".$sql);
 
             //Completed
-            $sql = $this->getOcanOrderSearchSql("Completed",$sqlWhere);
+            $sql = $this->getOcanOrderSearchSql("Completed",$sqlWhere_bk);
             $Completed = common::excuteOneSql($sql);
             error_log("online_ocean_count_Completed_SQL: ".$sql);
             
             if (!empty($_POST["filterTag"])) {
                 $tagsList = array(array("name"=>"All","number"=>$rc,"type"=>"all","checked"=>utils::in_array('All', $_POST["filterTag"])? true : false),
-                array("name"=>"Booked","number"=>$Booked,"type"=>"booked","checked"=>utils::in_array('Booked', $_POST["filterTag"])? true : false),
+                array("name"=>"Created","number"=>$Created,"type"=>"created","checked"=>utils::in_array('Created', $_POST["filterTag"])? true : false),
                 array("name"=>"Cargo Received","number"=>$Cargo_Received,"type"=>"cargo_received","checked"=>utils::in_array('Cargo Received', $_POST["filterTag"])? true : false),
                 array("name"=>"Departure","number"=>$Departed,"type"=>"departure","checked"=>utils::in_array('Departure', $_POST["filterTag"])? true : false),
                 array("name"=>"Arrived","number"=>$Arrived,"type"=>"arrived","checked"=>utils::in_array('Arrived', $_POST["filterTag"])? true : false),
@@ -477,7 +474,7 @@ class ocean_order {
             }else{
                 //初始,前端有选择着带入选择
                 $tagsList = array(array("name"=>"All","number"=>$rc,"type"=>"all","checked"=> true ),
-                array("name"=>"Booked","number"=>$Booked,"type"=>"booked","checked"=> false),
+                array("name"=>"Created","number"=>$Created,"type"=>"created","checked"=> false),
                 array("name"=>"Cargo Received","number"=>$Cargo_Received,"type"=>"cargo_received","checked"=> false),
                 array("name"=>"Departure","number"=>$Departed,"type"=>"departure","checked"=> false),
                 array("name"=>"Arrived","number"=>$Arrived,"type"=>"arrived","checked"=> false),
@@ -500,22 +497,23 @@ class ocean_order {
             $ocean_ref_sql = " LEFT JOIN LATERAL ( SELECT string_agg(ref_code ||ref_value, ', ') AS other_refenrence_no
                             FROM public.ocean_reference temp WHERE temp.serial_no = online_ocean.serial_no) aa ON true ";
 
-            $ocean_status_sql = " LEFT JOIN LATERAL (select case when a.code='IFFBCF' then 'Booked'
+            $ocean_status_sql = " 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 'Booked' END as new_status
+                                    else 'Created' END as new_status
                             from  ocean_milestone a 
                     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 ";
 
             $sql = "SELECT order_from as _schemas,serial_no as __serial_no, serial_no,
                     h_bol as _hbol, isf_bol as _isfbol, consignee_city as _consignee_city,
                     CASE
-	    	            WHEN dd.new_status is null THEN 'Booked'::text
+	    	            WHEN dd.new_status is null THEN 'Created'::text
 	    	            ELSE dd.new_status::text
 		            END AS new_status, ".
                     column::getInstance()->getSearchSqlForDisplay('Ocean_Search') . " from public.online_ocean $ocean_ref_sql $ocean_status_sql" . $sqlWhere . 
@@ -541,7 +539,7 @@ class ocean_order {
                'TransportList' => $TransportList,
                'allColums' => $allBookingColumns,
                'canEdiVgm' => _canEdiVgm(),
-               'rc' => $rc,
+               'rc' => $search_rc,
                'ps' => $ps,
                'cp' => $cp,
                'tp' => $tp,
@@ -567,6 +565,7 @@ class ocean_order {
     private function _ocean_detail() {
         $serial_no = common::deCode($_GET['a'], 'D');
         $sql = $this->getOceanDetail($serial_no);
+        error_log($sql);
         $ocean = common::excuteObjectSql($sql);
         
         if (!empty($ocean)) {
@@ -991,79 +990,99 @@ class ocean_order {
     }
     
     private function getOcanOrderSearchSql($type,$sqlWhere) {
-        if($type == "Booked"){
-            $Booked_sqlWhere = " and (1<>1 or dd.new_status ='Booked')";
+        if($type == "All"){
             return "select count(1) from online_ocean
-	            left join LATERAL (select case when a.code='IFFBCF' then 'Booked'
+	            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 'Booked' END as new_status
+                                else 'Created' END as new_status
                         from  ocean_milestone a 
                 where a.serial_no=online_ocean.serial_no 
                     and a.code in (select regexp_split_to_table('IFFBCF,IFFCPU,IFFREC,IFFDEP,IFFARR,IFFAFD', ','))
-                order by id desc limit 1) dd on true" . $sqlWhere.$Booked_sqlWhere;
+                    and a.act_date is not null
+                order by id desc limit 1) dd on true" . $sqlWhere;
+        }
+        if($type == "Created"){
+            $Created_sqlWhere = " and (1<>1 or dd.new_status ='Created' or dd.new_status is null)";
+            return "select count(1) from 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 new_status
+                        from  ocean_milestone a 
+                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.$Created_sqlWhere;
         }
         if($type == "Cargo Received"){
             $Cargo_Received_sqlWhere = " and (1<>1 or dd.new_status ='Cargo Received')";
             return "select count(1) from online_ocean
-	            left join LATERAL (select case when a.code='IFFBCF' then 'Booked'
+	            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 'Booked' END as new_status
+                                else 'Created' END as new_status
                         from  ocean_milestone a 
                 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.$Cargo_Received_sqlWhere;
         }
         if($type == "Departed"){
             $Departed_sqlWhere = " and (1<>1 or dd.new_status ='Departed')";
             return "select count(1) from online_ocean
-	            left join LATERAL (select case when a.code='IFFBCF' then 'Booked'
+	            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 'Booked' END as new_status
+                                else 'Created' END as new_status
                         from  ocean_milestone a 
                 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.$Departed_sqlWhere;
         }
         if($type == "Arrived"){
             $Arrived_sqlWhere = " and (1<>1 or dd.new_status ='Arrived')";
             return "select count(1) from online_ocean
-	            left join LATERAL (select case when a.code='IFFBCF' then 'Booked'
+	            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 'Booked' END as new_status
+                                else 'Created' END as new_status
                         from  ocean_milestone a 
                 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.$Arrived_sqlWhere;
         }
         if($type == "Completed"){
             $Completed_sqlWhere = " and (1<>1 or dd.new_status ='Completed')";
             return "select count(1) from online_ocean
-	            left join LATERAL (select case when a.code='IFFBCF' then 'Booked'
+	            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 'Booked' END as new_status
+                                else 'Created' END as new_status
                         from  ocean_milestone a 
                 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.$Completed_sqlWhere;
         }
     }
@@ -1163,20 +1182,26 @@ class ocean_order {
             $_schemas = "ocean";
         }
         $sql = "SELECT m_eta as _m_eta,  h_bol as _h_bol, m_bol as _m_bol,job_no as _job_bol,
+                (select incoterms from online_ocean where online_ocean.serial_no = o.serial_no limit 1) as incoterms,
                 public.z_get_eta_dest(o.final_eta::date, o.eta_dest::text, o.service::text, o.m_eta::date, o.place_of_delivery::text, o.mport_of_discharge::text) as _eta_dest, 
                 to_char(final_eta, 'MM/DD/YYYY') as _final_eta,
-                o.* ,sh.*, cn.* ,aa.*,dd.*,ee.status as new_status
+                o.* ,sh.*, cn.* ,aa.*,dd.*,
+                CASE
+	    	        WHEN ee.status is null THEN 'Created'::text
+	    	        ELSE ee.status::text
+		        END AS new_status
             from ocean o 
-            left join LATERAL (select case when a.code='IFFBCF' then 'Booked'
+            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 'Booked' END as status
+                                else 'Created' END as status
                         from  ocean_milestone a 
                 where a.serial_no=o.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) ee on true
             LEFT JOIN LATERAL ( SELECT company as cn_company,
                 address_1 as cn_address_1,
@@ -1247,6 +1272,9 @@ class ocean_order {
             //未发生前
             if(!empty($ocean_milestone_status_code['IFFDEP']['est_date'])){
                 $children[] = array("label" =>"Departure(ETD)","date" =>$ocean_milestone_status_code['IFFDEP']['est_date']);
+            } else {
+                //没有,取etd 
+                $children[] = array("label" =>"Departure(ETD)","date" =>$ocean['f_etd']);
             }
         } else{
             if(!empty($ocean_milestone_status_code['IFFONB']['act_date'])){
@@ -1267,6 +1295,9 @@ class ocean_order {
             //未发生前
             if(!empty($ocean_milestone_status_code['IFFARR']['est_date'])){
                 $children[] = array("label" =>"Arrival(ETA)","date" =>$ocean_milestone_status_code['IFFARR']['est_date']);
+            }else{
+                //没有,取eta
+                $children[] = array("label" =>"Arrival(ETA)","date" =>$ocean['m_eta']);
             }
         } else{
             if(!empty($ocean_milestone_status_code['IFFARR']['act_date'])){
@@ -1302,7 +1333,7 @@ class ocean_order {
         $voyage = utils::outDisplayForMerge($ocean['f_voyage'],$ocean['m_voyage']);
         $basicInfo = array("MAWB/MBL No." =>$ocean['m_bol'],"HAWB/HBOL" => $ocean['h_bol'],"Carrier_Booking_No" =>$ocean['carrier_booking'],
             "PO_NO" =>$ocean['po_no'],"Vessel/Airline" =>$vessel,"Voyage/Filght" =>$voyage,
-            "Incoterm" =>$ocean['terms'],"Service_Type" =>$ocean['service']);
+            "Incoterm" =>$ocean['incoterms'],"Service_Type" =>$ocean['service']);
         $data['basicInfo'] = $basicInfo;    
 
         //处理 拼接地址 ocean表单exp 字段无法精准分割电话和地址信息,只能从contacts表里查询

+ 9 - 3
utils/common.class.php

@@ -1268,18 +1268,22 @@ class common {
         $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
         $sqlWhere = " " . $sqlWhere;
 
+        $toporiginType = "shippr_uncode";
         $shippr_uncode_10_sql = "select count(shippr_uncode) as num,shippr_uncode from online_ocean  where 1=1 $sqlWhere group by shippr_uncode order by num desc limit 10";
         $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"])){
+            $toporiginType = "fport_of_loading_un";
             $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);
         }
 
+        $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";
         $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"])){
+            $topdestinationinType = "mport_of_discharge_un";
             $consignee_uncode_10_sql = "select count(mport_of_discharge_un) as num,mport_of_discharge_un as consignee_uncode from online_ocean where 1=1 $sqlWhere group by mport_of_discharge_un order by num desc limit 10";
             $consignee_uncode_10 = common::excuteListSql($consignee_uncode_10_sql);
         }
@@ -1347,8 +1351,8 @@ class common {
             $dest_interval = 1;
         }
 
-        $returnData = array("seller_data_list_origin"=>$toporigin,"toporiginMap"=>$toporiginMap,
-            "seller_data_list_destination"=>$topdestination,"topdestinationinMap"=>$topdestinationinMap,
+        $returnData = array("seller_data_list_origin"=>$toporigin,"toporiginMap"=>$toporiginMap,"toporiginType"=>$toporiginType,
+            "seller_data_list_destination"=>$topdestination,"topdestinationinMap"=>$topdestinationinMap,"topdestinationinType"=>$topdestinationinType,
             "min" => 0,"Max" =>$interval*10,"interval" =>$interval,
             "dest_min" => 0,"dest_Max" =>$dest_interval*10,"dest_interval" =>$dest_interval);
         return $returnData;
@@ -1511,7 +1515,9 @@ class common {
         //Milestones 数据信息待定
         $Milestones_data = array();
         $Milestones_data_arr = common::excuteListSql("select description,act_date||' '||act_time as date_time, remark,timezone from  ocean_milestone a 
-		 			where a.serial_no='".$ocean["serial_no"]."' order by id");           
+		 			where a.serial_no='".$ocean["serial_no"]."' 
+                        and act_date is not null  
+                    order by id");           
         foreach($Milestones_data_arr as $mda){
             $Milestones_data[] = array("milestones"=>$mda['description'],"date_time"=>$mda['date_time'],"timezone" =>$mda['timezone'],
                 "locations" => "", "remarks" =>$mda['remark']);