Selaa lähdekoodia

修复ERP Mobile 工程的部分警告错误,完成了对iOS已废弃的UIAlertView的替换

Ray Zhang 6 vuotta sitten
vanhempi
commit
d19d926948
24 muutettua tiedostoa jossa 2204 lisäystä ja 1468 poistoa
  1. 4 4
      RedAnt ERP Mobile/common/CommonEditor/CommonEditorCellEdit.m
  2. 7 7
      RedAnt ERP Mobile/common/CommonEditor/CommonEditorCellModel.m
  3. 1 2
      RedAnt ERP Mobile/common/CommonEditor/CommonEditorCellTextView.m
  4. 363 102
      RedAnt ERP Mobile/common/Functions/MainViewController.m
  5. 248 217
      RedAnt ERP Mobile/common/Functions/camscan/ScannerViewController.m
  6. 3 3
      RedAnt ERP Mobile/common/Functions/cart/BundleModelCell.m
  7. 7 7
      RedAnt ERP Mobile/common/Functions/contact/ContactListTableViewCell.m
  8. 1 0
      RedAnt ERP Mobile/common/Functions/contact/ContactListViewController.m
  9. 4 2
      RedAnt ERP Mobile/common/Functions/contact/CustomerInfoViewController.m
  10. 2 2
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.m
  11. 1 1
      RedAnt ERP Mobile/common/Functions/order/OrderListViewController.h
  12. 228 109
      RedAnt ERP Mobile/common/Functions/order/OrderListViewController.m
  13. 193 92
      RedAnt ERP Mobile/common/Functions/order/RAOrderEditorViewController.m
  14. 206 102
      RedAnt ERP Mobile/common/Functions/order/RAOrderPreviewController.m
  15. 351 286
      RedAnt ERP Mobile/common/Functions/portfolio/PortfolioViewController.m
  16. 237 237
      RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchViewController.m
  17. 1 1
      RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.h
  18. 108 108
      RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m
  19. 4 2
      RedAnt ERP Mobile/common/Functions/sidemenu/RetrievePassViewController.m
  20. 5 2
      RedAnt ERP Mobile/common/Functions/sidemenu/ScannerSettingViewController.m
  21. 202 160
      RedAnt ERP Mobile/common/Functions/watchlist/WatchListViewController.m
  22. 5 3
      RedAnt ERP Mobile/common/customUI/ImageUploadViewController.m
  23. 11 7
      RedAnt ERP Mobile/common/customUI/ImageViewController.m
  24. 12 12
      RedAnt ERP Mobile/common/customUI/PulldownMenu.m

+ 4 - 4
RedAnt ERP Mobile/common/CommonEditor/CommonEditorCellEdit.m

@@ -19,10 +19,10 @@
     return self;
 }
 
-- (void)awakeFromNib
-{
-    // Initialization code
-}
+//- (void)awakeFromNib
+//{
+//    // Initialization code
+//}
 
 - (void)setSelected:(BOOL)selected animated:(BOOL)animated
 {

+ 7 - 7
RedAnt ERP Mobile/common/CommonEditor/CommonEditorCellModel.m

@@ -28,13 +28,13 @@
     }
     return self;
 }
-
-- (void)awakeFromNib
-{
-    // Initialization code
-    
-//    [self addGestureRecognizer: [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longTap:)]];
-}
+//
+//- (void)awakeFromNib
+//{
+//    // Initialization code
+//    
+////    [self addGestureRecognizer: [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longTap:)]];
+//}
 - (IBAction)onClickBundle:(UIButton *)sender {
     
     UIViewController* vc=[RAUtils getViewController :sender];

+ 1 - 2
RedAnt ERP Mobile/common/CommonEditor/CommonEditorCellTextView.m

@@ -12,8 +12,7 @@
 
 - (void)awakeFromNib {
     
-    
-    
+    [super awakeFromNib];
     self.textview.layer.backgroundColor = [[UIColor clearColor] CGColor];
     
     self.textview.layer.borderColor = [[UIColor lightGrayColor] CGColor];

+ 363 - 102
RedAnt ERP Mobile/common/Functions/MainViewController.m

@@ -1357,19 +1357,150 @@
                             msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
                             
                         }
-                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch To Cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil),NSLocalizedString(@"Create new order", nil), nil];
                         
-                        
-                        
-                        // alert.
-                        [alert show];
+                        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                         
+                        UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+                            //open exist
+                            
+                            OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+                            ovc.showNavibar = true;
+                            ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+                                if(appDelegate.order_code==nil)
+                                {
+                                    [self neworderforCart];
+                                }
+                                else
+                                {
+                                    self.previous_VC = self.current_VC;
+                                    [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
+
+                                    [self checklogin:true];
+                                    
+                                }
+                                
+                            };
+                            ovc.init_style = OL_OPEN;
+                            ovc.onCancel = ^(){
+                                
+                                [self checklogin:true];
+                                
+                            };
+                            ovc.title = @"SAVED ORDER";
+                            [self.navigationController pushViewController:ovc animated:true];
+                        }];
+                         UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                             //create new;
+                             
+                             if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+                             {
+
+                                 ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+                                 cvc.showNavibar = true;
+                                 cvc.contact_type = @"Sales_Order_Customer";
+                                 cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+                                     
+                                     appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+                                     appDelegate.customerInfo = value;
+                                     
+                                     
+                                     if(appDelegate.order_code==nil)
+                                         [self neworderforCart];
+                                     
+
+                                 };
+                                 
+                                 cvc.onCancel = ^(){
+                                     
+                                     [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
+                                     
+                                     
+                                     
+                                 };
+                                 cvc.onReset = ^(){
+                                     [self checklogin:true];
+                                 };
+                                 
+                                 [self.navigationController pushViewController:cvc animated:true];
+                             }
+                             else
+                             {
+                                 [self neworderforCart];
+                             }
+                             
+                         }];
+                         UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+                             
+                             
+                             
+                         }];
+                         
+                         [alertController addAction:action_1];
+                         [alertController addAction:action_2];
+                         [alertController addAction:action_3];
+                         
+                         
+                         [self presentViewController:alertController animated:YES completion:nil];
+//                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch To Cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil),NSLocalizedString(@"Create new order", nil), nil];
+//
+//
+//
+//                        // alert.
+//                        [alert show];
                     }
                     else
                     {
-                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch To Cart", nil) message:NSLocalizedString(@"Do you want to switch to a pending order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil), nil];
                         
-                        // alert.
-                        [alert show];
+                        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:@"Do you want to switch to a pending order?" preferredStyle:UIAlertControllerStyleAlert];
+                         
+                       
+                         UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                             //open exist
+                             
+                             OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+                             ovc.showNavibar = true;
+                             ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+                                 if(appDelegate.order_code==nil)
+                                 {
+                                     [self neworderforCart];
+                                 }
+                                 else
+                                 {
+                                     self.previous_VC = self.current_VC;
+                                     [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
+
+                                     [self checklogin:true];
+                                     
+                                 }
+                                 
+                             };
+                             ovc.init_style = OL_OPEN;
+                             ovc.onCancel = ^(){
+                                 
+                                 [self checklogin:true];
+                                 
+                             };
+                             ovc.title = @"SAVED ORDER";
+                             [self.navigationController pushViewController:ovc animated:true];
+                         }];
+                         UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+                             
+                             
+                             
+                         }];
+                         
+                         
+                         [alertController addAction:action_2];
+                         [alertController addAction:action_3];
+                         
+                         
+                         [self presentViewController:alertController animated:YES completion:nil];
+                        
+                        
+//                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch To Cart", nil) message:NSLocalizedString(@"Do you want to switch to a pending order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil), nil];
+//
+//                        // alert.
+//                        [alert show];
                     }
                 }
                 else
@@ -1423,17 +1554,147 @@
                     
                 }
                 
-                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil),NSLocalizedString(@"Create new order", nil), nil];
+                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                 
+                UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+                    //open exist
+                    
+                    OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+                    ovc.showNavibar = true;
+                    ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+                        if(appDelegate.order_code==nil)
+                        {
+                            [self neworderforCart];
+                        }
+                        else
+                        {
+                            self.previous_VC = self.current_VC;
+                            [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
+
+                            [self checklogin:true];
+                            
+                        }
+                        
+                    };
+                    ovc.init_style = OL_OPEN;
+                    ovc.onCancel = ^(){
+                        
+                        [self checklogin:true];
+                        
+                    };
+                    ovc.title = @"SAVED ORDER";
+                    [self.navigationController pushViewController:ovc animated:true];
+                }];
+                 UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                     //create new;
+                     
+                     if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+                     {
+
+                         ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+                         cvc.showNavibar = true;
+                         cvc.contact_type = @"Sales_Order_Customer";
+                         cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+                             
+                             appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+                             appDelegate.customerInfo = value;
+                             
+                             
+                             if(appDelegate.order_code==nil)
+                                 [self neworderforCart];
+                             
+
+                         };
+                         
+                         cvc.onCancel = ^(){
+                             
+                             [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
+                             
+                             
+                             
+                         };
+                         cvc.onReset = ^(){
+                             [self checklogin:true];
+                         };
+                         
+                         [self.navigationController pushViewController:cvc animated:true];
+                     }
+                     else
+                     {
+                         [self neworderforCart];
+                     }
+                     
+                 }];
+                 UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+                     
+                     
+                     
+                 }];
+                 
+                 [alertController addAction:action_1];
+                 [alertController addAction:action_2];
+                 [alertController addAction:action_3];
+                 
+                 
+                 [self presentViewController:alertController animated:YES completion:nil];
+                
                 
-                // alert.
-                [alert show];
+//                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil),NSLocalizedString(@"Create new order", nil), nil];
+//
+//                // alert.
+//                [alert show];
             }
             else
             {
-                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch to cart", nil) message:NSLocalizedString(@"Do you want to Switch to a pending order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Switch to pending order", nil), nil];
+                 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:@"Do you want to switch to a pending order?" preferredStyle:UIAlertControllerStyleAlert];
+                  
+                
+                  UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Switch to pending order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                      //open exist
+                      
+                      OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+                      ovc.showNavibar = true;
+                      ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+                          if(appDelegate.order_code==nil)
+                          {
+                              [self neworderforCart];
+                          }
+                          else
+                          {
+                              self.previous_VC = self.current_VC;
+                              [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
+
+                              [self checklogin:true];
+                              
+                          }
+                          
+                      };
+                      ovc.init_style = OL_OPEN;
+                      ovc.onCancel = ^(){
+                          
+                          [self checklogin:true];
+                          
+                      };
+                      ovc.title = @"SAVED ORDER";
+                      [self.navigationController pushViewController:ovc animated:true];
+                  }];
+                  UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+                      
+                      
+                      
+                  }];
+                  
+                  
+                  [alertController addAction:action_2];
+                  [alertController addAction:action_3];
+                  
+                  
+                  [self presentViewController:alertController animated:YES completion:nil];
                 
-                // alert.
-                [alert show];
+//                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch to cart", nil) message:NSLocalizedString(@"Do you want to Switch to a pending order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Switch to pending order", nil), nil];
+//
+//                // alert.
+//                [alert show];
             }
         }
         else
@@ -2726,94 +2987,94 @@
     }
 }
 
