Przeglądaj źródła

1.修改NPD离线Place Order Ship To地址数据结构,完成自动填写和单选Action。

Pen Li 8 lat temu
rodzic
commit
e323262861

+ 350 - 24
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -5695,6 +5695,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         countryCode = @"US";
     }
     
+    __block NSInteger _count = 0;
     NSMutableDictionary *ret = [[iSalesDB jk_query:@"select _id,name,code,countrycode_id from offline_country;" completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container,long *count) {
         char *name = (char *) sqlite3_column_text(stmt, 1); // 全称
         char *code = (char *) sqlite3_column_text(stmt, 2); // 缩写
@@ -5713,9 +5714,49 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         *count = n + 1;
         NSString *key = [NSString stringWithFormat:@"val_%ld",n];
         [container setValue:countryDic forKey:key];
+        
+        _count = *count;
+        
     }] mutableCopy];
     
-    [ret setValue:[NSNumber numberWithInt:ret.allKeys.count] forKey:@"count"];
+    
+    [ret setValue:@(_count) forKey:@"count"];
+    return ret;
+}
+
++ (NSDictionary *)offline_getAllCountryDefaultId:(NSString *)countryCodeId db:(sqlite3 *)db {
+    if (db == nil) {
+        return nil;
+    }
+    if (!countryCodeId) {
+        countryCodeId = @"228";
+    }
+    __block NSInteger _count = 0;
+    NSMutableDictionary *ret = [[iSalesDB jk_query:@"select _id,name,code,countrycode_id from offline_country;" db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
+        char *name = (char *) sqlite3_column_text(stmt, 1); // 全称
+        char *code = (char *) sqlite3_column_text(stmt, 2); // 缩写
+        int code_id = sqlite3_column_int(stmt, 3); // id
+        
+        NSMutableDictionary *countryDic = [NSMutableDictionary dictionaryWithCapacity:2];
+        [countryDic setValue:[NSString stringWithFormat:@"%s",name] forKey:@"value"];
+        [countryDic setValue:[NSString stringWithFormat:@"%d",code_id] forKey:@"value_id"];
+        [countryDic setValue:[NSNumber numberWithInt:0] forKey:@"check"];
+        
+        if ([countryCodeId intValue] == code_id) {
+            [countryDic setValue:[NSNumber numberWithInt:1] forKey:@"check"];
+        }
+        
+        long n = *count;
+        *count = n + 1;
+        NSString *key = [NSString stringWithFormat:@"val_%ld",n];
+        [container setValue:countryDic forKey:key];
+        
+        _count = *count;
+        
+    }] mutableCopy];
+    
+    
+    [ret setValue:@(_count) forKey:@"count"];
     return ret;
 }
 
@@ -9409,6 +9450,115 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     return customer_dic;
 }
 
