|
|
@@ -166,10 +166,11 @@ class ajax {
|
|
|
$tp = ceil($rc / $ps);
|
|
|
if ($rc > 0) {
|
|
|
$sql = $_sql_arr['sql'];
|
|
|
- $sql = "select * from ($sql) as temp ";
|
|
|
- $sql .= " order by city limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
|
+ $sql = "select DISTINCT ON (city) country, city,uncode from ($sql) as temp ";
|
|
|
+ $sql .= " limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
|
|
|
|
$rs = common::excuteListSql($sql);
|
|
|
+ error_log($sql);
|
|
|
//前端要加上id 从1开始
|
|
|
$retData = array();
|
|
|
$i = 0;
|
|
|
@@ -476,11 +477,11 @@ class ajax {
|
|
|
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
|
|
|
+ $sql = "select 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) . "%') ";
|
|
|
+ or shippr_uncode ilike '%" . common::check_input($term) . "%') order by f_etd desc NULLS LAST";
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
@@ -492,11 +493,11 @@ class ajax {
|
|
|
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
|
|
|
+ $sql = "select 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) . "%')";
|
|
|
+ or consignee_uncode ilike '%" . common::check_input($term) . "%') order by f_etd desc NULLS LAST";
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
@@ -508,11 +509,11 @@ class ajax {
|
|
|
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
|
|
|
+ $sql = "select 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) . "%')";
|
|
|
+ or place_of_receipt_uncode ilike '%" . common::check_input($term) . "%') order by f_etd desc NULLS LAST";
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
@@ -524,11 +525,11 @@ class ajax {
|
|
|
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
|
|
|
+ $sql = "select 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) . "%')";
|
|
|
+ or fport_of_loading_uncode ilike '%" . common::check_input($term) . "%') order by f_etd desc NULLS LAST";
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
@@ -540,16 +541,20 @@ class ajax {
|
|
|
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
|
|
|
+ $sql = "select 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) . "%')";
|
|
|
+ or place_of_delivery_uncode ilike '%" . common::check_input($term) . "%') order by f_etd desc NULLS LAST";
|
|
|
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
//tracking
|
|
|
+ $order_by = " etd desc NULLS LAST";
|
|
|
+ if (_isCustomerLogin()) {
|
|
|
+ $order_by = " eta desc NULLS LAST";
|
|
|
+ }
|
|
|
if($search_field == "Origin" && $search_mode == "tracking"){
|
|
|
$sqlWhere = $this->getTrackingSearchWhere();
|
|
|
|
|
|
@@ -565,17 +570,17 @@ class ajax {
|
|
|
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
|
|
|
+ $sql = "select country, city,uncode from(select left(shippr_uncode, 2) as country,shipper_city as city, shippr_uncode as uncode,etd,eta
|
|
|
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) . "%')
|
|
|
union
|
|
|
- select DISTINCT ON (consignee_city) left(consignee_uncode, 2) as country,consignee_city as city, consignee_uncode as uncode
|
|
|
+ select left(consignee_uncode, 2) as country,consignee_city as city, consignee_uncode as uncode,etd,eta
|
|
|
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";
|
|
|
+ or consignee_uncode ilike '%" . common::check_input($term) . "%')) as temp order by $order_by";
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
@@ -587,11 +592,11 @@ class ajax {
|
|
|
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
|
|
|
+ $sql = "select 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) . "%')";
|
|
|
+ or final_desination_uncode ilike '%" . common::check_input($term) . "%') order by $order_by";
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
@@ -603,11 +608,11 @@ class ajax {
|
|
|
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
|
|
|
+ $sql = "select 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) . "%')";
|
|
|
+ or place_of_receipt_un ilike '%" . common::check_input($term) . "%') order by $order_by";
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
@@ -619,11 +624,11 @@ class ajax {
|
|
|
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
|
|
|
+ $sql = "select 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) . "%')";
|
|
|
+ or fport_of_loading_un ilike '%" . common::check_input($term) . "%') order by $order_by";
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
@@ -635,11 +640,11 @@ class ajax {
|
|
|
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
|
|
|
+ $sql = "select 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) . "%')";
|
|
|
+ or mport_of_discharge_un ilike '%" . common::check_input($term) . "%') order by $order_by";
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
@@ -651,11 +656,11 @@ class ajax {
|
|
|
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
|
|
|
+ $sql = "select 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) . "%')";
|
|
|
+ or place_of_delivery_un ilike '%" . common::check_input($term) . "%') order by $order_by";
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
}
|