-#pragma mark - UIAlertViewDelegate
-// Called when a button is clicked. The view will be automatically dismissed after this call returns
-- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
-{
-    UIApplication * app = [UIApplication sharedApplication];
-    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- 
-    
-    
- //   MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-    if(buttonIndex==alertView.cancelButtonIndex)
-    {
-        
-        
-        
-    }
-    else if(buttonIndex==1)
-    {
-        //open exist
-        
-        OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
-        ovc.showNavibar = true;
-        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
-            if(appDelegate.order_code==nil)
-            {
-                [self neworderforCart];
-            }
-            else
-            {
-                self.previous_VC = self.current_VC;
-                [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-
-                [self checklogin:true];
-                
-            }
-            
-        };
-        ovc.init_style = OL_OPEN;
-        ovc.onCancel = ^(){
-            
-            [self checklogin:true];
-            
-        };
-        ovc.title = @"SAVED ORDER";
-        [self.navigationController pushViewController:ovc animated:true];
-    }
-    else
-    {
-        //create new;
-        
-        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
-        {
-
-            ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
-            cvc.showNavibar = true;
-            cvc.contact_type = @"Sales_Order_Customer";
-            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-                
-                appDelegate.contact_id=[value valueForKey:@"customer_cid"];
-                appDelegate.customerInfo = value;
-                
-                
-                if(appDelegate.order_code==nil)
-                    [self neworderforCart];
-                
-
-            };
-            
-            cvc.onCancel = ^(){
-                
-                [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
-                
-                
-                
-            };
-            cvc.onReset = ^(){
-                [self checklogin:true];
-            };
-            
-            [self.navigationController pushViewController:cvc animated:true];
-        }
-        else
-        {
-            [self neworderforCart];
-        }
-        
-    }
-}
+//#pragma mark - UIAlertViewDelegate
+//// Called when a button is clicked. The view will be automatically dismissed after this call returns
+//- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
+//{
+//    UIApplication * app = [UIApplication sharedApplication];
+//    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+//
+//
+//
+// //   MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+//    if(buttonIndex==alertView.cancelButtonIndex)
+//    {
+//
+//
+//
+//    }
+//    else if(buttonIndex==1)
+//    {
+//        //open exist
+//
+//        OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+//        ovc.showNavibar = true;
+//        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+//            if(appDelegate.order_code==nil)
+//            {
+//                [self neworderforCart];
+//            }
+//            else
+//            {
+//                self.previous_VC = self.current_VC;
+//                [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
+//
+//                [self checklogin:true];
+//
+//            }
+//
+//        };
+//        ovc.init_style = OL_OPEN;
+//        ovc.onCancel = ^(){
+//
+//            [self checklogin:true];
+//
+//        };
+//        ovc.title = @"SAVED ORDER";
+//        [self.navigationController pushViewController:ovc animated:true];
+//    }
+//    else
+//    {
+//        //create new;
+//
+//        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+//        {
+//
+//            ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+//            cvc.showNavibar = true;
+//            cvc.contact_type = @"Sales_Order_Customer";
+//            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+//
+//                appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+//                appDelegate.customerInfo = value;
+//
+//
+//                if(appDelegate.order_code==nil)
+//                    [self neworderforCart];
+//
+//
+//            };
+//
+//            cvc.onCancel = ^(){
+//
+//                [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
+//
+//
+//
+//            };
+//            cvc.onReset = ^(){
+//                [self checklogin:true];
+//            };
+//
+//            [self.navigationController pushViewController:cvc animated:true];
+//        }
+//        else
+//        {
+//            [self neworderforCart];
+//        }
+//
+//    }
+//}
 -(void) neworderforCart
 {
     

+ 248 - 217
RedAnt ERP Mobile/common/Functions/camscan/ScannerViewController.m

@@ -465,123 +465,154 @@
 -(void)add_toCart
 {
     
-    
-    
-    UIApplication * app = [UIApplication sharedApplication];
-    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-    if(appDelegate.bLogin==false)
-    {
-        LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
-
-        
-        loginvc.returnValue = ^(bool blogin){
-            
-            
-
-            
-            
-            if(blogin)
-            {
-                if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/ true)
-                {
-                    
-#ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"CategoryViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-#else
-                    
-                    [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
-#endif
-                    
-                    
-                    
-                    [main_vc checklogin:false];
-                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"Do you want to add to pending a order or a new order", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil),NSLocalizedString(@"Add to new order", nil), nil];
-                    
-                    
-                    
-                    // alert.
-                    [alert show];
-                }
-                else
-                {
-                    [main_vc checklogin:true];
-                }
-            }
-            
-
-            
-        };
-        
-        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-        
-        
-        
-        
-        
-        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-        
-        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
-        [self presentViewController:navi animated:YES completion:^{
-            
-            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-            
-            DebugLog(@"LoginViewController present.........");
-            
-            //   self.btop = false;
-            //  <#code#>
-        }];
-    }
-    else
-    {
-        
-        //if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE&&/*appDelegate.contact_id==nil&&*/appDelegate.order_code==nil)
-        if(appDelegate.order_code==nil)
-        {
-            [main_vc checklogin:false];
-            
-            if(appDelegate.can_create_order)
-            {
-                NSString* msg =@"";
-                if(appDelegate.contact_id.length>0)
-                {
-                    msg = [msg stringByAppendingString:@"\n\nCustomer:"];
-                    msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
-                    
-                }
-                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil),NSLocalizedString(@"Add to new order", nil), nil];
-                
-                // alert.
-                [alert show];
-            }
-            else
-            {
-                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil), nil];
-                
-                // alert.
-                [alert show];
-            }
-        }
-        else
-        {
-            
-            
-            if(appDelegate.order_code==nil)
-                [ self neworder];
-            else
-                [self addtocart];
-            
-            
-        }
-    }
-    
-    
-    
-    
-    
-    
-    
-    
+    [CartUtils add_to_cart:self selectorholder:self selector:@selector(addtocart)];
+    return;
+    
+//    UIApplication * app = [UIApplication sharedApplication];
+//    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+//    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+//    if(appDelegate.bLogin==false)
+//    {
+//        LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
+//
+//
+//        loginvc.returnValue = ^(bool blogin){
+//
+//
+//
+//
+//
+//            if(blogin)
+//            {
+//                if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/ true)
+//                {
+//
+//#ifdef RA_NOTIFICATION
+//                    [ActiveViewController Notify:@"CategoryViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//
+//                    [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
+//#endif
+//
+//
+//
+//                    [main_vc checklogin:false];
+//
+//
+//
+//                    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Add to cart" message:@"Do you want to add to pending a order or a new order" preferredStyle:UIAlertControllerStyleAlert];
+//
+//
+//                     UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Add to pending order" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+//
+//
+//
+//                     }];
+//
+//                     UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Add to new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+//
+//
+//
+//                     }];
+//                     UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+//
+//
+//
+//                     }];
+//
+//                     [alertController addAction:action_1];
+//                     [alertController addAction:action_2];
+//                     [alertController addAction:action_3];
+//
+//
+//                     [self presentViewController:alertController animated:YES completion:nil];
+//
+////                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"Do you want to add to pending a order or a new order", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil),NSLocalizedString(@"Add to new order", nil), nil];
+////
+////
+////
+////                    // alert.
+////                    [alert show];
+//                }
+//                else
+//                {
+//                    [main_vc checklogin:true];
+//                }
+//            }
+//
+//
+//
+//        };
+//
+//        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
+//
+//
+//
+//
+//
+//        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
+//
+//        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
+//        [self presentViewController:navi animated:YES completion:^{
+//
+//            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
+//
+//            DebugLog(@"LoginViewController present.........");
+//
+//            //   self.btop = false;
+//            //  <#code#>
+//        }];
+//    }
+//    else
+//    {
+//
+//        //if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE&&/*appDelegate.contact_id==nil&&*/appDelegate.order_code==nil)
+//        if(appDelegate.order_code==nil)
+//        {
+//            [main_vc checklogin:false];
+//
+//            if(appDelegate.can_create_order)
+//            {
+//                NSString* msg =@"";
+//                if(appDelegate.contact_id.length>0)
+//                {
+//                    msg = [msg stringByAppendingString:@"\n\nCustomer:"];
+//                    msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
+//
+//                }
+//                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil),NSLocalizedString(@"Add to new order", nil), nil];
+//
+//                // alert.
+//                [alert show];
+//            }
+//            else
+//            {
+//                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil), nil];
+//
+//                // alert.
+//                [alert show];
+//            }
+//        }
+//        else
+//        {
+//
+//
+//            if(appDelegate.order_code==nil)
+//                [ self neworder];
+//            else
+//                [self addtocart];
+//
+//
+//        }
+//    }
+//
+//
+//
+//
+//
+//
+//
+//
 }
 
 
@@ -846,104 +877,104 @@
     return [translatedPoints copy];
 }
 
-#pragma mark - UIAlertViewDelegate
-// Called when a button is clicked. The view will be automatically dismissed after this call returns
-- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
-{
-    UIApplication * app = [UIApplication sharedApplication];
-    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
-    
-    //   int count=[self.quantity_text.text intValue];
-    
-    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-    if(buttonIndex==alertView.cancelButtonIndex)
-    {
-        
-        
-        
-    }
-    else if(buttonIndex==1)
-    {
-        //open exist
-                OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
-        ovc.showNavibar = true;
-        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
-            if(appDelegate.order_code==nil)
-            {
-                [self neworder];
-            }
-            else
-            {
-
-                
-#ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-#else
-                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-#endif
-                [self addtocart];
-                [main_vc checklogin:true];
-                
-                
-            }
-            
-        };
-        ovc.init_style = OL_OPEN;
-        ovc.onCancel = ^(){
-            
-            [main_vc checklogin:true];
-            
-        };
-        
-        [self.navigationController pushViewController:ovc animated:true];
-    }
-    else
-    {
-        //create new;
-        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
-        {
-           
-            
-            ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
-            cvc.showNavibar = true;
-            cvc.contact_type = @"Sales_Order_Customer";
-            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-                
-                appDelegate.contact_id=[value valueForKey:@"customer_cid"];
-                appDelegate.customerInfo = value;
-                
-                
-                if(appDelegate.order_code==nil)
-                    [self neworder];
-                
-                [main_vc checklogin:true];
-                //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-                
-                //
-                //                if(self.returnValue)
-                //                    self.returnValue(value);
-            };
-            
-            cvc.onCancel = ^(){
-                
-                UIViewController *vc= [RAUtils getViewController:self];
-                [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"New Order" controller:vc];
-                
-            };
-            cvc.onReset = ^(){
-                [main_vc checklogin:true];
-            };
-            
-            [self.navigationController pushViewController:cvc animated:true];
-        }
-        else
-        {
-            [self neworder];
-        }
-        
-        
-    }
-}
+//#pragma mark - UIAlertViewDelegate
+//// Called when a button is clicked. The view will be automatically dismissed after this call returns
+//- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
+//{
+//    UIApplication * app = [UIApplication sharedApplication];
+//    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+//
+//    
+//    //   int count=[self.quantity_text.text intValue];
+//    
+//    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+//    if(buttonIndex==alertView.cancelButtonIndex)
+//    {
+//        
+//        
+//        
+//    }
+//    else if(buttonIndex==1)
+//    {
+//        //open exist
+//                OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+//        ovc.showNavibar = true;
+//        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+//            if(appDelegate.order_code==nil)
+//            {
+//                [self neworder];
+//            }
+//            else
+//            {
+//
+//                
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//#endif
+//                [self addtocart];
+//                [main_vc checklogin:true];
+//                
+//                
+//            }
+//            
+//        };
+//        ovc.init_style = OL_OPEN;
+//        ovc.onCancel = ^(){
+//            
+//            [main_vc checklogin:true];
+//            
+//        };
+//        
+//        [self.navigationController pushViewController:ovc animated:true];
+//    }
+//    else
+//    {
+//        //create new;
+//        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+//        {
+//           
+//            
+//            ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+//            cvc.showNavibar = true;
+//            cvc.contact_type = @"Sales_Order_Customer";
+//            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+//                
+//                appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+//                appDelegate.customerInfo = value;
+//                
+//                
+//                if(appDelegate.order_code==nil)
+//                    [self neworder];
+//                
+//                [main_vc checklogin:true];
+//                //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+//                
+//                //
+//                //                if(self.returnValue)
+//                //                    self.returnValue(value);
+//            };
+//            
+//            cvc.onCancel = ^(){
+//                
+//                UIViewController *vc= [RAUtils getViewController:self];
+//                [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"New Order" controller:vc];
+//                
+//            };
+//            cvc.onReset = ^(){
+//                [main_vc checklogin:true];
+//            };
+//            
+//            [self.navigationController pushViewController:cvc animated:true];
+//        }
+//        else
+//        {
+//            [self neworder];
+//        }
+//        
+//        
+//    }
+//}
 @end