++ (void)dictionary:(NSMutableDictionary *)dictionary setValue:(id)value forKey:(id)key {
+    if (dictionary == nil || value == nil || key == nil) {
+        return;
+    }
+    [dictionary setValue:value forKey:key];
+}
+
++ (NSDictionary *)placeOrderAddressRefresh:(NSDictionary *)params {
+    
+    NSString *countryCode = nil;
+    NSString *countryCode_id = nil;
+    NSString *stateCode = nil;
+    NSString *city = nil;
+    NSString *zipCode = nil;
+    
+    NSMutableDictionary *ret = [NSMutableDictionary dictionary];
+    NSString *refresh_trigger = params[@"refresh_trigger"];
+    NSString *country_key = [refresh_trigger stringByReplacingOccurrencesOfString:@"zipcode" withString:@"country"];
+    NSString *state_key = [refresh_trigger stringByReplacingOccurrencesOfString:@"zipcode" withString:@"state"];
+    NSString *city_key = [refresh_trigger stringByReplacingOccurrencesOfString:@"zipcode" withString:@"city"];
+    NSString *countryCode_key = [refresh_trigger stringByReplacingOccurrencesOfString:@"zipcode" withString:@"countryCode"];
+    
+    if ([params.allKeys containsObject:@"refresh_trigger"]) {
+        
+        if([[refresh_trigger lowercaseString] containsString:@"country"]) { // choose country
+            
+            NSString *code_id = params[refresh_trigger];
+            countryCode_id = code_id;
+            countryCode = [self countryCodeByid:code_id];
+            
+            [self dictionary:ret setValue:countryCode_id forKey:refresh_trigger];
+            [self dictionary:ret setValue:countryCode forKey:countryCode_key];
+            
+        } else if ([[refresh_trigger lowercaseString] containsString:@"zipcode"]) { // zipcode
+            
+            NSString *zip_code = params[refresh_trigger];
+            
+            
+            // 剔除全部为空格
+            int spaceCount = 0;
+            for (int i = 0; i < zip_code.length; i++) {
+                if ([zip_code characterAtIndex:i] == ' ') {
+                    spaceCount++;
+                }
+            }
+            if (spaceCount == zip_code.length) {
+                zip_code = @"";
+            }
+            
+            zipCode = zip_code;
+            [self dictionary:ret setValue:zipCode forKey:refresh_trigger];
+            
+            
+            if (zipCode.length > 0) {
+                countryCode_id = params[country_key];
+                
+                NSDictionary *dic = [self offline_dealZipCode:zip_code];
+                
+                countryCode = [dic valueForKey:@"country_code"];
+                if (!countryCode) {
+                    //                    countryCode = @"US";
+                    NSString *code_id = params[country_key];
+                    countryCode_id = code_id;
+                    countryCode = [self countryCodeByid:code_id];
+                }
+                [self dictionary:ret setValue:countryCode_id forKey:country_key];
+                [self dictionary:ret setValue:countryCode forKey:countryCode_key];
+                
+                stateCode = [dic valueForKey:@"state_code"];
+                if (!stateCode.length) {
+                    stateCode = params[state_key];
+                }
+                [self dictionary:ret setValue:stateCode forKey:state_key];
+                
+                city = [dic valueForKey:@"city"];
+                if (!city.length) {
+                    city = params[city_key];
+                }
+                [self dictionary:ret setValue:city forKey:city_key];
+                
+                // zip code
+
+            }  else {
+                
+                NSString *code_id = params[country_key];
+                countryCode_id = code_id;
+                countryCode = [self countryCodeByid:code_id];
+                stateCode = params[state_key];
+                city = params[city_key];
+                
+                [self dictionary:ret setValue:countryCode_id forKey:country_key];
+                [self dictionary:ret setValue:countryCode forKey:countryCode_key];
+                [self dictionary:ret setValue:stateCode forKey:state_key];
+                [self dictionary:ret setValue:city forKey:city_key];
+            }
+        }
+        
+    } else {
+        // default: US United States
+        countryCode = @"US";
+        countryCode_id = @"228";
+        
+        [self dictionary:ret setValue:countryCode_id forKey:country_key];
+        [self dictionary:ret setValue:countryCode forKey:countryCode_key];
+    }
+    
+    return ret;
+}
+
 + (NSDictionary *)shipToDic:(NSDictionary *)params db:(sqlite3 *)db {
     
     __block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
@@ -9422,11 +9572,11 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     
     NSString *orderCode = [self valueInParams:params key:@"orderCode"];
     orderCode = [self translateSingleQuote:orderCode];
-    
      
     
-    NSString *sql = [NSString stringWithFormat:@"select receive_cid,receive_name,receive_ext,receive_contact,receive_email,receive_fax,receive_phone from offline_order where so_id = '%@';",orderCode];
-    
+//    NSString *sql = [NSString stringWithFormat:@"select receive_cid,receive_name,receive_ext,receive_contact,receive_email,receive_fax,receive_phone from offline_order where so_id = '%@';",orderCode];
+    NSString *sql = [NSString stringWithFormat:@"select receive_cid,receive_name,receive_ext,receive_contact,receive_email,receive_fax,receive_phone,receive_address1,receive_address2,receive_state,receive_zipcode,receive_city,receive_country from offline_order where so_id = '%@';",orderCode];
+
     
     [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
         
@@ -9438,8 +9588,15 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         NSString *fax = [self textAtColumn:5 statement:stmt];
         NSString *phone = [self textAtColumn:6 statement:stmt];
         
+        NSString *addr_1 = [self textAtColumn:7 statement:stmt];
+        NSString *addr_2 = [self textAtColumn:8 statement:stmt];
+        NSString *state = [self textAtColumn:9 statement:stmt];
+        NSString *zipcode = [self textAtColumn:10 statement:stmt];
+        NSString *city = [self textAtColumn:11 statement:stmt];
+        NSString *country = [self textAtColumn:12 statement:stmt];
+        
         // count
-        [dic setValue:[NSNumber numberWithInteger:8] forKey:@"count"];
+        [dic setValue:[NSNumber numberWithInteger:13] forKey:@"count"];
         
         // title
         [dic setValue:@"Ship To" forKey:@"title"];
@@ -9453,7 +9610,12 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
                                                @"key_map" : @{@"receive_cid" : @"customer_cid",
                                                               @"receive_contact" : @"customer_contact",
                                                               @"receive_email" : @"customer_email",
-                                                              @"receive_ext" : @"customer_contact_ext",
+                                                              @"receive_address1" : @"customer_address1",
+                                                              @"receive_address2" : @"customer_address2",
+                                                              @"receive_zipcode" : @"customer_zipcode",
+                                                              @"receive_city" : @"customer_city",
+                                                              @"receive_state" : @"customer_state",
+                                                              @"receive_country" : @"customer_country",
                                                               @"receive_fax" : @"customer_fax",
                                                               @"receive_name" : @"customer_name",
                                                               @"receive_phone" : @"customer_phone"},
@@ -9470,7 +9632,12 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
                                              @"key_map" : @{@"receive_cid" : @"customer_cid",
                                                               @"receive_contact" : @"customer_contact",
                                                               @"receive_email" : @"customer_email",
-                                                              @"receive_ext" : @"customer_contact_ext",
+                                                              @"receive_address1" : @"customer_address1",
+                                                              @"receive_address2" : @"customer_address2",
+                                                              @"receive_zipcode" : @"customer_zipcode",
+                                                              @"receive_city" : @"customer_city",
+                                                              @"receive_state" : @"customer_state",
+                                                              @"receive_country" : @"customer_country",
                                                               @"receive_fax" : @"customer_fax",
                                                               @"receive_name" : @"customer_name",
                                                               @"receive_phone" : @"customer_phone"},
@@ -9494,32 +9661,114 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         [dic setValue:company_name_dic forKey:@"item_2"];
         
         // address
-        NSMutableDictionary *ext_dic = [self infoName:@"receive_ext" aname:@"Address" control:@"text_view" keyboard:@"text" value:ext].mutableCopy;
-        NSNumber *required = setting[@"ShippingToAddressRequire"];
-        if ([required integerValue]) {
-            [ext_dic setValue:@"true" forKey:@"required"];
+//        NSMutableDictionary *ext_dic = [self infoName:@"receive_ext" aname:@"Address" control:@"text_view" keyboard:@"text" value:ext].mutableCopy;
+//        NSNumber *required = setting[@"ShippingToAddressRequire"];
+//        if ([required integerValue]) {
+//            [ext_dic setValue:@"true" forKey:@"required"];
+//        }
+//
+//        [dic setValue:ext_dic forKey:@"item_3"];
+        
+        // new address
+        
+        NSDictionary *addr1_dic = [self infoName:@"receive_address1" aname:@"Address1" control:@"edit" keyboard:@"text" value:addr_1];
+        
+        [dic setValue:addr1_dic forKey:@"item_3"];
+        
+        NSDictionary *addr2_dic = [self infoName:@"receive_address2" aname:@"Address2" control:@"edit" keyboard:@"text" value:addr_2];
+        
+        [dic setValue:addr2_dic forKey:@"item_4"];
+        
+        
+        // city
+        NSString *param_city = [params objectForKey:@"receive_city"];
+        if (param_city.length > 0) {
+            city = param_city;
         }
+        NSDictionary *city_dic = [self infoName:@"receive_city" aname:@"City" control:@"edit" keyboard:@"text" value:city];
+        
+        [dic setValue:city_dic forKey:@"item_5"];
+        
+        // state
+        NSString *param_state = [params objectForKey:@"receive_state"];
+        if (param_state.length > 0) {
+            state = param_state;
+        }
+        NSDictionary *state_dic = @{
+                                    @"aname" : @"State",
+                                    @"cadedate" : [self offline_getStateByCountryCode:@"US" checkedState:state db:db],
+                                    @"control" : @"enum",
+                                    @"enum" : @"true",
+                                    @"name" : @"receive_state",
+                                    @"required" : @"true",
+                                    @"single_select" : @"true"
+                                    };
+//        NSDictionary *state_dic = [self infoName:@"receive_state" aname:@"State" control:@"edit" keyboard:@"text" value:state];
+        
+        [dic setValue:state_dic forKey:@"item_6"];
+        
+        // zipcode
+        NSString *param_zipcode = [params objectForKey:@"receive_zipcode"];
+        if (param_zipcode.length > 0) {
+            zipcode = param_zipcode;
+        }
+        NSMutableDictionary *zipcode_dic = [[self infoName:@"receive_zipcode" aname:@"Zip code" control:@"edit" keyboard:@"text" value:zipcode] mutableCopy];
+        [zipcode_dic setValue:@(1) forKey:@"refresh"];
+        NSDictionary *restore = @{
+                                    @"count" : @(3),
+                                    @"item_0" : @"state",
+                                    @"item_1" : @"city",
+                                    @"item_2" : @"country"
+                                  };
+        [zipcode_dic setValue:restore forKey:@"restore"];
+        
+        [dic setValue:zipcode_dic forKey:@"item_7"];
+        
+        // country
+        NSString *param_country = [params objectForKey:@"receive_country"];
+        if (param_country.length > 0) {
+            country = param_country;
+        }
+        NSDictionary *country_dic = @{
+                                      @"aname" : @"Country",
+                                      @"cadedate" : [self offline_getAllCountryDefaultId:country db:db],
+                                      @"control" : @"enum",
+                                      @"name" : @"receive_country",
+                                      @"refresh" : @(1),
+                                      @"restore" : @{
+                                              @"count" : @(3),
+                                              @"item_0" : @"state",
+                                              @"item_1" : @"city",
+                                              @"item_2" : @"zipcode"
+                                              },
+                                      @"single_select" : @"true"
+                                      };
+        
+//        NSDictionary *country_dic = [self infoName:@"receive_country" aname:@"Country" control:@"edit" keyboard:@"text" value:country];
+        
+        [dic setValue:country_dic forKey:@"item_8"];
+        
+        
         
-        [dic setValue:ext_dic forKey:@"item_3"];
         
         // contact
         NSDictionary *contact_dic = [self infoName:@"receive_contact" aname:@"Contact" control:@"edit" keyboard:@"text" value:contact];
         
-        [dic setValue:contact_dic forKey:@"item_4"];
+        [dic setValue:contact_dic forKey:@"item_9"];
 
         // phone
         NSDictionary *phone_dic = [self infoName:@"receive_phone" aname:@"Phone" control:@"edit" keyboard:@"text" value:phone];
         
-        [dic setValue:phone_dic forKey:@"item_5"];
+        [dic setValue:phone_dic forKey:@"item_10"];
         
         // fax
         NSDictionary *fax_dic = [self infoName:@"receive_fax" aname:@"Fax" control:@"edit" keyboard:@"text" value:fax];
-        [dic setValue:fax_dic forKey:@"item_6"];
+        [dic setValue:fax_dic forKey:@"item_11"];
 
         // email
         NSDictionary *email_dic = [self infoName:@"receive_email" aname:@"Email" control:@"edit" keyboard:@"text" value:email];
         
-        [dic setValue:email_dic forKey:@"item_7"];
+        [dic setValue:email_dic forKey:@"item_12"];
         
     }];
     
@@ -9538,9 +9787,9 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     orderCode = [self translateSingleQuote:orderCode];
     
     
-    NSString *sql = [NSString stringWithFormat:@"select sender_cid,sender_name,sender_ext,sender_contact,sender_email,sender_fax,sender_phone from offline_order where so_id = '%@';",orderCode];
+    NSString *sql = [NSString stringWithFormat:@"select sender_cid,sender_name,sender_ext,sender_contact,sender_email,sender_fax,sender_phone,sender_address1,sender_address2,sender_state,sender_zipcode,sender_city,sender_country from offline_order where so_id = '%@';",orderCode];
     
-    NSString *ship_from_default_sql = @"select contact_id,decrypt(company_name),decrypt(addr_1),first_name || ' ' || last_name,email,fax,phone from offline_contact where contact_id = 'NPD';";
+    NSString *ship_from_default_sql = @"select contact_id,decrypt(company_name),decrypt(addr_1),first_name || ' ' || last_name,email,fax,phone,addr_2,state,zipcode,city,country from offline_contact where contact_id = 'NPD';";
     
     [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
         
@@ -9552,6 +9801,13 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         __block NSString *fax = [self textAtColumn:5 statement:stmt];
         __block NSString *phone = [self textAtColumn:6 statement:stmt];
         
+        __block NSString *addr_1 = [self textAtColumn:7 statement:stmt];
+        __block NSString *addr_2 = [self textAtColumn:8 statement:stmt];
+        __block NSString *state = [self textAtColumn:9 statement:stmt];
+        __block NSString *zipcode = [self textAtColumn:10 statement:stmt];
+        __block NSString *city = [self textAtColumn:11 statement:stmt];
+        __block NSString *country = [self textAtColumn:12 statement:stmt];
+        
         if (!cid.length) {
             [iSalesDB jk_query:ship_from_default_sql db:db close:NO completion:^(sqlite3_stmt *statment, NSMutableDictionary *container, long *count) {
                 
@@ -9563,6 +9819,14 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
                 fax = [self textAtColumn:5 statement:statment];
                 phone = [self textAtColumn:6 statement:statment];
                 
+                
+                addr_1 = ext;
+                addr_2 = [self textAtColumn:7 statement:statment];
+                state = [self textAtColumn:8 statement:statment];
+                zipcode = [self textAtColumn:9 statement:statment];
+                city = [self textAtColumn:10 statement:statment];
+                country = [self textAtColumn:11 statement:statment];
+                
             }];
         }
         
@@ -9649,7 +9913,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     orderCode = [self translateSingleQuote:orderCode];
     
     
-    NSString *sql = [NSString stringWithFormat:@"select shipping_billto_cid,shipping_billto_name,shipping_billto_ext,shipping_billto_contact,shipping_billto_email,shipping_billto_fax,shipping_billto_phone from offline_order where so_id = '%@';",orderCode];
+    NSString *sql = [NSString stringWithFormat:@"select shipping_billto_cid,shipping_billto_name,shipping_billto_ext,shipping_billto_contact,shipping_billto_email,shipping_billto_fax,shipping_billto_phone,shipping_billto_address1,shipping_billto_address2,shipping_billto_state,shipping_billto_zipcode,shipping_billto_city,shipping_billto_country from offline_order where so_id = '%@';",orderCode];
     
     
     [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
@@ -9662,6 +9926,14 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         NSString *fax = [self textAtColumn:5 statement:stmt];
         NSString *phone = [self textAtColumn:6 statement:stmt];
         
+        NSString *addr_1 = [self textAtColumn:7 statement:stmt];
+        NSString *addr_2 = [self textAtColumn:8 statement:stmt];
+        NSString *state = [self textAtColumn:9 statement:stmt];
+        NSString *zipcode = [self textAtColumn:10 statement:stmt];
+        NSString *city = [self textAtColumn:11 statement:stmt];
+        NSString *country = [self textAtColumn:12 statement:stmt];
+        
+        
         // count
         [dic setValue:[NSNumber numberWithInteger:8] forKey:@"count"];
         
@@ -9787,7 +10059,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     orderCode = [self translateSingleQuote:orderCode];
     
     
-    NSString *sql = [NSString stringWithFormat:@"select billing_cid,billing_name,billing_ext,billing_contact,billing_email,billing_fax,billing_phone from offline_order where so_id = '%@';",orderCode];
+    NSString *sql = [NSString stringWithFormat:@"select billing_cid,billing_name,billing_ext,billing_contact,billing_email,billing_fax,billing_phone,billing_address1,billing_address2,billing_state,billing_zipcode,billing_city,billing_country from offline_order where so_id = '%@';",orderCode];
     
     
     [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
@@ -9800,6 +10072,13 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         NSString *fax = [self textAtColumn:5 statement:stmt];
         NSString *phone = [self textAtColumn:6 statement:stmt];
         
+        NSString *addr_1 = [self textAtColumn:7 statement:stmt];
+        NSString *addr_2 = [self textAtColumn:8 statement:stmt];
+        NSString *state = [self textAtColumn:9 statement:stmt];
+        NSString *zipcode = [self textAtColumn:10 statement:stmt];
+        NSString *city = [self textAtColumn:11 statement:stmt];
+        NSString *country = [self textAtColumn:12 statement:stmt];
+        
         // count
         [dic setValue:[NSNumber numberWithInteger:8] forKey:@"count"];
         
@@ -9914,7 +10193,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     orderCode = [self translateSingleQuote:orderCode];
     
     
-    NSString *sql = [NSString stringWithFormat:@"select returnto_cid,returnto_name,returnto_ext,returnto_contact,returnto_email,returnto_fax,returnto_phone from offline_order where so_id = '%@';",orderCode];
+    NSString *sql = [NSString stringWithFormat:@"select returnto_cid,returnto_name,returnto_ext,returnto_contact,returnto_email,returnto_fax,returnto_phone,returnto_address1,returnto_address2,returnto_state,returnto_zipcode,returnto_city,returnto_country from offline_order where so_id = '%@';",orderCode];
     
     
     [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
@@ -9927,6 +10206,13 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         NSString *fax = [self textAtColumn:5 statement:stmt];
         NSString *phone = [self textAtColumn:6 statement:stmt];
         
+        NSString *addr_1 = [self textAtColumn:7 statement:stmt];
+        NSString *addr_2 = [self textAtColumn:8 statement:stmt];
+        NSString *state = [self textAtColumn:9 statement:stmt];
+        NSString *zipcode = [self textAtColumn:10 statement:stmt];
+        NSString *city = [self textAtColumn:11 statement:stmt];
+        NSString *country = [self textAtColumn:12 statement:stmt];
+        
         // count
         [dic setValue:[NSNumber numberWithInteger:8] forKey:@"count"];
         
@@ -11135,12 +11421,15 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
 
 +(NSData*) offline_placeorder :(NSMutableDictionary *) params
 {
-    
-    sqlite3 *db = [iSalesDB get_db];
     // params
     NSString *orderCode = [self valueInParams:params key:@"orderCode"];
     orderCode = [self translateSingleQuote:orderCode];
     
+    NSDictionary *addressRefreshDic = [self placeOrderAddressRefresh:params];
+    [params setValuesForKeysWithDictionary:addressRefreshDic];
+    
+    sqlite3 *db = [iSalesDB get_db];
+    
     // 缺货检查
     AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
     if (!appDelegate.can_create_backorder) {
@@ -11270,6 +11559,14 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     
     [iSalesDB close_db:db];
     
+    NSDictionary *up_params = @{
+                                @"count" : @(2),
+                                @"val_0" : @"receive_zipcode",
+                                @"val_1" : @"receive_country"
+                                };
+    
+    [ret setObject:up_params forKey:@"up_params"];
+    
     return [RAConvertor dict2data:ret];
 //    return nil;
 }
@@ -11721,6 +12018,35 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         receive_ext = [NSString stringWithFormat:@"receive_ext = '%@',",receive_ext];
     }
     
+    NSString *receive_addr1 = [self valueInParams:param key:@"receive_address1" translateSingleQuote:YES];
+    if (receive_addr1.length) {
+        receive_addr1 = [NSString stringWithFormat:@"receive_address1 = '%@',",receive_addr1];
+    }
+    
+    NSString *receive_addr2 = [self valueInParams:param key:@"receive_address2" translateSingleQuote:YES];
+    if (receive_addr2.length) {
+        receive_addr2 = [NSString stringWithFormat:@"receive_address2 = '%@',",receive_addr2];
+    }
+    
+    NSString *receive_city = [self valueInParams:param key:@"receive_city" translateSingleQuote:YES];
+    if (receive_city.length) {
+        receive_city = [NSString stringWithFormat:@"receive_city = '%@',",receive_city];
+    }
+    
+    NSString *receive_state = [self valueInParams:param key:@"receive_state" translateSingleQuote:YES];
+    if (receive_state.length) {
+        receive_state = [NSString stringWithFormat:@"receive_state = '%@',",receive_state];
+    }
+    
+    NSString *receive_zipcode = [self valueInParams:param key:@"receive_zipcode" translateSingleQuote:YES];
+    if (receive_zipcode.length) {
+        receive_zipcode = [NSString stringWithFormat:@"receive_zipcode = '%@',",receive_zipcode];
+    }
+    
+    NSString *receive_country = [self valueInParams:param key:@"receive_country" translateSingleQuote:YES];
+    if (receive_country.length) {
+        receive_country = [NSString stringWithFormat:@"receive_country = '%@',",receive_country];
+    }
     
     NSString *receive_contact = [self valueInParams:param key:@"receive_contact" translateSingleQuote:YES];
     if (receive_contact.length) {
@@ -11909,7 +12235,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         sync_sql = [NSString stringWithFormat:@",sync_data = '%@' ",sync_data];
     }
     
-    NSString *orderSql = [NSString stringWithFormat:@"update offline_order set %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ so_id = '%@' %@ where so_id = '%@';",order_status,general_notes,internal_notes,poNumber,must_call,sign_picpath,total_price,paymentsAndCredits,handling_fee_placeholder,lift_gate,lift_gate_placeholder,logist,logistic_note,erpOrderStatus,paymentType,credit_card_address1,credit_card_address2,credit_card_city,credit_card_first_name,credit_card_last_name,credit_card_number,credit_card_security_code,credit_card_state,credit_card_type,credit_card_zipcode,credit_card_expiration_year,credit_card_expiration_month,customer_cid,customer_contact,customer_email,customer_phone,customer_fax,receive_cid,receive_name,receive_ext,receive_contact,receive_phone,receive_email,receive_fax,sender_cid,sender_name,sender_ext,sender_contact,sender_phone,sender_fax,sender_email,shipping_billto_cid,shipping_billto_name,shipping_billto_ext,shipping_billto_contact,shipping_billto_phone,shipping_billto_fax,shipping_billto_email,billing_cid,billing_name,billing_ext,billing_contact,billing_phone,billing_fax,billing_email,returnto_cid,returnto_name,returnto_ext,returnto_contact,returnto_phone,returnto_fax,returnto_email,so_id,sync_sql,so_id];
+    NSString *orderSql = [NSString stringWithFormat:@"update offline_order set %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ so_id = '%@' %@ where so_id = '%@';",order_status,general_notes,internal_notes,poNumber,must_call,sign_picpath,total_price,paymentsAndCredits,handling_fee_placeholder,lift_gate,lift_gate_placeholder,logist,logistic_note,erpOrderStatus,paymentType,credit_card_address1,credit_card_address2,credit_card_city,credit_card_first_name,credit_card_last_name,credit_card_number,credit_card_security_code,credit_card_state,credit_card_type,credit_card_zipcode,credit_card_expiration_year,credit_card_expiration_month,customer_cid,customer_contact,customer_email,customer_phone,customer_fax,receive_cid,receive_name,receive_ext,receive_contact,receive_phone,receive_email,receive_fax,sender_cid,sender_name,sender_ext,sender_contact,sender_phone,sender_fax,sender_email,shipping_billto_cid,shipping_billto_name,shipping_billto_ext,shipping_billto_contact,shipping_billto_phone,shipping_billto_fax,shipping_billto_email,billing_cid,billing_name,billing_ext,billing_contact,billing_phone,billing_fax,billing_email,returnto_cid,returnto_name,returnto_ext,returnto_contact,returnto_phone,returnto_fax,returnto_email,receive_addr1,receive_addr2,receive_city,receive_state,receive_zipcode,receive_country,so_id,sync_sql,so_id];
     
     DebugLog(@"save order contactSql: %@",contactSql);
     DebugLog(@"save order orderSql: %@",orderSql);

+ 33 - 3
RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m

@@ -3362,10 +3362,40 @@
                 //                valuestr = [self getValue:valuefrom];
                 if(true)
                 {
-                    if(valuestr.length>0)
-                        [modify_item setValue:valuestr forKey:@"value"];
-                    else
+                    if(valuestr.length>0) {
+                        NSString *control = [modify_item objectForKey:@"control"];
+                        if ([control isEqualToString:@"enum"]) {
+                            NSMutableDictionary *cadedate = [[modify_item objectForKey:@"cadedate"] mutableCopy];
+                            int count = [[cadedate objectForKey:@"count"] intValue];
+                            for (int i = 0; i < count; i++) {
+                                NSString *key = [NSString stringWithFormat:@"val_%d",i];
+                                NSMutableDictionary *val = [[cadedate objectForKey:key] mutableCopy];
+                                int check = [[val objectForKey:@"check"] intValue];
+                                NSString *val_id = [val objectForKey:@"value_id"];
+                                NSString *val_value = [val objectForKey:@"value"];
+                                // state 通过id判断, country 通过value判断
+                                if (check == 1 && (![val_id isEqualToString:valuestr] && ![val_value isEqualToString:valuestr])) {
+                                    check = 0;
+                                    [val setObject:@(check) forKey:@"check"];
+                                    [cadedate setObject:val forKey:key];
+                                }
+                                
+                                if ([val_id isEqualToString:valuestr] || [val_value isEqualToString:valuestr]) {
+                                    check = 1;
+                                    [val setObject:@(check) forKey:@"check"];
+                                    [cadedate setObject:val forKey:key];
+                                }
+                                
+                            }
+                            [modify_item setObject:cadedate forKey:@"cadedate"];
+                        } else {
+                            [modify_item setValue:valuestr forKey:@"value"];
+                        }
+                        
+                    }
+                    else {
                         [modify_item setValue:@"" forKey:@"value"];
+                    }
                     [modify_item setValue:@"true" forKey:@"dirty"];
                     [section_json setObject:modify_item  forKey:[NSString stringWithFormat:@"item_%d",ic ]];
                 }

Plik diff jest za duży
+ 0 - 1
RedAnt ERP Mobile/common/data_provider/iSalesDB.m


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików