فهرست منبع

新增ERP Mobile 删除pofolio item 数据访问接口,并修改相关调用。
新增ERP Mobile 删除pofolio pdf 数据访问接口,并修改相关调用。
新增ERP Mobile 删除wishlist item 数据访问接口,并修改相关调用。
新增ERP Mobile 删除cart item 数据访问接口,并修改相关调用。
新增ERP Mobile 创建订单数据访问接口,并修改相关调用。

Ray Zhang 6 سال پیش
والد
کامیت
dc9c1b3d70

+ 70 - 35
RedAnt ERP Mobile/common/CartUtils.m

@@ -19,43 +19,78 @@
 {
 {
 
 
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
-        NSDictionary* return_json = [RANetwork new_Order];
-
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-
-
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                int result=[[return_json valueForKey:@"result"] intValue];
-                if(result==2)
-                {
-                    //successed.
-
-                    NSString* order_code = [return_json valueForKey:@"orderCode"];
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    appDelegate.order_code = order_code;
-                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-
-                    [holder performSelector:addtocart];
-
-
-
-
-                }
-            }
-            else
+    [RANetwork request_create_order:^(NSMutableDictionary *result) {
+        NSMutableDictionary* return_json = result;
+        
+        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+        
+        
+        if([[return_json valueForKey:@"result"] intValue]==2)
+        {
+            int result=[[return_json valueForKey:@"result"] intValue];
+            if(result==2)
             {
             {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:vc] ;
+                //successed.
+                
+                NSString* order_code = [return_json valueForKey:@"orderCode"];
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                appDelegate.order_code = order_code;
+                appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+                
+                [holder performSelector:addtocart];
+                
+                
+                
+                
             }
             }
-
-
-
-
-        });
-    });
+        }
+        else
+        {
+            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:vc] ;
+        }
+        
+        
+        
+        
+        
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* return_json = [RANetwork new_Order];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//                int result=[[return_json valueForKey:@"result"] intValue];
+//                if(result==2)
+//                {
+//                    //successed.
+//
+//                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    appDelegate.order_code = order_code;
+//                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+//
+//                    [holder performSelector:addtocart];
+//
+//
+//
+//
+//                }
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:vc] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 }
 
 
 +(void) add_to_cart:(UIViewController*) vc selectorholder:(id)holder selector:(SEL)addtocart
 +(void) add_to_cart:(UIViewController*) vc selectorholder:(id)holder selector:(SEL)addtocart

+ 79 - 37
RedAnt ERP Mobile/common/Functions/MainViewController.m

@@ -2817,50 +2817,92 @@
 {
 {
     
     
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_create_order:^(NSMutableDictionary *result) {
+        NSMutableDictionary* return_json = result;
         
         
-        NSDictionary* return_json = [RANetwork new_Order];
+        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
         
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-            
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
+        
+        if([[return_json valueForKey:@"result"] intValue]==2)
+        {
+            int result=[[return_json valueForKey:@"result"] intValue];
+            if(result==2)
             {
             {
-                int result=[[return_json valueForKey:@"result"] intValue];
-                if(result==2)
-                {
-                    //successed.
-                    
-                    NSString* order_code = [return_json valueForKey:@"orderCode"];
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    appDelegate.order_code = order_code;
-                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-                    
-                    self.previous_VC = self.current_VC;
-                    [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-
-
+                //successed.
+                
+                NSString* order_code = [return_json valueForKey:@"orderCode"];
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                appDelegate.order_code = order_code;
+                appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+                
+                self.previous_VC = self.current_VC;
+                [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
+                
+                
 #ifdef RA_NOTIFICATION
 #ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
 #else
-                    [self reloadCart:true immediately:false];
-                    [self reloadOrder:true immediately:false];
+                [self reloadCart:true immediately:false];
+                [self reloadOrder:true immediately:false];
 #endif
 #endif
-                    
-                    
-                }
-            }
-            else
-            {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                
+                
             }
             }
-            
-            
-            
-            
-        });
-    });
+        }
+        else
+        {
+            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+        }
+        
+        
+        
+        
+        
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//        
+//        NSDictionary* return_json = [RANetwork new_Order];
+//        
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//            
+//            
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//                int result=[[return_json valueForKey:@"result"] intValue];
+//                if(result==2)
+//                {
+//                    //successed.
+//                    
+//                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    appDelegate.order_code = order_code;
+//                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+//                    
+//                    self.previous_VC = self.current_VC;
+//                    [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
+//                    
+//                    
+//#ifdef RA_NOTIFICATION
+//                    [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                    [self reloadCart:true immediately:false];
+//                    [self reloadOrder:true immediately:false];
+//#endif
+//                    
+//                    
+//                }
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//            }
+//            
+//            
+//            
+//            
+//        });
+//    });
 }
 }
 
 
 - (void)showPriceAuth:(NSInteger)from {
 - (void)showPriceAuth:(NSInteger)from {

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

@@ -590,44 +590,80 @@
 {
 {
     
     
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_create_order:^(NSMutableDictionary *result) {
+        NSMutableDictionary* return_json = result;
         
         
-        NSDictionary* return_json = [RANetwork new_Order];
+        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
         
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-            
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
+        
+        if([[return_json valueForKey:@"result"] intValue]==2)
+        {
+            int result=[[return_json valueForKey:@"result"] intValue];
+            if(result==2)
             {
             {
-                int result=[[return_json valueForKey:@"result"] intValue];
-                if(result==2)
-                {
-                    //successed.
-                    
-                    NSString* order_code = [return_json valueForKey:@"orderCode"];
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    appDelegate.order_code = order_code;
-                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-   
-                    
-                    [self addtocart];
-                    
+                //successed.
+                
+                NSString* order_code = [return_json valueForKey:@"orderCode"];
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                appDelegate.order_code = order_code;
+                appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+                
+                
+                [self addtocart];
+                
+                
                 
                 
-                    
-                }
-            }
-            else
-            {
-               
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
             }
             }
+        }
+        else
+        {
             
             
-            
-            
-            
-        });
-    });
+            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+        }
+        
+        
+        
+        
+        
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* return_json = [RANetwork new_Order];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//                int result=[[return_json valueForKey:@"result"] intValue];
+//                if(result==2)
+//                {
+//                    //successed.
+//
+//                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    appDelegate.order_code = order_code;
+//                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+//
+//
+//                    [self addtocart];
+//
+//
+//
+//                }
+//            }
+//            else
+//            {
+//
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 }
 -(void) addtocart
 -(void) addtocart
 {
 {

+ 235 - 108
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -129,39 +129,71 @@
         
         
         UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
         UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
             UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Remove Models From Cart"];
             UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Remove Models From Cart"];
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            
+            [RANetwork request_remove_cart:ids completionHandler:^(NSMutableDictionary *result) {
+                NSMutableDictionary* cart_json =result;
                 
                 
-                NSDictionary* cart_json = [RANetwork cart_remove:ids];
                 
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
+                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+                
+                if([[cart_json valueForKey:@"result"] intValue]==2)
+                {
+                    
+                    [self end_edit];
+                    
                     
                     
-                    [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
                     
                     
-                    if([[cart_json valueForKey:@"result"] intValue]==2)
-                    {
-                        
-                        [self end_edit];
-
-                        
-                        
 #ifdef RA_NOTIFICATION
 #ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"CartViewController,CategoryViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"CartViewController,CategoryViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
 #else
-                        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
-                        [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:true];
-                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
+                    [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:true];
+                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
 #endif
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
-                    }
-                    
-                    
-                    
-                });
-            });
+                }
+                else
+                {
+                    [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+                }
+                
+                
+                
+                
+            }];
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSDictionary* cart_json = [RANetwork cart_remove:ids];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                    [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//
+//                    if([[cart_json valueForKey:@"result"] intValue]==2)
+//                    {
+//
+//                        [self end_edit];
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                        [ActiveViewController Notify:@"CartViewController,CategoryViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+//                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
+//                        [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:true];
+//                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+//                    }
+//
+//
+//
+//                });
+//            });
             
             
             
             
         }];
         }];
