Procházet zdrojové kódy

完成了ERP Mobile 消除警告错误的修改。
新增ERP Mobile 文件下载接口,并替换部分调用。
新增ERP Mobile 加购物车接口,并替换部分调用。
新增ERP Mobile 加wish list接口,并替换部分调用。
新增ERP Mobile 加portfolio接口,并替换部分调用。
新增ERP Mobile search 结果全部添加接口,并替换调用。
新增ERP Mobile item search 结果全部添加接口,并替分调用。

Ray Zhang před 6 roky
rodič
revize
6da1ba054b

+ 2 - 0
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m

@@ -6367,6 +6367,7 @@
         
         // table -> top > offset: table.y = -offset
         // 事实上top:topLayoutGuide
+        float y0=self.view.safeAreaLayoutGuide.topAnchor.accessibilityActivationPoint.y;
         CGFloat topAvailableHeight = (CGRectGetMinY(table_origin_screen_frame) - self.topLayoutGuide.length);
         if (topAvailableHeight > 0) {
             if (topAvailableHeight > offset) {
@@ -6375,6 +6376,7 @@
                 // 向上移动到topLayoutGuide,不足部分通过缩减高度到达keyboard顶部
                 table_frame.origin.y = -topAvailableHeight;
                 
+                
                 table_frame.size.height = (end_y - self.topLayoutGuide.length);
             }
         } else {

+ 68 - 34
RedAnt ERP Mobile/common/Functions/camscan/ScannerViewController.m

@@ -755,45 +755,79 @@
 -(void) addtocart
 {
 
-
-    
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_addto_cart_byname:self.scan_val withScreen:ScreenCodeCamScan completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* return_json = result;
+        
+        
+        
+        
+        if([[return_json valueForKey:@"result"] intValue]==2)
+        {
+            
+            
+            
             
-            NSDictionary* return_json = [RANetwork add_toCart_byName: self.scan_val withScreen:ScreenCodeCamScan];
             
-            dispatch_async(dispatch_get_main_queue(), ^{
-                
-                
-                
-                if([[return_json valueForKey:@"result"] intValue]==2)
-                {
-                    
-                    
-
-                    
-                    
 #ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+            [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                    
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+            
+            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+            [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
 #endif
-                    
-                    
-                }
-                else
-                {
-                   
-                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-                }
-                
-                
-                
-                
-            });
-        });
+            
+            
+        }
+        else
+        {
+            
+            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+        }
+        
+        
+        
+        
+        
+    }];
+    
+//        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//            NSDictionary* return_json = [RANetwork add_toCart_byName: self.scan_val withScreen:ScreenCodeCamScan];
+//
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//
+//                if([[return_json valueForKey:@"result"] intValue]==2)
+//                {
+//
+//
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                    [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//#endif
+//
+//
+//                }
+//                else
+//                {
+//
+//                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//                }
+//
+//
+//
+//
+//            });
+//        });
     
     
 }

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

@@ -197,46 +197,85 @@
                 
                 [main_vc checklogin:true];
                 
-                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                [RANetwork request_addto_portfolio:self.product_id withScreen:ScreenCodeModelInfo completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* return_json =result;
                     
-                    NSDictionary* return_json = [RANetwork add_toPortfolio:self.product_id withScreen:ScreenCodeModelInfo];
                     
-                    dispatch_async(dispatch_get_main_queue(), ^{
+                    if([[return_json valueForKey:@"result"] intValue]==2)
+                    {
+                        
+                        // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+                        
                         
-                        if([[return_json valueForKey:@"result"] intValue]==2)
-                        {
-                            
-                            // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
-                            
-                            
 #ifdef RA_NOTIFICATION
-                            [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                        [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                            [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
 #endif
-                            
-                            if(self.WatchlistBlock!=nil)
-                            {
-                                UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                                
-                                
-                                CGRect iv_rect = CGRectMake(self.btnaddPortfolio.center.x-50, self.btnaddPortfolio.center.y-50, 100, 100);
-                                UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                                iv.image = img;
-                                //                        [self.contentView addSubview:iv];
-                                self.PortfolioBlock(iv);
-                                
-                            }
-                        }
-                        else
+                        
+                        if(self.WatchlistBlock!=nil)
                         {
-                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add to portfolio" controller:vc] ;
+                            UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                            
+                            
+                            CGRect iv_rect = CGRectMake(self.btnaddPortfolio.center.x-50, self.btnaddPortfolio.center.y-50, 100, 100);
+                            UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                            iv.image = img;
+                            //                        [self.contentView addSubview:iv];
+                            self.PortfolioBlock(iv);
+                            
                         }
-                        
-                        
-                        
-                    });
-                });
+                    }
+                    else
+                    {
+                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add to portfolio" controller:vc] ;
+                    }
+                    
+                    
+                    
+                    
+                }];
+                
+//                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                    NSDictionary* return_json = [RANetwork add_toPortfolio:self.product_id withScreen:ScreenCodeModelInfo];
+//
+//                    dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                        if([[return_json valueForKey:@"result"] intValue]==2)
+//                        {
+//
+//                            // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+//
+//
+//#ifdef RA_NOTIFICATION
+//                            [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                            [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+//#endif
+//
+//                            if(self.WatchlistBlock!=nil)
+//                            {
+//                                UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+//
+//
+//                                CGRect iv_rect = CGRectMake(self.btnaddPortfolio.center.x-50, self.btnaddPortfolio.center.y-50, 100, 100);
+//                                UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+//                                iv.image = img;
+//                                //                        [self.contentView addSubview:iv];
+//                                self.PortfolioBlock(iv);
+//
+//                            }
+//                        }
+//                        else
+//                        {
+//                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add to portfolio" controller:vc] ;
+//                        }
+//
+//
+//
+//                    });
+//                });
                 
                 
             }
@@ -270,43 +309,75 @@
     }
     else
     {
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-            
-            NSDictionary* return_json = [RANetwork add_toPortfolio:self.product_id withScreen:ScreenCodeModelInfo];
-            
-            dispatch_async(dispatch_get_main_queue(), ^{
+        [RANetwork request_addto_portfolio:self.product_id withScreen:ScreenCodeModelInfo completionHandler:^(NSMutableDictionary *result) {
+            NSDictionary* return_json =result;
+            if([[return_json valueForKey:@"result"] intValue]==2)
+            {
                 
-                if([[return_json valueForKey:@"result"] intValue]==2)
-                {
-
 #ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                    [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
 #endif
-                    if(self.WatchlistBlock!=nil)
-                    {
-                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                        
-                        
-                        CGRect iv_rect = CGRectMake(self.btnaddPortfolio.center.x-50, self.btnaddPortfolio.center.y-50, 100, 100);
-                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                        iv.image = img;
-                        //                        [self.contentView addSubview:iv];
-                        self.PortfolioBlock(iv);
-                        
-                    }
-                }
-                else
+                if(self.WatchlistBlock!=nil)
                 {
-                    UIViewController *vc= [RAUtils getViewController:self];
-                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add to portfolio" controller:vc] ;
+                    UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                    
+                    
+                    CGRect iv_rect = CGRectMake(self.btnaddPortfolio.center.x-50, self.btnaddPortfolio.center.y-50, 100, 100);
+                    UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                    iv.image = img;
+                    //                        [self.contentView addSubview:iv];
+                    self.PortfolioBlock(iv);
+                    
                 }
-                
-                
-                
-            });
-        });
+            }
+            else
+            {
+                UIViewController *vc= [RAUtils getViewController:self];
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add to portfolio" controller:vc] ;
+            }
+            
+            
+            
+        }];
+//        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//            NSDictionary* return_json = [RANetwork add_toPortfolio:self.product_id withScreen:ScreenCodeModelInfo];
+//
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                if([[return_json valueForKey:@"result"] intValue]==2)
+//                {
+//
+//#ifdef RA_NOTIFICATION
+//                    [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                    [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+//#endif
+//                    if(self.WatchlistBlock!=nil)
+//                    {
+//                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+//
+//
+//                        CGRect iv_rect = CGRectMake(self.btnaddPortfolio.center.x-50, self.btnaddPortfolio.center.y-50, 100, 100);
+//                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+//                        iv.image = img;
+//                        //                        [self.contentView addSubview:iv];
+//                        self.PortfolioBlock(iv);
+//
+//                    }
+//                }
+//                else
+//                {
+//                    UIViewController *vc= [RAUtils getViewController:self];
+//                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add to portfolio" controller:vc] ;
+//                }
+//
+//
+//
+//            });
+//        });
     }
 }
 
@@ -340,46 +411,82 @@
                 
                 [main_vc checklogin:true];
                 
-                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                    
-                    NSDictionary* return_json = [RANetwork add_toWatchList:self.product_id withScreen:ScreenCodeModelInfo];
-                    
-                    dispatch_async(dispatch_get_main_queue(), ^{
+                [RANetwork request_addto_wishlist:self.product_id withScreen:ScreenCodeModelInfo completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* return_json =result;
+                    if([[return_json valueForKey:@"result"] intValue]==2)
+                    {
+                        
+                        // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+                        
                         
-                        if([[return_json valueForKey:@"result"] intValue]==2)
-                        {
-                            
-                           // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
-
-                            
 #ifdef RA_NOTIFICATION
-                            [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                        [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                            [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
 #endif
-                            
-                            if(self.WatchlistBlock!=nil)
-                            {
-                                UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                                
-                                
-                                CGRect iv_rect = CGRectMake(self.btnaddWish.center.x-50, self.btnaddWish.center.y-50, 100, 100);
-                                UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                                iv.image = img;
-                                //                        [self.contentView addSubview:iv];
-                                self.WatchlistBlock(iv);
-                                
-                            }
-                        }
-                        else
+                        
+                        if(self.WatchlistBlock!=nil)
                         {
-                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add Wish List" controller:vc] ;
+                            UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                            
+                            
+                            CGRect iv_rect = CGRectMake(self.btnaddWish.center.x-50, self.btnaddWish.center.y-50, 100, 100);
+                            UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                            iv.image = img;
+                            //                        [self.contentView addSubview:iv];
+                            self.WatchlistBlock(iv);
+                            
                         }
-                        
-                        
-                        
-                    });
-                });
+                    }
+                    else
+                    {
+                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add Wish List" controller:vc] ;
+                    }
+                    
+                    
+                    
+                }];
+                
+//                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                    NSDictionary* return_json = [RANetwork add_toWatchList:self.product_id withScreen:ScreenCodeModelInfo];
+//
+//                    dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                        if([[return_json valueForKey:@"result"] intValue]==2)
+//                        {
+//
+//                           // DebugLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+//
+//
+//#ifdef RA_NOTIFICATION
+//                            [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                            [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+//#endif
+//
+//                            if(self.WatchlistBlock!=nil)
+//                            {
+//                                UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+//
+//
+//                                CGRect iv_rect = CGRectMake(self.btnaddWish.center.x-50, self.btnaddWish.center.y-50, 100, 100);
+//                                UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+//                                iv.image = img;
+//                                //                        [self.contentView addSubview:iv];
+//                                self.WatchlistBlock(iv);
+//
+//                            }
+//                        }
+//                        else
+//                        {
+//                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add Wish List" controller:vc] ;
+//                        }
+//
+//
+//
+//                    });
+//                });
                 
                 
             }
@@ -413,45 +520,79 @@
     }
     else
     {
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-            
-            NSDictionary* return_json = [RANetwork add_toWatchList:self.product_id withScreen:ScreenCodeModelInfo];
-            
-            dispatch_async(dispatch_get_main_queue(), ^{
+        [RANetwork request_addto_wishlist:self.product_id withScreen:ScreenCodeModelInfo completionHandler:^(NSMutableDictionary *result) {
+            NSDictionary* return_json =result;
+            if([[return_json valueForKey:@"result"] intValue]==2)
+            {
+                
                 
-                if([[return_json valueForKey:@"result"] intValue]==2)
-                {
-
-                    
 #ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                    [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
 #endif
-                    
-                    if(self.WatchlistBlock!=nil)
-                    {
-                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                        
-                        
-                        CGRect iv_rect = CGRectMake(self.btnaddWish.center.x-50, self.btnaddWish.center.y-50, 100, 100);
-                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                        iv.image = img;
-                        //                        [self.contentView addSubview:iv];
-                        self.WatchlistBlock(iv);
-                        
-                    }
-                }
-                else
+                
+                if(self.WatchlistBlock!=nil)
                 {
-                    UIViewController *vc= [RAUtils getViewController:self];
-                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add Wish List" controller:vc] ;
+                    UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                    
+                    
+                    CGRect iv_rect = CGRectMake(self.btnaddWish.center.x-50, self.btnaddWish.center.y-50, 100, 100);
+                    UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                    iv.image = img;
+                    //                        [self.contentView addSubview:iv];
+                    self.WatchlistBlock(iv);
+                    
                 }
-                
-                
-                
-            });
-        });
+            }
+            else
+            {
+                UIViewController *vc= [RAUtils getViewController:self];
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add Wish List" controller:vc] ;
+            }
+            
+            
+            
+        }];
+//        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//            NSDictionary* return_json = [RANetwork add_toWatchList:self.product_id withScreen:ScreenCodeModelInfo];
+//
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                if([[return_json valueForKey:@"result"] intValue]==2)
+//                {
+//
+//
+//#ifdef RA_NOTIFICATION
+//                    [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                    [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+//#endif
+//
+//                    if(self.WatchlistBlock!=nil)
+//                    {
+//                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+//
+//
+//                        CGRect iv_rect = CGRectMake(self.btnaddWish.center.x-50, self.btnaddWish.center.y-50, 100, 100);
+//                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+//                        iv.image = img;
+//                        //                        [self.contentView addSubview:iv];
+//                        self.WatchlistBlock(iv);
+//
+//                    }
+//                }
+//                else
+//                {
+//                    UIViewController *vc= [RAUtils getViewController:self];
+//                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add Wish List" controller:vc] ;
+//                }
+//
+//
+//
+//            });
+//        });
     }
 }
 

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

@@ -1196,35 +1196,110 @@
     self.addCartBtn.enabled = false;
      UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Add Models To Cart"];
 
