ソースを参照

修复ERP Mobile 工程的部分警告错误

Ray Zhang 6 年 前
コミット
a2cd36da87
20 ファイル変更1238 行追加942 行削除
  1. 1 1
      RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.h
  2. 2 2
      RedAnt ERP Mobile/common/CommonEditor/EnumSelectViewController.m
  3. 248 146
      RedAnt ERP Mobile/common/Functions/cart/CartViewController.m
  4. 4 4
      RedAnt ERP Mobile/common/Functions/cart/EditModelPriceViewController.m
  5. 1 1
      RedAnt ERP Mobile/common/Functions/category/CategoryViewController.h
  6. 219 219
      RedAnt ERP Mobile/common/Functions/category/CategoryViewController.m
  7. 1 1
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.h
  8. 311 309
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.m
  9. 5 2
      RedAnt ERP Mobile/common/Functions/offline/OfflineSettingViewController.m
  10. 7 3
      RedAnt ERP Mobile/common/Functions/offline/OfflineUnlockViewController.m
  11. 272 138
      RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m
  12. 1 1
      RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.h
  13. 38 14
      RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m
  14. 2 1
      RedAnt ERP Mobile/common/Functions/order/RAOrderEditorViewController.m
  15. 2 1
      RedAnt ERP Mobile/common/Functions/order/RAOrderPreviewController.m
  16. 6 4
      RedAnt ERP Mobile/common/Functions/portfolio/PortfolioEditQTYViewController.m
  17. 4 1
      RedAnt ERP Mobile/common/Functions/portfolio/PortfolioViewController.m
  18. 2 1
      RedAnt ERP Mobile/common/Functions/portfolio/TearSheetParamViewController.m
  19. 2 2
      RedAnt ERP Mobile/common/RAUtils.h
  20. 110 91
      RedAnt ERP Mobile/common/RAUtils.m

+ 1 - 1
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.h

@@ -26,7 +26,7 @@
 
 @end
 
-@interface CommonEditorViewController : UIViewController<AutoCompleteDataSource,UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate,MonthPickerViewControllerDelegate/*,SignatureViewControllerDelegate*/,EnumSelectViewControllerDelegate,CommonEditorViewControllerDelegate,UITextViewDelegate,UIAlertViewDelegate>
+@interface CommonEditorViewController : UIViewController<AutoCompleteDataSource,UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate,MonthPickerViewControllerDelegate/*,SignatureViewControllerDelegate*/,EnumSelectViewControllerDelegate,CommonEditorViewControllerDelegate,UITextViewDelegate/*,UIAlertViewDelegate*/>
 @property (strong,nonatomic) NSMutableDictionary* content_data_download;
 @property (strong,nonatomic) NSMutableDictionary* changed_data;
 

+ 2 - 2
RedAnt ERP Mobile/common/CommonEditor/EnumSelectViewController.m

@@ -559,8 +559,8 @@
 //                //        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error!" message:@"User&Password can not be empty!" delegate:nil cancelButtonTitle:NSLocalizedString(@"ok", nil) , nil];
 //                [alert show];
                 
-                
-                [RAUtils alert_view:[NSString stringWithFormat:@"%d items at most for this field.",self.max_select ] title:@"Max count reached"];
+                [RAUtils message_alert:[NSString stringWithFormat:@"%d items at most for this field.",self.max_select ] title:@"Max count reached" controller:self];
+//                [RAUtils alert_view:[NSString stringWithFormat:@"%d items at most for this field.",self.max_select ] title:@"Max count reached"];
                 
                 return;
             }

+ 248 - 146
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -34,9 +34,9 @@
 #endif
 
 //#define ALERT_FREE 1024
-#define ALERT_DEL 1025
+//#define ALERT_DEL 1025
 //#define ALERT_SET_FREE 1026