@@ -327,38 +359,68 @@
     
     
     UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
     UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
         UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Remove Models From Cart"];
         UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Remove Models From Cart"];
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        [RANetwork request_remove_cart:ids completionHandler:^(NSMutableDictionary *result) {
+            NSMutableDictionary* cart_json =result;
             
             
-            NSDictionary* cart_json = [RANetwork cart_remove:ids];
             
             
-            dispatch_async(dispatch_get_main_queue(), ^{
+            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+            
+            if([[cart_json valueForKey:@"result"] intValue]==2)
+            {
+                
+                [self end_edit];
                 
                 
-                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
                 
                 
-                if([[cart_json valueForKey:@"result"] intValue]==2)
-                {
-                    
-                    [self end_edit];
-
-                    
 #ifdef RA_NOTIFICATION
 #ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"CartViewController,CategoryViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                [ActiveViewController Notify:@"CartViewController,CategoryViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
 #else
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
-                    [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:true];
-                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
+                [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:true];
+                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
 #endif
-                }
-                else
-                {
-                    [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
-                }
-                
-                
-                
-            });
-        });
+            }
+            else
+            {
+                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+            }
+            
+            
+            
+            
+        }];
+//        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//            NSDictionary* cart_json = [RANetwork cart_remove:ids];
+//
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//
+//                if([[cart_json valueForKey:@"result"] intValue]==2)
+//                {
+//
+//                    [self end_edit];
+//
+//
+//#ifdef RA_NOTIFICATION
+//                    [ActiveViewController Notify:@"CartViewController,CategoryViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
+//                    [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:true];
+//                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//                }
+//                else
+//                {
+//                    [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+//                }
+//
+//
+//
+//            });
+//        });
         
         
         
         
     }];
     }];
@@ -2848,76 +2910,141 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
             }
             }
             
             
             NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"cart_item_id"] intValue]];
             NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"cart_item_id"] intValue]];
-            
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            [RANetwork request_remove_cart:ids completionHandler:^(NSMutableDictionary *result) {
+                NSMutableDictionary* cart_json = result;
                 
                 
-                NSDictionary* cart_json = [RANetwork cart_remove:ids];
                 
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
-                    
-                    
-                    if([[cart_json valueForKey:@"result"] intValue]==2)
-                    {
-                        //  AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        if (self.back_order_flag) {
-                            
-                            NSInteger section_count = [self sectionCount];
-                            for (int i = 0; i < section_count; i++) {
-                                NSInteger item_count = [self itemCountInSection:i];
-                                BOOL ready_break = NO;
-                                
-                                for (int j = 0; j < item_count; j++) {
-                                    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
-                                    NSDictionary* obj_json = [self itemJsonAtIndexPath:indexPath];
-                                    NSString* _id =[obj_json valueForKey:@"cart_item_id"];
-                                    if([_id isEqualToString:ids])
-                                    {
-                                        [self updateItemJson:nil atIndexPath:indexPath];
-                                        ready_break = YES;
-                                        break;
-                                    }
-                                }
-                                
-                                if (ready_break) {
-                                    break;
-                                }
-                            }
+                
+                
+                if([[cart_json valueForKey:@"result"] intValue]==2)
+                {
+                    //  AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    if (self.back_order_flag) {
+                        
+                        NSInteger section_count = [self sectionCount];
+                        for (int i = 0; i < section_count; i++) {
+                            NSInteger item_count = [self itemCountInSection:i];
+                            BOOL ready_break = NO;
                             
                             
-                        } else {
-                            for(int i=0;i<self.content_arr.count;i++)
-                            {
-                                NSDictionary* obj_json = self.content_arr[i];
+                            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"];
                                 NSString* _id =[obj_json valueForKey:@"cart_item_id"];
                                 if([_id isEqualToString:ids])
                                 if([_id isEqualToString:ids])
                                 {
                                 {
-                                    [self.content_arr removeObjectAtIndex:i];
-                                    //  [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:self.indexPath] withRowAnimation:UITableViewRowAnimationLeft];
+                                    [self updateItemJson:nil atIndexPath:indexPath];
+                                    ready_break = YES;
                                     break;
                                     break;
-                                    // appDelegate.cart_count--;
-                                    // [appDelegate update_count_mark];
                                 }
                                 }
-                                
+                            }
+                            
+                            if (ready_break) {
+                                break;
                             }
                             }
                         }
                         }
-                        [self.itemListTable reloadData];
-                        [self refresh_total];
+                        
+                    } else {
+                        for(int i=0;i<self.content_arr.count;i++)
+                        {
+                            NSDictionary* obj_json = self.content_arr[i];
+                            NSString* _id =[obj_json valueForKey:@"cart_item_id"];
+                            if([_id isEqualToString:ids])
+                            {
+                                [self.content_arr removeObjectAtIndex:i];
+                                //  [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:self.indexPath] withRowAnimation:UITableViewRowAnimationLeft];
+                                break;
+                                // appDelegate.cart_count--;
+                                // [appDelegate update_count_mark];
+                            }
+                            
+                        }
+                    }
+                    [self.itemListTable reloadData];
+                    [self refresh_total];
 #ifdef RA_NOTIFICATION
 #ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
 #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
 #endif
-                        //                        [self reload_data];
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
-                    }
-                    
-                });
-            });
+                    //                        [self reload_data];
+                }
+                else
+                {
+                    [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+                }
+                
+                
+            }];
+            
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSDictionary* cart_json = [RANetwork cart_remove:ids];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//
+//                    if([[cart_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        //  AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                        if (self.back_order_flag) {
+//
+//                            NSInteger section_count = [self sectionCount];
+//                            for (int i = 0; i < section_count; i++) {
+//                                NSInteger item_count = [self itemCountInSection:i];
+//                                BOOL ready_break = NO;
+//
+//                                for (int j = 0; j < item_count; j++) {
+//                                    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
+//                                    NSDictionary* obj_json = [self itemJsonAtIndexPath:indexPath];
+//                                    NSString* _id =[obj_json valueForKey:@"cart_item_id"];
+//                                    if([_id isEqualToString:ids])
+//                                    {
+//                                        [self updateItemJson:nil atIndexPath:indexPath];
+//                                        ready_break = YES;
+//                                        break;
+//                                    }
+//                                }
+//
+//                                if (ready_break) {
+//                                    break;
+//                                }
+//                            }
+//
+//                        } else {
+//                            for(int i=0;i<self.content_arr.count;i++)
+//                            {
+//                                NSDictionary* obj_json = self.content_arr[i];
+//                                NSString* _id =[obj_json valueForKey:@"cart_item_id"];
+//                                if([_id isEqualToString:ids])
+//                                {
+//                                    [self.content_arr removeObjectAtIndex:i];
+//                                    //  [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:self.indexPath] withRowAnimation:UITableViewRowAnimationLeft];
+//                                    break;
+//                                    // appDelegate.cart_count--;
+//                                    // [appDelegate update_count_mark];
+//                                }
+//
+//                            }
+//                        }
+//                        [self.itemListTable reloadData];
+//                        [self refresh_total];
+//#ifdef RA_NOTIFICATION
+//                        [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//                        //                        [self reload_data];
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+//                    }
+//
+//                });
+//            });
             
             
         }
         }
     }
     }

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

