|
|
@@ -2673,6 +2673,45 @@
|
|
|
return dic;
|
|
|
}
|
|
|
|
|
|
++ (NSDictionary *)offline_getStateByCountryCodeId:(NSString *)codeId checkedState:(NSString *)stateCode {
|
|
|
+ NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
+
|
|
|
+ sqlite3 *db = [iSalesDB get_db];
|
|
|
+
|
|
|
+ NSString *sqlQuery = [NSString stringWithFormat:@"select name,code from offline_state where country_code = (select code as country_code FROM offline_country where countrycode_id = %@);",codeId];
|
|
|
+
|
|
|
+ DebugLog(@"query state:%@",sqlQuery);
|
|
|
+
|
|
|
+ sqlite3_stmt * statement;
|
|
|
+
|
|
|
+ if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK) {
|
|
|
+ int i = 0;
|
|
|
+ while (sqlite3_step(statement) == SQLITE_ROW) {
|
|
|
+ char *name = (char *) sqlite3_column_text(statement, 0); // value
|
|
|
+ char *code = (char *) sqlite3_column_text(statement, 1); // value_id
|
|
|
+
|
|
|
+ NSMutableDictionary *stateDic = [NSMutableDictionary dictionaryWithCapacity:2];
|
|
|
+ [stateDic setValue:[NSString stringWithUTF8String:name] forKey:@"value"];
|
|
|
+ [stateDic setValue:[NSString stringWithUTF8String:code] forKey:@"value_id"];
|
|
|
+ [stateDic setValue:[NSNumber numberWithInt:0] forKey:@"check"];
|
|
|
+
|
|
|
+ if (stateCode && [[NSString stringWithUTF8String:code] isEqualToString:stateCode]) {
|
|
|
+ [stateDic setValue:[NSNumber numberWithInt:1] forKey:@"check"];
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *key = [NSString stringWithFormat:@"val_%d",i++];
|
|
|
+ [dic setValue:stateDic forKey:key];
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlite3_finalize(statement);
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlite3_close(db);
|
|
|
+ [dic setValue:[NSNumber numberWithInt:dic.allKeys.count] forKey:@"count"];
|
|
|
+ return dic;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+ (NSDictionary *)offline_getPrice {
|
|
|
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
|
|
|
@@ -2852,6 +2891,8 @@
|
|
|
NSString *zip_code = params[@"zipcode"];
|
|
|
zipCode = zip_code;
|
|
|
|
|
|
+ countryCode_id = params[@"country"];
|
|
|
+
|
|
|
NSDictionary *dic = [self offline_dealZipCode:zip_code];
|
|
|
|
|
|
countryCode = [dic valueForKey:@"country_code"];
|
|
|
@@ -2869,6 +2910,7 @@
|
|
|
} else {
|
|
|
// default: US United States
|
|
|
countryCode = @"US";
|
|
|
+ countryCode_id = @"228";
|
|
|
}
|
|
|
|
|
|
// country
|
|
|
@@ -2877,6 +2919,7 @@
|
|
|
|
|
|
// state
|
|
|
NSDictionary *allState = [self offline_getStateByCountryCode:countryCode checkedState:stateCode];
|
|
|
+// NSDictionary *allState = [self offline_getStateByCountryCodeId:countryCode_id checkedState:stateCode];
|
|
|
[self setValue:allState forItemKey:@"item_11" valueKey:@"cadedate" inDictionary:section_0];
|
|
|
|
|
|
// city
|