-#define ALERT_RESTORE_FREE 1027
+//#define ALERT_RESTORE_FREE 1027
 
 @interface CartViewController ()
 {
@@ -2331,10 +2331,112 @@
         
          //[self.itemListTable setEditing:false animated:YES];
         
-        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Delete confirm", nil) message:NSLocalizedString(@"Are you sure remove model from cart?", 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 cart?" preferredStyle:UIAlertControllerStyleAlert];
+         
+         
+      
+
+         UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            
+             // [self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
+             NSMutableDictionary * item_json = nil;
+             if (self.back_order_flag) {
+                 item_json = [[self itemJsonAtIndexPath:self.indexPath] mutableCopy];
+             } else {
+                 item_json = [self.content_arr[self.indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
+                 
+             }
+             
+             NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"cart_item_id"] intValue]];
+             [RANetwork request_remove_cart:ids completionHandler:^(NSMutableDictionary *result) {
+                 NSMutableDictionary* cart_json = result;
+                 
+                 
+                 
+                 
+                 if([[cart_json valueForKey:@"result"] intValue]==2)
+                 {
+                     //  AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                     if (self.back_order_flag) {
+                         
+                         NSInteger section_count = [self sectionCount];
+                         for (int i = 0; i < section_count; i++) {
+                             NSInteger item_count = [self itemCountInSection:i];
+                             BOOL ready_break = NO;
+                             
+                             for (int j = 0; j < item_count; j++) {
+                                 NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
+                                 NSDictionary* obj_json = [self itemJsonAtIndexPath:indexPath];
+                                 NSString* _id =[obj_json valueForKey:@"cart_item_id"];
+                                 if([_id isEqualToString:ids])
+                                 {
+                                     [self updateItemJson:nil atIndexPath:indexPath];
+                                     ready_break = YES;
+                                     break;
+                                 }
+                             }
+                             
+                             if (ready_break) {
+                                 break;
+                             }
+                         }
+                         
+                     } else {
+                         for(int i=0;i<self.content_arr.count;i++)
+                         {
+                             NSDictionary* obj_json = self.content_arr[i];
+                             NSString* _id =[obj_json valueForKey:@"cart_item_id"];
+                             if([_id isEqualToString:ids])
+                             {
+                                 [self.content_arr removeObjectAtIndex:i];
+                                 //  [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:self.indexPath] withRowAnimation:UITableViewRowAnimationLeft];
+                                 break;
+                                 // appDelegate.cart_count--;
+                                 // [appDelegate update_count_mark];
+                             }
+                             
+                         }
+                     }
+                     [self.itemListTable reloadData];
+                     [self refresh_total];
+#ifdef RA_NOTIFICATION
+                     [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                     [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+#endif
+                     //                        [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 cart?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
+//        alert.tag = ALERT_DEL;
+//        // alert.
+//        [alert show];
         
         
         
@@ -3090,165 +3192,165 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
     //    [tableView reloadData];
     
 }
-#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==ALERT_DEL)
-    {
-        if(buttonIndex!=alertView.cancelButtonIndex)
-        {
-           // [self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
-            NSMutableDictionary * item_json = nil;
-            if (self.back_order_flag) {
-                item_json = [[self itemJsonAtIndexPath:self.indexPath] mutableCopy];
-            } else {
-                item_json = [self.content_arr[self.indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
-                
-            }
-            
-            NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"cart_item_id"] intValue]];
-            [RANetwork request_remove_cart:ids completionHandler:^(NSMutableDictionary *result) {
-                NSMutableDictionary* cart_json = result;
-                
-                
-                
-                
-                if([[cart_json valueForKey:@"result"] intValue]==2)
-                {
-                    //  AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    if (self.back_order_flag) {
-                        
-                        NSInteger section_count = [self sectionCount];
-                        for (int i = 0; i < section_count; i++) {
-                            NSInteger item_count = [self itemCountInSection:i];
-                            BOOL ready_break = NO;
-                            
-                            for (int j = 0; j < item_count; j++) {
-                                NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
-                                NSDictionary* obj_json = [self itemJsonAtIndexPath:indexPath];
-                                NSString* _id =[obj_json valueForKey:@"cart_item_id"];
-                                if([_id isEqualToString:ids])
-                                {
-                                    [self updateItemJson:nil atIndexPath:indexPath];
-                                    ready_break = YES;
-                                    break;
-                                }
-                            }
-                            
-                            if (ready_break) {
-                                break;
-                            }
-                        }
-                        
-                    } else {
-                        for(int i=0;i<self.content_arr.count;i++)
-                        {
-                            NSDictionary* obj_json = self.content_arr[i];
-                            NSString* _id =[obj_json valueForKey:@"cart_item_id"];
-                            if([_id isEqualToString:ids])
-                            {
-                                [self.content_arr removeObjectAtIndex:i];
-                                //  [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:self.indexPath] withRowAnimation:UITableViewRowAnimationLeft];
-                                break;
-                                // appDelegate.cart_count--;
-                                // [appDelegate update_count_mark];
-                            }
-                            
-                        }
-                    }
-                    [self.itemListTable reloadData];
-                    [self refresh_total];
-#ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-#else
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-#endif
-                    //                        [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
+//{
 //
-//                NSDictionary* cart_json = [RANetwork cart_remove:ids];
+//    if(alertView.tag==ALERT_DEL)
+//    {
+//        if(buttonIndex!=alertView.cancelButtonIndex)
+//        {
+//           // [self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
+//            NSMutableDictionary * item_json = nil;
+//            if (self.back_order_flag) {
+//                item_json = [[self itemJsonAtIndexPath:self.indexPath] mutableCopy];
+//            } else {
+//                item_json = [self.content_arr[self.indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
 //
-//                dispatch_async(dispatch_get_main_queue(), ^{
+//            }
 //
+//            NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"cart_item_id"] intValue]];
+//            [RANetwork request_remove_cart:ids completionHandler:^(NSMutableDictionary *result) {
+//                NSMutableDictionary* cart_json = result;
 //
 //
-//                    if([[cart_json valueForKey:@"result"] intValue]==2)
-//                    {
-//                        //  AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//                        if (self.back_order_flag) {
-//
-//                            NSInteger section_count = [self sectionCount];
-//                            for (int i = 0; i < section_count; i++) {
-//                                NSInteger item_count = [self itemCountInSection:i];
-//                                BOOL ready_break = NO;
-//
-//                                for (int j = 0; j < item_count; j++) {
-//                                    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
-//                                    NSDictionary* obj_json = [self itemJsonAtIndexPath:indexPath];
-//                                    NSString* _id =[obj_json valueForKey:@"cart_item_id"];
-//                                    if([_id isEqualToString:ids])
-//                                    {
-//                                        [self updateItemJson:nil atIndexPath:indexPath];
-//                                        ready_break = YES;
-//                                        break;
-//                                    }
-//                                }
 //
-//                                if (ready_break) {
-//                                    break;
-//                                }
-//                            }
 //
-//                        } else {
-//                            for(int i=0;i<self.content_arr.count;i++)
-//                            {
-//                                NSDictionary* obj_json = self.content_arr[i];
+//                if([[cart_json valueForKey:@"result"] intValue]==2)
+//                {
+//                    //  AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    if (self.back_order_flag) {
+//
+//                        NSInteger section_count = [self sectionCount];
+//                        for (int i = 0; i < section_count; i++) {
+//                            NSInteger item_count = [self itemCountInSection:i];
+//                            BOOL ready_break = NO;
+//
+//                            for (int j = 0; j < item_count; j++) {
+//                                NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
+//                                NSDictionary* obj_json = [self itemJsonAtIndexPath:indexPath];
 //                                NSString* _id =[obj_json valueForKey:@"cart_item_id"];
 //                                if([_id isEqualToString:ids])
 //                                {
-//                                    [self.content_arr removeObjectAtIndex:i];
-//                                    //  [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:self.indexPath] withRowAnimation:UITableViewRowAnimationLeft];
+//                                    [self updateItemJson:nil atIndexPath:indexPath];
+//                                    ready_break = YES;
 //                                    break;
-//                                    // appDelegate.cart_count--;
-//                                    // [appDelegate update_count_mark];
 //                                }
+//                            }
 //
+//                            if (ready_break) {
+//                                break;
 //                            }
 //                        }
-//                        [self.itemListTable reloadData];
-//                        [self refresh_total];
+//
+//                    } else {
+//                        for(int i=0;i<self.content_arr.count;i++)
+//                        {
+//                            NSDictionary* obj_json = self.content_arr[i];
+//                            NSString* _id =[obj_json valueForKey:@"cart_item_id"];
+//                            if([_id isEqualToString:ids])
+//                            {
+//                                [self.content_arr removeObjectAtIndex:i];
+//                                //  [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:self.indexPath] withRowAnimation:UITableViewRowAnimationLeft];
+//                                break;
+//                                // appDelegate.cart_count--;
+//                                // [appDelegate update_count_mark];
+//                            }
+//
+//                        }
+//                    }
+//                    [self.itemListTable reloadData];
+//                    [self refresh_total];
 //#ifdef RA_NOTIFICATION
-//                        [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//                    [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 //#else
-//                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 //#endif
-//                        //                        [self reload_data];
-//                    }
-//                    else
-//                    {
-//                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
-//                    }
+//                    //                        [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 cart_remove:ids];
+////
+////                dispatch_async(dispatch_get_main_queue(), ^{
+////
+////
+////
+////                    if([[cart_json valueForKey:@"result"] intValue]==2)
+////                    {
+////                        //  AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+////                        if (self.back_order_flag) {
+////
+////                            NSInteger section_count = [self sectionCount];
+////                            for (int i = 0; i < section_count; i++) {
+////                                NSInteger item_count = [self itemCountInSection:i];
+////                                BOOL ready_break = NO;
+////
+////                                for (int j = 0; j < item_count; j++) {
+////                                    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
+////                                    NSDictionary* obj_json = [self itemJsonAtIndexPath:indexPath];
+////                                    NSString* _id =[obj_json valueForKey:@"cart_item_id"];
+////                                    if([_id isEqualToString:ids])
+////                                    {
+////                                        [self updateItemJson:nil atIndexPath:indexPath];
+////                                        ready_break = YES;
+////                                        break;
+////                                    }
+////                                }
+////
+////                                if (ready_break) {
+////                                    break;
+////                                }
+////                            }
+////
+////                        } else {
+////                            for(int i=0;i<self.content_arr.count;i++)
+////                            {
+////                                NSDictionary* obj_json = self.content_arr[i];
+////                                NSString* _id =[obj_json valueForKey:@"cart_item_id"];
+////                                if([_id isEqualToString:ids])
+////                                {
+////                                    [self.content_arr removeObjectAtIndex:i];
+////                                    //  [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:self.indexPath] withRowAnimation:UITableViewRowAnimationLeft];
+////                                    break;
+////                                    // appDelegate.cart_count--;
+////                                    // [appDelegate update_count_mark];
+////                                }
+////
+////                            }
+////                        }
+////                        [self.itemListTable reloadData];
+////                        [self refresh_total];
+////#ifdef RA_NOTIFICATION
+////                        [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+////#else
+////                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+////                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+////#endif
+////                        //                        [self reload_data];
+////                    }
+////                    else
+////                    {
+////                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+////                    }
+////
+////                });
+////            });
+//
+//        }
+//    }
+//
+//}
 
 #pragma mark - Support scanner
 -(void) onDecodedData:(NSString*) value

+ 4 - 4
RedAnt ERP Mobile/common/Functions/cart/EditModelPriceViewController.m

@@ -70,8 +70,8 @@
 //
 //        
 //        [alert show];
-        
-        [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
+        [RAUtils message_alert:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing." controller:self];
+//        [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
         
         self.editDiscount.text=@"0";
         
@@ -220,8 +220,8 @@
 //            [alert show];
             
             
-            
-            [RAUtils alert_view:@"Discount must less than 100." title:@"Input Error."];
+            [RAUtils message_alert:@"Discount must less than 100." title:@"Input Error." controller:self];
+//            [RAUtils alert_view:@"Discount must less than 100." title:@"Input Error."];
             textField.text=@"0";
         }
     }

+ 1 - 1
RedAnt ERP Mobile/common/Functions/category/CategoryViewController.h

@@ -18,7 +18,7 @@
 typedef void (^add_to_cart_Handler)(void);
 
 
-@interface CategoryViewController : ActiveViewController<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout/*,UITableViewDataSource,UITableViewDelegate*/,UIScrollViewDelegate,/*SearchFilterDelegate,*/CategoryMenuDelegate,UIAlertViewDelegate>
+@interface CategoryViewController : ActiveViewController<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout/*,UITableViewDataSource,UITableViewDelegate*/,UIScrollViewDelegate,/*SearchFilterDelegate,*/CategoryMenuDelegate/*,UIAlertViewDelegate*/>
 //@property (strong, nonatomic) IBOutlet UIView *headerView;
 
 @property (strong,nonatomic) NSString* modelname;

+ 219 - 219
RedAnt ERP Mobile/common/Functions/category/CategoryViewController.m

@@ -416,132 +416,132 @@
     [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 = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-        [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(@"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 = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
+//        [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(@"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];
+//
+//
+//
+//        }
+//    }
+//
+//
+//
+//
 }
 
 
@@ -2537,99 +2537,99 @@
 }
 
 
-#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
-        
-        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:@"Cannot create order without cursomer infomation." title:@"New Order Error" 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];
+//    
+// //   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:@"Cannot create order without cursomer infomation." title:@"New Order Error" 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
 {

+ 1 - 1
RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.h

@@ -28,7 +28,7 @@
 @end
 
 
-@interface DetailHeaderCell : UITableViewCell<PhotoStackViewDataSource, PhotoStackViewDelegate,UIAlertViewDelegate,UITextFieldDelegate>
+@interface DetailHeaderCell : UITableViewCell<PhotoStackViewDataSource, PhotoStackViewDelegate,UITextFieldDelegate>
 {
 @private
     //    id <MDSpreadViewDataSource>__unsafe_unretained _dataSource;

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

@@ -459,188 +459,190 @@
     UIViewController *vc= [RAUtils getViewController:self];
     [CartUtils add_to_cart:vc selectorholder:self selector:@selector(addtocart)];
     return;
-    
-    
-    int count=[self.quantity_text.text intValue];
-    
-    UIApplication * app = [UIApplication sharedApplication];
-    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-    if(appDelegate.bLogin==false)
-    {
-        UIViewController *vc= [RAUtils getViewController:self];
-        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)
-                {
-                    if(self.set_update_data)
-                        self.set_update_data(true);
-                    [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];
-                    
-                    int c=[self.count_Label.text intValue];
-                    DebugLog(@"count label : %@ , convert:%d", self.count_Label.text ,c);
-                    
-                    NSString* ct=[self.count_Label.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
-                    
-                    
-                    
-                    if(!appDelegate.can_create_backorder && c<count)
-                    {
-                        
-                        NSString *msg = [NSString stringWithFormat:@"Item is OUT OF STOCK and not available to order from %@.\nAdd to cart anyway?",COMPANY_SHORT_NAME];
-                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Availability %@",ct ] message:NSLocalizedString(msg, nil) delegate:self cancelButtonTitle:NSLocalizedString(@"No", nil) otherButtonTitles:NSLocalizedString(@"Yes", nil), nil];
-                        
-                        // alert.
-                        
-                        alert.tag = 1234;
-                        [alert show];
-                    }
-                    else
-                    {
-                        if(appDelegate.order_code==nil)
-                            [ self neworder];
-                        else
-                            [self addtocart:count];
-                    }
-                    
-                    
-                }
-            }
-            
-            //            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;//有三种状态,自己看看是哪种
-        [vc 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(@"Do you want to add to a pending order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil), nil];
-                
-                // alert.
-                [alert show];
-            }
-        }
-        else
-        {
-            
-//            if ([self.priceLabel.text isEqualToString:@"No Price."])
+//
+//
+//    int count=[self.quantity_text.text intValue];
+//
+//    UIApplication * app = [UIApplication sharedApplication];
+//    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+//    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+//    if(appDelegate.bLogin==false)
+//    {
+//        UIViewController *vc= [RAUtils getViewController:self];
+//        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)
 //            {
-////                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Model No Price" message:@"Cannot add model without price." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-////
-////                
-////                
-////                [alert show];
-//                
-//                
-//                
-//                [RAUtils alert_view:@"Cannot add model without price." title:@"Model No Price."];
+//                if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/ true)
+//                {
+//                    if(self.set_update_data)
+//                        self.set_update_data(true);
+//                    [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];
+//
+//                    int c=[self.count_Label.text intValue];
+//                    DebugLog(@"count label : %@ , convert:%d", self.count_Label.text ,c);
+//
+//                    NSString* ct=[self.count_Label.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
+//
+//
+//
+//                    if(!appDelegate.can_create_backorder && c<count)
+//                    {
+//
+//                        NSString *msg = [NSString stringWithFormat:@"Item is OUT OF STOCK and not available to order from %@.\nAdd to cart anyway?",COMPANY_SHORT_NAME];
+//                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Availability %@",ct ] message:NSLocalizedString(msg, nil) delegate:self cancelButtonTitle:NSLocalizedString(@"No", nil) otherButtonTitles:NSLocalizedString(@"Yes", nil), nil];
+//
+//                        // alert.
+//
+//                        alert.tag = 1234;
+//                        [alert show];
+//                    }
+//                    else
+//                    {
+//                        if(appDelegate.order_code==nil)
+//                            [ self neworder];
+//                        else
+//                            [self addtocart:count];
+//                    }
+//
+//
+//                }
+//            }
+//
+//            //            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;//有三种状态,自己看看是哪种
+//        [vc 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
-            {
-                
-                int c=[self.count_Label.text intValue];
-                DebugLog(@"count label : %@ , convert:%d", self.count_Label.text ,c);
-                
-                NSString* ct=[self.count_Label.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
-                
-                
-                
-                if(c<count)
-                {
-                    
-                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Availability %@",ct ] message:NSLocalizedString(@"Confirm add to cart. ", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Confirm", nil), nil];
-                    
-                    // alert.
-                    
-                    alert.tag = 1234;
-                    [alert show];
-                }
-                else
-                {
-                    if(appDelegate.order_code==nil)
-                        [ self neworder];
-                    else
-                        [self addtocart:count];
-                }
-            }
-            
-        }
-    }
-    
-    
-    
-    
-    
-    
-    
-    
+//            {
+//                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"Do you want to add to a pending order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Add to pending order", nil), nil];
+//
+//                // alert.
+//                [alert show];
+//            }
+//        }
+//        else
+//        {
+//
+////            if ([self.priceLabel.text isEqualToString:@"No Price."])
+////            {
+//////                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Model No Price" message:@"Cannot add model without price." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+//////
+//////
+//////
+//////                [alert show];
+////
+////
+////
+////                [RAUtils alert_view:@"Cannot add model without price." title:@"Model No Price."];
+////            }
+////            else
+//            {
+//
+//                int c=[self.count_Label.text intValue];
+//                DebugLog(@"count label : %@ , convert:%d", self.count_Label.text ,c);
+//
+//                NSString* ct=[self.count_Label.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
+//
+//
+//
+//                if(c<count)
+//                {
+//
+//                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Availability %@",ct ] message:NSLocalizedString(@"Confirm add to cart. ", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Confirm", nil), nil];
+//
+//                    // alert.
+//
+//                    alert.tag = 1234;
+//                    [alert show];
+//                }
+//                else
+//                {
+//                    if(appDelegate.order_code==nil)
+//                        [ self neworder];
+//                    else
+//                        [self addtocart:count];
+//                }
+//            }
+//
+//        }
+//    }
+//
+//
+//
+//
+//
+//
+//
+//
 }
 -(void) addtocart
 {
@@ -1482,136 +1484,136 @@
 //        });
 //    });
 }
-#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)//库存小于0
-    {
-        
-        // availability warring;
-        
-        int count=[self.quantity_text.text intValue];
-        if(buttonIndex!=alertView.cancelButtonIndex)
-        {
-            if(appDelegate.order_code==nil)
-            {
-                [self neworder];
-            }
-            else
-            {
-                [self addtocart:count];
-            }
-        }
-        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
-        UIViewController *vc= [RAUtils getViewController:self];
-        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
-            {
-                if(self.set_update_data)
-                    self.set_update_data(true);
-                
-                int model_count = [[order_detail valueForKey:@"model_count"] intValue];
-                for(int i=0;i<model_count;i++)
-                {
-                    NSDictionary* item = [order_detail objectForKey:[NSString stringWithFormat:@"item_%d",i]];
-                    NSString* product_id = [item valueForKey:@"product_id"];
-                    if([product_id isEqualToString:self.product_id])
-                    {
-                        self.cqty = [[item valueForKey:@"QTY"]intValue];
-                        if(self.set_cqty)
-                            self.set_cqty(self.cqty);
-                        break;
-                    }
-                    
-                }
-                int count=[self.quantity_text.text intValue];
-                [self addtocart:count];
-                [main_vc checklogin:true];
-                
-                
-            }
-            
-        };
-        ovc.init_style = OL_OPEN;
-        ovc.onCancel = ^(){
-            
-            [main_vc checklogin:true];
-            
-        };
-        
-        [vc.navigationController pushViewController:ovc animated:true];
-    }
-    else
-    {
-        //create new;
-        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
-        {
-            UIViewController *vc= [RAUtils getViewController:self];
-            
-
-            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];
-            };
-            
-            [vc.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)//库存小于0
+//    {
+//
+//        // availability warring;
+//
+//        int count=[self.quantity_text.text intValue];
+//        if(buttonIndex!=alertView.cancelButtonIndex)
+//        {
+//            if(appDelegate.order_code==nil)
+//            {
+//                [self neworder];
+//            }
+//            else
+//            {
+//                [self addtocart:count];
+//            }
+//        }
+//        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
+//        UIViewController *vc= [RAUtils getViewController:self];
+//        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
+//            {
+//                if(self.set_update_data)
+//                    self.set_update_data(true);
+//
+//                int model_count = [[order_detail valueForKey:@"model_count"] intValue];
+//                for(int i=0;i<model_count;i++)
+//                {
+//                    NSDictionary* item = [order_detail objectForKey:[NSString stringWithFormat:@"item_%d",i]];
+//                    NSString* product_id = [item valueForKey:@"product_id"];
+//                    if([product_id isEqualToString:self.product_id])
+//                    {
+//                        self.cqty = [[item valueForKey:@"QTY"]intValue];
+//                        if(self.set_cqty)
+//                            self.set_cqty(self.cqty);
+//                        break;
+//                    }
+//
+//                }
+//                int count=[self.quantity_text.text intValue];
+//                [self addtocart:count];
+//                [main_vc checklogin:true];
+//
+//
+//            }
+//
+//        };
+//        ovc.init_style = OL_OPEN;
+//        ovc.onCancel = ^(){
+//
+//            [main_vc checklogin:true];
+//
+//        };
+//
+//        [vc.navigationController pushViewController:ovc animated:true];
+//    }
+//    else
+//    {
+//        //create new;
+//        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+//        {
+//            UIViewController *vc= [RAUtils getViewController:self];
+//
+//
+//            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];
+//            };
+//
+//            [vc.navigationController pushViewController:cvc animated:true];
+//        }
+//        else
+//        {
+//            [self neworder];
+//        }
+//
+//
+//    }
+//}
 
 - (void)valueChanged:(UIStepper *)sender {
     

+ 5 - 2
RedAnt ERP Mobile/common/Functions/offline/OfflineSettingViewController.m

@@ -277,7 +277,8 @@
             }
             else
             {
-                [RAUtils alert_view:@"Must login" title:@"Data sync"];
+                [RAUtils message_alert:@"Must login" title:@"Data sync" controller:self];
+//                [RAUtils alert_view:@"Must login" title:@"Data sync"];
             }
             
             
@@ -326,7 +327,9 @@
         {
             if(!self.bunlock)
             {
-            [RAUtils alert_view:@"Current login account is different from the offline account, to continue with sync, all current offline data will be erased, you must unlock offline lock first. " title:@"Sync denied."];
+                
+                [RAUtils message_alert:@"Current login account is different from the offline account, to continue with sync, all current offline data will be erased, you must unlock offline lock first. "  title:@"Sync denied." controller:self];
+//            [RAUtils alert_view:@"Current login account is different from the offline account, to continue with sync, all current offline data will be erased, you must unlock offline lock first. " title:@"Sync denied."];
             return;
             }
             else

+ 7 - 3
RedAnt ERP Mobile/common/Functions/offline/OfflineUnlockViewController.m

@@ -44,8 +44,8 @@
         //        //[[UILabel appearanceWhenContainedIn:UIAlertView.class, nil] setAppearanceFont:[UIFont boldSystemFontOfSize:10]];
         //        [alert show];
         
-        
-        [RAUtils alert_view:@"Username or Password cannot be blank." title:@"Unlock offline"];
+        [RAUtils message_alert:@"Username or Password cannot be blank." title:@"Unlock offline" controller:self];
+//        [RAUtils alert_view:@"Username or Password cannot be blank." title:@"Unlock offline"];
         return;
     }
     
@@ -62,7 +62,11 @@
 
         }];
     else
-        [RAUtils alert_view:MSG_USERAUTH_ERROR title:@"Unlock offline"];
+    {
+        [RAUtils message_alert:MSG_USERAUTH_ERROR title:@"Unlock offline" controller:self];
+        //        [RAUtils alert_view:MSG_USERAUTH_ERROR title:@"Unlock offline"];
+    }
+
     
 }
 - (IBAction)CloseClick:(id)sender {

+ 272 - 138
RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m

@@ -1707,23 +1707,151 @@
 //        
 //    }
 
-    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:NSLocalizedString(@"Switch to cart", nil),@"Switch to order history",NSLocalizedString(@"Close and cancel order", nil), nil];
+//    UIAlertView * alert = nil;
+    
+    
+         
+       
+        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Close" message:@"Choose your action" preferredStyle:UIAlertControllerStyleAlert];
         
-    }
-    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];
         
