|
|
@@ -47,7 +47,15 @@ class ocean_order {
|
|
|
}
|
|
|
|
|
|
if ($operate == "detail") {
|
|
|
- $this->_ocean_detail();
|
|
|
+ $serial_no = common::deCode($_GET['a'], 'D');
|
|
|
+ $transport_mode = common::excuteOneSql("SELECT transport_mode FROM public.kln_ocean ob WHERE ob.serial_no = '$serial_no'");
|
|
|
+ if ($transport_mode == "sea"){
|
|
|
+ $this->_ocean_detail();
|
|
|
+ } elseif ($transport_mode == "air"){
|
|
|
+ $this->_air_ocean_detail();
|
|
|
+ } else {
|
|
|
+ $this->_ocean_detail();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if ($operate == "ams_isf_log"){
|
|
|
@@ -268,6 +276,15 @@ class ocean_order {
|
|
|
}
|
|
|
exit();
|
|
|
}
|
|
|
+
|
|
|
+ /*
|
|
|
+ * share_shipment 这个提交的意义,是为了留下记录用户信息
|
|
|
+ */
|
|
|
+ if ($operate == "share_shipment") {
|
|
|
+ $data = array("msg" =>"share_shipment");
|
|
|
+ common::echo_json_encode(200,$data);
|
|
|
+ exit();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -281,7 +298,7 @@ class ocean_order {
|
|
|
if (empty($cp))
|
|
|
$cp = 1;
|
|
|
|
|
|
- $sqlWhere = ' where ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
+ $sqlWhere = ' where ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
$sqlWhere .= search::getInstance()->getSearchSQL("Ocean_Search");
|
|
|
|
|
|
if (!empty($_REQUEST["_reportRef"])) {
|
|
|
@@ -398,18 +415,7 @@ class ocean_order {
|
|
|
$textSearch_arr = str_replace(",", ";", $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)";
|
|
|
- // }
|
|
|
$more_param = common::getInNotInSqlForSearch(strtolower(implode(';',$textSearch_arr)));
|
|
|
- // or text_search @@ (str_to_tsquery('" . common::check_input($_POST["_textSearch"]) . "'))
|
|
|
//$sqlWhere .= " and (ARRAY[$more_param] && array_append(array[lower(booking_no)::text,lower(h_bol)::text, lower(po_no),lower(carrier_booking),lower(tracking_no)],''))";
|
|
|
$sqlWhere .= " and ((ARRAY[$more_param] && array_append(ARRAY[lower(booking_no::text), lower(h_bol::text), lower(m_bol), lower(carrier_booking), lower(quote_no), lower(tracking_no)]||string_to_array(lower(ctnrs),','), ''::text))
|
|
|
or lower(po_no) like '%" . strtolower(common::check_input($_POST["_textSearch"])) . "%'
|
|
|
@@ -417,6 +423,22 @@ class ocean_order {
|
|
|
}
|
|
|
//移除filterTag
|
|
|
$sqlWhere_befrom_filterTag = $sqlWhere;
|
|
|
+
|
|
|
+ $mode_param = "";
|
|
|
+ if(!isset($_POST["transport_mode"]) || empty($_POST["transport_mode"])){
|
|
|
+ $_POST["transport_mode"] = "all";
|
|
|
+ }
|
|
|
+ if (strtolower($_POST["transport_mode"]) == "all") {
|
|
|
+ $mode_param = "'sea','air'";
|
|
|
+ } else {
|
|
|
+ $transport_mode = str_replace(",", ";", $_POST["transport_mode"]);
|
|
|
+ //替换transport_mode对应的value
|
|
|
+ $transport_mode = str_replace("Ocean Freight", "sea", $transport_mode);
|
|
|
+ $transport_mode = str_replace("Air Freight", "air", $transport_mode);
|
|
|
+ $mode_param = common::getInNotInSqlForSearch($transport_mode);
|
|
|
+ }
|
|
|
+ $sqlWhere .= " and transport_mode in ($mode_param)";
|
|
|
+ $transport_mode_search = " and transport_mode in ($mode_param)";
|
|
|
|
|
|
//查询tag
|
|
|
// IFFBCF Booking Confirmation Created
|
|
|
@@ -468,12 +490,15 @@ class ocean_order {
|
|
|
if(empty($filterTag_param)){
|
|
|
$filterTag_param = "1=1";
|
|
|
}
|
|
|
+ $tag_and_mode_param = $filterTag_param.$transport_mode_search;
|
|
|
|
|
|
$rc = $_POST ['rc'];
|
|
|
//这里都要查询,除非多传几个参数回来
|
|
|
if ($rc == - 1 || true) {
|
|
|
$sql = "select count(1) as rc,
|
|
|
- sum(case when $filterTag_param then 1 else 0 end) as seach_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 $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)
|
|
|
then 1 else 0 end)
|
|
|
as created,
|
|
|
@@ -485,7 +510,7 @@ class ocean_order {
|
|
|
sum(case when (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 online_ocean". $sqlWhere_befrom_filterTag;
|
|
|
+ from kln_ocean". $sqlWhere_befrom_filterTag;
|
|
|
error_log("online_ocean_search_All_Status: ".$sql);
|
|
|
|
|
|
$sql_all_status_data = common::excuteObjectSql($sql);
|
|
|
@@ -505,6 +530,8 @@ class ocean_order {
|
|
|
}
|
|
|
$rc = $sql_all_status_data['rc'];
|
|
|
$search_rc = $sql_all_status_data['seach_rc'];
|
|
|
+ $sea_rc = $sql_all_status_data['sea_rc'];
|
|
|
+ $air_rc = $sql_all_status_data['air_rc'];
|
|
|
$Created = $sql_all_status_data['created'];
|
|
|
$Cargo_Received = $sql_all_status_data['cargo_received'];
|
|
|
$Departed = $sql_all_status_data['departed'];
|
|
|
@@ -528,17 +555,22 @@ class ocean_order {
|
|
|
array("name"=>"Completed","number"=>intval($Completed),"type"=>"completed","checked"=>false));
|
|
|
}
|
|
|
|
|
|
- if (!isset($_POST["transport_mode"])){
|
|
|
- //代表初始
|
|
|
- $TransportList = array(
|
|
|
- array("name"=>"Ocean Freight","number"=>intval($rc),"checked"=>false,"icon"=>"#icon-icon_ocean_b"));
|
|
|
- }else{
|
|
|
- if (strtolower($_POST["transport_mode"]) == "all") {
|
|
|
- $TransportList = array(
|
|
|
- array("name"=>"Ocean Freight","number"=>intval($rc),"checked"=>true,"icon"=>"#icon-icon_ocean_b"));
|
|
|
- } else {
|
|
|
- $TransportList = array(
|
|
|
- array("name"=>"Ocean Freight","number"=>intval($rc),"checked"=>false,"icon"=>"#icon-icon_ocean_b"));
|
|
|
+ $TransportList = array(
|
|
|
+ array("name"=>"Ocean Freight","number"=>intval($sea_rc),"checked"=>false,"icon"=>"#icon-icon_ocean_b"),
|
|
|
+ array("name"=>"Air Freight","number"=>intval($air_rc),"checked"=>false,"icon"=>"#icon-icon_airplane_b"));
|
|
|
+
|
|
|
+ if (strtolower($_POST["transport_mode"]) == "all") {
|
|
|
+ foreach($TransportList as $tkey => $transport){
|
|
|
+ $TransportList[$tkey]["checked"] = true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $transport_mode_arr = explode(",", $_POST["transport_mode"]);
|
|
|
+ foreach($transport_mode_arr as $mode){
|
|
|
+ foreach($TransportList as $tkey => $transport){
|
|
|
+ if(trim($mode) == $TransportList[$tkey]["name"]){
|
|
|
+ $TransportList[$tkey]["checked"] = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -552,10 +584,10 @@ class ocean_order {
|
|
|
$order_by = " eta desc";
|
|
|
}
|
|
|
if ($rc > 0) {
|
|
|
- $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 ";
|
|
|
+ // $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 order_from as _schemas,serial_no as __serial_no, serial_no,
|
|
|
+ $sql = "with oo as (SELECT order_from as _schemas,serial_no as __serial_no, serial_no,transport_mode,
|
|
|
h_bol as _hbol, isf_bol as _isfbol, consignee_city as _consignee_city,
|
|
|
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) THEN 'Created'::text
|
|
|
@@ -565,11 +597,18 @@ class ocean_order {
|
|
|
WHEN (m_iffdel is not null) THEN 'Completed'::text
|
|
|
ELSE 'Created'
|
|
|
END AS new_status, ".
|
|
|
- column::getInstance()->getSearchSqlForDisplay('Ocean_Search') . " from public.online_ocean " . $sqlWhere .
|
|
|
+ column::getInstance()->getSearchSqlForDisplay('Ocean_Search') . " from public.kln_ocean " . $sqlWhere .
|
|
|
" order by $order_by limit " . $ps . " offset " . ($cp - 1) * $ps.")
|
|
|
- select oo.* ,aa.other_refenrence_no as \"Other refenrence No.\" from oo $ocean_ref_sql";
|
|
|
-
|
|
|
- $tmp_search_without_limit = "with oo as (SELECT order_from as _schemas,serial_no as __serial_no, serial_no,
|
|
|
+ select oo.* ,
|
|
|
+ case when oo.transport_mode ='sea'
|
|
|
+ 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 ='air'
|
|
|
+ then ''
|
|
|
+ else ''
|
|
|
+ end as \"Other refenrence No.\"
|
|
|
+ from oo";
|
|
|
+
|
|
|
+ $tmp_search_without_limit = "with oo as (SELECT order_from as _schemas,serial_no as __serial_no, serial_no,transport_mode,
|
|
|
h_bol as _hbol, isf_bol as _isfbol, consignee_city as _consignee_city,
|
|
|
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) THEN 'Created'::text
|
|
|
@@ -579,9 +618,16 @@ class ocean_order {
|
|
|
WHEN (m_iffdel is not null) THEN 'Completed'::text
|
|
|
ELSE 'Created'
|
|
|
END AS new_status, ".
|
|
|
- column::getInstance()->getSearchSqlForDisplay('Ocean_Search') . " from public.online_ocean " . $sqlWhere .
|
|
|
+ column::getInstance()->getSearchSqlForDisplay('Ocean_Search') . " from public.kln_ocean " . $sqlWhere .
|
|
|
" order by $order_by)
|
|
|
- select oo.* ,aa.other_refenrence_no as \"Other refenrence No.\" from oo $ocean_ref_sql";
|
|
|
+ select oo.* ,
|
|
|
+ case when oo.transport_mode ='sea'
|
|
|
+ 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 ='air'
|
|
|
+ then ''
|
|
|
+ else ''
|
|
|
+ end as \"Other refenrence No.\"
|
|
|
+ from oo";
|
|
|
|
|
|
$rs = common::excuteListSql($sql);
|
|
|
error_log("online_ocean_search_SQL: ".$sql);
|
|
|
@@ -590,7 +636,8 @@ class ocean_order {
|
|
|
foreach($rs as $index => $val) {
|
|
|
//返回加密serial_no
|
|
|
$rs[$index]["__serial_no"] = common::deCode($val['__serial_no'], 'E');
|
|
|
- $rs[$index]["mode"] = "Ocean Freight";
|
|
|
+ //$rs[$index]["mode"] = "Ocean Freight";
|
|
|
+ $rs[$index]["Transportation Mode"] = $val['transport_mode'] == 'sea' ? "Ocean Freight" : ($val['transport_mode'] == 'air' ? "Air Freight": "");
|
|
|
//status 改为ocean_milestone里的信息
|
|
|
$rs[$index]["Status"] = $rs[$index]["new_status"];
|
|
|
}
|
|
|
@@ -743,7 +790,7 @@ class ocean_order {
|
|
|
$packing = array("Quantity/Unit"=>$quantity_tolal,"G. Weight" => $g_weight_tolal." KGS","Ch. Weight" => $ch_weight_tolal." LBS","Volume" => $cbm_tolal." CBM");
|
|
|
|
|
|
//Milestones info 列名固定
|
|
|
- $Milestones = common::getMilestonesInfo($ocean,$vueData['EDI315TimeAndLocation']);
|
|
|
+ $Milestones = common::getMilestonesInfo($ocean,"sea",$_schemas,$vueData['EDI315TimeAndLocation']);
|
|
|
|
|
|
//页面固定写死的信息
|
|
|
$document_column = array();
|
|
|
@@ -841,6 +888,7 @@ class ocean_order {
|
|
|
'email' => $email,
|
|
|
'ams_ss' => md5(md5($ocean['serial_no'])),
|
|
|
'isf_ss' => $isf_ss,
|
|
|
+ 'transport_mode' =>"sea",
|
|
|
'_schemas' =>$_schemas,
|
|
|
'uncode' =>$uncode,
|
|
|
'serial_no' =>$serial_no,
|
|
|
@@ -853,6 +901,159 @@ class ocean_order {
|
|
|
exit();
|
|
|
}
|
|
|
|
|
|
+ private function _air_ocean_detail(){
|
|
|
+ $serial_no = common::deCode($_GET['a'], 'D');
|
|
|
+ $sql = $this->getAirDetail($serial_no);
|
|
|
+ $air = common::excuteObjectSql($sql);
|
|
|
+
|
|
|
+ //根据air_milestone 判断 shipment status的state
|
|
|
+ $_schemas = $_REQUEST["_schemas"];
|
|
|
+ $air_milestone_status = common::excuteListSql("select code,
|
|
|
+ act_date,est_date,timezone
|
|
|
+ from ocean_milestone a
|
|
|
+ where a.serial_no='$serial_no' and code in('IFFCPU','IFFREC','IFFONB','IFFARR','IFFDEL')
|
|
|
+ order by id");
|
|
|
+ $state = -1;
|
|
|
+ if (!empty($air_milestone_status)) {
|
|
|
+ $state_arr = array();
|
|
|
+ foreach($air_milestone_status as $ms){
|
|
|
+ if($ms['code'] == "IFFCPU"){
|
|
|
+ $state_arr[] = 0;
|
|
|
+ }
|
|
|
+ if($ms['code'] == "IFFREC" || $ms['code'] == "IFFONB"){
|
|
|
+ $state_arr[] = 1;
|
|
|
+ }
|
|
|
+ if($ms['code'] == "IFFARR"){
|
|
|
+ $state_arr[] = 2;
|
|
|
+ }
|
|
|
+ if($ms['code'] == "IFFDEL"){
|
|
|
+ $state_arr[] = 3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $state = max($state_arr);
|
|
|
+ }
|
|
|
+ $vueData = $this->returnAirDetailData($air,$air_milestone_status,$state);
|
|
|
+
|
|
|
+ //处理shipment data暂时写死
|
|
|
+ $simplexData = $vueData['shipmentData'];
|
|
|
+ //处理transportInfo信息数据
|
|
|
+ $transportInfo = $vueData['transportInfo'];
|
|
|
+ //处理basicInfo信息数据
|
|
|
+ $basicInfo = $vueData['basicInfo'];
|
|
|
+ //处理 拼接地址 ocean表单exp 字段无法精准分割电话和地址信息,只能从contacts表里查询
|
|
|
+ $businessPartners = $vueData['businessPartners'];
|
|
|
+ //处理routes 转船可能有多个情况
|
|
|
+ $routes = $vueData['routes'];
|
|
|
+ //处理marksAndDescription
|
|
|
+ $marksAndDescription = $vueData['marksAndDescription'];
|
|
|
+
|
|
|
+ $quantity_tolal = empty($air['qty']) ? "" : $air['qty'].$air['qty_uom'];
|
|
|
+ $g_weight_tolal = empty($air['piece_count']) ? "" : sprintf("%.3f", $air['piece_count'])." KGS";
|
|
|
+ $ch_weight_tolal = empty($air['piece_count']) ? "": sprintf("%.3f", $air['weight'])." KGS";
|
|
|
+ $cbm_tolal = empty($air['cbm']) ? "" : sprintf("%.4f", $air['cbm'])." CBM";
|
|
|
+ //Packing信息
|
|
|
+ $packing = array("Quantity/Unit"=>$quantity_tolal,"G. Weight" => $g_weight_tolal,"Ch. Weight" => $ch_weight_tolal,"Volume" => $cbm_tolal);
|
|
|
+
|
|
|
+ //Milestones info 列名固定
|
|
|
+ $Milestones = common::getMilestonesInfo($air,"air",$_schemas);
|
|
|
+
|
|
|
+ //页面固定写死的信息
|
|
|
+ $document_column = array();
|
|
|
+ $document_column[] = array("title" =>"File Type","field" =>"file_type","formatter" =>"","type" =>"normal");
|
|
|
+ $document_column[] = array("title" =>"File","field" =>"file","formatter" =>"","type" =>"normal");
|
|
|
+
|
|
|
+ $document_data = array();
|
|
|
+
|
|
|
+ $document = _getAirViewDocType($_REQUEST["_schemas"]);
|
|
|
+ $air_can_view_file = common::excuteOneSql("select air_can_view_file from ra_online_user where lower(user_login)='".strtolower($_SESSION['ONLINE_USER']['user_login'])."'");
|
|
|
+ if (!empty($document)) {
|
|
|
+ foreach ($document as $v) {
|
|
|
+ $file_type = $v['display_name'];
|
|
|
+ $file_arr = $this->getFileByHbol($air['_m_bol'], $air['_h_bol'], $v['serial_no'], $v['m_h'], $v['display_name'], TRUE);
|
|
|
+
|
|
|
+ $tar = json_decode($air_can_view_file,true);
|
|
|
+ if(!empty($tar[$v['display_name']])){
|
|
|
+ foreach ($tar[$v['display_name']] as $dkey => $dvalue) {
|
|
|
+ switch ($v['display_name']) {
|
|
|
+ case 'HBL':
|
|
|
+ $sql = "SELECT file_path, file_name, upload_by, to_char(upload_date, 'MM/DD/YYYY') as upload_date
|
|
|
+ from air_doc_upload
|
|
|
+ where lower(bol) = lower('".$air['_h_bol']."') and lower(format_serailno) in ('".strtolower(str_replace(";","','",$dvalue['value']))."') and upper((string_to_array((string_to_array(file_name,'.'))[1], '_'))[2]) = '".$dvalue['type']."'
|
|
|
+ order by id desc";
|
|
|
+ break;
|
|
|
+ case 'MBL':
|
|
|
+ $sql = "SELECT file_path, file_name, upload_by, to_char(upload_date, 'MM/DD/YYYY') as upload_date
|
|
|
+ from air_doc_upload
|
|
|
+ where lower(bol) = lower('".strtolower($air['_m_bol'])."') and lower(format_serailno) in ('".strtolower(str_replace(";","','",$dvalue['value']))."') and upper((string_to_array((string_to_array(file_name,'.'))[1], '_'))[2]) = '".$dvalue['type']."'
|
|
|
+ order by id desc";
|
|
|
+ break;
|
|
|
+ case 'Others':
|
|
|
+ $sql = "SELECT file_path, file_name, upload_by, to_char(upload_date, 'MM/DD/YYYY') as upload_date
|
|
|
+ from air_doc_upload
|
|
|
+ where (lower(bol) = lower('".strtolower($air['_h_bol'])."') or lower(bol) = lower('".strtolower($air['_m_bol'])."')) and lower(format_serailno) in ('".strtolower(str_replace(";","','",$dvalue['value']))."') and upper((string_to_array((string_to_array(file_name,'.'))[1], '_'))[2]) = '".$dvalue['type']."'
|
|
|
+ order by id desc";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $sql = "";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (!empty($sql)) {
|
|
|
+ $rss = common::excuteListSql($sql);
|
|
|
+ foreach ($rss as $rs) {
|
|
|
+ $file_arr[] = array("url"=>"main_new_version.php?action=ocean_order&operate=download&url=". (common::deCode($rs['file_path'] . DS . $rs['file_name'], 'E')),
|
|
|
+ "file_name" => $rs['file_name'],
|
|
|
+ "detail"=>$rs['upload_date'],
|
|
|
+ "can_delete"=>_getLoginName() == $rs['upload_by'],
|
|
|
+ "from_system" =>'');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //$document_data[] = array("file_type"=>$file_type,"file"=>$file_arr);
|
|
|
+ //按现在的逻辑,有值才会显示
|
|
|
+ foreach($file_arr as $f){
|
|
|
+ $document_data[] = array("file_type"=>$file_type,"file"=>$f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $document_info = array("document_column"=>$document_column,"document_data" =>$document_data);
|
|
|
+
|
|
|
+ $emailRecords = $this->getCommunicationNew($air["serial_no"]);
|
|
|
+ $cc_email = common::excuteOneSql("select cc_email from public.online_ocean_communication where email_uuid='" . $air["serial_no"] . "' order by id desc limit 1");
|
|
|
+ $email = $this->getEmail($air["serial_no"]);
|
|
|
+ $email['cc_email'] = $cc_email;
|
|
|
+ $email['emailRecords'] = $emailRecords;
|
|
|
+
|
|
|
+ global $_COPYRIGHT;
|
|
|
+ $data = array('transportInfo' => $transportInfo,
|
|
|
+ 'basicInfo' => $basicInfo,
|
|
|
+ 'businessPartners' => $businessPartners,
|
|
|
+ 'ref_no' => array(),
|
|
|
+ 'packing' => $packing,
|
|
|
+ 'marksAndDescription' => $marksAndDescription,
|
|
|
+ 'containers' => array(),
|
|
|
+ 'simplexData' =>$simplexData,
|
|
|
+ 'containerStatusData' => array(),
|
|
|
+ 'document_info' => $document_info,
|
|
|
+ 'containers' => array(),
|
|
|
+ 'Milestones' => $Milestones,
|
|
|
+ 'routes' => $routes,
|
|
|
+ 'email' => $email,
|
|
|
+ 'ams_ss' =>"",
|
|
|
+ 'isf_ss' => "",
|
|
|
+ '_schemas' =>$_schemas,
|
|
|
+ 'uncode' =>"",
|
|
|
+ 'transport_mode' =>"air",
|
|
|
+ 'serial_no' =>$serial_no,
|
|
|
+ 'can_upload_doc' => strtolower($_SESSION['ONLINE_USER']['can_upload_doc']) == 't' || strtolower($_SESSION['ONLINE_USER']['can_view_doc']) == 't',
|
|
|
+ 'canEdiVgm' => _canEdiVgm(),
|
|
|
+ 'canViewAMSLog'=>_canViewAMSLog(),
|
|
|
+ 'canViewISFLog'=>_canViewISFLog(),
|
|
|
+ 'copyright' =>$_COPYRIGHT);
|
|
|
+ common::echo_json_encode(200,$data);
|
|
|
+ exit();
|
|
|
+ }
|
|
|
+
|
|
|
private function _ocean_excel() {
|
|
|
$sql = common::deCode($_POST ['tmp_search'], 'D');
|
|
|
//$sql = substr($sql, 0, strripos($sql, " limit"));
|
|
|
@@ -871,7 +1072,8 @@ class ocean_order {
|
|
|
foreach($rs as $index => $val) {
|
|
|
//返回加密serial_no
|
|
|
$rs[$index]["__serial_no"] = common::deCode($val['__serial_no'], 'E');
|
|
|
- $rs[$index]["mode"] = "Ocean Freight";
|
|
|
+ //$rs[$index]["mode"] = "Ocean Freight";
|
|
|
+ $rs[$index]["Transportation Mode"] = $val['transport_mode'] == 'sea' ? "Ocean Freight" : ($val['transport_mode'] == 'air' ? "Air Freight": "");
|
|
|
//status 改为ocean_milestone里的信息
|
|
|
$rs[$index]["Status"] = $rs[$index]["new_status"];
|
|
|
}
|
|
|
@@ -1277,6 +1479,79 @@ class ocean_order {
|
|
|
return $sql;
|
|
|
}
|
|
|
|
|
|
+ private function getAirDetail($serial_no) {
|
|
|
+ $order_from = $_REQUEST['_schemas'];
|
|
|
+ $_schemas = $_REQUEST['_schemas'];
|
|
|
+ if($_schemas == 'public'){
|
|
|
+ $_schemas = "ocean";
|
|
|
+ }
|
|
|
+ $sql = "with o as(
|
|
|
+ SELECT oo.*,m_bol as _m_bol, h_bol as _h_bol,
|
|
|
+ (select time_zone from public.city_timezone where uncode = oo.fport_of_loading_un limit 1) as pol_timezone,
|
|
|
+ (select uncity from public.ports where uncode = oo.fport_of_loading_un limit 1) as pol_uncity,
|
|
|
+ (select time_zone from public.city_timezone where uncode = oo.mport_of_discharge_un limit 1) as mpod_timezone,
|
|
|
+ (select uncity from public.ports where uncode = oo.mport_of_discharge_un limit 1) as mpod_uncity,
|
|
|
+ (select time_zone from public.city_timezone where uncode = oo.place_of_receipt_un limit 1) as por_timezone,
|
|
|
+ (select uncity from public.ports where uncode = oo.place_of_receipt_un limit 1) as por_uncity,
|
|
|
+ (select time_zone from public.city_timezone where uncode = oo.place_of_delivery_un limit 1) as pod_timezone,
|
|
|
+ (select uncity from public.ports where uncode = oo.place_of_delivery_un limit 1) as pod_uncity,
|
|
|
+ (select time_zone from public.city_timezone where uncode = oo.final_desination_uncode limit 1) as _fd_timezone,
|
|
|
+ (select uncity from public.ports where uncode = oo.final_desination_uncode limit 1) as _pd_uncity,
|
|
|
+ CASE
|
|
|
+ WHEN ((m_iffbcf is not null or m_iffbcf is null) and m_iffcpu is null and m_iffrec is null and m_iffdep is null and m_iffarr is null and m_iffdel is null) THEN 'Created'::text
|
|
|
+ WHEN ((m_iffcpu is not null or m_iffrec is not null) and m_iffdep is null and m_iffarr is null and m_iffdel is null) THEN 'Cargo Received'::text
|
|
|
+ WHEN (m_iffdep is not null and m_iffarr is null and m_iffdel is null) THEN 'Departure'::text
|
|
|
+ WHEN (m_iffarr is not null and m_iffdel is null) THEN 'Arrived'::text
|
|
|
+ WHEN (m_iffdel is not null) THEN 'Completed'::text
|
|
|
+ ELSE 'Created'::text
|
|
|
+ END AS new_status
|
|
|
+ from public.kln_ocean oo where oo.serial_no = '" . $serial_no . "' and oo.order_from = '$order_from'
|
|
|
+ )
|
|
|
+ SELECT o.* ,sh.*, cn.*,
|
|
|
+ aa.*,dd.*,fd.*
|
|
|
+ from o
|
|
|
+ LEFT JOIN LATERAL ( SELECT company as cn_company,
|
|
|
+ address_1 as cn_address_1,
|
|
|
+ address_2 as cn_address_2,
|
|
|
+ address_3 as cn_address_3,
|
|
|
+ address_4 as cn_address_4,
|
|
|
+ city as cn_city, state as cn_state, zipcode as cn_zipcode, country as cn_country,
|
|
|
+ phone_1 as cn_phone
|
|
|
+ FROM $_schemas.contacts c WHERE o.consignee_id::text = c.contact_id::text) cn ON true
|
|
|
+ LEFT JOIN LATERAL ( SELECT company as sh_company,
|
|
|
+ address_1 as sh_address_1,
|
|
|
+ address_2 as sh_address_2,
|
|
|
+ address_3 as sh_address_3,
|
|
|
+ address_4 as sh_address_4,
|
|
|
+ city as sh_city, state as sh_state, zipcode as sh_zipcode, country as sh_country,
|
|
|
+ phone_1 as sh_phone
|
|
|
+ FROM $_schemas.contacts c WHERE o.shipper_id::text = c.contact_id::text) sh ON true
|
|
|
+ LEFT JOIN LATERAL ( SELECT company as aa_company,
|
|
|
+ address_1 as aa_address_1,
|
|
|
+ address_2 as aa_address_2,
|
|
|
+ address_3 as aa_address_3,
|
|
|
+ address_4 as aa_address_4,
|
|
|
+ city as aa_city, state as aa_state, zipcode as aa_zipcode, country as aa_country,
|
|
|
+ phone_1 as aa_phone,
|
|
|
+ (select time_zone from public.city_timezone where uncode = LEFT(c.country, 2) || COALESCE(c.city_code,'') limit 1) as aa_timezone
|
|
|
+ FROM $_schemas.contacts c WHERE o.origin::text = c.contact_id::text) aa ON true
|
|
|
+ LEFT JOIN LATERAL ( SELECT company as dd_company,
|
|
|
+ address_1 as dd_address_1,
|
|
|
+ address_2 as dd_address_2,
|
|
|
+ address_3 as dd_address_3,
|
|
|
+ address_4 as dd_address_4,
|
|
|
+ city as dd_city, state as dd_state, zipcode as dd_zipcode, country as dd_country,
|
|
|
+ phone_1 as dd_phone,
|
|
|
+ (select time_zone from public.city_timezone where uncode = LEFT(c.country, 2) || COALESCE(c.city_code,'') limit 1) as dd_timezone
|
|
|
+ FROM $_schemas.contacts c WHERE o.agent::text = c.contact_id::text) dd ON true
|
|
|
+ LEFT JOIN LATERAL ( SELECT
|
|
|
+ city as fd_city,
|
|
|
+ (select time_zone from public.city_timezone where uncode = LEFT(c.country, 2) || COALESCE(c.city_code,'') limit 1) as fd_timezone
|
|
|
+ FROM $_schemas.contacts c WHERE o.final_desination::text = c.contact_id::text) fd ON true";
|
|
|
+ //error_log($sql);
|
|
|
+ return $sql;
|
|
|
+ }
|
|
|
+
|
|
|
private function returnOceanDetailData($ocean,$state){
|
|
|
$data = array();
|
|
|
//由于这些基础数据还待完善,而且现在提单样式改版也没有显示客户自身的地址数据,所以我们这边的这个取值也要麻烦调整一下:
|
|
|
@@ -1392,7 +1667,7 @@ class ocean_order {
|
|
|
$simplexData[] = $place_of_Delivery_status;
|
|
|
$data['shipmentData'] = $simplexData;
|
|
|
|
|
|
- //处理transportInfo信息数据
|
|
|
+ //处理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",
|
|
|
"origin" =>$ocean['shippr_uncode'],"destination" =>$ocean['consignee_uncode'],
|
|
|
"etd" =>$ocean['f_etd'],"atd" =>$ocean['atd'],
|
|
|
@@ -1451,10 +1726,148 @@ class ocean_order {
|
|
|
$data['routes'] = $routes;
|
|
|
|
|
|
//处理marksAndDescription
|
|
|
- $marksAndDescription = array("marks"=>$ocean['marks'],"description"=>$ocean['description']);
|
|
|
+ $marksAndDescription = array("marks"=>$ocean['marks'],"description"=>$ocean['description'],"remark"=>$ocean['remark']);
|
|
|
$data['marksAndDescription'] = $marksAndDescription;
|
|
|
|
|
|
return $data;
|
|
|
}
|
|
|
+
|
|
|
+ private function returnAirDetailData($ocean,$ocean_milestone_status,$state){
|
|
|
+ $data = array();
|
|
|
+ //由于这些基础数据还待完善,而且现在提单样式改版也没有显示客户自身的地址数据,所以我们这边的这个取值也要麻烦调整一下:
|
|
|
+ //1.Shipment detail顶部的Origin和Destination的取值换成Place of Receipt、Place of Delivery的UNCODE
|
|
|
+ //2.Tracking列表页里面字段Origin和Destination先隐藏(客户地址),不做展示
|
|
|
+ $ocean['shippr_uncode'] = $ocean['place_of_receipt_un'];
|
|
|
+ $ocean['consignee_uncode'] = $ocean['place_of_delivery_un'];
|
|
|
+
|
|
|
+ //处理shipment data
|
|
|
+ $ocean_milestone_status_code = array();
|
|
|
+ foreach($ocean_milestone_status as $oms){
|
|
|
+ $ocean_milestone_status_code[$oms['code']] = $oms;
|
|
|
+ }
|
|
|
+ if ($state < 1){
|
|
|
+ //未发生前
|
|
|
+ if(!empty($ocean_milestone_status_code['IFFONB']['est_date'])){
|
|
|
+ //如果milestone有值,或者与milestone不等,以milestone的优先度最高
|
|
|
+ $ocean['etd'] = $ocean_milestone_status_code['IFFONB']['est_date'];
|
|
|
+ }
|
|
|
+ } else{
|
|
|
+ if(!empty($ocean_milestone_status_code['IFFONB']['act_date'])){
|
|
|
+ //如果milestone有值,或者与milestone不等,以milestone的优先度最高
|
|
|
+ //ATD 取值为IFFONB milestone实际发生的时间
|
|
|
+ $ocean['atd'] = $ocean_milestone_status_code['IFFONB']['act_date'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $simplexData = array();
|
|
|
+ //place_of_Receipt
|
|
|
+ $place_of_Receipt_stauts = array("index" =>1,"label" =>"Place of Receipt",
|
|
|
+ "path" =>$ocean['place_of_receipt_exp']."/".$ocean['place_of_receipt_un'],"isArrival" =>$state >= 0 ? true : false);
|
|
|
+ $children = array();
|
|
|
+ if($state >= 1 && !empty($ocean_milestone_status_code['IFFCPU']['act_date'])){
|
|
|
+ //发生后,未发生前没有
|
|
|
+ $children[] = array("label" =>"Cargo Received","date" =>$ocean_milestone_status_code['IFFCPU']['act_date']);
|
|
|
+ }
|
|
|
+ $place_of_Receipt_stauts["children"] = $children;
|
|
|
+ $simplexData[] = $place_of_Receipt_stauts;
|
|
|
+
|
|
|
+ //port_of_Loading
|
|
|
+ $port_of_Loading_stauts = array("index" =>2,"label" =>"Port of Loading",
|
|
|
+ "path" =>$ocean['fport_of_loading_exp']."/".$ocean['fport_of_loading_un'],"isArrival" =>$state >= 1 ? true : false);
|
|
|
+ $children = array();
|
|
|
+ if ($state < 1){
|
|
|
+ $children[] = array("label" =>"Departure(ETD)","date" =>$ocean['etd']);
|
|
|
+ } else{
|
|
|
+ if(!empty($ocean_milestone_status_code['IFFREC']['act_date'])){
|
|
|
+ $children[] = array("label" =>"Cargo Received","date" =>$ocean_milestone_status_code['IFFREC']['act_date']);
|
|
|
+ }
|
|
|
+ if(!empty($ocean_milestone_status_code['IFFONB']['act_date'])){
|
|
|
+ $children[] = array("label" =>"Departure(ATD)","date" =>$ocean_milestone_status_code['IFFONB']['act_date']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $port_of_Loading_stauts["children"] = $children;
|
|
|
+ $simplexData[] = $port_of_Loading_stauts;
|
|
|
+
|
|
|
+ //Port of Discharge
|
|
|
+ $port_of_Discharge_status = array("index" =>3,"label" =>"Port of Discharge",
|
|
|
+ "path" =>$ocean['mport_of_discharge_exp']."/".$ocean['mport_of_discharge_un'],"isArrival" =>$state >= 2 ? true : false);
|
|
|
+ $children = array();
|
|
|
+ if ($state < 2){
|
|
|
+ $children[] = array("label" =>"Arrival(ETA)","date" =>$ocean['eta']);
|
|
|
+ }else{
|
|
|
+ if(!empty($ocean_milestone_status_code['IFFARR']['act_date'])){
|
|
|
+ $children[] = array("label" =>"Arrival(ATA)","date" =>$ocean_milestone_status_code['IFFARR']['act_date']);
|
|
|
+ $ocean['ata'] = $ocean_milestone_status_code['IFFARR']['act_date'];
|
|
|
+ }else{
|
|
|
+ //IFFARR 如果同步异常没有值时,去表里的 ata_date AS ata
|
|
|
+ $children[] = array("label" =>"Arrival(ATA)","date" =>$ocean['ata']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $port_of_Discharge_status["children"] = $children;
|
|
|
+ $simplexData[] = $port_of_Discharge_status;
|
|
|
+
|
|
|
+ //Place of Delivery
|
|
|
+ $place_of_Delivery_status = array("index" =>4,"label" =>"Place of Delivery",
|
|
|
+ "path" =>$ocean['place_of_delivery_exp']."/".$ocean['place_of_delivery_un'],"isArrival" =>$state == 3 ? true : false);
|
|
|
+ $children = array();
|
|
|
+ if ($state < 3){
|
|
|
+ //未发生前
|
|
|
+ } else{
|
|
|
+ if(!empty($ocean_milestone_status_code['IFFDEL']['act_date'])){
|
|
|
+ $children[] = array("label" =>"Cargo handover/Delivered","date" =>$ocean_milestone_status_code['IFFDEL']['act_date']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $simplexData[] = $place_of_Delivery_status;
|
|
|
+ $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",
|
|
|
+ "origin" =>$ocean['shippr_uncode'],"destination" =>$ocean['consignee_uncode'],
|
|
|
+ "etd" =>$ocean['etd'],"atd" =>$ocean['atd'],
|
|
|
+ "etd_timezone" =>$ocean['pol_timezone'],
|
|
|
+ "atd_timezone" =>$ocean['pol_timezone'],
|
|
|
+ "eta" =>$ocean['eta'],"ata" =>$ocean['ata'],
|
|
|
+ "eta_timezone" =>$ocean['mpod_timezone'],
|
|
|
+ "ata_timezone" =>$ocean['mpod_timezone']);
|
|
|
+ $data['transportInfo'] = $transportInfo;
|
|
|
+
|
|
|
+ //处理basicInfo信息数据
|
|
|
+ $vessel = $ocean['vessel'];
|
|
|
+ $voyage = $ocean['voyage'];
|
|
|
+ $basicInfo = array("MAWB/MBL No." =>$ocean['m_bol'],"HAWB/HBOL" => $ocean['h_bol'],"Carrier_Booking_No" =>$ocean['booking_no'],
|
|
|
+ "PO_NO" =>$ocean['po_no'],"Vessel/Airline" =>$vessel,"Voyage/Filght" =>$voyage,
|
|
|
+ "Incoterm" =>$ocean['incoterms'],"Service_Type" =>$ocean['service']);
|
|
|
+ $data['basicInfo'] = $basicInfo;
|
|
|
+
|
|
|
+ //处理 拼接地址 ocean表单exp 字段无法精准分割电话和地址信息,只能从contacts表里查询
|
|
|
+ $shipper_address = common::retStationInfo($ocean['sh_address_1'], $ocean['sh_address_2'], $ocean['sh_address_3'], $ocean['sh_address_4'],
|
|
|
+ $ocean['sh_city'], $ocean['sh_state'], $ocean['sh_zipcode'], $ocean['sh_country']);
|
|
|
+ $consignee_address = common::retStationInfo($ocean['cn_address_1'], $ocean['cn_address_2'], $ocean['cn_address_3'], $ocean['cn_address_4'],
|
|
|
+ $ocean['cn_city'], $ocean['cn_state'], $ocean['cn_zipcode'], $ocean['cn_country']);
|
|
|
+ $origin_address = common::retStationInfo($ocean['aa_address_1'], $ocean['aa_address_2'], $ocean['aa_address_3'], $ocean['aa_address_4'],
|
|
|
+ $ocean['aa_city'], $ocean['aa_state'], $ocean['aa_zipcode'], $ocean['aa_country']);
|
|
|
+ $destination_address = common::retStationInfo($ocean['dd_address_1'], $ocean['dd_address_2'], $ocean['dd_address_3'], $ocean['dd_address_4'],
|
|
|
+ $ocean['dd_city'], $ocean['dd_state'], $ocean['dd_zipcode'], $ocean['dd_country']);
|
|
|
+
|
|
|
+ $shipperPartners = array("company" =>$ocean['sh_company'],"address"=>$shipper_address,"phone"=>$ocean['sh_phone']);
|
|
|
+ $consigneePartners = array("company" =>$ocean['cn_company'],"address"=>$consignee_address,"phone"=>$ocean['cn_phone']);
|
|
|
+ $originPartners = array("company" =>$ocean['aa_company'],"address"=>$origin_address,"phone"=>$ocean['aa_phone']);
|
|
|
+ $destinationPartners = array("company" =>$ocean['dd_company'],"address"=>$destination_address,"phone"=>$ocean['dd_phone']);
|
|
|
+ $businessPartners = array("shipper"=>$shipperPartners,"consignee" => $consigneePartners,"origin" => $originPartners,"destination" => $destinationPartners);
|
|
|
+ $data['businessPartners'] = $businessPartners;
|
|
|
+
|
|
|
+ //处理routes air不存在中转的
|
|
|
+ $routes = array(array("mode" =>"Air Freight","mode_label" =>"Air", "origin" =>$ocean['shippr_uncode'],
|
|
|
+ "destination" => $ocean['consignee_uncode'],
|
|
|
+ "etd" => $ocean['etd'],"atd" => $ocean['atd'],
|
|
|
+ "eta" => $ocean['eta'],"ata" => $ocean['ata'],
|
|
|
+ "vessel" =>$ocean['vessel'],"voyageNo" =>$ocean['voyage']));
|
|
|
+ $data['routes'] = $routes;
|
|
|
+
|
|
|
+ //处理marksAndDescription
|
|
|
+ $marksAndDescription = array("marks"=>$ocean['marks'],"description"=>$ocean['description'],"remark"=>$ocean['remark']);
|
|
|
+ $data['marksAndDescription'] = $marksAndDescription;
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
}
|
|
|
?>
|