ShuanghongS hai 1 mes
pai
achega
33c64ad1dd

+ 2 - 2
main_new_version.php

@@ -629,7 +629,7 @@ switch ($action) {
         }
         $tp = ceil($rc / $ps);
         if ($rc > 0) {
-            $sql = "SELECT order_from as _schemas,serial_no, consignee, shipper, h_bol,final_desination_uncode, transport_mode,
+            $sql = "SELECT order_from as _schemas,serial_no, consignee, shipper, h_bol,final_desination_uncode, transport_mode,transport_mode_extend,
                         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, booking_no,
@@ -756,7 +756,7 @@ switch ($action) {
                     "act_time" =>$value["act_time"],
                     "timezone"=>$timezone,
                     "_schemas"=>$value["_schemas"],
-                    "transport_mode"=>$value["transport_mode"],
+                    "transport_mode"=>$value["transport_mode_extend"],
                     'is_subscribe' =>common::checkedSubscribe($value['serial_no']),
                     "a" =>common::deCode($value['serial_no'], 'E'));
             }

+ 4 - 1
service/login.class.php

@@ -1325,7 +1325,10 @@ class login {
         $ocean = $ocean_arr[0];
         //处理transportInfo信息数据
         $transportInfo = array("Tracking No." =>$ocean['tracking_no'],"status"=>$ocean['new_status'],
-            "mode" => $ocean['transport_mode'] == 'sea' ? "Ocean Freight" : ($ocean['transport_mode'] == 'air' ? "Air Freight": ""),
+            "mode" =>$ocean['transport_mode_extend'] == 'sea' ? "Ocean Freight" : 
+                        ($ocean['transport_mode_extend'] == 'air' ?  "Air Freight": 
+                        ($ocean['transport_mode_extend'] == 'rail' ? "Rail Freight": 
+                        ($ocean['transport_mode_extend'] == 'road' ? "Road Freight": ""))),
             "origin" =>$ocean['shippr_uncode'],"destination" =>$ocean['consignee_uncode'],
             "etd" =>$ocean['etd'],"atd" =>$ocean['atd'],
             "etd_timezone" =>$ocean['pol_timezone'],

+ 32 - 16
service/ocean_booking.class.php

@@ -166,15 +166,15 @@ class ocean_booking {
             $transport_mode = array($transport_mode);
         }
         if(utils::count($transport_mode) == 1 && strtolower($transport_mode[0]) == 'all'){
-            $transport_mode = array("sea","air","road");         
+            $transport_mode = array("sea","air","road","rail");         
         }
 
         $transport_mode = utils::implode(";",$transport_mode);
         $mode_param = common::getInNotInSqlForSearch($transport_mode);
 
         
-        $sqlWhere .= " and transport_mode in ($mode_param)";
-        $transport_mode_search = " and transport_mode in ($mode_param)";
+        $sqlWhere .= " and transport_mode_extend in ($mode_param)";
+        $transport_mode_search = " and transport_mode_extend in ($mode_param)";
         //前端提交是数组
         if (!empty($_POST['filterTag']) && utils::count($_POST['filterTag']) < 4) {
             if (utils::count($_POST['filterTag']) == 1){
@@ -208,17 +208,20 @@ class ocean_booking {
             $filterTag_param = "1=1";
         }
         $tag_and_mode_param = $filterTag_param.$transport_mode_search;
+        $mode_param_search = "1=1 ".$transport_mode_search;
 
         $rc = $_POST ['rc'];
         //这里都要查询,除非多传几个参数回来
         if ($rc == - 1 || true) {
             $sql_all_status = "SELECT count(1) as rc,
-                sum(case when (1<>1 or (transport_mode='sea')) then 1 else 0 end) as sea_rc,
-                sum(case when (1<>1 or (transport_mode='air')) then 1 else 0 end) as air_rc,
+                sum(case when (1<>1 or (transport_mode_extend='sea')) then 1 else 0 end) as sea_rc,
+                sum(case when (1<>1 or (transport_mode_extend='air')) then 1 else 0 end) as air_rc,
+                sum(case when (1<>1 or (transport_mode_extend='road')) then 1 else 0 end) as road_rc, 
+                sum(case when (1<>1 or (transport_mode_extend='rail')) then 1 else 0 end) as rail_rc,
                 sum(case when $tag_and_mode_param then 1 else 0 end) as seach_rc,
-                sum(case when (1<>1 or (bol_type = 'BOOKING' and status!='Cancelled')) then 1 else 0 end) as creatd,
-                sum(case when (1<>1 or (bol_type != 'BOOKING')) then 1 else 0 end) as confirmed,
-                sum(case when (1<>1 or (status='Cancelled')) then 1 else 0 end) as concelled
+                sum(case when (1<>1 or ($mode_param_search and bol_type = 'BOOKING' and status!='Cancelled')) then 1 else 0 end) as creatd,
+                sum(case when (1<>1 or ($mode_param_search and bol_type != 'BOOKING')) then 1 else 0 end) as confirmed,
+                sum(case when (1<>1 or ($mode_param_search and status='Cancelled')) then 1 else 0 end) as concelled
             from public.kln_booking" . $sqlWhere_befrom_filterTag;
 
             error_log($sql_all_status );
@@ -230,19 +233,21 @@ class ocean_booking {
             $rc = $sql_all_status_data['rc'];
             $sea_rc = $sql_all_status_data['sea_rc'];
             $air_rc = $sql_all_status_data['air_rc'];
+            $road_rc = $sql_all_status_data['road_rc'];
+            $rail_rc = $sql_all_status_data['rail_rc'];
             $Creatd = $sql_all_status_data['creatd'];
             $Confirmed = $sql_all_status_data['confirmed'];
             $Concelled = $sql_all_status_data['concelled'];
 
             //前端数据返回,不管有无数据
             if (!empty($_POST["filterTag"])) {
-                $tagsList = array(array("name"=>"All","number"=>intval($rc),"type"=>"all","checked"=>utils::in_array('All', $_POST["filterTag"])? true : false),
+                $tagsList = array(array("name"=>"All","number"=>intval($seach_rc),"type"=>"all","checked"=>utils::in_array('All', $_POST["filterTag"])? true : false),
                 array("name"=>"Created","number"=>intval($Creatd),"type"=>"created","checked"=>utils::in_array('Created', $_POST["filterTag"])? true : false),
                 array("name"=>"Confirmed","number"=>intval($Confirmed),"type"=>"confirmed","checked"=>utils::in_array('Confirmed', $_POST["filterTag"])? true : false),
                 array("name"=>"Cancelled","number"=>intval($Concelled),"type"=>"cancelled","checked"=>utils::in_array('Cancelled', $_POST["filterTag"])? true : false));
             }else{
                 //初始,前端有选择着带入选择
-                $tagsList = array(array("name"=>"All","number"=>intval($rc),"type"=>"all","checked"=>true),
+                $tagsList = array(array("name"=>"All","number"=>intval($seach_rc),"type"=>"all","checked"=>true),
                 array("name"=>"Created","number"=>intval($Creatd),"type"=>"created","checked"=>false),
                 array("name"=>"Confirmed","number"=>intval($Confirmed),"type"=>"confirmed","checked"=>false),
                 array("name"=>"Cancelled","number"=>intval($Concelled),"type"=>"cancelled","checked"=>false));
@@ -250,7 +255,9 @@ class ocean_booking {
 
             $TransportList = array(
                 array("name"=>"Ocean Freight","sname"=>"Sea","number"=>intval($sea_rc),"checked"=>false,"icon"=>"#icon-icon_ocean_b"),
-                array("name"=>"Air Freight","sname"=>"Air","number"=>intval($air_rc),"checked"=>false,"icon"=>"#icon-icon_airplane_b"));
+                array("name"=>"Air Freight","sname"=>"Air","number"=>intval($air_rc),"checked"=>false,"icon"=>"#icon-icon_airplane_b"),
+                array("name"=>"Rail Freight","sname"=>"Rail","number"=>intval($rail_rc),"checked"=>false,"icon"=>"#icon-icon_railway_b"),
+                array("name"=>"Road Freight","sname"=>"Road","number"=>intval($road_rc),"checked"=>false,"icon"=>"#icon-icon_truck_b"));
             
 
             $transport_mode_arr = explode(";", $transport_mode);
@@ -274,7 +281,7 @@ class ocean_booking {
             $ocean_dest_sql = "";
             //合并显示两个特殊字段 voyage_m_voyage/vessel_m_vessel
             $sql = "SELECT order_from as _schemas, serial_no as __serial_no, 
-                        color,transport_mode, bol_type, m_voyage as _m_voyage, m_vessel as _m_vessel," .
+                        color,transport_mode,transport_mode_extend, bol_type, m_voyage as _m_voyage, m_vessel as _m_vessel," .
                         column::getInstance()->getSearchSqlForDisplay('Booking_Search') . " from public.kln_booking $ocean_dest_sql " . $sqlWhere . " order by $order_by limit " . $ps . " offset " . ($cp - 1) * $ps;
             
             //$rs = common::excuteListSql($sql);
@@ -314,7 +321,9 @@ class ocean_booking {
                 }
                 $rs[$index]["Status"] = $status;
 
-                $rs[$index]["Mode"] = $val['transport_mode'] == 'sea' ? "Ocean Freight" : ($val['transport_mode'] == 'air' ? "Air Freight": "");
+                $rs[$index]["Mode"] = $val['transport_mode_extend'] == 'sea' ? "Ocean Freight" : ($val['transport_mode_extend'] == 'air' ? "Air Freight": 
+                                                ($val['transport_mode_extend'] == 'rail' ? "Rail Freight": 
+                                                ($val['transport_mode_extend'] == 'road' ? "Road Freight": "")));;
             }
             
             $arrTmp = array('searchData' => $rs, 
@@ -360,7 +369,7 @@ class ocean_booking {
             LEFT JOIN LATERAL ( SELECT shippr_uncode,shipper_city,
                 consignee_uncode,consignee_city,
                 place_of_receipt_uncode,place_of_delivery_uncode,
-                fport_of_loading_uncode,mport_of_discharge_uncode,po_no as _po_no,transport_mode
+                fport_of_loading_uncode,mport_of_discharge_uncode,po_no as _po_no,transport_mode,transport_mode_extend
             FROM public.kln_booking ob WHERE o.serial_no::text = ob.serial_no::text) ob ON true
             LEFT JOIN LATERAL ( SELECT company as cn_company,
                 address_1 as cn_address_1,
@@ -635,7 +644,10 @@ class ocean_booking {
                 $status = "Cancelled";
             }
             $rs[$index]["Status"] = $status;
-            $rs[$index]["Mode"] = $val['transport_mode'] == 'sea' ? "Ocean Freight" : ($val['transport_mode'] == 'air' ? "Air Freight": "");
+            $rs[$index]["Mode"] = $val['transport_mode_extend'] == 'sea' ? "Ocean Freight" : 
+                        ($val['transport_mode_extend'] == 'air' ?  "Air Freight": 
+                        ($val['transport_mode_extend'] == 'rail' ? "Rail Freight": 
+                        ($val['transport_mode_extend'] == 'road' ? "Road Freight": "")));
         }
         common::echo_json_encode(200,array("msg"=>"success","Data" => $rs));
         exit;
@@ -704,7 +716,11 @@ class ocean_booking {
         $uncodes = $ocean['fport_of_loading_uncode'].";".$ocean['mport_of_discharge_uncode'];
         $codeinfo = common::getCityPortsInfo($uncodes);
         //处理transportInfo信息数据
-        $transportInfo = array("bookingNo." =>$ocean['booking_no'],"status"=>$status,"mode" => $ocean['transport_mode'] == 'sea' ? "Ocean Freight" : ($ocean['transport_mode'] == 'air' ? "Air Freight": ""),
+        $_mode =  $ocean['transport_mode_extend'] == 'sea' ? "Ocean Freight" : 
+                        ($ocean['transport_mode_extend'] == 'air' ?  "Air Freight": 
+                        ($ocean['transport_mode_extend'] == 'rail' ? "Rail Freight": 
+                        ($ocean['transport_mode_extend'] == 'road' ? "Road Freight": "")));
+        $transportInfo = array("bookingNo." =>$ocean['booking_no'],"status"=>$status,"mode" => $_mode,
             "origin" =>$ocean['shippr_uncode'],"destination" =>$ocean['consignee_uncode'],
             "etd" =>$ocean['f_etd'],"atd" =>$ocean['atd'],
             "etd_timezone" =>$codeinfo[$ocean['fport_of_loading_uncode']],

+ 47 - 17
service/ocean_order.class.php

@@ -909,6 +909,7 @@ class ocean_order {
             $filterTag_param = "1=1";
         }
         $tag_and_mode_param = $filterTag_param.$transport_mode_search;
+        $mode_param_search = "1=1 ".$transport_mode_search;
 
         $rc = $_POST ['rc'];
         //这里都要查询,除非多传几个参数回来
@@ -919,15 +920,15 @@ class ocean_order {
                 sum(case when (1<>1 or (transport_mode_extend='road')) then 1 else 0 end) as road_rc, 
                 sum(case when (1<>1 or (transport_mode_extend='rail')) then 1 else 0 end) as rail_rc, 
                 sum(case when $tag_and_mode_param then 1 else 0 end) as seach_rc, 
-                sum(case when (m_iffcpu is null and m_iffrec is null and m_iffdep is null and m_iffarr is null and m_iffdel is null)
+                sum(case when ($mode_param_search and m_iffcpu is null and m_iffrec is null and m_iffdep is null and m_iffarr is null and m_iffdel is null)
                      then 1 else 0 end) 
                 as created, 
-                sum(case when ((m_iffcpu is not null or m_iffrec is not null) and m_iffdep is null and m_iffarr is null and m_iffdel is null)
+                sum(case when ($mode_param_search and (m_iffcpu is not null or m_iffrec is not null) and m_iffdep is null and m_iffarr is null and m_iffdel is null)
                      then 1 else 0 end) 
                 as cargo_received,
-                sum(case when (m_iffdep is not null and m_iffarr is null and m_iffdel is null) then 1 else 0 end) as departed,
-                sum(case when (m_iffarr is not null and m_iffdel is null) then 1 else 0 end) as arrived,
-                sum(case when (m_iffdel is not null) then 1 else 0 end) as completed,
+                sum(case when ($mode_param_search and m_iffdep is not null and m_iffarr is null and m_iffdel is null) then 1 else 0 end) as departed,
+                sum(case when ($mode_param_search and m_iffarr is not null and m_iffdel is null) then 1 else 0 end) as arrived,
+                sum(case when ($mode_param_search and m_iffdel is not null) then 1 else 0 end) as completed,
                 string_agg(distinct incoterms, '<$>') as incoterm_str,
                 string_agg(distinct service, '<$>') as service_str 
             from public.kln_ocean". $sqlWhere_befrom_filterTag;
@@ -962,7 +963,7 @@ class ocean_order {
             $Completed = $sql_all_status_data['completed'];
             
             if (!empty($_POST["filterTag"])) {
-                $tagsList = array(array("name"=>"All","number"=>intval($rc),"type"=>"all","checked"=>utils::in_array('All', $_POST["filterTag"])? true : false),
+                $tagsList = array(array("name"=>"All","number"=>intval($search_rc),"type"=>"all","checked"=>utils::in_array('All', $_POST["filterTag"])? true : false),
                 array("name"=>"Created","number"=>intval($Created),"type"=>"created","checked"=>utils::in_array('Created', $_POST["filterTag"])? true : false),
                 array("name"=>"Cargo Received","number"=>intval($Cargo_Received),"type"=>"cargo_received","checked"=>utils::in_array('Cargo Received', $_POST["filterTag"])? true : false),
                 array("name"=>"Departure","number"=>intval($Departed),"type"=>"departure","checked"=>utils::in_array('Departure', $_POST["filterTag"])? true : false),
@@ -970,7 +971,7 @@ class ocean_order {
                 array("name"=>"Completed","number"=>intval($Completed),"type"=>"completed","checked"=>utils::in_array('Completed', $_POST["filterTag"])? true : false));
             }else{
                 //初始,前端有选择着带入选择
-                $tagsList = array(array("name"=>"All","number"=>intval($rc),"type"=>"all","checked"=> true ),
+                $tagsList = array(array("name"=>"All","number"=>intval($search_rc),"type"=>"all","checked"=> true ),
                 array("name"=>"Created","number"=>intval($Created),"type"=>"created","checked"=> false),
                 array("name"=>"Cargo Received","number"=>intval($Cargo_Received),"type"=>"cargo_received","checked"=> false),
                 array("name"=>"Departure","number"=>intval($Departed),"type"=>"departure","checked"=> false),
@@ -980,7 +981,9 @@ class ocean_order {
 
             $TransportList = array(
                 array("name"=>"Ocean Freight","sname"=>"Sea","number"=>intval($sea_rc),"checked"=>false,"icon"=>"#icon-icon_ocean_b"),
-                array("name"=>"Air Freight","sname"=>"Air","number"=>intval($air_rc),"checked"=>false,"icon"=>"#icon-icon_airplane_b"));
+                array("name"=>"Air Freight","sname"=>"Air","number"=>intval($air_rc),"checked"=>false,"icon"=>"#icon-icon_airplane_b"),
+                array("name"=>"Rail Freight","sname"=>"Rail","number"=>intval($rail_rc),"checked"=>false,"icon"=>"#icon-icon_railway_b"),
+                array("name"=>"Road Freight","sname"=>"Road","number"=>intval($road_rc),"checked"=>false,"icon"=>"#icon-icon_truck_b"));
             
             $transport_mode_arr = explode(";", $transport_mode);
             foreach($transport_mode_arr as $mode){
@@ -1003,7 +1006,7 @@ 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 = oo.serial_no) aa ON true ";
 
-            $sql = "with oo  as (SELECT oe.*, order_from as _schemas,serial_no as __serial_no, serial_no,transport_mode,
+            $sql = "with oo  as (SELECT oe.*, order_from as _schemas,serial_no as __serial_no, serial_no,transport_mode,transport_mode_extend,
                     h_bol as _hbol, isf_bol as _isfbol, consignee_city as _consignee_city,
                     (select user_login from public.kln_user_subscribed us  
                         where lower(us.user_login) = '".strtolower(_getLoginName())."' and us.subscribed_serial_no = kln_ocean.serial_no) as is_subscribe,
@@ -1023,15 +1026,17 @@ class ocean_order {
                     FROM public.kln_ocean_extend oe WHERE oe.serial_no::text = kln_ocean.serial_no::text and oe.order_from::text = kln_ocean.order_from::text) oe ON true " 
                 . $sqlWhere . " order by $order_by limit " . $ps . " offset " . ($cp - 1) * $ps.") 
             select oo.* ,
-                case when oo.transport_mode ='sea' 
+                case when oo.transport_mode ='sea'  and oo.order_from ='public'
                         then ( SELECT string_agg(ref_code ||ref_value, ', ') AS other_refenrence_no FROM public.ocean_reference temp WHERE temp.serial_no = oo.serial_no)
+                    when oo.transport_mode ='sea'   and oo.order_from ='sfs'
+                        then ( SELECT string_agg(ref_code ||ref_value, ', ') AS other_refenrence_no FROM sfs.ocean_reference temp WHERE temp.serial_no = oo.serial_no)    
                     when oo.transport_mode ='air' 
                         then ''
                     else '' 
                 end as \"Other refenrence No.\"
             from oo";
 
-            $tmp_search_without_limit = "with oo  as (SELECT oe.*, order_from as _schemas,serial_no as __serial_no, serial_no,transport_mode,
+            $tmp_search_without_limit = "with oo  as (SELECT oe.*, order_from as _schemas,serial_no as __serial_no, serial_no,transport_mode,transport_mode_extend,
                     h_bol as _hbol, isf_bol as _isfbol, consignee_city as _consignee_city,
                     (select user_login from public.kln_user_subscribed us  
                         where lower(us.user_login) = '".strtolower(_getLoginName())."' and us.subscribed_serial_no = kln_ocean.serial_no) as is_subscribe,
@@ -1051,8 +1056,10 @@ class ocean_order {
                     FROM public.kln_ocean_extend oe WHERE oe.serial_no::text = kln_ocean.serial_no::text and oe.order_from::text = kln_ocean.order_from::text) oe ON true " 
                 . $sqlWhere . " order by $order_by) 
            select oo.* ,
-                case when oo.transport_mode ='sea' 
+                case when oo.transport_mode ='sea'  and oo.order_from ='public'
                         then ( SELECT string_agg(ref_code ||ref_value, ', ') AS other_refenrence_no FROM public.ocean_reference temp WHERE temp.serial_no = oo.serial_no)
+                    when oo.transport_mode ='sea'   and oo.order_from ='sfs'
+                        then ( SELECT string_agg(ref_code ||ref_value, ', ') AS other_refenrence_no FROM sfs.ocean_reference temp WHERE temp.serial_no = oo.serial_no)    
                     when oo.transport_mode ='air' 
                         then ''
                     else '' 
@@ -1068,7 +1075,9 @@ class ocean_order {
                 //返回加密serial_no
                 $rs[$index]["__serial_no"] = common::deCode($val['__serial_no'], 'E');
                 //$rs[$index]["mode"] = "Ocean Freight";
-                $rs[$index]["Mode"] = $val['transport_mode'] == 'sea' ? "Ocean Freight" : ($val['transport_mode'] == 'air' ? "Air Freight": "");
+                $rs[$index]["Mode"] = $val['transport_mode_extend'] == 'sea' ? "Ocean Freight" : ($val['transport_mode_extend'] == 'air' ? "Air Freight": 
+                                                ($val['transport_mode_extend'] == 'rail' ? "Rail Freight": 
+                                                ($val['transport_mode_extend'] == 'road' ? "Road Freight": "")));
                 //status 改为ocean_milestone里的信息
                 $rs[$index]["Status"] = $rs[$index]["new_status"];
                 $rs[$index]["Shipment Type"] = $rs[$index]["Shipment Type"] == 'GPE' ? 'LCL' : $rs[$index]["Shipment Type"];
@@ -1191,6 +1200,8 @@ class ocean_order {
         //处理Container :配置Ocean_Container字段 UI 需要的字段有:Container.no Packing,quantity,Gross weight(kg),Gross weight(LB),CBM,seal#,size.service
         $ocean_container_column = array();
         $container_column = column::getInstance()->getDisplayColumnAll('Ocean_Container');
+        //特殊处理po_no,配置column在查询的时候,不好
+        $container_column[] = array("database_column_name" => "po_no","name"=>"PO_NO");
         $container_column_config = array("Quantity" => array("formatter"=>"number","digits"=>0),
                 "Gross Weight" => array("formatter"=>"number","digits"=>3),
                 "Gross Weight" => array("formatter"=>"number","digits"=>3),
@@ -1207,7 +1218,10 @@ class ocean_order {
             }
 
         }
-        $sql = "SELECT " . column::getInstance()->getSearchSql('Ocean_Container') . ",net_lbs from oc_container where lower(serial_no) = '" . strtolower($serial_no) . "'";
+        $sql = "SELECT " . column::getInstance()->getSearchSql('Ocean_Container') . ",
+                net_lbs,po_no as oc_po_no,
+                (select po_no from oc_container_item where oc_container_id = oc_container.id) as item_po_no 
+            from oc_container where lower(serial_no) = '" . strtolower($serial_no) . "'";
         $rss = common::excuteListSql($sql);
 
         $quantity_unit = array();
@@ -1216,6 +1230,9 @@ class ocean_order {
         $ch_weight_tolal_grs_lbs = 0;
         $cbm_tolal = 0;
         foreach ($rss as $key => $rs) {
+            //特殊处理po_no
+            $rss[$key]['po_no'] = utils::outDisplayForMergeForDISTINCT($rs['oc_po_no'],$rs['item_po_no']);
+
             $unit = $rs['unit'];
             if (array_key_exists($unit, $quantity_unit)) {
                 $quantity_unit[$unit] = $quantity_unit[$unit] + $rs['qty'];
@@ -1559,7 +1576,10 @@ class ocean_order {
             //返回加密serial_no
             $rs[$index]["__serial_no"] = common::deCode($val['__serial_no'], 'E');
             //$rs[$index]["mode"] = "Ocean Freight";
-            $rs[$index]["Mode"] = $val['transport_mode'] == 'sea' ? "Ocean Freight" : ($val['transport_mode'] == 'air' ? "Air Freight": "");
+            $rs[$index]["Mode"] = $val['transport_mode_extend'] == 'sea' ? "Ocean Freight" : 
+                        ($val['transport_mode_extend'] == 'air' ?  "Air Freight": 
+                        ($val['transport_mode_extend'] == 'rail' ? "Rail Freight": 
+                        ($val['transport_mode_extend'] == 'road'? "Road Freight": "")));
             //status 改为ocean_milestone里的信息
             $rs[$index]["Status"] = $rs[$index]["new_status"];
         }
@@ -1953,6 +1973,7 @@ class ocean_order {
                     atd as oo_atd,
                     ata as oo_ata,
                     carbon_emission,
+                    transport_mode_extend,
                     port_of_transshipment_un,
                     (select time_zone from public.city_timezone where uncode = oo.fport_of_loading_un limit 1) as pol_timezone,
                     (select uncity from $order_from.ports where uncode = oo.fport_of_loading_un limit 1) as pol_uncity,
@@ -2211,7 +2232,12 @@ class ocean_order {
         $data['shipmentData'] = $simplexData;
 
         //处理transportInfo信息数据(air改过,从KLN_Ocean主表信息 etd 和eta 的取值跟ocean的f_etd,m_eta)
-        $transportInfo = array("Tracking No." =>$ocean['_tracking_no'],"status"=>$ocean['new_status'],"mode" => "Ocean Freight",
+        $_mode =  $ocean['transport_mode_extend'] == 'sea' ? "Ocean Freight" : 
+                        ($ocean['transport_mode_extend'] == 'air' ?  "Air Freight": 
+                        ($ocean['transport_mode_extend'] == 'rail' ? "Rail Freight": 
+                        ($ocean['transport_mode_extend'] == 'road' ? "Road Freight": "")));
+
+        $transportInfo = array("Tracking No." =>$ocean['_tracking_no'],"status"=>$ocean['new_status'],"mode" => $_mode,
             "origin" =>$ocean['shippr_uncode'],"destination" =>$ocean['consignee_uncode'],
             "etd" =>$ocean['f_etd'],"atd" =>$ocean['atd'],
             "etd_timezone" =>$ocean['pol_timezone'],
@@ -2374,7 +2400,11 @@ class ocean_order {
         $data['shipmentData'] = $simplexData;
 
         //处理transportInfo信息数据(air改过,从KLN_Ocean主表信息 etd 和eta 的取值跟ocean的f_etd,m_eta)
-        $transportInfo = array("Tracking No." =>$ocean['tracking_no'],"status"=>$ocean['new_status'],"mode" => "Air Freight",
+        $_mode =  $ocean['transport_mode_extend'] == 'sea' ? "Ocean Freight" : 
+                        ($ocean['transport_mode_extend'] == 'air' ?  "Air Freight": 
+                        ($ocean['transport_mode_extend'] == 'rail' ? "Rail Freight": 
+                        ($ocean['transport_mode_extend'] == 'road' ? "Road Freight": "")));
+        $transportInfo = array("Tracking No." =>$ocean['tracking_no'],"status"=>$ocean['new_status'],"mode" => $_mode,
             "origin" =>$ocean['shippr_uncode'],"destination" =>$ocean['consignee_uncode'],
             "etd" =>$ocean['etd'],"atd" =>$ocean['atd'],
             "etd_timezone" =>$ocean['pol_timezone'],

+ 18 - 9
service/tools.class.php

@@ -1666,9 +1666,9 @@ class tools {
                         else ''
                     end as ctnr_desc,
 
-                    ccc.order_from,ccc.h_bol,ccc.transport_mode,ccc.m_bol
+                    ccc.order_from,ccc.h_bol,ccc.transport_mode,ccc.transport_mode_extend,ccc.m_bol
                 from public.kln_notifiation_info ni
-                        inner join LATERAL (select oo.h_bol,oo.transport_mode,oo.order_from,oo.m_bol 
+                        inner join LATERAL (select oo.h_bol,oo.transport_mode,oo.transport_mode_extend,oo.order_from,oo.m_bol 
                             from public.kln_ocean oo 
                             where oo.serial_no = ni.serial_no limit 1) ccc on true
                         left join LATERAL (select COALESCE(ke.default_time_zone,'UTC-08') as default_time_zone from public.kln_user_extend ke where lower(ke.user_login) = lower(ni.user_login) limit 1) ddd on true    
@@ -1952,12 +1952,12 @@ class tools {
                         else ''
                     end as ctnr_desc,
 
-                    ccc.order_from,ccc.h_bol,ccc.transport_mode,ccc.m_bol,eee.*
+                    ccc.order_from,ccc.h_bol,ccc.transport_mode,ccc.transport_mode_extend,ccc.m_bol,eee.*
                 from public.kln_notifiation_info ni
                         inner join LATERAL (select id,total_count,departure_count,arrival_count,etd_count,eta_count
                             from summary 
                             where id = ni.id ) eee on true
-                        left join LATERAL (select oo.h_bol,oo.transport_mode,oo.order_from,oo.m_bol 
+                        left join LATERAL (select oo.h_bol,oo.transport_mode,oo.transport_mode_extend,oo.order_from,oo.m_bol 
                             from public.kln_ocean oo 
                             where oo.serial_no = ni.serial_no limit 1) ccc on true
                         left join LATERAL (select COALESCE(ke.default_time_zone,'UTC-08') as default_time_zone from public.kln_user_extend ke where lower(ke.user_login) = lower(ni.user_login) limit 1) ddd on true    
@@ -2258,9 +2258,9 @@ class tools {
                         then public.getPreviousMilestone(bb.serial_no,bb.milestone_code,ccc.transport_mode,ccc.order_from)
                     else ''
                     end as milestone_previous_json,
-	                ccc.order_from,ccc.h_bol,ccc.transport_mode,ccc.m_bol
+	                ccc.order_from,ccc.h_bol,ccc.transport_mode,ccc.transport_mode_extend,ccc.m_bol
                 from  bb 
-	                inner join LATERAL (select oo.h_bol,oo.transport_mode,oo.order_from,oo.m_bol 
+	                inner join LATERAL (select oo.h_bol,oo.transport_mode,oo.transport_mode_extend,oo.order_from,oo.m_bol 
                             from public.kln_ocean oo 
                         where oo.serial_no = bb.serial_no limit 1) ccc on true " .$limit_param;
 
@@ -2341,7 +2341,10 @@ class tools {
                     "numericRecords"=>0,
                     "isRead"=>!empty($mInfo["is_send_message"]) ? true : false,
                     "title"=>"Milestone Update",
-                    "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
+                    "mode"=>$mInfo['transport_mode_extend'] == 'sea' ? "Ocean Freight" : 
+                            ($mInfo['transport_mode_extend'] == 'air' ?  "Air Freight": 
+                            ($mInfo['transport_mode_extend'] == 'rail' ? "Rail Freight": 
+                            ($mInfo['transport_mode_extend'] == 'road' ? "Road Freight": ""))),
                     "no"=>!empty($mInfo["h_bol"]) ? $mInfo["h_bol"] : $mInfo["m_bol"],
                     "tag"=>$mInfo["milestone_description"],
                     "location"=>$mInfo["milestone_locations"],
@@ -2489,7 +2492,10 @@ class tools {
                     "numericRecords"=>0,
                     "isRead"=>!empty($mInfo["is_send_message"]) ? true : false,
                     "title"=>$title,
-                    "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
+                    "mode"=>$mInfo['transport_mode_extend'] == 'sea' ? "Ocean Freight" : 
+                            ($mInfo['transport_mode_extend'] == 'air' ?  "Air Freight": 
+                            ($mInfo['transport_mode_extend'] == 'rail' ? "Rail Freight": 
+                            ($mInfo['transport_mode_extend'] == 'road' ? "Road Freight": ""))),
                     "no"=>!empty($mInfo["h_bol"]) ? $mInfo["h_bol"] : $mInfo["m_bol"],
                     //第一个字母大写
                     "tag"=>ucfirst($mInfo["delay_name"]),
@@ -2560,7 +2566,10 @@ class tools {
                     "numericRecords"=>0,
                     "isRead"=>!empty($mInfo["is_send_message"]) ? true : false,
                     "title"=>$title,
-                    "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
+                    "mode"=>$mInfo['transport_mode_extend'] == 'sea' ? "Ocean Freight" : 
+                            ($mInfo['transport_mode_extend'] == 'air' ?  "Air Freight": 
+                            ($mInfo['transport_mode_extend'] == 'rail' ? "Rail Freight": 
+                            ($mInfo['transport_mode_extend'] == 'road' ? "Road Freight": ""))),
                     "no"=>!empty($mInfo["h_bol"]) ? $mInfo["h_bol"] : $mInfo["m_bol"],
                     "tag"=>ucfirst($mInfo["date_change_name"]),
                     "location"=>"",

+ 17 - 15
utils/common.class.php

@@ -1259,30 +1259,32 @@ class common {
         }
         $mode_param = "";
         if(utils::count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
-            $mode_param = "'sea','air','road'";         
+            $mode_param = "'sea','air','road','rail'";         
         }else{
             $transport_mode = utils::implode(';', $transportation);
             $mode_param = common::getInNotInSqlForSearch($transport_mode);
         }
-        $sqlWhere .= " and transport_mode in ($mode_param)";
+        $sqlWhere .= " and transport_mode_extend in ($mode_param)";
          
         $ContainerCount_Title = array();
         //先查询总的排放量sea air road,确定排名后,在分别查询对应的sea air road 
         //这里的问题跟 top 一样 。总的排放量查询有问题。目前是总的排放量 暂时等于 sea的排放量
         if ($type == "co2e_orgin"){
             $co2e_shippr_sql = "select SUM(COALESCE(carbon_emission,0)) as catnum ,
-                sum(case when (1<>1 or (transport_mode='air')) then COALESCE(carbon_emission,0) else 0 end) as air_rc,
-                sum(case when (1<>1 or (transport_mode='sea')) then COALESCE(carbon_emission,0) else 0 end) as sea_rc, 
-                sum(case when (1<>1 or (transport_mode='road')) then COALESCE(carbon_emission,0) else 0 end) as road_rc, 
+                sum(case when (1<>1 or (transport_mode_extend='air')) then COALESCE(carbon_emission,0) else 0 end) as air_rc,
+                sum(case when (1<>1 or (transport_mode_extend='sea')) then COALESCE(carbon_emission,0) else 0 end) as sea_rc, 
+                sum(case when (1<>1 or (transport_mode_extend='road')) then COALESCE(carbon_emission,0) else 0 end) as road_rc,
+                sum(case when (1<>1 or (transport_mode_extend='rail')) then COALESCE(carbon_emission,0) else 0 end) as rail_rc, 
                 shippr_uncode as station from public.kln_ocean  where 1=1 and COALESCE(shippr_uncode,'')<>'' and carbon_emission is not null  $sqlWhere group by shippr_uncode order by catnum desc limit 10";
             //$co2e_aLL = common::excuteListSql($co2e_shippr_sql);
             $co2e_aLL = $mapdb->GetAll($co2e_shippr_sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $co2e_shippr_sql), 0));
         }
         if ($type == "co2e_destination"){
             $co2e_consignee_sql = "select SUM(COALESCE(carbon_emission,0)) as catnum ,
-                sum(case when (1<>1 or (transport_mode='air')) then COALESCE(carbon_emission,0) else 0 end) as air_rc,
-                sum(case when (1<>1 or (transport_mode='sea')) then COALESCE(carbon_emission,0) else 0 end) as sea_rc, 
-                sum(case when (1<>1 or (transport_mode='road')) then COALESCE(carbon_emission,0) else 0 end) as road_rc, 
+                sum(case when (1<>1 or (transport_mode_extend='air')) then COALESCE(carbon_emission,0) else 0 end) as air_rc,
+                sum(case when (1<>1 or (transport_mode_extend='sea')) then COALESCE(carbon_emission,0) else 0 end) as sea_rc, 
+                sum(case when (1<>1 or (transport_mode_extend='road')) then COALESCE(carbon_emission,0) else 0 end) as road_rc,
+                sum(case when (1<>1 or (transport_mode_extend='rail')) then COALESCE(carbon_emission,0) else 0 end) as rail_rc,  
                 consignee_uncode as station from public.kln_ocean  where 1=1 and COALESCE(consignee_uncode,'')<>'' and carbon_emission is not null $sqlWhere group by consignee_uncode order by catnum desc limit 10";
             //$co2e_aLL = common::excuteListSql($co2e_consignee_sql);
             $co2e_aLL = $mapdb->GetAll($co2e_consignee_sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $co2e_consignee_sql), 0));
@@ -1300,7 +1302,7 @@ class common {
         // $station_str = utils::implode(',',$stations);
 
         $ContainerCounSeries = array();
-        $shipment_mode_arr = array("air","sea","road");
+        $shipment_mode_arr = array("air","sea","road","rail");
         foreach($shipment_mode_arr as $_shipment_mode){
             //类型有 sea air road,目前之类只查询sea的,其他为空
             $shipment_mode = $_shipment_mode;
@@ -1368,12 +1370,12 @@ class common {
         }
         $mode_param = "";
         if(utils::count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
-            $mode_param = "'sea','air','road'";         
+            $mode_param = "'sea','air','road','rail'";         
         }else{
             $transport_mode = utils::implode(';', $transportation);
             $mode_param = common::getInNotInSqlForSearch($transport_mode);
         }
-        $sqlWhere .= " and transport_mode in ($mode_param)";    
+        $sqlWhere .= " and transport_mode_extend in ($mode_param)";    
          
         $toporiginType = "shippr_uncode";
         $shippr_uncode_10_sql ="with aa as  (select count(shippr_uncode) as num,shippr_uncode,
@@ -1524,12 +1526,12 @@ class common {
         }
         $mode_param = "";
         if(utils::count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
-            $mode_param = "'sea','air','road'";         
+            $mode_param = "'sea','air','road','rail'";         
         }else{
             $transport_mode = utils::implode(';', $transportation);
             $mode_param = common::getInNotInSqlForSearch($transport_mode);
         }
-        $sqlWhere .= " and transport_mode in ($mode_param)";    
+        $sqlWhere .= " and transport_mode_extend in ($mode_param)";    
          
         $toporiginType = "shippr_uncode";
         $shippr_uncode_10_sql ="with aa as  (select count(shippr_uncode) as num,shippr_uncode,
@@ -2361,12 +2363,12 @@ class common {
         }
         $mode_param = "";
         if(utils::count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
-            $mode_param = "'sea','air','road'";         
+            $mode_param = "'sea','air','road','rail'";         
         }else{
             $transport_mode = utils::implode(';', $transportation);
             $mode_param = common::getInNotInSqlForSearch($transport_mode);
         }
-        return " and transport_mode in ($mode_param)";
+        return " and transport_mode_extend in ($mode_param)";
     }
 
 

+ 21 - 1
utils/utils.class.php

@@ -856,7 +856,7 @@ class utils {
 
         $shipment_mode_where = " 1=1 ";
         //这里处理为空,目前没有数据
-        $shipment_mode_where = " transport_mode = '$shipment_mode' ";
+        $shipment_mode_where = " transport_mode_extend = '$shipment_mode' ";
         $shipment_mode_where .= $sqlWhere;
         foreach ($ids_arr as $value) {
             if (!empty($value)) {
@@ -1772,5 +1772,25 @@ class utils {
         }
         return $decrypted;
     }
+
+
+    /**
+     * 去重显示 pono
+     */
+    public static function outDisplayForMergeForDISTINCT($ocPoNo, $itemPoNo){
+        if ($ocPoNo === null && $itemPoNo === null) {
+            return null;
+        }
+
+        if (trim($ocPoNo) == trim($itemPoNo)) {
+            return $ocPoNo;
+        }
+
+        $parts = [];
+        if (!empty($ocPoNo)) $parts[] = $ocPoNo;
+        if (!empty($itemPoNo)) $parts[] = $itemPoNo;
+
+        return implode(',', $parts);
+    }
 }
 ?>