|
|
@@ -64,6 +64,9 @@ class ajax {
|
|
|
|
|
|
//不查询全局的信息,查询该用户,最近3个月内输入过的信息自动补全
|
|
|
public function autody(){
|
|
|
+ //分担查询
|
|
|
+ include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
|
|
|
+
|
|
|
$term = $_POST['term'];
|
|
|
$type = $_POST['type'];
|
|
|
$search_field = $_POST['search_field'];
|
|
|
@@ -91,6 +94,19 @@ class ajax {
|
|
|
"Vessel_booking"=>"f_vessel as code,m_vessel as code_2",
|
|
|
"Voyage/Flight_tracking"=>"voyage as code,f_voyage as code_2",
|
|
|
"Vessel_tracking"=>"vessel as code,f_vessel as code_2");
|
|
|
+
|
|
|
+ $search_field_group_mapping = array("Origin Agent"=>"group by origin",
|
|
|
+ "Destination Agent"=>"group by agent",
|
|
|
+ "Shipper Name"=>"group by shipper",
|
|
|
+ "Consignee Name"=>"group by consignee",
|
|
|
+ "Notify Party" =>"group by notify_party",
|
|
|
+ "Bill to" =>"group by billto",
|
|
|
+ "Destination Operator"=>"group by dest_op",
|
|
|
+ "Sales"=>"group by sales_rep",
|
|
|
+ "Voyage/Flight_booking"=>"group by f_voyage,m_voyage",
|
|
|
+ "Vessel_booking"=>"group by f_vessel,m_vessel",
|
|
|
+ "Voyage/Flight_tracking"=>"group by voyage,f_voyage",
|
|
|
+ "Vessel_tracking"=>"group by vessel,f_vessel");
|
|
|
|
|
|
$sql_where_mapping = array("Origin Agent"=>" and (origin ilike '%" . common::check_input($term) . "%')",
|
|
|
"Destination Agent"=>" and (agent ilike '%" . common::check_input($term) . "%')",
|
|
|
@@ -113,24 +129,39 @@ class ajax {
|
|
|
}
|
|
|
$str = $search_field_mapping[$_search_field];
|
|
|
$sql_where = $sql_where_mapping[$_search_field];
|
|
|
+ $group_by = $search_field_group_mapping[$_search_field];
|
|
|
|
|
|
$table = $search_mode == "tracking" ? "public.kln_ocean " : "public.kln_booking ";
|
|
|
|
|
|
+ // if($search_mode == "booking"){
|
|
|
+ // $order_by = " f_etd desc";
|
|
|
+ // }else{
|
|
|
+ // $order_by = " etd desc";
|
|
|
+ // if (_isCustomerLogin()) {
|
|
|
+ // $order_by = " eta desc";
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ //$sql = "select DISTINCT * from (select $str from $table $sqlWhere $sql_where order by $order_by ) as temp";
|
|
|
+ //$sql .= " order by code limit 20";
|
|
|
+
|
|
|
if($search_mode == "booking"){
|
|
|
- $order_by = " f_etd desc NULLS LAST";
|
|
|
+ $order_by = " max(f_etd) desc";
|
|
|
}else{
|
|
|
- $order_by = " etd desc NULLS LAST";
|
|
|
+ $order_by = " max(etd) desc";
|
|
|
if (_isCustomerLogin()) {
|
|
|
- $order_by = " eta desc NULLS LAST";
|
|
|
+ $order_by = " max(eta) desc";
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- $sql = "select DISTINCT * from (select $str from $table $sqlWhere $sql_where order by $order_by ) as temp";
|
|
|
- $sql .= " order by code limit 20";
|
|
|
+
|
|
|
+ $sql = "select $str from $table $sqlWhere $sql_where $group_by order by $order_by";
|
|
|
+ $sql .= " limit 20";
|
|
|
+ }
|
|
|
+ if(!empty($sql)){
|
|
|
+ //$rs = common::excuteListSql($sql);
|
|
|
+ $rs = $mapdb->GetAll($sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $sql), 0));
|
|
|
error_log($sql);
|
|
|
- $rs = common::excuteListSql($sql);
|
|
|
}
|
|
|
- $rs = common::excuteListSql($sql);
|
|
|
$array = array();
|
|
|
foreach($rs as $v){
|
|
|
if(!empty($v['code'])){
|
|
|
@@ -146,6 +177,9 @@ class ajax {
|
|
|
}
|
|
|
|
|
|
public function autoPort() {
|
|
|
+ //分担查询
|
|
|
+ include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
|
|
|
+
|
|
|
$cp = common::check_input($_POST ['cp']); //current_page
|
|
|
$ps = common::check_input($_POST ['ps']); //ps
|
|
|
if (empty($ps))
|
|
|
@@ -160,7 +194,8 @@ class ajax {
|
|
|
$rc = $_POST ['rc'];
|
|
|
if ($rc == - 1) {
|
|
|
$sql = $_sql_arr['count_sql'];
|
|
|
- $rc = common::excuteOneSql($sql);
|
|
|
+ //$rc = common::excuteOneSql($sql);
|
|
|
+ $rc = $mapdb->GetOne($sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $sql), 0));
|
|
|
error_log($sql);
|
|
|
}
|
|
|
$tp = ceil($rc / $ps);
|
|
|
@@ -169,7 +204,8 @@ class ajax {
|
|
|
$sql = "select DISTINCT ON (city) country, city,uncode from ($sql) as temp ";
|
|
|
$sql .= " limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
|
|
|
|
- $rs = common::excuteListSql($sql);
|
|
|
+ //$rs = common::excuteListSql($sql);
|
|
|
+ $rs = $mapdb->GetAll($sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $sql), 0));
|
|
|
error_log($sql);
|
|
|
//前端要加上id 从1开始
|
|
|
$retData = array();
|
|
|
@@ -474,7 +510,7 @@ class ajax {
|
|
|
from public.kln_booking $sqlWhere
|
|
|
and COALESCE(shippr_uncode,'')<>''
|
|
|
and (shipper_city ilike '%" . common::check_input($term) . "%'
|
|
|
- or shippr_uncode ilike '%" . common::check_input($term) . "%') order by f_etd desc NULLS LAST";
|
|
|
+ or shippr_uncode ilike '%" . common::check_input($term) . "%') order by f_etd desc";
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
@@ -490,7 +526,7 @@ class ajax {
|
|
|
from public.kln_booking $sqlWhere
|
|
|
and COALESCE(consignee_uncode,'')<>''
|
|
|
and (consignee_city ilike '%" . common::check_input($term) . "%'
|
|
|
- or consignee_uncode ilike '%" . common::check_input($term) . "%') order by f_etd desc NULLS LAST";
|
|
|
+ or consignee_uncode ilike '%" . common::check_input($term) . "%') order by f_etd desc";
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
@@ -506,7 +542,7 @@ class ajax {
|
|
|
from public.kln_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) . "%') order by f_etd desc NULLS LAST";
|
|
|
+ or place_of_receipt_uncode ilike '%" . common::check_input($term) . "%') order by f_etd desc";
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
@@ -522,7 +558,7 @@ class ajax {
|
|
|
from public.kln_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) . "%') order by f_etd desc NULLS LAST";
|
|
|
+ or fport_of_loading_uncode ilike '%" . common::check_input($term) . "%') order by f_etd desc";
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
@@ -538,15 +574,15 @@ class ajax {
|
|
|
from public.kln_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) . "%') order by f_etd desc NULLS LAST";
|
|
|
+ or place_of_delivery_uncode ilike '%" . common::check_input($term) . "%') order by f_etd desc";
|
|
|
|
|
|
return array("count_sql"=>$count_sql,"sql"=>$sql);
|
|
|
}
|
|
|
|
|
|
//tracking
|
|
|
- $order_by = " etd desc NULLS LAST";
|
|
|
+ $order_by = " etd desc";
|
|
|
if (_isCustomerLogin()) {
|
|
|
- $order_by = " eta desc NULLS LAST";
|
|
|
+ $order_by = " eta desc";
|
|
|
}
|
|
|
if($search_field == "Origin" && $search_mode == "tracking"){
|
|
|
$sqlWhere = $this->getTrackingSearchWhere();
|