@@ -550,43 +550,78 @@
 {
 {
     
     
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_create_order:^(NSMutableDictionary *result) {
+        NSMutableDictionary* return_json = result;
         
         
-        NSDictionary* return_json = [RANetwork new_Order];
+        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
         
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-            
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                int result=[[return_json valueForKey:@"result"] intValue];
-                if(result==2)
-                {
-                    //successed.
-                    
-                    NSString* order_code = [return_json valueForKey:@"orderCode"];
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    appDelegate.order_code = order_code;
-                    
-                    
-                    [self addtocart];
-                    
-                    
-
-                    
-                }
-            }
-            else
+        
+        if([[return_json valueForKey:@"result"] intValue]==2)
+        {
+            int result=[[return_json valueForKey:@"result"] intValue];
+            if(result==2)
             {
             {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                //successed.
+                
+                NSString* order_code = [return_json valueForKey:@"orderCode"];
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                appDelegate.order_code = order_code;
+                
+                
+                [self addtocart];
+                
+                
+                
+                
             }
             }
-            
-            
-            
-            
-        });
-    });
+        }
+        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 new_Order];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//                int result=[[return_json valueForKey:@"result"] intValue];
+//                if(result==2)
+//                {
+//                    //successed.
+//
+//                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    appDelegate.order_code = order_code;
+//
+//
+//                    [self addtocart];
+//
+//
+//
+//
+//                }
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 }
 - (IBAction)onAddPortfolioClick:(id)sender {
 - (IBAction)onAddPortfolioClick:(id)sender {
     UIApplication * app = [UIApplication sharedApplication];
     UIApplication * app = [UIApplication sharedApplication];

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

@@ -1361,67 +1361,126 @@
 {
 {
     
     
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_create_order:^(NSMutableDictionary *result) {
+        NSMutableDictionary* return_json = result;
         
         
-        NSDictionary* return_json = [RANetwork new_Order];
+        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
         
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-            
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                int result=[[return_json valueForKey:@"result"] intValue];
-                if(result==2)
-                {
-                    //successed.
-                    
-                    NSString* order_code = [return_json valueForKey:@"orderCode"];
-                    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-                    appDelegate.order_code = order_code;
-                    
-                    int count=[self.quantity_text.text intValue];
-                    [self addtocart:count];
-                    
-                    
-                    //    [self ReloadData];
-                    
-                    
-                    //                    if(self.shopCartBlock!=nil)
-                    //                    {
-                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                    //
-                    //
-                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                    //                        iv.image = img;
-                    //                        //                        [self.contentView addSubview:iv];
-                    //                        self.shopCartBlock(iv);
-                    //
-                    //                    }
-                    
-                }
-            }
-            else
+        
+        if([[return_json valueForKey:@"result"] intValue]==2)
+        {
+            int result=[[return_json valueForKey:@"result"] intValue];
+            if(result==2)
             {
             {
-                UIViewController *vc= [RAUtils getViewController:self];
-                NSString *msg = [return_json valueForKey:@"err_msg"];
-                NSString *title = @"Add To Cart";
-                if ([msg hasPrefix:@"Out of Stock.\n"]) {
-                    title = @"Add To Cart: Out of Stock";
-                    msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
-                    self.btnNotifyMe.enabled = YES;
-                    self.btnaddCart.enabled = NO;
-                }
+                //successed.
+                
+                NSString* order_code = [return_json valueForKey:@"orderCode"];
+                AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+                appDelegate.order_code = order_code;
+                
+                int count=[self.quantity_text.text intValue];
+                [self addtocart:count];
+                
+                
+                //    [self ReloadData];
+                
+                
+                //                    if(self.shopCartBlock!=nil)
+                //                    {
+                //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                //
+                //
+                //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                //                        iv.image = img;
+                //                        //                        [self.contentView addSubview:iv];
+                //                        self.shopCartBlock(iv);
+                //
+                //                    }
                 
                 
-                [RAUtils message_alert:msg title:title controller:vc] ;
+            }
+        }
+        else
+        {
+            UIViewController *vc= [RAUtils getViewController:self];
+            NSString *msg = [return_json valueForKey:@"err_msg"];
+            NSString *title = @"Add To Cart";
+            if ([msg hasPrefix:@"Out of Stock.\n"]) {
+                title = @"Add To Cart: Out of Stock";
+                msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+                self.btnNotifyMe.enabled = YES;
+                self.btnaddCart.enabled = NO;
             }
             }
             
             
-            
-            
-            
-        });
-    });
+            [RAUtils message_alert:msg title:title controller:vc] ;
+        }
+        
+        
+        
+        
+        
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* return_json = [RANetwork new_Order];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//                int result=[[return_json valueForKey:@"result"] intValue];
+//                if(result==2)
+//                {
+//                    //successed.
+//
+//                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+//                    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+//                    appDelegate.order_code = order_code;
+//
+//                    int count=[self.quantity_text.text intValue];
+//                    [self addtocart:count];
+//
+//
+//                    //    [self ReloadData];
+//
+//
+//                    //                    if(self.shopCartBlock!=nil)
+//                    //                    {
+//                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+//                    //
+//                    //
+//                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+//                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+//                    //                        iv.image = img;
+//                    //                        //                        [self.contentView addSubview:iv];
+//                    //                        self.shopCartBlock(iv);
+//                    //
+//                    //                    }
+//
+//                }
+//            }
+//            else
+//            {
+//                UIViewController *vc= [RAUtils getViewController:self];
+//                NSString *msg = [return_json valueForKey:@"err_msg"];
+//                NSString *title = @"Add To Cart";
+//                if ([msg hasPrefix:@"Out of Stock.\n"]) {
+//                    title = @"Add To Cart: Out of Stock";
+//                    msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+//                    self.btnNotifyMe.enabled = YES;
+//                    self.btnaddCart.enabled = NO;
+//                }
+//
+//                [RAUtils message_alert:msg title:title controller:vc] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 }
 #pragma mark - UIAlertViewDelegate
 #pragma mark - UIAlertViewDelegate
 // Called when a button is clicked. The view will be automatically dismissed after this call returns
 // Called when a button is clicked. The view will be automatically dismissed after this call returns