-    
-    
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* return_json = nil;
-        if (self.addAll) {
-            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-            return_json = [RANetwork ItemSearch_addall:self.offset limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller orderCode:appDelegate.order_code addTo:@"cart"];
-        } else {
-            return_json = [RANetwork add_toCart_byName:ids withScreen:ScreenCodeParticularCategory];
-        }
+    if (self.addAll) {
+        AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
+        [RANetwork request_addall_itemsearch:self.offset limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller orderCode:appDelegate.order_code addTo:@"cart" completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* return_json =result;
+                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    
+                    self.addCartBtn.enabled = true;
+                    
+                    if([[return_json valueForKey:@"result"] intValue]==2)
+                    {
+                        //                int result=[[return_json valueForKey:@"result"] intValue];
+                        //                if(result==2)
+                        //                {
+                        //                    //successed.
+                        
+                        //             NSString* order_code = [return_json valueForKey:@"order_code"];
+                        
+                        //                    appDelegate.order_code = order_code;
+                        //                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                        //                appDelegate.order_code = order_code;
+                        
+                        
+        #ifdef RA_NOTIFICATION
+                        [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+        #else
+                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+        #endif
+                        
+                        
+                        NSString * msg = nil;
+                        
+                        if (self.addAll) {
+                            
+                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            
+                            msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
+                        } else {
+                            
+                            
+                            if(checked.count==1)
+                            {
+                                msg=@"1 item added to Cart";
+                            }
+                            else
+                            {
+                                msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
+                            }
+                        }
+                        
+                        
+                        [RAUtils message_alert:nil title:msg controller:self] ;
+                        
+                        [self end_select:2];
+                        
+                        
+                        
+                        //                }
+                    }
+                    else  if([[return_json valueForKey:@"result"] intValue]==8)
+                    {
+                        
+                        
+        #ifdef RA_NOTIFICATION
+                        [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+        #else
+                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+        #endif
+                        
+                        [self end_select:2];
+                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                    }
+                    else
+                    {
+                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                    }
+                    
+                    
+                    
+                    
+                }];
 
+    } else {
+        [RANetwork request_addto_cart_byname:ids withScreen:ScreenCodeParticularCategory completionHandler:^(NSMutableDictionary *result) {
+            NSDictionary* return_json =result;
+            [waitalert dismissViewControllerAnimated:YES completion:nil];
+            
             self.addCartBtn.enabled = true;
             
             if([[return_json valueForKey:@"result"] intValue]==2)
             {
-//                int result=[[return_json valueForKey:@"result"] intValue];
-//                if(result==2)
-//                {
-//                    //successed.
+                //                int result=[[return_json valueForKey:@"result"] intValue];
+                //                if(result==2)
+                //                {
+                //                    //successed.
                 
-       //             NSString* order_code = [return_json valueForKey:@"order_code"];
+                //             NSString* order_code = [return_json valueForKey:@"order_code"];
                 
-//                    appDelegate.order_code = order_code;
-//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//                appDelegate.order_code = order_code;
+                //                    appDelegate.order_code = order_code;
+                //                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                //                appDelegate.order_code = order_code;
                 
                 
 #ifdef RA_NOTIFICATION
@@ -1243,8 +1318,8 @@
                     
                     msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
                 } else {
-
-                
+                    
+                    
                     if(checked.count==1)
                     {
                         msg=@"1 item added to Cart";
@@ -1256,17 +1331,17 @@
                 }
                 
                 
-                    [RAUtils message_alert:nil title:msg controller:self] ;
-                    
+                [RAUtils message_alert:nil title:msg controller:self] ;
+                
                 [self end_select:2];
                 
-                    
-                    
-//                }
+                
+                
+                //                }
             }
             else  if([[return_json valueForKey:@"result"] intValue]==8)
             {
-
+                
                 
 #ifdef RA_NOTIFICATION
                 [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
@@ -1287,8 +1362,102 @@
             
             
             
-        });
-    });
+        }];
+        
+        
+    }
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* return_json = nil;
+//        if (self.addAll) {
+//            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+//            return_json = [RANetwork ItemSearch_addall:self.offset limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller orderCode:appDelegate.order_code addTo:@"cart"];
+//        } else {
+//            return_json = [RANetwork add_toCart_byName:ids withScreen:ScreenCodeParticularCategory];
+//        }
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//            self.addCartBtn.enabled = true;
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+////                int result=[[return_json valueForKey:@"result"] intValue];
+////                if(result==2)
+////                {
+////                    //successed.
+//
+//       //             NSString* order_code = [return_json valueForKey:@"order_code"];
+//
+////                    appDelegate.order_code = order_code;
+////                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+////                appDelegate.order_code = order_code;
+//
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+//#endif
+//
+//
+//                NSString * msg = nil;
+//
+//                if (self.addAll) {
+//
+//                    unsigned long checkedCount = [return_json[@"count"] integerValue];
+//
+//                    msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
+//                } else {
+//
+//
+//                    if(checked.count==1)
+//                    {
+//                        msg=@"1 item added to Cart";
+//                    }
+//                    else
+//                    {
+//                        msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
+//                    }
+//                }
+//
+//
+//                    [RAUtils message_alert:nil title:msg controller:self] ;
+//
+//                [self end_select:2];
+//
+//
+//
+////                }
+//            }
+//            else  if([[return_json valueForKey:@"result"] intValue]==8)
+//            {
+//
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//
+//                [self end_select:2];
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 -(void) addtoportfolio
 {
@@ -1336,71 +1505,184 @@
     self.addPortfolioBtn.enabled =false;
     
     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Add Models To Portfolio"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* return_json = nil;
-        if (self.addAll) {
-//            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-            return_json = [RANetwork ItemSearch_addall:self.offset limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller orderCode:nil addTo:@"portfolio"];
-        } else {
-            return_json = [RANetwork add_toPortfolio:ids withScreen:ScreenCodeParticularCategory];
-        }
-
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
-            self.addPortfolioBtn.enabled =true;
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                
-                
-                
-                
+    
+            if (self.addAll) {
+                [RANetwork request_addall_itemsearch:self.offset limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller orderCode:nil addTo:@"portfolio" completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* return_json = result;
+                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    
+                    self.addPortfolioBtn.enabled =true;
+                    
+                    if([[return_json valueForKey:@"result"] intValue]==2)
+                    {
+                        
+                        
+                        
+                        
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                        [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
+                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                        [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
 #endif
-                
-                NSString * msg = nil;
-                
-                if (self.addAll) {
+                        
+                        NSString * msg = nil;
+                        
+                        if (self.addAll) {
+                            
+                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            
+                            msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
+                        } else {
+                            
+                            if(checked.count==1)
+                            {
+                                msg=@"1 item added to Portfolio";
+                            }
+                            else
+                            {
+                                msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                            }
+                        }
+                        
+                        [RAUtils message_alert:nil title:msg controller:self] ;
+                        
+                        
+                        [self end_select:3];
+                        
+                    }
+                    else
+                    {
+                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
+                    }
                     
-                    unsigned long checkedCount = [return_json[@"count"] integerValue];
                     
-                    msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
-                } else {
-                
-                    if(checked.count==1)
+                    
+                    
+                }];
+            } else {
+                [RANetwork request_addto_portfolio:ids withScreen:ScreenCodeParticularCategory completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* return_json = result;
+                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    
+                    self.addPortfolioBtn.enabled =true;
+                    
+                    if([[return_json valueForKey:@"result"] intValue]==2)
                     {
-                        msg=@"1 item added to Portfolio";
+                        
+                        
+                        
+                        
+#ifdef RA_NOTIFICATION
+                        [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                        [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
+#endif
+                        
+                        NSString * msg = nil;
+                        
+                        if (self.addAll) {
+                            
+                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            
+                            msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
+                        } else {
+                            
+                            if(checked.count==1)
+                            {
+                                msg=@"1 item added to Portfolio";
+                            }
+                            else
+                            {
+                                msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                            }
+                        }
+                        
+                        [RAUtils message_alert:nil title:msg controller:self] ;
+                        
+                        
+                        [self end_select:3];
+                        
                     }
                     else
                     {
-                        msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
                     }
-                }
-                
-                    [RAUtils message_alert:nil title:msg controller:self] ;
                     
                     
-                [self end_select:3];
+                    
+                    
+                }];
                 
             }
-            else
-            {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
-            }
-            
-            
-            
-            
-        });
-    });
+    
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* return_json = nil;
+//        if (self.addAll) {
+////            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+//            return_json = [RANetwork ItemSearch_addall:self.offset limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller orderCode:nil addTo:@"portfolio"];
+//        } else {
+//            return_json = [RANetwork add_toPortfolio:ids withScreen:ScreenCodeParticularCategory];
+//        }
+//
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//            self.addPortfolioBtn.enabled =true;
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
+//#endif
+//
+//                NSString * msg = nil;
+//
+//                if (self.addAll) {
+//
+//                    unsigned long checkedCount = [return_json[@"count"] integerValue];
+//
+//                    msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
+//                } else {
+//
+//                    if(checked.count==1)
+//                    {
+//                        msg=@"1 item added to Portfolio";
+//                    }
+//                    else
+//                    {
+//                        msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+//                    }
+//                }
+//
+//                    [RAUtils message_alert:nil title:msg controller:self] ;
+//
+//
+//                [self end_select:3];
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 -(void) addtowish
 {
@@ -1436,71 +1718,190 @@
     
     
      UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Add Models To Wish List"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* return_json = nil;
-        if (self.addAll) {
-//            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-            return_json = [RANetwork ItemSearch_addall:self.offset limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller orderCode:nil addTo:@"wishlist"];
-        } else {
-            return_json = [RANetwork add_toWatchList:ids withScreen:ScreenCodeParticularCategory];
-        }
-
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            self.addWishBtn.enabled =true;
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-
+    
+            if (self.addAll) {
+    
+                [RANetwork request_addall_itemsearch:self.offset limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller orderCode:nil addTo:@"wishlist" completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* return_json = result;
+                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    self.addWishBtn.enabled =true;
                     
- 
-
-                
+                    if([[return_json valueForKey:@"result"] intValue]==2)
+                    {
+                        
+                        
+                        
+                        
+                        
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                        [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                
-                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                        
+                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
 #endif
-                NSString * msg = nil;
-                
-                if (self.addAll) {
+                        NSString * msg = nil;
+                        
+                        if (self.addAll) {
+                            
+                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            
+                            msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
+                        } else {
+                            
+                            
+                            if(checked.count==1)
+                            {
+                                msg=@"1 item added to \nWish List";
+                            }
+                            else
+                            {
+                                msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+                            }
+                        }
+                        
+                        [RAUtils message_alert:nil title:msg controller:self] ;
+                        
+                        
+                        [self end_select:1];
+                        
+                    }
+                    else
+                    {
+                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
+                    }
                     
-                    unsigned long checkedCount = [return_json[@"count"] integerValue];
                     
-                    msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
-                } else {
+                    
+                    
+                }];
 
                 
-                    if(checked.count==1)
+            } else {
+                
+                [RANetwork request_addto_wishlist:ids withScreen:ScreenCodeParticularCategory completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* return_json = result;
+                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    self.addWishBtn.enabled =true;
+                    
+                    if([[return_json valueForKey:@"result"] intValue]==2)
                     {
-                        msg=@"1 item added to \nWish List";
+                        
+                        
+                        
+                        
+                        
+#ifdef RA_NOTIFICATION
+                        [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                        
+                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+#endif
+                        NSString * msg = nil;
+                        
+                        if (self.addAll) {
+                            
+                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            
+                            msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
+                        } else {
+                            
+                            
+                            if(checked.count==1)
+                            {
+                                msg=@"1 item added to \nWish List";
+                            }
+                            else
+                            {
+                                msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+                            }
+                        }
+                        
+                        [RAUtils message_alert:nil title:msg controller:self] ;
+                        
+                        
+                        [self end_select:1];
+                        
                     }
                     else
                     {
-                        msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
                     }
-                }
-                
-                    [RAUtils message_alert:nil title:msg controller:self] ;
                     
                     
-                [self end_select:1];
-               
-            }
-            else
-            {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
+                    
+                    
+                }];
+                
             }
-            
-            
-            
-            
-        });
-    });
+    
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* return_json = nil;
+//        if (self.addAll) {
+////            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+//            return_json = [RANetwork ItemSearch_addall:self.offset limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller orderCode:nil addTo:@"wishlist"];
+//        } else {
+//            return_json = [RANetwork add_toWatchList:ids withScreen:ScreenCodeParticularCategory];
+//        }
+//
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//            self.addWishBtn.enabled =true;
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//
+//                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+//#endif
+//                NSString * msg = nil;
+//
+//                if (self.addAll) {
+//
+//                    unsigned long checkedCount = [return_json[@"count"] integerValue];
+//
+//                    msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
+//                } else {
+//
+//
+//                    if(checked.count==1)
+//                    {
+//                        msg=@"1 item added to \nWish List";
+//                    }
+//                    else
+//                    {
+//                        msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+//                    }
+//                }
+//
+//                    [RAUtils message_alert:nil title:msg controller:self] ;
+//
+//
+//                [self end_select:1];
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 
 -(void) showCategory

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

