Bladeren bron

delivery and robat code

ShuanghongS 3 maanden geleden
bovenliggende
commit
188113bc5e
4 gewijzigde bestanden met toevoegingen van 243 en 79 verwijderingen
  1. 1 0
      include.ini.php
  2. 12 12
      main_new_version.php
  3. 95 49
      service/destination_delivery.class.php
  4. 135 18
      utils/common.class.php

+ 1 - 0
include.ini.php

@@ -70,6 +70,7 @@ if (!empty($tar["item_value"])&&$tar["item_value"]=="TOPOCEAN") {
 
 function _isApexLogin() {
     return strtolower($_SESSION['ONLINE_USER']['user_type']) == "employee";
+    //return false;
 }
 
 function _isAdmin() {

+ 12 - 12
main_new_version.php

@@ -91,24 +91,24 @@ switch ($action) {
                     }
                     //单独拼接URL
                     foreach ($ll as $v) {
-                        if($v['s_column'] =="Ocean Booking" || $v['s_column'] =="Ocean B/L Info."){
+                        //if($v['s_column'] =="Ocean Booking" || $v['s_column'] =="Ocean B/L Info."){
+                        if($v['s_column'] =="Ocean B/L Info."){
                             $urlData = $menuSetting[$v['s_column']];
                             $menuList[] = array("index"=>"$index","label"=>$urlData['label'],"icon"=>$urlData['icon'],"path"=>$urlData['path']);
                             $index = $index + 1;
                         }
                         //特殊处理book,需要加二级菜
-                        // if($v['s_column'] =="Ocean Booking"){
+                        if($v['s_column'] =="Ocean Booking"){
+                            $bookingManagement = array("index"=>"$index","label"=>"Booking","icon"=>"icon_booking__fill_b","type"=>"list");
+                            $children  = array(); 
 
-                        //     $bookingManagement = array("index"=>"$index","label"=>"Booking","icon"=>"icon_booking__fill_b","type"=>"list");
-                        //     $children  = array(); 
-
-                        //     $urlData = $menuSetting[$v['s_column']];
-                        //     $children[] = array("index"=>$index.'-1',"label"=>$urlData['label'],"path"=>$urlData['path']);
-                        //     $children[] = array("index"=>$index.'-2',"label"=>"Destination Delivery","path"=>"/destination-delivery");
-                        //     $bookingManagement["children"] = $children;
-                        //     $menuList[] = $bookingManagement;
-                        //     $index = $index + 1;
-                        // }
+                            $urlData = $menuSetting[$v['s_column']];
+                            $children[] = array("index"=>$index.'-1',"label"=>$urlData['label'],"path"=>$urlData['path']);
+                            $children[] = array("index"=>$index.'-2',"label"=>"Destination Delivery","path"=>"/destination-delivery");
+                            $bookingManagement["children"] = $children;
+                            $menuList[] = $bookingManagement;
+                            $index = $index + 1;
+                        }
                     }
                 }
             }

+ 95 - 49
service/destination_delivery.class.php

@@ -148,25 +148,67 @@ class destination_delivery {
          *  Manage Address load
         */
         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));
 
             $country = $_REQUEST['country'];
