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