@@ -914,20 +914,88 @@
     
     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Add Models To Cart"];
     
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* return_json = nil;
-        if (self.addAll) {
-            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-            return_json = [RANetwork Search_addall:self.offset limit:20 keywords:self.keywords matchfull:self.loadmore_matchfull orderCode:appDelegate.order_code addTo:@"cart"];
-        } else {
-            return_json = [RANetwork add_toCart_byName:ids withScreen:ScreenCodeSearch];
-        }
-
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    if (self.addAll)
+    {
+        [RANetwork request_addall_search:self.offset limit:20 keywords:self.keywords matchfull:self.loadmore_matchfull orderCode:appDelegate.order_code addTo:@"cart" completionHandler:^(NSMutableDictionary *result) {
+            {
+                
+                NSDictionary* return_json=result;
+                [waitalert dismissViewControllerAnimated:YES completion:nil];
+                
+                
+                self.addCartBtn.enabled = true;
+                
+                if([[return_json valueForKey:@"result"] intValue]==2)
+                {
+                    
+                    
+                    
+#ifdef RA_NOTIFICATION
+                    [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+#endif
+                    NSString * msg = nil;
+                    
+                    if (self.addAll) {
+                        
+                        unsigned long checkedCount = [return_json[@"count"] integerValue];
+                        
+                        msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
+                    } else {
+                        
+                        if(checked.count==1)
+                        {
+                            msg=@"1 item added to Cart";
+                        }
+                        else
+                        {
+                            msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
+                        }
+                    }
+                    
+                    [RAUtils message_alert:nil title:msg controller:self] ;
+                    
+                    [self end_select:2];
+                    
+                    
+                    
+                    //                }
+                }
+                else  if([[return_json valueForKey:@"result"] intValue]==8)
+                {
+                    
+                    
+#ifdef RA_NOTIFICATION
+                    [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    //                    appDelegate.order_code = order_code;
+                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+#endif
+                    [self end_select:2];
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                }
+                else
+                {
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                }
+                
+                
+                
+                
+            };
+        }];
+    }
+    else
+    {
+        [RANetwork request_addto_cart_byname:ids withScreen:ScreenCodeSearch completionHandler:^(NSMutableDictionary *result) {
             
-//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+            NSDictionary* return_json=result;
             [waitalert dismissViewControllerAnimated:YES completion:nil];
             
             
@@ -935,8 +1003,8 @@
             
             if([[return_json valueForKey:@"result"] intValue]==2)
             {
-
-
+                
+                
                 
 #ifdef RA_NOTIFICATION
                 [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
@@ -953,7 +1021,7 @@
                     
                     msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
                 } else {
-                
+                    
                     if(checked.count==1)
                     {
                         msg=@"1 item added to Cart";
@@ -964,17 +1032,17 @@
                     }
                 }
                 
-                    [RAUtils message_alert:nil title:msg controller:self] ;
-                    
+                [RAUtils message_alert:nil title:msg controller:self] ;
+                
                 [self end_select:2];
                 
-                    
-                    
-//                }
+                
+                
+                //                }
             }
             else  if([[return_json valueForKey:@"result"] intValue]==8)
             {
-
+                
                 
 #ifdef RA_NOTIFICATION
                 [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
@@ -995,8 +1063,92 @@
             
             
             
-        });
-    });
+        }];
+    }
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* return_json = nil;
+//        if (self.addAll) {
+//            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+//            return_json = [RANetwork Search_addall:self.offset limit:20 keywords:self.keywords matchfull:self.loadmore_matchfull orderCode:appDelegate.order_code addTo:@"cart"];
+//        } else {
+//            return_json = [RANetwork add_toCart_byName:ids withScreen:ScreenCodeSearch];
+//        }
+//
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//
+////            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//
+//            self.addCartBtn.enabled = true;
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//                NSString * msg = nil;
+//
+//                if (self.addAll) {
+//
+//                    unsigned long checkedCount = [return_json[@"count"] integerValue];
+//
+//                    msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
+//                } else {
+//
+//                    if(checked.count==1)
+//                    {
+//                        msg=@"1 item added to Cart";
+//                    }
+//                    else
+//                    {
+//                        msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
+//                    }
+//                }
+//
+//                    [RAUtils message_alert:nil title:msg controller:self] ;
+//
+//                [self end_select:2];
+//
+//
+//
+////                }
+//            }
+//            else  if([[return_json valueForKey:@"result"] intValue]==8)
+//            {
+//
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                //                    appDelegate.order_code = order_code;
+//                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//                [self end_select:2];
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 -(void) addtoportfolio
 {
@@ -1050,29 +1202,20 @@
     self.addPortfolioBtn.enabled =false;
     
     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Add Models To Portfolio"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* return_json = nil;
-        if (self.addAll) {
-//            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-            return_json = [RANetwork Search_addall:self.offset limit:20 keywords:self.keywords matchfull:self.loadmore_matchfull orderCode:nil addTo:@"portfolio"];
-        } else {
-            return_json = [RANetwork add_toPortfolio:ids withScreen:ScreenCodeSearch];
-        }
-
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+    
+    if (self.addAll) {
+        [RANetwork request_addall_search:self.offset limit:20 keywords:self.keywords matchfull:self.loadmore_matchfull orderCode:nil addTo:@"portfolio" completionHandler:^(NSMutableDictionary *result) {
+            NSMutableDictionary* return_json = result;
             [waitalert dismissViewControllerAnimated:YES completion:nil];
             
             self.addPortfolioBtn.enabled =true;
             
             if([[return_json valueForKey:@"result"] intValue]==2)
             {
-
-                    
                 
-
+                
+                
+                
                 
                 
 #ifdef RA_NOTIFICATION
@@ -1090,7 +1233,7 @@
                     
                     msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
                 } else {
-                
+                    
                     if(checked.count==1)
                     {
                         msg=@"1 item added to Portfolio";
@@ -1101,9 +1244,65 @@
                     }
                 }
                 
-                    [RAUtils message_alert:nil title:msg controller:self] ;
+                [RAUtils message_alert:nil title:msg controller:self] ;
+                
+                
+                [self end_select:3];
+                
+            }
+            else
+            {
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
+            }
+            
+            
+            
+            
+        }];
+    } else {
+        [RANetwork request_addto_portfolio:ids withScreen:ScreenCodeSearch completionHandler:^(NSMutableDictionary *result) {
+            NSMutableDictionary* return_json = result;
+            [waitalert dismissViewControllerAnimated:YES completion:nil];
+            
+            self.addPortfolioBtn.enabled =true;
+            
+            if([[return_json valueForKey:@"result"] intValue]==2)
+            {
+                
+                
+                
+                
+                
+                
+#ifdef RA_NOTIFICATION
+                [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                [((MainViewController*)appDelegate.main_vc) reloadPortfolio :true immediately:false];
+#endif
+                
+                NSString * msg = nil;
+                
+                if (self.addAll) {
                     
+                    unsigned long checkedCount = [return_json[@"count"] integerValue];
                     
+                    msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
+                } else {
+                    
+                    if(checked.count==1)
+                    {
+                        msg=@"1 item added to Portfolio";
+                    }
+                    else
+                    {
+                        msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                    }
+                }
+                
+                [RAUtils message_alert:nil title:msg controller:self] ;
+                
+                
                 [self end_select:3];
                 
             }
@@ -1115,8 +1314,78 @@
             
             
             
-        });
-    });
+        }];
+        
+    }
+    
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* return_json = nil;
+//        if (self.addAll) {
+////            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+//            return_json = [RANetwork Search_addall:self.offset limit:20 keywords:self.keywords matchfull:self.loadmore_matchfull orderCode:nil addTo:@"portfolio"];
+//        } else {
+//            return_json = [RANetwork add_toPortfolio:ids withScreen:ScreenCodeSearch];
+//        }
+//
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+////            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//            self.addPortfolioBtn.enabled =true;
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//
+//
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                [((MainViewController*)appDelegate.main_vc) reloadPortfolio :true immediately:false];
+//#endif
+//
+//                NSString * msg = nil;
+//
+//                if (self.addAll) {
+//
+//                    unsigned long checkedCount = [return_json[@"count"] integerValue];
+//
+//                    msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
+//                } else {
+//
+//                    if(checked.count==1)
+//                    {
+//                        msg=@"1 item added to Portfolio";
+//                    }
+//                    else
+//                    {
+//                        msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+//                    }
+//                }
+//
+//                    [RAUtils message_alert:nil title:msg controller:self] ;
+//
+//
+//                [self end_select:3];
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 -(void) addtowish
 {
@@ -1158,73 +1427,191 @@
     self.addWishBtn.enabled =false;
     
      UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Add Models To Wish List"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* return_json = nil;
-        if (self.addAll) {
-//            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-            return_json = [RANetwork Search_addall:self.offset limit:20 keywords:self.keywords matchfull:self.loadmore_matchfull orderCode:nil addTo:@"wishlist"];
-        } else {
-            return_json = [RANetwork add_toWatchList:ids withScreen:ScreenCodeSearch];
-        }
-
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            
-//            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-
-            self.addWishBtn.enabled =true;
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
+            if (self.addAll) {
 
+                [RANetwork request_addall_search:self.offset limit:20 keywords:self.keywords matchfull:self.loadmore_matchfull orderCode:nil addTo:@"wishlist" completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* return_json =result;
+                    //            [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    [waitalert dismissViewControllerAnimated:YES completion:nil];
                     
-
-                
+                    self.addWishBtn.enabled =true;
+                    
+                    if([[return_json valueForKey:@"result"] intValue]==2)
+                    {
+                        
+                        
+                        
+                        
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                        [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                
-                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                        
+                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
 #endif
-                
-                NSString * msg = nil;
-                
-                if (self.addAll) {
+                        
+                        NSString * msg = nil;
+                        
+                        if (self.addAll) {
+                            
+                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            
+                            msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
+                        } else {
+                            
+                            if(checked.count==1)
+                            {
+                                msg=@"1 item added to \nWish List";
+                            }
+                            else
+                            {
+                                msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+                            }
+                        }
+                        
+                        [RAUtils message_alert:nil title:@" Multiple items added to \nWish List" controller:self] ;
+                        
+                        
+                        [self end_select:1];
+                        
+                    }
+                    else
+                    {
+                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
+                    }
                     
-                    unsigned long checkedCount = [return_json[@"count"] integerValue];
                     
-                    msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
-                } else {
-                
-                    if(checked.count==1)
+                    
+                    
+                }];
+
+            } else {
+                [RANetwork request_addto_wishlist:ids withScreen:ScreenCodeSearch completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* return_json =result;
+                    //            [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    
+                    self.addWishBtn.enabled =true;
+                    
+                    if([[return_json valueForKey:@"result"] intValue]==2)
                     {
-                        msg=@"1 item added to \nWish List";
+                        
+                        
+                        
+                        
+#ifdef RA_NOTIFICATION
+                        [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                        
+                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+#endif
+                        
+                        NSString * msg = nil;
+                        
+                        if (self.addAll) {
+                            
+                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            
+                            msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
+                        } else {
+                            
+                            if(checked.count==1)
+                            {
+                                msg=@"1 item added to \nWish List";
+                            }
+                            else
+                            {
+                                msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+                            }
+                        }
+                        
+                        [RAUtils message_alert:nil title:@" Multiple items added to \nWish List" controller:self] ;
+                        
+                        
+                        [self end_select:1];
+                        
                     }
                     else
                     {
-                        msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
                     }
-                }
-                
-                    [RAUtils message_alert:nil title:@" Multiple items added to \nWish List" controller:self] ;
                     
                     
-                [self end_select:1];
+                    
+                    
+                }];
                 
             }
-            else
-            {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
-            }
-            
-            
-            
-            
-        });
-    });
+    
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* return_json = nil;
+//        if (self.addAll) {
+////            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+//            return_json = [RANetwork Search_addall:self.offset limit:20 keywords:self.keywords matchfull:self.loadmore_matchfull orderCode:nil addTo:@"wishlist"];
+//        } else {
+//            return_json = [RANetwork add_toWatchList:ids withScreen:ScreenCodeSearch];
+//        }
+//
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//
+////            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//            self.addWishBtn.enabled =true;
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//
+//                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+//#endif
+//
+//                NSString * msg = nil;
+//
+//                if (self.addAll) {
+//
+//                    unsigned long checkedCount = [return_json[@"count"] integerValue];
+//
+//                    msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
+//                } else {
+//
+//                    if(checked.count==1)
+//                    {
+//                        msg=@"1 item added to \nWish List";
+//                    }
+//                    else
+//                    {
+//                        msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+//                    }
+//                }
+//
+//                    [RAUtils message_alert:nil title:@" Multiple items added to \nWish List" controller:self] ;
+//
+//
+//                [self end_select:1];
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 
 -(void) operation_loadMore