+ 3 - 3
RedAnt ERP Mobile/common/Functions/cart/BundleModelCell.m

@@ -10,9 +10,9 @@
 
 @implementation BundleModelCell
 
-- (void)awakeFromNib {
-    // Initialization code
-}
+//- (void)awakeFromNib {
+//    // Initialization code
+//}
 
 - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
     [super setSelected:selected animated:animated];

+ 7 - 7
RedAnt ERP Mobile/common/Functions/contact/ContactListTableViewCell.m

@@ -10,13 +10,13 @@
 
 @implementation ContactListTableViewCell
 
-- (void)awakeFromNib {
-    // Initialization code
-    
-    
-    //    timelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
-//    self.rtlabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
-}
+//- (void)awakeFromNib {
+//    // Initialization code
+//    
+//    
+//    //    timelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
+////    self.rtlabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
+//}
 
 - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
     [super setSelected:selected animated:animated];

+ 1 - 0
RedAnt ERP Mobile/common/Functions/contact/ContactListViewController.m

@@ -37,6 +37,7 @@
 
 
 - (void)awakeFromNib {
+    [super awakeFromNib];
     self.edit_icon = true;
     self.assig_icon = true;
     self.reset_icon=false;

+ 4 - 2
RedAnt ERP Mobile/common/Functions/contact/CustomerInfoViewController.m

@@ -520,9 +520,11 @@
                 int result=[[return_json valueForKey:@"result"] intValue];
                 if(result==2)
                 {
-                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Upload successful." message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                     
-                    [alert show];
+                    [RAUtils message_alert:nil title:@"Upload successful." controller:self];
+//                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Upload successful." message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+//                    
+//                    [alert show];
                 }
             }
             else

+ 2 - 2
RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.m

@@ -456,9 +456,9 @@
 
 - (IBAction)add_toCart:(id)sender {
     
-    UIViewController *vc= [RAUtils getViewController:self];
-    [CartUtils add_to_cart:vc selectorholder:self selector:@selector(addtocart)];
+    [CartUtils add_to_cart:self selectorholder:self selector:@selector(addtocart)];
     return;
+
 //
 //
 //    int count=[self.quantity_text.text intValue];

+ 1 - 1
RedAnt ERP Mobile/common/Functions/order/OrderListViewController.h

@@ -13,7 +13,7 @@
 
 #define OL_DEFAULT 0
 #define OL_OPEN 1
-@interface OrderListViewController : ActiveViewController <UIAlertViewDelegate,EnumSelectViewControllerDelegate>
+@interface OrderListViewController : ActiveViewController </*UIAlertViewDelegate,*/EnumSelectViewControllerDelegate>
 //@property (strong, nonatomic) NSMutableDictionary* content_data;
 //@property (strong,nonatomic) UIButton* btnrefresh;
 @property (strong, nonatomic) IBOutlet UITableView *table_order;

+ 228 - 109
RedAnt ERP Mobile/common/Functions/order/OrderListViewController.m

@@ -402,8 +402,127 @@
             
         }
     }
-    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Warning", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
-    [alert show];
+    
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Warning" message:msg preferredStyle:UIAlertControllerStyleAlert];
+     
+     
+
+
+     UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+             AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+             
+             if(appDelegate.order_code && appDelegate.order_code.length>0)
+             {
+     //            appDelegate.order_code= nil;
+     //            [appDelegate SetSo:nil];
+                 
+                 if (appDelegate.user_type == USER_ROLE_EMPLOYEE) {
+                     //     MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+                     ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+                     cvc.showNavibar = true;
+                     cvc.contact_type = @"Sales_Order_Customer";
+                     cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+                         
+                         appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+                         appDelegate.customerInfo = value;
+                         
+                         self.norefresh = true;
+                         [self neworder];
+                         
+                         
+                         
+                         //    [main_vc checklogin:true];
+                         //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                         
+                         //
+                         //                if(self.returnValue)
+                         //                    self.returnValue(value);
+                     };
+                     
+                     cvc.onCancel = ^(){
+                         self.norefresh = true;
+                         if(appDelegate.customerInfo==nil)
+                         {
+                             [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
+                         }
+                         else
+                         {
+                             [self neworder];
+                         }
+                         //  [main_vc checklogin:true];
+                     };
+                     cvc.onReset = ^(){
+                         //   [main_vc checklogin:true];
+                     };
+                     
+                     [self.navigationController pushViewController:cvc animated:true];
+                 }
+                 else if (appDelegate.user_type == USER_ROLE_CUSTOMER){
+                     [self neworder];
+                 }
+                 
+             }
+             else
+             {
+                 //create new;
+                 
+                 if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+                 {
+                     MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+                     ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+                     cvc.showNavibar = true;
+                     cvc.contact_type = @"Sales_Order_Customer";
+                     cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+                         
+                         appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+                         appDelegate.customerInfo = value;
+                         
+                         
+                         if(appDelegate.order_code==nil)
+                             [self neworder];
+                         
+                         //   [main_vc checklogin:true];
+                         //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                         
+                         //
+                         //                if(self.returnValue)
+                         //                    self.returnValue(value);
+                     };
+                     
+                     cvc.onCancel = ^(){
+                         
+                         [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
+                         
+                         
+                         
+                     };
+                     cvc.onReset = ^(){
+                         [main_vc checklogin:true];
+                     };
+                     
+                     [self.navigationController pushViewController:cvc animated:true];
+                 }
+                 else
+                 {
+                     [self neworder];
+                 }
+             }
+             
+         }];
+     UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"NO" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+         
+         
+         
+     }];
+
+     [alertController addAction:action_2];
+     [alertController addAction:action_3];
+     
+     
+     [self presentViewController:alertController animated:YES completion:nil];
+    
+//    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Warning", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
+//    [alert show];
     
     
 }
@@ -858,113 +977,113 @@
 //        });
 //    });
 }
-#pragma mark - UIAlertViewDelegate
-// Called when a button is clicked. The view will be automatically dismissed after this call returns
-- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
-{
-    if(buttonIndex!=alertView.cancelButtonIndex)
-    {
-        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-        
-        if(appDelegate.order_code && appDelegate.order_code.length>0)
-        {
-//            appDelegate.order_code= nil;
-//            [appDelegate SetSo:nil];
-            
-            if (appDelegate.user_type == USER_ROLE_EMPLOYEE) {
-                //     MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-                ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
-                cvc.showNavibar = true;
-                cvc.contact_type = @"Sales_Order_Customer";
-                cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-                    
-                    appDelegate.contact_id=[value valueForKey:@"customer_cid"];
-                    appDelegate.customerInfo = value;
-                    
-                    self.norefresh = true;
-                    [self neworder];
-                    
-                    
-                    
-                    //    [main_vc checklogin:true];
-                    //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-                    
-                    //
-                    //                if(self.returnValue)
-                    //                    self.returnValue(value);
-                };
-                
-                cvc.onCancel = ^(){
-                    self.norefresh = true;
-                    if(appDelegate.customerInfo==nil)
-                    {
-                        [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
-                    }
-                    else
-                    {
-                        [self neworder];
-                    }
-                    //  [main_vc checklogin:true];
-                };
-                cvc.onReset = ^(){
-                    //   [main_vc checklogin:true];
-                };
-                
-                [self.navigationController pushViewController:cvc animated:true];
-            }
-            else if (appDelegate.user_type == USER_ROLE_CUSTOMER){
-                [self neworder];
-            }
-            
-        }
-        else
-        {
-            //create new;
-            
-            if(appDelegate.customerInfo==nil)// select contact if current contact not exist
-            {
-                MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-                ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
-                cvc.showNavibar = true;
-                cvc.contact_type = @"Sales_Order_Customer";
-                cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-                    
-                    appDelegate.contact_id=[value valueForKey:@"customer_cid"];
-                    appDelegate.customerInfo = value;
-                    
-                    
-                    if(appDelegate.order_code==nil)
-                        [self neworder];
-                    
-                    //   [main_vc checklogin:true];
-                    //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-                    
-                    //
-                    //                if(self.returnValue)
-                    //                    self.returnValue(value);
-                };
-                
-                cvc.onCancel = ^(){
-                    
-                    [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
-                    
-                    
-                    
-                };
-                cvc.onReset = ^(){
-                    [main_vc checklogin:true];
-                };
-                
-                [self.navigationController pushViewController:cvc animated:true];
-            }
-            else
-            {
-                [self neworder];
-            }
-        }
-        
-    }
-}
+//#pragma mark - UIAlertViewDelegate
+//// Called when a button is clicked. The view will be automatically dismissed after this call returns
+//- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
+//{
+//    if(buttonIndex!=alertView.cancelButtonIndex)
+//    {
+//        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//        
+//        if(appDelegate.order_code && appDelegate.order_code.length>0)
+//        {
+////            appDelegate.order_code= nil;
+////            [appDelegate SetSo:nil];
+//            
+//            if (appDelegate.user_type == USER_ROLE_EMPLOYEE) {
+//                //     MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+//                ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+//                cvc.showNavibar = true;
+//                cvc.contact_type = @"Sales_Order_Customer";
+//                cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+//                    
+//                    appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+//                    appDelegate.customerInfo = value;
+//                    
+//                    self.norefresh = true;
+//                    [self neworder];
+//                    
+//                    
+//                    
+//                    //    [main_vc checklogin:true];
+//                    //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+//                    
+//                    //
+//                    //                if(self.returnValue)
+//                    //                    self.returnValue(value);
+//                };
+//                
+//                cvc.onCancel = ^(){
+//                    self.norefresh = true;
+//                    if(appDelegate.customerInfo==nil)
+//                    {
+//                        [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
+//                    }
+//                    else
+//                    {
+//                        [self neworder];
+//                    }
+//                    //  [main_vc checklogin:true];
+//                };
+//                cvc.onReset = ^(){
+//                    //   [main_vc checklogin:true];
+//                };
+//                
+//                [self.navigationController pushViewController:cvc animated:true];
+//            }
+//            else if (appDelegate.user_type == USER_ROLE_CUSTOMER){
+//                [self neworder];
+//            }
+//            
+//        }
+//        else
+//        {
+//            //create new;
+//            
+//            if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+//            {
+//                MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+//                ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+//                cvc.showNavibar = true;
+//                cvc.contact_type = @"Sales_Order_Customer";
+//                cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+//                    
+//                    appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+//                    appDelegate.customerInfo = value;
+//                    
+//                    
+//                    if(appDelegate.order_code==nil)
+//                        [self neworder];
+//                    
+//                    //   [main_vc checklogin:true];
+//                    //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+//                    
+//                    //
+//                    //                if(self.returnValue)
+//                    //                    self.returnValue(value);
+//                };
+//                
+//                cvc.onCancel = ^(){
+//                    
+//                    [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
+//                    
+//                    
+//                    
+//                };
+//                cvc.onReset = ^(){
+//                    [main_vc checklogin:true];
+//                };
+//                
+//                [self.navigationController pushViewController:cvc animated:true];
+//            }
+//            else
+//            {
+//                [self neworder];
+//            }
+//        }
+//        
+//    }
+//}
 #pragma mark - Table view data source
 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
 {

+ 193 - 92
RedAnt ERP Mobile/common/Functions/order/RAOrderEditorViewController.m

@@ -17,7 +17,7 @@
 
 
 
-#define CLOSE_ACTION 567
+//#define CLOSE_ACTION 567
 static const int totalPage = 3;
 
 @interface RAOrderEditorViewController ()
@@ -156,106 +156,207 @@ static const int totalPage = 3;
     }
     
     
-    UIAlertView * alert = nil;
+//    UIAlertView * alert = nil;
+    NSString* a2title = nil;
     if(appDelegate.order_status==0)
