|
|
@@ -246,7 +246,7 @@
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-+(NSMutableDictionary*) get_model_all_price:(NSString*) contact_id product_id:(int) product_id db:(sqlite3*)db
|
|
|
++(NSMutableDictionary*) get_model_all_price:(NSString*) contact_id item_id:(int) item_id db:(sqlite3*)db
|
|
|
{
|
|
|
|
|
|
UIApplication * app = [UIApplication sharedApplication];
|
|
|
@@ -273,9 +273,9 @@
|
|
|
|
|
|
NSString* sqlQuery = nil;
|
|
|
if(appDelegate.contact_id==nil)
|
|
|
- sqlQuery=[NSString stringWithFormat:@"select a.name,b.price from price as a left join model_price as b on a.name=b.price_name and b.product_id=%d order by a.order_by;",product_id];
|
|
|
+ sqlQuery=[NSString stringWithFormat:@"select a.name,b.price from price as a left join model_price as b on a.name=b.price_name and b.item_id=%d order by a.order_by;",item_id];
|
|
|
else
|
|
|
- sqlQuery=[NSString stringWithFormat:@"select a.name,b.price from price as a left join model_price as b on a.name=b.price_name and b.product_id=%d and b.price_name in(%@) order by a.order_by;",product_id,whereprice];
|
|
|
+ sqlQuery=[NSString stringWithFormat:@"select a.name,b.price from price as a left join model_price as b on a.name=b.price_name and b.item_id=%d and b.price_name in(%@) order by a.order_by;",item_id,whereprice];
|
|
|
sqlite3_stmt * statement;
|
|
|
|
|
|
|
|
|
@@ -347,17 +347,79 @@
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-+(NSNumber*) get_model_default_price:(NSString*) contact_id product_id:(int) product_id db:(sqlite3*)db
|
|
|
+//+(NSNumber*) get_model_default_price:(NSString*) contact_id product_id:(int) product_id db:(sqlite3*)db
|
|
|
+//{
|
|
|
+// NSArray* arr1 = [self get_user_all_price_type:db];
|
|
|
+// NSArray* arr2 = [self get_contact_default_price_type:contact_id db:db];
|
|
|
+//
|
|
|
+// // NSSet *set1 = [NSSet setWithArray:arr1];
|
|
|
+// // NSMutableSet *set2 = [[NSSet setWithArray:arr2] mutableCopy];
|
|
|
+// // [set2 intersectsSet:set1];
|
|
|
+// //
|
|
|
+// //
|
|
|
+// // NSArray *retarr = [set2 allObjects];
|
|
|
+//
|
|
|
+// NSString* whereprice=nil;
|
|
|
+// if(contact_id==nil)
|
|
|
+// whereprice=[RAUtils arr2string:arr1 separator:@"," trim:true brackets:@"'"];
|
|
|
+// else
|
|
|
+// whereprice=[RAUtils arr2string:arr2 separator:@"," trim:true brackets:@"'"];
|
|
|
+//
|
|
|
+//
|
|
|
+// // sqlite3 *db = [iSalesDB get_db];
|
|
|
+//
|
|
|
+// NSString* sqlQuery = [NSString stringWithFormat:@"select price from model_price where product_id='%d' and price_name in(%@);",product_id,whereprice];
|
|
|
+// sqlite3_stmt * statement;
|
|
|
+//
|
|
|
+//
|
|
|
+// NSNumber* ret = nil;
|
|
|
+// double dprice=DBL_MAX;
|
|
|
+// if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
|
+// {
|
|
|
+//
|
|
|
+//
|
|
|
+// while (sqlite3_step(statement) == SQLITE_ROW)
|
|
|
+// {
|
|
|
+//
|
|
|
+// // double val = sqlite3_column_double(statement, 0);
|
|
|
+// char *price = (char*)sqlite3_column_text(statement, 0);
|
|
|
+// if(price!=nil)
|
|
|
+// {
|
|
|
+// NSString* nsprice = [[NSString alloc]initWithUTF8String:price];
|
|
|
+// nsprice=[AESCrypt fastdecrypt:nsprice];
|
|
|
+// if(nsprice.length>0)
|
|
|
+// {
|
|
|
+// double dp= [nsprice doubleValue];
|
|
|
+// if(dp<dprice)
|
|
|
+// dprice=dp;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// sqlite3_finalize(statement);
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// // [iSalesDB close_db:db];
|
|
|
+//
|
|
|
+// if(dprice==DBL_MAX)
|
|
|
+// ret= nil;
|
|
|
+// else
|
|
|
+// ret= [NSNumber numberWithDouble:dprice];
|
|
|
+// return ret;
|
|
|
+//}
|
|
|
+
|
|
|
++(NSNumber*) get_model_default_price:(NSString*) contact_id product_id:(id) product_id item_id:(id)item_id db:(sqlite3*)db
|
|
|
{
|
|
|
NSArray* arr1 = [self get_user_all_price_type:db];
|
|
|
NSArray* arr2 = [self get_contact_default_price_type:contact_id db:db];
|
|
|
|
|
|
- // NSSet *set1 = [NSSet setWithArray:arr1];
|
|
|
- // NSMutableSet *set2 = [[NSSet setWithArray:arr2] mutableCopy];
|
|
|
- // [set2 intersectsSet:set1];
|
|
|
- //
|
|
|
- //
|
|
|
- // NSArray *retarr = [set2 allObjects];
|
|
|
|
|
|
NSString* whereprice=nil;
|
|
|
if(contact_id==nil)
|
|
|
@@ -367,8 +429,17 @@
|
|
|
|
|
|
|
|
|
// sqlite3 *db = [iSalesDB get_db];
|
|
|
+ NSString *productIdCondition = @"1 = 1";
|
|
|
+ if (product_id) {
|
|
|
+ productIdCondition = [NSString stringWithFormat:@"product_id = %@",product_id];
|
|
|
+ }
|
|
|
+ NSString *itemIdCondition = @"";
|
|
|
+ if (item_id) {
|
|
|
+ itemIdCondition = [NSString stringWithFormat:@"and item_id = %@",item_id];
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- NSString* sqlQuery = [NSString stringWithFormat:@"select price from model_price where product_id='%d' and price_name in(%@);",product_id,whereprice];
|
|
|
+ NSString* sqlQuery = [NSString stringWithFormat:@"select price from model_price where %@ %@ and price_name in(%@);",productIdCondition,itemIdCondition,whereprice];
|
|
|
sqlite3_stmt * statement;
|
|
|
|
|
|
|
|
|
@@ -415,6 +486,7 @@
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+(NSArray*) get_user_all_price_type:(sqlite3*)db
|
|
|
{
|
|
|
|
|
|
@@ -691,7 +763,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:@"product" where:[NSString stringWithFormat:@"category like'#%%%@%%#'",category]];
|
|
|
|
|
|
|
|
|
NSString *sqlQuery = nil;
|
|
|
@@ -700,7 +772,7 @@
|
|
|
sqlQuery = [NSString stringWithFormat:@"select name,description,product_id,color,legcolor,availability,incoming_stock,demension,seat_height,material,box_dim,volume,weight,model_set,load_ability,default_category,fabric_content,assembling,made_in,special_remarks,stockUom,product_group,selector_field,property_field,packaging from product where name='%@';",model_name]; // select name,description,product_id,color,legcolor,availability,incoming_stock,demension,seat_height,material,box_dim,volume,weight,model_set,load_ability,default_category,fabric_content,assembling,made_in,special_remarks,stockUom,product_group,selector_field,property_field,packaging from model where name='%@';
|
|
|
else
|
|
|
|
|
|
- sqlQuery = [NSString stringWithFormat:@"select name,description,product_id,color,legcolor,availability,incoming_stock,demension,seat_height,material,box_dim,volume,weight,model_set,load_ability,default_category,fabric_content,assembling,made_in,special_remarks,stockUom,product_group,selector_field,property_field,packaging from product where product_id=%@;",product_id]; // select name,description,product_id,color,legcolor,availability,incoming_stock,demension,seat_height,material,box_dim,volume,weight,model_set,load_ability,default_category,fabric_content,assembling,made_in,special_remarks,stockUom,product_group,selector_field,property_field,packaging from model where product_id=%@;
|
|
|
+ sqlQuery = [NSString stringWithFormat:@"select name,description,product_id,color,legcolor,availability,incoming_stock,demension,seat_height,material,box_dim,volume,weight,model_set,load_ability,default_category,fabric_content,assembling,made_in,special_remarks,stockUom,product_group,selector_field,property_field,packaging,item_id from product where product_id=%@;",product_id]; // select name,description,product_id,color,legcolor,availability,incoming_stock,demension,seat_height,material,box_dim,volume,weight,model_set,load_ability,default_category,fabric_content,assembling,made_in,special_remarks,stockUom,product_group,selector_field,property_field,packaging from model where product_id=%@;
|
|
|
|
|
|
|
|
|
sqlite3_stmt * statement;
|
|
|
@@ -873,13 +945,15 @@
|
|
|
|
|
|
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
|
+ int item_id = sqlite3_column_int(statement, 25);
|
|
|
|
|
|
NSString* Price=nil;
|
|
|
if(appDelegate.bLogin==false)
|
|
|
Price=@"Must Sign in.";
|
|
|
else
|
|
|
{
|
|
|
- NSNumber* price= [self get_model_default_price:appDelegate.contact_id product_id:product_id db:db];
|
|
|
+// NSNumber* price= [self get_model_default_price:appDelegate.contact_id product_id:product_id db:db];
|
|
|
+ NSNumber* price = [self get_model_default_price:appDelegate.contact_id product_id:nil item_id:@(item_id) db:db];
|
|
|
if(price==nil)
|
|
|
Price=@"No Price.";
|
|
|
else
|
|
|
@@ -910,7 +984,8 @@
|
|
|
[detail0_section setObject:[self model_kvItem:@"Packaging" value:nspackaging] forKey:[NSString stringWithFormat:@"item_%d",detail0_item_count++]];
|
|
|
|
|
|
|
|
|
- NSDictionary* pricejson=[self get_model_all_price:appDelegate.contact_id product_id:product_id db:db];
|
|
|
+// NSDictionary* pricejson=[self get_model_all_price:appDelegate.contact_id product_id:product_id db:db];
|
|
|
+ NSDictionary* pricejson = [self get_model_all_price:appDelegate.contact_id item_id:item_id db:db];
|
|
|
for(int l=0;l<[pricejson[@"count"] intValue];l++)
|
|
|
{
|
|
|
NSDictionary* price_item = pricejson[[NSString stringWithFormat:@"item_%d",l]];
|
|
|
@@ -995,7 +1070,7 @@
|
|
|
|
|
|
sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
|
- int count = [iSalesDB get_recordcount:db table:@"model" where:[NSString stringWithFormat:@"lower(name) like'%%%@%%' or lower(description) like'%%%@%%'",keyword,keyword]];
|
|
|
+ int count = [iSalesDB get_recordcount:db table:@"product" where:[NSString stringWithFormat:@"lower(name) like'%%%@%%' or lower(description) like'%%%@%%'",keyword,keyword]];
|
|
|
|
|
|
|
|
|
NSString *sqlQuery = nil;
|
|
|
@@ -1597,10 +1672,13 @@
|
|
|
|
|
|
char *str_price = (char*)sqlite3_column_text(statement, 1);
|
|
|
|
|
|
+ int item_id = sqlite3_column_int(statement, 8);
|
|
|
+
|
|
|
NSString* Price=nil;
|
|
|
if(str_price==nil)
|
|
|
{
|
|
|
- NSNumber* price= [self get_model_default_price:appDelegate.contact_id product_id:product_id db:db];
|
|
|
+// NSNumber* price= [self get_model_default_price:appDelegate.contact_id product_id:product_id db:db];
|
|
|
+ NSNumber* price = [self get_model_default_price:appDelegate.contact_id product_id:nil item_id:@(item_id) db:db];
|
|
|
if(price==nil)
|
|
|
Price=@"No Price.";
|
|
|
else
|
|
|
@@ -1632,7 +1710,7 @@
|
|
|
if(description!=nil)
|
|
|
nsdescription= [[NSString alloc]initWithUTF8String:description];
|
|
|
|
|
|
- int item_id = sqlite3_column_int(statement, 8);
|
|
|
+
|
|
|
int stockUom = sqlite3_column_int(statement, 9);
|
|
|
int _id = sqlite3_column_int(statement, 10);
|
|
|
|
|
|
@@ -4190,12 +4268,12 @@
|
|
|
} else if([price containsString:@"+"]){
|
|
|
price = [price stringByReplacingOccurrencesOfString:@"+" withString:@""];
|
|
|
price_min = [price doubleValue];
|
|
|
- price = [NSString stringWithFormat:@"and product_id in (select DISTINCT product_id from model_price where price_name in (%@) and cast(decrypt(price) as double) >= %.2lf and cast(decrypt(price) as double) <= %.2lf)",priceName,price_min,price_max];
|
|
|
+ price = [NSString stringWithFormat:@"and item_id in (select DISTINCT item_id from model_price where price_name in (%@) and cast(decrypt(price) as double) >= %.2lf and cast(decrypt(price) as double) <= %.2lf)",priceName,price_min,price_max];
|
|
|
} else {
|
|
|
NSArray *priceArray = [price componentsSeparatedByString:@"-"];
|
|
|
price_min = [[priceArray objectAtIndex:0] doubleValue];
|
|
|
price_max = [[priceArray objectAtIndex:1] doubleValue];
|
|
|
- price = [NSString stringWithFormat:@"and product_id in (select DISTINCT product_id from model_price where price_name in (%@) and cast(decrypt(price) as double) >= %.2lf and cast(decrypt(price) as double) <= %.2lf)",priceName,price_min,price_max];
|
|
|
+ price = [NSString stringWithFormat:@"and item_id in (select DISTINCT item_id from model_price where price_name in (%@) and cast(decrypt(price) as double) >= %.2lf and cast(decrypt(price) as double) <= %.2lf)",priceName,price_min,price_max];
|
|
|
}
|
|
|
} else {
|
|
|
price = @"";
|
|
|
@@ -4225,7 +4303,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- count = [iSalesDB get_recordcount:db table:@"model" where:where];
|
|
|
+ count = [iSalesDB get_recordcount:db table:@"product" where:where];
|
|
|
|
|
|
if (!appDelegate.user) {
|
|
|
[filter setValue:@{@"count" : @(0)} forKey:@"price"];
|
|
|
@@ -4428,12 +4506,12 @@
|
|
|
} else if([price containsString:@"+"]){
|
|
|
price = [price stringByReplacingOccurrencesOfString:@"+" withString:@""];
|
|
|
price_min = [price doubleValue];
|
|
|
- price = [NSString stringWithFormat:@"and product_id in (select DISTINCT product_id from model_price where price_name in (%@) and cast(decrypt(price) as double) >= %.2lf and cast(decrypt(price) as double) <= %.2lf)",priceName,price_min,price_max];
|
|
|
+ price = [NSString stringWithFormat:@"and item_id in (select DISTINCT item_id from model_price where price_name in (%@) and cast(decrypt(price) as double) >= %.2lf and cast(decrypt(price) as double) <= %.2lf)",priceName,price_min,price_max];
|
|
|
} else {
|
|
|
NSArray *priceArray = [price componentsSeparatedByString:@"-"];
|
|
|
price_min = [[priceArray objectAtIndex:0] doubleValue];
|
|
|
price_max = [[priceArray objectAtIndex:1] doubleValue];
|
|
|
- price = [NSString stringWithFormat:@"and product_id in (select DISTINCT product_id from model_price where price_name in (%@) and cast(decrypt(price) as double) >= %.2lf and cast(decrypt(price) as double) <= %.2lf)",priceName,price_min,price_max];
|
|
|
+ price = [NSString stringWithFormat:@"and item_id in (select DISTINCT item_id from model_price where price_name in (%@) and cast(decrypt(price) as double) >= %.2lf and cast(decrypt(price) as double) <= %.2lf)",priceName,price_min,price_max];
|
|
|
}
|
|
|
} else {
|
|
|
price = @"";
|
|
|
@@ -4518,7 +4596,7 @@
|
|
|
}
|
|
|
where = [where stringByReplacingOccurrencesOfString:@"m." withString:@""];
|
|
|
|
|
|
- count = [iSalesDB get_recordcount:db table:@"model" where:where];
|
|
|
+ count = [iSalesDB get_recordcount:db table:@"product" where:where];
|
|
|
|
|
|
|
|
|
|