+ 112 - 53
RedAnt ERP Mobile/common/Functions/order/OrderListViewController.m

@@ -737,66 +737,125 @@
 {
 {
     
     
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_create_order:^(NSMutableDictionary *result) {
+        NSMutableDictionary* return_json =result;
         
         
-        NSDictionary* return_json = [RANetwork new_Order];
+        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
         
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-            
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
+        
+        if([[return_json valueForKey:@"result"] intValue]==2)
+        {
+            int result=[[return_json valueForKey:@"result"] intValue];
+            if(result==2)
             {
             {
-                int result=[[return_json valueForKey:@"result"] intValue];
-                if(result==2)
-                {
-                    //successed.
-                    
-                    NSString* order_code = [return_json valueForKey:@"orderCode"];
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    appDelegate.order_code = order_code;
-                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-
-                    
+                //successed.
+                
+                NSString* order_code = [return_json valueForKey:@"orderCode"];
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                appDelegate.order_code = order_code;
+                appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+                
+                
 #ifdef RA_NOTIFICATION
 #ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
 #else
-                    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-                    [main_vc reloadCart:true immediately:false];
+                MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+                [main_vc reloadCart:true immediately:false];
 #endif
 #endif
-                    
-                    [self ReloadData];
-                    
-                    
-                    //     [self performSelector:@selector(loadpage) withObject:nil afterDelay:1];
-                    //    [self loadpage];
-                    
-                    
-                    //                    if(self.shopCartBlock!=nil)
-                    //                    {
-                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                    //
-                    //
-                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                    //                        iv.image = img;
-                    //                        //                        [self.contentView addSubview:iv];
-                    //                        self.shopCartBlock(iv);
-                    //
-                    //                    }
-                    
-                }
-            }
-            else
-            {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:self] ;
+                
+                [self ReloadData];
+                
+                
+                //     [self performSelector:@selector(loadpage) withObject:nil afterDelay:1];
+                //    [self loadpage];
+                
+                
+                //                    if(self.shopCartBlock!=nil)
+                //                    {
+                //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                //
+                //
+                //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                //                        iv.image = img;
+                //                        //                        [self.contentView addSubview:iv];
+                //                        self.shopCartBlock(iv);
+                //
+                //                    }
+                
             }
             }
-            
-            
-            
-            
-        });
-    });
+        }
+        else
+        {
+            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:self] ;
+        }
+        
+        
+        
+        
+        
+    }];
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* return_json = [RANetwork new_Order];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//                int result=[[return_json valueForKey:@"result"] intValue];
+//                if(result==2)
+//                {
+//                    //successed.
+//
+//                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    appDelegate.order_code = order_code;
+//                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+//
+//
+//#ifdef RA_NOTIFICATION
+//                    [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+//                    [main_vc reloadCart:true immediately:false];
+//#endif
+//
+//                    [self ReloadData];
+//
+//
+//                    //     [self performSelector:@selector(loadpage) withObject:nil afterDelay:1];
+//                    //    [self loadpage];
+//
+//
+//                    //                    if(self.shopCartBlock!=nil)
+//                    //                    {
+//                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+//                    //
+//                    //
+//                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+//                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+//                    //                        iv.image = img;
+//                    //                        //                        [self.contentView addSubview:iv];
+//                    //                        self.shopCartBlock(iv);
+//                    //
+//                    //                    }
+//
+//                }
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 }
 #pragma mark - UIAlertViewDelegate
 #pragma mark - UIAlertViewDelegate
 // Called when a button is clicked. The view will be automatically dismissed after this call returns
 // Called when a button is clicked. The view will be automatically dismissed after this call returns

+ 41 - 19
RedAnt ERP Mobile/common/Functions/portfolio/PortfolioListViewController.m

@@ -668,28 +668,50 @@
             
             
             UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
             UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
                 UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Remove Portfilio"];
                 UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Remove Portfilio"];
-                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                
+                [RANetwork request_removeportfoliopdf:listid completionHandler:^(NSMutableDictionary *result) {
+                    NSMutableDictionary* cart_json = result;
                     
                     
-                    NSDictionary* cart_json = [RANetwork delete_portfoliolist:listid];
                     
                     
-                    dispatch_async(dispatch_get_main_queue(), ^{
-                        
-                        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-                        
-                        if([[cart_json valueForKey:@"result"] intValue]==2)
-                        {
-                            
-                            [self ReloadData];
-                        }
-                        else
-                        {
-                            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Portfolio" controller:self] ;
-                        }
-                        
-                        
+                    [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+                    
+                    if([[cart_json valueForKey:@"result"] intValue]==2)
+                    {
                         
                         
-                    });
-                });
+                        [self ReloadData];
+                    }
+                    else
+                    {
+                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Portfolio" controller:self] ;
+                    }
+                    
+                    
+                    
+                    
+                }];
+                
+//                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//                    
+//                    NSMutableDictionary* cart_json =[RANetwork delete_portfoliolist:listid];
+//                    
+//                    dispatch_async(dispatch_get_main_queue(), ^{
+//                        
+//                        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//                        
+//                        if([[cart_json valueForKey:@"result"] intValue]==2)
+//                        {
+//                            
+//                            [self ReloadData];
+//                        }
+//                        else
+//                        {
+//                            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Portfolio" controller:self] ;
+//                        }
+//                        
+//                        
+//                        
+//                    });
+//                });
                 
                 
                 
                 
             }];
             }];

+ 145 - 60
RedAnt ERP Mobile/common/Functions/portfolio/PortfolioViewController.m