-    }
+        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];
+            
+
+            [((MainViewController*)appDelegate.main_vc) switchToOrder];
+            
+        }];
+        NSString * a2Title=nil;
+        if(appDelegate.order_status==0)
+            a2Title=@"Close and cancel order";
+        else
+            a2Title=@"Close and release order";
+        UIAlertAction *action_2 = [UIAlertAction actionWithTitle:a2Title style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            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,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                        [((MainViewController*)appDelegate.main_vc) reloadOrder: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];
+                        //                        [self.navigationController dismissViewControllerAnimated:true completion:^{
+                        //                            ;
+                        //                        }];
+                        
+                    }
+                    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
+//    {
+//
+//        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Close" message:@"Choose your action" preferredStyle:UIAlertControllerStyleAlert];
+//
+//
+//        UIAlertAction *action_0 = [UIAlertAction actionWithTitle:@"Switch to cart" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+//
+//
+//
+//        }];
+//
+//        UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Switch to order history" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+//
+//
+//
+//        }];
+//        UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Close and release order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+//
+//
+//
+//        }];
+//        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 release order", nil), nil];
+//
+//    }
     
 
     
-    alert.tag = CLOSE_ACTION;
-    // alert.
-    [alert show];
+//    alert.tag = CLOSE_ACTION;
+//    // alert.
+//    [alert show];
     
     
     //    if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