-    {
-        alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Choose your action", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Switch to cart", nil),@"Switch to order history",NSLocalizedString(@"Close and cancel order", nil), nil];
-        
-    }
+       a2title= @"Close and cancel order";
     else
-    {
-        alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Choose your action", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Switch to cart", nil),@"Switch to order history",NSLocalizedString(@"Close and release order", nil), nil];
-        
-    }
+        a2title=@"Close and release order";
     
-    alert.tag = CLOSE_ACTION;
-
-    [alert show];
-
-
-}
-
-- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
     
-    if(alertView.tag == CLOSE_ACTION)
-    {
-        if(buttonIndex==1)
-        {
-            
+    
+    
+        
+        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Choose your action" message:@"" preferredStyle:UIAlertControllerStyleAlert];
+         
+         
+         UIAlertAction *action_0 = [UIAlertAction actionWithTitle:@"Switch to cart" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+             
             [self.navigationController popViewControllerAnimated:true];
+             
+         }];
+         
+         UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Switch to order history" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+                     
+                     [self.navigationController popViewControllerAnimated:false];
+                     
+                     
+
+                     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+         //#ifdef RA_NOTIFICATION
+         //            [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+         //#else
+         //            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+         //#endif
+                     [((MainViewController*)appDelegate.main_vc) switchToOrder];
+
+                 }];
+
+         UIAlertAction *action_2 = [UIAlertAction actionWithTitle:a2title style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                     // close order;
+                     
+                     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
+                     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                         
+                         NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:nil];
+                         
+                         dispatch_async(dispatch_get_main_queue(), ^{
+         //                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+                             [waitalert dismissViewControllerAnimated:YES completion:nil];
+                             
+                             if([[order_json valueForKey:@"result"] intValue]==2)
+                             {
+                                 AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                                 
+                                 [appDelegate closeOrder];
+
+                                 
+         //#ifdef RA_NOTIFICATION
+         //                        [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+         //#else
+         //                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+         //#endif
+                                 [((MainViewController*)appDelegate.main_vc) switchToHome];
+                                 
+                                 if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
+                                 {
+                                     [((MainViewController*)appDelegate.main_vc) Loginout:false];
+                                 }
+                                 
+                                 [self prepareReturn:nil];
+                                 
+                                 
+                                 [self.navigationController popViewControllerAnimated:true];
+
+                                 
+                             }
+                             else
+                             {
+                                 [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
+                             }
+                             
+                             
+                             
+                         });
+                     });
+                     
+                     
+                 }];
+         UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+             
+             
+             
+         }];
+         [alertController addAction:action_0];
+         [alertController addAction:action_1];
+         [alertController addAction:action_2];
+         [alertController addAction:action_3];
+         
+         
+         [self presentViewController:alertController animated:YES completion:nil];
+        
+//
+//        alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Choose your action", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Switch to cart", nil),@"Switch to order history",NSLocalizedString(@"Close and cancel order", nil), nil];
+        
+    
+//    else
+//    {
+        
+       
+        
+//        alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Choose your action", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Switch to cart", nil),@"Switch to order history",NSLocalizedString(@"Close and release order", nil), nil];
+        
+//    }
+    
+//    alert.tag = CLOSE_ACTION;
+//
+//    [alert show];
 
-        }
-        if(buttonIndex==2)
-        {
-            
-            [self.navigationController popViewControllerAnimated:false];
-            
-            
 
-            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//#ifdef RA_NOTIFICATION
-//            [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-//#else
-//            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-//#endif
-            [((MainViewController*)appDelegate.main_vc) switchToOrder];
+}
 
-        }
-        else if(buttonIndex==3)
-        {
-            // close order;
-            
-            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-            UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                
-                NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:nil];
-                
-                dispatch_async(dispatch_get_main_queue(), ^{
+//- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
+//
+//    if(alertView.tag == CLOSE_ACTION)
+//    {
+//        if(buttonIndex==1)
+//        {
+//
+//            [self.navigationController popViewControllerAnimated:true];
+//
+//        }
+//        if(buttonIndex==2)
+//        {
+//
+//            [self.navigationController popViewControllerAnimated:false];
+//
+//
+//
+//            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+////#ifdef RA_NOTIFICATION
+////            [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+////#else
+////            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+////#endif
+//            [((MainViewController*)appDelegate.main_vc) switchToOrder];
+//
+//        }
+//        else if(buttonIndex==3)
+//        {
+//            // close order;
+//
+//            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//            UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:nil];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+////                    [waitalert dismissViewControllerAnimated:YES completion:nil];
 //                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    
-                    if([[order_json valueForKey:@"result"] intValue]==2)
-                    {
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        
-                        [appDelegate closeOrder];
-
-                        
-//#ifdef RA_NOTIFICATION
-//                        [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-//#else
-//                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-//#endif
-                        [((MainViewController*)appDelegate.main_vc) switchToHome];
-                        
-                        if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
-                        {
-                            [((MainViewController*)appDelegate.main_vc) Loginout:false];
-                        }
-                        
-                        [self prepareReturn:nil];
-                        
-                        
-                        [self.navigationController popViewControllerAnimated:true];
-
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
-                    }
-                    
-                    
-                    
-                });
-            });
-            
-            
-        }
-    }
-    
-}
+//
+//                    if([[order_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//
+//                        [appDelegate closeOrder];
+//
+//
+////#ifdef RA_NOTIFICATION
+////                        [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+////#else
+////                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+////#endif
+//                        [((MainViewController*)appDelegate.main_vc) switchToHome];
+//
+//                        if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
+//                        {
+//                            [((MainViewController*)appDelegate.main_vc) Loginout:false];
+//                        }
+//
+//                        [self prepareReturn:nil];
+//
+//
+//                        [self.navigationController popViewControllerAnimated:true];
+//
+//
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
+//                    }
+//
+//
+//
+//                });
+//            });
+//
+//
+//        }
+//    }
+//
+//}
 
 - (void)setupPageControlBar {
     

+ 206 - 102
RedAnt ERP Mobile/common/Functions/order/RAOrderPreviewController.m

@@ -21,7 +21,7 @@
 
 #define SUBMIT_CONFIRM 123
 #define KEEP_TAIL 456
-#define CLOSE_ACTION 567
+//#define CLOSE_ACTION 567
 
 @interface RAOrderPreviewController ()
 
@@ -1706,23 +1706,127 @@
     }
     
     
-    UIAlertView * alert = nil;
+    NSString* a3title = nil;
     if(appDelegate.order_status==0)
-    {
-        alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Choose your action", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:@"Continue edit order",NSLocalizedString(@"Switch to cart", nil),@"Switch to order history",NSLocalizedString(@"Close and release order", nil), nil];
-        
-    }
+       a3title= @"Close and cancel order";
     else
-    {
-        alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Choose your action", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:@"Continue edit order",NSLocalizedString(@"Switch to cart", nil),@"Switch to order history",NSLocalizedString(@"Close and release order", nil), nil];
-        
-    }
+        a3title=@"Close and release order";
+    
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Choose your action" message:@"" preferredStyle:UIAlertControllerStyleAlert];
+     
+    
     
     
     
-    alert.tag = CLOSE_ACTION;
-    // alert.
-    [alert show];
+     
+     UIAlertAction *action_0 = [UIAlertAction actionWithTitle:@"Continue edit order" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+         // back edit order
+         [self.navigationController popViewControllerAnimated:YES];
+     }];
+     
+     UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Switch to cart" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+         // back to cart
+         [self.navigationController popToRootViewControllerAnimated:true];
+
+     }];
+    UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Switch to order history" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+        
+        [self.navigationController popToRootViewControllerAnimated:false];
+        
+        
+        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+        
+        
+        
+        
+
+        [((MainViewController*)appDelegate.main_vc) switchToOrder];
+
+    }];
+
+     UIAlertAction *action_3 = [UIAlertAction actionWithTitle:a3title style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                 // close order;
+                 
+                 
+                 AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                 UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
+                 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                     
+                     NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:nil];
+                     
+                     dispatch_async(dispatch_get_main_queue(), ^{
+                         [waitalert dismissViewControllerAnimated:YES completion:nil];
+                         if([[order_json valueForKey:@"result"] intValue]==2)
+                         {
+                             AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                             //                        appDelegate.order_code = nil;
+                             
+                             [appDelegate closeOrder];
+                             
+                             
+     #ifdef RA_NOTIFICATION
+                             [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+     #else
+                             [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+     #endif
+                             [((MainViewController*)appDelegate.main_vc) switchToHome];
+                             
+                             if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
+                             {
+                                 [((MainViewController*)appDelegate.main_vc) Loginout:false];
+                             }
+                             
+                             [self prepareReturn:nil];
+                             
+                             
+                             [self.navigationController popToRootViewControllerAnimated:true];
+                             //                        [self.navigationController dismissViewControllerAnimated:true completion:^{
+                             //                            ;
+                             //                        }];
+                             
+                         }
+                         else
+                         {
+                             [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
+                         }
+                         
+                         
+                         
+                     });
+                 });
+
+             }];
+     UIAlertAction *action_4 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+         
+         
+         
+     }];
+     [alertController addAction:action_0];
+     [alertController addAction:action_1];
+     [alertController addAction:action_2];
+     [alertController addAction:action_3];
+     
+     
+     [self presentViewController:alertController animated:YES completion:nil];
+//
+//
+//    UIAlertView * alert = nil;
+//    if(appDelegate.order_status==0)
+//    {
+//        alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Choose your action", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:@"Continue edit order",NSLocalizedString(@"Switch to cart", nil),@"Switch to order history",NSLocalizedString(@"Close and release order", nil), nil];
+
+//    }
+//    else
+//    {
+//        alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Choose your action", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:@"Continue edit order",NSLocalizedString(@"Switch to cart", nil),@"Switch to order history",NSLocalizedString(@"Close and release order", nil), nil];
+//
+//    }
+//
+//
+//
+//    alert.tag = CLOSE_ACTION;
+//    // alert.
+//    [alert show];
     
     
     //    if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
@@ -1966,95 +2070,95 @@
  // Pass the selected object to the new view controller.
  }
  */
-#pragma mark - UIAlertViewDelegate
-// Called when a button is clicked. The view will be automatically dismissed after this call returns
-- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
-{
-    
-
-
-    if(alertView.tag == CLOSE_ACTION)
-    {
-        if (buttonIndex == 1) {
-            // back edit order
-            [self.navigationController popViewControllerAnimated:YES];
-        }
-        else if(buttonIndex==2)
-        {
-            // back to cart
-            [self.navigationController popToRootViewControllerAnimated:true];
-
-        }
-        else if(buttonIndex==3)
-        {
-            
-            [self.navigationController popToRootViewControllerAnimated:false];
-            
-            
-            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-            
-            
-            
-            
-
-            [((MainViewController*)appDelegate.main_vc) switchToOrder];
-
-        }
-        else if(buttonIndex==4)
-        {
-            // close order;
-            
-            
-            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-            UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                
-                NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:nil];
-                
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    if([[order_json valueForKey:@"result"] intValue]==2)
-                    {
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        //                        appDelegate.order_code = nil;
-                        
-                        [appDelegate closeOrder];
-                        
-                        
-#ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-#else
-                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-#endif
-                        [((MainViewController*)appDelegate.main_vc) switchToHome];
-                        
-                        if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
-                        {
-                            [((MainViewController*)appDelegate.main_vc) Loginout:false];
-                        }
-                        
-                        [self prepareReturn:nil];
-                        
-                        
-                        [self.navigationController popToRootViewControllerAnimated:true];
-                        //                        [self.navigationController dismissViewControllerAnimated:true completion:^{
-                        //                            ;
-                        //                        }];
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
-                    }
-                    
-                    
-                    
-                });
-            });
-
-        }
-    }
-}
+//#pragma mark - UIAlertViewDelegate
+//// Called when a button is clicked. The view will be automatically dismissed after this call returns
+//- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
+//{
+//
+//
+//
+//    if(alertView.tag == CLOSE_ACTION)
+//    {
+//        if (buttonIndex == 1) {
+//            // back edit order
+//            [self.navigationController popViewControllerAnimated:YES];
+//        }
+//        else if(buttonIndex==2)
+//        {
+//            // back to cart
+//            [self.navigationController popToRootViewControllerAnimated:true];
+//
+//        }
+//        else if(buttonIndex==3)
+//        {
+//
+//            [self.navigationController popToRootViewControllerAnimated:false];
+//
+//
+//            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//
+//
+//
+//
+//
+//            [((MainViewController*)appDelegate.main_vc) switchToOrder];
+//
+//        }
+//        else if(buttonIndex==4)
+//        {
+//            // close order;
+//
+//
+//            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//            UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:nil];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+//                    if([[order_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                        //                        appDelegate.order_code = nil;
+//
+//                        [appDelegate closeOrder];
+//
+//
+//#ifdef RA_NOTIFICATION
+//                        [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//#endif
+//                        [((MainViewController*)appDelegate.main_vc) switchToHome];
+//
+//                        if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
+//                        {
+//                            [((MainViewController*)appDelegate.main_vc) Loginout:false];
+//                        }
+//
+//                        [self prepareReturn:nil];
+//
+//
+//                        [self.navigationController popToRootViewControllerAnimated:true];
+//                        //                        [self.navigationController dismissViewControllerAnimated:true completion:^{
+//                        //                            ;
+//                        //                        }];
+//
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
+//                    }
+//
+//
+//
+//                });
+//            });
+//
+//        }
+//    }
+//}
 
 - (void)releaseOrderAfterSave {
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];

