|
@@ -8,12 +8,266 @@
|
|
|
|
|
|
|
|
#import "OLDataProvider.h"
|
|
#import "OLDataProvider.h"
|
|
|
#import "iSalesDB.h"
|
|
#import "iSalesDB.h"
|
|
|
|
|
+#import "RAUtils.h"
|
|
|
@interface OLDataProvider ()
|
|
@interface OLDataProvider ()
|
|
|
|
|
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
@implementation OLDataProvider
|
|
@implementation OLDataProvider
|
|
|
-+(NSDictionary*) get_category :(NSMutableDictionary *) params
|
|
|
|
|
|
|
++(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"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSString* model_name = [params valueForKey:@"product_name"];
|
|
|
|
|
+
|
|
|
|
|
+ NSString* product_id = [params valueForKey:@"product_id"];
|
|
|
|
|
+
|
|
|
|
|
+ NSString* category = [params valueForKey:@"category"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
+
|
|
|
|
|
+ int count = [iSalesDB get_recordcount:db table:@"model" where:[NSString stringWithFormat:@"category like'#%%%@%%#'",category]];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSString *sqlQuery = nil;
|
|
|
|
|
+
|
|
|
|
|
+ if(product_id==nil)
|
|
|
|
|
+ sqlQuery = [NSString stringWithFormat:@"select name,description,product_id,color,legcolor,availability,incoming_stock,demension,seat_height,meterial,box_dim,volume,weight,model_set,load_ability,default_category,fabric_content,assembling,made_in,special_remarks,stockUom,fashion,selector_field,property_field from model where name='%@';",model_name];
|
|
|
|
|
+ else
|
|
|
|
|
+ sqlQuery = [NSString stringWithFormat:@"select name,description,product_id,color,legcolor,availability,incoming_stock,demension,seat_height,meterial,box_dim,volume,weight,model_set,load_ability,default_category,fabric_content,assembling,made_in,special_remarks,stockUom,fashion,selector_field,property_field from model where product_id=%@;",product_id];
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_stmt * statement;
|
|
|
|
|
+ [ret setValue:@"2" forKey:@"result"];
|
|
|
|
|
+ [ret setValue:@"2" forKey:@"detail_section_count"];
|
|
|
|
|
+
|
|
|
|
|
+ // int count=0;
|
|
|
|
|
+ if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (sqlite3_step(statement) == SQLITE_ROW)
|
|
|
|
|
+ {
|
|
|
|
|
+ NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ char *name = (char*)sqlite3_column_text(statement, 0);
|
|
|
|
|
+ if(name==nil)
|
|
|
|
|
+ name="";
|
|
|
|
|
+ NSString *nsname = [[NSString alloc]initWithUTF8String:name];
|
|
|
|
|
+
|
|
|
|
|
+ char *description = (char*)sqlite3_column_text(statement, 1);
|
|
|
|
|
+ if(description==nil)
|
|
|
|
|
+ description="";
|
|
|
|
|
+ NSString *nsdescription = [[NSString alloc]initWithUTF8String:description];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ int product_id = sqlite3_column_int(statement, 2);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ 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];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+ int availability = sqlite3_column_int(statement, 5);
|
|
|
|
|
+//
|
|
|
|
|
+// int incoming_stock = sqlite3_column_int(statement, 6);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ char *demension = (char*)sqlite3_column_text(statement, 7);
|
|
|
|
|
+ if(demension==nil)
|
|
|
|
|
+ demension="";
|
|
|
|
|
+ NSString *nsdemension = [[NSString alloc]initWithUTF8String:demension];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // ,,,,,,,,,
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ char *seat_height = (char*)sqlite3_column_text(statement, 8);
|
|
|
|
|
+ if(seat_height==nil)
|
|
|
|
|
+ seat_height="";
|
|
|
|
|
+ NSString *nsseat_height = [[NSString alloc]initWithUTF8String:seat_height];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ char *meterial = (char*)sqlite3_column_text(statement, 9);
|
|
|
|
|
+ if(meterial==nil)
|
|
|
|
|
+ meterial="";
|
|
|
|
|
+ NSString *nsmeterial = [[NSString alloc]initWithUTF8String:meterial];
|
|
|
|
|
+
|
|
|
|
|
+ char *box_dim = (char*)sqlite3_column_text(statement, 10);
|
|
|
|
|
+ if(box_dim==nil)
|
|
|
|
|
+ box_dim="";
|
|
|
|
|
+ NSString *nsbox_dim = [[NSString alloc]initWithUTF8String:box_dim];
|
|
|
|
|
+
|
|
|
|
|
+ char *volume = (char*)sqlite3_column_text(statement, 11);
|
|
|
|
|
+ if(volume==nil)
|
|
|
|
|
+ volume="";
|
|
|
|
|
+ NSString *nsvolume = [[NSString alloc]initWithUTF8String:volume];
|
|
|
|
|
+
|
|
|
|
|
+ double weight = sqlite3_column_double(statement, 12);
|
|
|
|
|
+
|
|
|
|
|
+ char *model_set = (char*)sqlite3_column_text(statement, 13);
|
|
|
|
|
+ if(model_set==nil)
|
|
|
|
|
+ model_set="";
|
|
|
|
|
+ NSString *nsmodel_set = [[NSString alloc]initWithUTF8String:model_set];
|
|
|
|
|
+
|
|
|
|
|
+ char *load_ability = (char*)sqlite3_column_text(statement, 14);
|
|
|
|
|
+ if(load_ability==nil)
|
|
|
|
|
+ load_ability="";
|
|
|
|
|
+ NSString *nsload_ability = [[NSString alloc]initWithUTF8String:load_ability];
|
|
|
|
|
+
|
|
|
|
|
+ char *default_category = (char*)sqlite3_column_text(statement, 15);
|
|
|
|
|
+ if(default_category==nil)
|
|
|
|
|
+ default_category="";
|
|
|
|
|
+ NSString *nsdefault_category = [[NSString alloc]initWithUTF8String:default_category];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ char *fabric_content = (char*)sqlite3_column_text(statement, 16);
|
|
|
|
|
+ if(fabric_content==nil)
|
|
|
|
|
+ fabric_content="";
|
|
|
|
|
+ NSString *nsfabric_content = [[NSString alloc]initWithUTF8String:fabric_content];
|
|
|
|
|
+
|
|
|
|
|
+ char *assembling = (char*)sqlite3_column_text(statement, 17);
|
|
|
|
|
+ if(assembling==nil)
|
|
|
|
|
+ assembling="";
|
|
|
|
|
+ NSString *nsassembling = [[NSString alloc]initWithUTF8String:assembling];
|
|
|
|
|
+
|
|
|
|
|
+ char *made_in = (char*)sqlite3_column_text(statement, 18);
|
|
|
|
|
+ if(made_in==nil)
|
|
|
|
|
+ made_in="";
|
|
|
|
|
+ NSString *nsmade_in = [[NSString alloc]initWithUTF8String:made_in];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ char *special_remarks = (char*)sqlite3_column_text(statement, 19);
|
|
|
|
|
+ if(special_remarks==nil)
|
|
|
|
|
+ special_remarks="";
|
|
|
|
|
+ NSString *nsspecial_remarks = [[NSString alloc]initWithUTF8String:special_remarks];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ int stockUcom = sqlite3_column_double(statement, 20);
|
|
|
|
|
+
|
|
|
|
|
+ char *fashion = (char*)sqlite3_column_text(statement, 21);
|
|
|
|
|
+ if(fashion==nil)
|
|
|
|
|
+ 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 *property_field = (char*)sqlite3_column_text(statement, 22);
|
|
|
|
|
+ if(property_field==nil)
|
|
|
|
|
+ property_field="";
|
|
|
|
|
+ NSString *nsproperty_field = [[NSString alloc]initWithUTF8String:property_field];
|
|
|
|
|
+
|
|
|
|
|
+ [ret setValue:[NSString stringWithFormat:@"%d",product_id] forKey:@"product_id"];
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* img_section = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+ [img_section setObject:[self model_img:product_id] forKey:@"images"];
|
|
|
|
|
+ [img_section setObject:[self model_property:product_id field:nsproperty_field] forKey:@"property"];
|
|
|
|
|
+ [img_section setObject:[self model_selector:nsfashion field:nsproperty_field] forKey:@"selector"];
|
|
|
|
|
+ NSString* Availability=nil;
|
|
|
|
|
+ if(availability>0)
|
|
|
|
|
+ Availability=[NSString stringWithFormat:@"%d",availability];
|
|
|
|
|
+ else
|
|
|
|
|
+ Availability = @"In Production";
|
|
|
|
|
+
|
|
|
|
|
+ [img_section setValue:Availability forKey:@"Availability"];
|
|
|
|
|
+ [img_section setValue:[NSString stringWithFormat:@"%d",stockUcom] forKey:@"stockUom"];
|
|
|
|
|
+
|
|
|
|
|
+ NSString* Price=@"Must Sign in.";
|
|
|
|
|
+
|
|
|
|
|
+ [img_section setValue:Price forKey:@"price"];
|
|
|
|
|
+ [img_section setValue:nsname forKey:@"model_name"];
|
|
|
|
|
+ [img_section setValue:nsdescription forKey:@"model_descrition"];
|
|
|
|
|
+
|
|
|
|
|
+ [ret setObject:img_section forKey:@"img_section"];
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* detail0_section = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+ int detail0_item_count=0;
|
|
|
|
|
+
|
|
|
|
|
+ [detail0_section setObject:[self model_kvItem:@"Dimension" value:nsdemension] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
|
|
|
|
|
+ [detail0_section setObject:[self model_kvItem:@"Seat Height" value:nsseat_height] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
|
|
|
|
|
+ [detail0_section setObject:[self model_kvItem:@"Material" value:nsmeterial] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
|
|
|
|
|
+ [detail0_section setObject:[self model_kvItem:@"Box dimension" value:nsbox_dim] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
|
|
|
|
|
+ [detail0_section setObject:[self model_kvItem:@"Volume" value:nsvolume] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
|
|
|
|
|
+ [detail0_section setObject:[self model_kvItem:@"Weight" value:[NSString stringWithFormat:@"%0.2f",weight]] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
|
|
|
|
|
+ [detail0_section setObject:[self model_kvItem:@"Set" value:nsmodel_set] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
|
|
|
|
|
+ [detail0_section setObject:[self model_kvItem:@"Load ability" value:nsload_ability] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
|
|
|
|
|
+ [detail0_section setObject:[self model_kvItem:@"Fabric Content" value:nsfabric_content] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
|
|
|
|
|
+ [detail0_section setObject:[self model_kvItem:@"Assembling" value:nsassembling] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
|
|
|
|
|
+ [detail0_section setObject:[self model_kvItem:@"Made in" value:nsmade_in] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
|
|
|
|
|
+ [detail0_section setObject:[self model_kvItem:@"Special Remarks" value:nsspecial_remarks] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [detail0_section setValue:[NSString stringWithFormat:@"%d",detail0_item_count] forKey:@"count"];
|
|
|
|
|
+ [detail0_section setValue:@"kv" forKey:@"type"];
|
|
|
|
|
+ [detail0_section setValue:@"Product Information" forKey:@"title"];
|
|
|
|
|
+
|
|
|
|
|
+ [ret setObject:detail0_section forKey:@"detail_0"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* detail1_section = [[self model_NIYMAL:category] mutableCopy];
|
|
|
|
|
+ [detail1_section setValue:@"detail" forKey:@"target"];
|
|
|
|
|
+ [detail1_section setValue:@"popup" forKey:@"action"];
|
|
|
|
|
+ [detail1_section setValue:@"content" forKey:@"type"];
|
|
|
|
|
+
|
|
|
|
|
+ [ret setObject:detail1_section forKey:@"detail_1"];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_finalize(statement);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ [ret setValue:@"8" forKey:@"result"];
|
|
|
|
|
+ }
|
|
|
|
|
+ NSLog(@"count:%d",count);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_close(db);
|
|
|
|
|
+ DebugLog(@"data string: %@",[RAUtils dict2string:ret] );
|
|
|
|
|
+
|
|
|
|
|
+ return ret;
|
|
|
|
|
+}
|
|
|
|
|
++(NSDictionary*) offline_category :(NSMutableDictionary *) params
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
// if(appDelegate.user!=nil)
|
|
// if(appDelegate.user!=nil)
|
|
@@ -52,17 +306,25 @@
|
|
|
|
|
|
|
|
sqlite3 *db = [iSalesDB get_db];
|
|
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.description,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 i.type =%d order by m.name limit %d offset %d ;",category,OFFLINE_IMG_TYPE_CATEGORY,limit, offset];
|
|
|
|
|
|
|
|
- NSString *sqlQuery = @"select m.name,m.description,m.product_id,i.name from model m LEFT join model_image i on m.product_id = i.product_id";
|
|
|
|
|
|
|
+ DebugLog(@"offline_category sql:%@",sqlQuery);
|
|
|
sqlite3_stmt * statement;
|
|
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;
|
|
// int count=0;
|
|
|
if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
|
|
+ int i=0;
|
|
|
while (sqlite3_step(statement) == SQLITE_ROW)
|
|
while (sqlite3_step(statement) == SQLITE_ROW)
|
|
|
{
|
|
{
|
|
|
|
|
+ NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+
|
|
|
// char *name = (char*)sqlite3_column_text(statement, 1);
|
|
// char *name = (char*)sqlite3_column_text(statement, 1);
|
|
|
// NSString *nsNameStr = [[NSString alloc]initWithUTF8String:name];
|
|
// NSString *nsNameStr = [[NSString alloc]initWithUTF8String:name];
|
|
|
|
|
|
|
@@ -73,22 +335,99 @@
|
|
|
NSString *nsdescription = [[NSString alloc]initWithUTF8String:description];
|
|
NSString *nsdescription = [[NSString alloc]initWithUTF8String:description];
|
|
|
|
|
|
|
|
|
|
|
|
|
-// NSLog(@"product name:%@ price:%@",nsname,nsprice);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ int product_id = sqlite3_column_int(statement, 2);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ char *url = (char*)sqlite3_column_text(statement, 3);
|
|
|
|
|
+ if(url==nil)
|
|
|
|
|
+ url="";
|
|
|
|
|
+ NSString *nsurl = [[NSString alloc]initWithUTF8String:url];
|
|
|
|
|
+
|
|
|
|
|
+ [item setValue:nsurl forKey:@"img"];
|
|
|
|
|
+ [item setValue:nsname forKey:@"name"];
|
|
|
|
|
+ [item setValue:nsdescription forKey:@"description"];
|
|
|
|
|
+ [item setValue:[NSString stringWithFormat:@"%d",product_id] forKey:@"product_id"];
|
|
|
|
|
+ [items setObject:item forKey:[NSString stringWithFormat:@"item_%d",i]];
|
|
|
|
|
+ i++;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ [items setValue:[NSString stringWithFormat:@"%d",i] forKey:@"count"];
|
|
|
|
|
+ [ret setObject:items forKey:@"items"];
|
|
|
|
|
+ sqlite3_finalize(statement);
|
|
|
|
|
+ }
|
|
|
|
|
+ NSLog(@"count:%d",count);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_close(db);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ DebugLog(@"data string: %@",[RAUtils dict2string:ret] );
|
|
|
|
|
+
|
|
|
|
|
+ return ret;
|
|
|
|
|
+}
|
|
|
|
|
++(NSDictionary*) model_NIYMAL:(NSString*) category
|
|
|
|
|
+{
|
|
|
|
|
+ // MODEL DETAIL NEW ITEM YOU MAY ALSO LIKE
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
+
|
|
|
|
|
+ // 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];
|
|
|
|
|
+ sqlite3_stmt * statement;
|
|
|
|
|
+ int count = 0;
|
|
|
|
|
+ [ret setValue:[NSString stringWithFormat:@"%d",count] forKey:@"count"];
|
|
|
|
|
+
|
|
|
|
|
+ // int count=0;
|
|
|
|
|
+ if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ int i=0;
|
|
|
|
|
+ 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];
|
|
|
|
|
+
|
|
|
|
|
+ char *name = (char*)sqlite3_column_text(statement, 0);
|
|
|
|
|
+ NSString *nsname = [[NSString alloc]initWithUTF8String:name];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
- // NSData* img_data=[ApexMobileDB load_cached_img:nsname];
|
|
|
|
|
- //
|
|
|
|
|
- // if(img_data!=nil)
|
|
|
|
|
- // {
|
|
|
|
|
- //
|
|
|
|
|
- // UIImage * img =[UIImage imageWithData:img_data];
|
|
|
|
|
- // self.imageView.image = img;
|
|
|
|
|
- // }
|
|
|
|
|
- //
|
|
|
|
|
- // char *address = (char*)sqlite3_column_text(statement, 3);
|
|
|
|
|
- // NSString *nsAddressStr = [[NSString alloc]initWithUTF8String:address];
|
|
|
|
|
|
|
|
|
|
|
|
+ int product_id = sqlite3_column_int(statement, 1);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ char *url = (char*)sqlite3_column_text(statement, 2);
|
|
|
|
|
+ if(url==nil)
|
|
|
|
|
+ url="";
|
|
|
|
|
+ NSString *nsurl = [[NSString alloc]initWithUTF8String:url];
|
|
|
|
|
+
|
|
|
|
|
+ [item setValue:nsurl forKey:@"picture_path"];
|
|
|
|
|
+ [item setValue:nsname forKey:@"fash_name"];
|
|
|
|
|
+ [item setValue:[NSString stringWithFormat:@"%d",product_id] forKey:@"product_id"];
|
|
|
|
|
+ [item setValue:category forKey:@"category"];
|
|
|
|
|
+ [ret setObject:item forKey:[NSString stringWithFormat:@"item_%d",i]];
|
|
|
|
|
+ i++;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ [ret setValue:[NSString stringWithFormat:@"%d",i] forKey:@"count"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
sqlite3_finalize(statement);
|
|
sqlite3_finalize(statement);
|
|
|
}
|
|
}
|
|
|
NSLog(@"count:%d",count);
|
|
NSLog(@"count:%d",count);
|
|
@@ -97,6 +436,253 @@
|
|
|
sqlite3_close(db);
|
|
sqlite3_close(db);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ return ret;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
++(NSDictionary*) model_kvItem:(NSString*) key value:(NSString*)value
|
|
|
|
|
+{
|
|
|
|
|
+ NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+
|
|
|
|
|
+ [ret setValue:key forKey:@"key"];
|
|
|
|
|
+ [ret setValue:value forKey:@"val"];
|
|
|
|
|
+ return ret;
|
|
|
|
|
+}
|
|
|
|
|
++(NSDictionary*) model_property :(int)product_id field:(NSString*) field
|
|
|
|
|
+{
|
|
|
|
|
+ NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+
|
|
|
|
|
+ [ret setValue:@"0" forKey:@"img_count"];
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSString *sqlQuery = [NSString stringWithFormat:@"select %@,property_display from model where product_id=%d ;",field,product_id];
|
|
|
|
|
+ sqlite3_stmt * statement;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ int i=0;
|
|
|
|
|
+ if (sqlite3_step(statement) == SQLITE_ROW)
|
|
|
|
|
+ {
|
|
|
|
|
+ NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+
|
|
|
|
|
+ // char *name = (char*)sqlite3_column_text(statement, 1);
|
|
|
|
|
+ // NSString *nsNameStr = [[NSString alloc]initWithUTF8String:name];
|
|
|
|
|
+
|
|
|
|
|
+ char *value = (char*)sqlite3_column_text(statement, 0);
|
|
|
|
|
+ if(value==nil)
|
|
|
|
|
+ value="";
|
|
|
|
|
+ NSString *nsvalue = [[NSString alloc]initWithUTF8String:value];
|
|
|
|
|
+
|
|
|
|
|
+ char *key = (char*)sqlite3_column_text(statement, 1);
|
|
|
|
|
+ if(key==nil)
|
|
|
|
|
+ key="";
|
|
|
|
|
+ NSString *nskey = [[NSString alloc]initWithUTF8String:key];
|
|
|
|
|
+
|
|
|
|
|
+ [item setValue:nsvalue forKey:@"val"];
|
|
|
|
|
+ [item setValue:nskey forKey:@"key"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [ret setObject:item forKey:[NSString stringWithFormat:@"item_%d",i]];
|
|
|
|
|
+ [ret setValue:@"1" forKey:@"count"];
|
|
|
|
|
+ i++;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_finalize(statement);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_close(db);
|
|
|
|
|
+
|
|
|
|
|
+ return ret;
|
|
|
|
|
+}
|
|
|
|
|
++(NSDictionary*) model_selector :(NSString*)fashion field:(NSString*) field
|
|
|
|
|
+{
|
|
|
|
|
+ NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+
|
|
|
|
|
+ [ret setValue:@"0" forKey:@"count"];
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSString *sqlQuery = [NSString stringWithFormat:@"select %@,selector_display,product_id,category from model where fashion='%@' order by name;",field,fashion];
|
|
|
|
|
+ sqlite3_stmt * statement;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ int i=0;
|
|
|
|
|
+ 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];
|
|
|
|
|
+
|
|
|
|
|
+ char *value = (char*)sqlite3_column_text(statement, 0);
|
|
|
|
|
+ if(value==nil)
|
|
|
|
|
+ value="";
|
|
|
|
|
+ NSString *nsvalue = [[NSString alloc]initWithUTF8String:value];
|
|
|
|
|
+
|
|
|
|
|
+ char *selector_display = (char*)sqlite3_column_text(statement, 1);
|
|
|
|
|
+ if(selector_display==nil)
|
|
|
|
|
+ selector_display="";
|
|
|
|
|
+ NSString *nsselector_display = [[NSString alloc]initWithUTF8String:selector_display];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ int product_id = sqlite3_column_int(statement, 2);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ char *category = (char*)sqlite3_column_text(statement, 3);
|
|
|
|
|
+ if(category==nil)
|
|
|
|
|
+ category="";
|
|
|
|
|
+ NSString *nscategory = [[NSString alloc]initWithUTF8String:category];
|
|
|
|
|
+
|
|
|
|
|
+ NSString* url = [self category_img:product_id];
|
|
|
|
|
+
|
|
|
|
|
+ [item setValue:nsvalue forKey:@"title"];
|
|
|
|
|
+ [item setValue:url forKey:@"pic_url"];
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* params=[[NSMutableDictionary alloc] init];
|
|
|
|
|
+ [params setValue:@"2" forKey:@"count"];
|
|
|
|
|
+ NSMutableDictionary* param0=[[NSMutableDictionary alloc] init];
|
|
|
|
|
+ [param0 setValue:[NSNumber numberWithInt:product_id ] forKey:@"val"];
|
|
|
|
|
+ [param0 setValue:@"product_id" forKey:@"name"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* param1=[[NSMutableDictionary alloc] init];
|
|
|
|
|
+ [param1 setValue:nscategory forKey:@"val"];
|
|
|
|
|
+ [param1 setValue:@"category" forKey:@"name"];
|
|
|
|
|
+
|
|
|
|
|
+ [params setObject:param0 forKey:@"param_0"];
|
|
|
|
|
+ [params setObject:param1 forKey:@"param_1"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [item setObject:params forKey:@"params"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [ret setValue:nsselector_display forKey:@"name"];
|
|
|
|
|
+
|
|
|
|
|
+ [ret setObject:item forKey:[NSString stringWithFormat:@"item_%d",i]];
|
|
|
|
|
+ i++;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ [ret setValue:[NSString stringWithFormat:@"%d",i] forKey:@"count"];
|
|
|
|
|
+ [ret setValue:@"switch" forKey:@"action"];
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_finalize(statement);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_close(db);
|
|
|
|
|
+
|
|
|
|
|
+ return ret;
|
|
|
|
|
+}
|
|
|
|
|
++(NSString*) category_img :(int)product_id
|
|
|
|
|
+{
|
|
|
|
|
+ // model 在 category search 显示的图片。
|
|
|
|
|
+ NSString* ret =nil;
|
|
|
|
|
+
|
|
|
|
|
+ [ret setValue:@"0" forKey:@"img_count"];
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSString *sqlQuery = [NSString stringWithFormat:@"select url from model_image where product_id=%d and type=%d;",product_id,OFFLINE_IMG_TYPE_CATEGORY];
|
|
|
|
|
+ sqlite3_stmt * statement;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (sqlite3_step(statement) == SQLITE_ROW)
|
|
|
|
|
+ {
|
|
|
|
|
+ char *url = (char*)sqlite3_column_text(statement, 0);
|
|
|
|
|
+ if(url==nil)
|
|
|
|
|
+ url="";
|
|
|
|
|
+ ret = [[NSString alloc]initWithUTF8String:url];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_finalize(statement);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_close(db);
|
|
|
|
|
+
|
|
|
|
|
+ return ret;
|
|
|
|
|
+}
|
|
|
|
|
++(NSDictionary*) model_img :(int)product_id
|
|
|
|
|
+{
|
|
|
|
|
+ NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+
|
|
|
|
|
+ [ret setValue:@"0" forKey:@"img_count"];
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ 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)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ int i=0;
|
|
|
|
|
+ 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];
|
|
|
|
|
+
|
|
|
|
|
+ char *url = (char*)sqlite3_column_text(statement, 0);
|
|
|
|
|
+ if(url==nil)
|
|
|
|
|
+ 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++;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ [ret setValue:[NSString stringWithFormat:@"%d",i] forKey:@"img_count"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_finalize(statement);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_close(db);
|
|
|
|
|
+
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
|