|
@@ -11,7 +11,6 @@
|
|
|
#import "RAUtils.h"
|
|
#import "RAUtils.h"
|
|
|
#import "AESCrypt.h"
|
|
#import "AESCrypt.h"
|
|
|
#import "AppDelegate.h"
|
|
#import "AppDelegate.h"
|
|
|
-#import "iSalesDB+JKDB.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@interface OLDataProvider ()
|
|
@interface OLDataProvider ()
|
|
@@ -2658,6 +2657,7 @@
|
|
|
#pragma mark - Jack
|
|
#pragma mark - Jack
|
|
|
|
|
|
|
|
#pragma mark create new contact
|
|
#pragma mark create new contact
|
|
|
|
|
+
|
|
|
+ (NSDictionary *)offline_getAllCountryDefault:(NSString *)countryCode {
|
|
+ (NSDictionary *)offline_getAllCountryDefault:(NSString *)countryCode {
|
|
|
// "val_227" : {
|
|
// "val_227" : {
|
|
|
// "check" : 1,
|
|
// "check" : 1,
|
|
@@ -2669,101 +2669,127 @@
|
|
|
countryCode = @"US";
|
|
countryCode = @"US";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
|
|
- sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
-
|
|
|
|
|
- const char *sqlQuery = "select _id,name,code,countrycode_id from offline_country;";
|
|
|
|
|
- sqlite3_stmt * statement;
|
|
|
|
|
-
|
|
|
|
|
- if (sqlite3_prepare_v2(db, sqlQuery, -1, &statement, nil) == SQLITE_OK) {
|
|
|
|
|
-
|
|
|
|
|
- long count = 0;
|
|
|
|
|
- while (sqlite3_step(statement) == SQLITE_ROW) {
|
|
|
|
|
- char *name = (char *) sqlite3_column_text(statement, 1); // 全称
|
|
|
|
|
- char *code = (char *) sqlite3_column_text(statement, 2); // 缩写
|
|
|
|
|
- int code_id = sqlite3_column_int(statement, 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 ([countryCode isEqualToString:[NSString stringWithUTF8String:code]]) {
|
|
|
|
|
- [countryDic setValue:[NSNumber numberWithInt:1] forKey:@"check"];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- NSString *key = [NSString stringWithFormat:@"val_%ld",count++];
|
|
|
|
|
- [dic setValue:countryDic forKey:key];
|
|
|
|
|
|
|
+// NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
|
|
+// sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
+//
|
|
|
|
|
+// const char *sqlQuery = "select _id,name,code,countrycode_id from offline_country;";
|
|
|
|
|
+// sqlite3_stmt * statement;
|
|
|
|
|
+//
|
|
|
|
|
+// if (sqlite3_prepare_v2(db, sqlQuery, -1, &statement, nil) == SQLITE_OK) {
|
|
|
|
|
+//
|
|
|
|
|
+// long count = 0;
|
|
|
|
|
+// while (sqlite3_step(statement) == SQLITE_ROW) {
|
|
|
|
|
+// char *name = (char *) sqlite3_column_text(statement, 1); // 全称
|
|
|
|
|
+// char *code = (char *) sqlite3_column_text(statement, 2); // 缩写
|
|
|
|
|
+// int code_id = sqlite3_column_int(statement, 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 ([countryCode isEqualToString:[NSString stringWithUTF8String:code]]) {
|
|
|
|
|
+// [countryDic setValue:[NSNumber numberWithInt:1] forKey:@"check"];
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// NSString *key = [NSString stringWithFormat:@"val_%ld",count++];
|
|
|
|
|
+// [dic setValue:countryDic forKey:key];
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// sqlite3_finalize(statement);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// sqlite3_close(db);
|
|
|
|
|
+// [dic setValue:[NSNumber numberWithInt:dic.allKeys.count] forKey:@"count"];
|
|
|
|
|
+// return dic;
|
|
|
|
|
+
|
|
|
|
|
+ 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); // 缩写
|
|
|
|
|
+ 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 ([countryCode isEqualToString:[NSString stringWithUTF8String:code]]) {
|
|
|
|
|
+ [countryDic setValue:[NSNumber numberWithInt:1] forKey:@"check"];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- sqlite3_finalize(statement);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- sqlite3_close(db);
|
|
|
|
|
- [dic setValue:[NSNumber numberWithInt:dic.allKeys.count] forKey:@"count"];
|
|
|
|
|
- return dic;
|
|
|
|
|
|
|
+ long n = *count;
|
|
|
|
|
+ *count = n + 1;
|
|
|
|
|
+ NSString *key = [NSString stringWithFormat:@"val_%ld",n];
|
|
|
|
|
+ [container setValue:countryDic forKey:key];
|
|
|
|
|
+ }] mutableCopy];
|
|
|
|
|
|
|
|
-// NSDictionary *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); // 缩写
|
|
|
|
|
-// 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 ([countryCode isEqualToString:[NSString stringWithUTF8String:code]]) {
|
|
|
|
|
-// [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];
|
|
|
|
|
-// }];
|
|
|
|
|
-//
|
|
|
|
|
-// return [ret copy];
|
|
|
|
|
|
|
+ [ret setValue:[NSNumber numberWithInt:ret.allKeys.count] forKey:@"count"];
|
|
|
|
|
+ return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ (NSDictionary *)offline_getStateByCountryCode:(NSString *)countryCode checkedState:(NSString *)state_code{
|
|
+ (NSDictionary *)offline_getStateByCountryCode:(NSString *)countryCode checkedState:(NSString *)state_code{
|
|
|
|
|
|
|
|
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
|
|
-
|
|
|
|
|
- sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
|
|
+// NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
|
|
+//
|
|
|
|
|
+// sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
+//
|
|
|
|
|
+// NSString *sqlQuery = [NSString stringWithFormat:@"select _id,name,code,country_code from offline_state where country_code = '%@';",countryCode];
|
|
|
|
|
+//
|
|
|
|
|
+// // NSString *sqlQuery = [NSString stringWithFormat:@"select * from offline_state"];
|
|
|
|
|
+// 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, 1); // value
|
|
|
|
|
+// char *code = (char *) sqlite3_column_text(statement, 2); // 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 (state_code && [[NSString stringWithUTF8String:code] isEqualToString:state_code]) {
|
|
|
|
|
+// [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;
|
|
|
|
|
|
|
|
NSString *sqlQuery = [NSString stringWithFormat:@"select _id,name,code,country_code from offline_state where country_code = '%@';",countryCode];
|
|
NSString *sqlQuery = [NSString stringWithFormat:@"select _id,name,code,country_code from offline_state where country_code = '%@';",countryCode];
|
|
|
|
|
|
|
|
- // NSString *sqlQuery = [NSString stringWithFormat:@"select * from offline_state"];
|
|
|
|
|
- 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, 1); // value
|
|
|
|
|
- char *code = (char *) sqlite3_column_text(statement, 2); // value_id
|
|
|
|
|
-
|
|
|
|
|
|
|
+ NSMutableDictionary *ret = [[iSalesDB jk_query:sqlQuery completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
|
|
+
|
|
|
|
|
+ char *name = (char *) sqlite3_column_text(stmt, 1); // value
|
|
|
|
|
+ char *code = (char *) sqlite3_column_text(stmt, 2); // value_id
|
|
|
|
|
+
|
|
|
NSMutableDictionary *stateDic = [NSMutableDictionary dictionaryWithCapacity:2];
|
|
NSMutableDictionary *stateDic = [NSMutableDictionary dictionaryWithCapacity:2];
|
|
|
[stateDic setValue:[NSString stringWithUTF8String:name] forKey:@"value"];
|
|
[stateDic setValue:[NSString stringWithUTF8String:name] forKey:@"value"];
|
|
|
[stateDic setValue:[NSString stringWithUTF8String:code] forKey:@"value_id"];
|
|
[stateDic setValue:[NSString stringWithUTF8String:code] forKey:@"value_id"];
|
|
|
[stateDic setValue:[NSNumber numberWithInt:0] forKey:@"check"];
|
|
[stateDic setValue:[NSNumber numberWithInt:0] forKey:@"check"];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (state_code && [[NSString stringWithUTF8String:code] isEqualToString:state_code]) {
|
|
if (state_code && [[NSString stringWithUTF8String:code] isEqualToString:state_code]) {
|
|
|
[stateDic setValue:[NSNumber numberWithInt:1] forKey:@"check"];
|
|
[stateDic setValue:[NSNumber numberWithInt:1] forKey:@"check"];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- NSString *key = [NSString stringWithFormat:@"val_%d",i++];
|
|
|
|
|
- [dic setValue:stateDic forKey:key];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ NSString *key = [NSString stringWithFormat:@"val_%ld",(*count)++];
|
|
|
|
|
+ [container setValue:stateDic forKey:key];
|
|
|
|
|
|
|
|
- sqlite3_finalize(statement);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }] mutableCopy];
|
|
|
|
|
|
|
|
- sqlite3_close(db);
|
|
|
|
|
- [dic setValue:[NSNumber numberWithInt:dic.allKeys.count] forKey:@"count"];
|
|
|
|
|
- return dic;
|
|
|
|
|
|
|
+ [ret setValue:[NSNumber numberWithInt:ret.allKeys.count] forKey:@"count"];
|
|
|
|
|
+
|
|
|
|
|
+ return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ (NSDictionary *)offline_getStateByCountryCodeId:(NSString *)codeId checkedState:(NSString *)stateCode {
|
|
+ (NSDictionary *)offline_getStateByCountryCodeId:(NSString *)codeId checkedState:(NSString *)stateCode {
|
|
@@ -3179,7 +3205,8 @@
|
|
|
|
|
|
|
|
NSString *sql = [NSString stringWithFormat:@"insert into offline_contact (company_name,addr_1,addr_2,addr_3,addr_4,country,state,city,zipcode,first_name,last_name,phone,fax,email,notes,price_type,sales_rep,img_0,img_1,img_2,editable,contact_id) values ('%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@',1,'%@')",companyName,addr1,addr2,addr3,addr4,country,state,city,zipcode,fistName,lastName,phone,fax,email,notes,price,salesRep,img_0,img_1,img_2,contact_id];
|
|
NSString *sql = [NSString stringWithFormat:@"insert into offline_contact (company_name,addr_1,addr_2,addr_3,addr_4,country,state,city,zipcode,first_name,last_name,phone,fax,email,notes,price_type,sales_rep,img_0,img_1,img_2,editable,contact_id) values ('%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@',1,'%@')",companyName,addr1,addr2,addr3,addr4,country,state,city,zipcode,fistName,lastName,phone,fax,email,notes,price,salesRep,img_0,img_1,img_2,contact_id];
|
|
|
|
|
|
|
|
- int result = [iSalesDB jk_execSql:sql withDatabase:YES];
|
|
|
|
|
|
|
+// int result = [iSalesDB jk_execSql:sql withDatabase:YES];
|
|
|
|
|
+ int result = [iSalesDB execSql:sql] == SQLITE_OK ? RESULT_TRUE : RESULT_FALSE;
|
|
|
|
|
|
|
|
NSString *retStr = [NSString stringWithFormat:@"{\"result\":%d,\"min_ver\":\"160409\",\"mode\":\"Regular Mode\"}",result];
|
|
NSString *retStr = [NSString stringWithFormat:@"{\"result\":%d,\"min_ver\":\"160409\",\"mode\":\"Regular Mode\"}",result];
|
|
|
|
|
|