+ 351 - 286
RedAnt ERP Mobile/common/Functions/portfolio/PortfolioViewController.m

@@ -31,7 +31,7 @@
 
 #endif
 
-#define ALERT_DEL 1025
+//#define ALERT_DEL 1025
 #define checked_Count @"checkedCount"
 @interface PortfolioViewController ()
 
@@ -96,131 +96,131 @@
    // [self refresh_total];
 #endif
 }
-- (IBAction)onAddtoCart:(id)sender {
-    UIApplication * app = [UIApplication sharedApplication];
-    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-    if(appDelegate.bLogin==false)
-    {
-        
-        LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
-        //        loginvc.delegate = self;
-        //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-        
-        loginvc.returnValue = ^(bool blogin){
-            
-            
-            //            UIApplication * app = [UIApplication sharedApplication];
-            //            AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-            
-            
-            
-            
-            if(blogin)
-            {
-                if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
-                {
-                    
-                    [main_vc checklogin:false];
-                    
-                    if(appDelegate.can_create_order)
-                    {
-                        NSString* msg =@"";
-                        if(appDelegate.contact_id.length>0)
-                        {
-                            msg = [msg stringByAppendingString:@"\n\nCustomer:"];
-                            msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
-                            
-                        }
-                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil),NSLocalizedString(@"Create new order", nil), nil];
-                    
-                    
-                    
-                    // alert.
-                    [alert show];
-                    }
-                    else
-                    {
-                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil), nil];
-                        
-                        // alert.
-                        [alert show];
-                    }
-                }
-                else
-                {
-                    [main_vc checklogin:true];
-                }
-            }
-            
-            //            self.offset = 0;
-            //            [self.content_data removeAllObjects];
-            //            [self loadpage];
-            //
-            //            [[self navigationController] setNavigationBarHidden:YES animated:NO];
-            
-        };
-        
-        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-        
-        
-        
-        
-        
-        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-        
-        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
-        [self presentViewController:navi animated:YES completion:^{
-            
-            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-            
-            DebugLog(@"LoginViewController present.........");
-            
-            //   self.btop = false;
-            //  <#code#>
-        }];
-    }
-    else
-    {
-        if(appDelegate.user_type==USER_ROLE_EMPLOYEE&&/*appDelegate.contact_id==nil&&*/appDelegate.order_code==nil)
-        {
-            [main_vc checklogin:false];
-            if(appDelegate.can_create_order)
-            {
-                NSString* msg =@"";
-                if(appDelegate.contact_id.length>0)
-                {
-                    msg = [msg stringByAppendingString:@"\n\nCustomer:"];
-                    msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
-                    
-                }
-            UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil),NSLocalizedString(@"Create new order", nil), nil];
-            
-            // alert.
-            [alert show];
-            }
-            else
-            {
-                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil), nil];
-                
-                // alert.
-                [alert show];
-            }
-        }
-        else
-        {
-            
-            if(appDelegate.order_code==nil)
-            [ self neworder];
-            else
-            [self addtocart];
-            
-            
-            
-        }
-    }
-    
-}
+//- (IBAction)onAddtoCart:(id)sender {
+//    UIApplication * app = [UIApplication sharedApplication];
+//    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+//    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+//    if(appDelegate.bLogin==false)
+//    {
+//
+//        LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
+//        //        loginvc.delegate = self;
+//        //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
+//
+//        loginvc.returnValue = ^(bool blogin){
+//
+//
+//            //            UIApplication * app = [UIApplication sharedApplication];
+//            //            AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+//
+//
+//
+//
+//            if(blogin)
+//            {
+//                if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
+//                {
+//
+//                    [main_vc checklogin:false];
+//
+//                    if(appDelegate.can_create_order)
+//                    {
+//                        NSString* msg =@"";
+//                        if(appDelegate.contact_id.length>0)
+//                        {
+//                            msg = [msg stringByAppendingString:@"\n\nCustomer:"];
+//                            msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
+//
+//                        }
+//                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil),NSLocalizedString(@"Create new order", nil), nil];
+//
+//
+//
+//                    // alert.
+//                    [alert show];
+//                    }
+//                    else
+//                    {
+//                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil), nil];
+//
+//                        // alert.
+//                        [alert show];
+//                    }
+//                }
+//                else
+//                {
+//                    [main_vc checklogin:true];
+//                }
+//            }
+//
+//            //            self.offset = 0;
+//            //            [self.content_data removeAllObjects];
+//            //            [self loadpage];
+//            //
+//            //            [[self navigationController] setNavigationBarHidden:YES animated:NO];
+//
+//        };
+//
+//        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
+//
+//
+//
+//
+//
+//        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
+//
+//        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
+//        [self presentViewController:navi animated:YES completion:^{
+//
+//            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
+//
+//            DebugLog(@"LoginViewController present.........");
+//
+//            //   self.btop = false;
+//            //  <#code#>
+//        }];
+//    }
+//    else
+//    {
+//        if(appDelegate.user_type==USER_ROLE_EMPLOYEE&&/*appDelegate.contact_id==nil&&*/appDelegate.order_code==nil)
+//        {
+//            [main_vc checklogin:false];
+//            if(appDelegate.can_create_order)
+//            {
+//                NSString* msg =@"";
+//                if(appDelegate.contact_id.length>0)
+//                {
+//                    msg = [msg stringByAppendingString:@"\n\nCustomer:"];
+//                    msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
+//
+//                }
+//            UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil),NSLocalizedString(@"Create new order", nil), nil];
+//
+//            // alert.
+//            [alert show];
+//            }
+//            else
+//            {
+//                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil), nil];
+//
+//                // alert.
+//                [alert show];
+//            }
+//        }
+//        else
+//        {
+//
+//            if(appDelegate.order_code==nil)
+//            [ self neworder];
+//            else
+//            [self addtocart];
+//
+//
+//
+//        }
+//    }
+//
+//}
 -(void) addtocart
 {
     
@@ -1553,10 +1553,75 @@
         
         DebugLog(@"delete click");
         self.deleteIndexPath = indexPath;
-        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Delete confirm", nil) message:NSLocalizedString(@"Are you sure remove model from portfolio?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
-        alert.tag = ALERT_DEL;
-        // alert.
-        [alert show];
+        
+        
+        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Delete confirm" message:@"Are you sure remove model from portfolio?" preferredStyle:UIAlertControllerStyleAlert];
+         
+       
+
+        UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            
+            
+            
+            self.indexPath = self.deleteIndexPath;
+            
+            int count =[[self.content_data valueForKey:@"count"] intValue];
+            BOOL delete_last = self.indexPath.row == count - 1 ? YES : NO;
+            
+            [self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
+            NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
+            
+            NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]];
+            
+            [RANetwork request_removeportfolio:ids completionHandler:^(NSMutableDictionary *result) {
+                NSMutableDictionary* cart_json =result;
+                
+                
+                
+                
+                if([[cart_json valueForKey:@"result"] intValue]==2)
+                {
+                    self.deletedRow = delete_last ? -1 : self.indexPath.row;
+                    if (delete_last) {
+                        self.indexPath = [NSIndexPath indexPathForRow:count - 2 inSection:0];
+                    }
+                    [self reload_data];
+                }
+                else
+                {
+                    [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+                }
+                
+                
+            }];
+            
+            
+            
+            self.deleteIndexPath = nil;
+            return;
+            
+            
+        }];
+         UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"NO" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+             
+             self.deleteIndexPath = nil;
+             return;
+             
+         }];
+        
+         [alertController addAction:action_2];
+         [alertController addAction:action_3];
+         
+         
+         [self presentViewController:alertController animated:YES completion:nil];
+        
+        
+        
+        
+//        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Delete confirm", nil) message:NSLocalizedString(@"Are you sure remove model from portfolio?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
+//        alert.tag = ALERT_DEL;
+//        // alert.
+//        [alert show];
         
         
         
@@ -1743,75 +1808,52 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
     
     
 }