@@ -1961,109 +2089,109 @@
  // 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)
-        {
-            
-            [self.navigationController popViewControllerAnimated:true];
-            // back to cart;
-            //            [self.navigationController dismissViewControllerAnimated:true completion:^{
-            //                ;
-            //            }];
-            //    if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
-            //        appDelegate.order_code = nil;
-            //
-            //    }
-        }
-        if(buttonIndex==2)
-        {
-            
-            [self.navigationController popViewControllerAnimated:false];
-            
-            
-
-            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-            
-
-            [((MainViewController*)appDelegate.main_vc) switchToOrder];
-            // back to cart;
-            //            [self.navigationController dismissViewControllerAnimated:true completion:^{
-            //                ;
-            //            }];
-            //    if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
-            //        appDelegate.order_code = nil;
-            //
-            //    }
-        }
-        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];
-                    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,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-#else
-                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                        [((MainViewController*)appDelegate.main_vc) reloadOrder: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];
-                        //                        [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)
+//        {
+//
+//            [self.navigationController popViewControllerAnimated:true];
+//            // back to cart;
+//            //            [self.navigationController dismissViewControllerAnimated:true completion:^{
+//            //                ;
+//            //            }];
+//            //    if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
+//            //        appDelegate.order_code = nil;
+//            //
+//            //    }
+//        }
+//        if(buttonIndex==2)
+//        {
+//
+//            [self.navigationController popViewControllerAnimated:false];
+//
+//
+//
+//            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//
+//
+//            [((MainViewController*)appDelegate.main_vc) switchToOrder];
+//            // back to cart;
+//            //            [self.navigationController dismissViewControllerAnimated:true completion:^{
+//            //                ;
+//            //            }];
+//            //    if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
+//            //        appDelegate.order_code = nil;
+//            //
+//            //    }
+//        }
+//        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];
+//                    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,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//                        [((MainViewController*)appDelegate.main_vc) reloadOrder: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];
+//                        //                        [self.navigationController dismissViewControllerAnimated:true completion:^{
+//                        //                            ;
+//                        //                        }];
+//
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
+//                    }
+//
+//
+//
+//                });
+//            });
+//
+//
+//
+//
+//
+//            //
+//            //    }
+//        }
+//    }
+//}
 //
 //
 //-(void) downloadpdf:(NSString* )url