-            $country =array('GB','DE');
+            $country =array('GB','DE','US');
             $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);
             error_log($sql);
             $manageAddressList = array();
             //Online_D_Address
             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(
                     "address_1"=>$d['addr1'],
                     "address_2"=>$d['addr2'],
@@ -175,13 +217,15 @@ class destination_delivery {
                     "country"=>$d['ctry_code'],
                     "city"=>$d['city_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類地址
                     "contact_id" => $d['contact_id'],
                     "sync_key" => $d['sync_key'],         //唯一key 
                     "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);
@@ -709,8 +753,13 @@ class destination_delivery {
 
             $booking_data = array();
             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["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']);
             } else {
                 $shipments = $this->search_shipment();
@@ -759,6 +808,7 @@ class destination_delivery {
             }
         
             $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']);
 
             //检查不能重复添加booking  这里空运没问题,但是会遇到相同hbol 不同的柜子情况,本质上来说就是一条
@@ -790,10 +840,9 @@ class destination_delivery {
                 if (!empty($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)) {
                     $updateSqlSet.= ", delivery_address = '$delivery_address' ";
+                    $updateSqlSet.= ", delivery_address_detail = '$delivery_address_detail' ";
                 }
                 if (!empty($special_requirements)) {
                     $updateSqlSet.= ", special_requirements = '$special_requirements' ";
@@ -803,14 +852,11 @@ class destination_delivery {
                 }
                 if (!empty($delivery_date)) {
                     $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 
                 $sql .= "update public.kln_destination_delivery set ".$updateSqlSet."
                     where serial_no = '$serial_no';"; 
@@ -824,9 +870,6 @@ class destination_delivery {
                     $recommended_delivery_window_date_from, $recommended_delivery_window_date_to,
                     $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){
                     $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."'";
-                    $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(
                             serial_no, h_serial_no,address_country,
                             booking_no, h_bol,h_bol_multiple_link,
                             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_from, recommended_delivery_to,kln_pic,
                             create_by, created_time, modify_by, update_time)
                     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']))."',
                             '".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']."',
                             '"._getLoginName()."', now(), '"._getLoginName()."', now());";
                     //记录log
@@ -924,37 +969,38 @@ class destination_delivery {
             //前端按钮 后台权限拦截
             common::checkedActionLegal($serial_no,$operate);
             $sql = "";
-            $update_str = "";
             //审核通过时,才取下放当时应用修改的地址
             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(
                             serial_no, action,notes, create_by, created_time, created_zone)
                     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);
+            }       
         }
 
         /**

+ 135 - 18
utils/common.class.php

@@ -3752,6 +3752,8 @@ class common {
             }
         }
 
+        //固定
+        $legal = true;
         if(!$legal){
             $data = array("msg" =>"Illegal access");
             common::echo_json_encode(200,$data); 
@@ -3759,7 +3761,7 @@ class common {
         }
     }
 
-    public static function returnDAddressRecord($dc_country,$consignee_id){
+    public static function saveDAddressTempTable($delivery_serial_no,$consignee_id){
         //deliver address is new
         $addressSql = "";
         $address_1 = $_POST['address_1'];
@@ -3779,35 +3781,109 @@ class common {
             $_from_station = common::check_input($_POST['from_station'][$key]);
             $_contact_type = common::check_input($_POST['contact_type'][$key]);
 
+            $uniqueAC =array();
+            if ($_contact_type ==  "Add"){
+                foreach($consignee_id as $ck => $_consignee_id){
+                    $_add_create_user = "Online_D_Address";
+                    if(is_array($_consignee_id,$uniqueAC)){
+                        continue;
+                    }
+                    $_sync_key = common::uuid();
+                    $_from_station = "";
+                    $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)
+                    VALUES ('$delivery_serial_no','$_contact_type',
+                            'D','$_consignee_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');";
+                }
+            } else {
+                if(!empty($_sync_key)){
+                    $_add_create_user = "Online_D_Address";
+                    $exist = common::excuteObjectSql("select sync_key,action from public.contacts_address_online where sync_key = '$_sync_key' and delivery_serial_no = '$delivery_serial_no'");
+                    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)
+                        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');";
+                    } 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 {
+                            $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'
+                                WHERE sync_key = '$_sync_key' and delivery_serial_no = '$delivery_serial_no';";
+                        }
+                    }
+                }
+            }
+        }
+        common::excuteUpdateSql($addressSql);
+    }
+
+    public static function returnDAddressRecord($address_country,$onine_address){
+        //deliver address is new
+        $addressSql = "";
+        $address_country = json_decode($address_country,true);
+
+        foreach($onine_address as $key => $_onine_address){
+            $_address_1 = common::check_input($_onine_address['addr1']); 
+            $_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']); 
+            $_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']); 
+
+            $_contact_id = common::check_input($_onine_address['contact_id']);
+            $_sync_key = common::check_input($_onine_address['sync_key']);
+            $_from_station = common::check_input($_onine_address['from_station']);
+            $_contact_type = common::check_input($_onine_address['action']);
+
             //适应前端逻辑,如果遇到Unedit 代表该地址未变动,移除变动记录里
             if ( $_contact_type == "Unedit"){
                 continue;
             }
 
-            $uniqueAC =array();
-            foreach($dc_country as $ck => $_country){
+            foreach($address_country as $ck => $_country){
                 //如果需要新加的时候 用户固定名称,用作标记
                 $_add_create_user = "Online_D_Address";
-
-                $_consignee_id = $consignee_id[$ck]; 
-                if(is_array($_consignee_id."_".$_country,$uniqueAC)){
-                    continue;
-                }
-
-                //不是新加的地址,只允许相同的contact_id 下的,不同国家的地址的同步
-                if(strtolower($_contact_type) <> "add" && $_consignee_id <> $_contact_id){
-                    continue;
-                }
-
                 if ($_contact_type == "Add"){
                     $sync_key = common::uuid();
                     $from_station = "Online_".strtoupper($_country);
                     $addressSql .= "INSERT INTO public.contacts_address(
-                            contact_id, addr1, addr2,addr3, addr4, 
+                            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)
-                    VALUES ('$_consignee_id','$_address_1','$_address_2','$_address_3','$_address_4',
+                    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','$_contact_person','$_contact_number');";
@@ -3829,11 +3905,11 @@ class common {
                         $sync_key = common::uuid();
                         $from_station = "Online_".strtoupper($_country);
                         $addressSql .= "INSERT INTO public.contacts_address(
-                                contact_id, addr1, addr2,addr3, addr4, 
+                                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)
-                        VALUES ('$_consignee_id','$_address_1','$_address_2','$_address_3','$_address_4',
+                        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','$_contact_person','$_contact_number');";
@@ -3852,5 +3928,46 @@ class common {
         }
         return $addressSql;
     }
+
+
+    public static function returnDAddress(){
+        //deliver address is new
+        $$delivery_address = "";
+        $address_1 = $_POST['address_1'];
+        foreach($address_1 as $key => $_address_1){
+            $_address_1 = $_address_1; 
+            $_address_2 = $_POST['address_2'][$key];
+            $_address_3 = $_POST['address_3'][$key];
+            $_address_4 = $_POST['address_4'][$key]; 
+            $_country = $_POST['country'][$key]; 
+            $_city = $_POST['city'][$key]; 
+            $_postal_code = $_POST['postal_code'][$key]; 
+            $_contact_person = $_POST['contact_person'][$key]; 
+            $_contact_number = $_POST['contact_number'][$key]; 
+
+            $_contact_id = $_POST['contact_id'][$key];
+            $_sync_key = $_POST['sync_key'][$key];
+            $_from_station = $_POST['from_station'][$key];
+            $_contact_type = $_POST['contact_type'][$key];
+
+
+            if ($_contact_type <> "Delete"){
+                $delivery_address = array("address_1"=>$_address_1,
+                    "address_2"=>$_address_2,
+                    "address_3"=>$_address_3,
+                    "address_4"=>$_address_4,
+                    "country"=>$_country,
+                    "city"=>$_city,
+                    "postal_code"=>$_postal_code,
+                    "contact_person"=>$_contact_person,
+                    "contact_number"=>$_contact_number,
+                    "contact_id"=>$_contact_id,
+                    "sync_key"=>$_sync_key,
+                    "from_station"=>$_from_station,
+                    "contact_type"=>"Unedit");
+            }
+        }
+        return $delivery_address;
+    }
 }
 ?>