|
|
@@ -1895,297 +1895,6 @@
|
|
|
return [RAUtils dict2data:ret];
|
|
|
}
|
|
|
|
|
|
-+(NSDictionary*) offline_contactlist :(NSMutableDictionary *) params
|
|
|
-{
|
|
|
-
|
|
|
-// contactType = "Sales_Order_Customer";
|
|
|
-// "contact_name" = "12.03";
|
|
|
-// "customer_address" = 123;
|
|
|
-// "customer_cid" = 12;
|
|
|
-// "customer_city" = 123;
|
|
|
-// "customer_country" = 123;
|
|
|
-// "customer_email" = 5464;
|
|
|
-// "customer_fax" = 4564;
|
|
|
-// "customer_name" = 123;
|
|
|
-// "customer_phone" = 454;
|
|
|
-// "customer_sales_rep" = 456465;
|
|
|
-// "customer_state" = 13;
|
|
|
-// "customer_zipcode" = 123;
|
|
|
-// limit = 25;
|
|
|
-// offset = 0;
|
|
|
-// password = 123456;
|
|
|
-// "price_name" = 16;
|
|
|
-// user = EvanK;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- NSString* contactType = [params valueForKey:@"contactType"];
|
|
|
-
|
|
|
- NSString* keyword = [params valueForKey:@"keyword"];
|
|
|
-
|
|
|
-
|
|
|
- // advanced search
|
|
|
-
|
|
|
- // NSString* contact_name = [params valueForKey:@"contact_name"];
|
|
|
- // NSString* customer_phone = [params valueForKey:@"customer_phone"];
|
|
|
- // NSString* customer_fax = [params valueForKey:@"customer_fax"];
|
|
|
- // NSString* customer_zipcode = [params valueForKey:@"customer_zipcode"];
|
|
|
- // NSString* sales_rep = [params valueForKey:@"sales_rep"];
|
|
|
- // NSString* customer_state = [params valueForKey:@"customer_state"];
|
|
|
- // NSString* customer_name = [params valueForKey:@"customer_name"];
|
|
|
- // NSString* customer_country = [params valueForKey:@"customer_country"];
|
|
|
- // NSString* customer_cid = [params valueForKey:@"customer_cid"];
|
|
|
- // NSString* customer_city = [params valueForKey:@"customer_city"];
|
|
|
- // NSString* customer_address = [params valueForKey:@"customer_address"];
|
|
|
- // NSString* customer_email = [params valueForKey:@"customer_email"];
|
|
|
-
|
|
|
-
|
|
|
- int limit = [[params valueForKey:@"limit"] intValue];
|
|
|
- int offset = [[params valueForKey:@"offset"] intValue];
|
|
|
-
|
|
|
-
|
|
|
- NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- sqlite3 *db = [iSalesDB get_db];
|
|
|
-
|
|
|
- int result= [iSalesDB AddExFunction:db];
|
|
|
-
|
|
|
- int count =0;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- NSString *sqlQuery = nil;
|
|
|
-
|
|
|
- if(keyword.length==0)
|
|
|
- {
|
|
|
- sqlQuery=[NSString stringWithFormat:@"select editable,company_name,country,addr,zipcode,state,city,contact_name,phone,contact_id,addr_1,addr_2,addr_3,addr_4,first_name,last_name,fax,email from offline_contact where %@=1 order by decrypt(company_name) limit %d offset %d",contactType , limit, offset];
|
|
|
- count=[iSalesDB get_recordcount:db table:@"offline_contact" where:[NSString stringWithFormat:@"%@='1",contactType]];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // NSString* encrypt_keyword= [AESCrypt fastencrypt:keyword];
|
|
|
-
|
|
|
- keyword = keyword.lowercaseString;
|
|
|
-
|
|
|
-
|
|
|
- sqlQuery=[NSString stringWithFormat:@"select editable,company_name,country,addr,zipcode,state,city,contact_name,phone,contact_id,addr_1,addr_2,addr_3,addr_4,first_name,last_name,fax,email from offline_contact where %@=1 and (lower(contact_id ) like'%%%@%%' or lower(decrypt(company_name)) like '%%%@%%') order by decrypt(company_name) limit %d offset %d",contactType , keyword,keyword,limit, offset];
|
|
|
-
|
|
|
- count=[iSalesDB get_recordcount:db table:@"offline_contact" where:[NSString stringWithFormat:@"%@=1 and (lower(contact_id ) like'%@' or lower(company_name) like'%@')",contactType,keyword,keyword]];
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- DebugLog(@"offline_contactlist sql:%@",sqlQuery);
|
|
|
- sqlite3_stmt * statement;
|
|
|
-
|
|
|
-
|
|
|
- [ret setValue:@"2" forKey:@"result"];
|
|
|
- [ret setValue:[NSNumber numberWithInt:count ] forKey:@"total"];
|
|
|
-
|
|
|
-
|
|
|
- if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
|
- {
|
|
|
-
|
|
|
- int i = 0;
|
|
|
- while (sqlite3_step(statement) == SQLITE_ROW)
|
|
|
- {
|
|
|
-
|
|
|
- [ret setValue:[NSNumber numberWithInt:AP_USER_AUTH ] forKey:@"result"];
|
|
|
-
|
|
|
- NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
|
|
-
|
|
|
-
|
|
|
- int editable = sqlite3_column_int(statement, 0);
|
|
|
-
|
|
|
-
|
|
|
- char *company_name = (char*)sqlite3_column_text(statement, 1);
|
|
|
- NSString *nscompany_name =nil;
|
|
|
- if(company_name==nil)
|
|
|
- nscompany_name=@"";
|
|
|
- else
|
|
|
- nscompany_name= [[NSString alloc]initWithUTF8String:company_name] ;
|
|
|
-
|
|
|
-
|
|
|
- char *country = (char*)sqlite3_column_text(statement, 2);
|
|
|
- if(country==nil)
|
|
|
- country="";
|
|
|
- NSString *nscountry= [[NSString alloc]initWithUTF8String:country];
|
|
|
-
|
|
|
-
|
|
|
- // char *addr = (char*)sqlite3_column_text(statement, 3);
|
|
|
- // if(addr==nil)
|
|
|
- // addr="";
|
|
|
- // NSString *nsaddr= [[NSString alloc]initWithUTF8String:addr];
|
|
|
-
|
|
|
-
|
|
|
- char *zipcode = (char*)sqlite3_column_text(statement, 4);
|
|
|
- if(zipcode==nil)
|
|
|
- zipcode="";
|
|
|
- NSString *nszipcode= [[NSString alloc]initWithUTF8String:zipcode];
|
|
|
-
|
|
|
-
|
|
|
- char *state = (char*)sqlite3_column_text(statement, 5);
|
|
|
- if(state==nil)
|
|
|
- state="";
|
|
|
- NSString *nsstate= [[NSString alloc]initWithUTF8String:state];
|
|
|
-
|
|
|
- char *city = (char*)sqlite3_column_text(statement, 6);
|
|
|
- if(city==nil)
|
|
|
- city="";
|
|
|
- NSString *nscity= [[NSString alloc]initWithUTF8String:city];
|
|
|
-
|
|
|
- // char *contact_name = (char*)sqlite3_column_text(statement, 7);
|
|
|
- // NSString *nscontact_name = nil;
|
|
|
- // if(contact_name==nil)
|
|
|
- // nscontact_name=@"";
|
|
|
- // else
|
|
|
- // nscontact_name= [[NSString alloc]initWithUTF8String:contact_name];
|
|
|
-
|
|
|
- char *phone = (char*)sqlite3_column_text(statement, 8);
|
|
|
- NSString *nsphone = nil;
|
|
|
- if(phone==nil)
|
|
|
- nsphone=@"";
|
|
|
- else
|
|
|
- nsphone= [[NSString alloc]initWithUTF8String:phone];
|
|
|
-
|
|
|
-
|
|
|
- char *contact_id = (char*)sqlite3_column_text(statement, 9);
|
|
|
- if(contact_id==nil)
|
|
|
- contact_id="";
|
|
|
- NSString *nscontact_id= [[NSString alloc]initWithUTF8String:contact_id];
|
|
|
-
|
|
|
- char *addr_1 = (char*)sqlite3_column_text(statement, 10);
|
|
|
- if(addr_1==nil)
|
|
|
- addr_1="";
|
|
|
- NSString *nsaddr_1= [[NSString alloc]initWithUTF8String:addr_1];
|
|
|
-
|
|
|
- char *addr_2 = (char*)sqlite3_column_text(statement, 11);
|
|
|
- if(addr_2==nil)
|
|
|
- addr_2="";
|
|
|
- NSString *nsaddr_2= [[NSString alloc]initWithUTF8String:addr_2];
|
|
|
-
|
|
|
-
|
|
|
- char *addr_3 = (char*)sqlite3_column_text(statement, 12);
|
|
|
- if(addr_3==nil)
|
|
|
- addr_3="";
|
|
|
- NSString *nsaddr_3= [[NSString alloc]initWithUTF8String:addr_3];
|
|
|
-
|
|
|
-
|
|
|
- char *addr_4 = (char*)sqlite3_column_text(statement, 13);
|
|
|
- if(addr_4==nil)
|
|
|
- addr_4="";
|
|
|
- NSString *nsaddr_4= [[NSString alloc]initWithUTF8String:addr_4];
|
|
|
-
|
|
|
-
|
|
|
- char *first_name = (char*)sqlite3_column_text(statement, 14);
|
|
|
- if(first_name==nil)
|
|
|
- first_name="";
|
|
|
- NSString *nsfirst_name= [[NSString alloc]initWithUTF8String:first_name];
|
|
|
-
|
|
|
-
|
|
|
- char *last_name = (char*)sqlite3_column_text(statement, 15);
|
|
|
- if(last_name==nil)
|
|
|
- last_name="";
|
|
|
- NSString *nslast_name= [[NSString alloc]initWithUTF8String:last_name];
|
|
|
-
|
|
|
- char *fax = (char*)sqlite3_column_text(statement, 16);
|
|
|
- NSString *nsfax = nil;
|
|
|
- if(fax==nil)
|
|
|
- nsfax=@"";
|
|
|
- else
|
|
|
- nsfax= [NSString stringWithFormat:@"FAX:%@",[[NSString alloc]initWithUTF8String:fax]];
|
|
|
-
|
|
|
- char *email = (char*)sqlite3_column_text(statement, 17);
|
|
|
- NSString *nsemail = nil;
|
|
|
- if(email==nil)
|
|
|
- nsemail=@"";
|
|
|
- else
|
|
|
- nsemail= [NSString stringWithFormat:@"EMAIL:%@",[[NSString alloc]initWithUTF8String:email]];
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- NSMutableArray* arr_name= [[NSMutableArray alloc] init];
|
|
|
-
|
|
|
- [arr_name addObject:nsfirst_name];
|
|
|
- [arr_name addObject:nslast_name];
|
|
|
-
|
|
|
- NSString *nscontact_name=[RAUtils arr2string:arr_name separator:@" " trim:true];
|
|
|
-
|
|
|
- NSMutableArray* arr_addr = [[NSMutableArray alloc] init];
|
|
|
-
|
|
|
- {
|
|
|
- // decrypt
|
|
|
-
|
|
|
- nscompany_name=[AESCrypt fastdecrypt:nscompany_name];
|
|
|
-
|
|
|
- nscompany_name=[NSString stringWithFormat:@"<b>%@</b>",nscompany_name];
|
|
|
-
|
|
|
- nsphone=[AESCrypt fastdecrypt:nsphone];
|
|
|
- nsphone=[NSString stringWithFormat:@"TEL:%@",nsphone];
|
|
|
-
|
|
|
- nsaddr_1=[AESCrypt fastdecrypt:nsaddr_1];
|
|
|
- // nsaddr_1=[NSString stringWithFormat:@"TEL:%@",nsphone];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- [arr_addr addObject:nscompany_name];
|
|
|
- [arr_addr addObject:nscontact_name];
|
|
|
- [arr_addr addObject:@"<br>"];
|
|
|
-
|
|
|
- [arr_addr addObject:nsaddr_1];
|
|
|
- [arr_addr addObject:nsaddr_2];
|
|
|
- [arr_addr addObject:nsaddr_3];
|
|
|
- [arr_addr addObject:nsaddr_4];
|
|
|
- //[arr_addr addObject:nsaddr];
|
|
|
- [arr_addr addObject:nszipcode];
|
|
|
- [arr_addr addObject:nscity];
|
|
|
- [arr_addr addObject:nsstate];
|
|
|
- [arr_addr addObject:nscountry];
|
|
|
- [arr_addr addObject:@"<br>"];
|
|
|
- [arr_addr addObject:nsphone];
|
|
|
- [arr_addr addObject:nsfax];
|
|
|
- [arr_addr addObject:nsemail];
|
|
|
-
|
|
|
- NSString * name = [RAUtils arr2string:arr_addr separator:@", " trim:true];
|
|
|
-
|
|
|
- name=[name stringByReplacingOccurrencesOfString:@", <br>," withString:@"<br>"];
|
|
|
-
|
|
|
-
|
|
|
- [item setValue:name forKey:@"name"];
|
|
|
- [item setValue:nscontact_id forKey:@"contact_id"];
|
|
|
- [item setValue:editable==1?@"true":@"false" forKey:@"can_update"];
|
|
|
- [ret setObject:item forKey:[NSString stringWithFormat:@"item_%d",i]];
|
|
|
- i++;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- UIApplication * app = [UIApplication sharedApplication];
|
|
|
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
|
|
|
- [ret setValue:appDelegate.mode forKey:@"mode"];
|
|
|
- [ret setValue:[NSNumber numberWithInt:i ] forKey:@"count"];
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- sqlite3_finalize(statement);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [iSalesDB close_db:db];
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- DebugLog(@"data string: %@",[RAUtils dict2string:ret] );
|
|
|
-
|
|
|
- return ret;
|
|
|
-}
|
|
|
+(NSDictionary*) model_NIYMAL:(NSString*) category db:(sqlite3 *)db
|
|
|
{
|
|
|
// MODEL DETAIL NEW ITEM YOU MAY ALSO LIKE
|
|
|
@@ -2884,6 +2593,350 @@
|
|
|
return [string stringByReplacingOccurrencesOfString:@"'" withString:@"''"];
|
|
|
}
|
|
|
|
|
|
++ (NSString *)valueInParams:(NSDictionary *)params key:(NSString *)key {
|
|
|
+ return [params valueForKey:key] ? [params valueForKey:key] : @"";
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark contact list
|
|
|
+
|
|
|
++(NSDictionary*) offline_contactlist :(NSMutableDictionary *) params
|
|
|
+{
|
|
|
+
|
|
|
+ // contactType = "Sales_Order_Customer";
|
|
|
+ // limit = 25;
|
|
|
+ // offset = 0;
|
|
|
+ // password = 123456;
|
|
|
+ // "price_name" = 16;
|
|
|
+ // user = EvanK;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ NSString* contactType = [params valueForKey:@"contactType"]; // contactType = "Sales_Order_Customer";
|
|
|
+ if (contactType) {
|
|
|
+ contactType = [NSString stringWithFormat:@"%@ = 1",contactType];
|
|
|
+ } else {
|
|
|
+ contactType = @"1 = 1";
|
|
|
+ }
|
|
|
+
|
|
|
+ // advanced search
|
|
|
+
|
|
|
+ NSString* contact_name = [params valueForKey:@"contact_name"]; // "contact_name"
|
|
|
+ if (contact_name) {
|
|
|
+ contact_name = [NSString stringWithFormat:@"contact_name = '%@'",contact_name];
|
|
|
+ } else {
|
|
|
+ contact_name = @"";
|
|
|
+ }
|
|
|
+ NSString* customer_phone = [params valueForKey:@"customer_phone"]; // "customer_phone"
|
|
|
+ if (customer_phone) {
|
|
|
+ customer_phone = [NSString stringWithFormat:@"and phone = '%@'",customer_phone];
|
|
|
+ } else {
|
|
|
+ customer_phone = @"";
|
|
|
+ }
|
|
|
+ NSString* customer_fax = [params valueForKey:@"customer_fax"]; // "customer_fax"
|
|
|
+ if (customer_fax) {
|
|
|
+ customer_fax = [NSString stringWithFormat:@"and fax = '%@'",customer_fax];
|
|
|
+ } else {
|
|
|
+ customer_fax = @"";
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString* customer_zipcode = [params valueForKey:@"customer_zipcode"]; // "customer_zipcode"
|
|
|
+ if (customer_zipcode) {
|
|
|
+ customer_zipcode = [NSString stringWithFormat:@"and zipcode = '%@'",customer_zipcode];
|
|
|
+ } else {
|
|
|
+ customer_zipcode = @"";
|
|
|
+ }
|
|
|
+ NSString* customer_sales_rep = [params valueForKey:@"customer_sales_rep"]; // "customer_sales_rep"
|
|
|
+ if (customer_sales_rep) {
|
|
|
+ customer_sales_rep = [NSString stringWithFormat:@"and sales_rep = '%@'",customer_sales_rep];
|
|
|
+ } else {
|
|
|
+ customer_sales_rep = @"";
|
|
|
+ }
|
|
|
+ NSString* customer_state = [params valueForKey:@"customer_state"]; // "customer_state"
|
|
|
+ if (customer_state) {
|
|
|
+ customer_state = [NSString stringWithFormat:@"and state = '%@'",customer_state];
|
|
|
+ } else {
|
|
|
+ customer_state = @"";
|
|
|
+ }
|
|
|
+ NSString* customer_name = [params valueForKey:@"customer_name"]; // "customer_name" 也就是company name
|
|
|
+ if (customer_name) {
|
|
|
+ customer_name = [NSString stringWithFormat:@"and decrypt(company_name) = '%@'",customer_name];
|
|
|
+ } else {
|
|
|
+ customer_name = @"";
|
|
|
+ }
|
|
|
+ NSString* customer_country = [params valueForKey:@"customer_country"]; // "customer_country"
|
|
|
+ if (customer_country) {
|
|
|
+ customer_country = [NSString stringWithFormat:@"and country like '%%%@%%'",customer_country];
|
|
|
+ } else {
|
|
|
+ customer_country = @"";
|
|
|
+ }
|
|
|
+ NSString* customer_cid = [params valueForKey:@"customer_cid"]; // "customer_cid"
|
|
|
+ if (customer_cid) {
|
|
|
+ customer_cid = [NSString stringWithFormat:@"and contact_id = '%@'",customer_cid];
|
|
|
+ } else {
|
|
|
+ customer_cid = @"";
|
|
|
+ }
|
|
|
+ NSString* customer_city = [params valueForKey:@"customer_city"]; // "customer_city"
|
|
|
+ if (customer_city) {
|
|
|
+ customer_city = [NSString stringWithFormat:@"and city = '%@'",customer_city];
|
|
|
+ } else {
|
|
|
+ customer_city = @"";
|
|
|
+ }
|
|
|
+ NSString* customer_address = [params valueForKey:@"customer_address"]; // "customer_address"
|
|
|
+ if (customer_address) {
|
|
|
+ customer_address = [NSString stringWithFormat:@"and decrypt(addr) = '%@'",customer_address];
|
|
|
+ } else {
|
|
|
+ customer_address = @"";
|
|
|
+ }
|
|
|
+ NSString* customer_email = [params valueForKey:@"customer_email"]; // "customer_email"
|
|
|
+ if (customer_email) {
|
|
|
+ customer_email = [NSString stringWithFormat:@"and email = '%@'",customer_email];
|
|
|
+ } else {
|
|
|
+ customer_email = @"";
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *price_name = [params valueForKey:@"price_name"];
|
|
|
+ if (price_name) {
|
|
|
+ price_name = [NSString stringWithFormat:@"and price_type in (SELECT name FROM price where type = %@ )",price_name];
|
|
|
+ } else {
|
|
|
+ price_name = @"";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ int limit = [[params valueForKey:@"limit"] intValue];
|
|
|
+ int offset = [[params valueForKey:@"offset"] intValue];
|
|
|
+
|
|
|
+
|
|
|
+ NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
+
|
|
|
+ NSString *where = [NSString stringWithFormat:@" %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ %@ ",contactType,contact_name,customer_phone,customer_fax,customer_zipcode,customer_sales_rep,customer_state,customer_name,customer_country,customer_cid,customer_city,customer_address,customer_email,price_name];
|
|
|
+
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select editable,company_name,country,addr,zipcode,state,city,contact_name,phone,contact_id,addr_1,addr_2,addr_3,addr_4,first_name,last_name,fax,email from offline_contact where %@ order by decrypt(company_name) limit %d offset %d",where,limit,offset];
|
|
|
+
|
|
|
+
|
|
|
+ sqlite3 *db = [iSalesDB get_db];
|
|
|
+
|
|
|
+ int result= [iSalesDB AddExFunction:db];
|
|
|
+
|
|
|
+ int count =0;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ NSString *sqlQuery = nil;
|
|
|
+
|
|
|
+ sqlQuery = sql;
|
|
|
+
|
|
|
+ count = [iSalesDB get_recordcount:db table:@"offline_contact" where:where];
|
|
|
+
|
|
|
+ DebugLog(@"offline_contactlist sql:%@",sqlQuery);
|
|
|
+ sqlite3_stmt * statement;
|
|
|
+
|
|
|
+
|
|
|
+ [ret setValue:@"2" forKey:@"result"];
|
|
|
+ [ret setValue:[NSNumber numberWithInt:count ] forKey:@"total"];
|
|
|
+
|
|
|
+
|
|
|
+ if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
|
+ {
|
|
|
+
|
|
|
+ int i = 0;
|
|
|
+ while (sqlite3_step(statement) == SQLITE_ROW)
|
|
|
+ {
|
|
|
+
|
|
|
+ [ret setValue:[NSNumber numberWithInt:AP_USER_AUTH ] forKey:@"result"];
|
|
|
+
|
|
|
+ NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
|
|
+
|
|
|
+
|
|
|
+ int editable = sqlite3_column_int(statement, 0);
|
|
|
+
|
|
|
+
|
|
|
+ char *company_name = (char*)sqlite3_column_text(statement, 1);
|
|
|
+ NSString *nscompany_name =nil;
|
|
|
+ if(company_name==nil)
|
|
|
+ nscompany_name=@"";
|
|
|
+ else
|
|
|
+ nscompany_name= [[NSString alloc]initWithUTF8String:company_name] ;
|
|
|
+
|
|
|
+
|
|
|
+ char *country = (char*)sqlite3_column_text(statement, 2);
|
|
|
+ if(country==nil)
|
|
|
+ country="";
|
|
|
+ NSString *nscountry= [[NSString alloc]initWithUTF8String:country];
|
|
|
+
|
|
|
+
|
|
|
+// char *addr = (char*)sqlite3_column_text(statement, 3);
|
|
|
+// if(addr==nil)
|
|
|
+// addr="";
|
|
|
+// NSString *nsaddr= [[NSString alloc]initWithUTF8String:addr];
|
|
|
+
|
|
|
+
|
|
|
+ char *zipcode = (char*)sqlite3_column_text(statement, 4);
|
|
|
+ if(zipcode==nil)
|
|
|
+ zipcode="";
|
|
|
+ NSString *nszipcode= [[NSString alloc]initWithUTF8String:zipcode];
|
|
|
+
|
|
|
+
|
|
|
+ char *state = (char*)sqlite3_column_text(statement, 5);
|
|
|
+ if(state==nil)
|
|
|
+ state="";
|
|
|
+ NSString *nsstate= [[NSString alloc]initWithUTF8String:state];
|
|
|
+
|
|
|
+ char *city = (char*)sqlite3_column_text(statement, 6);
|
|
|
+ if(city==nil)
|
|
|
+ city="";
|
|
|
+ NSString *nscity= [[NSString alloc]initWithUTF8String:city];
|
|
|
+
|
|
|
+// char *contact_name = (char*)sqlite3_column_text(statement, 7);
|
|
|
+// NSString *nscontact_name = nil;
|
|
|
+// if(contact_name==nil)
|
|
|
+// nscontact_name=@"";
|
|
|
+// else
|
|
|
+// nscontact_name= [[NSString alloc]initWithUTF8String:contact_name];
|
|
|
+
|
|
|
+ char *phone = (char*)sqlite3_column_text(statement, 8);
|
|
|
+ NSString *nsphone = nil;
|
|
|
+ if(phone==nil)
|
|
|
+ nsphone=@"";
|
|
|
+ else
|
|
|
+ nsphone= [[NSString alloc]initWithUTF8String:phone];
|
|
|
+
|
|
|
+
|
|
|
+ char *contact_id = (char*)sqlite3_column_text(statement, 9);
|
|
|
+ if(contact_id==nil)
|
|
|
+ contact_id="";
|
|
|
+ NSString *nscontact_id= [[NSString alloc]initWithUTF8String:contact_id];
|
|
|
+
|
|
|
+ char *addr_1 = (char*)sqlite3_column_text(statement, 10);
|
|
|
+ if(addr_1==nil)
|
|
|
+ addr_1="";
|
|
|
+ NSString *nsaddr_1= [[NSString alloc]initWithUTF8String:addr_1];
|
|
|
+
|
|
|
+ char *addr_2 = (char*)sqlite3_column_text(statement, 11);
|
|
|
+ if(addr_2==nil)
|
|
|
+ addr_2="";
|
|
|
+ NSString *nsaddr_2= [[NSString alloc]initWithUTF8String:addr_2];
|
|
|
+
|
|
|
+
|
|
|
+ char *addr_3 = (char*)sqlite3_column_text(statement, 12);
|
|
|
+ if(addr_3==nil)
|
|
|
+ addr_3="";
|
|
|
+ NSString *nsaddr_3= [[NSString alloc]initWithUTF8String:addr_3];
|
|
|
+
|
|
|
+
|
|
|
+ char *addr_4 = (char*)sqlite3_column_text(statement, 13);
|
|
|
+ if(addr_4==nil)
|
|
|
+ addr_4="";
|
|
|
+ NSString *nsaddr_4= [[NSString alloc]initWithUTF8String:addr_4];
|
|
|
+
|
|
|
+
|
|
|
+ char *first_name = (char*)sqlite3_column_text(statement, 14);
|
|
|
+ if(first_name==nil)
|
|
|
+ first_name="";
|
|
|
+ NSString *nsfirst_name= [[NSString alloc]initWithUTF8String:first_name];
|
|
|
+
|
|
|
+
|
|
|
+ char *last_name = (char*)sqlite3_column_text(statement, 15);
|
|
|
+ if(last_name==nil)
|
|
|
+ last_name="";
|
|
|
+ NSString *nslast_name= [[NSString alloc]initWithUTF8String:last_name];
|
|
|
+
|
|
|
+ char *fax = (char*)sqlite3_column_text(statement, 16);
|
|
|
+ NSString *nsfax = nil;
|
|
|
+ if(fax==nil)
|
|
|
+ nsfax=@"";
|
|
|
+ else
|
|
|
+ nsfax= [NSString stringWithFormat:@"FAX:%@",[[NSString alloc]initWithUTF8String:fax]];
|
|
|
+
|
|
|
+ char *email = (char*)sqlite3_column_text(statement, 17);
|
|
|
+ NSString *nsemail = nil;
|
|
|
+ if(email==nil)
|
|
|
+ nsemail=@"";
|
|
|
+ else
|
|
|
+ nsemail= [NSString stringWithFormat:@"EMAIL:%@",[[NSString alloc]initWithUTF8String:email]];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ NSMutableArray* arr_name= [[NSMutableArray alloc] init];
|
|
|
+
|
|
|
+ [arr_name addObject:nsfirst_name];
|
|
|
+ [arr_name addObject:nslast_name];
|
|
|
+
|
|
|
+ NSString *nscontact_name=[RAUtils arr2string:arr_name separator:@" " trim:true];
|
|
|
+
|
|
|
+ NSMutableArray* arr_addr = [[NSMutableArray alloc] init];
|
|
|
+
|
|
|
+ {
|
|
|
+ // decrypt
|
|
|
+
|
|
|
+ nscompany_name=[AESCrypt fastdecrypt:nscompany_name];
|
|
|
+
|
|
|
+ nscompany_name=[NSString stringWithFormat:@"<b>%@</b>",nscompany_name];
|
|
|
+
|
|
|
+ nsphone=[AESCrypt fastdecrypt:nsphone];
|
|
|
+ nsphone=[NSString stringWithFormat:@"TEL:%@",nsphone];
|
|
|
+
|
|
|
+ nsaddr_1=[AESCrypt fastdecrypt:nsaddr_1];
|
|
|
+ // nsaddr_1=[NSString stringWithFormat:@"TEL:%@",nsphone];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ [arr_addr addObject:nscompany_name];
|
|
|
+ [arr_addr addObject:nscontact_name];
|
|
|
+ [arr_addr addObject:@"<br>"];
|
|
|
+
|
|
|
+ [arr_addr addObject:nsaddr_1];
|
|
|
+ [arr_addr addObject:nsaddr_2];
|
|
|
+ [arr_addr addObject:nsaddr_3];
|
|
|
+ [arr_addr addObject:nsaddr_4];
|
|
|
+ //[arr_addr addObject:nsaddr];
|
|
|
+ [arr_addr addObject:nszipcode];
|
|
|
+ [arr_addr addObject:nscity];
|
|
|
+ [arr_addr addObject:nsstate];
|
|
|
+ [arr_addr addObject:nscountry];
|
|
|
+ [arr_addr addObject:@"<br>"];
|
|
|
+ [arr_addr addObject:nsphone];
|
|
|
+ [arr_addr addObject:nsfax];
|
|
|
+ [arr_addr addObject:nsemail];
|
|
|
+
|
|
|
+ NSString * name = [RAUtils arr2string:arr_addr separator:@", " trim:true];
|
|
|
+
|
|
|
+ name=[name stringByReplacingOccurrencesOfString:@", <br>," withString:@"<br>"];
|
|
|
+
|
|
|
+
|
|
|
+ [item setValue:name forKey:@"name"];
|
|
|
+ [item setValue:nscontact_id forKey:@"contact_id"];
|
|
|
+ [item setValue:editable==1?@"true":@"false" forKey:@"can_update"];
|
|
|
+ [ret setObject:item forKey:[NSString stringWithFormat:@"item_%d",i]];
|
|
|
+ i++;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ UIApplication * app = [UIApplication sharedApplication];
|
|
|
+ AppDelegate *appDelegate = (AppDelegate *)[app delegate];
|
|
|
+ [ret setValue:appDelegate.mode forKey:@"mode"];
|
|
|
+ [ret setValue:[NSNumber numberWithInt:i ] forKey:@"count"];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ sqlite3_finalize(statement);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [iSalesDB close_db:db];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DebugLog(@"data string: %@",[RAUtils dict2string:ret] );
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
#pragma mark contact search
|
|
|
|
|
|
+(NSData *) offline_contactAdvancedSearch:(NSMutableDictionary *) params
|