|
@@ -148,25 +148,67 @@ class destination_delivery {
|
|
|
* Manage Address load
|
|
* Manage Address load
|
|
|
*/
|
|
*/
|
|
|
if ($operate == "manage_address"){
|
|
if ($operate == "manage_address"){
|
|
|
- $consignee = $_REQUEST['consignee'];
|
|
|
|
|
|
|
+ $consignee = $_REQUEST['consignee_id'];
|
|
|
|
|
|
|
|
- $consignee =array('COMGEN38002','FGB050132','ATOZTI35005');
|
|
|
|
|
|
|
+ $consignee =array('COMGEN38002','FGB050132','ATOZTI35005','WILSON80001');
|
|
|
$more_param = common::getInNotInSqlForSearch(utils::implode(';',$consignee));
|
|
$more_param = common::getInNotInSqlForSearch(utils::implode(';',$consignee));
|
|
|
|
|
|
|
|
$country = $_REQUEST['country'];
|
|
$country = $_REQUEST['country'];
|
|
|
- $country =array('GB','DE');
|
|
|
|
|
|
|
+ $country =array('GB','DE','US');
|
|
|
$more_param_country = common::getInNotInSqlForSearch(utils::implode(';',$country));
|
|
$more_param_country = common::getInNotInSqlForSearch(utils::implode(';',$country));
|
|
|
|
|
|
|
|
- $sql = "SELECT * FROM public.contacts_address
|
|
|
|
|
- WHERE addr_type = 'D'
|
|
|
|
|
- and lower(contact_id) in ($more_param)
|
|
|
|
|
- and from_station in (select code from public.kerry_system_code where lower(category) in ($more_param_country))";
|
|
|
|
|
|
|
+ $delivery_serial_no = common::deCode($_REQUEST['delivery_serial_no'], 'D');
|
|
|
|
|
+ //$delivery_serial_no = 'c4d2951f438a4c9fccde37f26614740a';
|
|
|
|
|
+ if(!empty($delivery_serial_no)){
|
|
|
|
|
+ $sql = "SELECT addr1,addr2,addr3,addr4,
|
|
|
|
|
+ ctry_code,city_code,postal_code,
|
|
|
|
|
+ contact_person,contact_number,
|
|
|
|
|
+ create_user,contact_id,sync_key,
|
|
|
|
|
+ from_station,
|
|
|
|
|
+ 'from Ksmart' as op_action
|
|
|
|
|
+ FROM public.contacts_address ca
|
|
|
|
|
+ WHERE addr_type = 'D'
|
|
|
|
|
+ and lower(ca.contact_id) in (".$more_param.")
|
|
|
|
|
+ and ca.from_station in (select code from public.kerry_system_code where lower(category) in (".$more_param_country."))
|
|
|
|
|
+ and ca.sync_key not in (select sync_key from public.contacts_address_online where delivery_serial_no = '".$delivery_serial_no."')
|
|
|
|
|
+ union all
|
|
|
|
|
+ SELECT addr1,addr2,addr3,addr4,
|
|
|
|
|
+ ctry_code,city_code,postal_code,
|
|
|
|
|
+ contact_person,contact_number,
|
|
|
|
|
+ create_user,contact_id,sync_key,
|
|
|
|
|
+ from_station,
|
|
|
|
|
+ action as op_action
|
|
|
|
|
+ FROM public.contacts_address_online
|
|
|
|
|
+ where delivery_serial_no = '$delivery_serial_no'";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $sql = "SELECT addr1,addr2,addr3,addr4,
|
|
|
|
|
+ ctry_code,city_code,postal_code,
|
|
|
|
|
+ contact_person,contact_number,
|
|
|
|
|
+ create_user,contact_id,sync_key,
|
|
|
|
|
+ from_station,
|
|
|
|
|
+ 'from Ksmart' as op_action
|
|
|
|
|
+ FROM public.contacts_address ca
|
|
|
|
|
+ WHERE addr_type = 'D'
|
|
|
|
|
+ and lower(ca.contact_id) in (".$more_param.")
|
|
|
|
|
+ and ca.from_station in (select code from public.kerry_system_code where lower(category) in (".$more_param_country."))";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$data = common::excuteListSql($sql);
|
|
$data = common::excuteListSql($sql);
|
|
|
error_log($sql);
|
|
error_log($sql);
|
|
|
$manageAddressList = array();
|
|
$manageAddressList = array();
|
|
|
//Online_D_Address
|
|
//Online_D_Address
|
|
|
foreach($data as $d){
|
|
foreach($data as $d){
|
|
|
|
|
+ if ($d['op_action'] == "from Ksmart" && $d['create_user'] <> "Online_D_Address"){
|
|
|
|
|
+ $address_remark = "read-only";
|
|
|
|
|
+ } elseif ($d['op_action'] == "from Ksmart" && $d['create_user'] == "Online_D_Address"){
|
|
|
|
|
+ $address_remark = "reviewed";
|
|
|
|
|
+ } elseif ($d['op_action'] == "Add" && $d['create_user'] == "Online_D_Address"){
|
|
|
|
|
+ $address_remark = "unreviewed";
|
|
|
|
|
+ } elseif ($d['op_action'] == "Modify" && $d['create_user'] == "Online_D_Address"){
|
|
|
|
|
+ $address_remark = "unreviewed";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $address_remark = "deletion";
|
|
|
|
|
+ }
|
|
|
$manageAddressList[] = array(
|
|
$manageAddressList[] = array(
|
|
|
"address_1"=>$d['addr1'],
|
|
"address_1"=>$d['addr1'],
|
|
|
"address_2"=>$d['addr2'],
|
|
"address_2"=>$d['addr2'],
|
|
@@ -175,13 +217,15 @@ class destination_delivery {
|
|
|
"country"=>$d['ctry_code'],
|
|
"country"=>$d['ctry_code'],
|
|
|
"city"=>$d['city_code'],
|
|
"city"=>$d['city_code'],
|
|
|
"postal_code"=>$d['postal_code'],
|
|
"postal_code"=>$d['postal_code'],
|
|
|
- "contact_person"=>$d['contact_person'],
|
|
|
|
|
- "contact_number" =>$d['contact_number'],
|
|
|
|
|
|
|
+ "contact_person"=>$d['contact_person'] === null ? '' : $d['contact_person'],
|
|
|
|
|
+ "contact_number" =>$d['contact_number'] === null ? '' : $d['contact_number'],
|
|
|
"create_user" => $d['create_user'], //create_user = Online_D_Address 时,代表對客戶賬號類型自己創建的D類地址
|
|
"create_user" => $d['create_user'], //create_user = Online_D_Address 时,代表對客戶賬號類型自己創建的D類地址
|
|
|
"contact_id" => $d['contact_id'],
|
|
"contact_id" => $d['contact_id'],
|
|
|
"sync_key" => $d['sync_key'], //唯一key
|
|
"sync_key" => $d['sync_key'], //唯一key
|
|
|
"from_station" => $d['from_station'], //只有是客户新键的才会特殊处理station Online_GE. 好判断是那个国家的
|
|
"from_station" => $d['from_station'], //只有是客户新键的才会特殊处理station Online_GE. 好判断是那个国家的
|
|
|
- "contact_type" => "Unedit"
|
|
|
|
|
|
|
+ "contact_type" => "Unedit", //这个前端控制的
|
|
|
|
|
+ "op_action" => $d['op_action'],
|
|
|
|
|
+ "address_remark" => $address_remark
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
common::echo_json_encode(200,$manageAddressList);
|
|
common::echo_json_encode(200,$manageAddressList);
|
|
@@ -709,8 +753,13 @@ class destination_delivery {
|
|
|
|
|
|
|
|
$booking_data = array();
|
|
$booking_data = array();
|
|
|
if(!empty($serial_no)){
|
|
if(!empty($serial_no)){
|
|
|
- $sql = "select * from public.kln_destination_delivery where serial_no = '$serial_no'";
|
|
|
|
|
|
|
+ //to_char(delivery_date, 'MM/DD/YYYY') AS _delivery_date,
|
|
|
|
|
+ $sql = "select *,
|
|
|
|
|
+ to_char(delivery_date, 'HH24:MI') AS _delivery_time
|
|
|
|
|
+ from public.kln_destination_delivery where serial_no = '$serial_no'";
|
|
|
$booking_data = common::excuteObjectSql($sql);
|
|
$booking_data = common::excuteObjectSql($sql);
|
|
|
|
|
+ $booking_data["delivery_time"] = $booking_data["_delivery_time"];
|
|
|
|
|
+ $booking_data["delivery_address_detail"] = json_decode($booking_data["delivery_address_detail"],true);
|
|
|
$shipments = $this->search_shipment_with_booking($booking_data['serial_no'],$booking_data['h_serial_no'],$booking_data['ctnr']);
|
|
$shipments = $this->search_shipment_with_booking($booking_data['serial_no'],$booking_data['h_serial_no'],$booking_data['ctnr']);
|
|
|
} else {
|
|
} else {
|
|
|
$shipments = $this->search_shipment();
|
|
$shipments = $this->search_shipment();
|
|
@@ -759,6 +808,7 @@ class destination_delivery {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$delivery_address = common::check_input($_POST['delivery_address']);
|
|
$delivery_address = common::check_input($_POST['delivery_address']);
|
|
|
|
|
+ $delivery_address_detail = common::check_input(json_encode(common::returnDAddress(),JSON_UNESCAPED_UNICODE));
|
|
|
$special_requirements = common::check_input($_POST['special_requirements']);
|
|
$special_requirements = common::check_input($_POST['special_requirements']);
|
|
|
|
|
|
|
|
//检查不能重复添加booking 这里空运没问题,但是会遇到相同hbol 不同的柜子情况,本质上来说就是一条
|
|
//检查不能重复添加booking 这里空运没问题,但是会遇到相同hbol 不同的柜子情况,本质上来说就是一条
|
|
@@ -790,10 +840,9 @@ class destination_delivery {
|
|
|
if (!empty($status)) {
|
|
if (!empty($status)) {
|
|
|
$updateSqlSet.= ", status = '$status' ";
|
|
$updateSqlSet.= ", status = '$status' ";
|
|
|
}
|
|
}
|
|
|
- $delivery_address = $_POST['location_name']."\n".$_POST['address_1']."\n".$_POST['address_2']."\nContact:".$_POST['contact_person']." ".$_POST['contact_number'];
|
|
|
|
|
- $delivery_address = common::check_input($delivery_address);
|
|
|
|
|
if (!empty($delivery_address)) {
|
|
if (!empty($delivery_address)) {
|
|
|
$updateSqlSet.= ", delivery_address = '$delivery_address' ";
|
|
$updateSqlSet.= ", delivery_address = '$delivery_address' ";
|
|
|
|
|
+ $updateSqlSet.= ", delivery_address_detail = '$delivery_address_detail' ";
|
|
|
}
|
|
}
|
|
|
if (!empty($special_requirements)) {
|
|
if (!empty($special_requirements)) {
|
|
|
$updateSqlSet.= ", special_requirements = '$special_requirements' ";
|
|
$updateSqlSet.= ", special_requirements = '$special_requirements' ";
|
|
@@ -803,14 +852,11 @@ class destination_delivery {
|
|
|
}
|
|
}
|
|
|
if (!empty($delivery_date)) {
|
|
if (!empty($delivery_date)) {
|
|
|
$delivery_date = empty($_POST['delivery_date']) ? "null": "'".common::usDate2sqlDate($_POST['delivery_date'])." ".$delivery_time."'";
|
|
$delivery_date = empty($_POST['delivery_date']) ? "null": "'".common::usDate2sqlDate($_POST['delivery_date'])." ".$delivery_time."'";
|
|
|
- //$updateSqlSet.= ", delivery_date = $delivery_date";
|
|
|
|
|
|
|
+ $updateSqlSet.= ", delivery_date = $delivery_date";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $addressSql = common::returnDAddressRecord($dc_country,$consignee_id);
|
|
|
|
|
- if (!empty($addressSql)) {
|
|
|
|
|
- $updateSqlSet.= ", d_address_change_log = d_address_change_log ||';'||'".common::check_input($addressSql)."' ";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //修改记录临时表
|
|
|
|
|
+ common::saveDAddressTempTable($serial_no,$consignee_id);
|
|
|
//代表update
|
|
//代表update
|
|
|
$sql .= "update public.kln_destination_delivery set ".$updateSqlSet."
|
|
$sql .= "update public.kln_destination_delivery set ".$updateSqlSet."
|
|
|
where serial_no = '$serial_no';";
|
|
where serial_no = '$serial_no';";
|
|
@@ -824,9 +870,6 @@ class destination_delivery {
|
|
|
$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);
|
|
$recommended_delivery_from,$recommended_delivery_to,$dc_country);
|
|
|
|
|
|
|
|
- $delivery_address = $_POST['location_name']."\n".$_POST['address_1']."\n".$_POST['address_2']."\nContact:".$_POST['contact_person']." ".$_POST['contact_number'];
|
|
|
|
|
- $delivery_address = common::check_input($delivery_address);
|
|
|
|
|
-
|
|
|
|
|
foreach($saveData as $sData){
|
|
foreach($saveData as $sData){
|
|
|
$serial_no = common::uuid();
|
|
$serial_no = common::uuid();
|
|
|
|
|
|
|
@@ -850,21 +893,23 @@ class destination_delivery {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$delivery_date = empty($_POST['delivery_date']) ? "null": "'".common::usDate2sqlDate($_POST['delivery_date'])." ".$delivery_time."'";
|
|
$delivery_date = empty($_POST['delivery_date']) ? "null": "'".common::usDate2sqlDate($_POST['delivery_date'])." ".$delivery_time."'";
|
|
|
- $addressSql = common::check_input(common::returnDAddressRecord($sData['dc_country'],$sData['consignee_id']));
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //修改记录临时表
|
|
|
|
|
+ common::saveDAddressTempTable($serial_no,$sData['consignee_id']);
|
|
|
|
|
|
|
|
$sql .= "INSERT INTO public.kln_destination_delivery(
|
|
$sql .= "INSERT INTO public.kln_destination_delivery(
|
|
|
serial_no, h_serial_no,address_country,
|
|
serial_no, h_serial_no,address_country,
|
|
|
booking_no, h_bol,h_bol_multiple_link,
|
|
booking_no, h_bol,h_bol_multiple_link,
|
|
|
m_bol, ctnr,
|
|
m_bol, ctnr,
|
|
|
- consignee, delivery_date, delivery_mode, status, delivery_address, special_requirements,
|
|
|
|
|
|
|
+ consignee, delivery_date, delivery_mode, status, delivery_address,delivery_address_detail, special_requirements,
|
|
|
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)
|
|
create_by, created_time, modify_by, update_time)
|
|
|
VALUES ('$serial_no', ".$tags_sql.",".$country_sql.",
|
|
VALUES ('$serial_no', ".$tags_sql.",".$country_sql.",
|
|
|
'".$sData['booking_no']."', '".utils::implode(',',$sData['h_bol'])."','".common::check_input(json_encode($sData['h_bol_multiple_link']))."',
|
|
'".$sData['booking_no']."', '".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', '$special_requirements',
|
|
|
|
|
- $recommended_delivery_window_date_from, $recommended_delivery_window_date_to,'$addressSql',
|
|
|
|
|
|
|
+ '".$sData['consignee']."', $delivery_date,'$delivery_mode','$status', '$delivery_address','$delivery_address_detail', '$special_requirements',
|
|
|
|
|
+ $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());";
|
|
'"._getLoginName()."', now(), '"._getLoginName()."', now());";
|
|
|
//记录log
|
|
//记录log
|
|
@@ -924,37 +969,38 @@ class destination_delivery {
|
|
|
//前端按钮 后台权限拦截
|
|
//前端按钮 后台权限拦截
|
|
|
common::checkedActionLegal($serial_no,$operate);
|
|
common::checkedActionLegal($serial_no,$operate);
|
|
|
$sql = "";
|
|
$sql = "";
|
|
|
- $update_str = "";
|
|
|
|
|
//审核通过时,才取下放当时应用修改的地址
|
|
//审核通过时,才取下放当时应用修改的地址
|
|
|
if ($status == "Approve") {
|
|
if ($status == "Approve") {
|
|
|
- $addressSql = common::excuteOneSql("select d_address_change_log from public.kln_destination_delivery where serial_no = '$serial_no'");
|
|
|
|
|
- if(!empty($addressSql)){
|
|
|
|
|
- $sql .=$addressSql;
|
|
|
|
|
- }
|
|
|
|
|
- $update_str = "d_address_change_log = null";
|
|
|
|
|
|
|
+ $address_country = common::excuteOneSql("select array_to_json(address_country) as address_country from public.kln_destination_delivery where serial_no = '$serial_no'");
|
|
|
|
|
+ $onine_address = common::excuteListSql("select * from public.contacts_address_online where delivery_serial_no = '$serial_no'");
|
|
|
|
|
+ $sql .= "delete from public.contacts_address_online where delivery_serial_no = '$serial_no';";
|
|
|
|
|
+ $sql .=common::returnDAddressRecord($address_country,$onine_address);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $sql .= "update public.kln_destination_delivery set ".$update_str.",status = '$status', modify_by = '"._getLoginName()."',update_time = now() where serial_no = '$serial_no';";
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $sql .= "update public.kln_destination_delivery set status = '$status', modify_by = '"._getLoginName()."',update_time = now() where serial_no = '$serial_no';";
|
|
|
$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)
|
|
|
VALUES ('$serial_no', '$status','$notes', '$action_user', now(), ''); ";
|
|
VALUES ('$serial_no', '$status','$notes', '$action_user', now(), ''); ";
|
|
|
|
|
|
|
|
- common::excuteUpdateSql($sql);
|
|
|
|
|
-
|
|
|
|
|
- //状态变更时,发送邮件提醒
|
|
|
|
|
- $data = common::excuteObjectSql("select *,
|
|
|
|
|
- TO_CHAR(delivery_date, 'Mon-DD-YYYY') as _delivery_date,
|
|
|
|
|
- TO_CHAR(created_time, 'Mon-DD-YYYY') as _created_time,
|
|
|
|
|
- TO_CHAR(update_time, 'Mon-DD-YYYY') as _update_time
|
|
|
|
|
- from public.kln_destination_delivery where serial_no = '$serial_no'");
|
|
|
|
|
- $shipmentsData = $this->search_shipment_with_booking($data['serial_no'],$data['h_serial_no'],$data['ctnr']);
|
|
|
|
|
- $email_sql = common::sendDestinationDeliveryReminder($data,$shipmentsData,$status);
|
|
|
|
|
- if(!empty($email_sql)){
|
|
|
|
|
- common::excuteUpdateSql($email_sql);
|
|
|
|
|
- }
|
|
|
|
|
- $data = array("msg" =>"success");
|
|
|
|
|
- common::echo_json_encode(200,$data);
|
|
|
|
|
|
|
+ $rs = common::excuteUpdateSql($sql);
|
|
|
|
|
+ if ($rs === FALSE){
|
|
|
|
|
+ $data = array("msg" => "Update Error");
|
|
|
|
|
+ common::echo_json_encode(200,$data);
|
|
|
|
|
+ } else{
|
|
|
|
|
+ //状态变更时,发送邮件提醒
|
|
|
|
|
+ $data = common::excuteObjectSql("select *,
|
|
|
|
|
+ TO_CHAR(delivery_date, 'Mon-DD-YYYY') as _delivery_date,
|
|
|
|
|
+ TO_CHAR(created_time, 'Mon-DD-YYYY') as _created_time,
|
|
|
|
|
+ TO_CHAR(update_time, 'Mon-DD-YYYY') as _update_time
|
|
|
|
|
+ from public.kln_destination_delivery where serial_no = '$serial_no'");
|
|
|
|
|
+ $shipmentsData = $this->search_shipment_with_booking($data['serial_no'],$data['h_serial_no'],$data['ctnr']);
|
|
|
|
|
+ $email_sql = common::sendDestinationDeliveryReminder($data,$shipmentsData,$status);
|
|
|
|
|
+ if(!empty($email_sql)){
|
|
|
|
|
+ common::excuteUpdateSql($email_sql);
|
|
|
|
|
+ }
|
|
|
|
|
+ $data = array("msg" =>"success");
|
|
|
|
|
+ common::echo_json_encode(200,$data);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|