|
|
@@ -25,6 +25,7 @@
|
|
|
#import "JKMessageBoxController.h"
|
|
|
|
|
|
#import "CartUtils.h"
|
|
|
+#import "PDFViewController.h"
|
|
|
|
|
|
#define DEF_CELL_HEIGHT 44
|
|
|
#define DEF_TABLE_HEIGHT 44
|
|
|
@@ -944,6 +945,16 @@ self.isrefreshing=false;
|
|
|
|
|
|
}
|
|
|
|
|
|
+- (BOOL)isOutofStock {
|
|
|
+ NSMutableDictionary* section_json = [[self.detail_data objectForKey:@"img_section"] mutableCopy];
|
|
|
+ NSString *qtyStr = [section_json valueForKey:@"Availability"];
|
|
|
+
|
|
|
+ if (!qtyStr || !qtyStr.length || [qtyStr isEqualToString:@"In Production"] || [qtyStr isEqualToString:@"0"] || [qtyStr isEqualToString:@"Sold Out"] || [qtyStr isEqualToString:@"Out of Stock"]) {
|
|
|
+ return YES;
|
|
|
+ }
|
|
|
+ return NO;
|
|
|
+}
|
|
|
+
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
{
|
|
|
// DebugLog(@"cellForRowAtIndexPath");
|
|
|
@@ -1033,7 +1044,7 @@ self.isrefreshing=false;
|
|
|
|
|
|
if (!appDelegate.order_code) { // 未打开订单状态
|
|
|
|
|
|
- if (!qtyStr || !qtyStr.length || [qtyStr isEqualToString:@"In Production"] || [qtyStr isEqualToString:@"0"] || [qtyStr isEqualToString:@"Sold Out"]) {
|
|
|
+ if ([self isOutofStock]) {
|
|
|
|
|
|
if (!appDelegate.can_create_backorder) {
|
|
|
cell.btnaddCart.enabled = NO;
|
|
|
@@ -1054,7 +1065,7 @@ self.isrefreshing=false;
|
|
|
// 默认未缺货
|
|
|
cell.btnNotifyMe.enabled = NO;
|
|
|
|
|
|
- if (!qtyStr || !qtyStr.length || [qtyStr isEqualToString:@"In Production"] || [qtyStr isEqualToString:@"0"] || [qtyStr isEqualToString:@"Sold Out"]) { // 缺货
|
|
|
+ if ([self isOutofStock]) { // 缺货
|
|
|
|
|
|
cell.btnNotifyMe.enabled = YES;
|
|
|
|
|
|
@@ -1062,7 +1073,7 @@ self.isrefreshing=false;
|
|
|
|
|
|
} else {
|
|
|
// Purchase Order
|
|
|
- if (!qtyStr || !qtyStr.length || [qtyStr isEqualToString:@"In Production"] || [qtyStr isEqualToString:@"0"] || [qtyStr isEqualToString:@"Sold Out"]) { // 缺货
|
|
|
+ if ([self isOutofStock]) { // 缺货
|
|
|
if (!appDelegate.can_create_backorder) {
|
|
|
cell.btnaddCart.enabled = NO;
|
|
|
}
|
|
|
@@ -1086,7 +1097,7 @@ self.isrefreshing=false;
|
|
|
cell.btnaddPortfolio.hidden = NO;
|
|
|
cell.btnNotifyMe.hidden = NO;
|
|
|
|
|
|
- if (!qtyStr || !qtyStr.length || [qtyStr isEqualToString:@"In Production"] || [qtyStr isEqualToString:@"0"] || [qtyStr isEqualToString:@"Sold Out"]) { // 缺货
|
|
|
+ if ([self isOutofStock]) { // 缺货
|
|
|
if (!appDelegate.can_create_backorder) {
|
|
|
cell.btnaddCart.enabled = NO;
|
|
|
}
|
|
|
@@ -1412,7 +1423,7 @@ self.isrefreshing=false;
|
|
|
});
|
|
|
// cell.backgroundColor = [UIColor whiteColor];
|
|
|
|
|
|
-
|
|
|
+ __weak typeof(self) weakself = self;
|
|
|
cell.shopCartBlock = ^(UIImageView *imageView){
|
|
|
self.add_cart=true;
|
|
|
CGRect rect = [tableView rectForRowAtIndexPath:indexPath];
|
|
|
@@ -1451,6 +1462,12 @@ self.isrefreshing=false;
|
|
|
[((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
|
|
|
};
|
|
|
|
|
|
+ cell.introduceBlock = ^(UIButton *sender) {
|
|
|
+ NSString *introduce = [weakself.detail_data objectForKey:@"introduce"];
|
|
|
+// introduce = @"http://127.0.0.1/ios.pdf";
|
|
|
+ [weakself showIntroducePDF:introduce];
|
|
|
+ };
|
|
|
+
|
|
|
return cell;
|
|
|
}
|
|
|
// NSDictionary* related_json = [self.detail_data objectForKey:@"related_model"];
|
|
|
@@ -1956,4 +1973,61 @@ self.isrefreshing=false;
|
|
|
[self presentViewController:emailAddrVC animated:YES completion:nil];
|
|
|
}
|
|
|
|
|
|
+- (void)showIntroducePDF:(NSString *)link {
|
|
|
+
|
|
|
+ if (link.length == 0) {
|
|
|
+ [RAUtils message_alert:@"There is no resource to open" title:@"Warning" controller:self];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ BOOL isLocalFile = NO;
|
|
|
+ NSMutableDictionary* section_json = [[self.detail_data objectForKey:@"img_section"] mutableCopy];
|
|
|
+ NSString *name = [section_json valueForKey:@"model_name"];
|
|
|
+ NSString *path = [NSString stringWithFormat:@"%@/Introduce/%@/%@",[RAUtils appCacheDirectory],name,link.lastPathComponent];
|
|
|
+ if ([RAUtils fileExistsAtPath:path]) { // 检查缓存
|
|
|
+ isLocalFile = YES;
|
|
|
+ link = path;
|
|
|
+ } else {
|
|
|
+ // 创建缓存目录
|
|
|
+ NSString *dir = [path stringByDeletingLastPathComponent];
|
|
|
+ [[NSFileManager defaultManager] createDirectoryAtPath:dir withIntermediateDirectories:YES attributes:nil error:nil];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ name = [NSString stringWithFormat:@"%@ Assembly Instruction",name];
|
|
|
+
|
|
|
+ PDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
|
|
|
+ ViewController.url = link;
|
|
|
+ ViewController.canSave = false;
|
|
|
+ ViewController.isLocalfile=isLocalFile;
|
|
|
+ ViewController.cachePath = path;
|
|
|
+ NSString* subject = name;
|
|
|
+
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+ NSString* customer_email = [appDelegate.customerInfo valueForKey:@"customer_email"];
|
|
|
+
|
|
|
+
|
|
|
+ NSMutableArray* send_to = [[NSMutableArray alloc]init];
|
|
|
+ if(customer_email.length>0)
|
|
|
+ {
|
|
|
+ send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ ViewController.mail_to = send_to;
|
|
|
+
|
|
|
+ ViewController.attachment_name = [NSString stringWithFormat:@"%@.pdf",name];
|
|
|
+ ViewController.mail_subject = subject;
|
|
|
+
|
|
|
+ ViewController.hidenavi = false;
|
|
|
+
|
|
|
+
|
|
|
+// UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:ViewController];
|
|
|
+// nav.modalPresentationStyle = UIModalPresentationFormSheet;// 只在iPad起作用
|
|
|
+// CGSize size = [UIScreen mainScreen].bounds.size;
|
|
|
+// nav.preferredContentSize = CGSizeMake(size.width * 0.8, size.height * 0.8);
|
|
|
+
|
|
|
+ [self.navigationController pushViewController:ViewController animated:YES];
|
|
|
+}
|
|
|
+
|
|
|
@end
|