+ 10 - 9
RedAnt ERP Mobile/common/RAUtils.h

@@ -17,23 +17,23 @@
 //    
 //}MyTestStruct;
 
-
+NS_ASSUME_NONNULL_BEGIN
 @interface RAUtils : NSObject
 
 
-+ (CGSize)sizeWithFont:(NSString*)string font:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode;
++ (CGSize)sizeWithFont:(NSString*_Nonnull)string font:(UIFont *_Nonnull)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode;
 
 + (BOOL)isNumeric:(NSString*)string;
 //+(NSData*) dict2data:(NSDictionary*) dict;
 +(NSString*) FloatFormat:(float)value;
 +(UIViewController*) getViewController:(UIView*) view;
 + (CGRect)relativeFrameForScreenWithView:(UIView *)v;
-+(NSDictionary*) error_json :(int)code err_msg:(NSString*)msg;
-+(UIAlertController*) message_alert :(NSString*) msg title:(NSString*) title controller:(UIViewController*) vc;
++(NSDictionary*) error_json :(int)code err_msg:(NSString* _Nullable)msg;
++(UIAlertController*) message_alert :(NSString* _Nullable) msg title:(NSString*_Nullable) 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;
++(UIAlertController*) waiting_alert:(UIViewController*)parent title:(NSString*_Nullable) title;
++(UIAlertController*) waiting_alert:(UIViewController*)parent message:(NSString*_Nullable)msg title:(NSString*_Nullable) title;
 + (float)fileSizeForDir:(NSString*)path;//计算文件夹下文件的总大小;
 +(void) deletefiles :(NSString*) path;
 +(UIColor*) strColor:(NSString*) color;
@@ -58,7 +58,7 @@
 +(UIImage*)img_compress:(UIImage*)image kbsize:(float) size;
 +(NSString* )current_date;
 +(NSString*) current_date_forfile;
-+(NSMutableArray*)dictionary2array:(NSDictionary*)json count_fields:(NSString*) count_fields item_mark:(NSString*) item_mark items_mark:(NSString* )items_mark;
++(NSMutableArray*)dictionary2array:(NSDictionary*)json count_fields:(NSString*) count_fields item_mark:(NSString*) item_mark items_mark:(NSString* _Nullable )items_mark;
 +(int)getRandomNumber:(int)from to:(int)to;
 
 //+(void) add_recent_model:(NSDictionary*) model;
@@ -83,8 +83,9 @@
 
 + (nullable NSString *)md5:(nullable NSString *)str;
 
-+ (NSString *)deviceID;
++ (NSString *_Nullable)deviceID;
 
-+ (void)ra_showAlertTitle:(NSString *)title message:(NSString *)msg withViewController:(UIViewController *)vc;
++ (void)ra_showAlertTitle:(NSString *_Nullable)title message:(NSString *_Nullable)msg withViewController:(UIViewController *_Nonnull)vc;
 
 @end
+NS_ASSUME_NONNULL_END

+ 5 - 1
RedAnt ERP Mobile/common/TextUtils.m