-#pragma mark - UIAlertViewDelegate
-// Called when a button is clicked. The view will be automatically dismissed after this call returns
-- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
-{
-    UIApplication * app = [UIApplication sharedApplication];
-    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-    //    if(alertView.tag==1234)
-    //    {
-    //
-    //        // availability warring;
-    //
-    //
-    //        if(buttonIndex!=alertView.cancelButtonIndex)
-    //        {
-    //            if(appDelegate.order_code==nil)
-    //            {
-    //                [self neworder];
-    //            }
-    //            else
-    //            {
-    //                [self addtocart];
-    //            }
-    //        }
-    //        return;
-    //    }
-    //   int count=[self.quantity_text.text intValue];
-    
-    
-    
-    if(alertView.tag==ALERT_DEL)
-    {
-        if(buttonIndex!=alertView.cancelButtonIndex)
-        {
-            self.indexPath = self.deleteIndexPath;
-            
-            int count =[[self.content_data valueForKey:@"count"] intValue];
-            BOOL delete_last = self.indexPath.row == count - 1 ? YES : NO;
-            
-            [self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
-            NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
-            
-            NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]];
-            
-            [RANetwork request_removeportfolio:ids completionHandler:^(NSMutableDictionary *result) {
-                NSMutableDictionary* cart_json =result;
-                
-                    
-                    
-                    
-                    if([[cart_json valueForKey:@"result"] intValue]==2)
-                    {
-                        self.deletedRow = delete_last ? -1 : self.indexPath.row;
-                        if (delete_last) {
-                            self.indexPath = [NSIndexPath indexPathForRow:count - 2 inSection:0];
-                        }
-                        [self reload_data];
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
-                    }
-                    
-                
-            }];
-//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//#pragma mark - UIAlertViewDelegate
+//// Called when a button is clicked. The view will be automatically dismissed after this call returns
+//- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
+//{
+//    UIApplication * app = [UIApplication sharedApplication];
+//    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+//    //    if(alertView.tag==1234)
+//    //    {
+//    //
+//    //        // availability warring;
+//    //
+//    //
+//    //        if(buttonIndex!=alertView.cancelButtonIndex)
+//    //        {
+//    //            if(appDelegate.order_code==nil)
+//    //            {
+//    //                [self neworder];
+//    //            }
+//    //            else
+//    //            {
+//    //                [self addtocart];
+//    //            }
+//    //        }
+//    //        return;
+//    //    }
+//    //   int count=[self.quantity_text.text intValue];
+//
+//
+//
+//    if(alertView.tag==ALERT_DEL)
+//    {
+//        if(buttonIndex!=alertView.cancelButtonIndex)
+//        {
+//            self.indexPath = self.deleteIndexPath;
+//
+//            int count =[[self.content_data valueForKey:@"count"] intValue];
+//            BOOL delete_last = self.indexPath.row == count - 1 ? YES : NO;
 //
-//                NSDictionary* cart_json = [RANetwork portfolio_remove:ids];
+//            [self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
+//            NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
+//
+//            NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]];
+//
+//            [RANetwork request_removeportfolio:ids completionHandler:^(NSMutableDictionary *result) {
+//                NSMutableDictionary* cart_json =result;
 //
-//                dispatch_async(dispatch_get_main_queue(), ^{
 //
 //
 //
@@ -1828,95 +1870,118 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
 //                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
 //                    }
 //
-//                });
-//            });
-            
-        }
-        self.deleteIndexPath = nil;
-        return;
-    }
-    
-    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-    if(buttonIndex==alertView.cancelButtonIndex)
-    {
-        
-        
-        
-    }
-    else if(buttonIndex==1)
-    {
-        //open exist
-        
-        OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
-        ovc.showNavibar = true;
-        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
-            if(appDelegate.order_code==nil)
-            {
-                [self neworder];
-            }
-            else
-            {
-                [self addtocart];
-                [main_vc checklogin:true];
-                
-            }
-            
-        };
-        ovc.init_style = OL_OPEN;
-        ovc.onCancel = ^(){
-            
-            [main_vc checklogin:true];
-            
-        };
-        
-        [self.navigationController pushViewController:ovc animated:true];
-    }
-    else
-    {
-        //create new;
-        
-        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
-        {
-            ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
-            cvc.showNavibar = true;
-            cvc.contact_type = @"Sales_Order_Customer";
-            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-                
-                appDelegate.contact_id=[value valueForKey:@"customer_cid"];
-                appDelegate.customerInfo = value;
-                
-                
-                if(appDelegate.order_code==nil)
-                [self neworder];
-                
-                //   [main_vc checklogin:true];
-                //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-                
-                //
-                //                if(self.returnValue)
-                //                    self.returnValue(value);
-            };
-            
-            cvc.onCancel = ^(){
-                
-                [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
-                
-                
-                
-            };
-            cvc.onReset = ^(){
-                [main_vc checklogin:true];
-            };
-            
-            [self.navigationController pushViewController:cvc animated:true];
-        }
-        else
-        {
-            [self neworder];
-        }
-        
-    }
-}
+//
+//            }];
+////            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+////
+////                NSDictionary* cart_json = [RANetwork portfolio_remove:ids];
+////
+////                dispatch_async(dispatch_get_main_queue(), ^{
+////
+////
+////
+////                    if([[cart_json valueForKey:@"result"] intValue]==2)
+////                    {
+////                        self.deletedRow = delete_last ? -1 : self.indexPath.row;
+////                        if (delete_last) {
+////                            self.indexPath = [NSIndexPath indexPathForRow:count - 2 inSection:0];
+////                        }
+////                        [self reload_data];
+////                    }
+////                    else
+////                    {
+////                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+////                    }
+////
+////                });
+////            });
+//
+//        }
+//        self.deleteIndexPath = nil;
+//        return;
+//    }
+//
+//    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+//    if(buttonIndex==alertView.cancelButtonIndex)
+//    {
+//
+//
+//
+//    }
+//    else if(buttonIndex==1)
+//    {
+//        //open exist
+//
+//        OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+//        ovc.showNavibar = true;
+//        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+//            if(appDelegate.order_code==nil)
+//            {
+//                [self neworder];
+//            }
+//            else
+//            {
+//                [self addtocart];
+//                [main_vc checklogin:true];
+//
+//            }
+//
+//        };
+//        ovc.init_style = OL_OPEN;
+//        ovc.onCancel = ^(){
+//
+//            [main_vc checklogin:true];
+//
+//        };
+//
+//        [self.navigationController pushViewController:ovc animated:true];
+//    }
+//    else
+//    {
+//        //create new;
+//
+//        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+//        {
+//            ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+//            cvc.showNavibar = true;
+//            cvc.contact_type = @"Sales_Order_Customer";
+//            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+//
+//                appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+//                appDelegate.customerInfo = value;
+//
+//
+//                if(appDelegate.order_code==nil)
+//                [self neworder];
+//
+//                //   [main_vc checklogin:true];
+//                //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+//
+//                //
+//                //                if(self.returnValue)
+//                //                    self.returnValue(value);
+//            };
+//
+//            cvc.onCancel = ^(){
+//
+//                [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
+//
+//
+//
+//            };
+//            cvc.onReset = ^(){
+//                [main_vc checklogin:true];
+//            };
+//
+//            [self.navigationController pushViewController:cvc animated:true];
+//        }
+//        else
+//        {
+//            [self neworder];
+//        }
+//
+//    }
+//}
 
 /*
 #pragma mark - Navigation

+ 237 - 237
RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchViewController.m

@@ -821,135 +821,135 @@
     [CartUtils add_to_cart:self selectorholder:self selector:@selector(addtocart)];
     return;
     
-    UIApplication * app = [UIApplication sharedApplication];
-    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-    if(appDelegate.bLogin==false)
-    {
-        
-        LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
-        //        loginvc.delegate = self;
-        //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-        
-        loginvc.returnValue = ^(bool blogin){
-            
-            
-            //            UIApplication * app = [UIApplication sharedApplication];
-            //            AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-            
-            
-            
-            
-            if(blogin)
-            {
-                if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/true)
-                {
-                    
-                    [main_vc checklogin:false];
-                    
-                    if(appDelegate.can_create_order)
-                    {
-                        NSString* msg =@"";
-                        if(appDelegate.contact_id.length>0)
-                        {
-                            msg = [msg stringByAppendingString:@"\n\nCustomer:"];
-                            msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
-                            
-                        }
-                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil),NSLocalizedString(@"Add to new order", nil), nil];
-                    
-                    
-                    
-                    // alert.
-                    [alert show];
-                    }
-                    else
-                    {
-                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil), nil];
-                        
-                        // alert.
-                        [alert show];
-                    }
-                }
-                else
-                {
-                    [main_vc checklogin:false];
-                    [self addtocart];
-                }
-            }
-            
-            //            self.offset = 0;
-            //            [self.content_data removeAllObjects];
-            //            [self loadpage];
-            //
-            //            [[self navigationController] setNavigationBarHidden:YES animated:NO];
-            
-        };
-        
-        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-        
-        
-        
-        
-        
-        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-        
-        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
-        [self presentViewController:navi animated:YES completion:^{
-            
-            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-            
-            DebugLog(@"LoginViewController present.........");
-            
-            //   self.btop = false;
-            //  <#code#>
-        }];
-    }
-    else
-    {
-//        if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE&&/*appDelegate.contact_id==nil&&*/appDelegate.order_code==nil)
-        if(appDelegate.order_code==nil)
-        {
-            [main_vc checklogin:false];
-            
-            if(appDelegate.can_create_order)
-            {
-                NSString* msg =@"";
-                if(appDelegate.contact_id.length>0)
-                {
-                    msg = [msg stringByAppendingString:@"\n\nCustomer:"];
-                    msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
-                    
-                }
-            UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil),NSLocalizedString(@"Add to new order", nil), nil];
-            
-            // alert.
-            [alert show];
-            }
-            else
-            {
-                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil), nil];
-                
-                // alert.
-                [alert show];
-            }
-        }
-        else
-        {
-            
-            if(appDelegate.order_code==nil)
-                [ self neworder];
-            else
-                [self addtocart];
-            
-            
-            
-        }
-    }
-    
-    
-    
-    
+//    UIApplication * app = [UIApplication sharedApplication];
+//    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+//    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+//    if(appDelegate.bLogin==false)
+//    {
+//
+//        LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
+//        //        loginvc.delegate = self;
+//        //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
+//
+//        loginvc.returnValue = ^(bool blogin){
+//
+//
+//            //            UIApplication * app = [UIApplication sharedApplication];
+//            //            AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+//
+//
+//
+//
+//            if(blogin)
+//            {
+//                if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/true)
+//                {
+//
+//                    [main_vc checklogin:false];
+//
+//                    if(appDelegate.can_create_order)
+//                    {
+//                        NSString* msg =@"";
+//                        if(appDelegate.contact_id.length>0)
+//                        {
+//                            msg = [msg stringByAppendingString:@"\n\nCustomer:"];
+//                            msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
+//
+//                        }
+//                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil),NSLocalizedString(@"Add to new order", nil), nil];
+//
+//
+//
+//                    // alert.
+//                    [alert show];
+//                    }
+//                    else
+//                    {
+//                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil), nil];
+//
+//                        // alert.
+//                        [alert show];
+//                    }
+//                }
+//                else
+//                {
+//                    [main_vc checklogin:false];
+//                    [self addtocart];
+//                }
+//            }
+//
+//            //            self.offset = 0;
+//            //            [self.content_data removeAllObjects];
+//            //            [self loadpage];
+//            //
+//            //            [[self navigationController] setNavigationBarHidden:YES animated:NO];
+//
+//        };
+//
+//        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
+//
+//
+//
+//
+//
+//        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
+//
+//        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
+//        [self presentViewController:navi animated:YES completion:^{
+//
+//            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
+//
+//            DebugLog(@"LoginViewController present.........");
+//
+//            //   self.btop = false;
+//            //  <#code#>
+//        }];
+//    }
+//    else
+//    {
+////        if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE&&/*appDelegate.contact_id==nil&&*/appDelegate.order_code==nil)
+//        if(appDelegate.order_code==nil)
+//        {
+//            [main_vc checklogin:false];
+//
+//            if(appDelegate.can_create_order)
+//            {
+//                NSString* msg =@"";
+//                if(appDelegate.contact_id.length>0)
+//                {
+//                    msg = [msg stringByAppendingString:@"\n\nCustomer:"];
+//                    msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
+//
+//                }
+//            UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil),NSLocalizedString(@"Add to new order", nil), nil];
+//
+//            // alert.
+//            [alert show];
+//            }
+//            else
+//            {
+//                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil), nil];
+//
+//                // alert.
+//                [alert show];
+//            }
+//        }
+//        else
+//        {
+//
+//            if(appDelegate.order_code==nil)
+//                [ self neworder];
+//            else
+//                [self addtocart];
+//
+//
+//
+//        }
+//    }
+//
+//
+//
+//
 }
 
 
@@ -2197,114 +2197,114 @@
     
 }
 
