|
@@ -1,972 +0,0 @@
|
|
|
-//
|
|
|
|
|
-// OLDataProvider.m
|
|
|
|
|
-// iSales-NPD
|
|
|
|
|
-//
|
|
|
|
|
-// Created by Ray on 2/2/16.
|
|
|
|
|
-// Copyright © 2016 United Software Applications, Inc. All rights reserved.
|
|
|
|
|
-//
|
|
|
|
|
-
|
|
|
|
|
-#import "OLDataProvider.h"
|
|
|
|
|
-#import "iSalesDB.h"
|
|
|
|
|
-#import "RAUtils.h"
|
|
|
|
|
-#import "AESCrypt.h"
|
|
|
|
|
-#import "AppDelegate.h"
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-@interface OLDataProvider ()
|
|
|
|
|
-
|
|
|
|
|
-@end
|
|
|
|
|
-
|
|
|
|
|
-@implementation OLDataProvider
|
|
|
|
|
-+(NSDictionary*) offline_model :(NSMutableDictionary *) params
|
|
|
|
|
-{
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- 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
|
|
|
|
|
-{
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- NSString* orderCode = [params valueForKey:@"orderCode"];
|
|
|
|
|
-
|
|
|
|
|
- NSString* category = [params valueForKey:@"category"];
|
|
|
|
|
-
|
|
|
|
|
- int limit = [[params valueForKey:@"limit"] intValue];
|
|
|
|
|
- int offset = [[params valueForKey:@"offset"] intValue];
|
|
|
|
|
-
|
|
|
|
|
- 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.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];
|
|
|
|
|
-
|
|
|
|
|
- DebugLog(@"offline_category sql:%@",sqlQuery);
|
|
|
|
|
- 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;
|
|
|
|
|
- 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];
|
|
|
|
|
-
|
|
|
|
|
- char *description = (char*)sqlite3_column_text(statement, 1);
|
|
|
|
|
- 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)
|
|
|
|
|
- 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*) 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:@"," trim:true];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- [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;
|
|
|
|
|
-}
|
|
|
|
|
-+(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];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- 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);
|
|
|
|
|
- }
|
|
|
|
|
- NSLog(@"count:%d",count);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- 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;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-@end
|
|
|