|
@@ -1473,7 +1473,7 @@
|
|
|
{
|
|
{
|
|
|
NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
int limit = [[params valueForKey:@"limit"] intValue];
|
|
int limit = [[params valueForKey:@"limit"] intValue];
|
|
|
int offset = [[params valueForKey:@"offset"] intValue];
|
|
int offset = [[params valueForKey:@"offset"] intValue];
|
|
|
NSString* keyword = [params valueForKey:@"keyWord"];
|
|
NSString* keyword = [params valueForKey:@"keyWord"];
|
|
@@ -1981,6 +1981,76 @@
|
|
|
|
|
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
++(NSData *) offline_saveBusinesscard:(NSData *) image
|
|
|
|
|
+{
|
|
|
|
|
+ NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
|
|
|
|
+ NSString *cachefolder = [paths objectAtIndex:0];
|
|
|
|
|
+ NSString *offline_createimg = [cachefolder stringByAppendingPathComponent:@"offline_createimg"];
|
|
|
|
|
+ NSString *img_cache = [cachefolder stringByAppendingPathComponent:@"img_cache"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSFileManager* fileManager = [NSFileManager defaultManager];
|
|
|
|
|
+ BOOL bdir=YES;
|
|
|
|
|
+ if(! [fileManager fileExistsAtPath:offline_createimg isDirectory:&bdir])
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ NSError *error = nil;
|
|
|
|
|
+ bool bsuccess=[fileManager createDirectoryAtPath:offline_createimg withIntermediateDirectories:YES attributes:nil error:&error];
|
|
|
|
|
+
|
|
|
|
|
+ if(!bsuccess)
|
|
|
|
|
+ {
|
|
|
|
|
+ DebugLog(@"Create offline_createimg folder failed");
|
|
|
|
|
+ [ret setValue:[NSNumber numberWithInt:RESULT_ERROR] forKey:@"result"];
|
|
|
|
|
+ return [RAUtils dict2data:ret];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // if(bsuccess)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // sqlite3 *db = [self get_db];
|
|
|
|
|
+ //
|
|
|
|
|
+ // [self execSql:[NSString stringWithFormat:@"insert into img_cache(name) values('%@')",name] db:db];
|
|
|
|
|
+ // sqlite3_close(db);
|
|
|
|
|
+ // }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // NSData *imagedata=UIImagePNGRepresentation(self.imgview.image);
|
|
|
|
|
+
|
|
|
|
|
+ //JEPG格式
|
|
|
|
|
+
|
|
|
|
|
+ //NSData *imagedata=UIImageJEPGRepresentation(m_imgFore,1.0);
|
|
|
|
|
+
|
|
|
|
|
+ NSString* filename =[NSString stringWithFormat:@"%@.png",[[NSUUID UUID] UUIDString]];
|
|
|
|
|
+ NSString *savedImagePath=[offline_createimg stringByAppendingPathComponent:filename];
|
|
|
|
|
+
|
|
|
|
|
+ NSString *cacheImagePath=[img_cache stringByAppendingPathComponent:filename];
|
|
|
|
|
+
|
|
|
|
|
+ bool bsuccess=[image writeToFile:savedImagePath atomically:YES];
|
|
|
|
|
+ if(bsuccess)
|
|
|
|
|
+ {
|
|
|
|
|
+ NSError *error = nil;
|
|
|
|
|
+ if(![fileManager copyItemAtPath:savedImagePath toPath:cacheImagePath error:&error])
|
|
|
|
|
+ {
|
|
|
|
|
+ [ret setValue:[NSNumber numberWithInt:RESULT_ERROR] forKey:@"result"];
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ [ret setValue:[NSNumber numberWithInt:RESULT_TRUE] forKey:@"result"];
|
|
|
|
|
+
|
|
|
|
|
+ ret[@"img_url_aname"]=filename;
|
|
|
|
|
+ ret[@"img_url"]=savedImagePath;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ [ret setValue:[NSNumber numberWithInt:RESULT_ERROR] forKey:@"result"];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return [RAUtils dict2data:ret];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
+(NSDictionary*) offline_contactlist :(NSMutableDictionary *) params
|
|
+(NSDictionary*) offline_contactlist :(NSMutableDictionary *) params
|
|
|
{
|
|
{
|
|
|
|
|
|
|
@@ -2588,11 +2658,11 @@
|
|
|
|
|
|
|
|
#pragma mark create new contact
|
|
#pragma mark create new contact
|
|
|
+ (NSDictionary *)offline_getAllCountryDefault:(NSString *)countryCode {
|
|
+ (NSDictionary *)offline_getAllCountryDefault:(NSString *)countryCode {
|
|
|
-// "val_227" : {
|
|
|
|
|
-// "check" : 1,
|
|
|
|
|
-// "value" : "US United States",
|
|
|
|
|
-// "value_id" : "228"
|
|
|
|
|
-// },
|
|
|
|
|
|
|
+ // "val_227" : {
|
|
|
|
|
+ // "check" : 1,
|
|
|
|
|
+ // "value" : "US United States",
|
|
|
|
|
+ // "value_id" : "228"
|
|
|
|
|
+ // },
|
|
|
|
|
|
|
|
if (!countryCode) {
|
|
if (!countryCode) {
|
|
|
countryCode = @"US";
|
|
countryCode = @"US";
|
|
@@ -2641,7 +2711,7 @@
|
|
|
|
|
|
|
|
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"];
|
|
|
|
|
|
|
+ // NSString *sqlQuery = [NSString stringWithFormat:@"select * from offline_state"];
|
|
|
DebugLog(@"query state:%@",sqlQuery);
|
|
DebugLog(@"query state:%@",sqlQuery);
|
|
|
|
|
|
|
|
sqlite3_stmt * statement;
|
|
sqlite3_stmt * statement;
|
|
@@ -2709,7 +2779,7 @@
|
|
|
sqlite3_close(db);
|
|
sqlite3_close(db);
|
|
|
[dic setValue:[NSNumber numberWithInt:dic.allKeys.count] forKey:@"count"];
|
|
[dic setValue:[NSNumber numberWithInt:dic.allKeys.count] forKey:@"count"];
|
|
|
return dic;
|
|
return dic;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ (NSDictionary *)offline_getPrice {
|
|
+ (NSDictionary *)offline_getPrice {
|
|
@@ -2740,7 +2810,7 @@
|
|
|
|
|
|
|
|
sqlite3_finalize(statement);
|
|
sqlite3_finalize(statement);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
sqlite3_close(db);
|
|
sqlite3_close(db);
|
|
|
|
|
|
|
|
[dic setValue:[NSNumber numberWithInt:dic.allKeys.count] forKey:@"count"];
|
|
[dic setValue:[NSNumber numberWithInt:dic.allKeys.count] forKey:@"count"];
|
|
@@ -2762,12 +2832,12 @@
|
|
|
char *name = (char *)sqlite3_column_text(statement, 1);
|
|
char *name = (char *)sqlite3_column_text(statement, 1);
|
|
|
char *code = (char *)sqlite3_column_text(statement, 2);
|
|
char *code = (char *)sqlite3_column_text(statement, 2);
|
|
|
int salesrep_id = sqlite3_column_int(statement, 3);
|
|
int salesrep_id = sqlite3_column_int(statement, 3);
|
|
|
-// int _id = sqlite3_column_int(statement, 0);
|
|
|
|
|
-//
|
|
|
|
|
-// "val_0" : {
|
|
|
|
|
-// "value" : "BBSC - BARBARA BORROUGHS",
|
|
|
|
|
-// "value_id" : 121
|
|
|
|
|
-// },
|
|
|
|
|
|
|
+ // int _id = sqlite3_column_int(statement, 0);
|
|
|
|
|
+ //
|
|
|
|
|
+ // "val_0" : {
|
|
|
|
|
+ // "value" : "BBSC - BARBARA BORROUGHS",
|
|
|
|
|
+ // "value_id" : 121
|
|
|
|
|
+ // },
|
|
|
NSMutableDictionary *repDic = [NSMutableDictionary dictionary];
|
|
NSMutableDictionary *repDic = [NSMutableDictionary dictionary];
|
|
|
[repDic setValue:[NSString stringWithFormat:@"%s - %s",code,name] forKey:@"value"];
|
|
[repDic setValue:[NSString stringWithFormat:@"%s - %s",code,name] forKey:@"value"];
|
|
|
[repDic setValue:[NSNumber numberWithInt:salesrep_id] forKey:@"value_id"];
|
|
[repDic setValue:[NSNumber numberWithInt:salesrep_id] forKey:@"value_id"];
|
|
@@ -2828,7 +2898,7 @@
|
|
|
sqlite3_finalize(statement);
|
|
sqlite3_finalize(statement);
|
|
|
}
|
|
}
|
|
|
sqlite3_close(db);
|
|
sqlite3_close(db);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2857,7 +2927,7 @@
|
|
|
sqlite3_finalize(statement);
|
|
sqlite3_finalize(statement);
|
|
|
}
|
|
}
|
|
|
sqlite3_close(db);
|
|
sqlite3_close(db);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
return dic;
|
|
return dic;
|
|
|
}
|
|
}
|
|
@@ -2926,7 +2996,7 @@
|
|
|
|
|
|
|
|
// state
|
|
// state
|
|
|
NSDictionary *allState = [self offline_getStateByCountryCode:countryCode checkedState:stateCode];
|
|
NSDictionary *allState = [self offline_getStateByCountryCode:countryCode checkedState:stateCode];
|
|
|
-// NSDictionary *allState = [self offline_getStateByCountryCodeId:countryCode_id checkedState:stateCode];
|
|
|
|
|
|
|
+ // NSDictionary *allState = [self offline_getStateByCountryCodeId:countryCode_id checkedState:stateCode];
|
|
|
[self setValue:allState forItemKey:@"item_11" valueKey:@"cadedate" inDictionary:section_0];
|
|
[self setValue:allState forItemKey:@"item_11" valueKey:@"cadedate" inDictionary:section_0];
|
|
|
|
|
|
|
|
// city
|
|
// city
|
|
@@ -2940,7 +3010,7 @@
|
|
|
// price type
|
|
// price type
|
|
|
NSDictionary *priceDic = [self offline_getPrice];
|
|
NSDictionary *priceDic = [self offline_getPrice];
|
|
|
[self setValue:priceDic forItemKey:@"item_2" valueKey:@"cadedate" inDictionary:section_0];
|
|
[self setValue:priceDic forItemKey:@"item_2" valueKey:@"cadedate" inDictionary:section_0];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Sales Rep
|
|
// Sales Rep
|
|
|
NSDictionary *repDic = [self offline_getSalesRep];
|
|
NSDictionary *repDic = [self offline_getSalesRep];
|
|
|
[self setValue:repDic forItemKey:@"item_17" valueKey:@"cadedate" inDictionary:section_0];
|
|
[self setValue:repDic forItemKey:@"item_17" valueKey:@"cadedate" inDictionary:section_0];
|