@@ -2588,7 +2716,8 @@
             }
             else
             {
-                [RAUtils alert_view:@"" title:@"not impl"];
+                [RAUtils message_alert:@"not impl" title:@"Sorry" controller:self];
+//                [RAUtils alert_view:@"" title:@"not impl"];
             }
             
             [olditem setValue:@"true" forKey:@"dirty"];
@@ -2974,9 +3103,10 @@
                     msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
                 }
                 
-                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+                [RAUtils message_alert:msg title:title controller:self];
+//                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                 
-                [alert show];
+//                [alert show];
                 
                 [self prepareReturn:nil];
                 [self.navigationController popToRootViewControllerAnimated:true];
@@ -3036,35 +3166,39 @@
                     msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
                 }
                 
-                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-                
-                [alert show];
+                UIAlertController* message_alert=[RAUtils message_alert:msg title:title controller:self];
                 
+//                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+//
+//                [alert show];
+//
                 NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
                 NSString* email_content =[editor_json valueForKey:@"email_content"];
                 NSString* soid=[editor_json valueForKey:@"so#"];
+                
+                NSMutableDictionary *value = [NSMutableDictionary dictionary];
+                if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
+                {
+                    //bbb
+                    [((MainViewController*)appDelegate.main_vc) Loginout:false];
+                    value[@"commitorder_logout"]=@"true";
+                }
+                [self prepareReturn:value];
+                
+                [self.navigationController popToRootViewControllerAnimated:true];
+                
+                if(pdf_url.length>0)
                 {
-                    NSMutableDictionary *value = [NSMutableDictionary dictionary];
-                    if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
-                    {
-                        //bbb
-                        [((MainViewController*)appDelegate.main_vc) Loginout:false];
-                        value[@"commitorder_logout"]=@"true";
-                    }
-                    [self prepareReturn:value];
                     
-                    [self.navigationController popToRootViewControllerAnimated:true];
                     
-                    if(pdf_url.length>0)
-                    {
-                        
-                        [alert dismissWithClickedButtonIndex:0 animated:FALSE];
-                        [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
-                        //  [appDelegate printPdf:pdf_url];
-                        
-                    }
+                    [message_alert dismissViewControllerAnimated:YES completion:nil];
+                    //                        [alert dismissWithClickedButtonIndex:0 animated:FALSE];
+                    [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
+                    //  [appDelegate printPdf:pdf_url];
+                    
                 }
                 
+                
             }
             else
             {

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

@@ -10,7 +10,7 @@
 #import <WebKit/WebKit.h>
 #import "ActiveViewController.h"
 
-@interface OrderDetailViewController : ActiveViewController<UITableViewDataSource,UITableViewDelegate,UIAlertViewDelegate,WKNavigationDelegate>
+@interface OrderDetailViewController : ActiveViewController<UITableViewDataSource,UITableViewDelegate/*,UIAlertViewDelegate*/,WKNavigationDelegate>
 @property (strong, nonatomic) IBOutlet UITableView *detailTable;
 @property (strong,nonatomic) NSMutableDictionary* content_data;
 @property (strong,nonatomic) NSString* orderid;

+ 38 - 14
RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m

@@ -596,8 +596,29 @@
         
     } else {
         
-        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Copy confirm", nil) message:NSLocalizedString(@"Are you sure to copy order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
-        [alert show];
+        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Copy confirm" message:@"Are you sure to copy order?" preferredStyle:UIAlertControllerStyleAlert];
+         
+         
+
+         UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            
+            [self copyOrder];
+             
+         }];
+         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(@"Copy confirm", nil) message:NSLocalizedString(@"Are you sure to copy order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
+//        [alert show];
         
     }
     
