|
@@ -395,6 +395,7 @@ class ocean_order {
|
|
|
$sqlWhere .= " and ($more_sql)";
|
|
$sqlWhere .= " and ($more_sql)";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ //移除filterTag
|
|
|
$sqlWhere_befrom_filterTag = $sqlWhere;
|
|
$sqlWhere_befrom_filterTag = $sqlWhere;
|
|
|
|
|
|
|
|
//查询tag
|
|
//查询tag
|
|
@@ -404,6 +405,7 @@ class ocean_order {
|
|
|
// IFFDEP Departure Departed
|
|
// IFFDEP Departure Departed
|
|
|
// IFFARR Arrived at Final Destination Port Arrived
|
|
// IFFARR Arrived at Final Destination Port Arrived
|
|
|
// IFFAFD Arrived at Final Destination Completed
|
|
// IFFAFD Arrived at Final Destination Completed
|
|
|
|
|
+ $filterTag_param = "";
|
|
|
if (!empty($_POST["filterTag"])) {
|
|
if (!empty($_POST["filterTag"])) {
|
|
|
if (utils::count($_POST['filterTag']) == 1){
|
|
if (utils::count($_POST['filterTag']) == 1){
|
|
|
$filterTag = $_POST['filterTag'][0];
|
|
$filterTag = $_POST['filterTag'][0];
|
|
@@ -412,84 +414,77 @@ class ocean_order {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$_sqlwhere = "1<>1";
|
|
$_sqlwhere = "1<>1";
|
|
|
|
|
+ $filterTag_param = "1<>1";
|
|
|
if (stripos($filterTag, "Created") !== FALSE) {
|
|
if (stripos($filterTag, "Created") !== FALSE) {
|
|
|
- $_sqlwhere .= " or (dd.new_status = 'Created' or dd.new_status is null)";
|
|
|
|
|
|
|
+ $_sqlwhere .= " or (m_iffbcf is not 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 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)";
|
|
|
}
|
|
}
|
|
|
if (stripos($filterTag, "Cargo Received") !== FALSE) {
|
|
if (stripos($filterTag, "Cargo Received") !== FALSE) {
|
|
|
- $_sqlwhere .= " or (dd.new_status = 'Cargo Received')";
|
|
|
|
|
|
|
+ $_sqlwhere .= " or ((m_iffcpu is not null or m_iffrec is not 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_iffcpu is not null or m_iffrec is not null) and m_iffrec is null and m_iffdep is null and m_iffarr is null and m_iffafd is null)";
|
|
|
}
|
|
}
|
|
|
if (stripos($filterTag, "Departure") !== FALSE) {
|
|
if (stripos($filterTag, "Departure") !== FALSE) {
|
|
|
- $_sqlwhere .= " or (dd.new_status = 'Departed')";
|
|
|
|
|
|
|
+ $_sqlwhere .= "or (m_iffdep is not null and m_iffarr is null and m_iffafd is null)";
|
|
|
|
|
+ $filterTag_param .= "or (m_iffdep is not null and m_iffarr is null and m_iffafd is null)";
|
|
|
}
|
|
}
|
|
|
if (stripos($filterTag, "Arrived") !== FALSE) {
|
|
if (stripos($filterTag, "Arrived") !== FALSE) {
|
|
|
- $_sqlwhere .= " or (dd.new_status = 'Arrived')";
|
|
|
|
|
|
|
+ $_sqlwhere .= " or (m_iffarr is not null and m_iffafd is null)";
|
|
|
|
|
+ $filterTag_param .= " or (m_iffarr is not null and m_iffafd is null)";
|
|
|
}
|
|
}
|
|
|
if (stripos($filterTag, "Completed") !== FALSE) {
|
|
if (stripos($filterTag, "Completed") !== FALSE) {
|
|
|
- $_sqlwhere .= " or (dd.new_status = 'Completed')";
|
|
|
|
|
|
|
+ $_sqlwhere .= " or (m_iffafd is not null)";
|
|
|
|
|
+ $filterTag_param .= " or (m_iffafd is not null)";
|
|
|
}
|
|
}
|
|
|
if(strtolower($filterTag) <> "all" && !empty($filterTag)){
|
|
if(strtolower($filterTag) <> "all" && !empty($filterTag)){
|
|
|
$sqlWhere .= " and ($_sqlwhere)";
|
|
$sqlWhere .= " and ($_sqlwhere)";
|
|
|
|
|
+ $filterTag_param = " ($filterTag_param)";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ if(empty($filterTag_param)){
|
|
|
|
|
+ $filterTag_param = "1=1";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$rc = $_POST ['rc'];
|
|
$rc = $_POST ['rc'];
|
|
|
//这里都要查询,除非多传几个参数回来
|
|
//这里都要查询,除非多传几个参数回来
|
|
|
if ($rc == - 1 || true) {
|
|
if ($rc == - 1 || true) {
|
|
|
- $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;
|
|
|
|
|
-
|
|
|
|
|
- //后端带入Incoterms/Service
|
|
|
|
|
- $incoterms_sql = "select DISTINCT incoterms from online_ocean" . $sqlWhere_bk;
|
|
|
|
|
- $incoterms = common::excuteListSql($incoterms_sql);
|
|
|
|
|
|
|
+ $sql = "select count(1) as rc,
|
|
|
|
|
+ sum(case when $filterTag_param then 1 else 0 end) as seach_rc,
|
|
|
|
|
+ sum(case when (m_iffbcf is not 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 1 else 0 end)
|
|
|
|
|
+ as created,
|
|
|
|
|
+ sum(case when ((m_iffcpu is not null or m_iffrec is not null) and m_iffrec is null and m_iffdep is null and m_iffarr is null and m_iffafd 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_iffafd is null) then 1 else 0 end) as departed,
|
|
|
|
|
+ sum(case when (m_iffarr is not null and m_iffafd is null) then 1 else 0 end) as arrived,
|
|
|
|
|
+ sum(case when (m_iffafd 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 online_ocean". $sqlWhere_befrom_filterTag;
|
|
|
|
|
+ error_log("online_ocean_search_All_Status: ".$sql);
|
|
|
|
|
+
|
|
|
|
|
+ $sql_all_status_data = common::excuteObjectSql($sql);
|
|
|
|
|
+ $incoterms = explode("<$>", $sql_all_status_data['incoterm_str']);
|
|
|
$IncotermsList = array();
|
|
$IncotermsList = array();
|
|
|
foreach($incoterms as $terms){
|
|
foreach($incoterms as $terms){
|
|
|
if(!empty($terms['incoterms'])){
|
|
if(!empty($terms['incoterms'])){
|
|
|
$IncotermsList[] = array("name"=>$terms['incoterms'],"checked"=>false);
|
|
$IncotermsList[] = array("name"=>$terms['incoterms'],"checked"=>false);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- $service_sql = "select DISTINCT service from online_ocean" . $sqlWhere_bk;
|
|
|
|
|
- $service = common::excuteListSql($service_sql);
|
|
|
|
|
|
|
+ $service = explode("<$>", $sql_all_status_data['service_str']);
|
|
|
$ServiceList = array();
|
|
$ServiceList = array();
|
|
|
foreach($service as $_service){
|
|
foreach($service as $_service){
|
|
|
if(!empty($_service['service'])){
|
|
if(!empty($_service['service'])){
|
|
|
$ServiceList[] = array("name"=>$_service['service'],"checked"=>false);
|
|
$ServiceList[] = array("name"=>$_service['service'],"checked"=>false);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- $sql = $this->getOcanOrderSearchSql("All",$sqlWhere_bk);
|
|
|
|
|
- $rc = common::excuteOneSql($sql);
|
|
|
|
|
- error_log("online_ocean_count_ALL_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_bk);
|
|
|
|
|
- $Cargo_Received = common::excuteOneSql($sql);
|
|
|
|
|
- error_log("online_ocean_count_Cargo_Received_SQL: ".$sql);
|
|
|
|
|
-
|
|
|
|
|
- //Departed
|
|
|
|
|
- $sql = $this->getOcanOrderSearchSql("Departed",$sqlWhere_bk);
|
|
|
|
|
- $Departed = common::excuteOneSql($sql);
|
|
|
|
|
- error_log("online_ocean_count_Departed_SQL: ".$sql);
|
|
|
|
|
-
|
|
|
|
|
- //Arrived
|
|
|
|
|
- $sql = $this->getOcanOrderSearchSql("Arrived",$sqlWhere_bk);
|
|
|
|
|
- $Arrived = common::excuteOneSql($sql);
|
|
|
|
|
- error_log("online_ocean_count_Arrived_SQL: ".$sql);
|
|
|
|
|
-
|
|
|
|
|
- //Completed
|
|
|
|
|
- $sql = $this->getOcanOrderSearchSql("Completed",$sqlWhere_bk);
|
|
|
|
|
- $Completed = common::excuteOneSql($sql);
|
|
|
|
|
- error_log("online_ocean_count_Completed_SQL: ".$sql);
|
|
|
|
|
|
|
+ $rc = $sql_all_status_data['rc'];
|
|
|
|
|
+ $search_rc = $sql_all_status_data['seach_rc'];
|
|
|
|
|
+ $Created = $sql_all_status_data['created'];
|
|
|
|
|
+ $Cargo_Received = $sql_all_status_data['cargo_received'];
|
|
|
|
|
+ $Departed = $sql_all_status_data['departed'];
|
|
|
|
|
+ $Arrived = $sql_all_status_data['arrived'];
|
|
|
|
|
+ $Completed = $sql_all_status_data['completed'];
|
|
|
|
|
|
|
|
if (!empty($_POST["filterTag"])) {
|
|
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($rc),"type"=>"all","checked"=>utils::in_array('All', $_POST["filterTag"])? true : false),
|
|
@@ -535,26 +530,17 @@ class ocean_order {
|
|
|
$ocean_ref_sql = " LEFT JOIN LATERAL ( SELECT string_agg(ref_code ||ref_value, ', ') AS other_refenrence_no
|
|
$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 ";
|
|
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 '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 ";
|
|
|
|
|
-
|
|
|
|
|
$sql = "SELECT order_from as _schemas,serial_no as __serial_no, serial_no,
|
|
$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,
|
|
h_bol as _hbol, isf_bol as _isfbol, consignee_city as _consignee_city,
|
|
|
CASE
|
|
CASE
|
|
|
- WHEN dd.new_status is null THEN 'Created'::text
|
|
|
|
|
- ELSE dd.new_status::text
|
|
|
|
|
|
|
+ WHEN (m_iffbcf is not 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_iffrec is 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'
|
|
|
END AS new_status, ".
|
|
END AS new_status, ".
|
|
|
- column::getInstance()->getSearchSqlForDisplay('Ocean_Search') . " from public.online_ocean $ocean_ref_sql $ocean_status_sql" . $sqlWhere .
|
|
|
|
|
|
|
+ column::getInstance()->getSearchSqlForDisplay('Ocean_Search') . " from public.online_ocean $ocean_ref_sql " . $sqlWhere .
|
|
|
" order by $order_by limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
" order by $order_by limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
|
$rs = common::excuteListSql($sql);
|
|
$rs = common::excuteListSql($sql);
|
|
|
error_log("online_ocean_search_SQL: ".$sql);
|
|
error_log("online_ocean_search_SQL: ".$sql);
|
|
@@ -704,6 +690,10 @@ class ocean_order {
|
|
|
$quantity_tolal.=$uv." ".$uk." ";
|
|
$quantity_tolal.=$uv." ".$uk." ";
|
|
|
}
|
|
}
|
|
|
$ch_weight_tolal = empty($ch_weight_tolal) ? $ch_weight_tolal_grs_lbs : $ch_weight_tolal;
|
|
$ch_weight_tolal = empty($ch_weight_tolal) ? $ch_weight_tolal_grs_lbs : $ch_weight_tolal;
|
|
|
|
|
+
|
|
|
|
|
+ $g_weight_tolal = sprintf("%.3f", $g_weight_tolal);
|
|
|
|
|
+ $ch_weight_tolal = sprintf("%.3f", $ch_weight_tolal);
|
|
|
|
|
+ $cbm_tolal = sprintf("%.4f", $cbm_tolal);
|
|
|
//Containers信息
|
|
//Containers信息
|
|
|
$containers = array("container_column"=>$ocean_container_column,"container_data" =>$rss);
|
|
$containers = array("container_column"=>$ocean_container_column,"container_data" =>$rss);
|
|
|
//Packing信息
|
|
//Packing信息
|
|
@@ -877,9 +867,21 @@ class ocean_order {
|
|
|
$sql = common::deCode($_POST ['tmp_search'], 'D');
|
|
$sql = common::deCode($_POST ['tmp_search'], 'D');
|
|
|
$sql = substr($sql, 0, strripos($sql, " limit"));
|
|
$sql = substr($sql, 0, strripos($sql, " limit"));
|
|
|
if(!empty($sql)){
|
|
if(!empty($sql)){
|
|
|
- $rss = common::excuteListSql($sql);
|
|
|
|
|
|
|
+ $rs = common::excuteListSql($sql);
|
|
|
|
|
+ }
|
|
|
|
|
+ //对查询的结果做特殊处理,比如要拼接某个值,合并值等
|
|
|
|
|
+ foreach($rs as $index => $val) {
|
|
|
|
|
+ //返回加密serial_no
|
|
|
|
|
+ $rs[$index]["__serial_no"] = common::deCode($val['__serial_no'], 'E');
|
|
|
|
|
+ $rs[$index]["mode"] = "Ocean Freight";
|
|
|
|
|
+ //status 改为ocean_milestone里的信息
|
|
|
|
|
+ $rs[$index]["Status"] = $rs[$index]["new_status"];
|
|
|
|
|
+ //以下新增的origin是 shipper和consignee的地址
|
|
|
|
|
+ if(array_key_exists("Origin", $val)){
|
|
|
|
|
+ $rs[$index]["Origin"] = utils::outDisplayForMerge($val['Origin'],$val['_consignee_city']);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- common::echo_json_encode(200,array("msg"=>"success","Data" => $rss));
|
|
|
|
|
|
|
+ common::echo_json_encode(200,array("msg"=>"success","Data" => $rs));
|
|
|
exit;
|
|
exit;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1051,104 +1053,6 @@ class ocean_order {
|
|
|
common::download_file($url);
|
|
common::download_file($url);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function getOcanOrderSearchSql($type,$sqlWhere) {
|
|
|
|
|
- if($type == "All"){
|
|
|
|
|
- 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;
|
|
|
|
|
- }
|
|
|
|
|
- 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 '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.$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 '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.$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 '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.$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 '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.$Completed_sqlWhere;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private function save_vgm() {
|
|
private function save_vgm() {
|
|
|
$schemas = $_POST["schemas"];
|
|
$schemas = $_POST["schemas"];
|
|
|
$serial_no = common::deCode($_POST["serial_no"], 'D');
|
|
$serial_no = common::deCode($_POST["serial_no"], 'D');
|
|
@@ -1244,30 +1148,22 @@ class ocean_order {
|
|
|
$_schemas = "ocean";
|
|
$_schemas = "ocean";
|
|
|
}
|
|
}
|
|
|
$sql = "SELECT m_eta as _m_eta, h_bol as _h_bol, m_bol as _m_bol,job_no as _job_bol,
|
|
$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.*,oo.*,
|
|
|
|
|
- CASE
|
|
|
|
|
- WHEN ee.status is null THEN 'Created'::text
|
|
|
|
|
- ELSE ee.status::text
|
|
|
|
|
- END AS new_status
|
|
|
|
|
|
|
+ o.* ,sh.*, cn.* ,aa.*,dd.*,oo.*
|
|
|
from ocean o
|
|
from ocean o
|
|
|
- LEFT JOIN LATERAL ( SELECT shippr_uncode,shipper_city,
|
|
|
|
|
- consignee_uncode,consignee_city,fport_of_loading_un,mport_of_discharge_un,place_of_receipt_un,place_of_delivery_un
|
|
|
|
|
|
|
+ LEFT JOIN LATERAL ( SELECT tracking_no as _tracking_no,shippr_uncode,shipper_city,
|
|
|
|
|
+ consignee_uncode,consignee_city,incoterms,
|
|
|
|
|
+ fport_of_loading_un,mport_of_discharge_un,
|
|
|
|
|
+ place_of_receipt_un,place_of_delivery_un,
|
|
|
|
|
+ port_of_transshipment_un,
|
|
|
|
|
+ CASE
|
|
|
|
|
+ WHEN (m_iffbcf is not 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_iffrec is 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'::text
|
|
|
|
|
+ END AS new_status
|
|
|
FROM public.online_ocean oo WHERE oo.serial_no::text = o.serial_no::text) oo ON true
|
|
FROM public.online_ocean oo WHERE oo.serial_no::text = o.serial_no::text) oo ON true
|
|
|
- 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
|
|
|
|
|
- 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,
|
|
LEFT JOIN LATERAL ( SELECT company as cn_company,
|
|
|
address_1 as cn_address_1,
|
|
address_1 as cn_address_1,
|
|
|
address_2 as cn_address_2,
|
|
address_2 as cn_address_2,
|
|
@@ -1409,8 +1305,8 @@ class ocean_order {
|
|
|
$codeinfo = common::getCityPortsInfo($uncodes);
|
|
$codeinfo = common::getCityPortsInfo($uncodes);
|
|
|
|
|
|
|
|
//处理transportInfo信息数据
|
|
//处理transportInfo信息数据
|
|
|
- $transportInfo = array("Tracking No." =>$ocean['tracking_no'],"status"=>$ocean['new_status'],"mode" => "Ocean Freight",
|
|
|
|
|
- "origin" =>$ocean['origin_station'],"destination" =>$ocean['destination_station'],
|
|
|
|
|
|
|
+ $transportInfo = array("Tracking No." =>$ocean['_tracking_no'],"status"=>$ocean['new_status'],"mode" => "Ocean Freight",
|
|
|
|
|
+ "origin" =>$ocean['shippr_uncode'],"destination" =>$ocean['consignee_uncode'],
|
|
|
"etd" =>$ocean['f_etd'],"atd" =>$ocean['atd'],
|
|
"etd" =>$ocean['f_etd'],"atd" =>$ocean['atd'],
|
|
|
"etd_timezone" =>$codeinfo[$ocean['fport_of_loading_un']],
|
|
"etd_timezone" =>$codeinfo[$ocean['fport_of_loading_un']],
|
|
|
"atd_timezone" =>$codeinfo[$ocean['fport_of_loading_un']],
|
|
"atd_timezone" =>$codeinfo[$ocean['fport_of_loading_un']],
|
|
@@ -1447,19 +1343,19 @@ class ocean_order {
|
|
|
//处理routes 转船可能有多个情况
|
|
//处理routes 转船可能有多个情况
|
|
|
if ($ocean['is_vessel_direct'] <> "t"){
|
|
if ($ocean['is_vessel_direct'] <> "t"){
|
|
|
//不是直航
|
|
//不是直航
|
|
|
- $routes = array(array("mode" =>"Ocean Freight","mode_label" =>"Sea", "origin" =>$ocean['fport_of_loading'],
|
|
|
|
|
- "destination" => $ocean['fport_of_discharge'],
|
|
|
|
|
|
|
+ $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'],
|
|
"etd" => $ocean['f_etd'],"atd" => $ocean['atd'],
|
|
|
"eta" =>$ocean['f_eta'],"ata" => $ocean['ata'],
|
|
"eta" =>$ocean['f_eta'],"ata" => $ocean['ata'],
|
|
|
"vessel" =>$ocean['f_vessel'],"voyageNo" =>$ocean['f_voyage']));
|
|
"vessel" =>$ocean['f_vessel'],"voyageNo" =>$ocean['f_voyage']));
|
|
|
- $routes[] = array("mode" =>"Ocean Freight", "mode_label" =>"Sea","origin" =>$ocean['mport_of_loading'],
|
|
|
|
|
- "destination" => $ocean['mport_of_discharge'],
|
|
|
|
|
|
|
+ $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['atd'],
|
|
|
"eta" =>$ocean['m_eta'],"ata" =>$ocean['ata'],
|
|
"eta" =>$ocean['m_eta'],"ata" =>$ocean['ata'],
|
|
|
"vessel" =>$ocean['m_vessel'],"voyageNo" =>$ocean['m_voyage']);
|
|
"vessel" =>$ocean['m_vessel'],"voyageNo" =>$ocean['m_voyage']);
|
|
|
}else{
|
|
}else{
|
|
|
- $routes = array(array("mode" =>"Ocean Freight","mode_label" =>"Sea", "origin" =>$ocean['fport_of_loading'],
|
|
|
|
|
- "destination" => $ocean['fport_of_discharge'],
|
|
|
|
|
|
|
+ $routes = array(array("mode" =>"Ocean Freight","mode_label" =>"Sea", "origin" =>$ocean['shippr_uncode'],
|
|
|
|
|
+ "destination" => $ocean['consignee_uncode'],
|
|
|
"etd" => $ocean['f_etd'],"atd" => $ocean['atd'],
|
|
"etd" => $ocean['f_etd'],"atd" => $ocean['atd'],
|
|
|
"eta" =>$ocean['m_eta'],"ata" => $ocean['ata'],
|
|
"eta" =>$ocean['m_eta'],"ata" => $ocean['ata'],
|
|
|
"vessel" =>$ocean['f_vessel'],"voyageNo" =>$ocean['f_voyage']));
|
|
"vessel" =>$ocean['f_vessel'],"voyageNo" =>$ocean['f_voyage']));
|