Explorar o código

修复ERp Mobile 闪退后,恢复状态时线程调度错误。
新增ERP Mobile 打开订单数据访问接口,并修改相关调用。
新增ERP Mobile 购物车 数据访问接口,并修改相关调用。
新增ERP Mobile 购物车,wishlist item 相互移动 数据访问接口,并修改相关调用。
新增ERP Mobile 订单详情 数据访问接口,并修改相关调用。
删除ERP Mobile 不再使用的提交订单接口。
新增ERP Mobile 复制订单 数据访问接口,并修改相关调用。
修复ERP Mobile 工程的部分警告错误

Ray Zhang %!s(int64=6) %!d(string=hai) anos
pai
achega
6f71368264

+ 50 - 8
RedAnt ERP Mobile/common/AppDelegateBase.m

@@ -735,10 +735,9 @@ void UncaughtExceptionHandler(NSException *exception) {
                     NSString *so = [urgencyDic objectForKey:@"order_so"];
                     self.order_customer_id = order_customer_id;
                     
-                    // 首先通过order code 打开订单
-                    NSDictionary* order_json = [RANetwork open_Order:order_code];
-                    
-                    dispatch_async(dispatch_get_main_queue(), ^{
+                    [RANetwork request_open_order:order_code completionHandler:^(NSMutableDictionary *result) {
+                        NSDictionary* order_json = result;
+                        
                         //                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
                         if([[order_json valueForKey:@"result"] intValue]==2)
                         {
@@ -754,9 +753,9 @@ void UncaughtExceptionHandler(NSException *exception) {
                                     self.contact_id=[self.customerInfo valueForKey:@"customer_cid"];
                                 }];
                                 
-//                                self.customerInfo = [[[RANetwork request_CustomerInfo:order_customer_id] objectForKey:@"customerInfo"] mutableCopy];
-//                                
-//                                self.contact_id=[self.customerInfo valueForKey:@"customer_cid"];
+                                //                                self.customerInfo = [[[RANetwork request_CustomerInfo:order_customer_id] objectForKey:@"customerInfo"] mutableCopy];
+                                //
+                                //                                self.contact_id=[self.customerInfo valueForKey:@"customer_cid"];
                             }
                             
                             
@@ -775,7 +774,50 @@ void UncaughtExceptionHandler(NSException *exception) {
                         {
                             [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:mainVC] ;
                         }
-                    });
+                        
+                    }];
+                    
+                    // 首先通过order code 打开订单
+//                    NSDictionary* order_json = [RANetwork open_Order:order_code];
+                    
+//                    dispatch_async(dispatch_get_main_queue(), ^{
+//                        //                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//                        if([[order_json valueForKey:@"result"] intValue]==2)
+//                        {
+//
+//                            self.order_code = order_code;
+//                            self.order_status = order_status;
+//                            [self SetSo:so];
+//
+//                            if (userType != USER_ROLE_CUSTOMER) {
+//
+//                                [RANetwork request_contactinfo:order_customer_id completionHandler:^(NSMutableDictionary *result) {
+//                                    self.customerInfo = [result[@"customerInfo"] mutableCopy];
+//                                    self.contact_id=[self.customerInfo valueForKey:@"customer_cid"];
+//                                }];
+//
+////                                self.customerInfo = [[[RANetwork request_CustomerInfo:order_customer_id] objectForKey:@"customerInfo"] mutableCopy];
+////
+////                                self.contact_id=[self.customerInfo valueForKey:@"customer_cid"];
+//                            }
+//
+//
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                            [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                            [mainVC reloadOrder:true immediately:false];
+//                            [mainVC reloadCart:true immediately:false];
+//#endif
+//
+//                        }
+//                        else
+//                        {
+//                            [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:mainVC] ;
+//                        }
+//                    });
                     
                     
                     

+ 34 - 34
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m

@@ -534,7 +534,7 @@
     NSMutableArray* fields=[[NSMutableArray alloc] init];
     NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
     //  [upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
-    int section_count=self.content_data_control.count;//[[self.content_data_download valueForKey:@"section_count"] intValue];
+    int section_count=(int)self.content_data_control.count;//[[self.content_data_download valueForKey:@"section_count"] intValue];
     
     
 //    NSString* aaa  = [RAUtils dict2string:self.content_data_control];
@@ -542,7 +542,7 @@
     {
         DebugLog(@"debug...section:%d",i);
         NSMutableArray * sectionjson = [self.content_data_control[i] mutableCopy];//[[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
-        int item_count = sectionjson.count;//[[sectionjson valueForKey:@"count"] intValue];
+        int item_count = (int)sectionjson.count;//[[sectionjson valueForKey:@"count"] intValue];
         for(int j=0;j<item_count;j++)
         {
             NSMutableDictionary * itemjson=[sectionjson[j] mutableCopy];//[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
@@ -572,12 +572,12 @@
                     if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
                     {
                         self.cancommit = false;
-                        NSString* mfield =[NSString stringWithFormat:@"%d. %@ is missing",fields.count+1,itemjson[@"aname"]];
+                        NSString* mfield =[NSString stringWithFormat:@"%ld. %@ is missing",fields.count+1,itemjson[@"aname"]];
                         
                         [fields addObject:mfield];
                         NSIndexPath* indexpath =[self get_indexpath1:[itemjson valueForKey:@"name"]];
                         if(alert)
-                            [self unhide_section:indexpath.section];
+                            [self unhide_section:(int)indexpath.section];
                         if(fields.count==1)
                         {
                             self.first_miss_pos =  indexpath;
@@ -606,12 +606,12 @@
                     if([[itemjson valueForKey:@"required"] isEqualToString: @"true"]&&checked.count==0)
                     {
                         self.cancommit = false;
-                        NSString* mfield =[NSString stringWithFormat:@"%d. %@ is missing",fields.count+1,itemjson[@"aname"]];
+                        NSString* mfield =[NSString stringWithFormat:@"%ld. %@ is missing",fields.count+1,itemjson[@"aname"]];
                         
                         [fields addObject:mfield];
                         NSIndexPath* indexpath =[self get_indexpath1:[itemjson valueForKey:@"name"]];
                         if(alert)
-                            [self unhide_section:indexpath.section];
+                            [self unhide_section:(int)indexpath.section];
                         if(fields.count==1)
                         {
                             self.first_miss_pos =  indexpath;
@@ -634,12 +634,12 @@
                     if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
                     {
                         self.cancommit = false;
-                        NSString* mfield =[NSString stringWithFormat:@"%d. %@ is missing",fields.count+1,itemjson[@"aname"]];
+                        NSString* mfield =[NSString stringWithFormat:@"%ld. %@ is missing",fields.count+1,itemjson[@"aname"]];
                         
                         [fields addObject:mfield];
                         NSIndexPath* indexpath =[self get_indexpath1:[itemjson valueForKey:@"name"]];
                         if(alert)
-                            [self unhide_section:indexpath.section];
+                            [self unhide_section:(int)indexpath.section];
                         if(fields.count==1)
                         {
                             self.first_miss_pos =  indexpath;
@@ -653,12 +653,12 @@
                     if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"] ==nil)
                     {
                         self.cancommit = false;
-                        NSString* mfield =[NSString stringWithFormat:@"%d. %@ is missing",fields.count+1,itemjson[@"aname"]];
+                        NSString* mfield =[NSString stringWithFormat:@"%ld. %@ is missing",fields.count+1,itemjson[@"aname"]];
                         
                         [fields addObject:mfield];
                         NSIndexPath* indexpath =[self get_indexpath1:[itemjson valueForKey:@"name"]];
                         if(alert)
-                            [self unhide_section:indexpath.section];
+                            [self unhide_section:(int)indexpath.section];
                         if(fields.count==1)
                         {
                             self.first_miss_pos =  indexpath;
@@ -700,12 +700,12 @@
                                 if([[modify_item valueForKey:@"required"] isEqualToString: @"true"] )
                                 {
                                     self.cancommit = false;
-                                    NSString* mfield =[NSString stringWithFormat:@"%d. %@ is missing",fields.count+1,itemjson[@"aname"]];
+                                    NSString* mfield =[NSString stringWithFormat:@"%ld. %@ is missing",fields.count+1,itemjson[@"aname"]];
                                     
                                     [fields addObject:mfield];
                                     NSIndexPath* indexpath =[self get_indexpath1:[modify_item valueForKey:@"name"]];
                                     if(alert)
-                                        [self unhide_section:indexpath.section];
+                                        [self unhide_section:(int)indexpath.section];
                                     if(fields.count==1)
                                     {
                                         self.first_miss_pos =  indexpath;
@@ -725,12 +725,12 @@
                         if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
                         {
                             self.cancommit = false;
-                            NSString* mfield =[NSString stringWithFormat:@"%d. %@ is missing",fields.count+1,itemjson[@"aname"]];
+                            NSString* mfield =[NSString stringWithFormat:@"%ld. %@ is missing",fields.count+1,itemjson[@"aname"]];
                             
                             [fields addObject:mfield];
                             NSIndexPath* indexpath =[self get_indexpath1:[itemjson valueForKey:@"name"]];
                             if(alert)
-                                [self unhide_section:indexpath.section];
+                                [self unhide_section:(int)indexpath.section];
                             if(fields.count==1)
                             {
                                 self.first_miss_pos =  indexpath;
@@ -749,11 +749,11 @@
                         
                         
                         
-                        NSString* mfield =[NSString stringWithFormat:@"%d. %@ is too short",fields.count+1,itemjson[@"aname"]];
+                        NSString* mfield =[NSString stringWithFormat:@"%ld. %@ is too short",fields.count+1,itemjson[@"aname"]];
                         
                         
                         if(check_len_val.length==0 &&[[itemjson valueForKey:@"required"] isEqualToString: @"true"])
-                            mfield =[NSString stringWithFormat:@"%d. %@ is missing",fields.count+1,itemjson[@"aname"]];
+                            mfield =[NSString stringWithFormat:@"%ld. %@ is missing",fields.count+1,itemjson[@"aname"]];
                         
                         
                         [fields addObject:mfield];
@@ -761,7 +761,7 @@
                         
                         NSIndexPath* indexpath =[self get_indexpath1:[itemjson valueForKey:@"name"]];
                         if(alert)
-                            [self unhide_section:indexpath.section];
+                            [self unhide_section:(int)indexpath.section];
                         if(fields.count==1)
                         {
                             self.first_miss_pos =  indexpath;
@@ -862,7 +862,7 @@
                         if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
                         {
                             self.cancommit = false;
-                            NSString* mfield =[NSString stringWithFormat:@"%d. %@ is missing",fields.count+1,itemjson[@"aname"]];
+                            NSString* mfield =[NSString stringWithFormat:@"%ld. %@ is missing",fields.count+1,itemjson[@"aname"]];
                             
                             
                             [fields addObject:mfield];
@@ -870,7 +870,7 @@
                             
                             NSIndexPath* indexpath =[self get_indexpath1:[itemjson valueForKey:@"name"]];
                             if(alert)
-                                [self unhide_section:indexpath.section];
+                                [self unhide_section:(int)indexpath.section];
                             if(fields.count==1)
                             {
                                 self.first_miss_pos =  indexpath;
@@ -992,7 +992,7 @@
                         
                         NSIndexPath* indexpath =[self get_indexpath1:[itemjson valueForKey:@"name"]];
                         if(alert)
-                            [self unhide_section:indexpath.section];
+                            [self unhide_section:(int)indexpath.section];
                         if(fields.count==1)
                         {
                             self.first_miss_pos =  indexpath;
@@ -1010,7 +1010,7 @@
                         if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
                         {
                             self.cancommit = false;
-                            NSString* mfield =[NSString stringWithFormat:@"%d. %@ is missing",fields.count+1,itemjson[@"aname"]];
+                            NSString* mfield =[NSString stringWithFormat:@"%ld. %@ is missing",fields.count+1,itemjson[@"aname"]];
                             
                             
                             [fields addObject:mfield];
@@ -1018,7 +1018,7 @@
                             
                             NSIndexPath* indexpath =[self get_indexpath1:[itemjson valueForKey:@"name"]];
                             if(alert)
-                                [self unhide_section:indexpath.section];
+                                [self unhide_section:(int)indexpath.section];
                             if(fields.count==1)
                             {
                                 self.first_miss_pos =  indexpath;
@@ -1522,14 +1522,14 @@
                                 self.cancommit = false;
                                 
                                 
-                                NSString* mfield =[NSString stringWithFormat:@"%d. %@ is missing",fields.count+1,addjson[@"aname"]];
+                                NSString* mfield =[NSString stringWithFormat:@"%ld. %@ is missing",fields.count+1,addjson[@"aname"]];
                                 
                                 [fields addObject:mfield];
                                 
                                 
                                 NSIndexPath* indexpath =[self get_indexpath1:[addjson valueForKey:@"name"]];
                                 if(alert)
-                                    [self unhide_section:indexpath.section];
+                                    [self unhide_section:(int)indexpath.section];
                                 if(fields.count==1)
                                 {
                                     self.first_miss_pos =  indexpath;
@@ -1553,14 +1553,14 @@
                         if([required isEqualToString: @"true"] && action_data==nil)
                         {
                             self.cancommit = false;
-                            NSString* mfield =[NSString stringWithFormat:@"%d. %@ is missing",fields.count+1,addjson[@"aname"]];
+                            NSString* mfield =[NSString stringWithFormat:@"%ld. %@ is missing",fields.count+1,addjson[@"aname"]];
                             
                             [fields addObject:mfield];
                             
                             
                             NSIndexPath* indexpath =[self get_indexpath1:[addjson valueForKey:@"name"]];
                             if(alert)
-                                [self unhide_section:indexpath.section];
+                                [self unhide_section:(int)indexpath.section];
                             if(fields.count==1)
                             {
                                 self.first_miss_pos =  indexpath;
@@ -1605,14 +1605,14 @@
                                         if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
                                         {
                                             self.cancommit = false;
-                                            NSString* mfield =[NSString stringWithFormat:@"%d. %@ is missing",fields.count+1,itemjson[@"aname"]];
+                                            NSString* mfield =[NSString stringWithFormat:@"%ld. %@ is missing",fields.count+1,itemjson[@"aname"]];
                                             
                                             [fields addObject:mfield];
                                             
                                             
                                             NSIndexPath* indexpath =[self get_indexpath1:[itemjson valueForKey:@"name"]];
                                             if(alert)
-                                                [self unhide_section:indexpath.section];
+                                                [self unhide_section:(int)indexpath.section];
                                             if(fields.count==1)
                                             {
                                                 self.first_miss_pos =  indexpath;
@@ -1639,13 +1639,13 @@
                                         if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
                                         {
                                             self.cancommit = false;
-                                            NSString* mfield =[NSString stringWithFormat:@"%d. %@ is missing",fields.count+1,itemjson[@"aname"]];
+                                            NSString* mfield =[NSString stringWithFormat:@"%ld. %@ is missing",fields.count+1,itemjson[@"aname"]];
                                             
                                             [fields addObject:mfield];
                                             
                                             NSIndexPath* indexpath =[self get_indexpath1:[itemjson valueForKey:@"name"]];
                                             if(alert)
-                                                [self unhide_section:indexpath.section];
+                                                [self unhide_section:(int)indexpath.section];
                                             if(fields.count==1)
                                             {
                                                 self.first_miss_pos =  indexpath;
@@ -1674,13 +1674,13 @@
                             if([[addjson valueForKey:@"required"] isEqualToString: @"true"] )
                             {
                                 self.cancommit = false;
-                                NSString* mfield =[NSString stringWithFormat:@"%d. %@ is missing",fields.count+1,addjson[@"aname"]];
+                                NSString* mfield =[NSString stringWithFormat:@"%ld. %@ is missing",fields.count+1,addjson[@"aname"]];
                                 
                                 [fields addObject:mfield];
                                 
                                 NSIndexPath* indexpath =[self get_indexpath1:[addjson valueForKey:@"name"]];
                                 if(alert)
-                                    [self unhide_section:indexpath.section];
+                                    [self unhide_section:(int)indexpath.section];
                                 if(fields.count==1)
                                 {
                                     self.first_miss_pos =  indexpath;
@@ -1835,7 +1835,7 @@
             [retarray addObject:sectionarr];
         }
         
-        NSLog(@"content control count = %d",retarray.count);
+        NSLog(@"content control count = %ld",retarray.count);
         return retarray;
         //    retjson setObject:sec forKey:<#(id<NSCopying>)#>
         //    return nil;
@@ -3033,7 +3033,7 @@
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
 {
     
-    NSLog(@"numberOfSectionsInTableView  = %d",self.content_data_control.count);
+    NSLog(@"numberOfSectionsInTableView  = %ld",self.content_data_control.count);
     
     //    if(self.content_data_control.count>0)
     //        return 1;

+ 1 - 1
RedAnt ERP Mobile/common/Functions/cart/CartViewController.h

@@ -40,7 +40,7 @@
 @property (strong, nonatomic) IBOutlet UIActivityIndicatorView *mum;
 -(void)placeOrder;
 
-@property (nonatomic , copy) void (^onFinishLoad)();
+@property (nonatomic , copy) void (^onFinishLoad)(void);
 //@property (strong, nonatomic) IBOutlet UITableView *orderInfoTableView;
 //@property (strong, nonatomic) IBOutlet UITextField *editCount;
 //@property (strong, nonatomic) IBOutlet UITextField *editOrderID;

+ 357 - 161
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -216,41 +216,74 @@
     }];
     UIAlertAction *actionTwo = [UIAlertAction actionWithTitle:@"Move To Wish List" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
         UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Move Models To Wish List"];
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        [RANetwork request_move_cart2wish:ids completionHandler:^(NSMutableDictionary *result) {
+            NSDictionary* cart_json =result;
             
-            NSDictionary* cart_json = [RANetwork move_cart2wish:ids];
             
-            dispatch_async(dispatch_get_main_queue(), ^{
+            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+            
+            if([[cart_json valueForKey:@"result"] intValue]==2)
+            {
+                
+                
                 
-                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
                 
-                if([[cart_json valueForKey:@"result"] intValue]==2)
-                {
-                    
-                    
-
-                    
 #ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"WatchListViewController,CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                [ActiveViewController Notify:@"WatchListViewController,CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
-                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
-                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
+                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-                    
-                    
-                    [self end_edit];
-                }
-                else
-                {
-                    [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Move Models To Wish List" controller:self] ;
-                }
-                
                 
                 
-            });
-        });
+                [self end_edit];
+            }
+            else
+            {
+                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Move Models To Wish List" controller:self] ;
+            }
+            
+            
+            
+            
+        }];
+//        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//            NSDictionary* cart_json = [RANetwork move_cart2wish:ids];
+//
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//
+//                if([[cart_json valueForKey:@"result"] intValue]==2)
+//                {
+//
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                    [ActiveViewController Notify:@"WatchListViewController,CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+//                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
+//                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//
+//
+//                    [self end_edit];
+//                }
+//                else
+//                {
+//                    [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Move Models To Wish List" controller:self] ;
+//                }
+//
+//
+//
+//            });
+//        });
         
         
     }];
@@ -289,39 +322,69 @@
     //    UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Move Models To Wish List"];
     
-    
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_move_cart2wish:ids completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* cart_json = result;
         
-        NSDictionary* cart_json = [RANetwork move_cart2wish:ids];
         
-        dispatch_async(dispatch_get_main_queue(), ^{
+        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+        
+        if([[cart_json valueForKey:@"result"] intValue]==2)
+        {
             
-            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+            [self end_edit];
             
-            if([[cart_json valueForKey:@"result"] intValue]==2)
-            {
-                
-                [self end_edit];
-                
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"WatchListViewController,CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+            [ActiveViewController Notify:@"WatchListViewController,CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
-                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
-                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+            AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+            [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+            [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
+            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-
-            }
-            else
-            {
-                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Move To Wish List" controller:self] ;
-            }
-            
             
-            
-        });
-    });
+        }
+        else
+        {
+            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Move To Wish List" controller:self] ;
+        }
+        
+        
+        
+        
+    }];
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* cart_json = [RANetwork move_cart2wish: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:@"WatchListViewController,CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+//                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+//                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
+//                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Move To Wish List" controller:self] ;
+//            }
+//
+//
+//
+//        });
+//    });
     
     
     //    }];
@@ -745,83 +808,160 @@
         DebugLog(@"reloading...");
         UIAlertView *loadingView = [RAUtils waiting_alert:@"Please Wait" title:@"Loading"];
         
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        [RANetwork request_cart:weakself.sortIndex completionHandler:^(NSMutableDictionary *result) {
             DebugLog(@"BEGIN LOAD CART");
-            NSDictionary* cart_json = [RANetwork request_Cart:weakself.sortIndex];
+            NSDictionary* cart_json = result;
             
-            dispatch_async(dispatch_get_main_queue(), ^{
-                //
-//                [self.mum stopAnimating];
-                [loadingView dismissWithClickedButtonIndex:0 animated:YES];
-                
-                //            self.content_data = [cart_json mutableCopy];
+            //
+            //                [self.mum stopAnimating];
+            [loadingView dismissWithClickedButtonIndex:0 animated:YES];
+            
+            //            self.content_data = [cart_json mutableCopy];
 #ifdef BACKORDER_PROCESS
-                weakself.back_order_flag = [[cart_json objectForKey:@"back_order_version"] boolValue];
+            weakself.back_order_flag = [[cart_json objectForKey:@"back_order_version"] boolValue];
 #else
-                weakself.back_order_flag = NO;
+            weakself.back_order_flag = NO;
 #endif
+            
+            if (!weakself.back_order_flag) {
+                weakself.freejson = [cart_json objectForKey:@"freeGiveaway"];
+                weakself.notes = [cart_json valueForKey:@"general_note"];
+                weakself.content_arr = [RAUtils dictionary2array:cart_json count_fields:@"count" item_mark:@"item_" items_mark:nil];
+                weakself.currentOrderIsMerged = [[cart_json valueForKey:@"is_merged_order"] boolValue];
+                [Singleton sharedInstance].currentOrderIsMerged = weakself.currentOrderIsMerged;
+                [weakself.itemListTable reloadData];
+                weakself.print_url = [cart_json valueForKey:@"cart_print_url"];
                 
-                if (!weakself.back_order_flag) {
-                    weakself.freejson = [cart_json objectForKey:@"freeGiveaway"];
-                    weakself.notes = [cart_json valueForKey:@"general_note"];
-                    weakself.content_arr = [RAUtils dictionary2array:cart_json count_fields:@"count" item_mark:@"item_" items_mark:nil];
-                    weakself.currentOrderIsMerged = [[cart_json valueForKey:@"is_merged_order"] boolValue];
-                    [Singleton sharedInstance].currentOrderIsMerged = weakself.currentOrderIsMerged;
-                    [weakself.itemListTable reloadData];
-                    weakself.print_url = [cart_json valueForKey:@"cart_print_url"];
-                    
-                    
-                    [weakself checkProductAvailable:weakself.content_arr];
-                    
-                    
-                    [weakself refresh_total];
-                } else {
-                    // v1.94
-                    weakself.freejson = [cart_json objectForKey:@"freeGiveaway"];
-                    weakself.notes = [cart_json valueForKey:@"general_note"];
-                    weakself.cart_json = cart_json;
-                    [weakself.itemListTable reloadData];
-                    weakself.print_url = [cart_json valueForKey:@"cart_print_url"];
-                    [weakself checkProductAvailable:weakself.content_arr];
-                }
                 
-                int result=[[cart_json valueForKey:@"result"] intValue];
+                [weakself checkProductAvailable:weakself.content_arr];
                 
-                if (weakself.dataOperationQueue.operationCount > 1) {
-                    weakself.isrefreshing=false;
-                    return;
-                }
                 
-                if(result==2||result==1||result==0)
+                [weakself refresh_total];
+            } else {
+                // v1.94
+                weakself.freejson = [cart_json objectForKey:@"freeGiveaway"];
+                weakself.notes = [cart_json valueForKey:@"general_note"];
+                weakself.cart_json = cart_json;
+                [weakself.itemListTable reloadData];
+                weakself.print_url = [cart_json valueForKey:@"cart_print_url"];
+                [weakself checkProductAvailable:weakself.content_arr];
+            }
+            
+            int result_code=[[cart_json valueForKey:@"result"] intValue];
+            
+            if (weakself.dataOperationQueue.operationCount > 1) {
+                weakself.isrefreshing=false;
+                return;
+            }
+            
+            if(result_code==2||result_code==1||result_code==0)
+            {
+                
+                [weakself.edit_select_arr removeAllObjects];
+                
+                weakself.itemListTable.hidden = false;
+                //                    UIApplication * app = [UIApplication sharedApplication];
+                //                    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+                //                    appDelegate.cart_count =weakself.content_arr.count;//[[self.content_data valueForKey:@"count"] intValue];
+                weakself.itemListTable.hidden=false;
+                if(weakself.onFinishLoad)
+                    weakself.onFinishLoad();
+            }
+            else
+                if(result_code==RESULT_NET_ERROR)
                 {
-                    
-                    [weakself.edit_select_arr removeAllObjects];
-                    
-                    weakself.itemListTable.hidden = false;
-//                    UIApplication * app = [UIApplication sharedApplication];
-//                    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-//                    appDelegate.cart_count =weakself.content_arr.count;//[[self.content_data valueForKey:@"count"] intValue];
-                    weakself.itemListTable.hidden=false;
-                    if(weakself.onFinishLoad)
-                        weakself.onFinishLoad();
+                    weakself.label_net_err.hidden=false;
+                    weakself.itemListTable.hidden=true;
                 }
                 else
-                    if(result==RESULT_NET_ERROR)
-                    {
-                        weakself.label_net_err.hidden=false;
-                        weakself.itemListTable.hidden=true;
-                    }
-                    else
-                    {
-                        if(result!=1)
-                            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Loading Cart" controller:weakself] ;
-                    }
-                
-                weakself.isrefreshing=false;
-                DebugLog(@"FINISH LOAD CART");
-                
-            });
-        });
+                {
+                    if(result_code!=1)
+                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Loading Cart" controller:weakself] ;
+                }
+            
+            weakself.isrefreshing=false;
+            DebugLog(@"FINISH LOAD CART");
+            
+            
+        }];
+        
+//        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//            DebugLog(@"BEGIN LOAD CART");
+//            NSDictionary* cart_json = [RANetwork request_Cart:weakself.sortIndex];
+//
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//                //
+////                [self.mum stopAnimating];
+//                [loadingView dismissWithClickedButtonIndex:0 animated:YES];
+//
+//                //            self.content_data = [cart_json mutableCopy];
+//#ifdef BACKORDER_PROCESS
+//                weakself.back_order_flag = [[cart_json objectForKey:@"back_order_version"] boolValue];
+//#else
+//                weakself.back_order_flag = NO;
+//#endif
+//
+//                if (!weakself.back_order_flag) {
+//                    weakself.freejson = [cart_json objectForKey:@"freeGiveaway"];
+//                    weakself.notes = [cart_json valueForKey:@"general_note"];
+//                    weakself.content_arr = [RAUtils dictionary2array:cart_json count_fields:@"count" item_mark:@"item_" items_mark:nil];
+//                    weakself.currentOrderIsMerged = [[cart_json valueForKey:@"is_merged_order"] boolValue];
+//                    [Singleton sharedInstance].currentOrderIsMerged = weakself.currentOrderIsMerged;
+//                    [weakself.itemListTable reloadData];
+//                    weakself.print_url = [cart_json valueForKey:@"cart_print_url"];
+//
+//
+//                    [weakself checkProductAvailable:weakself.content_arr];
+//
+//
+//                    [weakself refresh_total];
+//                } else {
+//                    // v1.94
+//                    weakself.freejson = [cart_json objectForKey:@"freeGiveaway"];
+//                    weakself.notes = [cart_json valueForKey:@"general_note"];
+//                    weakself.cart_json = cart_json;
+//                    [weakself.itemListTable reloadData];
+//                    weakself.print_url = [cart_json valueForKey:@"cart_print_url"];
+//                    [weakself checkProductAvailable:weakself.content_arr];
+//                }
+//
+//                int result=[[cart_json valueForKey:@"result"] intValue];
+//
+//                if (weakself.dataOperationQueue.operationCount > 1) {
+//                    weakself.isrefreshing=false;
+//                    return;
+//                }
+//
+//                if(result==2||result==1||result==0)
+//                {
+//
+//                    [weakself.edit_select_arr removeAllObjects];
+//
+//                    weakself.itemListTable.hidden = false;
+////                    UIApplication * app = [UIApplication sharedApplication];
+////                    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+////                    appDelegate.cart_count =weakself.content_arr.count;//[[self.content_data valueForKey:@"count"] intValue];
+//                    weakself.itemListTable.hidden=false;
+//                    if(weakself.onFinishLoad)
+//                        weakself.onFinishLoad();
+//                }
+//                else
+//                    if(result==RESULT_NET_ERROR)
+//                    {
+//                        weakself.label_net_err.hidden=false;
+//                        weakself.itemListTable.hidden=true;
+//                    }
+//                    else
+//                    {
+//                        if(result!=1)
+//                            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Loading Cart" controller:weakself] ;
+//                    }
+//
+//                weakself.isrefreshing=false;
+//                DebugLog(@"FINISH LOAD CART");
+//
+//            });
+//        });
     });
     //    [[self navigationController] setNavigationBarHidden:YES animated:NO];
 }
@@ -2313,65 +2453,121 @@
         NSString* cart_item_id = [item_json valueForKey:@"cart_item_id"];
         [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
         
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//            ModelItemCell* cell=[self.itemListTable cellForRowAtIndexPath:indexPath];
-//            [cell cancel_setQTY];
+        [RANetwork request_move_cart2wish:cart_item_id completionHandler:^(NSMutableDictionary *result) {
+            NSDictionary* return_json = result;
             
-            NSDictionary* return_json = [RANetwork move_cart2wish:cart_item_id ];
             
-            dispatch_async(dispatch_get_main_queue(), ^{
+            if([[return_json valueForKey:@"result"] intValue]==2)
+            {
+                
+                
+                
+                
+                
                 
-                if([[return_json valueForKey:@"result"] intValue]==2)
-                {
-                    
-                    
-                    
-
-                    
-                    
 #ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"WatchListViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                [ActiveViewController Notify:@"WatchListViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
-                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-                    
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                
 #endif
-                    
-                    
-                    for(int i=0;i<self.content_arr.count;i++)
+                
+                
+                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:cart_item_id])
                     {
-                        NSDictionary* obj_json = self.content_arr[i];
-                        NSString* _id =[obj_json valueForKey:@"cart_item_id"];
-                        if([_id isEqualToString:cart_item_id])
-                        {
-                            if (self.back_order_flag) {
-                                [self updateItemJson:nil atIndexPath:indexPath];
-                            } else {
-                                [self.content_arr removeObjectAtIndex:i];
-                            }
-                            [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
-                            appDelegate.cart_count--;
-                            [appDelegate update_count_mark];
-                            
-                            
-                            [self refresh_total];
+                        if (self.back_order_flag) {
+                            [self updateItemJson:nil atIndexPath:indexPath];
+                        } else {
+                            [self.content_arr removeObjectAtIndex:i];
                         }
+                        [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
+                        appDelegate.cart_count--;
+                        [appDelegate update_count_mark];
+                        
                         
+                        [self refresh_total];
                     }
                     
-                    [self.itemListTable reloadData];
-
-                }
-                else
-                {
-                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Move To Wish List" controller:self] ;
                 }
                 
+                [self.itemListTable reloadData];
                 
-                
-            });
-        });
+            }
+            else
+            {
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Move To Wish List" controller:self] ;
+            }
+            
+            
+            
+            
+        }];
+        
+//        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+////            ModelItemCell* cell=[self.itemListTable cellForRowAtIndexPath:indexPath];
+////            [cell cancel_setQTY];
+//
+//            NSDictionary* return_json = [RANetwork move_cart2wish:cart_item_id ];
+//
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                if([[return_json valueForKey:@"result"] intValue]==2)
+//                {
+//
+//
+//
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                    [ActiveViewController Notify:@"WatchListViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+//                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//
+//#endif
+//
+//
+//                    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:cart_item_id])
+//                        {
+//                            if (self.back_order_flag) {
+//                                [self updateItemJson:nil atIndexPath:indexPath];
+//                            } else {
+//                                [self.content_arr removeObjectAtIndex:i];
+//                            }
+//                            [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
+//                            appDelegate.cart_count--;
+//                            [appDelegate update_count_mark];
+//
+//
+//                            [self refresh_total];
+//                        }
+//
+//                    }
+//
+//                    [self.itemListTable reloadData];
+//
+//                }
+//                else
+//                {
+//                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Move To Wish List" controller:self] ;
+//                }
+//
+//
+//
+//            });
+//        });
         
         
         

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

@@ -133,7 +133,7 @@
                     
                     NSString* value_id=[NSString stringWithFormat:@"%@",[valjson valueForKey:@"value_id"]];
                     
-                    int index=[checked indexOfObject:value_id];
+                    int index=(int)[checked indexOfObject:value_id];
                     if(NSNotFound!=index&& checked!=nil)
                     {
                         

+ 2 - 2
RedAnt ERP Mobile/common/Functions/contact/ContactListViewController.h

@@ -25,8 +25,8 @@
 @property (strong,nonatomic) NSString* contact_type;
 @property (strong,nonatomic) NSString* keywords;
 @property (nonatomic , copy) void (^returnValue)(NSMutableDictionary* value,NSIndexPath* source);
-@property (nonatomic , copy) void (^onCancel)();
-@property (nonatomic , copy) void (^onReset)();
+@property (nonatomic , copy) void (^onCancel)(void);
+@property (nonatomic , copy) void (^onReset)(void);
 @property (strong,nonatomic) NSIndexPath* from;
 @property (strong,nonatomic) NSString* is_subaction;
 @property (strong,nonatomic) NSString* subaction_tag;

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

@@ -571,7 +571,7 @@
     
     UITableViewCell *cell = (UITableViewCell *)btn.superview.superview;;
     NSIndexPath *indexPath = [self.table indexPathForCell:cell];
-    DebugLog(@"indexPath is = %i",indexPath.row);
+    DebugLog(@"indexPath is = %ld",indexPath.row);
     
     
     NSString* contactid=[self.content_data[indexPath.row] valueForKey:@"contact_id"] ;
@@ -656,39 +656,39 @@
     return ;
     
 //    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//        
+//
 //        NSDictionary* editor_json = [RANetwork request_CustomerInfo:contactid];
-//        
+//
 //        dispatch_async(dispatch_get_main_queue(), ^{
-//            
+//
 //            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-//            
+//
 //            if([[editor_json valueForKey:@"result"] intValue]==2)
 //            {
 //                __block NSMutableDictionary* data_init = [[editor_json objectForKey:@"customerInfo" ] mutableCopy];
-//                
+//
 //                //---------------- construct customer_contact----------------------
 //                NSString* customer_first_name = [data_init valueForKey:@"customer_first_name"];
 //                if(customer_first_name==nil)
 //                    customer_first_name=@"";
-//                
+//
 //                NSString* customer_last_name= [data_init valueForKey:@"customer_last_name"];
 //                if(customer_last_name==nil)
 //                    customer_last_name=@"";
 //                NSString* customer_contact = [NSString stringWithFormat:@"%@ %@",customer_first_name,customer_last_name];
 //                customer_contact=[customer_contact stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
 //                [data_init setValue:customer_contact forKey:@"customer_contact"];
-//                
+//
 //                data_init[@"is_subaction"]=self.is_subaction;
 //                data_init[@"subaction_tag"]= self.subaction_tag;
 //                [self.navigationController popToRootViewControllerAnimated:false];
-//                
-//                
+//
+//
 //                [self.table reloadData];
 //                NSLog(@"%s reloadData",__FUNCTION__);
 //                if(self.returnValue)
 //                    self.returnValue(data_init,self.from);
-//                
+//
 //                //                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
 //                //                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
 //                //                    NSDictionary* editor_json = [iSalesNetwork update_OrderCustomer:appDelegate.order_code customerinfo:data_init];
@@ -718,15 +718,15 @@
 //                //
 //                //                    });
 //                //                });
-//                
+//
 //            }
 //            else
 //            {
 //                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Loading Contact Information" controller:self] ;
 //                //                self.btn_assign.enabled=false;
 //            }
-//            
-//            
+//
+//
 //        });
 //    });
     

+ 2 - 2
RedAnt ERP Mobile/common/Functions/home/HomeViewController.m

@@ -524,7 +524,7 @@
         [imgScroll setTotalPagesCount];
         imgScroll.TapActionBlock = ^(NSInteger pageIndex){
             DebugLog(@"点击了第%ld个",(long)pageIndex);
-            NSDictionary * item_json =[view_json objectForKey:[NSString stringWithFormat:@"item_%d",pageIndex] ];
+            NSDictionary * item_json =[view_json objectForKey:[NSString stringWithFormat:@"item_%ld",pageIndex] ];
             NSString* action = [item_json valueForKeyPath:@"action"];
             
             [Singleton sharedInstance].homeClickedItemName = @"slide_view";
@@ -731,7 +731,7 @@
 
    
     //这个sender其实就是UIButton,因此通过sender.tag就可以拿到刚才的参数
-    int tag = [sender tag];
+    int tag = (int)[sender tag];
     int section = tag/1000;
     int row = (tag-section*1000)/100;
     int idx =(tag-section*1000 - row*100);

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

@@ -250,7 +250,7 @@
     SelectOrderTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SelectOrderTableViewCell" forIndexPath:indexPath];
     
     NSDictionary *dic = [self.mergeList objectAtIndex:indexPath.row];
-    int check = [dic[@"check"] integerValue];
+    int check = [dic[@"check"] intValue];
     NSString *so_id = dic[@"so_id"];
     NSString *create_by = dic[@"create_by"];
     NSString *create_time = [dic[@"create_time"] stringByAppendingString:@" PST"];
@@ -356,7 +356,7 @@
     
     NSMutableDictionary *dic = (NSMutableDictionary *)[self.mergeList objectAtIndex:indexPath.row];
 
-    int check = [dic[@"check"] integerValue];
+    int check = [dic[@"check"] intValue];
    
     if (cell.checkedButton.selected) {
         check = 1;

+ 412 - 189
RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m

@@ -1059,50 +1059,92 @@
 - (void)opentOrder:(void(^)(void))completionBlk {
     
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Open Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_open_order:self.order_code completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* order_json = result;
         
-        NSDictionary* order_json = [RANetwork open_Order:self.order_code];
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-            if([[order_json valueForKey:@"result"] intValue]==2)
-            {
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                appDelegate.order_code = self.order_code;
-                appDelegate.order_status = self.order_status;
-                [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
-                
-                
-                appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
-                
-                appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
-                
-//                [self.navigationController popViewControllerAnimated:false];
-                
+        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+        if([[order_json valueForKey:@"result"] intValue]==2)
+        {
+            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+            appDelegate.order_code = self.order_code;
+            appDelegate.order_status = self.order_status;
+            [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
+            
+            
+            appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
+            
+            appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
+            
+            //                [self.navigationController popViewControllerAnimated:false];
+            
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"CartViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+            [ActiveViewController Notify:@"CartViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
+            //                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+            [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+            [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
 #endif
-                
-                if (completionBlk) {
-                    completionBlk();
-                }
-                
-//                if(self.selectOrder)
-//                    self.selectOrder(self.content_data);
-            }
-            else
-            {
-                [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
-            }
-            
             
+            if (completionBlk) {
+                completionBlk();
+            }
             
-        });
-    });
+            //                if(self.selectOrder)
+            //                    self.selectOrder(self.content_data);
+        }
+        else
+        {
+            [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
+        }
+        
+        
+        
+        
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* order_json = [RANetwork open_Order:self.order_code];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//            if([[order_json valueForKey:@"result"] intValue]==2)
+//            {
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                appDelegate.order_code = self.order_code;
+//                appDelegate.order_status = self.order_status;
+//                [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
+//
+//
+//                appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
+//
+//                appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
+//
+////                [self.navigationController popViewControllerAnimated:false];
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"CartViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+////                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//                [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
+//#endif
+//
+//                if (completionBlk) {
+//                    completionBlk();
+//                }
+//
+////                if(self.selectOrder)
+////                    self.selectOrder(self.content_data);
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
+//            }
+//
+//
+//
+//        });
+//    });
     
 }
 
@@ -1190,76 +1232,98 @@
         if (self.erpSerialNo) {
             [params setValue:self.erpSerialNo forKey:@"erp_order_serial_no"];
         }
-        
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-            
+        [RANetwork request_orderdetail:params completionHandler:^(NSMutableDictionary *result) {
+            NSDictionary* order_json = result;
             
-            NSDictionary* order_json = [RANetwork request_OrderDetail:params];
             
-            dispatch_async(dispatch_get_main_queue(), ^{
+            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+            [self.mum stopAnimating];
+            if([[order_json valueForKey:@"result"] intValue]==2)
+            {
+                self.detailTable.hidden = false;
+                self.content_data = [order_json mutableCopy];
                 
-                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-                [self.mum stopAnimating];
-                if([[order_json valueForKey:@"result"] intValue]==2)
+                
+            }
+            else {
+                self.content_data = nil;
+                if([[order_json valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
                 {
-                    self.detailTable.hidden = false;
-                    self.content_data = [order_json mutableCopy];
-                    
-                    
+                    self.label_net_err.hidden=false;
+                    self.detailTable.hidden=true;
                 }
-                else {
-                    self.content_data = nil;
-                    if([[order_json valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
+                else
+                {
+                    [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Loading Order Detail" controller:self] ;
+                }
+            }
+            
+            bool web_order =[[self.content_data valueForKey:@"from_online"] boolValue];
+            if(web_order)
+                self.btnCopy.enabled = false;
+            else
+                self.btnCopy.enabled = true;
+            int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
+            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+            int model_count =[[self.content_data valueForKey:@"model_count"] intValue];
+            if(model_count>0)/*&& ! appDelegate.offline_mode*/
+            {
+                if(appDelegate.user_type== USER_ROLE_EMPLOYEE || (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeCustomer))
+                    self.btnPDF.enabled =true;
+                else
+                {
+                    // || appDelegate.user_type==USER_ROLE_CUSTOMER
+                    if(self.is_shoporder)
                     {
-                        self.label_net_err.hidden=false;
-                        self.detailTable.hidden=true;
+                        if(status_code==1||status_code==30)
+                            self.btnPDF.enabled =true;
+                        
                     }
                     else
                     {
-                        [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Loading Order Detail" controller:self] ;
+                        if(status_code==2)
+                            self.btnPDF.enabled =true;
                     }
                 }
+            }
+            //            [self.btnPDF setImage:[[UIImage imageNamed:@"download"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
+            
+            //                NSString* status = [self.content_data valueForKey:@"order_status"];
+            
+            NSString* lock_user = [self.content_data valueForKey:@"opened_customer"];
+            
+            bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
+            if(status_code==1)//[status isEqualToString:@"Saved Order"])
+            {
+                //                        [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
+                //
+                //                        [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
                 
-                bool web_order =[[self.content_data valueForKey:@"from_online"] boolValue];
-                if(web_order)
-                    self.btnCopy.enabled = false;
-                else
-                    self.btnCopy.enabled = true;
-                                int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                int model_count =[[self.content_data valueForKey:@"model_count"] intValue];
-                if(model_count>0)/*&& ! appDelegate.offline_mode*/
+                BOOL condition = offline_edit;
+#ifdef OFFLINE_MODE
+                condition = condition || appDelegate.offline_mode==false;
+#else
+                condition = YES;
+#endif
+                if(condition)
                 {
-                    if(appDelegate.user_type== USER_ROLE_EMPLOYEE || (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeCustomer))
-                        self.btnPDF.enabled =true;
-                    else
-                    {
-                       // || appDelegate.user_type==USER_ROLE_CUSTOMER
-                        if(self.is_shoporder)
-                        {
-                            if(status_code==1||status_code==30)
-                                self.btnPDF.enabled =true;
-
-                        }
-                        else
-                        {
-                            if(status_code==2)
-                                self.btnPDF.enabled =true;
-                        }
-                    }
+                    self.btnOpen.enabled =true;
+                    
+                    self.btnSign.enabled = true;
                 }
-                //            [self.btnPDF setImage:[[UIImage imageNamed:@"download"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
-                
-//                NSString* status = [self.content_data valueForKey:@"order_status"];
-
-                NSString* lock_user = [self.content_data valueForKey:@"opened_customer"];
-
-                bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
-                if(status_code==1)//[status isEqualToString:@"Saved Order"])
+                //                if([lock_user isEqualToString:appDelegate.user])
+                //                {
+                //                    self.btnCommit.enabled =true;
+                //                }
+                //                else
+                //                     self.btnCommit.enabled =false;
+            }
+            else
+                if(status_code==0)//[status isEqualToString:@"Quote Saved"])
                 {
-                    //                        [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
+                    //                    [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
                     //
-                    //                        [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
+                    //                    [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
                     
                     BOOL condition = offline_edit;
 #ifdef OFFLINE_MODE
@@ -1267,74 +1331,192 @@
 #else
                     condition = YES;
 #endif
-                    if(condition)
-                    {
-                    self.btnOpen.enabled =true;
-                    
-                    self.btnSign.enabled = true;
-                    }
-                    //                if([lock_user isEqualToString:appDelegate.user])
-                    //                {
-                    //                    self.btnCommit.enabled =true;
-                    //                }
-                    //                else
-                    //                     self.btnCommit.enabled =false;
-                }
-                else
-                    if(status_code==0)//[status isEqualToString:@"Quote Saved"])
+                    if (condition)
                     {
-                        //                    [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
-                        //
-                        //                    [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
+                        self.btnOpen.enabled =true;
                         
-                        BOOL condition = offline_edit;
-#ifdef OFFLINE_MODE
-                        condition = condition || appDelegate.offline_mode==false;
-#else
-                        condition = YES;
-#endif
-                        if (condition)
-                        {
-                            self.btnOpen.enabled =true;
-                            
-                            self.btnSign.enabled = true;
-                        }
-                        //                    self.btnCommit.enabled =false;
+                        self.btnSign.enabled = true;
                     }
-                BOOL lock_condition_1 = [lock_user isEqualToString:appDelegate.user];
-                BOOL lock_condition_2 = false;
+                    //                    self.btnCommit.enabled =false;
+                }
+            BOOL lock_condition_1 = [lock_user isEqualToString:appDelegate.user];
+            BOOL lock_condition_2 = false;
 #ifdef OFFLINE_MODE
-                lock_condition_1 = !appDelegate.offline_mode && lock_condition_1;
-                lock_condition_2 = appDelegate.offline_mode && [self.order_code isEqualToString:appDelegate.order_code];
+            lock_condition_1 = !appDelegate.offline_mode && lock_condition_1;
+            lock_condition_2 = appDelegate.offline_mode && [self.order_code isEqualToString:appDelegate.order_code];
 #endif
+            
+            if((lock_condition_1 || lock_condition_2)&& (status_code==1||status_code==0))
+            {
+                //                [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
                 
-                if((lock_condition_1 || lock_condition_2)&& (status_code==1||status_code==0))
-                {
-                    //                [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
-                    
-                    
-                    self.btnRelease.enabled =true;
-                }
-                else
-                {
-                    
-                    
-                    //                    [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
-                    self.btnRelease.enabled =false;
-                }
                 
-                [self.detailTable reloadData];
-                self.isrefreshing=false;
+                self.btnRelease.enabled =true;
+            }
+            else
+            {
                 
-                if (self.order_code == nil) {
-                    self.btnCopy.enabled = false;
-                } else {
-                    self.btnCopy.enabled = true;
-                }
                 
-            });
+                //                    [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
+                self.btnRelease.enabled =false;
+            }
             
-        });
+            [self.detailTable reloadData];
+            self.isrefreshing=false;
+            
+            if (self.order_code == nil) {
+                self.btnCopy.enabled = false;
+            } else {
+                self.btnCopy.enabled = true;
+            }
+            
+            
+        }];
+        
+//        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//
+//            NSDictionary* order_json = [RANetwork request_OrderDetail:params];
+//
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//                [self.mum stopAnimating];
+//                if([[order_json valueForKey:@"result"] intValue]==2)
+//                {
+//                    self.detailTable.hidden = false;
+//                    self.content_data = [order_json mutableCopy];
+//
+//
+//                }
+//                else {
+//                    self.content_data = nil;
+//                    if([[order_json valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
+//                    {
+//                        self.label_net_err.hidden=false;
+//                        self.detailTable.hidden=true;
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Loading Order Detail" controller:self] ;
+//                    }
+//                }
+//
+//                bool web_order =[[self.content_data valueForKey:@"from_online"] boolValue];
+//                if(web_order)
+//                    self.btnCopy.enabled = false;
+//                else
+//                    self.btnCopy.enabled = true;
+//                                int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                int model_count =[[self.content_data valueForKey:@"model_count"] intValue];
+//                if(model_count>0)/*&& ! appDelegate.offline_mode*/
+//                {
+//                    if(appDelegate.user_type== USER_ROLE_EMPLOYEE || (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeCustomer))
+//                        self.btnPDF.enabled =true;
+//                    else
+//                    {
+//                       // || appDelegate.user_type==USER_ROLE_CUSTOMER
+//                        if(self.is_shoporder)
+//                        {
+//                            if(status_code==1||status_code==30)
+//                                self.btnPDF.enabled =true;
+//
+//                        }
+//                        else
+//                        {
+//                            if(status_code==2)
+//                                self.btnPDF.enabled =true;
+//                        }
+//                    }
+//                }
+//                //            [self.btnPDF setImage:[[UIImage imageNamed:@"download"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
+//
+////                NSString* status = [self.content_data valueForKey:@"order_status"];
+//
+//                NSString* lock_user = [self.content_data valueForKey:@"opened_customer"];
+//
+//                bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
+//                if(status_code==1)//[status isEqualToString:@"Saved Order"])
+//                {
+//                    //                        [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
+//                    //
+//                    //                        [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
+//
+//                    BOOL condition = offline_edit;
+//#ifdef OFFLINE_MODE
+//                    condition = condition || appDelegate.offline_mode==false;
+//#else
+//                    condition = YES;
+//#endif
+//                    if(condition)
+//                    {
+//                    self.btnOpen.enabled =true;
+//
+//                    self.btnSign.enabled = true;
+//                    }
+//                    //                if([lock_user isEqualToString:appDelegate.user])
+//                    //                {
+//                    //                    self.btnCommit.enabled =true;
+//                    //                }
+//                    //                else
+//                    //                     self.btnCommit.enabled =false;
+//                }
+//                else
+//                    if(status_code==0)//[status isEqualToString:@"Quote Saved"])
+//                    {
+//                        //                    [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
+//                        //
+//                        //                    [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
+//
+//                        BOOL condition = offline_edit;
+//#ifdef OFFLINE_MODE
+//                        condition = condition || appDelegate.offline_mode==false;
+//#else
+//                        condition = YES;
+//#endif
+//                        if (condition)
+//                        {
+//                            self.btnOpen.enabled =true;
+//
+//                            self.btnSign.enabled = true;
+//                        }
+//                        //                    self.btnCommit.enabled =false;
+//                    }
+//                BOOL lock_condition_1 = [lock_user isEqualToString:appDelegate.user];
+//                BOOL lock_condition_2 = false;
+//#ifdef OFFLINE_MODE
+//                lock_condition_1 = !appDelegate.offline_mode && lock_condition_1;
+//                lock_condition_2 = appDelegate.offline_mode && [self.order_code isEqualToString:appDelegate.order_code];
+//#endif
+//
+//                if((lock_condition_1 || lock_condition_2)&& (status_code==1||status_code==0))
+//                {
+//                    //                [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
+//
+//
+//                    self.btnRelease.enabled =true;
+//                }
+//                else
+//                {
+//
+//
+//                    //                    [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
+//                    self.btnRelease.enabled =false;
+//                }
+//
+//                [self.detailTable reloadData];
+//                self.isrefreshing=false;
+//
+//                if (self.order_code == nil) {
+//                    self.btnCopy.enabled = false;
+//                } else {
+//                    self.btnCopy.enabled = true;
+//                }
+//
+//            });
+//
+//        });
     });
 }
 - (void)viewWillAppear:(BOOL)animated
@@ -3541,50 +3723,91 @@
 - (void)copyOrder {
     
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Copy Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* order_json = [RANetwork copy_Order:self.order_code];
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-            if([[order_json valueForKey:@"result"] intValue]==2)
-            {
-                //     NSString* orderCode = [order_json valueForKey:@"orderCode"];
-                
-                //                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                //                    if([appDelegate.order_code isEqualToString: self.order_code])
-                //                    {
-                //                        [appDelegate closeOrder];
-                ////                        appDelegate.order_code= nil;
-                //                        [appDelegate SetSo:nil];
-                //
-                //
-                //                    }
-                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Copy successful." message:[NSString stringWithFormat:@"New order SO#: %@",[order_json valueForKey:@"so_id"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-                
-                [alert show];
-                
-
-                
+    [RANetwork request_copy_order:self.order_code completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* order_json = result;
+        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+        if([[order_json valueForKey:@"result"] intValue]==2)
+        {
+            //     NSString* orderCode = [order_json valueForKey:@"orderCode"];
+            
+            //                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+            //                    if([appDelegate.order_code isEqualToString: self.order_code])
+            //                    {
+            //                        [appDelegate closeOrder];
+            ////                        appDelegate.order_code= nil;
+            //                        [appDelegate SetSo:nil];
+            //
+            //
+            //                    }
+            UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Copy successful." message:[NSString stringWithFormat:@"New order SO#: %@",[order_json valueForKey:@"so_id"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+            
+            [alert show];
+            
+            
+            
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+            [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-                
-                [self.navigationController popViewControllerAnimated:false];
-                
-            }
-            else
-            {
-                [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Cpoy Order" controller:self] ;
-            }
-            
             
+            [self.navigationController popViewControllerAnimated:false];
             
-        });
-    });
+        }
+        else
+        {
+            [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Cpoy Order" controller:self] ;
+        }
+        
+        
+        
+        
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* order_json = [RANetwork copy_Order:self.order_code];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//            if([[order_json valueForKey:@"result"] intValue]==2)
+//            {
+//                //     NSString* orderCode = [order_json valueForKey:@"orderCode"];
+//
+//                //                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                //                    if([appDelegate.order_code isEqualToString: self.order_code])
+//                //                    {
+//                //                        [appDelegate closeOrder];
+//                ////                        appDelegate.order_code= nil;
+//                //                        [appDelegate SetSo:nil];
+//                //
+//                //
+//                //                    }
+//                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Copy successful." message:[NSString stringWithFormat:@"New order SO#: %@",[order_json valueForKey:@"so_id"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+//
+//                [alert show];
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                [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.navigationController popViewControllerAnimated:false];
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Cpoy Order" controller:self] ;
+//            }
+//
+//
+//
+//        });
+//    });
 
 }
 

+ 75 - 34
RedAnt ERP Mobile/common/Functions/order/OrderListViewController.m

@@ -2208,48 +2208,89 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
     NSString *so = [order objectForKey:@"so#"];
     
     __weak typeof(self) weakself = self;
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    
+    [RANetwork request_open_order:orderCode completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* order_json = result ;
         
-        NSDictionary* order_json = [RANetwork open_Order:orderCode];
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-
-            if([[order_json valueForKey:@"result"] intValue]==2)
-            {
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                appDelegate.order_code = orderCode;
-                appDelegate.order_status = orderStatus;
-                [appDelegate SetSo:so];
-                
-                __weak MainViewController *mainVC = (MainViewController*)appDelegate.main_vc;
-                
+        if([[order_json valueForKey:@"result"] intValue]==2)
+        {
+            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+            appDelegate.order_code = orderCode;
+            appDelegate.order_status = (int)orderStatus;
+            [appDelegate SetSo:so];
+            
+            __weak MainViewController *mainVC = (MainViewController*)appDelegate.main_vc;
+            
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"CartViewController,OrderListViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+            [ActiveViewController Notify:@"CartViewController,OrderListViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                
-                
-                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
+            
+            
+            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+            [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+            [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
 #endif
-                
-                [((MainViewController*)appDelegate.main_vc) switchToCart];
-                
-                mainVC.cartViewController.onFinishLoad=^{
-                    [mainVC.cartViewController placeOrder];
-                    mainVC.cartViewController.onFinishLoad=nil;
-                };
-                
-            }
-            else
-            {
-                [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:weakself] ;
-            }
             
+            [((MainViewController*)appDelegate.main_vc) switchToCart];
             
+            mainVC.cartViewController.onFinishLoad=^{
+                [mainVC.cartViewController placeOrder];
+                mainVC.cartViewController.onFinishLoad=nil;
+            };
             
-        });
-    });
+        }
+        else
+        {
+            [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:weakself] ;
+        }
+        
+        
+        
+        
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* order_json = [RANetwork open_Order:orderCode];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//
+//            if([[order_json valueForKey:@"result"] intValue]==2)
+//            {
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                appDelegate.order_code = orderCode;
+//                appDelegate.order_status = orderStatus;
+//                [appDelegate SetSo:so];
+//
+//                __weak MainViewController *mainVC = (MainViewController*)appDelegate.main_vc;
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"CartViewController,OrderListViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//
+//
+//                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//                [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
+//#endif
+//
+//                [((MainViewController*)appDelegate.main_vc) switchToCart];
+//
+//                mainVC.cartViewController.onFinishLoad=^{
+//                    [mainVC.cartViewController placeOrder];
+//                    mainVC.cartViewController.onFinishLoad=nil;
+//                };
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:weakself] ;
+//            }
+//
+//
+//
+//        });
+//    });
 
     
 }

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

@@ -58,7 +58,7 @@
     
     self.editLineNotes.enabled = NO;
         
-    self.label_multiItems.text = [NSString stringWithFormat:@"%d items selected",self.ids_count ? self.ids_count :  self.arr_fashion_ids.count];//ids_count多选情况有值,而self.arr_fashion_ids在单选情况才不为空
+    self.label_multiItems.text = [NSString stringWithFormat:@"%ld items selected",self.ids_count ? self.ids_count :  self.arr_fashion_ids.count];//ids_count多选情况有值,而self.arr_fashion_ids在单选情况才不为空
 
     
         self.editPrice.enabled = false;

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

@@ -1035,7 +1035,7 @@
 //        NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
         
         vc.arr_fashion_ids = nil;
-        vc.ids_count=checked.count;
+        vc.ids_count=(int)checked.count;
         
         //        vc.fashionid =        [NSString stringWithFormat:@"%d",[[item_json valueForKey:@"fashion_id"] intValue]];
 //        vc.qty = [[item_json valueForKey:@"available_qty"] intValue];
@@ -1063,7 +1063,7 @@
                     
                     if([[cart_json valueForKey:@"result"] intValue]==2)
                     {
-                        [RAUtils message_alert:[NSString stringWithFormat:@"%d items saved.",checked.count] title:@"Edit Portfolio" controller:self] ;
+                        [RAUtils message_alert:[NSString stringWithFormat:@"%ld items saved.",checked.count] title:@"Edit Portfolio" controller:self] ;
                         [self reload_data];
                     }
                     else
@@ -1927,8 +1927,8 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
 #pragma mark - Jack
 
 - (BOOL)allChecked {
-    int checkedCount = [[self.content_data objectForKey:checked_Count] integerValue];
-    int count = [[self.content_data objectForKey:@"count"] integerValue];
+    int checkedCount = [[self.content_data objectForKey:checked_Count] intValue];
+    int count = [[self.content_data objectForKey:@"count"] intValue];
     
     return checkedCount == count;
 }
@@ -1947,7 +1947,7 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
 
 - (void)checkedCountRise:(BOOL)rise {
     
-    int checkedCount = [[self.content_data objectForKey:checked_Count] integerValue];
+    int checkedCount = [[self.content_data objectForKey:checked_Count] intValue];
     
     if (rise) {
         checkedCount++;

+ 79 - 46
RedAnt ERP Mobile/common/Functions/watchlist/WatchListViewController.m

@@ -241,59 +241,92 @@
     NSString * ids = [checked_iid componentsJoinedByString:@","];
     self.btnAddtoCart.enabled = false;
     
-    
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_move_wish2cart:ids completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* return_json = result;
+        
         
-        NSDictionary* return_json = [RANetwork move_wish2cart:ids];
+        self.btnAddtoCart.enabled = true;
         
-        dispatch_async(dispatch_get_main_queue(), ^{
+        if([[return_json valueForKey:@"result"] intValue]==2)
+        {
+            
             
-            self.btnAddtoCart.enabled = true;
             
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-//                int result=[[return_json valueForKey:@"result"] intValue];re
-//                if(result==2)
-//                {
-                    //successed.
-                    
-            //        NSString* order_code = [return_json valueForKey:@"order_code"];
-                
-//                    appDelegate.order_code = order_code;
-//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//                    appDelegate.order_code = order_code;
-
-                
-                
-                
-                
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"WatchListViewController,CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+            [ActiveViewController Notify:@"WatchListViewController,CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
-                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
-                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+            [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+            [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
+            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-                    [RAUtils message_alert:nil title:@" Multiple items moved to Cart" controller:self] ;
-                    
-//                    [self end_select];
-                    
-                    
-                    
-//                }
-            }
-            else
-            {
-                [self reload_data];
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Move To Cart" controller:self] ;
-            }
-            
+            [RAUtils message_alert:nil title:@" Multiple items moved to Cart" controller:self] ;
             
-            
-            
-        });
-    });
+        }
+        else
+        {
+            [self reload_data];
+            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Move To Cart" controller:self] ;
+        }
+        
+        
+        
+        
+        
+    }];
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* return_json = [RANetwork move_wish2cart:ids];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//
+//            self.btnAddtoCart.enabled = true;
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+////                int result=[[return_json valueForKey:@"result"] intValue];re
+////                if(result==2)
+////                {
+//                    //successed.
+//
+//            //        NSString* order_code = [return_json valueForKey:@"order_code"];
+//
+////                    appDelegate.order_code = order_code;
+////                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+////                    appDelegate.order_code = order_code;
+//
+//
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"WatchListViewController,CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+//                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:true];
+//                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//                    [RAUtils message_alert:nil title:@" Multiple items moved to Cart" controller:self] ;
+//
+////                    [self end_select];
+//
+//
+//
+////                }
+//            }
+//            else
+//            {
+//                [self reload_data];
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Move To Cart" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 -(void) neworder
 {
@@ -890,7 +923,7 @@
     }
     cell.backgroundColor = [UIColor whiteColor];// [UIColor whiteColor];;
     
-    int qty = [item_json[@"cart_count"] integerValue];
+    int qty = [item_json[@"cart_count"] intValue];
     cell.qty_Label.text = [NSString stringWithFormat:@"QTY: %d",qty];
     
     return cell;

+ 1 - 1
RedAnt ERP Mobile/common/Price Setting/PriceSettingViewController.m

@@ -156,7 +156,7 @@
         int check = [[dic objectForKey:@"check"] intValue];
         if (check) {
             
-            priceType = [[dic objectForKey:@"value_code"] integerValue];
+            priceType = [[dic objectForKey:@"value_code"] intValue];
             
             break;
         }

+ 3 - 3
RedAnt ERP Mobile/common/Price Setting/SetCategoryPriceController.m

@@ -113,7 +113,7 @@
         int check = [[dic objectForKey:@"check"] intValue];
         if (check) {
             
-            priceType = [[dic objectForKey:@"value_code"] integerValue];
+            priceType = [[dic objectForKey:@"value_code"] intValue];
             
             break;
         }
@@ -225,13 +225,13 @@
         
         UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Set Price"];
         
-        NSDictionary *dic = [RANetwork set_npd_shop_givenPrice:@{@"base_price" : [NSString stringWithFormat:@"%d",self.priceType],@"discount" : discount,@"category_id" : @(self.categoryID)}.mutableCopy];
+        NSDictionary *dic = [RANetwork set_npd_shop_givenPrice:@{@"base_price" : [NSString stringWithFormat:@"%ld",self.priceType],@"discount" : discount,@"category_id" : @(self.categoryID)}.mutableCopy];
         
         [waitalert dismissWithClickedButtonIndex:0 animated:YES];
         
         if ([[dic objectForKey:@"result"] integerValue] == 2) {
             
-            [self.categoryPrice setObject:[NSString stringWithFormat:@"%d",self.priceType] forKey:@"base_price"];
+            [self.categoryPrice setObject:[NSString stringWithFormat:@"%ld",self.priceType] forKey:@"base_price"];
             [self.categoryPrice setObject:discount forKey:@"price_discount"];
             
             // 将数据返回

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

@@ -96,7 +96,7 @@ extern NSString *const ScreenCodeOfflineSync;
 +(NSDictionary*) add_toCart:(NSString* ) item_id count:(int) count name:(NSString *)name;
 +(NSDictionary*) add_toCart_byName:(NSString* ) model_name withScreen:(NSString *)screenName;
 +(NSDictionary*) add_toWatchList:(NSString* ) item_id withScreen:(NSString *)screenName;
-+(NSDictionary*)request_Cart:(int)sort;
+//+(NSDictionary*)request_Cart:(int)sort;
 //+(NSDictionary*)request_WatchList:(int)sort;
 +(NSDictionary*) portfolio_setPrice:(NSString*) watchlist_id price:(float) price discount:(float) discount QTY:(int)qty qty_p:(float) qty_p notes:(NSString*)notes;
 //+(NSDictionary*) portfolio_setQTY:(NSString*) watchlist_id QTY:(int)qty;
@@ -105,18 +105,18 @@ extern NSString *const ScreenCodeOfflineSync;
 //+(NSDictionary*) cart_check:(NSString* ) item_ids;
 //+(NSDictionary*) watchlist_remove:(NSString* ) item_ids;
 
-+(NSDictionary*) move_wish2cart:(NSString* ) item_ids;
-+(NSDictionary*) move_cart2wish:(NSString* ) item_ids;
+//+(NSDictionary*) move_wish2cart:(NSString* ) item_ids;
+//+(NSDictionary*) move_cart2wish:(NSString* ) item_ids;
 
 //+(NSDictionary*)request_OrderList:(int ) offset limit :(int)limit keywords :(NSString* ) keywords status:(NSString*) status_code customer:(NSString*) customer is_merged:(BOOL) isMerged;
-+(NSDictionary*)request_OrderDetail:(NSMutableDictionary *) params;
-+(NSDictionary*)commit_Order:(NSString*) order_code;// saved:(bool) saved;
-+(NSDictionary*)copy_Order:(NSString*) order_code;
+//+(NSDictionary*)request_OrderDetail:(NSMutableDictionary *) params;
+//+(NSDictionary*)commit_Order:(NSString*) order_code;// saved:(bool) saved;
+//+(NSDictionary*)copy_Order:(NSString*) order_code;
 +(NSDictionary*)sign_Order:(NSString*) order_code path:(NSString*)path;
 +(NSDictionary*)update_OrderCustomer:(NSString*) order_code customerinfo:(NSMutableDictionary*)info;
 +(NSDictionary*)saveandcommit_Order:(NSMutableDictionary*)params;
 //+(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*)save_Order:(NSMutableDictionary*)params;
 +(NSDictionary*)delete_Order:(NSString*) order_id;
@@ -219,4 +219,11 @@ extern NSString *const ScreenCodeOfflineSync;
 +(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;
++(void)request_open_order:(NSString*) order_code completionHandler:(resultHandler)result;
++(void)request_cart:(int)sort completionHandler:(resultHandler)result;
++(void) request_move_wish2cart:(NSString* ) item_ids completionHandler:(resultHandler)result;
++(void) request_move_cart2wish:(NSString* ) item_ids completionHandler:(resultHandler)result;
++(void)request_orderdetail:(NSMutableDictionary *) params completionHandler:(resultHandler)result;
+//+(void)request_commit_order:(NSString*) order_code completionHandler:(resultHandler)result;
++(void)request_copy_order:(NSString*) order_code completionHandler:(resultHandler)result;
 @end

+ 649 - 2
RedAnt ERP Mobile/common/data_provider/RANetwork.m

@@ -4341,7 +4341,7 @@ repeat:
         appDelegate.user_type = [[objheader valueForKey:@"user_type"] intValue];
         appDelegate.user_icon =[objheader valueForKey:@"user_img"] ;
         appDelegate.bLogin = true;
-        appDelegate.customer_type = [[objheader valueForKey:@"customer_login_type"] integerValue];
+        appDelegate.customer_type = [[objheader valueForKey:@"customer_login_type"] intValue];
         
         
         
@@ -5433,7 +5433,7 @@ repeat:
         appDelegate.user_type = [[objheader valueForKey:@"user_type"] intValue];
         appDelegate.user_icon =[objheader valueForKey:@"user_img"] ;
         appDelegate.bLogin = true;
-        appDelegate.customer_type = [[objheader valueForKey:@"customer_login_type"] integerValue];
+        appDelegate.customer_type = [[objheader valueForKey:@"customer_login_type"] intValue];
         
         
         
@@ -7072,5 +7072,652 @@ repeat:
 //    }
 //
 //    return jsobj;
+}
++(void)request_open_order:(NSString*) order_code completionHandler:(resultHandler)result
+{
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+     AppDelegate *appDelegate = nil;
+    
+        appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if(appDelegate.user!=nil)
+        [params setValue:appDelegate.user forKey:@"user"];
+    //    if(appDelegate.contact_id!=nil)
+    //        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+    if(appDelegate.password!=nil)
+        [params setValue:appDelegate.password forKey:@"password"];
+    
+    [params setValue:order_code forKey:@"orderCode"];
+    //    [params setValue:sourceid forKey:@"sourceid"];
+    //    [params setValue:editor forKey:@"editor"];
+    
+     [params setValue:ScreenCodeOrderInfo forKey:kScreenName];
+    
+    
+    if(appDelegate.offline_mode)
+    {
+
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            NSMutableDictionary* json = [[OLDataProvider offline_editorder:params] mutableCopy];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                result(json);
+            });
+        });
+        
+        return;
+    }
+    
+    
+    [self request_interface:URL_OPEN_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];
+            
+            if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
+                [Singleton sharedInstance].currentOrderIsMerged = [[resulti valueForKey:@"is_merged_order"] boolValue];
+            }
+            
+        }
+        result(resulti);
+    } retry:0];
+//
+//    NSData* json=nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json=[OLDataProvider offline_editorder:params];
+//
+//    }
+//    else
+//    {
+//        if(![self IsNetworkAvailable])
+//            return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//
+//        json=[self get_json:URL_OPEN_ORDER 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];
+//
+//            if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
+//                [Singleton sharedInstance].currentOrderIsMerged = [[jsobj valueForKey:@"is_merged_order"] boolValue];
+//            }
+//
+//        }
+//
+//        return jsobj;
+//    }
+//    else
+//        return nil;
+}
++(void)request_cart:(int)sort completionHandler:(resultHandler)result
+{
+    
+    DebugLog(@"iSalesNetwork::request_Cart");
+    
+    
+    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:[NSNumber numberWithInt:sort] forKey:@"sort"];
+    
+    [params setObject:ScreenCodeCart forKey:kScreenName];
+    
+    
+    if(appDelegate.offline_mode)
+    {
+
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            NSMutableDictionary* json = [[OLDataProvider offline_requestcart:params] mutableCopy];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                result(json);
+            });
+        });
+        
+        return;
+    }
+    
+    
+    NSString * uuid= [[NSUUID UUID] UUIDString];
+    params[@"resultSerial"]=uuid;
+    __block bool bbreak = false;
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    for(int i=0;i<150;i++)
+    {
+        //           NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
+        //            result_params[@"resultSerial"]=uuid;
+        if(bbreak)
+            break;
+        
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [self request_interface:URL_CART parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
+                    
+                    
+            if([resulti[@"result"] intValue]==2)
+            {
+                bbreak=true;
+                appDelegate.cart_count = [[resulti valueForKey:@"cart_count"] intValue];
+
+                
+                [appDelegate update_count_mark];
+                
+                result(resulti);
+                
+            }
+                
+                
+            } retry:0];
+
+        });
+        
+                   sleep(2);
+        
+//        json=[self get_json:URL_CART parameters:params];
+//        if(json!=nil)
+//        {
+//
+//            NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//            if([jsobj[@"result"] intValue]==2)
+//            {
+//                break;
+//            }
+//        }
+     
+    }
+    });
+    
+    
+
+//
+//
+//
+//    NSData* json=nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json= [OLDataProvider offline_requestcart:params];
+//    }
+//    else
+//    {
+//    if(![self IsNetworkAvailable])
+//        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//
+//        NSError *error=nil;
+//
+//        NSString * uuid= [[NSUUID UUID] UUIDString];
+//        params[@"resultSerial"]=uuid;
+//
+//        for(int i=0;i<150;i++)
+//        {
+//            //           NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
+//            //            result_params[@"resultSerial"]=uuid;
+//            json=[self get_json:URL_CART parameters:params];
+//            if(json!=nil)
+//            {
+//
+//                NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//                if([jsobj[@"result"] intValue]==2)
+//                {
+//                    break;
+//                }
+//            }
+//            sleep(2);
+//        }
+//
+//    }
+//    if(json==nil)
+//        return nil;
+//    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//    int result = [[jsobj valueForKey:@"result"] intValue];
+//
+//    if (result==2)
+//    {
+//
+//        appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
+//        //appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
+//        //    appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
+//
+//        [appDelegate update_count_mark];
+//    }
+//    return jsobj;
+}
+
++(void) request_move_wish2cart:(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:@"collectId"];
+    //    [params setValue:editor forKey:@"editor"];
+    
+    [params setValue:ScreenCodeWishList forKey:kScreenName];
+    [params setValue:@"Move To Cart" forKey:kAction];
+    
+    if(appDelegate.offline_mode)
+    {
+
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            NSMutableDictionary* json = [[OLDataProvider offline_movewish2cart:params] mutableCopy];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                result(json);
+            });
+        });
+        
+        return;
+    }
+    
+    
+    [self request_interface:URL_WISH2CART 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.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
+            
+            [appDelegate update_count_mark];
+            
+        }
+        result(resulti);
+    } retry:0];
+    
+//    
+//    NSData *json = nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json = [OLDataProvider offline_movewish2cart:params];
+//    } else {
+//        if(![self IsNetworkAvailable])
+//            return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//        
+//        json=[self get_json:URL_WISH2CART 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_move_cart2wish:(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:@"Cart Move To Wish List" forKey:kAction];
+    
+    if(appDelegate.offline_mode)
+    {
+
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            NSMutableDictionary* json = [[OLDataProvider offline_movecart2wish:params] mutableCopy];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                result(json);
+            });
+        });
+        
+        return;
+    }
+    
+    
+    [self request_interface:URL_CART2WISH 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.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
+            
+            [appDelegate update_count_mark];
+            
+        }
+        result(resulti);
+    } retry:0];
+//    
+//    NSData* json = nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json= [OLDataProvider offline_movecart2wish:params];
+//    }
+//    else
+//    {
+//    if(![self IsNetworkAvailable])
+//        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//    
+//    json=[self get_json:URL_CART2WISH 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_orderdetail:(NSMutableDictionary *) params completionHandler:(resultHandler)result
+{
+//    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+    if (params == nil) {
+        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:[NSString stringWithFormat:@"%d",limit ] forKey:@"limit"];
+    
+    [params setObject:ScreenCodeOrderInfo forKey:kScreenName];
+    
+        if(appDelegate.offline_mode)
+        {
+
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                NSMutableDictionary* json = [[OLDataProvider offline_orderdetail:params] mutableCopy];
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    result(json);
+                });
+            });
+            
+            return;
+        }
+        
+        
+        NSString * uuid= [[NSUUID UUID] UUIDString];
+        params[@"resultSerial"]=uuid;
+        __block bool bbreak = false;
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        for(int i=0;i<150;i++)
+        {
+            //           NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
+            //            result_params[@"resultSerial"]=uuid;
+            if(bbreak)
+                break;
+            
+            dispatch_async(dispatch_get_main_queue(), ^{
+                [self request_interface:URL_ORDER_DETAIL parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
+                    
+                    
+                    if([resulti[@"result"] intValue]==2||[resulti[@"result"] intValue]==8)
+                    {
+                        bbreak=true;
+                        result(resulti);
+                        
+                    }
+                    
+                    
+                } retry:0];
+                
+            });
+            
+            sleep(2);
+            
+            
+            
+        }
+    });
+    
+    
+//
+//    NSData* json=nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json= [OLDataProvider offline_orderdetail:params];
+//    }
+//    else
+//    {
+//        if(![self IsNetworkAvailable])
+//            return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//
+//            NSError *error=nil;
+//
+//            NSString * uuid= [[NSUUID UUID] UUIDString];
+//            params[@"resultSerial"]=uuid;
+//
+//            for(int i=0;i<150;i++)
+//            {
+//                //           NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
+//                //            result_params[@"resultSerial"]=uuid;
+//                json=[self get_json:URL_ORDER_DETAIL parameters:params];
+//                if(json!=nil)
+//                {
+//
+//                    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//                    int resultCode = [jsobj[@"result"] intValue];
+//                    if(resultCode==2 || resultCode == 8)
+//                    {
+//                        break;
+//                    }
+//                }
+//                sleep(2);
+//            }
+//
+//
+//    }
+//    if(json==nil)
+//        return nil;
+//    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//    return jsobj;
+}
+//
+//+(void)request_commit_order:(NSString*) order_code 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"];
+//    //    NSString* ssaved = @"false";
+//    //     if(saved)
+//    //         ssaved=@"true";
+//    [params setValue:@"true" forKey:@"saved"];
+//    [params setValue:order_code forKey:@"orderCode"];
+//    //    [params setValue:sourceid forKey:@"sourceid"];
+//    //    [params setValue:editor forKey:@"editor"];
+//    
+//     [params setValue:ScreenCodePlaceOrder forKey:kScreenName];
+//    
+//    
+//    if(appDelegate.offline_mode)
+//    {
+//
+//        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//            NSMutableDictionary* json = [[OLDataProvider offline_submitorder:params] mutableCopy];
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//                result(json);
+//            });
+//        });
+//        
+//        return;
+//    }
+//    
+//    
+//    [self request_interface:URL_COMMIT_ORDER parameters:params err_record_url:nil completionHandler:result retry:0];
+//    
+////    NSData* json = nil;
+////
+////    if(appDelegate.offline_mode)
+////    {
+////        json= [OLDataProvider offline_submitorder:params];
+////    }
+////    else
+////    {
+////    if(![self IsNetworkAvailable])
+////        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+////
+////    json=[self get_json:URL_COMMIT_ORDER parameters:params];
+////    }
+////    if(json!=nil)
+////    {
+////        NSError *error=nil;
+////        NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+////        return jsobj;
+////    }
+////    else
+////        return nil;
+//    
+//}
+
+
++(void)request_copy_order:(NSString*) order_code 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"];
+    //    NSString* ssaved = @"false";
+    //     if(saved)
+    //         ssaved=@"true";
+    //  [params setValue:@"true" forKey:@"saved"];
+    [params setValue:order_code forKey:@"code"];
+    //    [params setValue:sourceid forKey:@"sourceid"];
+    //    [params setValue:editor forKey:@"editor"];
+    
+    [params setValue:ScreenCodeOrderInfo forKey:kScreenName];
+    
+        if(appDelegate.offline_mode)
+        {
+    
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                NSMutableDictionary* json = [[OLDataProvider offline_copyorder:params] mutableCopy];
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    result(json);
+                });
+            });
+    
+            return;
+        }
+    
+    
+        [self request_interface:URL_COPY_ORDER parameters:params err_record_url:nil completionHandler:result retry:0];
+        
+    
+    
+//    NSData* json=nil;
+//    if(appDelegate.offline_mode)
+//    {
+//        json= [OLDataProvider offline_copyorder:params];
+//    }
+//    else
+//    {
+//    if(![self IsNetworkAvailable])
+//        return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
+//    
+//    json=[self get_json:URL_COPY_ORDER parameters:params];
+//    }
+//    if(json!=nil)
+//    {
+//        NSError *error=nil;
+//        NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//        return jsobj;
+//    }
+//    else
+//        return nil;
+    
 }
 @end