|
|
@@ -833,25 +833,32 @@ class destination_delivery {
|
|
|
$special_requirements = common::check_input($_POST['special_requirements']);
|
|
|
|
|
|
//检查不能重复添加booking 这里空运没问题,但是会遇到相同hbol 不同的柜子情况,本质上来说就是一条
|
|
|
- //$sqlWhere = ' where ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
+ $sqlWhere = ' where ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
//兜底规则
|
|
|
- //$sqlWhere .= " and eta >= now() - INTERVAL '6 months' and eta <= now() + INTERVAL '6 months'";
|
|
|
-
|
|
|
- // $ckeckedSql = "with save_table as (select regexp_split_to_table('".utils::implode(',',$h_serial_no)."', ',') as serial_no)
|
|
|
- // select string_agg(h_bol, ';') as h_bol from public.kln_destination_delivery kde
|
|
|
- // where exists(select 1 from save_table where save_table.serial_no = any(kde.h_serial_no))
|
|
|
- // and exists(select 1 from public.kln_ocean oo ". $sqlWhere." and oo.serial_no = any(kde.h_serial_no))";
|
|
|
- // //代表编辑
|
|
|
- // if(!empty($serial_no)){
|
|
|
- // $ckeckedSql .=" and kde.serial_no <> '$serial_no'";
|
|
|
- // }
|
|
|
-
|
|
|
- // $checkeData = common::excuteObjectSql($ckeckedSql);
|
|
|
- // if(!empty($checkeData['h_bol'])){
|
|
|
- // $data = array("msg" =>"The ".$checkeData['h_bol'] ." already exists");
|
|
|
- // common::echo_json_encode(200,$data);
|
|
|
- // exit();
|
|
|
- // }
|
|
|
+ $sqlWhere .= " and eta >= now() - INTERVAL '6 months' and eta <= now() + INTERVAL '6 months'";
|
|
|
+
|
|
|
+ $ckeckedSql = "with save_table as (
|
|
|
+ select regexp_split_to_table('".utils::implode(',',$h_serial_no)."', ',') as serial_no
|
|
|
+ ),
|
|
|
+ save_table_ctnr as (
|
|
|
+ select regexp_split_to_table('".utils::implode(',',$ctnr)."', ',') as ctnr
|
|
|
+ )
|
|
|
+ select h_bol,ctnr from public.kln_destination_delivery kde
|
|
|
+ where exists(select 1 from save_table where save_table.serial_no = any(kde.h_serial_no))
|
|
|
+ and (exists(select 1 from save_table_ctnr where save_table_ctnr.ctnr = ANY(regexp_split_to_array(kde.ctnr, ','))
|
|
|
+ or COALESCE(kde.ctnr,'') = ''))
|
|
|
+ and exists(select 1 from public.kln_ocean oo ". $sqlWhere." and oo.serial_no = any(kde.h_serial_no) limit 1)";
|
|
|
+ //代表编辑
|
|
|
+ if(!empty($serial_no)){
|
|
|
+ $ckeckedSql .=" and kde.serial_no <> '$serial_no'";
|
|
|
+ }
|
|
|
+
|
|
|
+ $checkeData = common::excuteObjectSql($ckeckedSql);
|
|
|
+ if(!empty($checkeData['h_bol'])){
|
|
|
+ $data = array("msg" =>"The ".$checkeData['h_bol'] .",".$checkeData['ctnr'] ." already exists");
|
|
|
+ common::echo_json_encode(200,$data);
|
|
|
+ exit();
|
|
|
+ }
|
|
|
|
|
|
$sql = "";
|
|
|
//代表修改
|
|
|
@@ -1213,17 +1220,17 @@ class destination_delivery {
|
|
|
//vessel name
|
|
|
$vessel = $_REQUEST['vessel'];
|
|
|
if (!empty($vessel)){
|
|
|
- $sqlWhere .= " and lower(vessel) like '%".strtolower($vessel)."'%";
|
|
|
+ $sqlWhere .= " and lower(vessel) like '%".strtolower($vessel)."%'";
|
|
|
}
|
|
|
|
|
|
$consignee = $_REQUEST['consignee'];
|
|
|
- if (!empty($vessel)){
|
|
|
- $sqlWhere .= " and lower(consignee) like '%".strtolower($consignee)."'%";
|
|
|
+ if (!empty($consignee)){
|
|
|
+ $sqlWhere .= " and lower(consignee) like '%".strtolower($consignee)."%'";
|
|
|
}
|
|
|
|
|
|
$shipper = $_REQUEST['shipper'];
|
|
|
- if (!empty($vessel)){
|
|
|
- $sqlWhere .= " and lower(shipper) like '%".strtolower($shipper)."'%";
|
|
|
+ if (!empty($shipper)){
|
|
|
+ $sqlWhere .= " and lower(shipper) like '%".strtolower($shipper)."%'";
|
|
|
}
|
|
|
|
|
|
if (isset($_REQUEST['eta_start']) && !empty($_REQUEST['eta_start']))
|