|
@@ -615,18 +615,18 @@ class destination_delivery {
|
|
|
//代表employee
|
|
//代表employee
|
|
|
$sqlDeliveryWhere = " 1=1";
|
|
$sqlDeliveryWhere = " 1=1";
|
|
|
if(_isApexLogin()){
|
|
if(_isApexLogin()){
|
|
|
- //$sqlWhere .= " and kln_pic ilike '"._getLoginEamil()."'";
|
|
|
|
|
- $sqlDeliveryWhere .= " and '".strtolower(_getLoginEmployeeEamil())."' in (select regexp_split_to_table(lower(kd.kln_pic), ','))";
|
|
|
|
|
|
|
+ //$sqlDeliveryWhere .= " and '".strtolower("CATHY.LEE@APEXSHIPPING.COM")."' = ANY(LOWER(regexp_split_to_array(kd.kln_pic, ',')))";
|
|
|
|
|
+ $sqlDeliveryWhere .= " and '".strtolower(_getLoginEmployeeEamil())."' = ANY(LOWER(regexp_split_to_array(kd.kln_pic, ',')))";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//条件带入
|
|
//条件带入
|
|
|
$text_search = $_REQUEST['text_search'];
|
|
$text_search = $_REQUEST['text_search'];
|
|
|
if (!empty($text_search)){
|
|
if (!empty($text_search)){
|
|
|
- $sqlWhere .= " and (booking_no ilike '%".strtolower($text_search)."%'
|
|
|
|
|
- or h_bol ilike '%".strtolower($text_search)."%'
|
|
|
|
|
- or m_bol ilike '%".strtolower($text_search)."%'
|
|
|
|
|
- or ctnr ilike '%".strtolower($text_search)."%'
|
|
|
|
|
- or consignee ilike '%".strtolower($text_search)."%')";
|
|
|
|
|
|
|
+ $sqlDeliveryWhere .= " and (lower(booking_no) like '%".strtolower($text_search)."%'
|
|
|
|
|
+ or lower(h_bol) like '%".strtolower($text_search)."%'
|
|
|
|
|
+ or lower(m_bol) like '%".strtolower($text_search)."%'
|
|
|
|
|
+ or lower(ctnr) like '%".strtolower($text_search)."%'
|
|
|
|
|
+ or lower(consignee) like '%".strtolower($text_search)."%')";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (isset($_REQUEST['delivery_date_start']) && !empty($_REQUEST['delivery_date_start']))
|
|
if (isset($_REQUEST['delivery_date_start']) && !empty($_REQUEST['delivery_date_start']))
|
|
@@ -689,7 +689,7 @@ class destination_delivery {
|
|
|
sum(case when kd.status ='Cancel' then 1 else 0 end) as cancelled_rc
|
|
sum(case when kd.status ='Cancel' then 1 else 0 end) as cancelled_rc
|
|
|
from public.kln_destination_delivery kd
|
|
from public.kln_destination_delivery kd
|
|
|
where ".$sqlDeliveryWhere."
|
|
where ".$sqlDeliveryWhere."
|
|
|
- and exists(select 1 from public.kln_ocean oo ". $sqlWhere." and oo.serial_no = any(kd.h_serial_no))";
|
|
|
|
|
|
|
+ and exists(select 1 from public.kln_ocean oo ". $sqlWhere." and oo.serial_no = any(kd.h_serial_no) limit 1)";
|
|
|
error_log("kln_destination_delivery_count:".$sql);
|
|
error_log("kln_destination_delivery_count:".$sql);
|
|
|
$statusRc = common::excuteObjectSql($sql);
|
|
$statusRc = common::excuteObjectSql($sql);
|
|
|
$rc = $statusRc['rc'];
|
|
$rc = $statusRc['rc'];
|
|
@@ -707,7 +707,7 @@ class destination_delivery {
|
|
|
from public.kln_destination_delivery kd
|
|
from public.kln_destination_delivery kd
|
|
|
where ".$tag_and_mode_param."
|
|
where ".$tag_and_mode_param."
|
|
|
and ".$sqlDeliveryWhere."
|
|
and ".$sqlDeliveryWhere."
|
|
|
- and exists(select 1 from public.kln_ocean oo ". $sqlWhere." and oo.serial_no = any(h_serial_no))";
|
|
|
|
|
|
|
+ and exists(select 1 from public.kln_ocean oo ". $sqlWhere." and oo.serial_no = any(h_serial_no) limit 1)";
|
|
|
$sql .= " order by id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
$sql .= " order by id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
|
|
|
|
|
|
error_log("kln_destination_delivery_search:".$sql);
|
|
error_log("kln_destination_delivery_search:".$sql);
|
|
@@ -1148,8 +1148,8 @@ class destination_delivery {
|
|
|
|
|
|
|
|
$sqlDeliveryWhere = " 1=1";
|
|
$sqlDeliveryWhere = " 1=1";
|
|
|
if(_isApexLogin()){
|
|
if(_isApexLogin()){
|
|
|
- //$sqlWhere .= " and kln_pic ilike '"._getLoginEamil()."'";
|
|
|
|
|
- $sqlDeliveryWhere .= " and '".strtolower(_getLoginEmployeeEamil())."' in (select regexp_split_to_table(lower(kd.kln_pic), ','))";
|
|
|
|
|
|
|
+ //$sqlDeliveryWhere .= " and '".strtolower("CATHY.LEE@APEXSHIPPING.COM")."' = ANY(LOWER(regexp_split_to_array(kd.kln_pic, ',')))";
|
|
|
|
|
+ $sqlDeliveryWhere .= " and '".strtolower(_getLoginEmployeeEamil())."' = ANY(LOWER(regexp_split_to_array(kd.kln_pic, ',')))";
|
|
|
}
|
|
}
|
|
|
//$sqlWhere_befrom_filterTag = $sqlWhere;
|
|
//$sqlWhere_befrom_filterTag = $sqlWhere;
|
|
|
$sql = "select delivery_date::date as delivery_date,
|
|
$sql = "select delivery_date::date as delivery_date,
|
|
@@ -1157,7 +1157,7 @@ class destination_delivery {
|
|
|
sum(case when status ='Approve' then 1 else 0 end) as approved_rc
|
|
sum(case when status ='Approve' then 1 else 0 end) as approved_rc
|
|
|
from public.kln_destination_delivery kd
|
|
from public.kln_destination_delivery kd
|
|
|
where ".$sqlDeliveryWhere."
|
|
where ".$sqlDeliveryWhere."
|
|
|
- and exists(select 1 from public.kln_ocean oo ". $sqlWhere." and oo.serial_no = any(h_serial_no))
|
|
|
|
|
|
|
+ and exists(select 1 from public.kln_ocean oo ". $sqlWhere." and oo.serial_no = any(h_serial_no) limit 1)
|
|
|
group by delivery_date::date order by delivery_date::date desc";
|
|
group by delivery_date::date order by delivery_date::date desc";
|
|
|
$rs = common::excuteListSql($sql);
|
|
$rs = common::excuteListSql($sql);
|
|
|
error_log("delivery_date_load:".$sql);
|
|
error_log("delivery_date_load:".$sql);
|
|
@@ -1213,25 +1213,25 @@ class destination_delivery {
|
|
|
|
|
|
|
|
$text_search = $_REQUEST['text_search'];
|
|
$text_search = $_REQUEST['text_search'];
|
|
|
if (!empty($text_search)){
|
|
if (!empty($text_search)){
|
|
|
- $sqlWhere .= " and (oo.h_bol ilike '%".strtolower($text_search)."%'
|
|
|
|
|
- or oo.po_no ilike '%".strtolower($text_search)."%'
|
|
|
|
|
- or oo.ctnrs ilike '%".strtolower($text_search)."%')";
|
|
|
|
|
|
|
+ $sqlWhere .= " and (lower(oo.h_bol) like '%".strtolower($text_search)."%'
|
|
|
|
|
+ or lower(oo.po_no) like '%".strtolower($text_search)."%'
|
|
|
|
|
+ or lower(oo.ctnrs) like '%".strtolower($text_search)."%')";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//vessel name
|
|
//vessel name
|
|
|
$vessel = $_REQUEST['vessel'];
|
|
$vessel = $_REQUEST['vessel'];
|
|
|
if (!empty($vessel)){
|
|
if (!empty($vessel)){
|
|
|
- $sqlWhere .= " and vessel ilike '%".strtolower($vessel)."'%";
|
|
|
|
|
|
|
+ $sqlWhere .= " and lower(vessel) like '%".strtolower($vessel)."'%";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$consignee = $_REQUEST['consignee'];
|
|
$consignee = $_REQUEST['consignee'];
|
|
|
if (!empty($vessel)){
|
|
if (!empty($vessel)){
|
|
|
- $sqlWhere .= " and consignee ilike '%".strtolower($consignee)."'%";
|
|
|
|
|
|
|
+ $sqlWhere .= " and lower(consignee) like '%".strtolower($consignee)."'%";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$shipper = $_REQUEST['shipper'];
|
|
$shipper = $_REQUEST['shipper'];
|
|
|
if (!empty($vessel)){
|
|
if (!empty($vessel)){
|
|
|
- $sqlWhere .= " and shipper ilike '%".strtolower($shipper)."'%";
|
|
|
|
|
|
|
+ $sqlWhere .= " and lower(shipper) like '%".strtolower($shipper)."'%";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (isset($_REQUEST['eta_start']) && !empty($_REQUEST['eta_start']))
|
|
if (isset($_REQUEST['eta_start']) && !empty($_REQUEST['eta_start']))
|
|
@@ -1245,16 +1245,53 @@ class destination_delivery {
|
|
|
$sqlWhere .= " and ata <= '" . common::usDate2sqlDate($_REQUEST['ata_end']) . " 23:59:59'";
|
|
$sqlWhere .= " and ata <= '" . common::usDate2sqlDate($_REQUEST['ata_end']) . " 23:59:59'";
|
|
|
|
|
|
|
|
$sql = "with oo as(
|
|
$sql = "with oo as(
|
|
|
- select * from public.kln_ocean oo ". $sqlWhere ."
|
|
|
|
|
|
|
+ select oo.serial_no,
|
|
|
|
|
+ oo.h_bol,
|
|
|
|
|
+ oo.m_bol,
|
|
|
|
|
+ oo.service,
|
|
|
|
|
+ oo.po_no,
|
|
|
|
|
+ oo.transport_mode,
|
|
|
|
|
+ oo.qty,
|
|
|
|
|
+ oo.qty_uom,
|
|
|
|
|
+ oo.piece_count,
|
|
|
|
|
+ oo.cbm,
|
|
|
|
|
+ oo.vessel,
|
|
|
|
|
+ oo.voyage,
|
|
|
|
|
+ oo.carrier,
|
|
|
|
|
+ oo.fport_of_loading_un,
|
|
|
|
|
+ oo.mport_of_discharge_un,
|
|
|
|
|
+ oo.eta,
|
|
|
|
|
+ oo.ata,
|
|
|
|
|
+ oo.etd,
|
|
|
|
|
+ oo.atd,
|
|
|
|
|
+ oo.shipper,
|
|
|
|
|
+ oo.consignee_id,
|
|
|
|
|
+ oo.consignee,
|
|
|
|
|
+ oo.booking_no,
|
|
|
|
|
+ oo.agent,
|
|
|
|
|
+ oo.order_from
|
|
|
|
|
+ from public.kln_ocean oo ". $sqlWhere ."
|
|
|
|
|
+ ),
|
|
|
|
|
+ -- 2. 预解析station字段
|
|
|
|
|
+ station_list AS (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ serial_no,
|
|
|
|
|
+ country,
|
|
|
|
|
+ kln_pic,
|
|
|
|
|
+ booking_window,
|
|
|
|
|
+ booking_window_date_start,
|
|
|
|
|
+ booking_window_date_end,
|
|
|
|
|
+ unnest(string_to_array(station, ',')) as station_code
|
|
|
|
|
+ FROM public.kln_destination_delivery_config
|
|
|
),
|
|
),
|
|
|
ooc as (
|
|
ooc as (
|
|
|
select oo.*,
|
|
select oo.*,
|
|
|
dc.serial_no as dc_serial_no,
|
|
dc.serial_no as dc_serial_no,
|
|
|
dc.country as dc_country,
|
|
dc.country as dc_country,
|
|
|
dc.kln_pic as dc_kln_pic
|
|
dc.kln_pic as dc_kln_pic
|
|
|
- from public.kln_destination_delivery_config dc
|
|
|
|
|
|
|
+ from station_list dc
|
|
|
Inner Join oo
|
|
Inner Join oo
|
|
|
- on oo.agent in (select regexp_split_to_table(dc.station, ','))
|
|
|
|
|
|
|
+ on oo.agent = dc.station_code
|
|
|
where 1=1 and
|
|
where 1=1 and
|
|
|
case when dc.booking_window = 'Restrictions_ETD_ATD' and COALESCE(dc.booking_window_date_start,'')<>'' and COALESCE(dc.booking_window_date_end,'')<>''
|
|
case when dc.booking_window = 'Restrictions_ETD_ATD' and COALESCE(dc.booking_window_date_start,'')<>'' and COALESCE(dc.booking_window_date_end,'')<>''
|
|
|
then COALESCE(atd, etd) >= (NOW() - (dc.booking_window_date_start ||' days')::INTERVAL)::date and COALESCE(atd, etd) <= (NOW() + (dc.booking_window_date_end ||' days')::INTERVAL)::date
|
|
then COALESCE(atd, etd) >= (NOW() - (dc.booking_window_date_start ||' days')::INTERVAL)::date and COALESCE(atd, etd) <= (NOW() + (dc.booking_window_date_end ||' days')::INTERVAL)::date
|