|
@@ -25,6 +25,12 @@
|
|
|
#import "SortButton.h"
|
|
#import "SortButton.h"
|
|
|
#import "TextUtils.h"
|
|
#import "TextUtils.h"
|
|
|
|
|
|
|
|
|
|
+#ifdef BUILD_UWAVER
|
|
|
|
|
+
|
|
|
|
|
+#import "RAPortfolioInputDialog.h"
|
|
|
|
|
+
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
#define ALERT_DEL 1025
|
|
#define ALERT_DEL 1025
|
|
|
#define checked_Count @"checkedCount"
|
|
#define checked_Count @"checkedCount"
|
|
|
@interface PortfolioViewController ()
|
|
@interface PortfolioViewController ()
|
|
@@ -352,6 +358,20 @@
|
|
|
}
|
|
}
|
|
|
- (IBAction)onCreateTearSheet:(id)sender {
|
|
- (IBAction)onCreateTearSheet:(id)sender {
|
|
|
|
|
|
|
|
|
|
+#ifdef BUILD_UWAVER
|
|
|
|
|
+
|
|
|
|
|
+ [self createPreviewPortfolio];
|
|
|
|
|
+
|
|
|
|
|
+#else
|
|
|
|
|
+
|
|
|
|
|
+ [self createTearSheet];
|
|
|
|
|
+
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)createTearSheet {
|
|
|
|
|
+
|
|
|
|
|
|
|
|
self.pdf_url= nil;
|
|
self.pdf_url= nil;
|
|
|
NSMutableArray* checked = [[NSMutableArray alloc] init];
|
|
NSMutableArray* checked = [[NSMutableArray alloc] init];
|
|
@@ -376,7 +396,7 @@
|
|
|
#ifdef BUILD_UWAVER
|
|
#ifdef BUILD_UWAVER
|
|
|
title = @"Cannot Create Hang Tag.";
|
|
title = @"Cannot Create Hang Tag.";
|
|
|
#else
|
|
#else
|
|
|
- title:@"Cannot Create Portfolio.";
|
|
|
|
|
|
|
+ title:@"Cannot Create Portfolio.";
|
|
|
#endif
|
|
#endif
|
|
|
[RAUtils message_alert:@"You must select at least one model." title:title controller:self] ;
|
|
[RAUtils message_alert:@"You must select at least one model." title:title controller:self] ;
|
|
|
return;
|
|
return;
|
|
@@ -412,8 +432,8 @@
|
|
|
};
|
|
};
|
|
|
VC.onSaved=^(NSString* url,NSString* name,bool isLocalFile)
|
|
VC.onSaved=^(NSString* url,NSString* name,bool isLocalFile)
|
|
|
{
|
|
{
|
|
|
- // NSString* name=[self.content_data[indexPath.row] valueForKey:@"tear_name"];
|
|
|
|
|
- // NSString* url= [self.content_data[indexPath.row] valueForKey:@"pdf_path"];
|
|
|
|
|
|
|
+ // NSString* name=[self.content_data[indexPath.row] valueForKey:@"tear_name"];
|
|
|
|
|
+ // NSString* url= [self.content_data[indexPath.row] valueForKey:@"pdf_path"];
|
|
|
|
|
|
|
|
RAPDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
|
|
RAPDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
|
|
|
ViewController.url = url;
|
|
ViewController.url = url;
|
|
@@ -443,17 +463,17 @@
|
|
|
// {
|
|
// {
|
|
|
// subject = [NSString stringWithFormat:@"Tear sheet for %@",company ];
|
|
// subject = [NSString stringWithFormat:@"Tear sheet for %@",company ];
|
|
|
// }
|
|
// }
|
|
|
-// ViewController.attachment_name = [NSString stringWithFormat:@"NPD_Product_List %@.pdf",cur_time];
|
|
|
|
|
|
|
+ // ViewController.attachment_name = [NSString stringWithFormat:@"NPD_Product_List %@.pdf",cur_time];
|
|
|
ViewController.filename = [NSString stringWithFormat:@"%@.pdf",[TextUtils legalFilename:name]];
|
|
ViewController.filename = [NSString stringWithFormat:@"%@.pdf",[TextUtils legalFilename:name]];
|
|
|
ViewController.mail_subject = subject;
|
|
ViewController.mail_subject = subject;
|
|
|
|
|
|
|
|
ViewController.hidenavi = false;
|
|
ViewController.hidenavi = false;
|
|
|
[self.navigationController pushViewController:ViewController animated:YES];
|
|
[self.navigationController pushViewController:ViewController animated:YES];
|
|
|
};
|
|
};
|
|
|
-// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
|
|
+ // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
VC.onDismiss=^(NSString* catelog_name)
|
|
VC.onDismiss=^(NSString* catelog_name)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
//
|
|
//
|
|
@@ -478,7 +498,199 @@
|
|
|
}];
|
|
}];
|
|
|
|
|
|
|
|
[self.btnselect setTitle:@"Select all"];
|
|
[self.btnselect setTitle:@"Select all"];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)createPreviewPortfolio {
|
|
|
|
|
|
|
|
|
|
+ NSMutableArray* checked = [[NSMutableArray alloc] init];
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableArray* checked_iid = [[NSMutableArray alloc] init];
|
|
|
|
|
+
|
|
|
|
|
+ int count = [[self.content_data valueForKey:@"count"] intValue];
|
|
|
|
|
+ for(int i=0;i<count;i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%d",i]] mutableCopy];
|
|
|
|
|
+ bool check = [[item_json valueForKey:@"check"] boolValue];
|
|
|
|
|
+ if(check)
|
|
|
|
|
+ {
|
|
|
|
|
+ [checked addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"product_id"] intValue]]];
|
|
|
|
|
+ [checked_iid addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"item_id"] intValue]]];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // disable for debug
|
|
|
|
|
+ if(checked.count==0)
|
|
|
|
|
+ {
|
|
|
|
|
+ NSString *title = @"Cannot Create Portfolio.";
|
|
|
|
|
+#ifdef BUILD_UWAVER
|
|
|
|
|
+ title = @"Cannot Create Hang Tag.";
|
|
|
|
|
+#else
|
|
|
|
|
+ title:@"Cannot Create Portfolio.";
|
|
|
|
|
+#endif
|
|
|
|
|
+ [RAUtils message_alert:@"You must select at least one model." title:title controller:self] ;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
|
|
+ [RAPortfolioInputDialog presentDialogBy:self withCompletion:^(BOOL preview, NSString *name, NSString *note) {
|
|
|
|
|
+
|
|
|
|
|
+ if (preview) {
|
|
|
|
|
+ [weakSelf createPreviewPortfolio:name Note:note ProductIds:checked ItemIds:checked_iid];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)createPreviewPortfolio:(NSString *)catelog_name Note:(NSString *)internal_note ProductIds:(NSArray *)productIds ItemIds:(NSArray *)itemIds {
|
|
|
|
|
+
|
|
|
|
|
+ if (catelog_name.length == 0) {
|
|
|
|
|
+ NSString *msg = @"Portfolio name can not be empty";
|
|
|
|
|
+#ifdef BUILD_UWAVER
|
|
|
|
|
+ msg = @"hang tag name can not be empty";
|
|
|
|
|
+#else
|
|
|
|
|
+ msg = @"Portfolio name can not be empty";
|
|
|
|
|
+#endif
|
|
|
|
|
+ [RAUtils message_alert:msg title:@"Warning" controller:self];
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ self.pdf_url= nil;
|
|
|
|
|
+
|
|
|
|
|
+ NSString* pdf_url = [self.content_data valueForKey:@"pdf_url"];
|
|
|
|
|
+ if (!pdf_url) {
|
|
|
|
|
+ pdf_url = @"";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
|
|
|
|
|
+
|
|
|
|
|
+ NSString * string = [productIds componentsJoinedByString:@","];
|
|
|
|
|
+
|
|
|
|
|
+ NSString * string_iid = [itemIds componentsJoinedByString:@","];
|
|
|
|
|
+ [params setValue:string forKey:@"product_ids"];
|
|
|
|
|
+ [params setValue:string_iid forKey:@"item_ids"];
|
|
|
|
|
+ [params setObject:@(self.sortIndex) forKey:@"sort"];
|
|
|
|
|
+ [params setObject:pdf_url forKey:@"pdfUrl"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Processing"];
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
+
|
|
|
|
|
+ NSDictionary* editor_json = [RANetwork request_TearSheet:params];
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if([[editor_json valueForKey:@"result"] intValue]==2)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+
|
|
|
|
|
+ NSString* url = [editor_json valueForKey:@"pdf_path"];
|
|
|
|
|
+ NSString* path = [editor_json valueForKey:@"pdf_real_path"];
|
|
|
|
|
+ bool isLocalFile = [[editor_json valueForKey:@"isLocalFile"] boolValue];
|
|
|
|
|
+ RAPDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
|
|
|
|
|
+ ViewController.url = url;
|
|
|
|
|
+ ViewController.canSave = true;
|
|
|
|
|
+ ViewController.isLocalfile=isLocalFile;
|
|
|
|
|
+
|
|
|
|
|
+ ViewController.filename = [NSString stringWithFormat:@"%@.pdf",[TextUtils legalFilename:catelog_name]];
|
|
|
|
|
+ ViewController.save_name =catelog_name;
|
|
|
|
|
+ ViewController.save_note =internal_note;
|
|
|
|
|
+
|
|
|
|
|
+ NSString* company= [appDelegate.customerInfo valueForKey:@"customer_name"];
|
|
|
|
|
+
|
|
|
|
|
+ if(company==nil)
|
|
|
|
|
+ company=@"";
|
|
|
|
|
+
|
|
|
|
|
+ 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;
|
|
|
|
|
+
|
|
|
|
|
+ NSString* subject;
|
|
|
|
|
+
|
|
|
|
|
+ subject =catelog_name;
|
|
|
|
|
+
|
|
|
|
|
+ ViewController.mail_subject = subject;
|
|
|
|
|
+
|
|
|
|
|
+ ViewController.onSavePDF=^(NSString* name,NSString* file)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSString* del_ids = nil;
|
|
|
|
|
+
|
|
|
|
|
+ UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Saving..."];
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+#ifdef OFFLINE_MODE
|
|
|
|
|
+ if (appDelegate.offline_mode)
|
|
|
|
|
+ {
|
|
|
|
|
+ [params setValue:url forKey:@"pdfPath"];
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+#endif
|
|
|
|
|
+ {
|
|
|
|
|
+ [params setValue:path forKey:@"pdfPath"];
|
|
|
|
|
+ }
|
|
|
|
|
+ [params setValue:name forKey:@"pdfName"];
|
|
|
|
|
+ [params setValue:internal_note forKey:@"pdfNote"];
|
|
|
|
|
+ [params setValue:del_ids forKey:@"itemIds"];
|
|
|
|
|
+ [params setValue:pdf_url forKey:@"configureParams"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSDictionary* json = [RANetwork save_TearSheet:params];
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if([[json valueForKey:@"result"] intValue]==2)
|
|
|
|
|
+ {
|
|
|
|
|
+ [RAUtils alert_view:nil title:@"Portfolio saved. You can find it from View Portfolios" ] ;
|
|
|
|
|
+
|
|
|
|
|
+ [self.navigationController dismissViewControllerAnimated:true completion:^{
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+#ifdef RA_NOTIFICATION
|
|
|
|
|
+ [ActiveViewController Notify:@"PortfolioViewController,PDFListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
|
|
|
+#else
|
|
|
|
|
+ [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:true];
|
|
|
|
|
+ [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
|
|
|
|
|
+#endif
|
|
|
|
|
+ }];
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Save Portfolio" controller:self] ;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ ViewController.hidenavi = false;
|
|
|
|
|
+ [self.navigationController pushViewController:ViewController animated:YES];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Create Portfolio" controller:self] ;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|