|
|
@@ -9,6 +9,10 @@
|
|
|
#import "OLDataProvider.h"
|
|
|
#import "iSalesDB.h"
|
|
|
#import "RAUtils.h"
|
|
|
+#import "AESCrypt.h"
|
|
|
+#import "AppDelegate.h"
|
|
|
+
|
|
|
+
|
|
|
@interface OLDataProvider ()
|
|
|
|
|
|
@end
|
|
|
@@ -17,23 +21,8 @@
|
|
|
+(NSDictionary*) offline_model :(NSMutableDictionary *) params
|
|
|
{
|
|
|
|
|
|
- // if(appDelegate.user!=nil)
|
|
|
- // [params setValue:appDelegate.user forKey:@"user"];
|
|
|
- // if(appDelegate.contact_id!=nil)
|
|
|
- // [params setValue:appDelegate.contact_id forKey:@"contactId"];
|
|
|
- // if(appDelegate.password!=nil)
|
|
|
- // [params setValue:appDelegate.password forKey:@"password"];
|
|
|
- // if(appDelegate.order_code!=nil)
|
|
|
- // [params setValue:appDelegate.order_code forKey:@"orderCode"];
|
|
|
- // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
|
|
|
- // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
|
|
|
- // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
|
|
|
- // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
|
|
|
- // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
|
|
|
- // [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
|
|
|
- // [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
|
|
|
- // [params setValue:filter forKey:@"filter"];
|
|
|
- // [params setValue:keyword forKey:@"keyword"];
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
@@ -76,7 +65,7 @@
|
|
|
{
|
|
|
NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
-
|
|
|
+
|
|
|
char *name = (char*)sqlite3_column_text(statement, 0);
|
|
|
if(name==nil)
|
|
|
name="";
|
|
|
@@ -94,17 +83,17 @@
|
|
|
char *color = (char*)sqlite3_column_text(statement, 3);
|
|
|
if(color==nil)
|
|
|
color="";
|
|
|
-// NSString *nscolor = [[NSString alloc]initWithUTF8String:color];
|
|
|
-//
|
|
|
-// char *legcolor = (char*)sqlite3_column_text(statement, 4);
|
|
|
-// if(legcolor==nil)
|
|
|
-// legcolor="";
|
|
|
-// NSString *nslegcolor = [[NSString alloc]initWithUTF8String:legcolor];
|
|
|
-//
|
|
|
-//
|
|
|
+ // NSString *nscolor = [[NSString alloc]initWithUTF8String:color];
|
|
|
+ //
|
|
|
+ // char *legcolor = (char*)sqlite3_column_text(statement, 4);
|
|
|
+ // if(legcolor==nil)
|
|
|
+ // legcolor="";
|
|
|
+ // NSString *nslegcolor = [[NSString alloc]initWithUTF8String:legcolor];
|
|
|
+ //
|
|
|
+ //
|
|
|
int availability = sqlite3_column_int(statement, 5);
|
|
|
-//
|
|
|
-// int incoming_stock = sqlite3_column_int(statement, 6);
|
|
|
+ //
|
|
|
+ // int incoming_stock = sqlite3_column_int(statement, 6);
|
|
|
|
|
|
|
|
|
char *demension = (char*)sqlite3_column_text(statement, 7);
|
|
|
@@ -185,10 +174,10 @@
|
|
|
fashion="";
|
|
|
NSString *nsfashion = [[NSString alloc]initWithUTF8String:fashion];
|
|
|
|
|
|
-// char *fashion_selector = (char*)sqlite3_column_text(statement, 22);
|
|
|
-// if(fashion_selector==nil)
|
|
|
-// fashion_selector="";
|
|
|
-// NSString *nsfashion_selector = [[NSString alloc]initWithUTF8String:fashion_selector];
|
|
|
+ // char *fashion_selector = (char*)sqlite3_column_text(statement, 22);
|
|
|
+ // if(fashion_selector==nil)
|
|
|
+ // fashion_selector="";
|
|
|
+ // NSString *nsfashion_selector = [[NSString alloc]initWithUTF8String:fashion_selector];
|
|
|
|
|
|
char *property_field = (char*)sqlite3_column_text(statement, 22);
|
|
|
if(property_field==nil)
|
|
|
@@ -263,30 +252,15 @@
|
|
|
|
|
|
|
|
|
sqlite3_close(db);
|
|
|
- DebugLog(@"data string: %@",[RAUtils dict2string:ret] );
|
|
|
+ DebugLog(@"data string: %@",[RAUtils dict2string:ret] );
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
|
+(NSDictionary*) offline_category :(NSMutableDictionary *) params
|
|
|
{
|
|
|
|
|
|
-// if(appDelegate.user!=nil)
|
|
|
-// [params setValue:appDelegate.user forKey:@"user"];
|
|
|
-// if(appDelegate.contact_id!=nil)
|
|
|
-// [params setValue:appDelegate.contact_id forKey:@"contactId"];
|
|
|
-// if(appDelegate.password!=nil)
|
|
|
-// [params setValue:appDelegate.password forKey:@"password"];
|
|
|
-// if(appDelegate.order_code!=nil)
|
|
|
-// [params setValue:appDelegate.order_code forKey:@"orderCode"];
|
|
|
-// [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
|
|
|
-// [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
|
|
|
-// [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
|
|
|
-// [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
|
|
|
-// [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
|
|
|
-// [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
|
|
|
-// [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
|
|
|
-// [params setValue:filter forKey:@"filter"];
|
|
|
-// [params setValue:keyword forKey:@"keyword"];
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
@@ -315,8 +289,8 @@
|
|
|
sqlite3_stmt * statement;
|
|
|
[ret setValue:@"2" forKey:@"result"];
|
|
|
[ret setValue:[NSString stringWithFormat:@"%d",count] forKey:@"item_total_count"];
|
|
|
- NSMutableDictionary* items = [[NSMutableDictionary alloc] init];
|
|
|
-// int count=0;
|
|
|
+ NSMutableDictionary* items = [[NSMutableDictionary alloc] init];
|
|
|
+ // int count=0;
|
|
|
if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
|
{
|
|
|
|
|
|
@@ -324,7 +298,7 @@
|
|
|
while (sqlite3_step(statement) == SQLITE_ROW)
|
|
|
{
|
|
|
NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
|
|
-
|
|
|
+
|
|
|
// char *name = (char*)sqlite3_column_text(statement, 1);
|
|
|
// NSString *nsNameStr = [[NSString alloc]initWithUTF8String:name];
|
|
|
|
|
|
@@ -335,9 +309,9 @@
|
|
|
NSString *nsdescription = [[NSString alloc]initWithUTF8String:description];
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
int product_id = sqlite3_column_int(statement, 2);
|
|
|
-
|
|
|
+
|
|
|
|
|
|
char *url = (char*)sqlite3_column_text(statement, 3);
|
|
|
if(url==nil)
|
|
|
@@ -364,6 +338,315 @@
|
|
|
|
|
|
|
|
|
|
|
|
+ DebugLog(@"data string: %@",[RAUtils dict2string:ret] );
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
++(NSDictionary*) offline_login :(NSMutableDictionary *) params
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ NSString* user = [params valueForKey:@"user"];
|
|
|
+
|
|
|
+ NSString* password = [params valueForKey:@"password"];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ sqlite3 *db = [iSalesDB get_db];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ NSString *sqlQuery = [NSString stringWithFormat:@"select can_show_price,can_see_price,contact_id,user_type,can_cancel_order,can_set_cart_price,can_create_portfolio,can_delete_order,can_submit_order,can_set_tearsheet_price,can_create_order,mode,username from offline_login where lower(username)='%@' and password='%@'",user.lowercaseString ,[AESCrypt encrypt:password password:@"usai"]];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DebugLog(@"offline_login sql:%@",sqlQuery);
|
|
|
+ sqlite3_stmt * statement;
|
|
|
+
|
|
|
+
|
|
|
+ [ret setValue:[NSNumber numberWithInt:AP_USER_NOT_AUTH ] forKey:@"result"];
|
|
|
+
|
|
|
+
|
|
|
+ if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ if (sqlite3_step(statement) == SQLITE_ROW)
|
|
|
+ {
|
|
|
+
|
|
|
+ [ret setValue:[NSNumber numberWithInt:AP_USER_AUTH ] forKey:@"result"];
|
|
|
+ NSMutableDictionary* header = [[NSMutableDictionary alloc] init];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ int can_show_price = sqlite3_column_int(statement, 0);
|
|
|
+ int can_see_price = sqlite3_column_int(statement, 1);
|
|
|
+
|
|
|
+ char *contact_id = (char*)sqlite3_column_text(statement, 2);
|
|
|
+ if(contact_id==nil)
|
|
|
+ contact_id="";
|
|
|
+ NSString *nscontact_id= [[NSString alloc]initWithUTF8String:contact_id];
|
|
|
+
|
|
|
+ int user_type = sqlite3_column_int(statement, 3);
|
|
|
+
|
|
|
+ int can_cancel_order = sqlite3_column_int(statement, 4);
|
|
|
+ int can_set_cart_price = sqlite3_column_int(statement, 5);
|
|
|
+ int can_create_portfolio = sqlite3_column_int(statement, 6);
|
|
|
+ int can_delete_order = sqlite3_column_int(statement, 7);
|
|
|
+ int can_submit_order = sqlite3_column_int(statement, 8);
|
|
|
+ int can_set_tearsheet_price = sqlite3_column_int(statement, 9);
|
|
|
+ int can_create_order = sqlite3_column_int(statement, 10);
|
|
|
+
|
|
|
+
|
|
|
+ char *mode = (char*)sqlite3_column_text(statement, 11);
|
|
|
+ if(mode==nil)
|
|
|
+ mode="";
|
|
|
+ NSString *nsmode= [[NSString alloc]initWithUTF8String:mode];
|
|
|
+
|
|
|
+
|
|
|
+ char *username = (char*)sqlite3_column_text(statement, 12);
|
|
|
+ if(username==nil)
|
|
|
+ username="";
|
|
|
+ NSString *nsusername= [[NSString alloc]initWithUTF8String:username];
|
|
|
+
|
|
|
+
|
|
|
+ [header setValue:[NSNumber numberWithBool:can_show_price] forKey:@"can_show_price"];
|
|
|
+ [header setValue:[NSNumber numberWithBool:can_see_price] forKey:@"can_see_price"];
|
|
|
+ [header setValue:nscontact_id forKey:@"contact_id"];
|
|
|
+ [header setValue:[NSNumber numberWithBool:user_type] forKey:@"user_type"];
|
|
|
+ [header setValue:[NSNumber numberWithBool:can_cancel_order] forKey:@"can_cancel_order"];
|
|
|
+ [header setValue:[NSNumber numberWithBool:can_set_cart_price] forKey:@"can_set_cart_price"];
|
|
|
+ [header setValue:[NSNumber numberWithBool:can_create_portfolio] forKey:@"can_create_portfolio"];
|
|
|
+ [header setValue:[NSNumber numberWithBool:can_delete_order] forKey:@"can_delete_order"];
|
|
|
+ [header setValue:[NSNumber numberWithBool:can_submit_order] forKey:@"can_submit_order"];
|
|
|
+ [header setValue:[NSNumber numberWithBool:can_set_tearsheet_price] forKey:@"can_set_tearsheet_price"];
|
|
|
+ [header setValue:[NSNumber numberWithBool:can_create_order] forKey:@"can_create_order"];
|
|
|
+
|
|
|
+ [header setValue:nsusername forKey:@"username"];
|
|
|
+
|
|
|
+
|
|
|
+ [ret setObject:header forKey:@"header"];
|
|
|
+ [ret setValue:nsmode forKey:@"mode"];
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ sqlite3_finalize(statement);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ sqlite3_close(db);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DebugLog(@"data string: %@",[RAUtils dict2string:ret] );
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
++(NSDictionary*) offline_contactlist :(NSMutableDictionary *) params
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 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 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 from offline_contact where contactType='%@' order by create_time limit %d offset %d",contactType , limit, offset];
|
|
|
+ count=[iSalesDB get_recordcount:db table:@"offline_contact" where:[NSString stringWithFormat:@"contactType='%@'",contactType]];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ keyword = keyword.lowercaseString;
|
|
|
+ sqlQuery=[NSString stringWithFormat:@"select editable,company_name,country,addr,zipcode,state,city,contact_name,phone,contact_id from offline_contact where contactType='%@' and (lower(contact_id ) like'%@' or lower(company_name) like'%@') order by create_time limit %d offset %d",contactType , keyword,keyword,limit, offset];
|
|
|
+
|
|
|
+ count=[iSalesDB get_recordcount:db table:@"offline_contact" where:[NSString stringWithFormat:@"contactType='%@' 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 stringWithFormat:@"<b>%@</b>", [[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 stringWithFormat:@"TEL:%@",[[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];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ NSMutableArray* arr_addr = [[NSMutableArray alloc] init];
|
|
|
+
|
|
|
+
|
|
|
+ [arr_addr addObject:nscompany_name];
|
|
|
+ [arr_addr addObject:nscontact_name];
|
|
|
+ [arr_addr addObject:@"<br>"];
|
|
|
+
|
|
|
+ [arr_addr addObject:nsaddr];
|
|
|
+ [arr_addr addObject:nszipcode];
|
|
|
+ [arr_addr addObject:nscity];
|
|
|
+ [arr_addr addObject:nsstate];
|
|
|
+ [arr_addr addObject:nscountry];
|
|
|
+ [arr_addr addObject:nsphone];
|
|
|
+
|
|
|
+
|
|
|
+ NSString * name = [RAUtils arr2string:arr_addr separator:@","];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [item setValue:name forKey:@"name"];
|
|
|
+ [item setValue:nscontact_id forKey:@"contact_id"];
|
|
|
+
|
|
|
+ [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);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ sqlite3_close(db);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
DebugLog(@"data string: %@",[RAUtils dict2string:ret] );
|
|
|
|
|
|
return ret;
|
|
|
@@ -383,7 +666,7 @@
|
|
|
|
|
|
sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
|
- // int count = [iSalesDB get_recordcount:db table:@"model" where:[NSString stringWithFormat:@"category like'#%%%@%%#'",category]];
|
|
|
+ // int count = [iSalesDB get_recordcount:db table:@"model" where:[NSString stringWithFormat:@"category like'#%%%@%%#'",category]];
|
|
|
|
|
|
|
|
|
NSString *sqlQuery = [NSString stringWithFormat:@"select m.name,m.product_id,i.url from model m LEFT join model_image i on m.product_id = i.product_id where m.category like'%%#%@#%%' and isnew=1 and i.type = %d order by m.name ;",category,OFFLINE_IMG_TYPE_CATEGORY];
|
|
|
@@ -437,7 +720,7 @@
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
-
|
|
|
+
|
|
|
|
|
|
}
|
|
|
+(NSDictionary*) model_kvItem:(NSString*) key value:(NSString*)value
|
|
|
@@ -557,7 +840,7 @@
|
|
|
|
|
|
NSMutableDictionary* params=[[NSMutableDictionary alloc] init];
|
|
|
[params setValue:@"2" forKey:@"count"];
|
|
|
- NSMutableDictionary* param0=[[NSMutableDictionary alloc] init];
|
|
|
+ NSMutableDictionary* param0=[[NSMutableDictionary alloc] init];
|
|
|
[param0 setValue:[NSNumber numberWithInt:product_id ] forKey:@"val"];
|
|
|
[param0 setValue:@"product_id" forKey:@"name"];
|
|
|
|
|
|
@@ -613,10 +896,10 @@
|
|
|
|
|
|
if (sqlite3_step(statement) == SQLITE_ROW)
|
|
|
{
|
|
|
- char *url = (char*)sqlite3_column_text(statement, 0);
|
|
|
+ char *url = (char*)sqlite3_column_text(statement, 0);
|
|
|
if(url==nil)
|
|
|
url="";
|
|
|
- ret = [[NSString alloc]initWithUTF8String:url];
|
|
|
+ ret = [[NSString alloc]initWithUTF8String:url];
|
|
|
|
|
|
|
|
|
|
|
|
@@ -645,8 +928,8 @@
|
|
|
|
|
|
NSString *sqlQuery = [NSString stringWithFormat:@"select url from model_image where product_id=%d and type=%d;",product_id,OFFLINE_IMG_TYPE_DETAIL];
|
|
|
sqlite3_stmt * statement;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
|
{
|
|
|
|
|
|
@@ -663,11 +946,11 @@
|
|
|
url="";
|
|
|
NSString *nsurl = [[NSString alloc]initWithUTF8String:url];
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
[item setValue:nsurl forKey:@"s"];
|
|
|
[item setValue:nsurl forKey:@"l"];
|
|
|
-
|
|
|
+
|
|
|
|
|
|
[ret setObject:item forKey:[NSString stringWithFormat:@"img_%d",i]];
|
|
|
i++;
|
|
|
@@ -678,7 +961,7 @@
|
|
|
|
|
|
sqlite3_finalize(statement);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
sqlite3_close(db);
|