@@ -3712,16 +3733,16 @@
 
 
 
-#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)
-    {
-        [self copyOrder];
-    }
-}
+//#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)
+//    {
+//        [self copyOrder];
+//    }
+//}
 
 - (void)copyOrder {
     
@@ -3742,10 +3763,13 @@
             //
             //
             //                    }
-            UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Copy successful." message:[NSString stringWithFormat:@"New order SO#: %@",[order_json valueForKey:@"so_id"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
             
-            [alert show];
+            [RAUtils message_alert:[NSString stringWithFormat:@"New order SO#: %@",[order_json valueForKey:@"so_id"]] title:@"Copy successful." controller:self];
             
+//            UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Copy successful." message:[NSString stringWithFormat:@"New order SO#: %@",[order_json valueForKey:@"so_id"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+//
+//            [alert show];
+//
             
             
 #ifdef RA_NOTIFICATION

+ 2 - 1
RedAnt ERP Mobile/common/Functions/order/RAOrderEditorViewController.m

@@ -1138,7 +1138,8 @@ static const int totalPage = 3;
             }
             else
             {
-                [RAUtils alert_view:@"" title:@"not impl"];
+                [RAUtils message_alert:@"not impl" title:@"Sorry" controller:self];
+//                [RAUtils alert_view:@"" title:@"not impl"];
             }
             
             [olditem setValue:@"true" forKey:@"dirty"];