@@ -304,57 +304,106 @@
 {
 {
     
     
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_create_order:^(NSMutableDictionary *result) {
+        NSMutableDictionary* return_json = result;
         
         
-        NSDictionary* return_json = [RANetwork new_Order];
+        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
         
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-            
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                int result=[[return_json valueForKey:@"result"] intValue];
-                if(result==2)
-                {
-                    //successed.
-                    
-                    NSString* order_code = [return_json valueForKey:@"orderCode"];
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    appDelegate.order_code = order_code;
-                    
-                    
-                    [self addtocart];
-                    
-                    
-                    //    [self ReloadData];
-                    
-                    
-                    //                    if(self.shopCartBlock!=nil)
-                    //                    {
-                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                    //
-                    //
-                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                    //                        iv.image = img;
-                    //                        //                        [self.contentView addSubview:iv];
-                    //                        self.shopCartBlock(iv);
-                    //
-                    //                    }
-                    
-                }
-            }
-            else
+        
+        if([[return_json valueForKey:@"result"] intValue]==2)
+        {
+            int result=[[return_json valueForKey:@"result"] intValue];
+            if(result==2)
             {
             {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                //successed.
+                
+                NSString* order_code = [return_json valueForKey:@"orderCode"];
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                appDelegate.order_code = order_code;
+                
+                
+                [self addtocart];
+                
+                
+                //    [self ReloadData];
+                
+                
+                //                    if(self.shopCartBlock!=nil)
+                //                    {
+                //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                //
+                //
+                //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                //                        iv.image = img;
+                //                        //                        [self.contentView addSubview:iv];
+                //                        self.shopCartBlock(iv);
+                //
+                //                    }
+                
             }
             }
-            
-            
-            
-            
-        });
-    });
+        }
+        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 new_Order];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//                int result=[[return_json valueForKey:@"result"] intValue];
+//                if(result==2)
+//                {
+//                    //successed.
+//
+//                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    appDelegate.order_code = order_code;
+//
+//
+//                    [self addtocart];
+//
+//
+//                    //    [self ReloadData];
+//
+//
+//                    //                    if(self.shopCartBlock!=nil)
+//                    //                    {
+//                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+//                    //
+//                    //
+//                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+//                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+//                    //                        iv.image = img;
+//                    //                        //                        [self.contentView addSubview:iv];
+//                    //                        self.shopCartBlock(iv);
+//                    //
+//                    //                    }
+//
+//                }
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 }
 - (IBAction)onCreateTearSheet:(id)sender {
 - (IBAction)onCreateTearSheet:(id)sender {
     
     
@@ -1083,11 +1132,9 @@
     
     
     //    NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
     //    NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
     NSString * string = [checked componentsJoinedByString:@","];
     NSString * string = [checked componentsJoinedByString:@","];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* cart_json = [RANetwork portfolio_remove:string];
+    [RANetwork request_removeportfolio:string completionHandler:^(NSMutableDictionary *result) {
+        NSMutableDictionary* cart_json =result;
         
         
-        dispatch_async(dispatch_get_main_queue(), ^{
             
             
             
             
             
             
@@ -1100,8 +1147,26 @@
                 [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Remove Model From Portfolio" controller:self] ;
                 [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Remove Model From Portfolio" controller:self] ;
             }
             }
             
             
-        });
-    });
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* cart_json = [RANetwork portfolio_remove:string];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//
+//            if([[cart_json valueForKey:@"result"] intValue]==2)
+//            {
+//                [self reload_data];
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Remove Model From Portfolio" controller:self] ;
+//            }
+//
+//        });
+//    });
     
     
     
     
 }
 }
@@ -1717,12 +1782,9 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
             
             
             NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]];
             NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]];
             
             
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            [RANetwork request_removeportfolio:ids completionHandler:^(NSMutableDictionary *result) {
+                NSMutableDictionary* cart_json =result;
                 
                 
-                NSDictionary* cart_json = [RANetwork portfolio_remove:ids];
-                
-                dispatch_async(dispatch_get_main_queue(), ^{
                     
                     
                     
                     
                     
                     
@@ -1739,8 +1801,31 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
                         [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
                         [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
                     }
                     }
                     
                     
-                });
-            });
+                
+            }];
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSDictionary* cart_json = [RANetwork portfolio_remove:ids];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//
+//                    if([[cart_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        self.deletedRow = delete_last ? -1 : self.indexPath.row;
+//                        if (delete_last) {
+//                            self.indexPath = [NSIndexPath indexPathForRow:count - 2 inSection:0];
+//                        }
+//                        [self reload_data];
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+//                    }
+//
+//                });
+//            });
             
             
         }
         }
         self.deleteIndexPath = nil;
         self.deleteIndexPath = nil;

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

@@ -958,57 +958,106 @@
 {
 {
     
     
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_create_order:^(NSMutableDictionary *result) {
+        NSMutableDictionary* return_json = result;
         
         
-        NSDictionary* return_json = [RANetwork new_Order];
+        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
         
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-            
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                int result=[[return_json valueForKey:@"result"] intValue];
-                if(result==2)
-                {
-                    //successed.
-                    
-                    NSString* order_code = [return_json valueForKey:@"orderCode"];
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    appDelegate.order_code = order_code;
-                    
-                    
-                    [self addtocart];
-                    
-                    
-                    //    [self ReloadData];
-                    
-                    
-                    //                    if(self.shopCartBlock!=nil)
-                    //                    {
-                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                    //
-                    //
-                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                    //                        iv.image = img;
-                    //                        //                        [self.contentView addSubview:iv];
-                    //                        self.shopCartBlock(iv);
-                    //
-                    //                    }
-                    
-                }
-            }
-            else
+        
+        if([[return_json valueForKey:@"result"] intValue]==2)
+        {
+            int result=[[return_json valueForKey:@"result"] intValue];
+            if(result==2)
             {
             {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                //successed.
+                
+                NSString* order_code = [return_json valueForKey:@"orderCode"];
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                appDelegate.order_code = order_code;
+                
+                
+                [self addtocart];
+                
+                
+                //    [self ReloadData];
+                
+                
+                //                    if(self.shopCartBlock!=nil)
+                //                    {
+                //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                //
+                //
+                //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                //                        iv.image = img;
+                //                        //                        [self.contentView addSubview:iv];
+                //                        self.shopCartBlock(iv);
+                //
+                //                    }
+                
             }
             }
-            
-            
-            
-            
-        });
-    });
+        }
+        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 new_Order];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//                int result=[[return_json valueForKey:@"result"] intValue];
+//                if(result==2)
+//                {
+//                    //successed.
+//
+//                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    appDelegate.order_code = order_code;
+//
+//
+//                    [self addtocart];
+//
+//
+//                    //    [self ReloadData];
+//
+//
+//                    //                    if(self.shopCartBlock!=nil)
+//                    //                    {
+//                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+//                    //
+//                    //
+//                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+//                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+//                    //                        iv.image = img;
+//                    //                        //                        [self.contentView addSubview:iv];
+//                    //                        self.shopCartBlock(iv);
+//                    //
+//                    //                    }
+//
+//                }
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 }
 - (IBAction)onAddPortfolioClick:(id)sender {
 - (IBAction)onAddPortfolioClick:(id)sender {
     UIApplication * app = [UIApplication sharedApplication];
     UIApplication * app = [UIApplication sharedApplication];

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

@@ -670,57 +670,106 @@
 {
 {
     
     
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_create_order:^(NSMutableDictionary *result) {
+        NSMutableDictionary* return_json = result;
         
         
-        NSDictionary* return_json = [RANetwork new_Order];
+        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
         
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-            
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                int result=[[return_json valueForKey:@"result"] intValue];
-                if(result==2)
-                {
-                    //successed.
-                    
-                    NSString* order_code = [return_json valueForKey:@"orderCode"];
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    appDelegate.order_code = order_code;
-                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-                    
-                    [self addtocart];
-                    
-                    
-                    //    [self ReloadData];
-                    
-                    
-                    //                    if(self.shopCartBlock!=nil)
-                    //                    {
-                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                    //
-                    //
-                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                    //                        iv.image = img;
-                    //                        //                        [self.contentView addSubview:iv];
-                    //                        self.shopCartBlock(iv);
-                    //
-                    //                    }
-                    
-                }
-            }
-            else
+        
+        if([[return_json valueForKey:@"result"] intValue]==2)
+        {
+            int result=[[return_json valueForKey:@"result"] intValue];
+            if(result==2)
             {
             {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                //successed.
+                
+                NSString* order_code = [return_json valueForKey:@"orderCode"];
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                appDelegate.order_code = order_code;
+                appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+                
+                [self addtocart];
+                
+                
+                //    [self ReloadData];
+                
+                
+                //                    if(self.shopCartBlock!=nil)
+                //                    {
+                //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                //
+                //
+                //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                //                        iv.image = img;
+                //                        //                        [self.contentView addSubview:iv];
+                //                        self.shopCartBlock(iv);
+                //
+                //                    }
+                
             }
             }
-            
-            
-            
-            
-        });
-    });
+        }
+        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 new_Order];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//                int result=[[return_json valueForKey:@"result"] intValue];
+//                if(result==2)
+//                {
+//                    //successed.
+//
+//                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    appDelegate.order_code = order_code;
+//                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+//
+//                    [self addtocart];
+//
+//
+//                    //    [self ReloadData];
+//
+//
+//                    //                    if(self.shopCartBlock!=nil)
+//                    //                    {
+//                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+//                    //
+//                    //
+//                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+//                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+//                    //                        iv.image = img;
+//                    //                        //                        [self.contentView addSubview:iv];
+//                    //                        self.shopCartBlock(iv);
+//                    //
+//                    //                    }
+//
+//                }
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 }
 - (IBAction)onAddPortfolioClick:(id)sender {
 - (IBAction)onAddPortfolioClick:(id)sender {
     UIApplication * app = [UIApplication sharedApplication];
     UIApplication * app = [UIApplication sharedApplication];

+ 149 - 85
RedAnt ERP Mobile/common/Functions/watchlist/WatchListViewController.m

@@ -299,57 +299,92 @@
 {
 {
     
     
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    
+    [RANetwork request_create_order:^(NSMutableDictionary *result) {
+        NSMutableDictionary* return_json =result;
         
         
-        NSDictionary* return_json = [RANetwork new_Order];
+        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
         
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-            
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                int result=[[return_json valueForKey:@"result"] intValue];
-                if(result==2)
-                {
-                    //successed.
-                    
-                    NSString* order_code = [return_json valueForKey:@"orderCode"];
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    appDelegate.order_code = order_code;
-                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-                    
-                    [self addtocart];
-                    
-                    
-                    //    [self ReloadData];
-                    
-                    
-                    //                    if(self.shopCartBlock!=nil)
-                    //                    {
-                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                    //
-                    //
-                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                    //                        iv.image = img;
-                    //                        //                        [self.contentView addSubview:iv];
-                    //                        self.shopCartBlock(iv);
-                    //
-                    //                    }
-                    
-                }
-            }
-            else
+        
+        if([[return_json valueForKey:@"result"] intValue]==2)
+        {
+            int result=[[return_json valueForKey:@"result"] intValue];
+            if(result==2)
             {
             {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                //successed.
+                
+                NSString* order_code = [return_json valueForKey:@"orderCode"];
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                appDelegate.order_code = order_code;
+                appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+                
+                [self addtocart];
+                
+
+                
             }
             }
-            
-            
-            
-            
-        });
-    });
+        }
+        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 new_Order];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//                int result=[[return_json valueForKey:@"result"] intValue];
+//                if(result==2)
+//                {
+//                    //successed.
+//
+//                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    appDelegate.order_code = order_code;
+//                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+//
+//                    [self addtocart];
+//
+//
+//                    //    [self ReloadData];
+//
+//
+//                    //                    if(self.shopCartBlock!=nil)
+//                    //                    {
+//                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+//                    //
+//                    //
+//                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+//                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+//                    //                        iv.image = img;
+//                    //                        //                        [self.contentView addSubview:iv];
+//                    //                        self.shopCartBlock(iv);
+//                    //
+//                    //                    }
+//
+//                }
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 }
 
 
 
 
@@ -468,27 +503,40 @@
     
     
     //    NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
     //    NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
     NSString * string = [checked componentsJoinedByString:@","];
     NSString * string = [checked componentsJoinedByString:@","];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* cart_json = [RANetwork watchlist_remove:string];
