|
@@ -290,6 +290,37 @@ class destination_delivery {
|
|
|
exit();
|
|
exit();
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if ($operate == "destination_delivery_calendar_consignee") {
|
|
|
|
|
+ $month = common::check_input($_POST ['month']);
|
|
|
|
|
+ $month = common::excuteObjectSql("SELECT CURRENT_DATE AS access_date,
|
|
|
|
|
+ (to_date('".$month."', 'MM/YYYY'))::date AS month_start,
|
|
|
|
|
+ (date_trunc('month', to_date('".$month."', 'MM/YYYY')) + interval '1 month - 1 day')::date AS month_end");
|
|
|
|
|
+
|
|
|
|
|
+ $sqlWhere = ' where ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
|
|
+ //兜底规则
|
|
|
|
|
+ $sqlWhere .= " and eta >= now() - INTERVAL '6 months' and eta <= now() + INTERVAL '6 months'";
|
|
|
|
|
+ $consignee = common::check_input($_POST ['consignee']);
|
|
|
|
|
+ if(!empty($consignee)){
|
|
|
|
|
+ $sqlWhere .= " and consignee ilike '".$consignee."%'";
|
|
|
|
|
+ }
|
|
|
|
|
+ $sqlKNDDWhere = "and exists(select 1 from public.kln_ocean ". $sqlWhere." and kln_ocean.serial_no = any(kln_destination_delivery.h_serial_no) limit 1)";
|
|
|
|
|
+
|
|
|
|
|
+ $sql = "select consignee as code from public.kln_destination_delivery
|
|
|
|
|
+ where
|
|
|
|
|
+ status NOT IN ('Cancel', 'Reject')
|
|
|
|
|
+ AND delivery_date >= '".$month['month_start']."'
|
|
|
|
|
+ AND delivery_date <= '".$month['month_end']."' ".$sqlKNDDWhere;
|
|
|
|
|
+ $rs = common::excuteListSql($sql);
|
|
|
|
|
+
|
|
|
|
|
+ foreach($rs as $key => $val){
|
|
|
|
|
+ if(!empty($val['code'])){
|
|
|
|
|
+ $retData[] = array("value" =>$val['code'] ,"label"=>$val['code']);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ common::echo_json_encode(200,$retData);
|
|
|
|
|
+ exit();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -771,9 +802,14 @@ class destination_delivery {
|
|
|
if ($operate == "search_calendar"){
|
|
if ($operate == "search_calendar"){
|
|
|
|
|
|
|
|
$month = common::check_input($_POST ['month']); //current_page
|
|
$month = common::check_input($_POST ['month']); //current_page
|
|
|
|
|
+ $consignee = common::check_input($_POST ['consignee']);
|
|
|
$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'";
|
|
$sqlWhere .= " and eta >= now() - INTERVAL '6 months' and eta <= now() + INTERVAL '6 months'";
|
|
|
|
|
+ if(!empty($consignee)){
|
|
|
|
|
+ $sqlWhere .= " and consignee ilike '%".$consignee."%'";
|
|
|
|
|
+ }
|
|
|
|
|
+ $sqlKNDDWhere = "and exists(select 1 from public.kln_ocean ". $sqlWhere." and kln_ocean.serial_no = any(kln_destination_delivery.h_serial_no) limit 1)";
|
|
|
|
|
|
|
|
$search_calendar_sql = common::excuteOneSql("select item_value from public.config where item = 'Destination_Bookings_Calendar_Sql'");
|
|
$search_calendar_sql = common::excuteOneSql("select item_value from public.config where item = 'Destination_Bookings_Calendar_Sql'");
|
|
|
|
|
|
|
@@ -786,10 +822,33 @@ class destination_delivery {
|
|
|
$search_calendar_sql = str_replace('<{month_start}>', $month['month_start'], $search_calendar_sql);
|
|
$search_calendar_sql = str_replace('<{month_start}>', $month['month_start'], $search_calendar_sql);
|
|
|
$search_calendar_sql = str_replace('<{month_end}>', $month['month_end'], $search_calendar_sql);
|
|
$search_calendar_sql = str_replace('<{month_end}>', $month['month_end'], $search_calendar_sql);
|
|
|
$search_calendar_sql = str_replace('<{sqlWhere}>', $sqlWhere, $search_calendar_sql);
|
|
$search_calendar_sql = str_replace('<{sqlWhere}>', $sqlWhere, $search_calendar_sql);
|
|
|
|
|
+ $search_calendar_sql = str_replace('<{sqlKNDDWhere}>', $sqlKNDDWhere, $search_calendar_sql);
|
|
|
|
|
|
|
|
//error_log($search_calendar_sql);
|
|
//error_log($search_calendar_sql);
|
|
|
$result = common::excuteOneSql($search_calendar_sql);
|
|
$result = common::excuteOneSql($search_calendar_sql);
|
|
|
$result = json_decode($result,true);
|
|
$result = json_decode($result,true);
|
|
|
|
|
+
|
|
|
|
|
+ foreach($result as $index => $_result){
|
|
|
|
|
+ $size_arr = array();
|
|
|
|
|
+ foreach($_result['bookingDetail'] as $bookingDetail){
|
|
|
|
|
+ $oc_size_arr = explode(',', $bookingDetail['oc_size']);
|
|
|
|
|
+ foreach($oc_size_arr as $size){
|
|
|
|
|
+ if (!empty($size)) {
|
|
|
|
|
+ // 如果已经存在,加1;否则初始化为1
|
|
|
|
|
+ if (isset($size_arr[$size])) {
|
|
|
|
|
+ $size_arr[$size]++;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $size_arr[$size] = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $output = [];
|
|
|
|
|
+ foreach ($size_arr as $size => $count) {
|
|
|
|
|
+ $output[] = $size . '*' . $count;
|
|
|
|
|
+ }
|
|
|
|
|
+ $result[$index]['ctnrSize'] = $output;
|
|
|
|
|
+ }
|
|
|
common::echo_json_encode(200,$result);
|
|
common::echo_json_encode(200,$result);
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|
|
@@ -862,6 +921,7 @@ class destination_delivery {
|
|
|
$consignee_id = $_POST['consignee_id'];
|
|
$consignee_id = $_POST['consignee_id'];
|
|
|
$dc_country = $_POST['dc_country'];
|
|
$dc_country = $_POST['dc_country'];
|
|
|
$pakages = $_POST['pakages'];
|
|
$pakages = $_POST['pakages'];
|
|
|
|
|
+ $oc_size = $_POST['oc_size'];
|
|
|
|
|
|
|
|
$recommended_delivery_window_date_from = $_POST['recommended_delivery_from_date'];
|
|
$recommended_delivery_window_date_from = $_POST['recommended_delivery_from_date'];
|
|
|
$recommended_delivery_window_date_to = $_POST['recommended_delivery_to_date'];
|
|
$recommended_delivery_window_date_to = $_POST['recommended_delivery_to_date'];
|
|
@@ -955,7 +1015,7 @@ class destination_delivery {
|
|
|
//array("msg"=>"","result"=>$result);
|
|
//array("msg"=>"","result"=>$result);
|
|
|
$saveDataArr = $this->groupShipments($booking_no,$manifest_type,$h_bol,$h_serial_no,$order_from,$m_bol,$ctnr,$kln_pic,$consignee,$consignee_id,
|
|
$saveDataArr = $this->groupShipments($booking_no,$manifest_type,$h_bol,$h_serial_no,$order_from,$m_bol,$ctnr,$kln_pic,$consignee,$consignee_id,
|
|
|
$recommended_delivery_window_date_from, $recommended_delivery_window_date_to,
|
|
$recommended_delivery_window_date_from, $recommended_delivery_window_date_to,
|
|
|
- $recommended_delivery_from,$recommended_delivery_to,$dc_country,$pakages);
|
|
|
|
|
|
|
+ $recommended_delivery_from,$recommended_delivery_to,$dc_country,$pakages,$oc_size);
|
|
|
|
|
|
|
|
if(!empty($saveDataArr['msg'])){
|
|
if(!empty($saveDataArr['msg'])){
|
|
|
$data = array("msg" =>$saveDataArr['msg']);
|
|
$data = array("msg" =>$saveDataArr['msg']);
|
|
@@ -999,14 +1059,14 @@ class destination_delivery {
|
|
|
consignee, delivery_date, delivery_mode, status, delivery_address,delivery_address_detail, special_requirements,delivery_reference,
|
|
consignee, delivery_date, delivery_mode, status, delivery_address,delivery_address_detail, special_requirements,delivery_reference,
|
|
|
recommended_delivery_window_date_from, recommended_delivery_window_date_to, d_address_change_log,
|
|
recommended_delivery_window_date_from, recommended_delivery_window_date_to, d_address_change_log,
|
|
|
recommended_delivery_from, recommended_delivery_to,kln_pic,
|
|
recommended_delivery_from, recommended_delivery_to,kln_pic,
|
|
|
- create_by, created_time, modify_by, update_time,total_qty)
|
|
|
|
|
|
|
+ create_by, created_time, modify_by, update_time,total_qty,oc_size)
|
|
|
VALUES ('$serial_no', ".$tags_sql.",".$country_sql.",
|
|
VALUES ('$serial_no', ".$tags_sql.",".$country_sql.",
|
|
|
'".$booking_no_new."', '".utils::implode(',',$sData['h_bol'])."','".common::check_input(json_encode($sData['h_bol_multiple_link']))."',
|
|
'".$booking_no_new."', '".utils::implode(',',$sData['h_bol'])."','".common::check_input(json_encode($sData['h_bol_multiple_link']))."',
|
|
|
'".utils::implode(',',$sData['m_bol'])."', '".utils::implode(',',$sData['ctnr'])."',
|
|
'".utils::implode(',',$sData['m_bol'])."', '".utils::implode(',',$sData['ctnr'])."',
|
|
|
'".$sData['consignee']."', $delivery_date,'$delivery_mode','$status', '$delivery_address','$delivery_address_detail', '$special_requirements','$delivery_reference',
|
|
'".$sData['consignee']."', $delivery_date,'$delivery_mode','$status', '$delivery_address','$delivery_address_detail', '$special_requirements','$delivery_reference',
|
|
|
$recommended_delivery_window_date_from, $recommended_delivery_window_date_to,'',
|
|
$recommended_delivery_window_date_from, $recommended_delivery_window_date_to,'',
|
|
|
'".$sData['recommended_delivery_from']."', '".$sData['recommended_delivery_to']."','".$sData['kln_pic']."',
|
|
'".$sData['recommended_delivery_from']."', '".$sData['recommended_delivery_to']."','".$sData['kln_pic']."',
|
|
|
- '"._getLoginName()."', now(), '"._getLoginName()."', now(),'".$sData['pakages']."');";
|
|
|
|
|
|
|
+ '"._getLoginName()."', now(), '"._getLoginName()."', now(),'".$sData['pakages']."','".utils::implode(',',$sData['oc_size'])."');";
|
|
|
//记录log
|
|
//记录log
|
|
|
$sql .="INSERT INTO public.kln_destination_delivery_operation_log(
|
|
$sql .="INSERT INTO public.kln_destination_delivery_operation_log(
|
|
|
serial_no, action,notes, create_by, created_time, created_zone)
|
|
serial_no, action,notes, create_by, created_time, created_zone)
|
|
@@ -1018,7 +1078,7 @@ class destination_delivery {
|
|
|
$rs = common::excuteUpdateSql($sql);
|
|
$rs = common::excuteUpdateSql($sql);
|
|
|
if ($rs === FALSE){
|
|
if ($rs === FALSE){
|
|
|
$data = array("msg" =>"error");
|
|
$data = array("msg" =>"error");
|
|
|
- common::echo_json_encode(200,$data);
|
|
|
|
|
|
|
+ common::echo_json_encode(500,$data);
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1416,6 +1476,7 @@ class destination_delivery {
|
|
|
oc.unit as package_type ,
|
|
oc.unit as package_type ,
|
|
|
oc.grs_kgs::text as kgw,
|
|
oc.grs_kgs::text as kgw,
|
|
|
oc.cbm as volume,
|
|
oc.cbm as volume,
|
|
|
|
|
+ oc.size as oc_size,
|
|
|
ooc.vessel,
|
|
ooc.vessel,
|
|
|
ooc.voyage,
|
|
ooc.voyage,
|
|
|
ooc.carrier,
|
|
ooc.carrier,
|
|
@@ -1451,6 +1512,7 @@ class destination_delivery {
|
|
|
oc.unit as package_type ,
|
|
oc.unit as package_type ,
|
|
|
oc.grs_kgs::text as kgw,
|
|
oc.grs_kgs::text as kgw,
|
|
|
oc.cbm as volume,
|
|
oc.cbm as volume,
|
|
|
|
|
+ oc.size as oc_size,
|
|
|
ooc.vessel,
|
|
ooc.vessel,
|
|
|
ooc.voyage,
|
|
ooc.voyage,
|
|
|
ooc.carrier,
|
|
ooc.carrier,
|
|
@@ -1486,6 +1548,7 @@ class destination_delivery {
|
|
|
ooc.qty_uom as package_type ,
|
|
ooc.qty_uom as package_type ,
|
|
|
ooc.piece_count as kgw,
|
|
ooc.piece_count as kgw,
|
|
|
ooc.cbm as volume,
|
|
ooc.cbm as volume,
|
|
|
|
|
+ '' as oc_size,
|
|
|
ooc.vessel,
|
|
ooc.vessel,
|
|
|
ooc.voyage,
|
|
ooc.voyage,
|
|
|
ooc.carrier,
|
|
ooc.carrier,
|
|
@@ -1612,6 +1675,7 @@ class destination_delivery {
|
|
|
oc.unit as package_type ,
|
|
oc.unit as package_type ,
|
|
|
oc.grs_kgs::text as kgw,
|
|
oc.grs_kgs::text as kgw,
|
|
|
oc.cbm as volume,
|
|
oc.cbm as volume,
|
|
|
|
|
+ oc.size as oc_size,
|
|
|
ooc.vessel,
|
|
ooc.vessel,
|
|
|
ooc.voyage,
|
|
ooc.voyage,
|
|
|
ooc.carrier,
|
|
ooc.carrier,
|
|
@@ -1645,6 +1709,7 @@ class destination_delivery {
|
|
|
oc.unit as package_type ,
|
|
oc.unit as package_type ,
|
|
|
oc.grs_kgs::text as kgw,
|
|
oc.grs_kgs::text as kgw,
|
|
|
oc.cbm as volume,
|
|
oc.cbm as volume,
|
|
|
|
|
+ oc.size as oc_size,
|
|
|
ooc.vessel,
|
|
ooc.vessel,
|
|
|
ooc.voyage,
|
|
ooc.voyage,
|
|
|
ooc.carrier,
|
|
ooc.carrier,
|
|
@@ -1678,6 +1743,7 @@ class destination_delivery {
|
|
|
ooc.qty_uom as package_type ,
|
|
ooc.qty_uom as package_type ,
|
|
|
ooc.piece_count as kgw,
|
|
ooc.piece_count as kgw,
|
|
|
ooc.cbm as volume,
|
|
ooc.cbm as volume,
|
|
|
|
|
+ '' as oc_size,
|
|
|
ooc.vessel,
|
|
ooc.vessel,
|
|
|
ooc.voyage,
|
|
ooc.voyage,
|
|
|
ooc.carrier,
|
|
ooc.carrier,
|
|
@@ -1726,7 +1792,7 @@ class destination_delivery {
|
|
|
|
|
|
|
|
function groupShipments($booking_no, $manifest_type, $h_bol,$h_serial_no, $order_from,$m_bol, $ctnr,$kln_pic,$consignee,$consignee_id,
|
|
function groupShipments($booking_no, $manifest_type, $h_bol,$h_serial_no, $order_from,$m_bol, $ctnr,$kln_pic,$consignee,$consignee_id,
|
|
|
$recommended_delivery_window_date_from, $recommended_delivery_window_date_to,
|
|
$recommended_delivery_window_date_from, $recommended_delivery_window_date_to,
|
|
|
- $recommended_delivery_from,$recommended_delivery_to,$dc_country,$pakages){
|
|
|
|
|
|
|
+ $recommended_delivery_from,$recommended_delivery_to,$dc_country,$pakages,$oc_size){
|
|
|
// Combine the data into an array of shipments
|
|
// Combine the data into an array of shipments
|
|
|
$shipments = [];
|
|
$shipments = [];
|
|
|
foreach ($h_bol as $index => $_h_bol) {
|
|
foreach ($h_bol as $index => $_h_bol) {
|
|
@@ -1746,6 +1812,7 @@ class destination_delivery {
|
|
|
'consignee_id' => $consignee_id[$index],
|
|
'consignee_id' => $consignee_id[$index],
|
|
|
'dc_country' => $dc_country[$index],
|
|
'dc_country' => $dc_country[$index],
|
|
|
'pakages' => $pakages[$index],
|
|
'pakages' => $pakages[$index],
|
|
|
|
|
+ 'oc_size' => $oc_size[$index],
|
|
|
'recommended_delivery_window_date_from' => $recommended_delivery_window_date_from[$index],
|
|
'recommended_delivery_window_date_from' => $recommended_delivery_window_date_from[$index],
|
|
|
'recommended_delivery_window_date_to' => $recommended_delivery_window_date_to[$index],
|
|
'recommended_delivery_window_date_to' => $recommended_delivery_window_date_to[$index],
|
|
|
'recommended_delivery_from' => $recommended_delivery_from[$index],
|
|
'recommended_delivery_from' => $recommended_delivery_from[$index],
|
|
@@ -1767,6 +1834,7 @@ class destination_delivery {
|
|
|
$dc_country = $item['dc_country'];
|
|
$dc_country = $item['dc_country'];
|
|
|
$consignee_id = $item['consignee_id'];
|
|
$consignee_id = $item['consignee_id'];
|
|
|
$pakages = $item['pakages'];
|
|
$pakages = $item['pakages'];
|
|
|
|
|
+ $oc_size = $item['oc_size'];
|
|
|
|
|
|
|
|
if(strtoupper($item['manifest_type']) == 'BCN'){
|
|
if(strtoupper($item['manifest_type']) == 'BCN'){
|
|
|
if (!isset($groupedByMbol[$m_bol])) {
|
|
if (!isset($groupedByMbol[$m_bol])) {
|
|
@@ -1776,6 +1844,7 @@ class destination_delivery {
|
|
|
$item['ctnr'] = array();
|
|
$item['ctnr'] = array();
|
|
|
$item['dc_country'] = array();
|
|
$item['dc_country'] = array();
|
|
|
$item['consignee_id'] = array();
|
|
$item['consignee_id'] = array();
|
|
|
|
|
+ $item['oc_size'] = array();
|
|
|
$item['pakages'] = 0;
|
|
$item['pakages'] = 0;
|
|
|
$item['m_bol'] = array($item['m_bol']);
|
|
$item['m_bol'] = array($item['m_bol']);
|
|
|
$groupedByMbol[$m_bol] = $item;
|
|
$groupedByMbol[$m_bol] = $item;
|
|
@@ -1790,6 +1859,7 @@ class destination_delivery {
|
|
|
}
|
|
}
|
|
|
if (!in_array($ctnr, $groupedByMbol[$m_bol]['ctnr'])) {
|
|
if (!in_array($ctnr, $groupedByMbol[$m_bol]['ctnr'])) {
|
|
|
$groupedByMbol[$m_bol]['ctnr'][] = $ctnr;
|
|
$groupedByMbol[$m_bol]['ctnr'][] = $ctnr;
|
|
|
|
|
+ $groupedByMbol[$m_bol]['oc_size'][] = $oc_size;
|
|
|
$groupedByMbol[$m_bol]['pakages'] += intval($pakages);
|
|
$groupedByMbol[$m_bol]['pakages'] += intval($pakages);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
@@ -1801,6 +1871,7 @@ class destination_delivery {
|
|
|
$item['h_serial_no'] = array($item['h_serial_no']);
|
|
$item['h_serial_no'] = array($item['h_serial_no']);
|
|
|
$item['h_bol'] = array($item['h_bol']);
|
|
$item['h_bol'] = array($item['h_bol']);
|
|
|
$item['pakages'] = 0;
|
|
$item['pakages'] = 0;
|
|
|
|
|
+ $item['oc_size'] = array();
|
|
|
$item['h_bol_multiple_link'] = array(array("key"=>$h_bol,"value" =>$h_serial_no,"order_from"=>$order_from));
|
|
$item['h_bol_multiple_link'] = array(array("key"=>$h_bol,"value" =>$h_serial_no,"order_from"=>$order_from));
|
|
|
$groupedByShipmentId[$h_serial_no] = $item;
|
|
$groupedByShipmentId[$h_serial_no] = $item;
|
|
|
}
|
|
}
|
|
@@ -1811,6 +1882,7 @@ class destination_delivery {
|
|
|
|
|
|
|
|
if (!in_array($ctnr, $groupedByShipmentId[$h_serial_no]['ctnr'])) {
|
|
if (!in_array($ctnr, $groupedByShipmentId[$h_serial_no]['ctnr'])) {
|
|
|
$groupedByShipmentId[$h_serial_no]['ctnr'][] = $ctnr;
|
|
$groupedByShipmentId[$h_serial_no]['ctnr'][] = $ctnr;
|
|
|
|
|
+ $groupedByShipmentId[$h_serial_no]['oc_size'][] = $oc_size;
|
|
|
$groupedByShipmentId[$h_serial_no]['pakages'] += intval($pakages);
|
|
$groupedByShipmentId[$h_serial_no]['pakages'] += intval($pakages);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|