+ 2 - 1
RedAnt ERP Mobile/common/Functions/order/RAOrderPreviewController.m

@@ -2319,7 +2319,8 @@
             }
             else
             {
-                [RAUtils alert_view:@"" title:@"not impl"];
+                [RAUtils message_alert:@"not impl." title:@"Sorry" controller:self];
+//                [RAUtils alert_view:@"" title:@"not impl"];
             }
             
             [olditem setValue:@"true" forKey:@"dirty"];

+ 6 - 4
RedAnt ERP Mobile/common/Functions/portfolio/PortfolioEditQTYViewController.m

@@ -202,7 +202,8 @@
         //
         //        [alert show];
         
-        [RAUtils alert_view:@"Percentage must less than 100." title:@"Input Error"];
+        [RAUtils message_alert:@"Percentage must less than 100." title:@"Input Error" controller:self];
+//        [RAUtils alert_view:@"Percentage must less than 100." title:@"Input Error"];
         
         self.editDiscount.text=@"0";
         
@@ -215,7 +216,8 @@
         //
         //        [alert show];
         
-        [RAUtils alert_view:@"Percentage must less than 100." title:@"Input Error"];
+        [RAUtils message_alert:@"Percentage must less than 100." title:@"Input Error" controller:self];
+//        [RAUtils alert_view:@"Percentage must less than 100." title:@"Input Error"];
         
         self.editDiscount.text=@"0";
         
@@ -418,8 +420,8 @@
             //            [alert show];
             
             
-            
-            [RAUtils alert_view:@"Percentage must less than 100." title:@"Input Error."];
+            [RAUtils message_alert:@"Percentage must less than 100." title:@"Input Error" controller:self];
+//            [RAUtils alert_view:@"Percentage must less than 100." title:@"Input Error."];
             textField.text=@"0";
         }
     }

+ 4 - 1
RedAnt ERP Mobile/common/Functions/portfolio/PortfolioViewController.m