+    [RANetwork request_remove_wishlist:string completionHandler:^(NSMutableDictionary *result) {
+        NSMutableDictionary* cart_json = result;
+        if([[cart_json valueForKey:@"result"] intValue]==2)
+        {
+            [self reload_data];
+            [self.btnselect setTitle:@"Select all"];
+        }
+        else
+        {
+            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Remove Model From Wish List" controller:self] ;
+        }
         
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            
-            
-            
-            if([[cart_json valueForKey:@"result"] intValue]==2)
-            {
-                [self reload_data];
-                
-                        [self.btnselect setTitle:@"Select all"];
-            }
-            else
-            {
-                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Remove Model From Wish List" controller:self] ;
-            }
-            
-        });
-    });
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* cart_json = [RANetwork watchlist_remove:string];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//
+//            if([[cart_json valueForKey:@"result"] intValue]==2)
+//            {
+//                [self reload_data];
+//
+//                        [self.btnselect setTitle:@"Select all"];
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Remove Model From Wish List" controller:self] ;
+//            }
+//
+//        });
+//    });
     
     
     
     
 }
 }
@@ -988,26 +1036,42 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
             
             
             NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]];
             NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]];
             
             
-            
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            [RANetwork request_remove_wishlist:ids completionHandler:^(NSMutableDictionary *result) {
+                NSMutableDictionary* cart_json = result;
                 
                 
-                NSDictionary* cart_json = [RANetwork watchlist_remove:ids];
                 
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
-                    
-                    
-                    if([[cart_json valueForKey:@"result"] intValue]==2)
-                    {
-                        [self reload_data];
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
-                    }
-                    
-                });
-            });
+                
+                
+                if([[cart_json valueForKey:@"result"] intValue]==2)
+                {
+                    [self reload_data];
+                }
+                else
+                {
+                    [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+                }
+                
+                
+            }];
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSDictionary* cart_json = [RANetwork watchlist_remove:ids];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//
+//                    if([[cart_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        [self reload_data];
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+//                    }
+//
+//                });
+//            });
             
             
         }
         }
         return;
         return;

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

@@ -53,10 +53,10 @@ extern NSString *const ScreenCodeOfflineSync;
 
 
 @interface RANetwork : NetworkUtils
 @interface RANetwork : NetworkUtils
 +(void) LoadImage:(NSString*) url into:(UIImageView*) container;
 +(void) LoadImage:(NSString*) url into:(UIImageView*) container;
-+(NSDictionary*) portfolio_remove:(NSString* ) item_ids;
+//+(NSDictionary*) portfolio_remove:(NSString* ) item_ids;
 //+(NSDictionary*)request_Portfolio:(int)sort;
 //+(NSDictionary*)request_Portfolio:(int)sort;
 
 
-+(NSDictionary*) delete_portfoliolist:(NSString* ) listid;
+//+(NSDictionary*) delete_portfoliolist:(NSString* ) listid;
 
 
 +(NSDictionary*) add_toPortfolio:(NSString* ) item_id withScreen:(NSString *)screenName;
 +(NSDictionary*) add_toPortfolio:(NSString* ) item_id withScreen:(NSString *)screenName;
 //+(NSData*)get_json : (NSString*) url parameters:(NSMutableDictionary *) params;
 //+(NSData*)get_json : (NSString*) url parameters:(NSMutableDictionary *) params;