@@ -69,7 +69,11 @@
     {
         const char* string = [phone UTF8String];
         long length = [phone lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
-        if( [[NSString stringWithCString:string length:1] intValue]==1 )
+        [[NSString stringWithCString:string encoding:NSUTF8StringEncoding] substringToIndex:1];
+        
+//        if( [[NSString stringWithCString:string length:1] intValue]==1 )
+        
+        if([[[NSString stringWithCString:string encoding:NSUTF8StringEncoding] substringToIndex:1] intValue]==1)
         {
             if( length > 11 )
                 return phone;

+ 13 - 5
RedAnt ERP Mobile/common/data_provider/RANetwork.h

@@ -58,7 +58,7 @@ extern NSString *const ScreenCodeOfflineSync;
 
 //+(NSDictionary*) delete_portfoliolist:(NSString* ) listid;
 
-+(NSDictionary*) add_toPortfolio:(NSString* ) item_id withScreen:(NSString *)screenName;
+//+(NSDictionary*) add_toPortfolio:(NSString* ) item_id withScreen:(NSString *)screenName;
 //+(NSData*)get_json : (NSString*) url parameters:(NSMutableDictionary *) params;
 //+(int)Authorize : (NSString*) user password:(NSString*) password ;
 //+(NSDictionary*)logout;
@@ -94,8 +94,8 @@ extern NSString *const ScreenCodeOfflineSync;
 +(NSDictionary*) finish_download_Offline:(NSString* )vid;
 
 +(NSDictionary*) add_toCart:(NSString* ) item_id count:(int) count name:(NSString *)name;
-+(NSDictionary*) add_toCart_byName:(NSString* ) model_name withScreen:(NSString *)screenName;
-+(NSDictionary*) add_toWatchList:(NSString* ) item_id withScreen:(NSString *)screenName;
+//+(NSDictionary*) add_toCart_byName:(NSString* ) model_name withScreen:(NSString *)screenName;
+//+(NSDictionary*) add_toWatchList:(NSString* ) item_id withScreen:(NSString *)screenName;
 //+(NSDictionary*)request_Cart:(int)sort;
 //+(NSDictionary*)request_WatchList:(int)sort;
 +(NSDictionary*) portfolio_setPrice:(NSString*) watchlist_id price:(float) price discount:(float) discount QTY:(int)qty qty_p:(float) qty_p notes:(NSString*)notes;
@@ -152,9 +152,9 @@ extern NSString *const ScreenCodeOfflineSync;
 
 +(NSString*) create_portfolio:(NSMutableDictionary*)params ;
 
-+(NSDictionary*)Search_addall:(long ) offset limit :(long)limit keywords :(NSString*) keywords matchfull:(bool)matchfull orderCode:(NSString*) orderCode  addTo:(NSString*) addTo;
+//+(NSDictionary*)Search_addall:(long ) offset limit :(long)limit keywords :(NSString*) keywords matchfull:(bool)matchfull orderCode:(NSString*) orderCode  addTo:(NSString*) addTo;
 
-+(NSDictionary*)ItemSearch_addall:(long ) offset limit :(long)limit covertype:(NSString* ) covertype ctgid:(NSString*)ctgid modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller orderCode:(NSString*) orderCode addTo:(NSString*) addTo;
+//+(NSDictionary*)ItemSearch_addall:(long ) offset limit :(long)limit covertype:(NSString* ) covertype ctgid:(NSString*)ctgid modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller orderCode:(NSString*) orderCode addTo:(NSString*) addTo;
 
 +(NSDictionary*)err_log:(NSString*) up_params result:(NSString*)result module:(NSString*) module code:(int) code;
 //+(NSDictionary*)category_LoadMore: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(int)offset;
@@ -226,4 +226,12 @@ extern NSString *const ScreenCodeOfflineSync;
 +(void)request_orderdetail:(NSMutableDictionary *) params completionHandler:(resultHandler)result;
 //+(void)request_commit_order:(NSString*) order_code completionHandler:(resultHandler)result;
 +(void)request_copy_order:(NSString*) order_code completionHandler:(resultHandler)result;
++ (void)request_fastdownload:(NSMutableDictionary *)params url:(NSString *)url completionHandler:(resultHandler)result;
++(void) request_addto_portfolio:(NSString* ) item_id withScreen:(NSString *)screenName completionHandler:(resultHandler)result;
+
++(void)request_addall_search:(long ) offset limit :(long)limit keywords :(NSString*) keywords matchfull:(bool)matchfull orderCode:(NSString*) orderCode  addTo:(NSString*) addTo completionHandler:(resultHandler)result;
++(void) request_addto_cart_byname:(NSString* ) model_name withScreen:(NSString *)screenName completionHandler:(resultHandler)result;
++(void) request_addto_wishlist:(NSString* ) item_id withScreen:(NSString *)screenName completionHandler:(resultHandler)result;
++(void)request_addall_itemsearch:(long ) offset limit :(long)limit covertype:(NSString* ) covertype ctgid:(NSString*)ctgid modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller orderCode:(NSString*) orderCode addTo:(NSString*) addTo completionHandler:(resultHandler)result;
++(void)request_addall_category: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword  offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip orderCode:(NSString*) orderCode addTo:(NSString*) addTo completionHandler:(resultHandler)result;
 @end

+ 674 - 0
RedAnt ERP Mobile/common/data_provider/RANetwork.m

@@ -7721,5 +7721,679 @@ NSString *const ScreenCodeOfflineSync = @"Offline Sync Screen";
 //    else
 //        return nil;
     
+}
+
++ (void)request_fastdownload:(NSMutableDictionary *)params url:(NSString *)url completionHandler:(resultHandler)result
+{
+    
+//#ifdef test_server
+//    url=URL_REQUEST_RECORDS;
+//    params[@"prefix"]=URL_REQUEST_RECORDS;
+//#endif
+
+    [self request_file_fast:url parameters:params completionHandler:result];
+    
+}
+
++(void) request_addto_portfolio:(NSString* ) item_id withScreen:(NSString *)screenName completionHandler:(resultHandler)result
+{
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+     AppDelegate *appDelegate = nil;
+    
+        appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if(appDelegate.user!=nil)
+        [params setValue:appDelegate.user forKey:@"user"];
+    if(appDelegate.contact_id!=nil)
+        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+    if(appDelegate.password!=nil)
+        [params setValue:appDelegate.password forKey:@"password"];
+    
+    [params setValue:item_id forKey:@"product_id"];
+    
+    [params setObject:screenName forKey:kScreenName];
+    
+    
+    if(appDelegate.offline_mode)
+    {
+
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            NSMutableDictionary* json = [[OLDataProvider offline_add2Portfolio:params] mutableCopy];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                result(json);
+            });
+        });
+        
+        return;
+    }
+    
+    
+    [self request_interface:URL_ADD_TO_PORTFOLIO parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
+        int result_code = [[resulti valueForKey:@"result"] intValue];
+        
+        if (result_code==2)
+        {
+            
+            appDelegate.port_count =[[resulti valueForKey:@"portfolio_count"] intValue];
+            
+            [appDelegate update_count_mark];
+            
+        }
+        result(resulti);
+    } retry:0];
+    
+    
+    
+//    
+//    NSData* json = nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json = [OLDataProvider offline_add2Portfolio:params];
+//    } else {
+//    if(![self IsNetworkAvailable])
+//        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//    
+//        json=[self get_json:URL_ADD_TO_PORTFOLIO parameters:params];
+//    }
+//    
+//    if(json==nil)
+//        return nil;
+//    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//    int result = [[jsobj valueForKey:@"result"] intValue];
+//    
+//    if (result==2)
+//    {
+//        
+//        //        appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
+//        //    appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
+//        appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
+//        
+//        [appDelegate update_count_mark];
+//    }
+//    return jsobj;
+}
++(void)request_addall_search:(long ) offset limit :(long)limit keywords :(NSString*) keywords matchfull:(bool)matchfull orderCode:(NSString*) orderCode  addTo:(NSString*) addTo completionHandler:(resultHandler)result
+{
+    
+
+    
+    
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+     AppDelegate *appDelegate = nil;
+    
+        appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if(appDelegate.user!=nil)
+        [params setValue:appDelegate.user forKey:@"user"];
+    if(appDelegate.contact_id!=nil)
+        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+    if(appDelegate.password!=nil)
+        [params setValue:appDelegate.password forKey:@"password"];
+    if(appDelegate.order_code!=nil)
+        [params setValue:appDelegate.order_code forKey:@"orderCode"];
+    //    [params setValue:[NSString stringWithFormat:@"%d",price_template]  forKey:@"price_template"];
+    //    [params setValue:[NSString stringWithFormat:@"%d",customid]  forKey:@"custom_id"];
+    //    [params setValue:[NSString stringWithFormat:@"%@",category]  forKey:@"category"];
+    //    [params setValue:[NSString stringWithFormat:@"%d",sort_by]  forKey:@"sort_by"];
+    //    [params setValue:filter forKey:@"filter"];
+    [params setValue:keywords forKey:@"keyword"];
+    [params setValue:addTo forKey:@"addTo"];
+    
+    [params setValue:orderCode forKey:@"orderCode"];
+    [params setValue:[NSString stringWithFormat:@"%ld",limit]  forKey:@"limit"];
+    [params setValue:[NSString stringWithFormat:@"%ld",offset]  forKey:@"offset"];
+    if(matchfull)
+        [params setValue:@"true"  forKey:@"exactMatch"];
+    else
+        [params setValue:@"false"  forKey:@"exactMatch"];
+    
+    [params setObject:ScreenCodeSearch forKey:kScreenName];
+    if ([addTo isEqualToString:@"cart"]) {
+        [params setObject:@"Add To Cart" forKey:kAction];
+    }
+    
+    
+        if(appDelegate.offline_mode)
+        {
+
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                NSMutableDictionary* json = [[OLDataProvider offline_searchaddall:params] mutableCopy];
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    result(json);
+                });
+            });
+            
+            return;
+        }
+        
+        
+        NSString * uuid= [[NSUUID UUID] UUIDString];
+        params[@"resultSerial"]=uuid;
+        __block bool bbreak = false;
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        for(int i=0;i<150;i++)
+        {
+            //           NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
+            //            result_params[@"resultSerial"]=uuid;
+            if(bbreak)
+                break;
+            
+            dispatch_async(dispatch_get_main_queue(), ^{
+                [self request_interface:URL_SEARCHADDALL parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
+                    
+                    
+                    if([resulti[@"result"] intValue]==2)
+                    {
+                        bbreak=true;
+                        result(resulti);
+                        
+                    }
+                    
+                    
+                } retry:0];
+                
+            });
+            
+            sleep(2);
+            
+            
+            
+        }
+    });
+
+    
+//    
+//    
+//    NSData* json=nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json=[OLDataProvider offline_searchaddall:params];
+//    }
+//    else
+//    {
+//    if(![self IsNetworkAvailable])
+//        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//    
+//        NSError *error=nil;
+//        
+//        NSString * uuid= [[NSUUID UUID] UUIDString];
+//        params[@"resultSerial"]=uuid;
+//        
+//        for(int i=0;i<150;i++)
+//        {
+//            //           NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
+//            //            result_params[@"resultSerial"]=uuid;
+//            json=[self get_json:URL_SEARCHADDALL parameters:params];
+//            if(json!=nil)
+//            {
+//                
+//                NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//                if([jsobj[@"result"] intValue]==2)
+//                {
+//                    break;
+//                }
+//            }
+//            sleep(2);
+//        }
+//    }
+//    if(json==nil)
+//        return nil;
+//    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//    return jsobj;
+
+}
+
++(void) request_addto_cart_byname:(NSString* ) model_name withScreen:(NSString *)screenName completionHandler:(resultHandler)result
+{
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+     AppDelegate *appDelegate = nil;
+    
+
+        appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if(appDelegate.user!=nil)
+        [params setValue:appDelegate.user forKey:@"user"];
+    if(appDelegate.contact_id!=nil)
+        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+    if(appDelegate.password!=nil)
+        [params setValue:appDelegate.password forKey:@"password"];
+    
+    if(appDelegate.order_code!=nil)
+        [params setValue:appDelegate.order_code forKey:@"orderCode"];
+    [params setValue:model_name forKey:@"product_name"];
+    [params setValue:[NSString stringWithFormat:@"%d",-1]  forKey:@"count"];
+    
+    [params setObject:screenName forKey:kScreenName];
+    [params setObject:@"Add To Cart" forKey:kAction];
+    if (!model_name) {
+        model_name = @"";
+    }
+    [params setObject:@{@"ModelName" : model_name} forKey:kExtra];
+    
+    NSDictionary* customerinfo= appDelegate.customerInfo;
+    
+    NSArray* keys=[customerinfo allKeys];
+    for(int i=0;i<keys.count;i++)
+    {
+        [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
+    }
+    
+    
+    if(appDelegate.offline_mode)
+    {
+
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            NSMutableDictionary* json = [[OLDataProvider offline_add2cartbyname:params] mutableCopy];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                result(json);
+            });
+        });
+        
+        return;
+    }
+    
+    
+    [self request_interface:URL_ADD_TO_CART parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
+        int result_code = [[resulti valueForKey:@"result"] intValue];
+        
+        if (result_code==2||result_code==8)
+        {
+            
+           appDelegate.cart_count = [[resulti valueForKey:@"cart_count"] intValue];
+
+            [appDelegate update_count_mark];
+            
+        }
+        result(resulti);
+    } retry:0];
+    
+//    NSData* json=nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json= [OLDataProvider offline_add2cartbyname:params];
+//    }
+//    else
+//    {
+//    if(![self IsNetworkAvailable])
+//        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//    
+//    json=[self get_json:URL_ADD_TO_CART parameters:params];
+//    }
+//    if(json==nil)
+//        return nil;
+//    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//    
+//    
+//    
+//    int result = [[jsobj valueForKey:@"result"] intValue];
+//    
+//    if (result==2||result==8)
+//    {
+//        
+//        appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
+//        //    appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
+//        //    appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
+//        
+//        [appDelegate update_count_mark];
+//    }
+//    
+//    return jsobj;
+}
+
++(void) request_addto_wishlist:(NSString* ) item_id withScreen:(NSString *)screenName completionHandler:(resultHandler)result
+{
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+     AppDelegate *appDelegate = nil;
+    
+        appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if(appDelegate.user!=nil)
+        [params setValue:appDelegate.user forKey:@"user"];
+    if(appDelegate.contact_id!=nil)
+        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+    if(appDelegate.password!=nil)
+        [params setValue:appDelegate.password forKey:@"password"];
+    
+    
+    [params setValue:item_id forKey:@"product_id"];
+    
+    [params setObject:screenName forKey:kScreenName];
+    
+    
+    
+      if(appDelegate.offline_mode)
+      {
+
+          dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+              NSMutableDictionary* json = [[OLDataProvider offline_add2wishlist:params] mutableCopy];
+              dispatch_async(dispatch_get_main_queue(), ^{
+                  result(json);
+              });
+          });
+          
+          return;
+      }
+      
+      
+      [self request_interface:URL_ADD_TO_WATCHLIST parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
+          int result_code = [[resulti valueForKey:@"result"] intValue];
+          
+          if (result_code==2||result_code==8)
+          {
+              
+             appDelegate.wish_count =[[resulti valueForKey:@"wish_count"] intValue];
+
+              [appDelegate update_count_mark];
+              
+          }
+          result(resulti);
+      } retry:0];
+      
+    
+    
+//    if(appDelegate.offline_mode)
+//    {
+//        return [OLDataProvider offline_add2wishlist:params];
+//    }
+//    if(![self IsNetworkAvailable])
+//        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//    
+//    NSData* json=[self get_json:URL_ADD_TO_WATCHLIST parameters:params];
+//    if(json==nil)
+//        return nil;
+//    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//    int result = [[jsobj valueForKey:@"result"] intValue];
+//    
+//    if (result==2)
+//    {
+//        
+//        //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
+//        appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
+//        //    appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
+//        
+//        [appDelegate update_count_mark];
+//    }
+//    return jsobj;
+}
+
++(void)request_addall_itemsearch:(long ) offset limit :(long)limit covertype:(NSString* ) covertype ctgid:(NSString*)ctgid modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller orderCode:(NSString*) orderCode addTo:(NSString*) addTo completionHandler:(resultHandler)result
+{
+    // for debug
+    //    return [RAUtils error_json:RESULT_NET_ERROR err_msg:nil];
+    //return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+    
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+     AppDelegate *appDelegate = nil;
+    
+  
+        appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+    
+    if(appDelegate.user!=nil)
+        [params setValue:appDelegate.user forKey:@"user"];
+    if(appDelegate.contact_id!=nil)
+        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+    if(appDelegate.password!=nil)
+        [params setValue:appDelegate.password forKey:@"password"];
+    if(appDelegate.order_code!=nil)
+        [params setValue:appDelegate.order_code forKey:@"orderCode"];
+    
+        [params setValue:addTo forKey:@"addTo"];
+    
+    [params setValue:orderCode forKey:@"orderCode"];
+    
+    //    [params setValue:[NSString stringWithFormat:@"%d",price_template]  forKey:@"price_template"];
+    //    [params setValue:[NSString stringWithFormat:@"%d",customid]  forKey:@"custom_id"];
+    //    [params setValue:[NSString stringWithFormat:@"%@",category]  forKey:@"category"];
+    //    [params setValue:[NSString stringWithFormat:@"%d",sort_by]  forKey:@"sort_by"];
+    //    [params setValue:filter forKey:@"filter"];
+    [params setValue:covertype forKey:@"covertype"];
+    [params setValue:ctgid forKey:@"ctgId"];
+    [params setValue:modelname forKey:@"modelName"];
+    [params setValue:modeldescrip forKey:@"modelDescription"];
+    [params setValue:alert forKey:@"alert"];
+    [params setValue:qty forKey:@"sold_by_qty"];
+    [params setValue:available forKey:@"available"];
+    [params setValue:price forKey:@"price"];
+    [params setValue:bestseller forKey:@"bestseller"];
+    
+    [params setValue:[NSString stringWithFormat:@"%ld",limit]  forKey:@"limit"];
+    [params setValue:[NSString stringWithFormat:@"%ld",offset]  forKey:@"offset"];
+    
+    [params setObject:ScreenCodeParticularCategory forKey:kScreenName];
+    if ([addTo isEqualToString:@"cart"]) {
+        [params setObject:@"Add To Cart" forKey:kAction];
+    }
+    
+    
+       if(appDelegate.offline_mode)
+        {
+
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                NSMutableDictionary* json = [[OLDataProvider offline_itemsearchaddall:params] mutableCopy];
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    result(json);
+                });
+            });
+            
+            return;
+        }
+        
+        
+        NSString * uuid= [[NSUUID UUID] UUIDString];
+        params[@"resultSerial"]=uuid;
+        __block bool bbreak = false;
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        for(int i=0;i<150;i++)
+        {
+            //           NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
+            //            result_params[@"resultSerial"]=uuid;
+            if(bbreak)
+                break;
+            
+            dispatch_async(dispatch_get_main_queue(), ^{
+                [self request_interface:URL_ITEMSEARCHADDALL parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
+                    
+                    
+                    if([resulti[@"result"] intValue]==2)
+                    {
+                        bbreak=true;
+                        result(resulti);
+                        
+                    }
+                    
+                    
+                } retry:0];
+                
+            });
+            
+            sleep(2);
+            
+            
+            
+        }
+    });
+    
+//
+//    NSData* json = nil;
+//
+//    if(appDelegate.offline_mode)
+//    {
+//        json= [OLDataProvider offline_itemsearchaddall:params];
+//    }
+//    else
+//    {
+//    if(![self IsNetworkAvailable])
+//        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//        NSError *error=nil;
+//
+//        NSString * uuid= [[NSUUID UUID] UUIDString];
+//        params[@"resultSerial"]=uuid;
+//
+//        for(int i=0;i<150;i++)
+//        {
+//            //           NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
+//            //            result_params[@"resultSerial"]=uuid;
+//            json=[self get_json:URL_ITEMSEARCHADDALL parameters:params];
+//            if(json!=nil)
+//            {
+//
+//                NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//                if([jsobj[@"result"] intValue]==2)
+//                {
+//                    break;
+//                }
+//            }
+//            sleep(2);
+//        }
+//    }
+//    if(json==nil)
+//        return nil;
+//    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//    return jsobj;
+}
+
++(void)request_addall_category: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword  offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip orderCode:(NSString*) orderCode addTo:(NSString*) addTo completionHandler:(resultHandler)result
+
+{
+
+    
+     AppDelegate *appDelegate = nil;
+    
+ 
+        appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+
+    
+    
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+    
+    if(appDelegate.user!=nil)
+        [params setValue:appDelegate.user forKey:@"user"];
+    if(appDelegate.contact_id!=nil)
+        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+    if(appDelegate.password!=nil)
+        [params setValue:appDelegate.password forKey:@"password"];
+    if(appDelegate.order_code!=nil)
+        [params setValue:appDelegate.order_code forKey:@"orderCode"];
+    
+    [params setValue:addTo forKey:@"addTo"];
+    [params setValue:orderCode forKey:@"orderCode"];
+    [params setValue:alert forKey:@"alert"];
+    [params setValue:qty forKey:@"sold_by_qty"];
+    [params setValue:available forKey:@"available"];
+    [params setValue:price forKey:@"price"];
+    [params setValue:bestseller forKey:@"bestseller"];
+    [params setValue:modelname forKey:@"modelName"];
+    [params setValue:modeldescrip forKey:@"modelDescription"];
+    
+    [params setValue:[NSString stringWithFormat:@"%d",price_template]  forKey:@"price_template"];
+    [params setValue:[NSString stringWithFormat:@"%d",customid]  forKey:@"custom_id"];
+    [params setValue:category  forKey:@"category"];
+    [params setValue:[NSString stringWithFormat:@"%d",sort_by]  forKey:@"sort_by"];
+    [params setValue:[NSString stringWithFormat:@"%d",sort_by]  forKey:@"sort_by"];
+    [params setValue:[NSString stringWithFormat:@"%ld",limit]  forKey:@"limit"];
+    [params setValue:[NSString stringWithFormat:@"%ld",offset]  forKey:@"offset"];
+    [params setValue:filter forKey:@"filter"];
+    [params setValue:keyword forKey:@"keyword"];
+    
+    [params setObject:ScreenCodeCategory forKey:kScreenName];
+    if ([addTo isEqualToString:@"cart"]) {
+        [params setObject:@"Add To Cart" forKey:kAction];
+    }
+    
+    
+      if(appDelegate.offline_mode)
+        {
+
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                NSMutableDictionary* json = [[OLDataProvider offline_categoryaddall:params] mutableCopy];
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    result(json);
+                });
+            });
+            
+            return;
+        }
+        
+        
+        NSString * uuid= [[NSUUID UUID] UUIDString];
+        params[@"resultSerial"]=uuid;
+        __block bool bbreak = false;
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        for(int i=0;i<150;i++)
+        {
+            //           NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
+            //            result_params[@"resultSerial"]=uuid;
+            if(bbreak)
+                break;
+            
+            dispatch_async(dispatch_get_main_queue(), ^{
+                [self request_interface:URL_CATEGORYADDALL parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
+                    
+                    
+                    if([resulti[@"result"] intValue]==2|| [resulti[@"result"] intValue] == 8)
+                    {
+                        bbreak=true;
+                        result(resulti);
+                        
+                    }
+                    
+                    
+                } retry:0];
+                
+            });
+            
+            sleep(2);
+            
+            
+            
+        }
+    });
+    
+//
+//    NSData* json= nil;
+//
+//    if(appDelegate.offline_mode)
+//    {
+//        json= [OLDataProvider offline_categoryaddall:params];
+//    }
+//    else
+//    {
+//        if(![self IsNetworkAvailable])
+//            return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//
+//
+//        NSError *error=nil;
+//
+//        NSString * uuid= [[NSUUID UUID] UUIDString];
+//        params[@"resultSerial"]=uuid;
+//
+//        for(int i=0;i<150;i++)
+//        {
+// //           NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
+////            result_params[@"resultSerial"]=uuid;
+//            json=[self get_json:URL_CATEGORYADDALL parameters:params];
+//            if(json!=nil)
+//            {
+//
+//                NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//                int resultInt = [jsobj[@"result"] intValue];
+//                if(resultInt == 2 || resultInt == 8)
+//                {
+//                    break;
+//                }
+//            }
+//            sleep(2);
+//        }
+//
+//
+//
+//    }
+//    if(json==nil)
+//        return nil;
+//    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//    return jsobj;
+
 }
 @end

