Browse Source

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

Ray Zhang 6 years ago
parent
commit
923151c725

+ 56 - 30
RedAnt ERP Mobile/common/Functions/cart/CartGeneralNotesViewController.m

@@ -58,41 +58,67 @@
     
     NSString* notes=self.tv_notes.text;
     UIApplication * app = [UIApplication sharedApplication];
-    __block AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+     AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+    
+    
+    [RANetwork request_update_cartgeneralnote:appDelegate.order_code notes:notes completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* cart_json = result;
+        
+        [waitalert dismissViewControllerAnimated:YES completion:nil];
+        //            [waitalert dismissViewControllerAnimated:YES completion:nil];
+        if([[cart_json valueForKey:@"result"] intValue]==2)
+        {
+            [self dismissViewControllerAnimated:NO
+                                     completion:^{
+                
+                if(self.onSetValue)
+                    self.onSetValue(self.notes);
+                
+            }];
+        }
+        else
+        {
+            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update General Notes" controller:self] ;
+        }
         
-        NSDictionary* cart_json = nil;
         
-
-
         
-        cart_json = [RANetwork cart_setGeneralNote:appDelegate.order_code notes:notes];
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            
-            
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* cart_json = nil;
+//
+//
+//
+//
+//        cart_json = [RANetwork cart_setGeneralNote:appDelegate.order_code notes:notes];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
 //            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            if([[cart_json valueForKey:@"result"] intValue]==2)
-            {
-                [self dismissViewControllerAnimated:NO
-                                         completion:^{
-                                             
-                                             if(self.onSetValue)
-                                                 self.onSetValue(self.notes);
-                                             
-                                         }];
-            }
-            else
-            {
-                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update General Notes" controller:self] ;
-            }
-            
-            
-            
-            
-        });
-    });
+////            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//            if([[cart_json valueForKey:@"result"] intValue]==2)
+//            {
+//                [self dismissViewControllerAnimated:NO
+//                                         completion:^{
+//
+//                                             if(self.onSetValue)
+//                                                 self.onSetValue(self.notes);
+//
+//                                         }];
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update General Notes" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 
 /*

+ 195 - 86
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -3424,121 +3424,230 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
 {
     
     
-    
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_addto_cart_byname:modelname withScreen:ScreenCodeCart completionHandler:^(NSMutableDictionary *result) {
         
-        NSDictionary* return_json = [RANetwork add_toCart_byName: modelname withScreen:ScreenCodeCart];
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            
-            
+        NSDictionary* return_json =result;
+        if([[return_json valueForKey:@"result"] intValue]==2)
+        {
+            NSDictionary* newitem = [return_json objectForKey:@"item_0"];
+            NSString* item_id = [newitem valueForKey:@"cart_item_id"];
+            //  bool isnew=false;
+            //
+            //                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
             
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                NSDictionary* newitem = [return_json objectForKey:@"item_0"];
-                NSString* item_id = [newitem valueForKey:@"cart_item_id"];
-                //  bool isnew=false;
-//
-                //                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+            if (self.back_order_flag) {
                 
-                if (self.back_order_flag) {
-                    
-                    NSInteger section_count = [self sectionCount];
-                    for (int i = 0; i < section_count; i++) {
-                        NSInteger item_count = [self itemCountInSection:i];
-                        BOOL ready_break = NO;
-                        for (int j = 0; j < item_count; j++) {
-                            NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
-                            NSDictionary* obj_json = [self itemJsonAtIndexPath:indexPath];
-                            NSString* _id =[obj_json valueForKey:@"cart_item_id"];
-                            if([_id isEqualToString:item_id])
-                            {
-                                [self updateItemJson:nil atIndexPath:indexPath];
-                                ready_break = YES;
-                                break;
-                            }
-                        }
-                        if (ready_break) {
-                            break;
-                        }
-                        
-                        
-                    }
-                    
-                } else {
-                    
-                    for(int i=0;i<self.content_arr.count;i++)
-                    {
-                        NSDictionary* obj_json = self.content_arr[i];
+                NSInteger section_count = [self sectionCount];
+                for (int i = 0; i < section_count; i++) {
+                    NSInteger item_count = [self itemCountInSection:i];
+                    BOOL ready_break = NO;
+                    for (int j = 0; j < item_count; j++) {
+                        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
+                        NSDictionary* obj_json = [self itemJsonAtIndexPath:indexPath];
                         NSString* _id =[obj_json valueForKey:@"cart_item_id"];
                         if([_id isEqualToString:item_id])
                         {
-                            //                        self.content_arr[i] = newitem;
-                            
-                            
-                            [self.content_arr removeObjectAtIndex:i];
-                            
+                            [self updateItemJson:nil atIndexPath:indexPath];
+                            ready_break = YES;
                             break;
-                            //                        [self.content_arr removeObjectAtIndex:i];
-                            //                        [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
-                            //                        appDelegate.cart_count--;
-                            //                        [appDelegate update_count_mark];
                         }
-                        
-                        
                     }
-                }
-                
-                AppDelegate *appDelegate =nil;
-                appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
-#ifdef OFFLINE_MODE
-                
-                if(appDelegate.offline_mode)
-                {
+                    if (ready_break) {
+                        break;
+                    }
                     
-                    [self ReloadData];
                     
                 }
-                else
-#endif
+                
+            } else {
+                
+                for(int i=0;i<self.content_arr.count;i++)
                 {
-                    
-                    if (self.back_order_flag) {
-                        [self ReloadData];
-                    } else {
-                        [self.content_arr insertObject:newitem atIndex:0];
+                    NSDictionary* obj_json = self.content_arr[i];
+                    NSString* _id =[obj_json valueForKey:@"cart_item_id"];
+                    if([_id isEqualToString:item_id])
+                    {
+                        //                        self.content_arr[i] = newitem;
                         
-                        [self.itemListTable reloadData];
-                        [self refresh_total];
+                        
+                        [self.content_arr removeObjectAtIndex:i];
+                        
+                        break;
+                        //                        [self.content_arr removeObjectAtIndex:i];
+                        //                        [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
+                        //                        appDelegate.cart_count--;
+                        //                        [appDelegate update_count_mark];
                     }
                     
+                    
                 }
+            }
+            
+            AppDelegate *appDelegate =nil;
+            appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+#ifdef OFFLINE_MODE
+            
+            if(appDelegate.offline_mode)
+            {
                 
-                //                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                
-                
-                
-                
-#ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-#else
-                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-#endif
-                
+                [self ReloadData];
                 
             }
             else
+#endif
             {
                 
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                if (self.back_order_flag) {
+                    [self ReloadData];
+                } else {
+                    [self.content_arr insertObject:newitem atIndex:0];
+                    
+                    [self.itemListTable reloadData];
+                    [self refresh_total];
+                }
+                
             }
             
+            //                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
             
             
             
-        });
-    });
+            
+#ifdef RA_NOTIFICATION
+            [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+            [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+#endif
+            
+            
+        }
+        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: modelname withScreen:ScreenCodeCart];
+//        
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            
+//            
+//            
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//                NSDictionary* newitem = [return_json objectForKey:@"item_0"];
+//                NSString* item_id = [newitem valueForKey:@"cart_item_id"];
+//                //  bool isnew=false;
+////
+//                //                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+//                
+//                if (self.back_order_flag) {
+//                    
+//                    NSInteger section_count = [self sectionCount];
+//                    for (int i = 0; i < section_count; i++) {
+//                        NSInteger item_count = [self itemCountInSection:i];
+//                        BOOL ready_break = NO;
+//                        for (int j = 0; j < item_count; j++) {
+//                            NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
+//                            NSDictionary* obj_json = [self itemJsonAtIndexPath:indexPath];
+//                            NSString* _id =[obj_json valueForKey:@"cart_item_id"];
+//                            if([_id isEqualToString:item_id])
+//                            {
+//                                [self updateItemJson:nil atIndexPath:indexPath];
+//                                ready_break = YES;
+//                                break;
+//                            }
+//                        }
+//                        if (ready_break) {
+//                            break;
+//                        }
+//                        
+//                        
+//                    }
+//                    
+//                } else {
+//                    
+//                    for(int i=0;i<self.content_arr.count;i++)
+//                    {
+//                        NSDictionary* obj_json = self.content_arr[i];
+//                        NSString* _id =[obj_json valueForKey:@"cart_item_id"];
+//                        if([_id isEqualToString:item_id])
+//                        {
+//                            //                        self.content_arr[i] = newitem;
+//                            
+//                            
+//                            [self.content_arr removeObjectAtIndex:i];
+//                            
+//                            break;
+//                            //                        [self.content_arr removeObjectAtIndex:i];
+//                            //                        [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
+//                            //                        appDelegate.cart_count--;
+//                            //                        [appDelegate update_count_mark];
+//                        }
+//                        
+//                        
+//                    }
+//                }
+//                
+//                AppDelegate *appDelegate =nil;
+//                appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+//#ifdef OFFLINE_MODE
+//                
+//                if(appDelegate.offline_mode)
+//                {
+//                    
+//                    [self ReloadData];
+//                    
+//                }
+//                else
+//#endif
+//                {
+//                    
+//                    if (self.back_order_flag) {
+//                        [self ReloadData];
+//                    } else {
+//                        [self.content_arr insertObject:newitem atIndex:0];
+//                        
+//                        [self.itemListTable reloadData];
+//                        [self refresh_total];
+//                    }
+//                    
+//                }
+//                
+//                //                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                
+//                
+//                
+//                
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//                
+//                
+//            }
+//            else
+//            {
+//                
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//            }
+//            
+//            
+//            
+//            
+//        });
+//    });
     
     
 }

+ 53 - 29
RedAnt ERP Mobile/common/Functions/cart/ItemNotesViewController.m

@@ -62,38 +62,62 @@
     
     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Update Item Notes"];
     
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_update_cartitemnote:self.cart_id notes:self.tv_notes.text completionHandler:^(NSMutableDictionary *result) {
         
-        NSDictionary* cart_json = nil;
-
+        NSDictionary* cart_json = result;
+        [waitalert dismissViewControllerAnimated:YES completion:nil];
+        if([[cart_json valueForKey:@"result"] intValue]==2)
+        {
+            [self dismissViewControllerAnimated:NO
+                                     completion:^{
+                                         if(self.onSaveNote)
+                                             
+                                             self.onSaveNote(self.notes);
+                                         
+                                     }];
+        }
+        else
+        {
+            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update Item Notes" controller:self] ;
+        }
         
-
-        cart_json = [RANetwork cart_setItemNote:self.cart_id notes:self.tv_notes.text];
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            
-            
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            if([[cart_json valueForKey:@"result"] intValue]==2)
-            {
-                [self dismissViewControllerAnimated:NO
-                                         completion:^{
-                                             if(self.onSaveNote)
-                                                 
-                                                 self.onSaveNote(self.notes);
-                                             
-                                         }];
-            }
-            else
-            {
-                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update Item Notes" controller:self] ;
-            }
-            
-            
-            
-            
-        });
-    });
+        
+        
+    }];
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* cart_json = nil;
+//
+//
+//
+//        cart_json = [RANetwork cart_setItemNote:self.cart_id notes:self.tv_notes.text];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//            if([[cart_json valueForKey:@"result"] intValue]==2)
+//            {
+//                [self dismissViewControllerAnimated:NO
+//                                         completion:^{
+//                                             if(self.onSaveNote)
+//
+//                                                 self.onSaveNote(self.notes);
+//
+//                                         }];
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update Item Notes" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 
 /*

+ 138 - 73
RedAnt ERP Mobile/common/Functions/cart/ModelItemCell.m

@@ -172,31 +172,54 @@
 //    NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(calculate) object:nil];
 //    // 启动
 //    [thread start];
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
     
-                NSDictionary* cart_json = [RANetwork cart_setQTY:self.cart_id value:self.pre_val];
-    
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    self.totalchange=0;
-                    if([[cart_json valueForKey:@"result"] intValue]==2)
-                    {
-                        if(self.onReturnQTY)
-                            self.onReturnQTY(self.pre_val,cart_json);
-    //                    if (self.delegate && [self.delegate respondsToSelector:@selector(returnQTY:)]) {
-    //                        [self.delegate returnQTY:sender.value ];
-    //                    }
-                    }
-                    else
-                    {
-                        UIViewController* vc=[RAUtils getViewController :self];
-                        [((CartViewController *)vc).itemListTable reloadData];
-                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Change Model Count" controller:vc] ;
-                    }
-                    
+    [RANetwork request_update_cartqty:self.cart_id value:self.pre_val completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* cart_json =result;
+        self.totalchange=0;
+        if([[cart_json valueForKey:@"result"] intValue]==2)
+        {
+            if(self.onReturnQTY)
+                self.onReturnQTY(self.pre_val,cart_json);
+            //                    if (self.delegate && [self.delegate respondsToSelector:@selector(returnQTY:)]) {
+            //                        [self.delegate returnQTY:sender.value ];
+            //                    }
+        }
+        else
+        {
+            UIViewController* vc=[RAUtils getViewController :self];
+            [((CartViewController *)vc).itemListTable reloadData];
+            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Change Model Count" controller:vc] ;
+        }
+        
+        
+        
+    }];
     
-                    
-                });
-            });
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSDictionary* cart_json = [RANetwork cart_setQTY:self.cart_id value:self.pre_val];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//                    self.totalchange=0;
+//                    if([[cart_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        if(self.onReturnQTY)
+//                            self.onReturnQTY(self.pre_val,cart_json);
+//    //                    if (self.delegate && [self.delegate respondsToSelector:@selector(returnQTY:)]) {
+//    //                        [self.delegate returnQTY:sender.value ];
+//    //                    }
+//                    }
+//                    else
+//                    {
+//                        UIViewController* vc=[RAUtils getViewController :self];
+//                        [((CartViewController *)vc).itemListTable reloadData];
+//                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Change Model Count" controller:vc] ;
+//                    }
+//
+//
+//
+//                });
+//            });
     
     
 }
@@ -407,32 +430,54 @@
                 
                 
                 
-                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                [RANetwork request_update_cartqty:self.cart_id value:qty completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* cart_json =result;
+                    if([[cart_json valueForKey:@"result"] intValue]==2)
+                    {
+                        //                if (self.delegate && [self.delegate respondsToSelector:@selector(returnQTY:)]) {
+                        //                    [self.delegate returnQTY:qty];
+                        //                }
+                        
+                        if(self.onReturnQTY)
+                            self.onReturnQTY(qty,cart_json);
+                    }
+                    else
+                    {
+                        UIViewController* vc=[RAUtils getViewController :self];
+                        [((CartViewController *)vc).itemListTable reloadData];
+                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Change Model Count" controller:vc] ;
+                    }
                     
-                    NSDictionary* cart_json = [RANetwork cart_setQTY:self.cart_id value:qty];
                     
-                    dispatch_async(dispatch_get_main_queue(), ^{
-                        
-                        if([[cart_json valueForKey:@"result"] intValue]==2)
-                        {
-                            //                if (self.delegate && [self.delegate respondsToSelector:@selector(returnQTY:)]) {
-                            //                    [self.delegate returnQTY:qty];
-                            //                }
-                            
-                            if(self.onReturnQTY)
-                                self.onReturnQTY(qty,cart_json);
-                        }
-                        else
-                        {
-                            UIViewController* vc=[RAUtils getViewController :self];
-                            [((CartViewController *)vc).itemListTable reloadData];
-                            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Change Model Count" controller:vc] ;
-                        }
-                        
-                        
-                        
-                    });
-                });
+                    
+                }];
+                
+//                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                    NSDictionary* cart_json = [RANetwork cart_setQTY:self.cart_id value:qty];
+//
+//                    dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                        if([[cart_json valueForKey:@"result"] intValue]==2)
+//                        {
+//                            //                if (self.delegate && [self.delegate respondsToSelector:@selector(returnQTY:)]) {
+//                            //                    [self.delegate returnQTY:qty];
+//                            //                }
+//
+//                            if(self.onReturnQTY)
+//                                self.onReturnQTY(qty,cart_json);
+//                        }
+//                        else
+//                        {
+//                            UIViewController* vc=[RAUtils getViewController :self];
+//                            [((CartViewController *)vc).itemListTable reloadData];
+//                            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Change Model Count" controller:vc] ;
+//                        }
+//
+//
+//
+//                    });
+//                });
 
             }];
             
@@ -456,34 +501,54 @@
         {
             [self set_Count:qty];
             
-            
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            [RANetwork request_update_cartqty:self.cart_id value:qty completionHandler:^(NSMutableDictionary *result) {
+                NSDictionary* cart_json =result;
+                if([[cart_json valueForKey:@"result"] intValue]==2)
+                {
+                    //                if (self.delegate && [self.delegate respondsToSelector:@selector(returnQTY:)]) {
+                    //                    [self.delegate returnQTY:qty];
+                    //                }
+                    
+                    if(self.onReturnQTY)
+                        self.onReturnQTY(qty,cart_json);
+                }
+                else
+                {
+                    UIViewController* vc=[RAUtils getViewController :self];
+                    [((CartViewController *)vc).itemListTable reloadData];
+                    [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Change Model Count" controller:vc] ;
+                }
                 
-                NSDictionary* cart_json = [RANetwork cart_setQTY:self.cart_id value:qty];
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
-                    if([[cart_json valueForKey:@"result"] intValue]==2)
-                    {
-                        //                if (self.delegate && [self.delegate respondsToSelector:@selector(returnQTY:)]) {
-                        //                    [self.delegate returnQTY:qty];
-                        //                }
-                        
-                        if(self.onReturnQTY)
-                            self.onReturnQTY(qty,cart_json);
-                    }
-                    else
-                    {
-                        UIViewController* vc=[RAUtils getViewController :self];
-                        [((CartViewController *)vc).itemListTable reloadData];
-                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Change Model Count" controller:vc] ;
-                    }
-                    
-                    
-                    
-                });
-            });
+                
+            }];
+            
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSDictionary* cart_json = [RANetwork cart_setQTY:self.cart_id value:qty];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                    if([[cart_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        //                if (self.delegate && [self.delegate respondsToSelector:@selector(returnQTY:)]) {
+//                        //                    [self.delegate returnQTY:qty];
+//                        //                }
+//
+//                        if(self.onReturnQTY)
+//                            self.onReturnQTY(qty,cart_json);
+//                    }
+//                    else
+//                    {
+//                        UIViewController* vc=[RAUtils getViewController :self];
+//                        [((CartViewController *)vc).itemListTable reloadData];
+//                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Change Model Count" controller:vc] ;
+//                    }
+//
+//
+//
+//                });
+//            });
 
         }
         

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

@@ -767,17 +767,98 @@
     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Add Models To Cart"];
     
     
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    if (self.addAll) {
+        AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
         
-        NSDictionary* return_json = nil;
-        if (self.addAll) {
-            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-            return_json = [RANetwork Category_addall:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:self.offset limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip orderCode:appDelegate.order_code  addTo:@"cart"];
-        } else {
-            return_json = [RANetwork add_toCart_byName:ids withScreen:ScreenCodeCategory];
-        }
+        [RANetwork request_addall_category:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:self.offset limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip 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;
+                    
+#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] ;
+            }
+            
+            
+            
+            
+            
+            
+        }];
         
-        dispatch_async(dispatch_get_main_queue(), ^{
+        
+    } else {
+        [RANetwork request_addto_cart_byname:ids withScreen:ScreenCodeCategory completionHandler:^(NSMutableDictionary *result) {
+            
+            NSDictionary* return_json = result;
             
             [waitalert dismissViewControllerAnimated:YES completion:nil];
             self.addCartBtn.enabled = true;
@@ -793,7 +874,7 @@
                     
                     
                     //      NSString* order_code = [return_json valueForKey:@"order_code"];
-
+                    
                     //                    appDelegate.order_code = order_code;
                     
 #ifdef RA_NOTIFICATION
@@ -809,7 +890,7 @@
                         
                         unsigned long checkedCount = [return_json[@"count"] integerValue];
                         
-                         msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
+                        msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
                     } else {
                         
                         if(checked.count==1)
@@ -820,7 +901,7 @@
                         {
                             msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
                         }
-
+                        
                         
                     }
                     [RAUtils message_alert:nil title:msg controller:self] ;
@@ -833,7 +914,7 @@
             }
             else  if([[return_json valueForKey:@"result"] intValue]==8)
             {
-
+                
                 
 #ifdef RA_NOTIFICATION
                 [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
@@ -855,8 +936,104 @@
             
             
             
-        });
-    });
+            
+            
+        }];
+        
+    }
+    
+    
+    
+//    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 Category_addall:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:self.offset limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip orderCode:appDelegate.order_code  addTo:@"cart"];
+//        } else {
+//            return_json = [RANetwork add_toCart_byName:ids withScreen:ScreenCodeCategory];
+//        }
+//
+//        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;
+//
+//#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
 {
@@ -906,73 +1083,195 @@
     
     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 Category_addall:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:self.offset limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip orderCode:nil  addTo:@"portfolio"];
-        } else {
-            return_json = [RANetwork add_toPortfolio:ids withScreen:ScreenCodeCategory];
-        }
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            self.addPortfolioBtn.enabled =true;
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                //                int result=[[return_json valueForKey:@"result"] intValue];
-                //                if(result==2)
-                //                {
-                //                    //successed.
-                
-                
-                
-                
-                #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) {
+    
+            if (self.addAll) {
+    //            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+                [RANetwork request_addall_category:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:self.offset limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip orderCode:nil  addTo:@"portfolio" completionHandler:^(NSMutableDictionary *result) {
                     
-                    unsigned long checkedCount = [return_json[@"count"] integerValue];
+                    NSDictionary* return_json = result;
+                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    self.addPortfolioBtn.enabled =true;
                     
-                    msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
-                } else {
-                
-                    if(checked.count==1)
+                    if([[return_json valueForKey:@"result"] intValue]==2)
                     {
-                        msg=@"1 item added to Portfolio";
+                        //                int result=[[return_json valueForKey:@"result"] intValue];
+                        //                if(result==2)
+                        //                {
+                        //                    //successed.
+                        
+                        
+                        
+                        
+                        #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 {
+                [RANetwork request_addto_portfolio:ids withScreen:ScreenCodeCategory completionHandler:^(NSMutableDictionary *result) {
+                    
+                    NSDictionary* return_json = result;
+                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    self.addPortfolioBtn.enabled =true;
+                    
+                    if([[return_json valueForKey:@"result"] intValue]==2)
+                    {
+                        //                int result=[[return_json valueForKey:@"result"] intValue];
+                        //                if(result==2)
+                        //                {
+                        //                    //successed.
+                        
+                        
+                        
+                        
+                        #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] ;
+                    }
+                    
+                    
+                    
+                    
+                }];
+               
             }
-            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 Category_addall:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:self.offset limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip orderCode:nil  addTo:@"portfolio"];
+//        } else {
+//            return_json = [RANetwork add_toPortfolio:ids withScreen:ScreenCodeCategory];
+//        }
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//            self.addPortfolioBtn.enabled =true;
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//                //                int result=[[return_json valueForKey:@"result"] intValue];
+//                //                if(result==2)
+//                //                {
+//                //                    //successed.
+//
+//
+//
+//
+//                #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
 {
@@ -1009,21 +1308,10 @@
     
     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) {
-            return_json = [RANetwork Category_addall:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:self.offset limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip orderCode:nil  addTo:@"wishlist"];
-        } else {
-            return_json = [RANetwork add_toWatchList:ids withScreen:ScreenCodeCategory];
-        }
-
-        
+    if (self.addAll) {
         
-        dispatch_async(dispatch_get_main_queue(), ^{
+        [RANetwork request_addall_category:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:self.offset limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip orderCode:nil  addTo:@"wishlist" completionHandler:^(NSMutableDictionary *result) {
+            NSDictionary* return_json = result;
             [waitalert dismissViewControllerAnimated:YES completion:nil];
             self.addWishBtn.enabled =true;
             
@@ -1033,7 +1321,7 @@
                 //successed.
                 
                 //                    NSString* order_code = [return_json valueForKey:@"order_code"];
-
+                
                 
 #ifdef RA_NOTIFICATION
                 [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
@@ -1051,7 +1339,7 @@
                     
                     msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
                 } else {
-                
+                    
                     if(checked.count==1)
                     {
                         msg=@"1 item added to \nWish List";
@@ -1077,8 +1365,140 @@
             
             
             
-        });
-    });
+        }];
+        
+        
+        
+    } else {
+        
+        [RANetwork request_addto_wishlist:ids withScreen:ScreenCodeCategory completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* return_json = result;
+                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    self.addWishBtn.enabled =true;
+                    
+                    if([[return_json valueForKey:@"result"] intValue]==2)
+                    {
+                        
+                        //successed.
+                        
+                        //                    NSString* order_code = [return_json valueForKey:@"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 \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] ;
+                    }
+                    
+                    
+                    
+                    
+                }];
+        
+        
+    }
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//
+//        NSDictionary* return_json = nil;
+//        if (self.addAll) {
+//            return_json = [RANetwork Category_addall:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:self.offset limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip orderCode:nil  addTo:@"wishlist"];
+//        } else {
+//            return_json = [RANetwork add_toWatchList:ids withScreen:ScreenCodeCategory];
+//        }
+//
+//
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//            self.addWishBtn.enabled =true;
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//                //successed.
+//
+//                //                    NSString* order_code = [return_json valueForKey:@"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 \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] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 #pragma mark get data
 -(void)operation_loadMore

+ 143 - 63
RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m

@@ -1887,88 +1887,168 @@
     
     
     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Saving Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_save_order:upparams completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* editor_json =result;
         
-        NSDictionary* editor_json = [RANetwork save_Order:upparams];
+        [waitalert dismissViewControllerAnimated:YES completion:nil];
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
+        
+        if([[editor_json valueForKey:@"result"] intValue]==2)
+        {
+            
+            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
             
             
-            if([[editor_json valueForKey:@"result"] intValue]==2)
+            
+            NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
+            
+            
+            if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
             {
-                
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                
-                
-                
-                NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-                
-                
-                if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
-                {
                 appDelegate.customerInfo = customerInfo;
                 appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
-                }
-                NSString *msg = nil;
-                if ([editor_json objectForKey:@"so#"]) {
-                    msg = [@"SO#:" stringByAppendingString:[editor_json objectForKey:@"so#"]];
-                }
-                [RAUtils message_alert:msg title:@"Order Saved" controller:self] ;
+            }
+            NSString *msg = nil;
+            if ([editor_json objectForKey:@"so#"]) {
+                msg = [@"SO#:" stringByAppendingString:[editor_json objectForKey:@"so#"]];
+            }
+            [RAUtils message_alert:msg title:@"Order Saved" controller:self] ;
+            
+            if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+            {
+                [((MainViewController*)appDelegate.main_vc) Loginout:false];
+                [self prepareReturn:nil];
+                [self.navigationController popViewControllerAnimated:true];
+            }
+            else{
+                
                 
-                if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
-                {
-                    [((MainViewController*)appDelegate.main_vc) Loginout:false];
-                    [self prepareReturn:nil];
-                    [self.navigationController popViewControllerAnimated:true];
-                }
-                else{
-                    
-                    
 #ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                    
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-                }
+            }
+            
+            if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
                 
-                if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
-                    
-                    if (![Singleton sharedInstance].currentOrderIsMerged) {
-                        [self releaseOrderAfterSave];
-                    }
-                    
-                    
+                if (![Singleton sharedInstance].currentOrderIsMerged) {
+                    [self releaseOrderAfterSave];
                 }
                 
                 
-                //                if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
-                //                    appDelegate.order_code = nil;
-                //
-                //                }
-                //    //     self.labelContact.text=appDelegate.contact_name;
-                //
-                //    NSDictionary * customerinfo = appDelegate.customerInfo;
-                // [self prepareReturn:nil];
-                //                [self.navigationController dismissViewControllerAnimated:true completion:^{
-                //
-                //
-                //                    ;
-                //                }];
-                
-            }
-            else
-            {
-                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
             }
             
             
+            //                if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
+            //                    appDelegate.order_code = nil;
+            //
+            //                }
+            //    //     self.labelContact.text=appDelegate.contact_name;
+            //
+            //    NSDictionary * customerinfo = appDelegate.customerInfo;
+            // [self prepareReturn:nil];
+            //                [self.navigationController dismissViewControllerAnimated:true completion:^{
+            //
+            //
+            //                    ;
+            //                }];
             
-            
-        });
-    });
+        }
+        else
+        {
+            [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
+        }
+        
+        
+        
+        
+        
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* editor_json = [RANetwork save_Order:upparams];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//
+//            if([[editor_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//
+//
+//
+//                NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
+//
+//
+//                if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+//                {
+//                appDelegate.customerInfo = customerInfo;
+//                appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
+//                }
+//                NSString *msg = nil;
+//                if ([editor_json objectForKey:@"so#"]) {
+//                    msg = [@"SO#:" stringByAppendingString:[editor_json objectForKey:@"so#"]];
+//                }
+//                [RAUtils message_alert:msg title:@"Order Saved" controller:self] ;
+//
+//                if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+//                {
+//                    [((MainViewController*)appDelegate.main_vc) Loginout:false];
+//                    [self prepareReturn:nil];
+//                    [self.navigationController popViewControllerAnimated:true];
+//                }
+//                else{
+//
+//
+//#ifdef RA_NOTIFICATION
+//                    [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//                }
+//
+//                if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
+//
+//                    if (![Singleton sharedInstance].currentOrderIsMerged) {
+//                        [self releaseOrderAfterSave];
+//                    }
+//
+//
+//                }
+//
+//
+//                //                if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
+//                //                    appDelegate.order_code = nil;
+//                //
+//                //                }
+//                //    //     self.labelContact.text=appDelegate.contact_name;
+//                //
+//                //    NSDictionary * customerinfo = appDelegate.customerInfo;
+//                // [self prepareReturn:nil];
+//                //                [self.navigationController dismissViewControllerAnimated:true completion:^{
+//                //
+//                //
+//                //                    ;
+//                //                }];
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
     
 }
 

+ 147 - 65
RedAnt ERP Mobile/common/Functions/order/RAOrderPreviewController.m

@@ -1868,89 +1868,171 @@
     
     
     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Saving Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    
+    [RANetwork request_save_order:upparams completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* editor_json =result;
         
-        NSDictionary* editor_json = [RANetwork save_Order:upparams];
+        [waitalert dismissViewControllerAnimated:YES completion:nil];
+        //            [waitalert dismissViewControllerAnimated:YES completion:nil];
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+        
+        if([[editor_json valueForKey:@"result"] intValue]==2)
+        {
             
+            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
             
-            if([[editor_json valueForKey:@"result"] intValue]==2)
+            
+            
+            NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
+            
+            
+            if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
             {
+                appDelegate.customerInfo = customerInfo;
+                appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
+            }
+            NSString *msg = nil;
+            if ([editor_json objectForKey:@"so#"]) {
+                msg = [@"SO#:" stringByAppendingString:[editor_json objectForKey:@"so#"]];
+            }
+            [RAUtils message_alert:msg title:@"Order Saved" controller:self] ;
+            
+            if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+            {
+                [((MainViewController*)appDelegate.main_vc) Loginout:false];
+                [self prepareReturn:nil];
+                [self.navigationController popToRootViewControllerAnimated:true];
+            }
+            else{
                 
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                
-                
-                
-                NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-                
-                
-                if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
-                {
-                    appDelegate.customerInfo = customerInfo;
-                    appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
-                }
-                NSString *msg = nil;
-                if ([editor_json objectForKey:@"so#"]) {
-                    msg = [@"SO#:" stringByAppendingString:[editor_json objectForKey:@"so#"]];
-                }
-                [RAUtils message_alert:msg title:@"Order Saved" controller:self] ;
                 
-                if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
-                {
-                    [((MainViewController*)appDelegate.main_vc) Loginout:false];
-                    [self prepareReturn:nil];
-                    [self.navigationController popToRootViewControllerAnimated:true];
-                }
-                else{
-                    
-                    
 #ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                    
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-                }
+            }
+            
+            if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
                 
-                if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
-                    
-                    if (![Singleton sharedInstance].currentOrderIsMerged) {
-                        [self releaseOrderAfterSave];
-                    }
-                    
-                    
+                if (![Singleton sharedInstance].currentOrderIsMerged) {
+                    [self releaseOrderAfterSave];
                 }
                 
                 
-                //                if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
-                //                    appDelegate.order_code = nil;
-                //
-                //                }
-                //    //     self.labelContact.text=appDelegate.contact_name;
-                //
-                //    NSDictionary * customerinfo = appDelegate.customerInfo;
-                // [self prepareReturn:nil];
-                //                [self.navigationController dismissViewControllerAnimated:true completion:^{
-                //
-                //
-                //                    ;
-                //                }];
-                
-            }
-            else
-            {
-                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
             }
             
             
+            //                if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
+            //                    appDelegate.order_code = nil;
+            //
+            //                }
+            //    //     self.labelContact.text=appDelegate.contact_name;
+            //
+            //    NSDictionary * customerinfo = appDelegate.customerInfo;
+            // [self prepareReturn:nil];
+            //                [self.navigationController dismissViewControllerAnimated:true completion:^{
+            //
+            //
+            //                    ;
+            //                }];
             
-            
-        });
-    });
+        }
+        else
+        {
+            [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
+        }
+        
+        
+        
+        
+        
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* editor_json = [RANetwork save_Order:upparams];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+////            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//
+//            if([[editor_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//
+//
+//
+//                NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
+//
+//
+//                if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+//                {
+//                    appDelegate.customerInfo = customerInfo;
+//                    appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
+//                }
+//                NSString *msg = nil;
+//                if ([editor_json objectForKey:@"so#"]) {
+//                    msg = [@"SO#:" stringByAppendingString:[editor_json objectForKey:@"so#"]];
+//                }
+//                [RAUtils message_alert:msg title:@"Order Saved" controller:self] ;
+//
+//                if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+//                {
+//                    [((MainViewController*)appDelegate.main_vc) Loginout:false];
+//                    [self prepareReturn:nil];
+//                    [self.navigationController popToRootViewControllerAnimated:true];
+//                }
+//                else{
+//
+//
+//#ifdef RA_NOTIFICATION
+//                    [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//                }
+//
+//                if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
+//
+//                    if (![Singleton sharedInstance].currentOrderIsMerged) {
+//                        [self releaseOrderAfterSave];
+//                    }
+//
+//
+//                }
+//
+//
+//                //                if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
+//                //                    appDelegate.order_code = nil;
+//                //
+//                //                }
+//                //    //     self.labelContact.text=appDelegate.contact_name;
+//                //
+//                //    NSDictionary * customerinfo = appDelegate.customerInfo;
+//                // [self prepareReturn:nil];
+//                //                [self.navigationController dismissViewControllerAnimated:true completion:^{
+//                //
+//                //
+//                //                    ;
+//                //                }];
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
     
 }
 

+ 11 - 7
RedAnt ERP Mobile/common/data_provider/RANetwork.h

@@ -74,20 +74,20 @@ extern NSString *const ScreenCodeOfflineSync;
 //+(NSDictionary*)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 ;
 
 //+(bool) IsNetworkAvailable;
-+(int)parse_authinfo : (NSData *) json user:(NSString*) user password:(NSString*) password;
+//+(int)parse_authinfo : (NSData *) json user:(NSString*) user password:(NSString*) password;
 
 
 
 //+(NSDictionary*)request_ItemDetail: (NSString* ) item_id model_name:(NSString*) model_name category_id:(NSString*) category_id use_name :(bool) use_name groupName:(NSString *)groupName;
 
-+(NSDictionary*) cart_incresement:(NSString*) cart_id increse:(bool) increse;
-+(NSDictionary*) cart_setQTY:(NSString*) cart_id value:(int) value;
+//+(NSDictionary*) cart_incresement:(NSString*) cart_id increse:(bool) increse;
+//+(NSDictionary*) cart_setQTY:(NSString*) cart_id value:(int) value;
 +(NSDictionary*) cart_setPrice:(NSString*) cart_id price:(float) price discount:(float) discount notes:(NSString*) notes;
 +(NSDictionary*) cart_setFree:(NSString*) cart_id isfree:(bool) isfree;
 
-+(NSDictionary*) cart_setItemNote:(NSString*) cart_id notes:(NSString*) notes;
+//+(NSDictionary*) cart_setItemNote:(NSString*) cart_id notes:(NSString*) notes;
 
-+(NSDictionary*) cart_setGeneralNote:(NSString*) order_code notes:(NSString*) notes;
+//+(NSDictionary*) cart_setGeneralNote:(NSString*) order_code notes:(NSString*) notes;
 
 +(NSDictionary*) check_Offline:(NSString* )ver  useInternalAddress:(bool)buseinternaladdress vid:(NSString*) vid;
 +(NSDictionary*) download_Offline:(NSString* )vid;
@@ -118,7 +118,7 @@ extern NSString *const ScreenCodeOfflineSync;
 //+(NSDictionary*) new_Order;
 //+(NSDictionary*)open_Order:(NSString*) order_code;
 +(NSDictionary*)release_Order:(NSString*) order_code withScreen:(NSString *)screenName;
-+(NSDictionary*)save_Order:(NSMutableDictionary*)params;
+//+(NSDictionary*)save_Order:(NSMutableDictionary*)params;
 +(NSDictionary*)delete_Order:(NSString*) order_id;
 +(NSDictionary*)cancel_Order:(NSString*) order_id order_code:(NSString*) order_code;
 //+(NSDictionary*)request_PendingOrder:(NSString* ) contactid;
@@ -146,7 +146,7 @@ extern NSString *const ScreenCodeOfflineSync;
 +(NSDictionary*)direct_save_TearSheet:(NSMutableDictionary*)params;//(NSString*) request_url name:(NSString*)name delete:(NSString* )ids note:(NSString* )saveNote modelIds:(NSDictionary *)modelIds;
 
 
-+(NSDictionary*)Category_addall: (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;
+//+(NSDictionary*)Category_addall: (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;
 //+(NSDictionary*)category_addall2wish: (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;
 //+(NSDictionary*)category_addall2portfolio: (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;
 
@@ -234,4 +234,8 @@ extern NSString *const ScreenCodeOfflineSync;
 +(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;
++(void)request_save_order:(NSMutableDictionary*)params completionHandler:(resultHandler)result;
++(void) request_update_cartqty:(NSString*) cart_id value:(int) value completionHandler:(resultHandler)result;
++(void) request_update_cartgeneralnote:(NSString*) order_code notes:(NSString*) notes completionHandler:(resultHandler)result;
++(void) request_update_cartitemnote:(NSString*) cart_id notes:(NSString*) notes completionHandler:(resultHandler)result;
 @end

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

@@ -8395,5 +8395,273 @@ NSString *const ScreenCodeOfflineSync = @"Offline Sync Screen";
 //    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
 //    return jsobj;
 
+}
+
++(void)request_save_order:(NSMutableDictionary*)params 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.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
+    //        [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
+    //    else
+    
+    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"];
+    
+    //    NSDictionary* customerinfo=nil;
+    
+    //    if(![[appDelegate.customerInfo valueForKey:@"customer_cid" ] isEqualToString: [appDelegate.customerInfo valueForKey:@"customer_cid" ]]&& appDelegate.order_customer_id!=nil)
+    //        [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
+    //    else
+    //        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+    //
+    //    appDelegate.customerInfo;
+    
+    //    NSArray* keys=[customerinfo allKeys];
+    //    for(int i=0;i<keys.count;i++)
+    //    {
+    //        [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
+    //    }
+    
+    //    [params setValue:sourceid forKey:@"sourceid"];
+    //    [params setValue:editor forKey:@"editor"];
+    
+    [params setObject:ScreenCodePlaceOrder forKey:kScreenName];
+    
+    
+        if(appDelegate.offline_mode)
+        {
+    
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                NSMutableDictionary* json = [[OLDataProvider offline_saveorder:params] mutableCopy];
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    result(json);
+                });
+            });
+    
+            return;
+        }
+    
+    
+        [self request_interface:URL_SAVE_ORDER parameters:params err_record_url:nil completionHandler:result retry:0];
+        
+    
+    
+//
+//    NSData* json=nil;
+//
+//    if(appDelegate.offline_mode)
+//    {
+//        json= [OLDataProvider offline_saveorder:params];
+//    }
+//    else
+//    {
+//    if(![self IsNetworkAvailable])
+//        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//
+//    json=[self get_json:URL_SAVE_ORDER parameters:params];
+//    }
+//    if(json!=nil)
+//    {
+//        NSError *error=nil;
+//        NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//        NSString *so = [jsobj valueForKey:@"so#"];
+//        if (so) {
+//            [appDelegate SetSo:so];
+//        }
+//        return jsobj;
+//    }
+//    else
+//        return nil;
+    
+}
+
++(void) request_update_cartqty:(NSString*) cart_id value:(int) value completionHandler:(resultHandler)result
+{
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+    AppDelegate *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:cart_id forKey:@"cartitem_id"];
+    
+    [params setObject:ScreenCodeCart forKey:kScreenName];
+    
+    [params setValue:[NSString stringWithFormat:@"%d",value] forKey:@"inputInt"];
+    
+    
+    
+    if(appDelegate.offline_mode)
+    {
+        
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            NSMutableDictionary* json = [[OLDataProvider offline_cartsetqty:params] mutableCopy];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                result(json);
+            });
+        });
+        
+        return;
+    }
+    
+    
+    [self request_interface:URL_CART_INCRESEMENT parameters:params err_record_url:nil completionHandler:result retry:0];
+    
+//    
+//    NSData* json=nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json= [OLDataProvider offline_cartsetqty:params];
+//    }
+//    else
+//    {
+//    if(![self IsNetworkAvailable])
+//        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//    
+//    json=[self get_json:URL_CART_INCRESEMENT parameters:params];
+//    }
+//    if(json==nil)
+//        return nil;
+//    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//    return jsobj;
+    
+}
++(void) request_update_cartgeneralnote:(NSString*) order_code notes:(NSString*) notes 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:order_code forKey:@"orderCode"];
+    
+    [params setObject:ScreenCodeCart forKey:kScreenName];
+    
+    if(notes.length==0)
+        notes=@"";
+    
+    
+    [params setValue:notes forKey:@"comments"];
+    
+       
+       if(appDelegate.offline_mode)
+       {
+           
+           dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+               NSMutableDictionary* json = [[OLDataProvider offline_updategnotes:params] mutableCopy];
+               dispatch_async(dispatch_get_main_queue(), ^{
+                   result(json);
+               });
+           });
+           
+           return;
+       }
+       
+       
+       [self request_interface:URL_CART_GENERAL_NOTES parameters:params err_record_url:nil completionHandler:result retry:0];
+       
+//    
+//    NSData* json=nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json= [OLDataProvider offline_updategnotes:params];
+//    }
+//    else
+//    {
+//    if(![self IsNetworkAvailable])
+//        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//    
+//     json=[self get_json:URL_CART_GENERAL_NOTES parameters:params];
+//    }
+//    if(json==nil)
+//        return nil;
+//    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//    return jsobj;
+}
++(void) request_update_cartitemnote:(NSString*) cart_id notes:(NSString*) notes 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:cart_id forKey:@"cartitem_id"];
+    
+    [params setObject:ScreenCodeCart forKey:kScreenName];
+    
+    if(notes.length==0)
+        notes=@"";
+    
+    
+    [params setValue:notes forKey:@"notes"];
+    
+
+    if(appDelegate.offline_mode)
+    {
+        
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            NSMutableDictionary* json = [[OLDataProvider offline_cartsetlnotes:params] mutableCopy];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                result(json);
+            });
+        });
+        
+        return;
+    }
+    
+    
+    [self request_interface:URL_CART_ITEM_NOTES parameters:params err_record_url:nil completionHandler:result retry:0];
+    
+    
+//    
+//    NSData* json=nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json= [OLDataProvider offline_cartsetlnotes:params];
+//    }
+//    else
+//    {
+//    if(![self IsNetworkAvailable])
+//        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//    
+//    json=[self get_json:URL_CART_ITEM_NOTES parameters:params];
+//    }
+//    if(json==nil)
+//        return nil;
+//    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//    return jsobj;
 }
 @end