Pen Li 7 лет назад
Родитель
Сommit
1300382827
1 измененных файлов с 111 добавлено и 11 удалено
  1. 111 11
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m

+ 111 - 11
RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m

@@ -29,6 +29,7 @@
 #import "RAPDFViewController.h"
 
 #import "ModelDescriptionController.h"
+#import "TextUtils.h"
 
 
 #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
@@ -289,16 +290,8 @@ self.isrefreshing=false;
     [self registeObserver];
     self.refresh_type =  REFRESH_VIEW;
     
-    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
-                                                                    style:UIBarButtonItemStylePlain
-                                                                   target:self
-                                                                   action:@selector( onBackClick:)];
-    
-
-    
-    self.navigationItem.leftBarButtonItem = backButton;
-    
-    
+    [self registNotification];
+    [self setupNavigationBar];
     
   //  self.detailTable.style = UITableViewStylePlain;
     
@@ -431,6 +424,113 @@ self.isrefreshing=false;
     
     
 }
+
+#pragma mark - Notification
+
+- (void)registNotification {
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleUserLoginNotification:) name:User_LoginOK_Notification object:nil];
+}
+
+- (void)unregistNotification {
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:User_LoginOK_Notification object:nil];
+}
+
+#pragma mark - Nav Bar
+
+- (void)setupNavigationBar {
+    
+    
+    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                                                   style:UIBarButtonItemStylePlain
+                                                                  target:self
+                                                                  action:@selector( onBackClick:)];
+    
+    self.navigationItem.leftBarButtonItem = backButton;
+    
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    
+#ifdef BUILD_UWAVER
+    
+    if (appDelegate.bLogin) {
+        UIBarButtonItem *hangTagItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(hanTagBtnClick:)];
+        self.navigationItem.rightBarButtonItem = hangTagItem;
+    }
+#endif
+    
+}
+
+#pragma mark - Action
+
+- (void)handleUserLoginNotification:(NSNotification *)notification {
+    
+    [self setupNavigationBar];
+}
+
+- (void)hanTagBtnClick:(id)sender {
+    
+    DetailViewController *vc = self;
+    
+    NSString *catelog_name = [NSString stringWithFormat:@"%@ Hang Tag",vc.groupName];
+    
+    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_hangTag:vc.groupName];
+        
+        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"];
+                bool isLocalFile = [[editor_json valueForKey:@"isLocalFile"] boolValue];
+                RAPDFViewController *ViewController = [vc.storyboard instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
+                ViewController.url = url;
+                ViewController.canSave = false;
+                ViewController.isLocalfile=isLocalFile;
+                
+                ViewController.filename = [NSString stringWithFormat:@"%@.pdf",[TextUtils legalFilename:catelog_name]];
+                
+                
+                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.hidenavi = false;
+                [vc.navigationController pushViewController:ViewController animated:YES];
+                
+            }
+            else
+            {
+                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Create Hang Tag" controller:vc];
+            }
+            
+        });
+    });
+    
+}
+
 #pragma mark - Selector delegate
 -(void) selected:(NSString*) detail_id category:(NSString*) category
 {
@@ -1088,7 +1188,7 @@ self.isrefreshing=false;
 #else
         NSString *CellIdentifier = @"DetailHeaderCell";
         DetailHeaderCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-        cell.btn_hangtag.hidden = !appDelegate.bLogin;
+        cell.btn_hangtag.hidden = YES;
 #endif