@@ -101,9 +101,9 @@ extern NSString *const ScreenCodeOfflineSync;
 +(NSDictionary*) portfolio_setPrice:(NSString*) watchlist_id price:(float) price discount:(float) discount QTY:(int)qty qty_p:(float) qty_p notes:(NSString*)notes;
 +(NSDictionary*) portfolio_setPrice:(NSString*) watchlist_id price:(float) price discount:(float) discount QTY:(int)qty qty_p:(float) qty_p notes:(NSString*)notes;
 //+(NSDictionary*) portfolio_setQTY:(NSString*) watchlist_id QTY:(int)qty;
 //+(NSDictionary*) portfolio_setQTY:(NSString*) watchlist_id QTY:(int)qty;
 
 
-+(NSDictionary*) cart_remove:(NSString* ) item_ids;
+//+(NSDictionary*) cart_remove:(NSString* ) item_ids;
 //+(NSDictionary*) cart_check:(NSString* ) item_ids;
 //+(NSDictionary*) cart_check:(NSString* ) item_ids;
-+(NSDictionary*) watchlist_remove:(NSString* ) item_ids;
+//+(NSDictionary*) watchlist_remove:(NSString* ) item_ids;
 
 
 +(NSDictionary*) move_wish2cart:(NSString* ) item_ids;
 +(NSDictionary*) move_wish2cart:(NSString* ) item_ids;
 +(NSDictionary*) move_cart2wish:(NSString* ) item_ids;
 +(NSDictionary*) move_cart2wish:(NSString* ) item_ids;
@@ -115,7 +115,7 @@ extern NSString *const ScreenCodeOfflineSync;
 +(NSDictionary*)sign_Order:(NSString*) order_code path:(NSString*)path;
 +(NSDictionary*)sign_Order:(NSString*) order_code path:(NSString*)path;
 +(NSDictionary*)update_OrderCustomer:(NSString*) order_code customerinfo:(NSMutableDictionary*)info;
 +(NSDictionary*)update_OrderCustomer:(NSString*) order_code customerinfo:(NSMutableDictionary*)info;
 +(NSDictionary*)saveandcommit_Order:(NSMutableDictionary*)params;
 +(NSDictionary*)saveandcommit_Order:(NSMutableDictionary*)params;
-+(NSDictionary*) new_Order;
+//+(NSDictionary*) new_Order;
 +(NSDictionary*)open_Order:(NSString*) order_code;
 +(NSDictionary*)open_Order:(NSString*) order_code;
 +(NSDictionary*)release_Order:(NSString*) order_code withScreen:(NSString *)screenName;
 +(NSDictionary*)release_Order:(NSString*) order_code withScreen:(NSString *)screenName;
 +(NSDictionary*)save_Order:(NSMutableDictionary*)params;
 +(NSDictionary*)save_Order:(NSMutableDictionary*)params;
@@ -214,4 +214,9 @@ extern NSString *const ScreenCodeOfflineSync;
 + (void)request_qouteorder:(NSString *)so_id emailAddr:(NSString *)addr completionHandler:(resultHandler)result;
 + (void)request_qouteorder:(NSString *)so_id emailAddr:(NSString *)addr completionHandler:(resultHandler)result;
 + (void)request_mergeorder:(NSMutableDictionary *)params completionHandler:(resultHandler)result;
 + (void)request_mergeorder:(NSMutableDictionary *)params completionHandler:(resultHandler)result;
 +(void)request_pendingorder:(NSString *)contactid completionHandler:(resultHandler)result;
 +(void)request_pendingorder:(NSString *)contactid completionHandler:(resultHandler)result;
++(void) request_removeportfolio:(NSString* ) item_ids completionHandler:(resultHandler)result;
++(void) request_removeportfoliopdf:(NSString* ) listid completionHandler:(resultHandler)result;
++(void) request_remove_wishlist:(NSString* ) item_ids completionHandler:(resultHandler)result;
++(void) request_remove_cart:(NSString* ) item_ids completionHandler:(resultHandler)result;
++(void) request_create_order:(resultHandler)result;
 @end
 @end

+ 375 - 1
RedAnt ERP Mobile/common/data_provider/RANetwork.m

@@ -4459,7 +4459,7 @@ repeat:
 
 
 //+(bool) IsNetworkAvailable
 //+(bool) IsNetworkAvailable
 //{
 //{
-//    
+//
 //    if (([Reachability reachabilityForInternetConnection].currentReachabilityStatus == NotReachable) &&
 //    if (([Reachability reachabilityForInternetConnection].currentReachabilityStatus == NotReachable) &&
 //        ([Reachability reachabilityForLocalWiFi].currentReachabilityStatus == NotReachable))
 //        ([Reachability reachabilityForLocalWiFi].currentReachabilityStatus == NotReachable))
 //        return false;
 //        return false;
@@ -6699,4 +6699,378 @@ repeat:
 //    return jsobj;
 //    return jsobj;
 //
 //
 }
 }
+
++(void) request_removeportfolio:(NSString* ) item_ids completionHandler:(resultHandler)result
+{
+    
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+     AppDelegate *appDelegate = nil;
+    
+
+        appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if(appDelegate.user!=nil)
+        [params setValue:appDelegate.user forKey:@"user"];
+    if(appDelegate.contact_id!=nil)
+        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+    if(appDelegate.password!=nil)
+        [params setValue:appDelegate.password forKey:@"password"];
+    [params setValue:item_ids forKey:@"portfolioId"];
+    //    [params setValue:editor forKey:@"editor"];
+    
+    [params setValue:ScreenCodePortfolio forKey:kScreenName];
+    
+    
+    if(appDelegate.offline_mode)
+    {
+
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            NSMutableDictionary* json = [[OLDataProvider offline_removePortfolio:params] mutableCopy];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                result(json);
+            });
+        });
+        
+        return;
+    }
+    
+    
+    [self request_interface:URL_PORTFOLIO_REMOVE parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
+        int result_code = [[resulti valueForKey:@"result"] intValue];
+        
+        if (result_code==2)
+        {
+            
+            
+            appDelegate.port_count =[[resulti valueForKey:@"portfolio_count"] intValue];
+            
+            [appDelegate update_count_mark];
+        };
+        result(resulti);
+    } retry:0];
+    
+//    NSData* json = nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json = [OLDataProvider offline_removePortfolio:params];
+//    } else {
+//        if(![self IsNetworkAvailable])
+//            return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//        json=[self get_json:URL_PORTFOLIO_REMOVE parameters:params];
+//    }
+//    if(json!=nil)
+//    {
+//        NSError *error=nil;
+//        NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//
+//
+//        int result = [[jsobj valueForKey:@"result"] intValue];
+//
+//        if (result==2)
+//        {
+//
+//
+//            appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
+//
+//            [appDelegate update_count_mark];
+//        }
+//        return jsobj;
+//    }
+//    else
+//        return nil;
+}
+
++(void) request_removeportfoliopdf:(NSString* ) listid 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:listid forKey:@"tearsheetsId"];
+    //    [params setValue:editor forKey:@"editor"];
+    [params setValue:ScreenCodeViewPortfolios forKey:kScreenName];
+//    [params setValue:@"Delete Portfolio" forKey:kAction];
+    
+    
+    if(appDelegate.offline_mode)
+    {
+
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            NSMutableDictionary* json = [[OLDataProvider offline_removePDF:params] mutableCopy];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                result(json);
+            });
+        });
+        
+        return;
+    }
+    
+    
+    [self request_interface:URL_PORTFOLIOLIST_REMOVE parameters:params err_record_url:nil completionHandler:result retry:0];
+
+}
++(void) request_remove_wishlist:(NSString* ) item_ids completionHandler:(resultHandler)result
+{
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+     AppDelegate *appDelegate = nil;
+    
+
+        appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+
+    if(appDelegate.user!=nil)
+        [params setValue:appDelegate.user forKey:@"user"];
+    if(appDelegate.contact_id!=nil)
+        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+    if(appDelegate.password!=nil)
+        [params setValue:appDelegate.password forKey:@"password"];
+    [params setValue:item_ids forKey:@"collectId"];
+    //    [params setValue:editor forKey:@"editor"];
+    
+    [params setValue:ScreenCodeWishList forKey:kScreenName];
+    
+    
+    if(appDelegate.offline_mode)
+    {
+
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            NSMutableDictionary* json = [[OLDataProvider offline_deletewishlist:params] mutableCopy];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                result(json);
+            });
+        });
+        
+        return;
+    }
+    
+    
+    [self request_interface:URL_PORTFOLIO_REMOVE parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
+        int result_code = [[resulti valueForKey:@"result"] intValue];
+        
+        if (result_code==2)
+        {
+            appDelegate.wish_count =[[resulti valueForKey:@"wish_count"] intValue];
+            [appDelegate update_count_mark];
+        };
+        result(resulti);
+    } retry:0];
+//
+//
+//    if(appDelegate.offline_mode)
+//    {
+//        return [OLDataProvider offline_deletewishlist:params];
+//    }
+//    if(![self IsNetworkAvailable])
+//        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//
+//    NSData* json=[self get_json:URL_WATCHLIST_REMOVE parameters:params];
+//    if(json!=nil)
+//    {
+//        NSError *error=nil;
+//        NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//        int result = [[jsobj valueForKey:@"result"] intValue];
+//
+//        if (result==2)
+//        {
+//
+//            //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
+//            appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
+//            //    appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
+//
+//            [appDelegate update_count_mark];
+//        }
+//        return jsobj;
+//    }
+//    else
+//        return nil;
+}
+
++(void) request_remove_cart:(NSString* ) item_ids completionHandler:(resultHandler)result
+{
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+     AppDelegate *appDelegate = nil;
+    
+
+        appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+
+    if(appDelegate.user!=nil)
+        [params setValue:appDelegate.user forKey:@"user"];
+    if(appDelegate.contact_id!=nil)
+        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+    if(appDelegate.password!=nil)
+        [params setValue:appDelegate.password forKey:@"password"];
+    
+    if(appDelegate.order_code!=nil)
+        [params setValue:appDelegate.order_code forKey:@"orderCode"];
+    [params setValue:item_ids forKey:@"cartItemId"];
+    //    [params setValue:editor forKey:@"editor"];
+    
+    [params setValue:ScreenCodeCart forKey:kScreenName];
+//    [params setValue:@"" forKey:kAction];
+    
+    
+    if(appDelegate.offline_mode)
+    {
+
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            NSMutableDictionary* json = [[OLDataProvider offline_cartremove:params] mutableCopy];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                result(json);
+            });
+        });
+        
+        return;
+    }
+    
+    
+    [self request_interface:URL_PORTFOLIO_REMOVE parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
+        int result_code = [[resulti valueForKey:@"result"] intValue];
+        
+        if (result_code==2)
+        {
+            appDelegate.cart_count = [[resulti valueForKey:@"cart_count"] intValue];
+            [appDelegate update_count_mark];
+        };
+        result(resulti);
+    } retry:0];
+//    
+//    NSData* json=nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json= [OLDataProvider offline_cartremove:params];
+//    }
+//    else
+//    {
+//    if(![self IsNetworkAvailable])
+//        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//    
+//    json=[self get_json:URL_CART_REMOVE parameters:params];
+//    }
+//    if(json!=nil)
+//    {
+//        NSError *error=nil;
+//        NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//        
+//        int result = [[jsobj valueForKey:@"result"] intValue];
+//        
+//        if (result==2)
+//        {
+//            
+//            appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
+//            
+//            
+//            [appDelegate update_count_mark];
+//        }
+//        return jsobj;
+//    }
+//    else
+//        return nil;
+}
+
+
++(void) request_create_order:(resultHandler)result
+{
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+     AppDelegate *appDelegate = nil;
+    
+
+        appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+
+    if(appDelegate.user!=nil)
+        [params setValue:appDelegate.user forKey:@"user"];
+    if(appDelegate.contact_id!=nil)
+        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+    if(appDelegate.password!=nil)
+        [params setValue:appDelegate.password forKey:@"password"];
+    
+    if(appDelegate.order_code!=nil)
+        [params setValue:appDelegate.order_code forKey:@"orderCode"];
+    
+    
+    [params setObject:ScreenCodeOrderList forKey:kScreenName];
+    
+    NSDictionary* customerinfo= appDelegate.customerInfo;
+    
+    NSArray* keys=[customerinfo allKeys];
+    for(int i=0;i<keys.count;i++)
+    {
+        [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
+    }
+    
+    
+    if(appDelegate.offline_mode)
+    {
+
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            NSMutableDictionary* json = [[OLDataProvider offline_createorder:params] mutableCopy];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                result(json);
+            });
+        });
+        
+        return;
+    }
+    
+    
+    [self request_interface:URL_NEW_ORDER parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
+        int result_code = [[resulti valueForKey:@"result"] intValue];
+        
+        if (result_code==2)
+        {
+            appDelegate.cart_count = [[resulti valueForKey:@"cart_count"] intValue];
+            [appDelegate update_count_mark];
+        };
+        [appDelegate SetSo:[resulti valueForKey:@"soId"]];
+        
+        if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
+            [Singleton sharedInstance].currentOrderIsMerged = NO;
+        }
+        result(resulti);
+    } retry:0];
+    
+    
+//
+//    NSData* json = nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json= [OLDataProvider offline_createorder:params];
+//    }
+//    else
+//    {
+//        if(![self IsNetworkAvailable])
+//            return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//
+//        json=[self get_json:URL_NEW_ORDER parameters:params];
+//    }
+//    if(json==nil)
+//        return nil;
+//    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//    int result = [[jsobj valueForKey:@"result"] intValue];
+//
+//    if (result==2)
+//    {
+//
+//        appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
+//        //appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
+//        //    appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
+//
+//        [appDelegate update_count_mark];
+//    }
+//
+//    [appDelegate SetSo:[jsobj valueForKey:@"soId"]];
+//
+//    if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
+//        [Singleton sharedInstance].currentOrderIsMerged = NO;
+//    }
+//
+//    return jsobj;
+}
 @end
 @end