-#pragma mark - UIAlertViewDelegate
-// Called when a button is clicked. The view will be automatically dismissed after this call returns
-- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
-{
-    UIApplication * app = [UIApplication sharedApplication];
-    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-    //    if(alertView.tag==1234)
-    //    {
-    //
-    //        // availability warring;
-    //
-    //
-    //        if(buttonIndex!=alertView.cancelButtonIndex)
-    //        {
-    //            if(appDelegate.order_code==nil)
-    //            {
-    //                [self neworder];
-    //            }
-    //            else
-    //            {
-    //                [self addtocart];
-    //            }
-    //        }
-    //        return;
-    //    }
-    //   int count=[self.quantity_text.text intValue];
-    
-    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-    if(buttonIndex==alertView.cancelButtonIndex)
-    {
-        
-        
-        
-    }
-    else if(buttonIndex==1)
-    {
-        //open exist
-        self.disable_refresh = true;
-        OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
-        ovc.showNavibar = true;
-        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
-            if(appDelegate.order_code==nil)
-            {
-                [self neworder];
-            }
-            else
-            {
-                [self addtocart];
-                [main_vc checklogin:true];
-                
-            }
-            
-        };
-        ovc.init_style = OL_OPEN;
-        ovc.onCancel = ^(){
-            self.disable_refresh = false;
-          //  [main_vc checklogin:true];
-            
-        };
-        
-        [self.navigationController pushViewController:ovc animated:true];
-    }
-    else
-    {
-        //create new;
-        self.disable_refresh = true;
-        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
-        {
-            ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
-            cvc.showNavibar = true;
-            cvc.contact_type = @"Sales_Order_Customer";
-            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-                
-                appDelegate.contact_id=[value valueForKey:@"customer_cid"];
-                appDelegate.customerInfo = value;
-                
-                
-                if(appDelegate.order_code==nil)
-                    [self neworder];
-                
-                [main_vc checklogin:true];
-                //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-                
-                //
-                //                if(self.returnValue)
-                //                    self.returnValue(value);
-            };
-            
-            cvc.onCancel = ^(){
-                
-                [RAUtils message_alert:@"Can ot create order without cursomer infomation." title:@"" controller:self];
-                self.disable_refresh = false;
-                
-                
-            };
-            cvc.onReset = ^(){
-                [main_vc checklogin:true];
-            };
-            
-            [self.navigationController pushViewController:cvc animated:true];
-        }
-        else
-        {
-            [self neworder];
-        }
-        
-    }
-}
+//#pragma mark - UIAlertViewDelegate
+//// Called when a button is clicked. The view will be automatically dismissed after this call returns
+//- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
+//{
+//    UIApplication * app = [UIApplication sharedApplication];
+//    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+//    //    if(alertView.tag==1234)
+//    //    {
+//    //
+//    //        // availability warring;
+//    //
+//    //
+//    //        if(buttonIndex!=alertView.cancelButtonIndex)
+//    //        {
+//    //            if(appDelegate.order_code==nil)
+//    //            {
+//    //                [self neworder];
+//    //            }
+//    //            else
+//    //            {
+//    //                [self addtocart];
+//    //            }
+//    //        }
+//    //        return;
+//    //    }
+//    //   int count=[self.quantity_text.text intValue];
+//    
+//    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+//    if(buttonIndex==alertView.cancelButtonIndex)
+//    {
+//        
+//        
+//        
+//    }
+//    else if(buttonIndex==1)
+//    {
+//        //open exist
+//        self.disable_refresh = true;
+//        OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+//        ovc.showNavibar = true;
+//        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+//            if(appDelegate.order_code==nil)
+//            {
+//                [self neworder];
+//            }
+//            else
+//            {
+//                [self addtocart];
+//                [main_vc checklogin:true];
+//                
+//            }
+//            
+//        };
+//        ovc.init_style = OL_OPEN;
+//        ovc.onCancel = ^(){
+//            self.disable_refresh = false;
+//          //  [main_vc checklogin:true];
+//            
+//        };
+//        
+//        [self.navigationController pushViewController:ovc animated:true];
+//    }
+//    else
+//    {
+//        //create new;
+//        self.disable_refresh = true;
+//        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+//        {
+//            ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+//            cvc.showNavibar = true;
+//            cvc.contact_type = @"Sales_Order_Customer";
+//            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+//                
+//                appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+//                appDelegate.customerInfo = value;
+//                
+//                
+//                if(appDelegate.order_code==nil)
+//                    [self neworder];
+//                
+//                [main_vc checklogin:true];
+//                //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+//                
+//                //
+//                //                if(self.returnValue)
+//                //                    self.returnValue(value);
+//            };
+//            
+//            cvc.onCancel = ^(){
+//                
+//                [RAUtils message_alert:@"Can ot create order without cursomer infomation." title:@"" controller:self];
+//                self.disable_refresh = false;
+//                
+//                
+//            };
+//            cvc.onReset = ^(){
+//                [main_vc checklogin:true];
+//            };
+//            
+//            [self.navigationController pushViewController:cvc animated:true];
+//        }
+//        else
+//        {
+//            [self neworder];
+//        }
+//        
+//    }
+//}
 /*
 #pragma mark - Navigation
 

+ 1 - 1
RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.h

@@ -9,7 +9,7 @@
 #import <UIKit/UIKit.h>
 #import "ActiveViewController.h"
 
-@interface SearchViewController : ActiveViewController<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UIScrollViewDelegate,UISearchBarDelegate,UIAlertViewDelegate>
+@interface SearchViewController : ActiveViewController<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UIScrollViewDelegate,UISearchBarDelegate/*,UIAlertViewDelegate*/>
 @property (strong, nonatomic) IBOutlet UICollectionView *collectionview;
 @property (strong, nonatomic) IBOutlet UISearchBar *searchBar;
 @property long offset;

+ 108 - 108
RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m

@@ -2263,114 +2263,114 @@
 
 
 
-#pragma mark - UIAlertViewDelegate
-// Called when a button is clicked. The view will be automatically dismissed after this call returns
-- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
-{
-    UIApplication * app = [UIApplication sharedApplication];
-    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-    //    if(alertView.tag==1234)
-    //    {
-    //
-    //        // availability warring;
-    //
-    //
-    //        if(buttonIndex!=alertView.cancelButtonIndex)
-    //        {
-    //            if(appDelegate.order_code==nil)
-    //            {
-    //                [self neworder];
-    //            }
-    //            else
-    //            {
-    //                [self addtocart];
-    //            }
-    //        }
-    //        return;
-    //    }
-    //   int count=[self.quantity_text.text intValue];
-    
- //   MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-    if(buttonIndex==alertView.cancelButtonIndex)
-    {
-        
-        
-        
-    }
-    else if(buttonIndex==1)
-    {
-        //open exist
-        self.disable_refresh = true;
-        OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
-        ovc.showNavibar = true;
-        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
-            if(appDelegate.order_code==nil)
-            {
-                [self neworder];
-            }
-            else
-            {
-                [self addtocart];
-             //   [main_vc checklogin:true];
-                
-            }
-            
-        };
-        ovc.init_style = OL_OPEN;
-        ovc.onCancel = ^(){
-            self.disable_refresh = false;
-         //   [main_vc checklogin:true];
-            
-        };
-        
-        [self.navigationController pushViewController:ovc animated:true];
-    }
-    else
-    {
-        //create new;
-        self.disable_refresh = true;
-        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
-        {
-            ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
-            cvc.showNavibar = true;
-            cvc.contact_type = @"Sales_Order_Customer";
-            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-                
-                appDelegate.contact_id=[value valueForKey:@"customer_cid"];
-                appDelegate.customerInfo = value;
-                
-                
-                if(appDelegate.order_code==nil)
-                    [self neworder];
-                
-             //   [main_vc checklogin:true];
-                //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-                
-                //
-                //                if(self.returnValue)
-                //                    self.returnValue(value);
-            };
-            
-            cvc.onCancel = ^(){
-                
-                [RAUtils message_alert:@"Can ot create order without cursomer infomation." title:@"" controller:self];
-                
-                self.disable_refresh = false;
-                
-            };
-            cvc.onReset = ^(){
-              //  [main_vc checklogin:true];
-            };
-            
-            [self.navigationController pushViewController:cvc animated:true];
-        }
-        else
-        {
-            [self neworder];
-        }
-        
-    }
-}
+//#pragma mark - UIAlertViewDelegate
+//// Called when a button is clicked. The view will be automatically dismissed after this call returns
+//- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
+//{
+//    UIApplication * app = [UIApplication sharedApplication];
+//    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+//    //    if(alertView.tag==1234)
+//    //    {
+//    //
+//    //        // availability warring;
+//    //
+//    //
+//    //        if(buttonIndex!=alertView.cancelButtonIndex)
+//    //        {
+//    //            if(appDelegate.order_code==nil)
+//    //            {
+//    //                [self neworder];
+//    //            }
+//    //            else
+//    //            {
+//    //                [self addtocart];
+//    //            }
+//    //        }
+//    //        return;
+//    //    }
+//    //   int count=[self.quantity_text.text intValue];
+//    
+// //   MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+//    if(buttonIndex==alertView.cancelButtonIndex)
+//    {
+//        
+//        
+//        
+//    }
+//    else if(buttonIndex==1)
+//    {
+//        //open exist
+//        self.disable_refresh = true;
+//        OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+//        ovc.showNavibar = true;
+//        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+//            if(appDelegate.order_code==nil)
+//            {
+//                [self neworder];
+//            }
+//            else
+//            {
+//                [self addtocart];
+//             //   [main_vc checklogin:true];
+//                
+//            }
+//            
+//        };
+//        ovc.init_style = OL_OPEN;
+//        ovc.onCancel = ^(){
+//            self.disable_refresh = false;
+//         //   [main_vc checklogin:true];
+//            
+//        };
+//        
+//        [self.navigationController pushViewController:ovc animated:true];
+//    }
+//    else
+//    {
+//        //create new;
+//        self.disable_refresh = true;
+//        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+//        {
+//            ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+//            cvc.showNavibar = true;
+//            cvc.contact_type = @"Sales_Order_Customer";
+//            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+//                
+//                appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+//                appDelegate.customerInfo = value;
+//                
+//                
+//                if(appDelegate.order_code==nil)
+//                    [self neworder];
+//                
+//             //   [main_vc checklogin:true];
+//                //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+//                
+//                //
+//                //                if(self.returnValue)
+//                //                    self.returnValue(value);
+//            };
+//            
+//            cvc.onCancel = ^(){
+//                
+//                [RAUtils message_alert:@"Can ot create order without cursomer infomation." title:@"" controller:self];
+//                
+//                self.disable_refresh = false;
+//                
+//            };
+//            cvc.onReset = ^(){
+//              //  [main_vc checklogin:true];
+//            };
+//            
+//            [self.navigationController pushViewController:cvc animated:true];
+//        }
+//        else
+//        {
+//            [self neworder];
+//        }
+//        
+//    }
+//}
 
 #pragma mark - Support scanner
 -(void) onDecodedData:(NSString*) value

+ 4 - 2
RedAnt ERP Mobile/common/Functions/sidemenu/RetrievePassViewController.m

@@ -59,8 +59,10 @@
             if([[json valueForKey:@"result"] intValue]==2)
             {
                 
-        UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Successful!" message:@"Please Check email later." delegate:nil cancelButtonTitle:NSLocalizedString(@"ok", nil) otherButtonTitles:nil, nil];
-             [alert show];
+                [RAUtils message_alert:@"Please Check email later." title:@"Successful!" controller:self];
+                
+//        UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Successful!" message:@"Please Check email later." delegate:nil cancelButtonTitle:NSLocalizedString(@"ok", nil) otherButtonTitles:nil, nil];
+//             [alert show];
                 
             }
             else

+ 5 - 2
RedAnt ERP Mobile/common/Functions/sidemenu/ScannerSettingViewController.m

@@ -8,6 +8,7 @@
 //#define USE_SOFTSCAN 1
 #import "ScannerSettingViewController.h"
 #import "AppDelegate.h"
+#import "RAUtils.h"
 @interface ScannerSettingViewController  ()
 
 @end
@@ -179,8 +180,10 @@
     {
         title=[NSString stringWithFormat:@"%@\n\n%@",title,msg];
     }
-    UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-    [alert show];
+    
+    [RAUtils message_alert:nil title:title controller:self];
+//    UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+//    [alert show];
 }
 - (IBAction)onEmailClicked:(id)sender {
     

+ 202 - 160
RedAnt ERP Mobile/common/Functions/watchlist/WatchListViewController.m

@@ -25,7 +25,7 @@
 #import "RAPDFViewController.h"
 #import "JKMessageBoxController.h"
 
-#define ALERT_DEL 1025
+//#define ALERT_DEL 1025
 //#import "PDFViewController.h"
 @interface WatchListViewController ()
 
@@ -996,12 +996,54 @@
         DebugLog(@"delete click");
         
         
+        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Delete confirm" message:@"Are you sure remove model from wishlist?" preferredStyle:UIAlertControllerStyleAlert];
+         
+         
+ 
+
+         UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                     [self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
+                     NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
+                     
+                     NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]];
+                     
+                     [RANetwork request_remove_wishlist:ids completionHandler:^(NSMutableDictionary *result) {
+                         NSMutableDictionary* cart_json = result;
+                         
+                         
+                         
+                         
+                         if([[cart_json valueForKey:@"result"] intValue]==2)
+                         {
+                             [self reload_data];
+                         }
+                         else
+                         {
+                             [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+                         }
+                         
+                         
+                     }];
+ 
+             
+                     
+                 }];
+         UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"NO" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+             
+             
+             
+         }];
+         [alertController addAction:action_2];
+         [alertController addAction:action_3];
+         
+         
+         [self presentViewController:alertController animated:YES completion:nil];
         
-        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Delete confirm", nil) message:NSLocalizedString(@"Are you sure remove model from wishlist?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
-        alert.tag = ALERT_DEL;
-        // alert.
-        [alert show];
-        
+//        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Delete confirm", nil) message:NSLocalizedString(@"Are you sure remove model from wishlist?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
+//        alert.tag = ALERT_DEL;
+//        // alert.
+//        [alert show];
+//
         
         
         
@@ -1034,166 +1076,166 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
    
     
 }
-#pragma mark - UIAlertViewDelegate
-// Called when a button is clicked. The view will be automatically dismissed after this call returns
-- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
-{
-    UIApplication * app = [UIApplication sharedApplication];
-    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-    //    if(alertView.tag==1234)
-    //    {
-    //
-    //        // availability warring;
-    //
-    //
-    //        if(buttonIndex!=alertView.cancelButtonIndex)
-    //        {
-    //            if(appDelegate.order_code==nil)
-    //            {
-    //                [self neworder];
-    //            }
-    //            else
-    //            {
-    //                [self addtocart];
-    //            }
-    //        }
-    //        return;
-    //    }
-    //   int count=[self.quantity_text.text intValue];
-    
-    
-    
-    if(alertView.tag==ALERT_DEL)
-    {
-        if(buttonIndex!=alertView.cancelButtonIndex)
-        {
-            [self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
-            NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
-            
-            NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]];
-            
-            [RANetwork request_remove_wishlist:ids completionHandler:^(NSMutableDictionary *result) {
-                NSMutableDictionary* cart_json = result;
-                
-                
-                
-                
-                if([[cart_json valueForKey:@"result"] intValue]==2)
-                {
-                    [self reload_data];
-                }
-                else
-                {
-                    [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
-                }
-                
-                
-            }];
-//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//#pragma mark - UIAlertViewDelegate
+//// Called when a button is clicked. The view will be automatically dismissed after this call returns
+//- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
+//{
+//    UIApplication * app = [UIApplication sharedApplication];
+//    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+//    //    if(alertView.tag==1234)
+//    //    {
+//    //
+//    //        // availability warring;
+//    //
+//    //
+//    //        if(buttonIndex!=alertView.cancelButtonIndex)
+//    //        {
+//    //            if(appDelegate.order_code==nil)
+//    //            {
+//    //                [self neworder];
+//    //            }
+//    //            else
+//    //            {
+//    //                [self addtocart];
+//    //            }
+//    //        }
+//    //        return;
+//    //    }
+//    //   int count=[self.quantity_text.text intValue];
+//
+//
+//
+//    if(alertView.tag==ALERT_DEL)
+//    {
+//        if(buttonIndex!=alertView.cancelButtonIndex)
+//        {
+//            [self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
+//            NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
 //
-//                NSDictionary* cart_json = [RANetwork watchlist_remove:ids];
+//            NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]];
 //
-//                dispatch_async(dispatch_get_main_queue(), ^{
+//            [RANetwork request_remove_wishlist:ids completionHandler:^(NSMutableDictionary *result) {
+//                NSMutableDictionary* cart_json = result;
 //
 //
 //
-//                    if([[cart_json valueForKey:@"result"] intValue]==2)
-//                    {
-//                        [self reload_data];
-//                    }
-//                    else
-//                    {
-//                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
-//                    }
 //
-//                });
-//            });
-            
-        }
-        return;
-    }
-    
-    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-    if(buttonIndex==alertView.cancelButtonIndex)
-    {
-        
-        
-        
-    }
-    else if(buttonIndex==1)
-    {
-        //open exist
-        
-        OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
-        ovc.showNavibar = true;
-        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
-            if(appDelegate.order_code==nil)
-            {
-                [self neworder];
-            }
-            else
-            {
-                [self addtocart];
-                [main_vc checklogin:true];
-                
-            }
-            
-        };
-        ovc.init_style = OL_OPEN;
-        ovc.onCancel = ^(){
-            
-            [main_vc checklogin:true];
-            
-        };
-        
-        [self.navigationController pushViewController:ovc animated:true];
-    }
-    else
-    {
-        //create new;
-        
-        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
-        {
-            ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
-            cvc.showNavibar = true;
-            cvc.contact_type = @"Sales_Order_Customer";
-            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-                
-                appDelegate.contact_id=[value valueForKey:@"customer_cid"];
-                appDelegate.customerInfo = value;
-                
-                
-                if(appDelegate.order_code==nil)
-                    [self neworder];
-                
-             //   [main_vc checklogin:true];
-                //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-                
-                //
-                //                if(self.returnValue)
-                //                    self.returnValue(value);
-            };
-            
-            cvc.onCancel = ^(){
-                
-                [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
-                
-                
-                
-            };
-            cvc.onReset = ^(){
-                [main_vc checklogin:true];
-            };
-            
-            [self.navigationController pushViewController:cvc animated:true];
-        }
-        else
-        {
-            [self neworder];
-        }
-        
-    }
-}
+//                if([[cart_json valueForKey:@"result"] intValue]==2)
+//                {
+//                    [self reload_data];
+//                }
+//                else
+//                {
+//                    [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+//                }
+//
+//
+//            }];
+////            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+////
+////                NSDictionary* cart_json = [RANetwork watchlist_remove:ids];
+////
+////                dispatch_async(dispatch_get_main_queue(), ^{
+////
+////
+////
+////                    if([[cart_json valueForKey:@"result"] intValue]==2)
+////                    {
+////                        [self reload_data];
+////                    }
+////                    else
+////                    {
+////                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+////                    }
+////
+////                });
+////            });
+//
+//        }
+//        return;
+//    }
+//
+//    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+//    if(buttonIndex==alertView.cancelButtonIndex)
+//    {
+//
+//
+//
+//    }
+//    else if(buttonIndex==1)
+//    {
+//        //open exist
+//
+//        OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+//        ovc.showNavibar = true;
+//        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+//            if(appDelegate.order_code==nil)
+//            {
+//                [self neworder];
+//            }
+//            else
+//            {
+//                [self addtocart];
+//                [main_vc checklogin:true];
+//
+//            }
+//
+//        };
+//        ovc.init_style = OL_OPEN;
+//        ovc.onCancel = ^(){
+//
+//            [main_vc checklogin:true];
+//
+//        };
+//
+//        [self.navigationController pushViewController:ovc animated:true];
+//    }
+//    else
+//    {
+//        //create new;
+//
+//        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+//        {
+//            ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+//            cvc.showNavibar = true;
+//            cvc.contact_type = @"Sales_Order_Customer";
+//            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+//
+//                appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+//                appDelegate.customerInfo = value;
+//
+//
+//                if(appDelegate.order_code==nil)
+//                    [self neworder];
+//
+//             //   [main_vc checklogin:true];
+//                //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+//
+//                //
+//                //                if(self.returnValue)
+//                //                    self.returnValue(value);
+//            };
+//
+//            cvc.onCancel = ^(){
+//
+//                [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
+//
+//
+//
+//            };
+//            cvc.onReset = ^(){
+//                [main_vc checklogin:true];
+//            };
+//
+//            [self.navigationController pushViewController:cvc animated:true];
+//        }
+//        else
+//        {
+//            [self neworder];
+//        }
+//
+//    }
+//}
 
 #pragma mark - sort button
 

+ 5 - 3
RedAnt ERP Mobile/common/customUI/ImageUploadViewController.m

@@ -209,10 +209,12 @@
     if(self.dirty==false)
     {
         
-        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Upload", nil) message:NSLocalizedString(@"Please set a photo first.", nil) delegate:nil cancelButtonTitle:NSLocalizedString(@"Ok", nil) otherButtonTitles:nil, nil];
+        [RAUtils message_alert:@"Please set a photo first." title:@"Upload" controller:self];
         
-        // alert.
-        [alert show];
+//        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Upload", nil) message:NSLocalizedString(@"Please set a photo first.", nil) delegate:nil cancelButtonTitle:NSLocalizedString(@"Ok", nil) otherButtonTitles:nil, nil];
+//
+//        // alert.
+//        [alert show];
         return;
         
     }

+ 11 - 7
RedAnt ERP Mobile/common/customUI/ImageViewController.m

@@ -7,7 +7,7 @@
 //
 
 #import "ImageViewController.h"
-
+#import "RAUtils.h"
 @interface ImageViewController ()
 
 @end
@@ -52,12 +52,16 @@
     }else{
         msg = @"Image saved" ;
     }
-    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Save Image"
-                                                    message:msg
-                                                   delegate:self
-                                          cancelButtonTitle:@"OK"
-                                          otherButtonTitles:nil];
-    [alert show];
+    
+    
+    [RAUtils message_alert:msg title:@"Save Image" controller:self];
+    
+//    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Save Image"
+//                                                    message:msg
+//                                                   delegate:self
+//                                          cancelButtonTitle:@"OK"
+//                                          otherButtonTitles:nil];
+//    [alert show];
 }
 - (void)onDownloadClick:(UIButton *)sender {
     

+ 12 - 12
RedAnt ERP Mobile/common/customUI/PulldownMenu.m

@@ -207,20 +207,20 @@
                           delay: 0.0
                         options: UIViewAnimationOptionCurveEaseOut
                      animations:^{
-                         if (fullyOpen)
+        if (self->fullyOpen)
                          {
                              
-                             self.center = CGPointMake(self.frame.size.width / 2, -((self.frame.size.height / 2) + topMargin));
-                             fullyOpen = NO;
+                             self.center = CGPointMake(self.frame.size.width / 2, -((self.frame.size.height / 2) + self->topMargin));
+                             self->fullyOpen = NO;
                          }
                          else
                          {
-                             self.center = CGPointMake(self.frame.size.width / 2, ((self.frame.size.height / 2) + topMargin));
-                             fullyOpen = YES;
+                             self.center = CGPointMake(self.frame.size.width / 2, ((self.frame.size.height / 2) + self->topMargin));
+                             self->fullyOpen = YES;
                          }
                      }
                      completion:^(BOOL finished){
-                         [delegate pullDownAnimated:fullyOpen];
+        [self->delegate pullDownAnimated:self->fullyOpen];
                      }];
 }
 
@@ -231,20 +231,20 @@
                           delay: 0.0
                         options: UIViewAnimationOptionCurveEaseOut
                      animations:^{
-                         if (fullyOpen)
+        if (self->fullyOpen)
                          {
                              
-                             self.center = CGPointMake(self.frame.size.width / 2+position.x, -((self.frame.size.height / 2)+position.y + topMargin));
-                             fullyOpen = NO;
+                             self.center = CGPointMake(self.frame.size.width / 2+position.x, -((self.frame.size.height / 2)+position.y + self->topMargin));
+                             self->fullyOpen = NO;
                          }
                          else
                          {
-                             self.center = CGPointMake(self.frame.size.width / 2+position.x, ((self.frame.size.height / 2)+position.y + topMargin));
-                             fullyOpen = YES;
+                             self.center = CGPointMake(self.frame.size.width / 2+position.x, ((self.frame.size.height / 2)+position.y + self->topMargin));
+                             self->fullyOpen = YES;
                          }
                      }
                      completion:^(BOOL finished){
-                         [delegate pullDownAnimated:fullyOpen];
+        [self->delegate pullDownAnimated:self->fullyOpen];
                      }];
 }