@@ -705,7 +705,10 @@
                             
                             if([[json valueForKey:@"result"] intValue]==2)
                             {
-                                [RAUtils alert_view:nil title:@"Portfolio saved. You can find it from View Portfolios" ] ;
+                                
+                                [RAUtils message_alert:@"Portfolio saved. You can find it from View Portfolios" title:@"Portfolio" controller:self];
+                                
+//                                [RAUtils alert_view:nil title:@"Portfolio saved. You can find it from View Portfolios" ] ;
                                 
                                 [self.navigationController dismissViewControllerAnimated:true completion:^{
                                     

+ 2 - 1
RedAnt ERP Mobile/common/Functions/portfolio/TearSheetParamViewController.m

@@ -393,7 +393,8 @@
                             
                             if([[json valueForKey:@"result"] intValue]==2)
                             {
-                                [RAUtils alert_view:nil title:@"Portfolio saved. You can find it from View Portfolios" ] ;
+                                [RAUtils message_alert:@"Portfolio saved. You can find it from View Portfolios" title:@"Portfolio" controller:self];
+//                                [RAUtils alert_view:nil title: ] ;
                                 
                                 [self.navigationController dismissViewControllerAnimated:true completion:^{
                                    

+ 2 - 2
RedAnt ERP Mobile/common/RAUtils.h

@@ -26,8 +26,8 @@
 +(UIViewController*) getViewController:(UIView*) view;
 + (CGRect)relativeFrameForScreenWithView:(UIView *)v;
 +(NSDictionary*) error_json :(int)code err_msg:(NSString*)msg;
-+(void) message_alert :(NSString*) msg title:(NSString*) title controller:(UIViewController*) vc;
-+(void) alert_view :(NSString*) msg title:(NSString*) title ;
++(UIAlertController*) message_alert :(NSString*) msg title:(NSString*) title controller:(UIViewController*) vc;
+//+(void) alert_view :(NSString*) msg title:(NSString*) title ;
 //+(UIAlertView * ) waiting_alert :(NSString*) msg title:(NSString*) title;
 +(UIAlertController*) waiting_alert:(UIViewController*)parent title:(NSString*) title;
 +(UIAlertController*) waiting_alert:(UIViewController*)parent message:(NSString*)msg title:(NSString*) title;

+ 110 - 91
RedAnt ERP Mobile/common/RAUtils.m

@@ -453,101 +453,101 @@
     NSString * na = [df stringFromDate:currentDate];
     return na;
 }
-+(void) message_alert :(NSString*) msg title:(NSString*) title controller:(UIViewController*) vc
-{
-    if(title==nil)
-        title = @"Message";
-    if ([title isEqualToString:@"Add To Cart"]) {
-        if ([msg hasPrefix:@"Out of Stock.\n"]) {
-            title = @"Add To Cart: Out of Stock";
-            msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
-        }
-    }
-    
-    
-    
-    return [self alert_view:msg title:title];
+//+(void) message_alert :(NSString*) msg title:(NSString*) title controller:(UIViewController*) vc
+//{
+//    if(title==nil)
+//        title = @"Message";
+//    if ([title isEqualToString:@"Add To Cart"]) {
+//        if ([msg hasPrefix:@"Out of Stock.\n"]) {
+//            title = @"Add To Cart: Out of Stock";
+//            msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+//        }
+//    }
 //
 //
-//    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];
-//    //block代码块取代了delegate
-//    
-//    
-//    //        [alertControl addTextFieldWithConfigurationHandler:^(UITextField *textField) {
-//    //            textField.text = self.save_name;
-//    //
-//    //
-//    //        }];
-//    
-//    //    UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-//    //
-//    //        UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Delete Order"];
-//    //        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//    //
-//    //            NSDictionary* return_json = [iSalesNetwork delete_Order:orderid];
-//    //
-//    //            dispatch_async(dispatch_get_main_queue(), ^{
-//    //                [waitalert dismissViewControllerAnimated:YES completion:nil];
-//    //
-//    //
-//    //                if([[return_json valueForKey:@"result"] intValue]==2)
-//    //                {
-//    //
-//    //                    [RAUtils error_alert:nil title:@"Order Delete"] ;
-//    //                }
-//    //                else
-//    //                {
-//    //                    [RAUtils error_alert:[return_json valueForKey:@"err_msg"] title:@"Delete Order Failed."] ;
-//    //                }
-//    //
-//    //
-//    //
-//    //
-//    //            });
-//    //        });
-//    //
-//    //
-//    //    }];
-//    
-//    UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
-//        //DebugLog(@"Cancel");
-//    }];
-//    // [alertControl addAction:actionOne];
-//    
-//    [alertControl addAction:alertthree];
-//    
-//    
-//    UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
-//    }];
-//    [alertControl addAction:alertcancel];
-//    //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
-//    
-//    
-//    
-//    
-//    [vc presentViewController:alertControl animated:YES completion:nil];
-//    
-//    
-//    
-//    return;
-//    
-//    
-    
-    
-}
+//
+//    return [self alert_view:msg title:title];
+////
+////
+////    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];
+////    //block代码块取代了delegate
+////
+////
+////    //        [alertControl addTextFieldWithConfigurationHandler:^(UITextField *textField) {
+////    //            textField.text = self.save_name;
+////    //
+////    //
+////    //        }];
+////
+////    //    UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
+////    //
+////    //        UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Delete Order"];
+////    //        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+////    //
+////    //            NSDictionary* return_json = [iSalesNetwork delete_Order:orderid];
+////    //
+////    //            dispatch_async(dispatch_get_main_queue(), ^{
+////    //                [waitalert dismissViewControllerAnimated:YES completion:nil];
+////    //
+////    //
+////    //                if([[return_json valueForKey:@"result"] intValue]==2)
+////    //                {
+////    //
+////    //                    [RAUtils error_alert:nil title:@"Order Delete"] ;
+////    //                }
+////    //                else
+////    //                {
+////    //                    [RAUtils error_alert:[return_json valueForKey:@"err_msg"] title:@"Delete Order Failed."] ;
+////    //                }
+////    //
+////    //
+////    //
+////    //
+////    //            });
+////    //        });
+////    //
+////    //
+////    //    }];
+////
+////    UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+////        //DebugLog(@"Cancel");
+////    }];
+////    // [alertControl addAction:actionOne];
+////
+////    [alertControl addAction:alertthree];
+////
+////
+////    UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+////    }];
+////    [alertControl addAction:alertcancel];
+////    //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
+////
+////
+////
+////
+////    [vc presentViewController:alertControl animated:YES completion:nil];
+////
+////
+////
+////    return;
+////
+////
+//
+//
+//}
 
 
-+(void) alert_view :(NSString*) msg title:(NSString*) title
-{
-    if(title==nil)
-        title = NSLocalizedString(@"Message", @"Message");
-    if(msg.length>0)
-    {
-        title=[NSString stringWithFormat:@"%@\n\n%@",title,msg];
-    }
-    UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:nil delegate:nil cancelButtonTitle:NSLocalizedString(@"Ok", @"Ok") otherButtonTitles:nil, nil];
-    [alert show];
-}
+//+(void) alert_view :(NSString*) msg title:(NSString*) title
+//{
+//    if(title==nil)
+//        title = NSLocalizedString(@"Message", @"Message");
+//    if(msg.length>0)
+//    {
+//        title=[NSString stringWithFormat:@"%@\n\n%@",title,msg];
+//    }
+//    UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:nil delegate:nil cancelButtonTitle:NSLocalizedString(@"Ok", @"Ok") otherButtonTitles:nil, nil];
+//    [alert show];
+//}
 + (long long) freeDiskSpaceInMegaBytes{
     struct statfs buf;
     long long freespace = -1;
@@ -572,6 +572,25 @@
     [parent presentViewController:alertController animated:YES completion:nil];
     return alertController;
 
+}
+
++(UIAlertController*) message_alert :(NSString*) msg title:(NSString*) title controller:(UIViewController*) vc
+{
+    if(title==nil)
+        title = @"Message";
+    if ([title isEqualToString:@"Add To Cart"]) {
+        if ([msg hasPrefix:@"Out of Stock.\n"]) {
+            title = @"Add To Cart: Out of Stock";
+            msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+        }
+    }
+    
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];
+    UIAlertAction *action_0 = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
+    [alertController addAction:action_0];
+    [vc presentViewController:alertController animated:YES completion:nil];
+    return alertController;
+
 }
 //+(UIAlertView * ) waiting_alert :(NSString*) msg title:(NSString*) title
 //{