|
|
@@ -3837,7 +3837,8 @@ class common {
|
|
|
$_contact_type = common::check_input($_POST['contact_type'][$key]);
|
|
|
$_create_user = common::check_input($_POST['create_user'][$key]);
|
|
|
|
|
|
- if ($_contact_type == "Add"){
|
|
|
+ //为空的代表新加 _contact_type在非Unedit 和 Delete时,判断新加前端有bug, 先添加,立即修改。状态会从add 变成 moidfy,这个是有问题。
|
|
|
+ if (empty($_sync_key)){
|
|
|
$uniqueAC =array();
|
|
|
foreach($consignee_id as $ck => $_consignee_id){
|
|
|
$_add_create_user = "Online_D_Address";
|
|
|
@@ -3865,63 +3866,54 @@ class common {
|
|
|
if(!empty($_sync_key)){
|
|
|
$_add_create_user = "Online_D_Address";
|
|
|
if($_contact_type == "Unedit"){
|
|
|
- $_add_create_user = $_create_user;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $_is_delete = 'f';
|
|
|
+ if ($_contact_type == "Delete"){
|
|
|
+ $_is_delete = 't';
|
|
|
}
|
|
|
- $exist = common::excuteObjectSql("select sync_key,action from public.contacts_address_online where sync_key = '$_sync_key' and delivery_serial_no = '$delivery_serial_no'");
|
|
|
+
|
|
|
+ $exist = common::excuteObjectSql("select sync_key,action from public.contacts_address_online where sync_key = '$_sync_key'");
|
|
|
if(empty($exist)){
|
|
|
$addressSql .= "INSERT INTO public.contacts_address_online(
|
|
|
delivery_serial_no,action,
|
|
|
addr_type,contact_id, addr1, addr2,addr3, addr4,
|
|
|
ctry_code, city_code, postal_code,
|
|
|
create_user, create_date, modify_user, modify_date,
|
|
|
- is_sync_country, sync_key, from_station,contact_person,contact_number)
|
|
|
+ is_sync_country, sync_key, from_station,contact_person,contact_number,is_delete)
|
|
|
VALUES ('$delivery_serial_no','$_contact_type',
|
|
|
'D','$_contact_id','$_address_1','$_address_2','$_address_3','$_address_4',
|
|
|
'$_country','$_city','$_postal_code',
|
|
|
'$_add_create_user',now(),'$_add_create_user',now(),
|
|
|
- true,'$_sync_key','$_from_station','$_contact_person','$_contact_number');";
|
|
|
+ true,'$_sync_key','$_from_station','$_contact_person','$_contact_number','$_is_delete');";
|
|
|
} else {
|
|
|
- if ($_contact_type == "Delete" && $exist['action'] == "Add"){
|
|
|
- //代表未审核新加的,这次提交为删除
|
|
|
- $addressSql .= "delete from public.contacts_address_online where sync_key = '$_sync_key' and delivery_serial_no = '$delivery_serial_no';";
|
|
|
- }
|
|
|
- // elseif ($_contact_type == "Delete" && ($exist['action'] == "Modify" || $exist['action'] == "Unedit")){
|
|
|
- // //代表未审核编辑的,这次提交为删除,修改action固定为Detele
|
|
|
- // $addressSql .="UPDATE public.contacts_address_online
|
|
|
- // SET addr1='$_address_1', addr2='$_address_2', addr3='$_address_3', addr4='$_address_4',
|
|
|
- // ctry_code='$_country', city_code='$_city', postal_code='$_postal_code',
|
|
|
- // modify_user='$_add_create_user', modify_date=now(),
|
|
|
- // contact_person='$_contact_person', contact_number='$_contact_number',
|
|
|
- // action='Delete'
|
|
|
- // WHERE sync_key = '$_sync_key' and delivery_serial_no = '$delivery_serial_no';";
|
|
|
- // }
|
|
|
- else {
|
|
|
- //Modify Unedit :如果是用户完全新加的,这里不做action的修改,保留记录的Add
|
|
|
- $temp_action = $_contact_type;
|
|
|
- if ($exist['action'] == "Add"){
|
|
|
- $temp_action = "Add";
|
|
|
- }
|
|
|
- $addressSql .="UPDATE public.contacts_address_online
|
|
|
- SET addr1='$_address_1', addr2='$_address_2', addr3='$_address_3', addr4='$_address_4',
|
|
|
- ctry_code='$_country', city_code='$_city', postal_code='$_postal_code',
|
|
|
- modify_user='$_add_create_user', modify_date=now(),
|
|
|
- contact_person='$_contact_person', contact_number='$_contact_number',
|
|
|
- action='$temp_action'
|
|
|
- WHERE sync_key = '$_sync_key' and delivery_serial_no = '$delivery_serial_no';";
|
|
|
-
|
|
|
+ //Modify Unedit :如果是用户完全新加的,这里不做action的修改,保留记录的Add
|
|
|
+ $temp_action = $_contact_type;
|
|
|
+ if ($exist['action'] == "Add"){
|
|
|
+ $temp_action = "Add";
|
|
|
}
|
|
|
+
|
|
|
+ $addressSql .="UPDATE public.contacts_address_online
|
|
|
+ SET delivery_serial_no = '$delivery_serial_no',addr1='$_address_1', addr2='$_address_2', addr3='$_address_3', addr4='$_address_4',
|
|
|
+ ctry_code='$_country', city_code='$_city', postal_code='$_postal_code',
|
|
|
+ modify_user='$_add_create_user', modify_date=now(),
|
|
|
+ contact_person='$_contact_person', contact_number='$_contact_number',
|
|
|
+ action='$temp_action', is_delete = '$_is_delete'
|
|
|
+ WHERE sync_key = '$_sync_key';";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- common::excuteUpdateSql($addressSql);
|
|
|
+ if(!empty($addressSql)){
|
|
|
+ common::excuteUpdateSql($addressSql);
|
|
|
+ }
|
|
|
return $_sync_key_add;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 审核通过时,才取下放当时应用修改的地址
|
|
|
*/
|
|
|
- public static function returnDAddressRecord($address_country,$onine_address){
|
|
|
+ public static function returnDAddressRecord($address_country,$onine_address,$delivery_address_detail){
|
|
|
//deliver address is new
|
|
|
$addressSql = "";
|
|
|
$address_country = json_decode($address_country,true);
|
|
|
@@ -3931,8 +3923,8 @@ class common {
|
|
|
$_address_2 = common::check_input($_onine_address['addr2']);
|
|
|
$_address_3 = common::check_input($_onine_address['addr3']);
|
|
|
$_address_4 = common::check_input($_onine_address['addr4']);
|
|
|
- $_country = common::check_input($_onine_address['ctry_code']);
|
|
|
- $_city = common::check_input($_onine_address['city_code']);
|
|
|
+ $_ctry_code = common::check_input($_onine_address['ctry_code']);
|
|
|
+ $_city_code = common::check_input($_onine_address['city_code']);
|
|
|
$_postal_code = common::check_input($_onine_address['postal_code']);
|
|
|
$_contact_person = common::check_input($_onine_address['contact_person']);
|
|
|
$_contact_number = common::check_input($_onine_address['contact_number']);
|
|
|
@@ -3941,12 +3933,9 @@ class common {
|
|
|
$_sync_key = common::check_input($_onine_address['sync_key']);
|
|
|
$_from_station = strtoupper(common::check_input($_onine_address['from_station']));
|
|
|
$_contact_type = common::check_input($_onine_address['action']);
|
|
|
+ $_is_delete = common::check_input($_onine_address['is_delete']);
|
|
|
|
|
|
- //适应前端逻辑,如果遇到Unedit 代表该地址未变动,移除变动记录里
|
|
|
- if ($_contact_type == "Unedit"){
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
+ $addressSql .= "delete from public.contacts_address_online WHERE sync_key = '$_sync_key';";
|
|
|
$uniqueAC =array();
|
|
|
foreach($address_country as $ck => $_country){
|
|
|
if(utils::in_array($_country,$uniqueAC)){
|
|
|
@@ -3954,57 +3943,36 @@ class common {
|
|
|
}
|
|
|
$uniqueAC[] = $_country;
|
|
|
|
|
|
- //如果需要新加的时候 用户固定名称,用作标记 //contact_person,contact_number '$_contact_person','$_contact_number'
|
|
|
$_add_create_user = "Online_D_Address";
|
|
|
- if ($_contact_type == "Add"){
|
|
|
- if(empty($_sync_key)){
|
|
|
- continue;
|
|
|
- }
|
|
|
- $from_station = "ONLINE_".strtoupper($_country);
|
|
|
- $addressSql .= "INSERT INTO public.contacts_address(
|
|
|
- addr_type,contact_id, addr1, addr2,addr3, addr4,
|
|
|
- ctry_code, city_code, postal_code,
|
|
|
- create_user, create_date, modify_user, modify_date,
|
|
|
- is_sync_country, sync_key, from_station)
|
|
|
- VALUES ('D','$_contact_id','$_address_1','$_address_2','$_address_3','$_address_4',
|
|
|
- '$_country','$_city','$_postal_code',
|
|
|
- '$_add_create_user',now(),'$_add_create_user',now(),
|
|
|
- true,'$_sync_key','$from_station');";
|
|
|
+ $from_station = "ONLINE_".strtoupper($_country);
|
|
|
+
|
|
|
+ $_sync_key_new = $_sync_key;
|
|
|
+ if($ck > 0){
|
|
|
+ $_sync_key_new = common::uuid();
|
|
|
}
|
|
|
- if ($_contact_type == "Modify"){
|
|
|
- //代表在一个国家内的编辑 //contact_person='$_contact_person', contact_number='$_contact_number'
|
|
|
- $from_station_country = "";
|
|
|
- if (strpos($_from_station, "ONLINE_") === 0) { // 确保字符串以 ONLINE_ 开头
|
|
|
- $from_station_country = substr($_from_station, strlen("ONLINE_"));
|
|
|
- }
|
|
|
- if($from_station_country == $_country){
|
|
|
+
|
|
|
+ $existData = common::excuteObjectSql("select sync_key FROM public.contacts_address WHERE sync_key = '$_sync_key' and from_station = '$from_station'");
|
|
|
+ if ($delivery_address_detail['sync_key'] == $_sync_key) {
|
|
|
+ if(!empty($existData) && !empty($existData['sync_key'])){
|
|
|
$addressSql .= "UPDATE public.contacts_address
|
|
|
SET addr1='$_address_1', addr2='$_address_2',
|
|
|
- ctry_code='$_country', city_code='$_city', postal_code='$_postal_code',
|
|
|
+ ctry_code='$_ctry_code', city_code='$_city_code', postal_code='$_postal_code',
|
|
|
modify_user='"._getLoginName()."', modify_date=now()
|
|
|
WHERE sync_key = '$_sync_key';";
|
|
|
} else {
|
|
|
- if(empty($_sync_key)){
|
|
|
- continue;
|
|
|
- }
|
|
|
- $from_station = "ONLINE_".strtoupper($_country);
|
|
|
$addressSql .= "INSERT INTO public.contacts_address(
|
|
|
addr_type,contact_id, addr1, addr2,addr3, addr4,
|
|
|
ctry_code, city_code, postal_code,
|
|
|
create_user, create_date, modify_user, modify_date,
|
|
|
is_sync_country, sync_key, from_station)
|
|
|
VALUES ('D','$_contact_id','$_address_1','$_address_2','$_address_3','$_address_4',
|
|
|
- '$_country','$_city','$_postal_code',
|
|
|
+ '$_ctry_code','$_city_code','$_postal_code',
|
|
|
'$_add_create_user',now(),'$_add_create_user',now(),
|
|
|
- true,'$_sync_key','$from_station');";
|
|
|
+ true,'$_sync_key_new','$from_station');";
|
|
|
}
|
|
|
- }
|
|
|
- if ($_contact_type == "Delete"){
|
|
|
- $from_station_country = "";
|
|
|
- if (strpos($_from_station, "ONLINE_") === 0) { // 确保字符串以 ONLINE_ 开头
|
|
|
- $from_station_country = substr($_from_station, strlen("ONLINE_"));
|
|
|
- }
|
|
|
- if($from_station_country == $_country){
|
|
|
+ } else {
|
|
|
+ //除开当前编辑的提交的,就只有用户自己删除要处理,其他的修改最后未选的情况留在本地管理
|
|
|
+ if ($_is_delete == 't' && !empty($existData) && !empty($existData['sync_key'])){
|
|
|
$addressSql .= "DELETE FROM public.contacts_address WHERE sync_key = '$_sync_key';";
|
|
|
}
|
|
|
}
|
|
|
@@ -4041,7 +4009,8 @@ class common {
|
|
|
$_from_station = $_POST['from_station'][$key];
|
|
|
$_contact_type = $_POST['contact_type'][$key];
|
|
|
|
|
|
- if($_contact_type == "Add"){
|
|
|
+ //if($_contact_type == "Add"){
|
|
|
+ if(!empty($_sync_key_add)){
|
|
|
//add 这么生成的唯一key
|
|
|
$_sync_key = $_sync_key_add;
|
|
|
}
|
|
|
@@ -4132,7 +4101,7 @@ class common {
|
|
|
est_delivery_date, est_delivery_time,instructions,
|
|
|
create_user, create_time,delivery_vehicle_type,delivery_fuel_type,
|
|
|
consignee, consignee_name, consignee_exp,delivery_to_address_sync_key,
|
|
|
- delivery_reference)
|
|
|
+ refno)
|
|
|
VALUES ('".$do_serial_no."','".$detail_row_count."','Ocean', '".$oceanInfo['agent']."','".$biztype."','Awaiting Confirmation','".$mode_type."',
|
|
|
'".$serial_no."','".$oceanInfo['m_bol']."','".$oceanInfo['h_bol']."','".$oceanInfo['job_no']."',now(),
|
|
|
".$total_pcs.",'".$total_pcs_unit."',".$total_weight.",'".$total_weight_unit."',".$total_volume.",'".$total_volume_unit."',
|