+ 1 - 1
common/NetworkUtils.m

@@ -1802,7 +1802,7 @@ repeat:
 //                    if (![[NSFileManager defaultManager] fileExistsAtPath:cacheDir]) {
 //                        [[NSFileManager defaultManager] createDirectoryAtPath:cacheDir withIntermediateDirectories:NO attributes:nil error:nil];
 //                    }
-            
+            ret[@"suggestedFilename"]=response.suggestedFilename;
             ret[@"result"]=@"2";
             ret[@"data"]=data;
             ret[@"path"]=path;//[location absoluteString];

+ 114 - 48
common/WK PDF+Web/RAPDFViewController.m

@@ -12,7 +12,7 @@
 #import "AppDelegate.h"
 #import "PDFUtils.h"
 #import "TextUtils.h"
-
+#import "RANetwork.h"
 
 @interface RAPDFViewController ()
 
@@ -256,45 +256,26 @@
         
     }
     else
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        
-        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:self.url]        cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60*5];
-        
-        //设置请求方式为get
-        
-        [request setHTTPMethod:@"GET"];
-        
-        //添加用户会话id
-        
-        [request addValue:@"text/html" forHTTPHeaderField:@"Content-Type"];
-        
-        //连接发送请求
-        
-        
-        NSHTTPURLResponse* urlResponse = nil;
-        
-        NSError *error = nil;
-        
-        self.content= [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
-        
-        if(self.filename.length<=0)
-            self.filename = [urlResponse suggestedFilename];
-        
+    {
         
-        dispatch_async(dispatch_get_main_queue(), ^{
+        [RANetwork request_fastdownload:nil url:self.url completionHandler:^(NSMutableDictionary *result) {
+            self.content= result[@"data"];
+            if(self.filename.length<=0)
+                self.filename = result[@"suggestedFilename"];
+            
+            
             [waitalert dismissViewControllerAnimated:YES completion:nil];
             
             [[self navigationController] setNavigationBarHidden:self.hidenavi animated:NO];
             self.navigationItem.title = self.save_name;
             UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
-          //  self.content=nil;
+            //  self.content=nil;
             if(self.content!=nil&&self.content.length>0)
             {
                 [reF removeFromSuperview];
                 
                 
-               // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+                // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
                 NSString *path = NSTemporaryDirectory();
                 NSString *filePath = [path stringByAppendingPathComponent:self.filename];
                 //    NSError *error = nil;
@@ -308,7 +289,7 @@
                 
                 self.url = filePath;
                 self.isLocalfile = true;
-
+                
                 
                 self.btnshare.enabled =true;
                 
@@ -323,11 +304,6 @@
                 [self.wkWebview loadRequest:request];
                 
                 
-
-                
-                
-                
- //               int a=0;
             }
             else
             {
@@ -335,22 +311,112 @@
                 
                 if(self.autoPrint)
                     [self.navigationController popViewControllerAnimated:true];
-//                self.content = [self.url dataUsingEncoding:NSUTF8StringEncoding];
             }
             
-            ;
-//            DebugLog(@"%@",[[NSString alloc] initWithData:self.content encoding:NSASCIIStringEncoding]);
-            //
-            
-//            DebugLog(urlResponse.MIMEType);
             
-//            [self.webView loadData:self.content MIMEType:urlResponse.MIMEType textEncodingName:nil baseURL:nil];
             
             
-            
-            
-        });
-    });
+        }];
+
+        
+        
+        
+//        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:self.url]        cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60*5];
+//
+//                //设置请求方式为get
+//
+//                [request setHTTPMethod:@"GET"];
+//
+//                //添加用户会话id
+//
+//                [request addValue:@"text/html" forHTTPHeaderField:@"Content-Type"];
+//
+//                //连接发送请求
+//
+//
+//                NSHTTPURLResponse* urlResponse = nil;
+//
+//                NSError *error = nil;
+//
+//                self.content= [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
+//
+//                if(self.filename.length<=0)
+//                    self.filename = [urlResponse suggestedFilename];
+//
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//                    [[self navigationController] setNavigationBarHidden:self.hidenavi animated:NO];
+//                    self.navigationItem.title = self.save_name;
+//                    UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
+//                  //  self.content=nil;
+//                    if(self.content!=nil&&self.content.length>0)
+//                    {
+//                        [reF removeFromSuperview];
+//
+//
+//                       // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+//                        NSString *path = NSTemporaryDirectory();
+//                        NSString *filePath = [path stringByAppendingPathComponent:self.filename];
+//                        //    NSError *error = nil;
+//                        //    BOOL bo = [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
+//                        //    NSAssert(bo,@"创建目录失败");
+//                        if (self.cachePath.length) {
+//                            filePath = self.cachePath;
+//                        }
+//
+//                        [self.content writeToFile:filePath atomically:YES];
+//
+//                        self.url = filePath;
+//                        self.isLocalfile = true;
+//
+//
+//                        self.btnshare.enabled =true;
+//
+//
+//                        self.btnemail.enabled =true;
+//                        self.btnsave.enabled =true;
+//
+//
+//
+//                        NSURL *url = [NSURL fileURLWithPath:filePath];
+//                        NSURLRequest *request = [NSURLRequest requestWithURL:url];
+//                        [self.wkWebview loadRequest:request];
+//
+//
+//
+//
+//
+//
+//         //               int a=0;
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:nil  title:@"Open PDF Failed" controller:self];
+//
+//                        if(self.autoPrint)
+//                            [self.navigationController popViewControllerAnimated:true];
+//        //                self.content = [self.url dataUsingEncoding:NSUTF8StringEncoding];
+//                    }
+//
+//                    ;
+//        //            DebugLog(@"%@",[[NSString alloc] initWithData:self.content encoding:NSASCIIStringEncoding]);
+//                    //
+//
+//        //            DebugLog(urlResponse.MIMEType);
+//
+//        //            [self.webView loadData:self.content MIMEType:urlResponse.MIMEType textEncodingName:nil baseURL:nil];
+//
+//
+//
+//
+//                });
+//        });
+    }
+    
     
     
     
@@ -397,7 +463,7 @@
     
     
     airPrinterController.showsNumberOfCopies=true;
-    airPrinterController.showsPageRange = true;
+//    airPrinterController.showsPageRange = true;
     airPrinterController.showsPaperSelectionForLoadedPapers=true;
     
     
@@ -903,7 +969,7 @@
     
     
     airPrinterController.showsNumberOfCopies=true;
-    airPrinterController.showsPageRange = true;
+//    airPrinterController.showsPageRange = true;
     airPrinterController.showsPaperSelectionForLoadedPapers=true;
     
     void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {