|
@@ -32,65 +32,44 @@ class destination_delivery {
|
|
|
* select country
|
|
* select country
|
|
|
*/
|
|
*/
|
|
|
if ($operate == "country") {
|
|
if ($operate == "country") {
|
|
|
- $$cp = common::check_input($_POST ['cp']); //current_page
|
|
|
|
|
- $ps = common::check_input($_POST ['ps']); //ps
|
|
|
|
|
- if (empty($ps))
|
|
|
|
|
- $ps = 20;
|
|
|
|
|
$term = $_POST['term'];
|
|
$term = $_POST['term'];
|
|
|
$term = trim($term);
|
|
$term = trim($term);
|
|
|
-
|
|
|
|
|
- $rc = $_POST ['rc'];
|
|
|
|
|
- if ($rc == - 1) {
|
|
|
|
|
- $sql = "select COUNT(DISTINCT SUBSTRING(c.country FROM 1 FOR 2)) AS total_count
|
|
|
|
|
- from public.contract_region_mapping crm
|
|
|
|
|
- left join ocean.contacts c on c.contact_id = crm.overeas and crm.ksmart_station_new ilike 'ksmart%'
|
|
|
|
|
- where coalesce(c.country,'')<> ''
|
|
|
|
|
- and SUBSTRING(c.country FROM 1 FOR 2) ilike '" . common::check_input($term) . "%'";
|
|
|
|
|
- $rc = common::excuteOneSql($sql);
|
|
|
|
|
- }
|
|
|
|
|
- $tp = ceil($rc / $ps);
|
|
|
|
|
- if ($rc > 0) {
|
|
|
|
|
- $sql = "select DISTINCT SUBSTRING(c.country FROM 1 FOR 2) AS country_code
|
|
|
|
|
|
|
+ $sql = "select DISTINCT SUBSTRING(c.country FROM 1 FOR 2) AS country_code
|
|
|
from public.contract_region_mapping crm
|
|
from public.contract_region_mapping crm
|
|
|
left join ocean.contacts c on c.contact_id = crm.overeas and crm.ksmart_station_new ilike 'ksmart%'
|
|
left join ocean.contacts c on c.contact_id = crm.overeas and crm.ksmart_station_new ilike 'ksmart%'
|
|
|
where coalesce(c.country,'')<> ''
|
|
where coalesce(c.country,'')<> ''
|
|
|
and SUBSTRING(c.country FROM 1 FOR 2) ilike '" . common::check_input($term) . "%'";
|
|
and SUBSTRING(c.country FROM 1 FOR 2) ilike '" . common::check_input($term) . "%'";
|
|
|
- $sql .= " order by country_code limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
|
|
|
-
|
|
|
|
|
- $rs = common::excuteListSql($sql);
|
|
|
|
|
- //前端要加上id 从1开始
|
|
|
|
|
- $retData = array();
|
|
|
|
|
- foreach($rs as $key => $val){
|
|
|
|
|
- if(!empty($val['country_code'])){
|
|
|
|
|
- $val["id"] = $key +1;
|
|
|
|
|
- $retData[] = $val;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $sql .= " order by country_code";
|
|
|
|
|
+
|
|
|
|
|
+ $rs = common::excuteListSql($sql);
|
|
|
|
|
+ //前端要加上id 从1开始
|
|
|
|
|
+ $retData = array();
|
|
|
|
|
+ foreach($rs as $key => $val){
|
|
|
|
|
+ if(!empty($val['country_code'])){
|
|
|
|
|
+ $retData[] = array("value" =>$val['country_code'] ,"label"=>$val['country_code']);
|
|
|
}
|
|
}
|
|
|
- $arrTmp = array('searchData' => $retData,
|
|
|
|
|
- 'rc' => $rc,
|
|
|
|
|
- 'ps' => $ps,
|
|
|
|
|
- 'cp' => $cp,
|
|
|
|
|
- 'tp' => $tp);
|
|
|
|
|
- common::echo_json_encode(200,$arrTmp);
|
|
|
|
|
- exit();
|
|
|
|
|
- }else{
|
|
|
|
|
- $arrTmp = array('searchData' => array());
|
|
|
|
|
- common::echo_json_encode(200, $arrTmp);
|
|
|
|
|
- exit();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ common::echo_json_encode(200,$retData);
|
|
|
|
|
+ exit();
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* select station 选择国家后再展示 station list数据
|
|
* select station 选择国家后再展示 station list数据
|
|
|
- */
|
|
|
|
|
|
|
+ */
|
|
|
if ($operate == "station") {
|
|
if ($operate == "station") {
|
|
|
$country = common::check_input($_REQUEST['country']);
|
|
$country = common::check_input($_REQUEST['country']);
|
|
|
$sql = "select crm.overeas from public.contract_region_mapping crm
|
|
$sql = "select crm.overeas from public.contract_region_mapping crm
|
|
|
left join ocean.contacts c on c.contact_id = crm.overeas and crm.ksmart_station_new ilike 'ksmart%'
|
|
left join ocean.contacts c on c.contact_id = crm.overeas and crm.ksmart_station_new ilike 'ksmart%'
|
|
|
where SUBSTRING(c.country FROM 1 FOR 2) = '".$country."'";
|
|
where SUBSTRING(c.country FROM 1 FOR 2) = '".$country."'";
|
|
|
- $data = common::excuteListSql($sql);
|
|
|
|
|
|
|
+ $rs = common::excuteListSql($sql);
|
|
|
|
|
|
|
|
- common::echo_json_encode(200,$data);
|
|
|
|
|
|
|
+ foreach($rs as $key => $val){
|
|
|
|
|
+ if(!empty($val['overeas'])){
|
|
|
|
|
+ $retData[] = array("value" =>$val['overeas'] ,"label"=>$val['overeas']);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ common::echo_json_encode(200,$retData);
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -98,13 +77,19 @@ class destination_delivery {
|
|
|
* select KLN PIC 下拉可供选择的employee帐号,且帐号权限站点包含选中的station
|
|
* select KLN PIC 下拉可供选择的employee帐号,且帐号权限站点包含选中的station
|
|
|
*/
|
|
*/
|
|
|
if ($operate == "employee_account") {
|
|
if ($operate == "employee_account") {
|
|
|
|
|
+ $term = $_POST['term'];
|
|
|
|
|
+ $term = trim($term);
|
|
|
$station = $_REQUEST['station'];
|
|
$station = $_REQUEST['station'];
|
|
|
$more_param = common::getInNotInSqlForSearch(utils::implode(';',$station));
|
|
$more_param = common::getInNotInSqlForSearch(utils::implode(';',$station));
|
|
|
|
|
|
|
|
- $sql = "select email from employee where contact_id in ($more_param) ";
|
|
|
|
|
- $data = common::excuteListSql($sql);
|
|
|
|
|
-
|
|
|
|
|
- common::echo_json_encode(200,$data);
|
|
|
|
|
|
|
+ $sql = "select email from employee where contact_id in ($more_param) and email ilike '" . common::check_input($term) . "%' limit 20";
|
|
|
|
|
+ $rs = common::excuteListSql($sql);
|
|
|
|
|
+ foreach($rs as $key => $val){
|
|
|
|
|
+ if(!empty($val['email'])){
|
|
|
|
|
+ $retData[] = array("value" =>$val['email'] ,"label"=>$val['email']);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ common::echo_json_encode(200,$retData);
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -112,107 +97,92 @@ class destination_delivery {
|
|
|
* 下拉可供选择的ports
|
|
* 下拉可供选择的ports
|
|
|
*/
|
|
*/
|
|
|
if ($operate == "ports") {
|
|
if ($operate == "ports") {
|
|
|
- $mode = $_REQUEST['mode'];
|
|
|
|
|
- if ($mode == 'sea'){
|
|
|
|
|
- $sql = "select DISTINCT uncode from public.ports where coalesce(uncode,'')<> '' order by uncode";
|
|
|
|
|
- } else {
|
|
|
|
|
- $sql = "select DISTINCT coalesce(airport.country_abb,'')||airport.airport_code as uncode from sfs.airport
|
|
|
|
|
- where coalesce(country_abb,'')<>'' order by uncode";
|
|
|
|
|
- }
|
|
|
|
|
- $data = common::excuteListSql($sql);
|
|
|
|
|
- common::echo_json_encode(200,$data);
|
|
|
|
|
- exit();
|
|
|
|
|
-
|
|
|
|
|
- $cp = common::check_input($_POST ['cp']); //current_page
|
|
|
|
|
- $ps = common::check_input($_POST ['ps']); //ps
|
|
|
|
|
- if (empty($ps))
|
|
|
|
|
- $ps = 20;
|
|
|
|
|
|
|
|
|
|
$mode = $_POST['mode'];
|
|
$mode = $_POST['mode'];
|
|
|
$term = $_POST['term'];
|
|
$term = $_POST['term'];
|
|
|
$term = trim($term);
|
|
$term = trim($term);
|
|
|
|
|
|
|
|
- $rc = $_POST ['rc'];
|
|
|
|
|
- if ($rc == - 1) {
|
|
|
|
|
- if ($mode == 'sea'){
|
|
|
|
|
- $sql = "select COUNT(DISTINCT uncode) from public.ports
|
|
|
|
|
- where coalesce(uncode,'')<>'' and uncode ilike '" . common::check_input($term) . "%'";
|
|
|
|
|
- } else {
|
|
|
|
|
- $sql = "select COUNT(DISTINCT coalesce(airport.country_abb,'')||airport.airport_code) from sfs.airport
|
|
|
|
|
- where coalesce(country_abb,'')<>''
|
|
|
|
|
- and coalesce(airport.country_abb,'')||airport.airport_code ilike '" . common::check_input($term) . "%'";
|
|
|
|
|
- }
|
|
|
|
|
- $rc = common::excuteOneSql($sql);
|
|
|
|
|
- }
|
|
|
|
|
- $tp = ceil($rc / $ps);
|
|
|
|
|
- if ($rc > 0) {
|
|
|
|
|
- if ($mode == 'sea'){
|
|
|
|
|
|
|
+ if ($mode == 'sea'){
|
|
|
$sql = "select DISTINCT uncode from public.ports
|
|
$sql = "select DISTINCT uncode from public.ports
|
|
|
where coalesce(uncode,'')<> '' and uncode ilike '" . common::check_input($term) . "%'";
|
|
where coalesce(uncode,'')<> '' and uncode ilike '" . common::check_input($term) . "%'";
|
|
|
- } else {
|
|
|
|
|
|
|
+ } else {
|
|
|
$sql = "select DISTINCT coalesce(airport.country_abb,'')||airport.airport_code as uncode from sfs.airport
|
|
$sql = "select DISTINCT coalesce(airport.country_abb,'')||airport.airport_code as uncode from sfs.airport
|
|
|
where coalesce(country_abb,'')<>''
|
|
where coalesce(country_abb,'')<>''
|
|
|
and coalesce(airport.country_abb,'')||airport.airport_code ilike '" . common::check_input($term) . "%'";
|
|
and coalesce(airport.country_abb,'')||airport.airport_code ilike '" . common::check_input($term) . "%'";
|
|
|
|
|
+ }
|
|
|
|
|
+ $sql .= " order by uncode limit 20";
|
|
|
|
|
+
|
|
|
|
|
+ $rs = common::excuteListSql($sql);
|
|
|
|
|
+ //前端要加上id 从1开始
|
|
|
|
|
+ $retData = array();
|
|
|
|
|
+ foreach($rs as $key => $val){
|
|
|
|
|
+ if(!empty($val['uncode'])){
|
|
|
|
|
+ $retData[] = array("value" =>$val['uncode'] ,"label"=>$val['uncode']);
|
|
|
}
|
|
}
|
|
|
- $sql .= " order by uncode limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
|
|
|
-
|
|
|
|
|
- $rs = common::excuteListSql($sql);
|
|
|
|
|
- //前端要加上id 从1开始
|
|
|
|
|
- $retData = array();
|
|
|
|
|
- foreach($rs as $key => $val){
|
|
|
|
|
- if(!empty($val['uncode'])){
|
|
|
|
|
- $val["id"] = $key +1;
|
|
|
|
|
- $retData[] = $val;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- $arrTmp = array('searchData' => $retData,
|
|
|
|
|
- 'rc' => $rc,
|
|
|
|
|
- 'ps' => $ps,
|
|
|
|
|
- 'cp' => $cp,
|
|
|
|
|
- 'tp' => $tp);
|
|
|
|
|
- common::echo_json_encode(200,$arrTmp);
|
|
|
|
|
- exit();
|
|
|
|
|
- }else{
|
|
|
|
|
- $arrTmp = array('searchData' => array());
|
|
|
|
|
- common::echo_json_encode(200, $arrTmp);
|
|
|
|
|
- exit();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ common::echo_json_encode(200,$retData);
|
|
|
|
|
+ exit();
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 下拉可供选择的carrier
|
|
* 下拉可供选择的carrier
|
|
|
*/
|
|
*/
|
|
|
if ($operate == "carrier") {
|
|
if ($operate == "carrier") {
|
|
|
|
|
+ $term = $_POST['term'];
|
|
|
|
|
+ $term = trim($term);
|
|
|
|
|
+
|
|
|
|
|
+ $sql = "select DISTINCT scac from public.vessel_company
|
|
|
|
|
+ where coalesce(scac,'')<> '' and scac ilike '" . common::check_input($term) . "%'";
|
|
|
|
|
+ $sql .= " order by scac limit 20";
|
|
|
|
|
+
|
|
|
|
|
+ $rs = common::excuteListSql($sql);
|
|
|
|
|
+ //前端要加上id 从1开始
|
|
|
|
|
+ $retData = array();
|
|
|
|
|
+ foreach($rs as $key => $val){
|
|
|
|
|
+ if(!empty($val['scac'])){
|
|
|
|
|
+ $retData[] = array("value" =>$val['scac'] ,"label"=>$val['scac']);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ common::echo_json_encode(200,$retData);
|
|
|
|
|
+ exit();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * destination_delivery 配置
|
|
|
|
|
+ */
|
|
|
|
|
+ public function destination_delivery_config(){
|
|
|
|
|
+ $operate = utils::_get('operate');
|
|
|
|
|
+ $operate = strtolower($operate);
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 这个是嵌套在destination_delivery的配置查询,
|
|
|
|
|
+ */
|
|
|
|
|
+ if ($operate == "search"){
|
|
|
$cp = common::check_input($_POST ['cp']); //current_page
|
|
$cp = common::check_input($_POST ['cp']); //current_page
|
|
|
$ps = common::check_input($_POST ['ps']); //ps
|
|
$ps = common::check_input($_POST ['ps']); //ps
|
|
|
if (empty($ps))
|
|
if (empty($ps))
|
|
|
- $ps = 20;
|
|
|
|
|
-
|
|
|
|
|
- $term = $_POST['term'];
|
|
|
|
|
- $term = trim($term);
|
|
|
|
|
|
|
+ $ps = 100;
|
|
|
|
|
+ if (empty($cp))
|
|
|
|
|
+ $cp = 1;
|
|
|
|
|
|
|
|
$rc = $_POST ['rc'];
|
|
$rc = $_POST ['rc'];
|
|
|
if ($rc == - 1) {
|
|
if ($rc == - 1) {
|
|
|
- $sql = "select COUNT(DISTINCT scac) from public.vessel_company
|
|
|
|
|
- where coalesce(scac,'')<> '' and scac ilike '" . common::check_input($term) . "%'";
|
|
|
|
|
|
|
+ $sql = "select count(*) from public.kln_destination_delivery_config";
|
|
|
$rc = common::excuteOneSql($sql);
|
|
$rc = common::excuteOneSql($sql);
|
|
|
}
|
|
}
|
|
|
$tp = ceil($rc / $ps);
|
|
$tp = ceil($rc / $ps);
|
|
|
if ($rc > 0) {
|
|
if ($rc > 0) {
|
|
|
- $sql = "select DISTINCT scac from public.vessel_company
|
|
|
|
|
- where coalesce(scac,'')<> '' and scac ilike '" . common::check_input($term) . "%'";
|
|
|
|
|
- $sql .= " order by scac limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
|
|
|
|
|
+ $sql = "select * from public.kln_destination_delivery_config";
|
|
|
|
|
+ $sql .= " order by id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
|
|
|
|
|
|
$rs = common::excuteListSql($sql);
|
|
$rs = common::excuteListSql($sql);
|
|
|
- //前端要加上id 从1开始
|
|
|
|
|
- $retData = array();
|
|
|
|
|
|
|
+
|
|
|
foreach($rs as $key => $val){
|
|
foreach($rs as $key => $val){
|
|
|
- if(!empty($val['scac'])){
|
|
|
|
|
- $val["id"] = $key +1;
|
|
|
|
|
- $retData[] = $val;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $rs[$key]["_serial_no"] = common::deCode($val['serial_no'], 'E');
|
|
|
}
|
|
}
|
|
|
- $arrTmp = array('searchData' => $retData,
|
|
|
|
|
|
|
+ $arrTmp = array('searchData' => $rs,
|
|
|
'rc' => $rc,
|
|
'rc' => $rc,
|
|
|
'ps' => $ps,
|
|
'ps' => $ps,
|
|
|
'cp' => $cp,
|
|
'cp' => $cp,
|
|
@@ -225,48 +195,184 @@ class destination_delivery {
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * destination_delivery 配置
|
|
|
|
|
- */
|
|
|
|
|
- public function destination_delivery_config(){
|
|
|
|
|
- $operate = utils::_get('operate');
|
|
|
|
|
- $operate = strtolower($operate);
|
|
|
|
|
|
|
+ if ($operate == "add"){
|
|
|
|
|
+ $serial_no = common::deCode($_GET['a'], 'D');
|
|
|
|
|
+ $data = array();
|
|
|
|
|
+ $rule = array();
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 这个是嵌套在destination_delivery的配置查询,
|
|
|
|
|
- */
|
|
|
|
|
- if ($operate == "search"){
|
|
|
|
|
- $sql = "select * from public.kln_destination_delivery_config";
|
|
|
|
|
- $data = common::excuteListSql($sql);
|
|
|
|
|
- common::echo_json_encode(200,$data);
|
|
|
|
|
- exit();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (!empty($serial_no)){
|
|
|
|
|
+ $sql = "select * from public.kln_destination_delivery_config where serial_no = '$serial_no'";
|
|
|
|
|
+ $data = common::excuteObjectSql($sql);
|
|
|
|
|
|
|
|
- if ($operate == "add"){
|
|
|
|
|
- $id = common::deCode($_GET['a'], 'D');
|
|
|
|
|
- if (!empty($id)){
|
|
|
|
|
|
|
+ if ($data['recommended_delivery'] == 'delivery_eta_ata') {
|
|
|
|
|
+ $sql = "select * from public.kln_destination_delivery_rule where recommended_delivery_serial_no = '$serial_no'";
|
|
|
|
|
+ $rule = common::excuteObjectSql($sql);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //处理组装返回格式
|
|
|
|
|
+ //RcommendDeliveryDate
|
|
|
|
|
+ $RecommendCheckedAirList = array();
|
|
|
|
|
+ $RecommendCheckedSeaList = array();
|
|
|
|
|
+ $RecommendCheckedList = array();
|
|
|
|
|
+ foreach($rule as $item){
|
|
|
|
|
+ if ($item['mode_type'] == 'sea'){
|
|
|
|
|
+ $RecommendCheckedSeaList[] = array("Priority"=>$item['priority'],"RuleType"=>$item['rule_type'],
|
|
|
|
|
+ "Port"=>explode(";", $item['ports']),
|
|
|
|
|
+ "Carrier"=>explode(";", $item['carrier']),
|
|
|
|
|
+ "FromDate"=>$item['recommended_delivery_from'],
|
|
|
|
|
+ "ToDate"=>$item['recommended_delivery_to']);
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($item['mode_type'] == 'air'){
|
|
|
|
|
+ $RecommendCheckedAirList[] = array("Priority"=>$item['priority'],"RuleType"=>$item['rule_type'],
|
|
|
|
|
+ "Port"=>explode(";", $item['ports']),
|
|
|
|
|
+ "Carrier"=>explode(";", $item['carrier']),
|
|
|
|
|
+ "FromDate"=>$item['recommended_delivery_from'],
|
|
|
|
|
+ "ToDate"=>$item['recommended_delivery_to']);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!utils::in_array($item['mode_type'], $RecommendCheckedList)) {
|
|
|
|
|
+ $RecommendCheckedList[] = $item['mode_type'];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ $returnData = $data;
|
|
|
|
|
+ if (!empty($data['booking_window'])) {
|
|
|
|
|
+ $returnData["SetBookingWindow"] = array("windowradio" =>$data['booking_window'],
|
|
|
|
|
+ "windowBeforeDays"=>$data['booking_window'],
|
|
|
|
|
+ "windowAfterDays"=>$data['booking_window']);
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ $returnData["SetBookingWindow"] = array();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ if ($data['recommended_delivery'] == 'Delivery_ETA_ATA') {
|
|
|
|
|
+ $returnData["RcommendDeliveryDate"] = array("Recommendradio" =>$data['recommended_delivery'],
|
|
|
|
|
+ "RecommendCheckedList"=>$RecommendCheckedList,
|
|
|
|
|
+ "RecommendCheckedAirList"=>$RecommendCheckedAirList,
|
|
|
|
|
+ "RecommendCheckedSeaList"=>$RecommendCheckedSeaList);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $returnData["RcommendDeliveryDate"] = array();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $returnData["KLNPLCvalue"] = explode(";", $data['kln_pic']);
|
|
|
|
|
+
|
|
|
global $_COPYRIGHT;
|
|
global $_COPYRIGHT;
|
|
|
$data = array('copyright' =>$_COPYRIGHT,
|
|
$data = array('copyright' =>$_COPYRIGHT,
|
|
|
- 'website' =>"");
|
|
|
|
|
|
|
+ 'returnData' =>$returnData);
|
|
|
common::echo_json_encode(200,$data);
|
|
common::echo_json_encode(200,$data);
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($operate == "save"){
|
|
if ($operate == "save"){
|
|
|
- $id = common::deCode($_GET['a'], 'D');
|
|
|
|
|
- if (!empty($id)){
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $serial_no = common::deCode($_POST['a'], 'D');
|
|
|
|
|
+
|
|
|
|
|
+ $country = common::check_input($_POST['country']);
|
|
|
|
|
+ $station = empty($_POST['station']) ? "" :explode(";", $_POST['station']);
|
|
|
|
|
+ $booking_window = common::check_input($_POST['booking_window']);
|
|
|
|
|
+ $booking_window_date_start = common::check_input($_POST['booking_window_date_start']);
|
|
|
|
|
+ $booking_window_date_end = common::check_input($_POST['booking_window_date_end']);
|
|
|
|
|
+ $recommended_delivery = common::check_input($_POST['recommended_delivery']);
|
|
|
|
|
+ $kln_pic = empty($_POST['kln_pic']) ? "" :explode(";", $_POST['kln_pic']);
|
|
|
|
|
+
|
|
|
|
|
+ //rule
|
|
|
|
|
+ $_mode_type = $_POST['mode_type'];
|
|
|
|
|
+ $_priority = $_POST['priority'];
|
|
|
|
|
+ $_rule_type = $_POST['rule_type'];
|
|
|
|
|
+ $_ports = $_POST['ports'];
|
|
|
|
|
+ $_carrier = $_POST['carrier'];
|
|
|
|
|
+ $_recommended_delivery_from = $_POST['recommended_delivery_from'];
|
|
|
|
|
+ $_recommended_delivery_to = $_POST['recommended_delivery_to'];
|
|
|
|
|
+
|
|
|
|
|
+ $errmsg = "";
|
|
|
|
|
+ $sql = "";
|
|
|
|
|
+ if (!empty($serial_no)){
|
|
|
|
|
+ $updateSqlSet = " modify_by = '"._getLoginName()."',update_time = now()";
|
|
|
|
|
+ if (!empty($country)) {
|
|
|
|
|
+ $updateSqlSet.= ", country = '$country' ";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!empty($station)) {
|
|
|
|
|
+ $updateSqlSet.= ", station = '$station' ";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!empty($booking_window)) {
|
|
|
|
|
+ $updateSqlSet.= ", booking_window = '$booking_window' ";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!empty($booking_window_date_start)) {
|
|
|
|
|
+ $updateSqlSet.= ", booking_window_date_start = '$booking_window_date_start' ";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!empty($booking_window_date_end)) {
|
|
|
|
|
+ $updateSqlSet.= ", booking_window_date_end = '$booking_window_date_end' ";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!empty($recommended_delivery)) {
|
|
|
|
|
+ $updateSqlSet.= ", recommended_delivery = '$recommended_delivery' ";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!empty($kln_pic)) {
|
|
|
|
|
+ $updateSqlSet.= ", kln_pic = '$kln_pic' ";
|
|
|
|
|
+ }
|
|
|
|
|
+ //代表update
|
|
|
|
|
+ $sql .= "update public.kln_destination_delivery_config set ".$updateSqlSet."
|
|
|
|
|
+ where serial_no = '$serial_no';";
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ //代表更新
|
|
|
|
|
+ $serial_no = common::uuid();
|
|
|
|
|
+ $sql .="INSERT INTO public.kln_destination_delivery_config(
|
|
|
|
|
+ serial_no, country, station, booking_window, booking_window_date_start,
|
|
|
|
|
+ booking_window_date_end, recommended_delivery, kln_pic, create_by,
|
|
|
|
|
+ created_time, modify_by, update_time)
|
|
|
|
|
+ VALUES ('$serial_no', '$country', '$station', '$booking_window', '$booking_window_date_start',
|
|
|
|
|
+ '$booking_window_date_end', '$recommended_delivery', '$kln_pic',
|
|
|
|
|
+ '"._getLoginName()."', now(), '"._getLoginName()."', now());";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ if ($recommended_delivery == "delivery_eta_ata"){
|
|
|
|
|
+ // 用于统计每种类型是否存在,以及是否满足 rule_type = 'all'
|
|
|
|
|
+ $typeExists = ['air' => false, 'sea' => false];
|
|
|
|
|
+ $typeHasAllRule = ['air' => false, 'sea' => false];
|
|
|
|
|
+
|
|
|
|
|
+ foreach($_mode_type as $key => $v){
|
|
|
|
|
+ $mode_type = $v;
|
|
|
|
|
+ $priority = $_priority[$key];
|
|
|
|
|
+ $rule_type = $_rule_type[$key];
|
|
|
|
|
+ $ports = empty($_ports[$key]) ? "" :explode(";", $_ports[$key]);
|
|
|
|
|
+ $carrier = empty($_carrier[$key]) ? "" :explode(";", $_carrier[$key]);
|
|
|
|
|
+ $recommended_delivery_from = $_recommended_delivery_from[$key];
|
|
|
|
|
+ $recommended_delivery_to = $_recommended_delivery_to[$key];
|
|
|
|
|
+
|
|
|
|
|
+ // 只处理 air 和 sea
|
|
|
|
|
+ if ($mode_type == 'air' || $mode_type == 'sea') {
|
|
|
|
|
+ $typeExists[$mode_type] = true;
|
|
|
|
|
+ if ($rule_type == 'all') {
|
|
|
|
|
+ $typeHasAllRule[$mode_type] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //先删除,后添加
|
|
|
|
|
+ $sql .= "delete from public.kln_destination_delivery_rule where recommended_delivery_serial_no = '$serial_no';";
|
|
|
|
|
+ $sql .= "INSERT INTO public.kln_destination_delivery_rule(
|
|
|
|
|
+ serial_no, recommended_delivery_serial_no, mode_type, priority,
|
|
|
|
|
+ rule_type, ports, carrier, recommended_delivery_from, recommended_delivery_to,
|
|
|
|
|
+ create_by, created_time, modify_by, update_time)
|
|
|
|
|
+ VALUES ('$serial_no', '$mode_type', '$priority',
|
|
|
|
|
+ '$rule_type', '$ports', '$carrier', '$recommended_delivery_from', '$recommended_delivery_to',
|
|
|
|
|
+ '"._getLoginName()."', now(), '"._getLoginName()."', now());";
|
|
|
|
|
+ }
|
|
|
|
|
+ // 检查缺失的 rule_type = 'all'
|
|
|
|
|
+ $missingTypes = [];
|
|
|
|
|
+ foreach (['air', 'sea'] as $type) {
|
|
|
|
|
+ if ($typeExists[$type] && !$typeHasAllRule[$type]) {
|
|
|
|
|
+ $missingTypes[] = $type;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!empty($missingTypes)) {
|
|
|
|
|
+ $errmsg = "The Default Rule must exist.";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- $data = "";
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (empty($errmsg) && !empty($sql)){
|
|
|
|
|
+ common::excuteUpdateSql($sql);
|
|
|
|
|
+ $data = array("msg" =>"success");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $data = array("msg" =>$errmsg);
|
|
|
|
|
+ }
|
|
|
common::echo_json_encode(200,$data);
|
|
common::echo_json_encode(200,$data);
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|