Przeglądaj źródła

修复erp mobile 警告错误,替换所有网络接口。

Ray Zhang 6 lat temu
rodzic
commit
91d055bba2
55 zmienionych plików z 6861 dodań i 5584 usunięć
  1. 1 1
      RedAnt CRM/APEX CRM/APEX CRM/RAWKWebView.m
  2. 230 105
      RedAnt ERP Mobile/common/AppDelegateBase.m
  3. 210 205
      RedAnt ERP Mobile/common/CartUtils.m
  4. 124 59
      RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m
  5. 3 0
      RedAnt ERP Mobile/common/CommonEditor/EnumSelectViewController.m
  6. 3 3
      RedAnt ERP Mobile/common/ERPUtils.m
  7. 2 2
      RedAnt ERP Mobile/common/ERP_Mobile_Cart.storyboard
  8. 6 6
      RedAnt ERP Mobile/common/ERP_Mobile_Contact.storyboard
  9. 70 94
      RedAnt ERP Mobile/common/ERP_Mobile_Search.storyboard
  10. 118 112
      RedAnt ERP Mobile/common/Functions/MainViewController.m
  11. 46 14
      RedAnt ERP Mobile/common/Functions/address/AddressEditorViewController.m
  12. 28 26
      RedAnt ERP Mobile/common/Functions/camscan/ScannerViewController.m
  13. 18 16
      RedAnt ERP Mobile/common/Functions/cart/CartGeneralNotesViewController.m
  14. 482 300
      RedAnt ERP Mobile/common/Functions/cart/CartViewController.m
  15. 17 15
      RedAnt ERP Mobile/common/Functions/cart/ItemNotesViewController.m
  16. 86 4
      RedAnt ERP Mobile/common/Functions/category/CategorySearchFilterViewController.m
  17. 327 315
      RedAnt ERP Mobile/common/Functions/category/CategoryViewController.m
  18. 4 2
      RedAnt ERP Mobile/common/Functions/contact/ContactListViewController.m
  19. 73 20
      RedAnt ERP Mobile/common/Functions/contact/CustomerEditViewController.m
  20. 234 145
      RedAnt ERP Mobile/common/Functions/contact/CustomerInfoViewController.m
  21. 476 244
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.m
  22. 113 84
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m
  23. 34 32
      RedAnt ERP Mobile/common/Functions/modelDetail/HomerModelDetailHeaderCell.m
  24. 78 74
      RedAnt ERP Mobile/common/Functions/offline/OfflineSettingViewController.m
  25. 5 3
      RedAnt ERP Mobile/common/Functions/offline/OfflineUnlockViewController.m
  26. 60 32
      RedAnt ERP Mobile/common/Functions/offline/SelectUploadOrderViewController.m
  27. 302 114
      RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m
  28. 536 221
      RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m
  29. 205 92
      RedAnt ERP Mobile/common/Functions/order/OrderListViewController.m
  30. 101 47
      RedAnt ERP Mobile/common/Functions/order/RAOrderEditorViewController.m
  31. 366 179
      RedAnt ERP Mobile/common/Functions/order/RAOrderPreviewController.m
  32. 375 317
      RedAnt ERP Mobile/common/Functions/portfolio/PortfolioViewController.m
  33. 228 219
      RedAnt ERP Mobile/common/Functions/portfolio/TearSheetParamViewController.m
  34. 54 6
      RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchFilterViewController.m
  35. 333 319
      RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchViewController.m
  36. 286 272
      RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m
  37. 12 10
      RedAnt ERP Mobile/common/Functions/sidemenu/CacheViewController.m
  38. 164 159
      RedAnt ERP Mobile/common/Functions/sidemenu/LoginViewController.m
  39. 41 20
      RedAnt ERP Mobile/common/Functions/sidemenu/RetrievePassViewController.m
  40. 5 3
      RedAnt ERP Mobile/common/Functions/sidemenu/ScannerSettingViewController.m
  41. 75 73
      RedAnt ERP Mobile/common/Functions/sidemenu/UserListViewController.m
  42. 4 2
      RedAnt ERP Mobile/common/Functions/signature/SignatureViewController.m
  43. 55 45
      RedAnt ERP Mobile/common/Functions/watchlist/WatchListViewController.m
  44. 25 21
      RedAnt ERP Mobile/common/Price Setting/PriceSettingViewController.m
  45. 13 11
      RedAnt ERP Mobile/common/Price Setting/SetCategoryPriceController.m
  46. 3 0
      RedAnt ERP Mobile/common/RAUtils.m
  47. 43 22
      RedAnt ERP Mobile/common/data_provider/RANetwork.h
  48. 397 397
      RedAnt ERP Mobile/common/data_provider/RANetwork.m
  49. 1 3
      RedAnt ERP Mobile/iSales-GATIT.xcodeproj/project.pbxproj
  50. 0 6
      RedAnt ERP Mobile/iSales-NPD.xcodeproj/project.pbxproj
  51. 1 0
      RedAnt ERP Mobile/iSales-NPD/config.h
  52. 3 11
      RedAnt ERP Mobile/iSales-USAI.xcodeproj/project.pbxproj
  53. 1 1
      common/NetworkUtils.h
  54. 195 918
      common/NetworkUtils.m
  55. 189 183
      common/WK PDF+Web/RAPDFViewController.m

+ 1 - 1
RedAnt CRM/APEX CRM/APEX CRM/RAWKWebView.m

@@ -103,7 +103,7 @@
     if(self.wkwebView==nil)
         return;
     NSURL* U=[NSURL URLWithString:url];
-    NSURLRequest* request=[[NSURLRequest alloc]initWithURL:U cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30.0f];
+    NSURLRequest* request=[[NSURLRequest alloc]initWithURL:U cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0f];
     
     [self.wkwebView loadRequest:request];
 }

+ 230 - 105
RedAnt ERP Mobile/common/AppDelegateBase.m

@@ -639,13 +639,30 @@ void UncaughtExceptionHandler(NSException *exception) {
             
             NSString *result = [NSString stringWithFormat:@"version: %@ \n crash_datetime: %@ \n",version,time];
             
-            NSDictionary *ret = [RANetwork err_log:errlog result:result module:@"crash" code:0];
+//            NSDictionary *ret = [RANetwork err_log:errlog result:result module:@"crash" code:0];
             
-            // 上传成功之后清除纪录
-            if ([[ret objectForKey:@"result"] integerValue] == 2) {
-                
-                [iSalesDB execSql:[NSString stringWithFormat:@"delete from errlog where create_time = '%@';",time]];
-            }
+            dispatch_async(dispatch_get_main_queue(), ^{
+                [RANetwork request_err_log:errlog result:result module:@"crash" code:0 completionHandler:^(NSMutableDictionary *result) {
+                    
+                    dispatch_async(dispatch_get_global_queue(0, 0), ^{
+                        
+                        // 上传成功之后清除纪录
+                        if ([[result objectForKey:@"result"] integerValue] == 2) {
+                            
+                            [iSalesDB execSql:[NSString stringWithFormat:@"delete from errlog where create_time = '%@';",time]];
+                        }
+                        
+                        
+                        
+                    });
+                    
+
+                }];
+
+            });
+
+            
+
         }
         
         
@@ -1063,7 +1080,7 @@ void UncaughtExceptionHandler(NSException *exception) {
     
     // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
     // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
-#if defined(BUILD_NPD) || defined(BUILD_USAI)
+#if defined(GOOGLE_ANALYTICS) || defined(BUILD_USAI)
     NSTimeInterval timing = [[NSDate date] timeIntervalSinceDate:self.forgroundDate];
     self.forgroundDate = nil;
 
@@ -1456,113 +1473,216 @@ void UncaughtExceptionHandler(NSException *exception) {
         return;
     
     self.downloading=true;
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        
-        
-        NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
-        
-        NSString*  pvid = [defaults stringForKey:@"vid"] ;
-        
-        
-        
-        [self add_downloadlog:@"Checking offline data, this will take a few minute, please wait."];
-        
-        NSMutableDictionary* json=[[RANetwork  check_Offline:ver useInternalAddress:buseinternaladdress vid:pvid] mutableCopy];
-        
-        
+    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+    
+    NSString*  pvid = [defaults stringForKey:@"vid"] ;
+    
+    
+    
+    [self add_downloadlog:@"Checking offline data, this will take a few minute, please wait."];
+
+    [RANetwork request_new_offline_ticket:ver useInternalAddress:false vid:pvid completionHandler:^(NSMutableDictionary *result) {
+        NSMutableDictionary* json= result;
         if([json[@"result"] intValue]!=2)
         {
             [self add_downloadlog:@"Can not get offline data version, please try again later."];
             [self.settingUI onSyncFinish];
-            dispatch_async(dispatch_get_main_queue(), ^{
-                //    self.downloadlog=nil;
-                self.downloading=false;
-            });
+            
+            
+            //    self.downloadlog=nil;
+            self.downloading=false;
+            
+            
             return;
         }
-        
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [ [ UIApplication sharedApplication] setIdleTimerDisabled:YES ] ;
-        });
-        
-        
-        NSMutableDictionary* download_json=nil;
-        
-        //        NSString* vid=@"31f4d59d-c229-47e3-9270-e15425777186";
-        NSString* downSerial=[json valueForKey:@"downSerial"];
-        
-        [defaults removeObjectForKey:@"downSerial"];
-        [defaults setValue:downSerial forKey:@"downSerial"];
-        
-        [defaults synchronize];
-        
-        //                        sleep(3);
-        //UIAlertView * waitalert1 = [RAUtils waiting_alert:@"Please wait..." title:@"Server is preparing data for you"];
-        
-        
-        //     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        int count=0;
-        //  __block bool preparing = true;
-        while ([[download_json valueForKey:@"result"] intValue]!=2&&count<REQUEST_DOWNLOAD_RETRY_TIMES) //超过60分钟还没准被好数据就视为服务器出错。
+        else
         {
-            sleep(RETRY_DELAY);
+            [ [ UIApplication sharedApplication] setIdleTimerDisabled:YES ] ;
+            __block NSMutableDictionary* download_json=nil;
             
+            //        NSString* vid=@"31f4d59d-c229-47e3-9270-e15425777186";
+            NSString* downSerial=[json valueForKey:@"downSerial"];
             
-            count++;
-            download_json=[[RANetwork  download_Offline:downSerial] mutableCopy];
+            [defaults removeObjectForKey:@"downSerial"];
+            [defaults setValue:downSerial forKey:@"downSerial"];
             
+            [defaults synchronize];
             
+            //                        sleep(3);
+            //UIAlertView * waitalert1 = [RAUtils waiting_alert:@"Please wait..." title:@"Server is preparing data for you"];
             
             
-        }
-        
-        //服务器准备数据完毕,进入处理数据逻辑。
-        if(count>=REQUEST_DOWNLOAD_RETRY_TIMES)
-        {
-            [self add_downloadlog:@"Can not get offline data version, please try again later."];
-            dispatch_async(dispatch_get_main_queue(), ^{
-                //                self.downloadlog=nil;
-                self.downloading=false;
-            });
+            //     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//            int count=0;
+//            //  __block bool preparing = true;
+//            while ([[download_json valueForKey:@"result"] intValue]!=2&&count<REQUEST_DOWNLOAD_RETRY_TIMES) //超过60分钟还没准被好数据就视为服务器出错。
+//            {
+//                sleep(RETRY_DELAY);
+//
+//
+//                count++;
+////                download_json=[[RANetwork  download_Offline:downSerial] mutableCopy];
+//
+//                [RANetwork request_download_offline:downSerial completionHandler:^(NSMutableDictionary *result) {
+//                    download_json=result;
+//                }];
+//
+//
+//
+//
+//            }
+            
+            [RANetwork request_download_offline:downSerial completionHandler:^(NSMutableDictionary *result) {
+                download_json=result;
+                //服务器准备数据完毕,进入处理数据逻辑。
+                if([download_json[@"request_count"] intValue]>=REQUEST_DOWNLOAD_RETRY_TIMES)
+                {
+                    [self add_downloadlog:@"Can not get offline data version, please try again later."];
                     dispatch_async(dispatch_get_main_queue(), ^{
-                [ [ UIApplication sharedApplication] setIdleTimerDisabled:NO ] ;
-            });
-            [self.settingUI onSyncFinish];
-            return;
-            //一直没取到json,出错处理
-        }
-        else
-        {
-            if([download_json[@"count"] intValue]==0)
-            {
-                //没有找到更新包,当前是最新版本
-                [self add_downloadlog:@"You are up-to-date!"];
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    //                    self.downloadlog=nil;
-                    self.downloading=false;
-                });
+                        //                self.downloadlog=nil;
+                        self.downloading=false;
+                    });
+                    dispatch_async(dispatch_get_main_queue(), ^{
+                        [ [ UIApplication sharedApplication] setIdleTimerDisabled:NO ] ;
+                    });
+                    [self.settingUI onSyncFinish];
+                    return;
+                    //一直没取到json,出错处理
+                }
+                else
+                {
+                    if([download_json[@"count"] intValue]==0)
+                    {
+                        //没有找到更新包,当前是最新版本
+                        [self add_downloadlog:@"You are up-to-date!"];
                         dispatch_async(dispatch_get_main_queue(), ^{
-                    [ [ UIApplication sharedApplication] setIdleTimerDisabled:NO ] ;
-                });
-                [self.settingUI onSyncFinish];
-                return;
-            }
-            else
-            {
-                [self add_downloadlog:@"Find a new version, downloading..."];
-                self.download_task = [download_json mutableCopy];
-                //  self.download_task[@"abcdef"]=@"abcdef";
-                long long size= [[self.download_task valueForKey:@"size"] longLongValue] /1024/1024;
-                [self add_downloadlog:[NSString stringWithFormat:@"Total size %lldMB",size]];
-                [self download_offline:true checkdiskspace:true];
-                return;
-            }
+                            //                    self.downloadlog=nil;
+                            self.downloading=false;
+                        });
+                        dispatch_async(dispatch_get_main_queue(), ^{
+                            [ [ UIApplication sharedApplication] setIdleTimerDisabled:NO ] ;
+                        });
+                        [self.settingUI onSyncFinish];
+                        return;
+                    }
+                    else
+                    {
+                        [self add_downloadlog:@"Find a new version, downloading..."];
+                        self.download_task = [download_json mutableCopy];
+                        //  self.download_task[@"abcdef"]=@"abcdef";
+                        long long size= [[self.download_task valueForKey:@"size"] longLongValue] /1024/1024;
+                        [self add_downloadlog:[NSString stringWithFormat:@"Total size %lldMB",size]];
+                        [self download_offline:true checkdiskspace:true];
+                        return;
+                    }
+                    
+                }
+            }];
             
+
         }
         
-    });
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//
+//
+//
+//        NSMutableDictionary* json=[[RANetwork  check_Offline:ver useInternalAddress:buseinternaladdress vid:pvid] mutableCopy];
+//
+//
+//        if([json[@"result"] intValue]!=2)
+//        {
+//            [self add_downloadlog:@"Can not get offline data version, please try again later."];
+//            [self.settingUI onSyncFinish];
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//                //    self.downloadlog=nil;
+//                self.downloading=false;
+//            });
+//            return;
+//        }
+//
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [ [ UIApplication sharedApplication] setIdleTimerDisabled:YES ] ;
+//        });
+//
+//
+//        NSMutableDictionary* download_json=nil;
+//
+//        //        NSString* vid=@"31f4d59d-c229-47e3-9270-e15425777186";
+//        NSString* downSerial=[json valueForKey:@"downSerial"];
+//
+//        [defaults removeObjectForKey:@"downSerial"];
+//        [defaults setValue:downSerial forKey:@"downSerial"];
+//
+//        [defaults synchronize];
+//
+//        //                        sleep(3);
+//        //UIAlertView * waitalert1 = [RAUtils waiting_alert:@"Please wait..." title:@"Server is preparing data for you"];
+//
+//
+//        //     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//        int count=0;
+//        //  __block bool preparing = true;
+//        while ([[download_json valueForKey:@"result"] intValue]!=2&&count<REQUEST_DOWNLOAD_RETRY_TIMES) //超过60分钟还没准被好数据就视为服务器出错。
+//        {
+//            sleep(RETRY_DELAY);
+//
+//
+//            count++;
+//            download_json=[[RANetwork  download_Offline:downSerial] mutableCopy];
+//
+//
+//
+//
+//        }
+//
+//        //服务器准备数据完毕,进入处理数据逻辑。
+//        if(count>=REQUEST_DOWNLOAD_RETRY_TIMES)
+//        {
+//            [self add_downloadlog:@"Can not get offline data version, please try again later."];
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//                //                self.downloadlog=nil;
+//                self.downloading=false;
+//            });
+//                    dispatch_async(dispatch_get_main_queue(), ^{
+//                [ [ UIApplication sharedApplication] setIdleTimerDisabled:NO ] ;
+//            });
+//            [self.settingUI onSyncFinish];
+//            return;
+//            //一直没取到json,出错处理
+//        }
+//        else
+//        {
+//            if([download_json[@"count"] intValue]==0)
+//            {
+//                //没有找到更新包,当前是最新版本
+//                [self add_downloadlog:@"You are up-to-date!"];
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//                    //                    self.downloadlog=nil;
+//                    self.downloading=false;
+//                });
+//                        dispatch_async(dispatch_get_main_queue(), ^{
+//                    [ [ UIApplication sharedApplication] setIdleTimerDisabled:NO ] ;
+//                });
+//                [self.settingUI onSyncFinish];
+//                return;
+//            }
+//            else
+//            {
+//                [self add_downloadlog:@"Find a new version, downloading..."];
+//                self.download_task = [download_json mutableCopy];
+//                //  self.download_task[@"abcdef"]=@"abcdef";
+//                long long size= [[self.download_task valueForKey:@"size"] longLongValue] /1024/1024;
+//                [self add_downloadlog:[NSString stringWithFormat:@"Total size %lldMB",size]];
+//                [self download_offline:true checkdiskspace:true];
+//                return;
+//            }
+//
+//        }
+//
+//    });
 }
 -(void) check_offline:(NSString*) ver useInternalAddress:(bool)buseinternaladdress parentvc:(UIViewController*) parent
 {
@@ -1963,15 +2083,20 @@ void UncaughtExceptionHandler(NSException *exception) {
                     [config_list writeToFile:plistPath atomically:YES];
                 }
                 
-                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                    
-                    
-                    //debug
-//                    NSDictionary* editor_json = [RANetwork finish_download_Offline:downSerial];
-                    [RANetwork finish_download_Offline:downSerial];
-                    
+                
+                [RANetwork request_complete_offline_ticket:downSerial completionHandler:^(NSMutableDictionary *result) {
                     
-                });
+                }];
+                
+//                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//
+//                    //debug
+////                    NSDictionary* editor_json = [RANetwork finish_download_Offline:downSerial];
+//                    [RANetwork finish_download_Offline:downSerial];
+//
+//
+//                });
             }
             
             dispatch_async(dispatch_get_main_queue(), ^{
@@ -2612,7 +2737,7 @@ void UncaughtExceptionHandler(NSException *exception) {
     self.disable_trigger = false;
     [self initialExceptionHandler];
     [self becomeObserver];
-#ifdef BUILD_NPD
+#ifdef GOOGLE_ANALYTICS
     [self setUpGoogleAnalytics];
 #endif
     

+ 210 - 205
RedAnt ERP Mobile/common/CartUtils.m

@@ -22,37 +22,39 @@
     [RANetwork request_create_order:^(NSMutableDictionary *result) {
         NSMutableDictionary* return_json = result;
         
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            if([[return_json valueForKey:@"result"] intValue]==2)
+            {
+                int result=[[return_json valueForKey:@"result"] intValue];
+                if(result==2)
+                {
+                    //successed.
+                    
+                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    appDelegate.order_code = order_code;
+                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+                    
+                    IMP imp = [holder methodForSelector:addtocart];
+                    void (*func)(id, SEL) = (void *)imp;
+                    func(holder, addtocart);
+                    
+                    //                    [holder performSelector:addtocart];
+                    
+                    
+                    
+                    
+                }
+            }
+            else
+            {
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:vc] ;
+            }
+        }];
 //        [waitalert dismissViewControllerAnimated:YES completion:nil];
         
         
-        if([[return_json valueForKey:@"result"] intValue]==2)
-        {
-            int result=[[return_json valueForKey:@"result"] intValue];
-            if(result==2)
-            {
-                //successed.
-                
-                NSString* order_code = [return_json valueForKey:@"orderCode"];
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                appDelegate.order_code = order_code;
-                appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-                   
-                IMP imp = [holder methodForSelector:addtocart];
-                void (*func)(id, SEL) = (void *)imp;
-                func(holder, addtocart);
-                
-//                    [holder performSelector:addtocart];
-                
-                
-                
-                
-            }
-        }
-        else
-        {
-            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:vc] ;
-        }
+
         
         
         
@@ -407,138 +409,16 @@
                     NSMutableDictionary* return_json =result;
                     
                     
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    
-                    if([[return_json valueForKey:@"result"] intValue]==2)
-                    {
-                        
-                        bool openPendingOrder= [[return_json valueForKey:@"hasPending"] boolValue];
-                        bool createNewOrder=appDelegate.can_create_order;
-                        
-                        if(openPendingOrder&&createNewOrder)
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
+                        if([[return_json valueForKey:@"result"] intValue]==2)
                         {
                             
-                            NSString* msg =@"";
-                            if(appDelegate.contact_id.length>0)
-                            {
-                                msg = [msg stringByAppendingString:@"Customer:"];
-                                msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
-                                
-                            }
-                            
-                            UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Add to cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
-                            //block代码块取代了delegate
-                            
-                            
-                            
-                            UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-                                
-                                
-                                //  vc.disable_refresh = true;
-                                OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
-                                ovc.showNavibar = true;
-                                ovc.customer_id = appDelegate.contact_id;
-                                ovc.selectOrder = ^(NSMutableDictionary* order_detail){
-                                    
-                                    IMP imp = [holder methodForSelector:addtocart];
-                                    void (*func)(id, SEL) = (void *)imp;
-                                    func(holder, addtocart);
-//                                    [holder performSelector:addtocart];
-                                    
-                                    
-                                };
-                                ovc.init_style = OL_OPEN;
-                                
-                                ovc.onCancel = ^(){
-                                    
-                                    //  self.disable_refresh = false;
-                                    
-                                    
-                                    
-                                };
-                                
-                                [vc.navigationController pushViewController:ovc animated:true];
-                                
-                                
-                                
-                                
-                                
-                            }];
-                            
-                            UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-                                
-                                
-                                {
-                                    //create new;
-                                    //    self.disable_refresh = true;
-                                    if(appDelegate.customerInfo==nil)// select contact if current contact not exist
-                                    {
-                                        ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
-                                        cvc.showNavibar = true;
-                                        cvc.contact_type = @"Sales_Order_Customer";
-                                        cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-                                            
-                                            appDelegate.contact_id=[value valueForKey:@"customer_cid"];
-                                            appDelegate.customerInfo = value;
-                                            
-                                            
-                                            if(appDelegate.order_code==nil)
-                                                [self neworder:vc selectorholder:holder selector:addtocart];
-                                            //                                                            neworder();
-                                            
-                                            //    [main_vc checklogin:true];
-                                            //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-                                            
-                                            //
-                                            //                if(self.returnValue)
-                                            //                    self.returnValue(value);
-                                        };
-                                        
-                                        cvc.onCancel = ^(){
-                                            
-                                            [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"New Order Error" controller:vc];
-                                            
-                                            // self.disable_refresh = false;
-                                            
-                                        };
-                                        cvc.onReset = ^(){
-                                            // [main_vc checklogin:true];
-                                        };
-                                        
-                                        [vc.navigationController pushViewController:cvc animated:true];
-                                    }
-                                    else
-                                    {
-                                        [self neworder:vc selectorholder:holder selector:addtocart];
-                                    }
-                                    
-                                }
-                                
-                                
-                                DebugLog(@"No");
-                            }];
-                            [alertControl addAction:actionOne];
-                            
-                            [alertControl addAction:alertthree];
-                            
-                            UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
-                            }];
-                            [alertControl addAction:alertcancel];
-                            //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
-                            
+                            bool openPendingOrder= [[return_json valueForKey:@"hasPending"] boolValue];
+                            bool createNewOrder=appDelegate.can_create_order;
                             
-                            [vc presentViewController:alertControl animated:YES completion:nil];
-                            
-                            
-                            
-                            
-                            
-                            
-                        }
-                        else
-                        {
-                            if(openPendingOrder)
+                            if(openPendingOrder&&createNewOrder)
                             {
+                                
                                 NSString* msg =@"";
                                 if(appDelegate.contact_id.length>0)
                                 {
@@ -564,7 +444,7 @@
                                         IMP imp = [holder methodForSelector:addtocart];
                                         void (*func)(id, SEL) = (void *)imp;
                                         func(holder, addtocart);
-//                                        [holder performSelector:addtocart];
+                                        //                                    [holder performSelector:addtocart];
                                         
                                         
                                     };
@@ -586,43 +466,6 @@
                                     
                                 }];
                                 
-                                
-                                [alertControl addAction:actionOne];
-                                UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
-                                }];
-                                [alertControl addAction:alertcancel];
-                                
-                                //   [alertControl addAction:alertthree];
-                                
-                                //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
-                                
-                                
-                                [vc presentViewController:alertControl animated:YES completion:nil];
-                                
-                                
-                                
-                                
-                                
-                                
-                                
-                            }
-                            else if(createNewOrder)
-                            {
-                                NSString* msg =@"";
-                                if(appDelegate.contact_id.length>0)
-                                {
-                                    msg = [msg stringByAppendingString:@"Customer:"];
-                                    msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
-                                    
-                                }
-                                
-                                UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Add to cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
-                                //block代码块取代了delegate
-                                
-                                
-                                
-                                
-                                
                                 UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
                                     
                                     
@@ -675,14 +518,13 @@
                                     
                                     DebugLog(@"No");
                                 }];
-                                //                                        [alertControl addAction:actionOne];
+                                [alertControl addAction:actionOne];
                                 
                                 [alertControl addAction:alertthree];
                                 
                                 UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                                 }];
                                 [alertControl addAction:alertcancel];
-                                
                                 //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
                                 
                                 
@@ -692,21 +534,184 @@
                                 
                                 
                                 
+                                
                             }
                             else
                             {
-                                [RAUtils message_alert:[return_json valueForKey:@"You donot have permission to access order"] title:@"Add To Cart" controller:vc];
+                                if(openPendingOrder)
+                                {
+                                    NSString* msg =@"";
+                                    if(appDelegate.contact_id.length>0)
+                                    {
+                                        msg = [msg stringByAppendingString:@"Customer:"];
+                                        msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
+                                        
+                                    }
+                                    
+                                    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Add to cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                                    //block代码块取代了delegate
+                                    
+                                    
+                                    
+                                    UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                                        
+                                        
+                                        //  vc.disable_refresh = true;
+                                        OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+                                        ovc.showNavibar = true;
+                                        ovc.customer_id = appDelegate.contact_id;
+                                        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+                                            
+                                            IMP imp = [holder methodForSelector:addtocart];
+                                            void (*func)(id, SEL) = (void *)imp;
+                                            func(holder, addtocart);
+                                            //                                        [holder performSelector:addtocart];
+                                            
+                                            
+                                        };
+                                        ovc.init_style = OL_OPEN;
+                                        
+                                        ovc.onCancel = ^(){
+                                            
+                                            //  self.disable_refresh = false;
+                                            
+                                            
+                                            
+                                        };
+                                        
+                                        [vc.navigationController pushViewController:ovc animated:true];
+                                        
+                                        
+                                        
+                                        
+                                        
+                                    }];
+                                    
+                                    
+                                    [alertControl addAction:actionOne];
+                                    UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+                                    }];
+                                    [alertControl addAction:alertcancel];
+                                    
+                                    //   [alertControl addAction:alertthree];
+                                    
+                                    //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
+                                    
+                                    
+                                    [vc presentViewController:alertControl animated:YES completion:nil];
+                                    
+                                    
+                                    
+                                    
+                                    
+                                    
+                                    
+                                }
+                                else if(createNewOrder)
+                                {
+                                    NSString* msg =@"";
+                                    if(appDelegate.contact_id.length>0)
+                                    {
+                                        msg = [msg stringByAppendingString:@"Customer:"];
+                                        msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
+                                        
+                                    }
+                                    
+                                    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Add to cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                                    //block代码块取代了delegate
+                                    
+                                    
+                                    
+                                    
+                                    
+                                    UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                                        
+                                        
+                                        {
+                                            //create new;
+                                            //    self.disable_refresh = true;
+                                            if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+                                            {
+                                                ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+                                                cvc.showNavibar = true;
+                                                cvc.contact_type = @"Sales_Order_Customer";
+                                                cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+                                                    
+                                                    appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+                                                    appDelegate.customerInfo = value;
+                                                    
+                                                    
+                                                    if(appDelegate.order_code==nil)
+                                                        [self neworder:vc selectorholder:holder selector:addtocart];
+                                                    //                                                            neworder();
+                                                    
+                                                    //    [main_vc checklogin:true];
+                                                    //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                                                    
+                                                    //
+                                                    //                if(self.returnValue)
+                                                    //                    self.returnValue(value);
+                                                };
+                                                
+                                                cvc.onCancel = ^(){
+                                                    
+                                                    [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"New Order Error" controller:vc];
+                                                    
+                                                    // self.disable_refresh = false;
+                                                    
+                                                };
+                                                cvc.onReset = ^(){
+                                                    // [main_vc checklogin:true];
+                                                };
+                                                
+                                                [vc.navigationController pushViewController:cvc animated:true];
+                                            }
+                                            else
+                                            {
+                                                [self neworder:vc selectorholder:holder selector:addtocart];
+                                            }
+                                            
+                                        }
+                                        
+                                        
+                                        DebugLog(@"No");
+                                    }];
+                                    //                                        [alertControl addAction:actionOne];
+                                    
+                                    [alertControl addAction:alertthree];
+                                    
+                                    UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+                                    }];
+                                    [alertControl addAction:alertcancel];
+                                    
+                                    //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
+                                    
+                                    
+                                    [vc presentViewController:alertControl animated:YES completion:nil];
+                                    
+                                    
+                                    
+                                    
+                                    
+                                }
+                                else
+                                {
+                                    [RAUtils message_alert:[return_json valueForKey:@"You donot have permission to access order"] title:@"Add To Cart" controller:vc];
+                                }
+                                
                             }
                             
+                            
                         }
-                        
-                        
-                    }
-                    else
-                    {
-                        
-                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Check Pending Order" controller:vc] ;
-                    }
+                        else
+                        {
+                            
+                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Check Pending Order" controller:vc] ;
+                        }
+                    }];
+                    
+                    
+
                     
                     
                     

+ 124 - 59
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m

@@ -410,9 +410,7 @@
             
             
                 
-                [waitalert dismissViewControllerAnimated:YES completion:nil];
-                
-                
+            [waitalert dismissViewControllerAnimated:YES completion:^{
                 if([[editor_json valueForKey:@"result"] intValue]==2)
                 {
                     
@@ -439,6 +437,10 @@
                     [weakself alertMessage:[editor_json valueForKey:@"err_msg"]];
                     
                 }
+            }];
+                
+                
+
                 
                 
             
@@ -1383,9 +1385,7 @@
             NSMutableDictionary* editor_json = result;
             DebugLog(@"data string: %@",[RAConvertor dict2string:editor_json] );
             
-                [waitalert dismissViewControllerAnimated:YES completion:nil];
-                
-                
+            [waitalert dismissViewControllerAnimated:YES completion:^{
                 if([[editor_json valueForKey:@"result"] intValue]==2)
                 {
                     
@@ -1403,6 +1403,10 @@
                     [weakself download_failed];
                     [weakself alertMessage:[editor_json valueForKey:@"err_msg"]];
                 }
+            }];
+                
+                
+
                 
                 
                 
@@ -2616,15 +2620,10 @@
             
             UIAlertController * waitalert = [RAUtils waiting_alert:self message:self.loading_msg title:self.loading_title];
             __weak typeof(self) weakself = self;
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                
-                NSDictionary* editor_json = [RANetwork commoneditor_partialrefresh:params url:url];
-                
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    
-                    
+            
+            [RANetwork request_commoneditor_partialrefresh:params url:url completionHandler:^(NSMutableDictionary *result) {
+                NSDictionary* editor_json =result;
+                [waitalert dismissViewControllerAnimated:YES completion:^{
                     if([[editor_json valueForKey:@"result"] intValue]==2)
                     {
                         
@@ -2645,9 +2644,44 @@
                         [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:weakself] ;
                     }
                     
-                    
-                });
-            });
+                }];
+                
+                
+
+                
+            }];
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSDictionary* editor_json = [RANetwork commoneditor_partialrefresh:params url:url];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//
+//                    if([[editor_json valueForKey:@"result"] intValue]==2)
+//                    {
+//
+//                        int prcount = [[editor_json valueForKey:@"count"] intValue];
+//                        for(int ipr=0;ipr<prcount;ipr++)
+//                        {
+//                            NSDictionary* pr_item = [editor_json objectForKey:[NSString stringWithFormat:@"item_%d",ipr]];
+//                            NSString* name = [pr_item valueForKey:@"name"];
+//                            NSString* value = [pr_item valueForKey:@"value"];
+//
+//                            [weakself setValue:name value:value];
+//                        }
+//
+//
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:weakself] ;
+//                    }
+//
+//
+//                });
+//            });
             
             
             
@@ -2736,15 +2770,10 @@
             
             UIAlertController * waitalert = [RAUtils waiting_alert:self message:self.loading_msg title:self.loading_title];
             __weak typeof(self) weakself = self;
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                
-                NSDictionary* editor_json = [RANetwork commoneditor_partialrefresh:params url:url];
-                
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    
-                    
+            
+            [RANetwork request_commoneditor_partialrefresh:params url:url completionHandler:^(NSMutableDictionary *result) {
+                NSDictionary* editor_json = result;
+                [waitalert dismissViewControllerAnimated:YES completion:^{
                     if([[editor_json valueForKey:@"result"] intValue]==2)
                     {
                         
@@ -2763,10 +2792,44 @@
                     {
                         [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:weakself] ;
                     }
-                    
-                    
-                });
-            });
+                }];
+                
+                
+
+                
+                
+            }];
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSDictionary* editor_json = [RANetwork commoneditor_partialrefresh:params url:url];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//
+//                    if([[editor_json valueForKey:@"result"] intValue]==2)
+//                    {
+//
+//                        int prcount = [[editor_json valueForKey:@"count"] intValue];
+//                        for(int ipr=0;ipr<prcount;ipr++)
+//                        {
+//                            NSDictionary* pr_item = [editor_json objectForKey:[NSString stringWithFormat:@"item_%d",ipr]];
+//                            NSString* name = [pr_item valueForKey:@"name"];
+//                            NSString* value = [pr_item valueForKey:@"value"];
+//
+//                            [weakself setValue:name value:value];
+//                        }
+//
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:weakself] ;
+//                    }
+//
+//
+//                });
+//            });
             
             
             
@@ -4899,36 +4962,38 @@
                 [NetworkUtils upload:imageData FileName:@"test.jpg" Params:params ToHost:URL_UPLOAD_IMG Result:^(NSMutableDictionary *json) {
                     
                     dispatch_async(dispatch_get_main_queue(), ^{
-                        [waitalert dismissViewControllerAnimated:YES completion:nil];
+                        [waitalert dismissViewControllerAnimated:YES completion:^{
+                            if([[json valueForKey:@"result"] intValue]==2)
+                            {
+                                NSString* img_url_down = json[@"img_url_aname"];
+
+                                NSString* img_url_up = json[@"img_url"];
+                                
+                                NSMutableDictionary* item_json =((NSMutableArray*)weakself.content_data_control[indexPath.section])[indexPath.row];
+                                
+                                [item_json setValue:img_url_down forKey:@"avalue"];
+                                [item_json setValue:img_url_up forKey:@"value"];
+                                [item_json setValue:@"true" forKey:@"dirty"];
+                                NSMutableDictionary* section_json = [[weakself.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
+                                [section_json setObject:item_json forKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
+                                
+                                [weakself.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
+                                weakself.content_data_control = [weakself translate_json:weakself.content_data_download changed:weakself.changed_data];
+                                
+                                
+                                CommonEditorCellSignature* cell = (CommonEditorCellSignature*) [weakself.editorTable cellForRowAtIndexPath:indexPath];
+                                
+                                cell.imageviewSignature.image = signimg;
+                                
+                                
+                            }
+                            else
+                            {
+                                [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:weakself] ;
+                            }
+                        }];
                         
-                        if([[json valueForKey:@"result"] intValue]==2)
-                        {
-                            NSString* img_url_down = json[@"img_url_aname"];
 
-                            NSString* img_url_up = json[@"img_url"];
-                            
-                            NSMutableDictionary* item_json =((NSMutableArray*)weakself.content_data_control[indexPath.section])[indexPath.row];
-                            
-                            [item_json setValue:img_url_down forKey:@"avalue"];
-                            [item_json setValue:img_url_up forKey:@"value"];
-                            [item_json setValue:@"true" forKey:@"dirty"];
-                            NSMutableDictionary* section_json = [[weakself.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
-                            [section_json setObject:item_json forKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
-                            
-                            [weakself.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
-                            weakself.content_data_control = [weakself translate_json:weakself.content_data_download changed:weakself.changed_data];
-                            
-                            
-                            CommonEditorCellSignature* cell = (CommonEditorCellSignature*) [weakself.editorTable cellForRowAtIndexPath:indexPath];
-                            
-                            cell.imageviewSignature.image = signimg;
-                            
-                            
-                        }
-                        else
-                        {
-                            [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:weakself] ;
-                        }
                         
                     });
                     

+ 3 - 0
RedAnt ERP Mobile/common/CommonEditor/EnumSelectViewController.m

@@ -405,7 +405,10 @@
                 count++;
             
             if(count-1==indexPath.row)
+            {
                 val_json=search_json;
+            break;
+            }
         }
         
     }

+ 3 - 3
RedAnt ERP Mobile/common/ERPUtils.m

@@ -253,9 +253,9 @@
 
 + (void)googleAnalyticsSendRequestString:(NSString *)urlString WithScreen:(NSString *)screenName Action:(NSString *)action Extra:(NSDictionary *)extra {
 
-#ifndef BUILD_NPD
+#ifndef GOOGLE_ANALYTICS
     return;
-#endif
+#else
     
 //#if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
     if (!screenName && !action && !extra) {
@@ -319,7 +319,7 @@
 
     }
 
-//#endif
+#endif
     
 }
 

+ 2 - 2
RedAnt ERP Mobile/common/ERP_Mobile_Cart.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="ipad9_7" orientation="portrait" layout="fullscreen" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>

+ 6 - 6
RedAnt ERP Mobile/common/ERP_Mobile_Contact.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="ipad9_7" orientation="portrait" layout="fullscreen" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15509"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -33,7 +33,7 @@
                                     <barButtonItem style="plain" systemItem="flexibleSpace" id="Kh1-HL-uSg"/>
                                     <barButtonItem style="plain" id="3JX-S8-pQQ">
                                         <searchBar key="customView" contentMode="redraw" searchBarStyle="minimal" placeholder="Name, Address, Phone etc" id="LlH-OI-NKM">
-                                            <rect key="frame" x="300" y="3" width="361" height="44"/>
+                                            <rect key="frame" x="308" y="3" width="361" height="44"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
                                             <textInputTraits key="textInputTraits"/>
                                             <connections>
@@ -97,12 +97,12 @@
                                 </connections>
                             </tableView>
                             <activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" animating="YES" style="whiteLarge" translatesAutoresizingMaskIntoConstraints="NO" id="2zZ-CD-G37">
-                                <rect key="frame" x="366" y="494" width="37" height="37"/>
+                                <rect key="frame" x="365.5" y="493.5" width="37" height="37"/>
                                 <color key="color" red="0.59999999999999998" green="0.40000000000000002" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                             </activityIndicatorView>
                             <label hidden="YES" opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Cannot get data from server.
Tap to try again." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="R2e-04-QIL">
                                 <rect key="frame" x="262" y="489.5" width="244" height="45.5"/>
-                                <fontDescription key="fontDescription" type="system" pointSize="19"/>
+                                <fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="19"/>
                                 <color key="textColor" red="0.33333333329999998" green="0.33333333329999998" blue="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <nil key="highlightedColor"/>
                             </label>
@@ -137,6 +137,6 @@
     </scenes>
     <resources>
         <image name="assign" width="40" height="40"/>
-        <image name="newcustomer" width="40" height="40"/>
+        <image name="newcustomer" width="32" height="32"/>
     </resources>
 </document>

+ 70 - 94
RedAnt ERP Mobile/common/ERP_Mobile_Search.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="ipad9_7" orientation="portrait" layout="fullscreen" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -12,10 +12,6 @@
         <scene sceneID="69Z-e8-hFe">
             <objects>
                 <viewController storyboardIdentifier="ItemSearchViewController" title="ItemSearchViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="OAq-wC-Znd" customClass="ItemSearchViewController" sceneMemberID="viewController">
-                    <layoutGuides>
-                        <viewControllerLayoutGuide type="top" id="CYC-h2-HA8"/>
-                        <viewControllerLayoutGuide type="bottom" id="N6a-gx-maZ"/>
-                    </layoutGuides>
                     <view key="view" contentMode="scaleToFill" id="c2b-Th-UhH">
                         <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -406,7 +402,7 @@
                                         <nil key="highlightedColor"/>
                                     </label>
                                     <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="MNy-Uo-r2r">
-                                        <rect key="frame" x="525" y="6" width="32" height="32"/>
+                                        <rect key="frame" x="537" y="6" width="32" height="32"/>
                                         <constraints>
                                             <constraint firstAttribute="width" constant="32" id="4eK-ip-LqP"/>
                                             <constraint firstAttribute="height" constant="32" id="UUi-t3-BPc"/>
@@ -423,7 +419,7 @@
                                     <constraint firstItem="4Dr-50-C28" firstAttribute="centerY" secondItem="liz-4V-QlK" secondAttribute="centerY" id="AF3-ZM-Iud"/>
                                     <constraint firstItem="7rl-VN-VwT" firstAttribute="centerY" secondItem="liz-4V-QlK" secondAttribute="centerY" id="BiZ-8g-sRa"/>
                                     <constraint firstItem="MNy-Uo-r2r" firstAttribute="centerY" secondItem="liz-4V-QlK" secondAttribute="centerY" id="KZC-at-8cX"/>
-                                    <constraint firstItem="ACS-Rq-wWj" firstAttribute="leading" secondItem="MNy-Uo-r2r" secondAttribute="trailing" constant="24" id="NPS-f0-6BS"/>
+                                    <constraint firstItem="ACS-Rq-wWj" firstAttribute="leading" secondItem="MNy-Uo-r2r" secondAttribute="trailing" constant="12" id="NPS-f0-6BS"/>
                                     <constraint firstItem="ACS-Rq-wWj" firstAttribute="centerY" secondItem="liz-4V-QlK" secondAttribute="centerY" id="Tog-na-ZLq"/>
                                     <constraint firstItem="7rl-VN-VwT" firstAttribute="leading" secondItem="4Dr-50-C28" secondAttribute="trailing" constant="12" id="XzJ-9S-Xjo"/>
                                     <constraint firstAttribute="height" constant="44" id="bXJ-LW-jKj"/>
@@ -494,14 +490,14 @@
                         <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                         <constraints>
                             <constraint firstItem="liz-4V-QlK" firstAttribute="top" secondItem="c2b-Th-UhH" secondAttribute="top" id="MeY-WH-hvE"/>
-                            <constraint firstItem="G9n-cr-BZw" firstAttribute="centerX" secondItem="c2b-Th-UhH" secondAttribute="centerX" id="TAf-zl-QWd"/>
+                            <constraint firstItem="G9n-cr-BZw" firstAttribute="centerX" secondItem="Y97-Y9-Uum" secondAttribute="centerX" id="TAf-zl-QWd"/>
                             <constraint firstItem="G9n-cr-BZw" firstAttribute="centerY" secondItem="c2b-Th-UhH" secondAttribute="centerY" id="fcs-c3-ZwA"/>
-                            <constraint firstItem="9wz-xR-dz8" firstAttribute="centerX" secondItem="c2b-Th-UhH" secondAttribute="centerX" id="mXI-33-ehy"/>
+                            <constraint firstItem="9wz-xR-dz8" firstAttribute="centerX" secondItem="Y97-Y9-Uum" secondAttribute="centerX" id="mXI-33-ehy"/>
                             <constraint firstItem="9wz-xR-dz8" firstAttribute="centerY" secondItem="c2b-Th-UhH" secondAttribute="centerY" id="qNY-54-Ile"/>
-                            <constraint firstItem="liz-4V-QlK" firstAttribute="trailing" secondItem="EiH-ur-eDT" secondAttribute="trailing" id="tQa-FA-GvW"/>
-                            <constraint firstItem="liz-4V-QlK" firstAttribute="leading" secondItem="EiH-ur-eDT" secondAttribute="leading" id="thr-1H-24J"/>
+                            <constraint firstItem="liz-4V-QlK" firstAttribute="trailing" secondItem="Y97-Y9-Uum" secondAttribute="trailing" id="tQa-FA-GvW"/>
+                            <constraint firstItem="liz-4V-QlK" firstAttribute="leading" secondItem="Y97-Y9-Uum" secondAttribute="leading" id="thr-1H-24J"/>
                         </constraints>
-                        <viewLayoutGuide key="safeArea" id="EiH-ur-eDT"/>
+                        <viewLayoutGuide key="safeArea" id="Y97-Y9-Uum"/>
                     </view>
                     <connections>
                         <outlet property="addAllBtn" destination="388-Ug-Mxj" id="SsU-35-N0e"/>
@@ -527,10 +523,6 @@
         <scene sceneID="5aV-he-25V">
             <objects>
                 <viewController storyboardIdentifier="SearchViewController" title="SearchViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="7Gd-Dn-BSm" customClass="SearchViewController" sceneMemberID="viewController">
-                    <layoutGuides>
-                        <viewControllerLayoutGuide type="top" id="M3c-qa-r7r"/>
-                        <viewControllerLayoutGuide type="bottom" id="dQu-Um-vP0"/>
-                    </layoutGuides>
                     <view key="view" contentMode="scaleToFill" id="t7y-zK-XJN">
                         <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -1027,15 +1019,15 @@
                         </subviews>
                         <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                         <constraints>
-                            <constraint firstItem="wIZ-01-YqU" firstAttribute="centerX" secondItem="t7y-zK-XJN" secondAttribute="centerX" id="2iC-Ju-3Wh"/>
+                            <constraint firstItem="wIZ-01-YqU" firstAttribute="centerX" secondItem="TYD-IC-O3a" secondAttribute="centerX" id="2iC-Ju-3Wh"/>
                             <constraint firstItem="k7R-UE-n8t" firstAttribute="top" secondItem="t7y-zK-XJN" secondAttribute="top" id="3a0-x0-Xza"/>
-                            <constraint firstItem="k7R-UE-n8t" firstAttribute="trailing" secondItem="dTr-YA-UuF" secondAttribute="trailing" id="b52-Of-S0d"/>
-                            <constraint firstItem="k7R-UE-n8t" firstAttribute="leading" secondItem="dTr-YA-UuF" secondAttribute="leading" id="bUQ-AN-BV1"/>
+                            <constraint firstItem="k7R-UE-n8t" firstAttribute="trailing" secondItem="TYD-IC-O3a" secondAttribute="trailing" id="b52-Of-S0d"/>
+                            <constraint firstItem="k7R-UE-n8t" firstAttribute="leading" secondItem="TYD-IC-O3a" secondAttribute="leading" id="bUQ-AN-BV1"/>
                             <constraint firstItem="wIZ-01-YqU" firstAttribute="centerY" secondItem="t7y-zK-XJN" secondAttribute="centerY" id="kCQ-HC-plT"/>
                             <constraint firstItem="423-YP-V6q" firstAttribute="centerY" secondItem="t7y-zK-XJN" secondAttribute="centerY" id="lyx-f9-ris"/>
-                            <constraint firstItem="423-YP-V6q" firstAttribute="centerX" secondItem="t7y-zK-XJN" secondAttribute="centerX" id="na8-q6-24Z"/>
+                            <constraint firstItem="423-YP-V6q" firstAttribute="centerX" secondItem="TYD-IC-O3a" secondAttribute="centerX" id="na8-q6-24Z"/>
                         </constraints>
-                        <viewLayoutGuide key="safeArea" id="dTr-YA-UuF"/>
+                        <viewLayoutGuide key="safeArea" id="TYD-IC-O3a"/>
                     </view>
                     <connections>
                         <outlet property="addAllBtn" destination="1bP-Ac-JaX" id="V2C-rY-Rw3"/>
@@ -1064,10 +1056,6 @@
         <scene sceneID="Xx9-ZR-FjS">
             <objects>
                 <viewController storyboardIdentifier="ItemSearchFilterViewController" title="Item Search Filter" useStoryboardIdentifierAsRestorationIdentifier="YES" id="7KM-2e-YVW" customClass="ItemSearchFilterViewController" sceneMemberID="viewController">
-                    <layoutGuides>
-                        <viewControllerLayoutGuide type="top" id="6ni-CK-478"/>
-                        <viewControllerLayoutGuide type="bottom" id="nGb-Ms-z1p"/>
-                    </layoutGuides>
                     <view key="view" contentMode="scaleToFill" id="tzb-Sy-Soy">
                         <rect key="frame" x="0.0" y="0.0" width="540" height="680"/>
                         <autoresizingMask key="autoresizingMask"/>
@@ -1079,7 +1067,7 @@
                                         <rect key="frame" x="0.0" y="0.0" width="540" height="680"/>
                                         <subviews>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Item Number:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SwC-Ln-c68">
-                                                <rect key="frame" x="20" y="352" width="133" height="21"/>
+                                                <rect key="frame" x="20" y="337" width="133" height="21"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="21" id="9VL-eP-Vwa"/>
                                                     <constraint firstAttribute="width" constant="133" id="eVx-I7-UVH"/>
@@ -1089,7 +1077,7 @@
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Description:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f3R-Q6-vRK">
-                                                <rect key="frame" x="280" y="352" width="133" height="21"/>
+                                                <rect key="frame" x="280" y="337" width="133" height="21"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" constant="133" id="E7C-lO-z4Z"/>
                                                 </constraints>
@@ -1098,7 +1086,7 @@
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="0Od-XM-2kQ">
-                                                <rect key="frame" x="20" y="381" width="240" height="30"/>
+                                                <rect key="frame" x="20" y="366" width="240" height="30"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="30" id="VzF-hv-5XU"/>
                                                     <constraint firstAttribute="width" constant="240" id="YI7-fh-1ON"/>
@@ -1107,7 +1095,7 @@
                                                 <textInputTraits key="textInputTraits"/>
                                             </textField>
                                             <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="uMF-kI-vmY">
-                                                <rect key="frame" x="280" y="381" width="240" height="30"/>
+                                                <rect key="frame" x="280" y="366" width="240" height="30"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="30" id="FAG-qR-KTq"/>
                                                     <constraint firstAttribute="width" constant="240" id="nbt-AL-FIW"/>
@@ -1134,7 +1122,7 @@
                                                 </connections>
                                             </button>
                                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fLS-Yn-00O">
-                                                <rect key="frame" x="20" y="20" width="500" height="320"/>
+                                                <rect key="frame" x="10" y="5" width="520" height="320"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="320" id="Wyb-to-M5i"/>
                                                 </constraints>
@@ -1170,8 +1158,8 @@
                                                     <action selector="onSearchClick:" destination="7KM-2e-YVW" eventType="touchUpInside" id="Pyk-0U-ery"/>
                                                 </connections>
                                             </button>
-                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Availability:" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="73M-vv-4Va">
-                                                <rect key="frame" x="20" y="431" width="120" height="21"/>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Availability:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="73M-vv-4Va">
+                                                <rect key="frame" x="20" y="416" width="120" height="21"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="21" id="qAS-eS-eWI"/>
                                                     <constraint firstAttribute="width" constant="120" id="vg9-Ny-D57"/>
@@ -1181,7 +1169,7 @@
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Jfe-5Y-slQ">
-                                                <rect key="frame" x="148" y="498.5" width="372" height="30"/>
+                                                <rect key="frame" x="148" y="483.5" width="372" height="30"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="30" id="lRh-ct-NRc"/>
                                                     <constraint firstAttribute="width" constant="372" id="zGe-gE-sPY"/>
@@ -1194,7 +1182,7 @@
                                                 </connections>
                                             </button>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2Qp-FH-fAz">
-                                                <rect key="frame" x="148" y="534.5" width="372" height="30"/>
+                                                <rect key="frame" x="148" y="519.5" width="372" height="30"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" constant="372" id="Gwh-OR-mkF"/>
                                                     <constraint firstAttribute="height" constant="30" id="ppt-j6-4gD"/>
@@ -1206,8 +1194,8 @@
                                                     <action selector="onBestSellerClick:" destination="7KM-2e-YVW" eventType="touchUpInside" id="YWp-wb-mcn"/>
                                                 </connections>
                                             </button>
-                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sold by QTY:" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ylk-cI-f1y">
-                                                <rect key="frame" x="20" y="503" width="120" height="21"/>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sold by QTY:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ylk-cI-f1y">
+                                                <rect key="frame" x="20" y="488" width="120" height="21"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" constant="120" id="5Ef-sO-odI"/>
                                                     <constraint firstAttribute="height" constant="21" id="dbr-rG-QDN"/>
@@ -1216,8 +1204,8 @@
                                                 <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                 <nil key="highlightedColor"/>
                                             </label>
-                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Best Seller:" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pnu-Qv-4cA">
-                                                <rect key="frame" x="20" y="539" width="120" height="21"/>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Best Seller:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pnu-Qv-4cA">
+                                                <rect key="frame" x="20" y="524" width="120" height="21"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="21" id="ncZ-wk-Hd4"/>
                                                     <constraint firstAttribute="width" constant="120" id="zsv-fx-fpf"/>
@@ -1226,8 +1214,8 @@
                                                 <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                 <nil key="highlightedColor"/>
                                             </label>
-                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Price:" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VkN-9z-S8u">
-                                                <rect key="frame" x="20" y="575" width="120" height="21"/>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Price:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VkN-9z-S8u">
+                                                <rect key="frame" x="20" y="560" width="120" height="21"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="21" id="Hht-Fq-WDy"/>
                                                     <constraint firstAttribute="width" constant="120" id="WOQ-1H-6Nl"/>
@@ -1237,7 +1225,7 @@
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5mh-pW-BYL">
-                                                <rect key="frame" x="148" y="426.5" width="372" height="30"/>
+                                                <rect key="frame" x="148" y="411.5" width="372" height="30"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" constant="372" id="7V5-hg-IOc"/>
                                                     <constraint firstAttribute="height" constant="30" id="aCP-lA-LnX"/>
@@ -1250,7 +1238,7 @@
                                                 </connections>
                                             </button>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bAe-Za-GgE">
-                                                <rect key="frame" x="148" y="570.5" width="372" height="30"/>
+                                                <rect key="frame" x="148" y="555.5" width="372" height="30"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" constant="372" id="7uj-7x-l8U"/>
                                                     <constraint firstAttribute="height" constant="30" id="r8p-I0-jfF"/>
@@ -1263,7 +1251,7 @@
                                                 </connections>
                                             </button>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8zh-Mf-35k">
-                                                <rect key="frame" x="148" y="462.5" width="372" height="30"/>
+                                                <rect key="frame" x="148" y="447.5" width="372" height="30"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="30" id="BuO-pO-KfJ"/>
                                                     <constraint firstAttribute="width" constant="372" id="fsz-30-O6I"/>
@@ -1275,8 +1263,8 @@
                                                     <action selector="onAlertClick:" destination="7KM-2e-YVW" eventType="touchUpInside" id="5MD-ob-5Ly"/>
                                                 </connections>
                                             </button>
-                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Alert:" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PfB-gh-cVi">
-                                                <rect key="frame" x="20" y="467" width="120" height="21"/>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Alert:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PfB-gh-cVi">
+                                                <rect key="frame" x="20" y="452" width="120" height="21"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" constant="120" id="6dP-SN-S8D"/>
                                                     <constraint firstAttribute="height" constant="21" id="hiK-FL-r0u"/>
@@ -1311,11 +1299,11 @@
                                             <constraint firstItem="PfB-gh-cVi" firstAttribute="leading" secondItem="lF5-wJ-YMQ" secondAttribute="leading" constant="20" id="ana-O1-dui"/>
                                             <constraint firstAttribute="bottom" secondItem="Rgu-uk-snk" secondAttribute="bottom" constant="20" id="bcK-zx-mn6"/>
                                             <constraint firstItem="uMF-kI-vmY" firstAttribute="leading" secondItem="f3R-Q6-vRK" secondAttribute="leading" id="cVS-7W-tT8"/>
-                                            <constraint firstItem="fLS-Yn-00O" firstAttribute="leading" secondItem="lF5-wJ-YMQ" secondAttribute="leading" constant="20" id="d2N-eB-amD"/>
+                                            <constraint firstItem="fLS-Yn-00O" firstAttribute="leading" secondItem="lF5-wJ-YMQ" secondAttribute="leading" constant="10" id="d2N-eB-amD"/>
                                             <constraint firstAttribute="bottom" secondItem="jz1-eL-bX5" secondAttribute="bottom" constant="20" id="gLc-3d-64k"/>
                                             <constraint firstItem="uMF-kI-vmY" firstAttribute="top" secondItem="f3R-Q6-vRK" secondAttribute="bottom" constant="8" id="gfu-4c-NEV"/>
                                             <constraint firstItem="Jfe-5Y-slQ" firstAttribute="firstBaseline" secondItem="ylk-cI-f1y" secondAttribute="firstBaseline" id="hVh-fX-gjg"/>
-                                            <constraint firstItem="fLS-Yn-00O" firstAttribute="top" secondItem="lF5-wJ-YMQ" secondAttribute="top" constant="20" id="i0N-0R-QDU"/>
+                                            <constraint firstItem="fLS-Yn-00O" firstAttribute="top" secondItem="lF5-wJ-YMQ" secondAttribute="top" constant="5" id="i0N-0R-QDU"/>
                                             <constraint firstItem="f3R-Q6-vRK" firstAttribute="top" secondItem="fLS-Yn-00O" secondAttribute="bottom" constant="12" id="i14-XK-PJe"/>
                                             <constraint firstAttribute="trailing" secondItem="uMF-kI-vmY" secondAttribute="trailing" constant="20" id="iNa-Sw-dgh"/>
                                             <constraint firstAttribute="trailing" secondItem="8zh-Mf-35k" secondAttribute="trailing" constant="20" id="lzd-w0-BtI"/>
@@ -1323,7 +1311,7 @@
                                             <constraint firstItem="73M-vv-4Va" firstAttribute="top" secondItem="0Od-XM-2kQ" secondAttribute="bottom" constant="20" id="tyA-zP-iaY"/>
                                             <constraint firstItem="2Qp-FH-fAz" firstAttribute="firstBaseline" secondItem="pnu-Qv-4cA" secondAttribute="firstBaseline" id="wFb-vX-OCA"/>
                                             <constraint firstItem="pnu-Qv-4cA" firstAttribute="leading" secondItem="lF5-wJ-YMQ" secondAttribute="leading" constant="20" id="wVD-Qd-0dB"/>
-                                            <constraint firstAttribute="trailing" secondItem="fLS-Yn-00O" secondAttribute="trailing" constant="20" id="y0A-ma-UfB"/>
+                                            <constraint firstAttribute="trailing" secondItem="fLS-Yn-00O" secondAttribute="trailing" constant="10" id="y0A-ma-UfB"/>
                                             <constraint firstItem="pnu-Qv-4cA" firstAttribute="top" secondItem="ylk-cI-f1y" secondAttribute="bottom" constant="15" id="zoU-zi-TIO"/>
                                         </constraints>
                                     </view>
@@ -1340,12 +1328,12 @@
                         </subviews>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <constraints>
-                            <constraint firstItem="VVf-hI-5G1" firstAttribute="leading" secondItem="rXv-cQ-soF" secondAttribute="leading" id="PmB-ub-vIq"/>
-                            <constraint firstItem="VVf-hI-5G1" firstAttribute="trailing" secondItem="rXv-cQ-soF" secondAttribute="trailing" id="Yem-Tg-7LN"/>
+                            <constraint firstItem="VVf-hI-5G1" firstAttribute="leading" secondItem="wyb-4p-ncE" secondAttribute="leading" id="PmB-ub-vIq"/>
+                            <constraint firstItem="VVf-hI-5G1" firstAttribute="trailing" secondItem="wyb-4p-ncE" secondAttribute="trailing" id="Yem-Tg-7LN"/>
                             <constraint firstAttribute="bottom" secondItem="VVf-hI-5G1" secondAttribute="bottom" id="hfJ-wU-eZ0"/>
                             <constraint firstItem="VVf-hI-5G1" firstAttribute="top" secondItem="tzb-Sy-Soy" secondAttribute="top" id="l4V-Th-7xM"/>
                         </constraints>
-                        <viewLayoutGuide key="safeArea" id="rXv-cQ-soF"/>
+                        <viewLayoutGuide key="safeArea" id="wyb-4p-ncE"/>
                     </view>
                     <value key="contentSizeForViewInPopover" type="size" width="540" height="680"/>
                     <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
@@ -1371,10 +1359,6 @@
         <scene sceneID="vTQ-Ry-D8H">
             <objects>
                 <viewController storyboardIdentifier="CategoryViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="ayt-8S-R1j" customClass="CategoryViewController" sceneMemberID="viewController">
-                    <layoutGuides>
-                        <viewControllerLayoutGuide type="top" id="iPM-DG-Txq"/>
-                        <viewControllerLayoutGuide type="bottom" id="5KJ-Pc-vVD"/>
-                    </layoutGuides>
                     <view key="view" contentMode="scaleToFill" id="uLt-37-b3b">
                         <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
@@ -1860,13 +1844,13 @@
                         <constraints>
                             <constraint firstItem="WTH-xD-Oln" firstAttribute="centerY" secondItem="uLt-37-b3b" secondAttribute="centerY" id="7Sq-dV-qwd"/>
                             <constraint firstItem="0tN-LM-2Xd" firstAttribute="top" secondItem="uLt-37-b3b" secondAttribute="top" id="EgZ-q3-18O"/>
-                            <constraint firstItem="0tN-LM-2Xd" firstAttribute="leading" secondItem="RAm-8h-rXu" secondAttribute="leading" id="FOr-b1-jbd"/>
-                            <constraint firstItem="WTH-xD-Oln" firstAttribute="centerX" secondItem="uLt-37-b3b" secondAttribute="centerX" id="Mhv-ZL-6Ty"/>
+                            <constraint firstItem="0tN-LM-2Xd" firstAttribute="leading" secondItem="Fr5-Zu-LYs" secondAttribute="leading" id="FOr-b1-jbd"/>
+                            <constraint firstItem="WTH-xD-Oln" firstAttribute="centerX" secondItem="Fr5-Zu-LYs" secondAttribute="centerX" id="Mhv-ZL-6Ty"/>
                             <constraint firstItem="CYf-aH-yiE" firstAttribute="centerY" secondItem="uLt-37-b3b" secondAttribute="centerY" id="Z5v-uQ-Sau"/>
-                            <constraint firstItem="CYf-aH-yiE" firstAttribute="centerX" secondItem="uLt-37-b3b" secondAttribute="centerX" id="j28-7X-iSH"/>
-                            <constraint firstItem="0tN-LM-2Xd" firstAttribute="trailing" secondItem="RAm-8h-rXu" secondAttribute="trailing" id="uBf-Wk-QcI"/>
+                            <constraint firstItem="CYf-aH-yiE" firstAttribute="centerX" secondItem="Fr5-Zu-LYs" secondAttribute="centerX" id="j28-7X-iSH"/>
+                            <constraint firstItem="0tN-LM-2Xd" firstAttribute="trailing" secondItem="Fr5-Zu-LYs" secondAttribute="trailing" id="uBf-Wk-QcI"/>
                         </constraints>
-                        <viewLayoutGuide key="safeArea" id="RAm-8h-rXu"/>
+                        <viewLayoutGuide key="safeArea" id="Fr5-Zu-LYs"/>
                     </view>
                     <connections>
                         <outlet property="addAllBtn" destination="4nE-gy-r5m" id="MNr-3d-xkS"/>
@@ -1893,10 +1877,6 @@
         <scene sceneID="voB-Cf-rOL">
             <objects>
                 <viewController storyboardIdentifier="RAViewController" title="Category Selection" useStoryboardIdentifierAsRestorationIdentifier="YES" id="Dnb-uE-W12" customClass="RAViewController" sceneMemberID="viewController">
-                    <layoutGuides>
-                        <viewControllerLayoutGuide type="top" id="QAw-62-5K1"/>
-                        <viewControllerLayoutGuide type="bottom" id="ULJ-2X-vBM"/>
-                    </layoutGuides>
                     <view key="view" contentMode="scaleToFill" id="eFT-gS-v0L">
                         <rect key="frame" x="0.0" y="0.0" width="540" height="620"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -1935,12 +1915,12 @@
                             <constraint firstAttribute="bottom" secondItem="axf-kj-0b6" secondAttribute="bottom" id="2BW-pD-F7U"/>
                             <constraint firstItem="wXt-wd-XeS" firstAttribute="top" secondItem="eFT-gS-v0L" secondAttribute="top" id="8yk-kB-a4G"/>
                             <constraint firstItem="axf-kj-0b6" firstAttribute="top" secondItem="wXt-wd-XeS" secondAttribute="bottom" id="Qxt-uP-tT7"/>
-                            <constraint firstItem="axf-kj-0b6" firstAttribute="leading" secondItem="IgL-hq-mA4" secondAttribute="leading" id="S8a-MF-thI"/>
-                            <constraint firstItem="wXt-wd-XeS" firstAttribute="trailing" secondItem="IgL-hq-mA4" secondAttribute="trailing" id="cCS-Gj-6NA"/>
-                            <constraint firstItem="axf-kj-0b6" firstAttribute="trailing" secondItem="IgL-hq-mA4" secondAttribute="trailing" id="eTY-SI-Zn8"/>
-                            <constraint firstItem="wXt-wd-XeS" firstAttribute="leading" secondItem="IgL-hq-mA4" secondAttribute="leading" id="lvo-9Y-nbx"/>
+                            <constraint firstItem="axf-kj-0b6" firstAttribute="leading" secondItem="dIL-G4-QNB" secondAttribute="leading" id="S8a-MF-thI"/>
+                            <constraint firstItem="wXt-wd-XeS" firstAttribute="trailing" secondItem="dIL-G4-QNB" secondAttribute="trailing" id="cCS-Gj-6NA"/>
+                            <constraint firstItem="axf-kj-0b6" firstAttribute="trailing" secondItem="dIL-G4-QNB" secondAttribute="trailing" id="eTY-SI-Zn8"/>
+                            <constraint firstItem="wXt-wd-XeS" firstAttribute="leading" secondItem="dIL-G4-QNB" secondAttribute="leading" id="lvo-9Y-nbx"/>
                         </constraints>
-                        <viewLayoutGuide key="safeArea" id="IgL-hq-mA4"/>
+                        <viewLayoutGuide key="safeArea" id="dIL-G4-QNB"/>
                     </view>
                     <value key="contentSizeForViewInPopover" type="size" width="540" height="620"/>
                     <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
@@ -1959,10 +1939,6 @@
         <scene sceneID="OUb-Si-EbE">
             <objects>
                 <viewController storyboardIdentifier="CategorySearchFilterViewController" title="Category Filter" useStoryboardIdentifierAsRestorationIdentifier="YES" id="g8P-mU-4x1" customClass="CategorySearchFilterViewController" sceneMemberID="viewController">
-                    <layoutGuides>
-                        <viewControllerLayoutGuide type="top" id="ABg-OI-P4y"/>
-                        <viewControllerLayoutGuide type="bottom" id="rK6-Lu-1Be"/>
-                    </layoutGuides>
                     <view key="view" contentMode="scaleToFill" id="VMz-d0-X7j">
                         <rect key="frame" x="0.0" y="0.0" width="540" height="680"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -1974,7 +1950,7 @@
                                         <rect key="frame" x="0.0" y="0.0" width="540" height="680"/>
                                         <subviews>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Alert:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="l19-cb-AjS">
-                                                <rect key="frame" x="20" y="466" width="150" height="21"/>
+                                                <rect key="frame" x="20" y="451" width="150" height="21"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" constant="150" id="NIf-zb-VmG"/>
                                                     <constraint firstAttribute="height" constant="21" id="tVH-Mh-H5d"/>
@@ -1985,7 +1961,7 @@
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Availability:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fJR-PY-2MQ">
-                                                <rect key="frame" x="20" y="430" width="150" height="21"/>
+                                                <rect key="frame" x="20" y="415" width="150" height="21"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="21" id="LGz-aj-9x0"/>
                                                     <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="120" id="Yv2-hi-qjS"/>
@@ -1996,7 +1972,7 @@
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ei3-Zk-MvM">
-                                                <rect key="frame" x="126" y="497.5" width="394" height="30"/>
+                                                <rect key="frame" x="126" y="482.5" width="394" height="30"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="30" id="3T8-Zn-kaw"/>
                                                 </constraints>
@@ -2008,7 +1984,7 @@
                                                 </connections>
                                             </button>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7ds-kb-06q">
-                                                <rect key="frame" x="176" y="533.5" width="344" height="30"/>
+                                                <rect key="frame" x="176" y="518.5" width="344" height="30"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="30" id="NrN-ga-xBg"/>
                                                 </constraints>
@@ -2020,7 +1996,7 @@
                                                 </connections>
                                             </button>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sold by QTY:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="W2W-6W-20Q">
-                                                <rect key="frame" x="20" y="502" width="100" height="21"/>
+                                                <rect key="frame" x="20" y="487" width="100" height="21"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="21" id="UIO-DC-B1k"/>
                                                     <constraint firstAttribute="width" constant="100" id="iDL-YQ-aO1"/>
@@ -2030,7 +2006,7 @@
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Best Seller:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MdI-LH-ehb">
-                                                <rect key="frame" x="20" y="538" width="150" height="21"/>
+                                                <rect key="frame" x="20" y="523" width="150" height="21"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="21" id="0jh-tO-vJX"/>
                                                     <constraint firstAttribute="width" constant="150" id="Chb-Uz-Oba"/>
@@ -2041,7 +2017,7 @@
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Price:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XyL-AU-Twt">
-                                                <rect key="frame" x="20" y="574" width="150" height="21"/>
+                                                <rect key="frame" x="20" y="559" width="150" height="21"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="120" id="L0C-DS-4oG"/>
                                                     <constraint firstAttribute="width" constant="150" id="anc-Bi-vYh"/>
@@ -2052,7 +2028,7 @@
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="T1S-Bo-LHK">
-                                                <rect key="frame" x="176" y="461.5" width="344" height="30"/>
+                                                <rect key="frame" x="176" y="446.5" width="344" height="30"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="30" id="4hG-qy-GVW"/>
                                                 </constraints>
@@ -2064,7 +2040,7 @@
                                                 </connections>
                                             </button>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Qwu-mH-sLI">
-                                                <rect key="frame" x="176" y="425.5" width="344" height="30"/>
+                                                <rect key="frame" x="176" y="410.5" width="344" height="30"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="30" id="oQr-aV-xte"/>
                                                 </constraints>
@@ -2112,7 +2088,7 @@
                                                 </connections>
                                             </button>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a8R-bc-me5">
-                                                <rect key="frame" x="176" y="569.5" width="344" height="30"/>
+                                                <rect key="frame" x="176" y="554.5" width="344" height="30"/>
                                                 <constraints>
                                                     <constraint firstAttribute="height" constant="30" id="ZzD-F7-mWc"/>
                                                 </constraints>
@@ -2124,19 +2100,19 @@
                                                 </connections>
                                             </button>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Item Number:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MvV-eq-cCO">
-                                                <rect key="frame" x="20" y="352" width="104.5" height="21"/>
+                                                <rect key="frame" x="20" y="337" width="104.5" height="21"/>
                                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                 <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Description:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EGa-0v-X88">
-                                                <rect key="frame" x="280" y="352" width="92.5" height="21"/>
+                                                <rect key="frame" x="280" y="337" width="92.5" height="21"/>
                                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                 <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                 <nil key="highlightedColor"/>
                                             </label>
                                             <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="cQn-hR-TUa">
-                                                <rect key="frame" x="20" y="381" width="240" height="34"/>
+                                                <rect key="frame" x="20" y="366" width="240" height="34"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" constant="240" id="7Mc-nG-fcC"/>
                                                 </constraints>
@@ -2144,7 +2120,7 @@
                                                 <textInputTraits key="textInputTraits"/>
                                             </textField>
                                             <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="eHZ-vh-dRW">
-                                                <rect key="frame" x="280" y="381" width="240" height="34"/>
+                                                <rect key="frame" x="280" y="366" width="240" height="34"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" constant="240" id="Dfv-f3-YUU"/>
                                                 </constraints>
@@ -2161,9 +2137,9 @@
                                         <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                         <constraints>
                                             <constraint firstItem="cQn-hR-TUa" firstAttribute="leading" secondItem="WOe-yi-wQa" secondAttribute="leading" constant="20" id="0Y3-vz-6Mj"/>
-                                            <constraint firstItem="MvV-eq-cCO" firstAttribute="top" secondItem="e3B-9N-eea" secondAttribute="bottom" constant="27" id="9G1-HX-0jj"/>
+                                            <constraint firstItem="MvV-eq-cCO" firstAttribute="top" secondItem="e3B-9N-eea" secondAttribute="bottom" constant="12" id="9G1-HX-0jj"/>
                                             <constraint firstAttribute="bottom" secondItem="xAv-TP-7vv" secondAttribute="bottom" constant="20" id="9iG-gs-4Bu"/>
-                                            <constraint firstItem="EGa-0v-X88" firstAttribute="top" secondItem="e3B-9N-eea" secondAttribute="bottom" constant="27" id="Bsh-to-fql"/>
+                                            <constraint firstItem="EGa-0v-X88" firstAttribute="top" secondItem="e3B-9N-eea" secondAttribute="bottom" constant="12" id="Bsh-to-fql"/>
                                             <constraint firstAttribute="trailing" secondItem="Qwu-mH-sLI" secondAttribute="trailing" constant="20" id="By6-z4-TNa"/>
                                             <constraint firstItem="W2W-6W-20Q" firstAttribute="leading" secondItem="WOe-yi-wQa" secondAttribute="leading" constant="20" id="DAa-Mw-XjH"/>
                                             <constraint firstItem="Qwu-mH-sLI" firstAttribute="leading" secondItem="fJR-PY-2MQ" secondAttribute="trailing" constant="6" id="DMz-uB-Moo"/>
@@ -2220,11 +2196,11 @@
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <constraints>
                             <constraint firstAttribute="bottom" secondItem="9pl-MJ-YCv" secondAttribute="bottom" id="OAv-1Q-EOX"/>
-                            <constraint firstItem="9pl-MJ-YCv" firstAttribute="trailing" secondItem="sVq-TO-q42" secondAttribute="trailing" id="OCV-mJ-BJA"/>
+                            <constraint firstItem="9pl-MJ-YCv" firstAttribute="trailing" secondItem="d47-Eq-xrt" secondAttribute="trailing" id="OCV-mJ-BJA"/>
                             <constraint firstItem="9pl-MJ-YCv" firstAttribute="top" secondItem="VMz-d0-X7j" secondAttribute="top" id="ZYl-ra-F9e"/>
-                            <constraint firstItem="9pl-MJ-YCv" firstAttribute="leading" secondItem="sVq-TO-q42" secondAttribute="leading" id="odv-Ba-YiA"/>
+                            <constraint firstItem="9pl-MJ-YCv" firstAttribute="leading" secondItem="d47-Eq-xrt" secondAttribute="leading" id="odv-Ba-YiA"/>
                         </constraints>
-                        <viewLayoutGuide key="safeArea" id="sVq-TO-q42"/>
+                        <viewLayoutGuide key="safeArea" id="d47-Eq-xrt"/>
                     </view>
                     <value key="contentSizeForViewInPopover" type="size" width="540" height="680"/>
                     <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
@@ -2254,7 +2230,7 @@
         <image name="btn_search" width="102" height="30"/>
         <image name="check_0_24" width="24" height="24"/>
         <image name="check_1_24" width="24" height="24"/>
-        <image name="close" width="40" height="40"/>
+        <image name="close" width="32" height="32"/>
         <image name="filter" width="32" height="32"/>
         <image name="layout_list" width="40" height="40"/>
         <image name="layout_small" width="40" height="40"/>

+ 118 - 112
RedAnt ERP Mobile/common/Functions/MainViewController.m

@@ -665,43 +665,45 @@
         [RANetwork request_logout:^(NSMutableDictionary *result) {
             NSMutableDictionary* return_json =result;
             
-                            [waitalert dismissViewControllerAnimated:YES completion:nil];
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                if([[return_json valueForKey:@"result"] intValue]==2)
+                {
+                    //                    [self hideMenu];
+                    //                    [self switchToHome:nil];
+                    [appDelegate Logout];
+                    [self checklogin :false];
+                    if(showlogin)
+                    {
+                        LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
+                        loginvc.returnValue = ^(bool blogin){
+                            
+                            [self checklogin :true];
+                            
+                        };
+                        
+                        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
+                        
+                        
+                        
+                        
+                        
+                        
+                        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
+                        [self presentViewController:navi animated:YES completion:^{
+                            
+                            DebugLog(@"login present.........");
+                            
+                        }];
+                    }
+                }
+                else
+                {
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Sign Out" controller:self] ;
+                }
+            }];
+                            
                             
                             
-                            if([[return_json valueForKey:@"result"] intValue]==2)
-                            {
-            //                    [self hideMenu];
-            //                    [self switchToHome:nil];
-                                [appDelegate Logout];
-                                [self checklogin :false];
-                                if(showlogin)
-                                {
-                                LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
-                                loginvc.returnValue = ^(bool blogin){
-                                    
-                                    [self checklogin :true];
-                                    
-                                };
-                                
-                                UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-                                
-                                
-                                
-                                
-                                
-                                
-                                navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
-                                [self presentViewController:navi animated:YES completion:^{
-                                    
-                                    DebugLog(@"login present.........");
-                                    
-                                }];
-                                }
-                            }
-                            else
-                            {
-                                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Sign Out" controller:self] ;
-                            }
                             
                             
                             
@@ -1060,61 +1062,63 @@
 #pragma mark - LoginViewControllerDelegate
 -(void)LoginViewControllerDidLogin:(LoginViewController *)viewController
 {
-    [viewController dismissViewControllerAnimated:YES completion:nil];
-    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    
-    self.sideMenu_UserName.text =appDelegate.user;
-    [self.btn_sideMenu_UserName setTitle:appDelegate.user forState:UIControlStateNormal];
-    
-    [self.btnLogin setTitle:@"Sign out" forState:UIControlStateNormal];
-    
-    [RANetwork LoadImage:appDelegate.user_icon into:self.user_head ];
-    
-    if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/true)
-        self.btnContact.hidden = NO;
-//    else
-//        self.btnContact.hidden = YES;
-    
-    NSDictionary * customerinfo=appDelegate.customerInfo;
-    NSString * contact=nil;
-    NSString * customer=nil;
-    if(customerinfo==nil)
-    {
-        contact=@"Select Contact";
-        [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
-    }
-    else
-    {
-        contact=[customerinfo valueForKey:@"customer_contact"];
-        customer=[customerinfo valueForKey:@"customer_name"];
-        if(contact==nil||contact.length==0)
+    [viewController dismissViewControllerAnimated:YES completion:^{
+        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+        
+        self.sideMenu_UserName.text =appDelegate.user;
+        [self.btn_sideMenu_UserName setTitle:appDelegate.user forState:UIControlStateNormal];
+        
+        [self.btnLogin setTitle:@"Sign out" forState:UIControlStateNormal];
+        
+        [RANetwork LoadImage:appDelegate.user_icon into:self.user_head ];
+        
+        if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/true)
+            self.btnContact.hidden = NO;
+        //    else
+        //        self.btnContact.hidden = YES;
+        
+        NSDictionary * customerinfo=appDelegate.customerInfo;
+        NSString * contact=nil;
+        NSString * customer=nil;
+        if(customerinfo==nil)
         {
-            contact=@"No Name";
+            contact=@"Select Contact";
             [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
         }
         else
         {
-            [self.btnContact setTitleColor:UIColorFromRGB(0x009900) forState:UIControlStateNormal];
+            contact=[customerinfo valueForKey:@"customer_contact"];
+            customer=[customerinfo valueForKey:@"customer_name"];
+            if(contact==nil||contact.length==0)
+            {
+                contact=@"No Name";
+                [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
+            }
+            else
+            {
+                [self.btnContact setTitleColor:UIColorFromRGB(0x009900) forState:UIControlStateNormal];
+            }
         }
-    }
-    
-    
-    NSMutableArray* arr_contact = [[NSMutableArray alloc] init];
-    if(contact.length>0)
-        [arr_contact addObject:contact];
-    if(customer.length>0)
-        [arr_contact addObject:customer];
-    
-    NSString *contact_string = [arr_contact componentsJoinedByString:@" @"];
-    
-    
-    [self.btnContact setTitle:contact_string forState:UIControlStateNormal];
-    
-    //    [self.buttonUser setTitle:appDelegate.user forState:UIControlStateNormal];
-    
-    
-    
-    [self reload];
+        
+        
+        NSMutableArray* arr_contact = [[NSMutableArray alloc] init];
+        if(contact.length>0)
+            [arr_contact addObject:contact];
+        if(customer.length>0)
+            [arr_contact addObject:customer];
+        
+        NSString *contact_string = [arr_contact componentsJoinedByString:@" @"];
+        
+        
+        [self.btnContact setTitle:contact_string forState:UIControlStateNormal];
+        
+        //    [self.buttonUser setTitle:appDelegate.user forState:UIControlStateNormal];
+        
+        
+        
+        [self reload];
+        
+    }];
     
     
     
@@ -3083,39 +3087,41 @@
     [RANetwork request_create_order:^(NSMutableDictionary *result) {
         NSMutableDictionary* return_json = result;
         
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-        
-        if([[return_json valueForKey:@"result"] intValue]==2)
-        {
-            int result=[[return_json valueForKey:@"result"] intValue];
-            if(result==2)
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            if([[return_json valueForKey:@"result"] intValue]==2)
             {
-                //successed.
-                
-                NSString* order_code = [return_json valueForKey:@"orderCode"];
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                appDelegate.order_code = order_code;
-                appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-                
-                self.previous_VC = self.current_VC;
-                [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-                
-                
+                int result=[[return_json valueForKey:@"result"] intValue];
+                if(result==2)
+                {
+                    //successed.
+                    
+                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    appDelegate.order_code = order_code;
+                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+                    
+                    self.previous_VC = self.current_VC;
+                    [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
+                    
+                    
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                [self reloadCart:true immediately:false];
-                [self reloadOrder:true immediately:false];
+                    [self reloadCart:true immediately:false];
+                    [self reloadOrder:true immediately:false];
 #endif
-                
-                
+                    
+                    
+                }
             }
-        }
-        else
-        {
-            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-        }
+            else
+            {
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+            }
+        }];
+        
+        
+        
         
         
         

+ 46 - 14
RedAnt ERP Mobile/common/Functions/address/AddressEditorViewController.m

@@ -149,23 +149,23 @@
     if(self.cancommit==false)
         return;
     
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* editor_json = [RANetwork create_Address:upparams];
+    UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Save Address"];
+    
+    [RANetwork request_add_address:upparams completionHandler:^(NSMutableDictionary *result) {
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            
-            
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            NSDictionary* editor_json = result;
             
             if([[editor_json valueForKey:@"result"] intValue]==2)
             {
                 
-//                int result = [[editor_json valueForKey:@"result"] intValue];
+                //                int result = [[editor_json valueForKey:@"result"] intValue];
                 
-//                if(result==2)
+                //                if(result==2)
                 {
-                    [self prepareReturn: nil];
+                    
                     [self.navigationController popViewControllerAnimated:true];
+                    [self prepareReturn: nil];
                 }
                 
                 
@@ -174,11 +174,43 @@
             {
                 [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Create Address" controller:self] ;
             }
-            
-
-            
-        });
-    });
+        }];
+        
+        
+        
+        
+    }];
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* editor_json = [RANetwork create_Address:upparams];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//
+//            if([[editor_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+////                int result = [[editor_json valueForKey:@"result"] intValue];
+//
+////                if(result==2)
+//                {
+//                    [self prepareReturn: nil];
+//                    [self.navigationController popViewControllerAnimated:true];
+//                }
+//
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Create Address" controller:self] ;
+//            }
+//
+//
+//
+//        });
+//    });
     
 }
 

+ 28 - 26
RedAnt ERP Mobile/common/Functions/camscan/ScannerViewController.m

@@ -678,35 +678,37 @@
     [RANetwork request_create_order:^(NSMutableDictionary *result) {
         NSMutableDictionary* return_json = result;
         
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-//        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-        
-        if([[return_json valueForKey:@"result"] intValue]==2)
-        {
-            int result=[[return_json valueForKey:@"result"] intValue];
-            if(result==2)
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            
+            //        [waitalert dismissViewControllerAnimated:YES completion:nil];
+            
+            
+            if([[return_json valueForKey:@"result"] intValue]==2)
+            {
+                int result=[[return_json valueForKey:@"result"] intValue];
+                if(result==2)
+                {
+                    //successed.
+                    
+                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    appDelegate.order_code = order_code;
+                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+                    
+                    
+                    [self addtocart];
+                    
+                    
+                    
+                }
+            }
+            else
             {
-                //successed.
-                
-                NSString* order_code = [return_json valueForKey:@"orderCode"];
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                appDelegate.order_code = order_code;
-                appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-                
-                
-                [self addtocart];
-                
-                
                 
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
             }
-        }
-        else
-        {
-            
-            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-        }
+        }];
+        
         
         
         

+ 18 - 16
RedAnt ERP Mobile/common/Functions/cart/CartGeneralNotesViewController.m

@@ -64,22 +64,24 @@
     [RANetwork request_update_cartgeneralnote:appDelegate.order_code notes:notes completionHandler:^(NSMutableDictionary *result) {
         NSDictionary* cart_json = result;
         
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        //            [waitalert dismissViewControllerAnimated:YES completion:nil];
-        if([[cart_json valueForKey:@"result"] intValue]==2)
-        {
-            [self dismissViewControllerAnimated:NO
-                                     completion:^{
-                
-                if(self.onSetValue)
-                    self.onSetValue(self.notes);
-                
-            }];
-        }
-        else
-        {
-            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update General Notes" controller:self] ;
-        }
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            //            [waitalert dismissViewControllerAnimated:YES completion:nil];
+            if([[cart_json valueForKey:@"result"] intValue]==2)
+            {
+                [self dismissViewControllerAnimated:NO
+                                         completion:^{
+                    
+                    if(self.onSetValue)
+                        self.onSetValue(self.notes);
+                    
+                }];
+            }
+            else
+            {
+                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update General Notes" controller:self] ;
+            }
+        }];
+
         
         
         

Plik diff jest za duży
+ 482 - 300
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m


+ 17 - 15
RedAnt ERP Mobile/common/Functions/cart/ItemNotesViewController.m

@@ -65,21 +65,23 @@
     [RANetwork request_update_cartitemnote:self.cart_id notes:self.tv_notes.text completionHandler:^(NSMutableDictionary *result) {
         
         NSDictionary* cart_json = result;
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        if([[cart_json valueForKey:@"result"] intValue]==2)
-        {
-            [self dismissViewControllerAnimated:NO
-                                     completion:^{
-                                         if(self.onSaveNote)
-                                             
-                                             self.onSaveNote(self.notes);
-                                         
-                                     }];
-        }
-        else
-        {
-            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update Item Notes" controller:self] ;
-        }
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            if([[cart_json valueForKey:@"result"] intValue]==2)
+            {
+                [self dismissViewControllerAnimated:NO
+                                         completion:^{
+                    if(self.onSaveNote)
+                        
+                        self.onSaveNote(self.notes);
+                    
+                }];
+            }
+            else
+            {
+                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update Item Notes" controller:self] ;
+            }
+        }];
+
         
         
         

+ 86 - 4
RedAnt ERP Mobile/common/Functions/category/CategorySearchFilterViewController.m

@@ -244,7 +244,7 @@
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
     
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidChangeFrame:) name:UIKeyboardDidChangeFrameNotification object:nil];
     // Do any additional setup after loading the view.
 }
 -(void) dealloc
@@ -934,9 +934,8 @@
 
 #pragma mark - Responding to keyboard events
 
-
-- (void)keyboardWillChangeFrame:(NSNotification *)notification {
-    NSLog(@"keyboardWillChangeFrame");
+- (void)keyboardDidChangeFrame:(NSNotification *)notification {
+    NSLog(@"keyboardDidChangeFrame");
     
     
     // 使用tableContainer计算frame 保证屏幕旋转后table height正确
@@ -1018,6 +1017,89 @@
     //    }
     
 }
+//- (void)keyboardWillChangeFrame:(NSNotification *)notification {
+//    NSLog(@"keyboardWillChangeFrame");
+//
+//
+//    // 使用tableContainer计算frame 保证屏幕旋转后table height正确
+//    //    CGRect table_origin_screen_frame = [self.tableContainer convertRect:self.tableContainer.bounds toView:self.view.window];
+//
+//    CGRect screen_rect = [RAUtils relativeFrameForScreenWithView:self.view];
+//    //
+//    //    //    NSTimeInterval duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
+//    //    //    duration *= 0.0;
+//    CGRect end = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
+//    CGFloat keyboard_top = end.origin.y;
+//    NSLog(@"keyboard rect: %@",NSStringFromCGRect(end));
+//
+//    NSLog(@"view rect: %@",NSStringFromCGRect(self.view.frame));
+//    NSLog(@"view screen rect: %@",NSStringFromCGRect(screen_rect));
+//
+//    //    self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
+//
+//    float dark = screen_rect.origin.y+screen_rect.size.height-keyboard_top;
+//
+//    if(dark>0)
+//    {
+//        self.scrollView.scrollEnabled = true;
+//        self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width, self.scrollView.frame.size.height+dark);
+//        self.treeView.scrollEnabled = false;
+//    }
+//    else
+//    {
+//        self.scrollView.scrollEnabled = false;
+//        self.scrollView.contentSize = self.scrollView.frame.size;
+//        self.treeView.scrollEnabled = true;
+//    }
+//
+//    //    CGRect screenframe=[[UIScreen mainScreen] bounds];
+//    //    self.autocompleteView.frame= CGRectMake(screenframe.origin.x, screenframe.origin.y, screenframe.size.width, end_y);
+//    //
+//    //    NSIndexPath *indexPath = [self.editorTable indexPathForCell:self.editingcell];
+//    //
+//    //    CGRect table_frame = self.editorTable.frame;
+//    //    // table底部距离键盘顶部偏移
+//    //    CGFloat offset = CGRectGetMaxY(table_origin_screen_frame) - end_y;
+//    //    if (offset > 0) {
+//    //
+//    //        // table -> top > offset: table.y = -offset
+//    //        // 事实上top:topLayoutGuide
+//    //        CGFloat topAvailableHeight = (CGRectGetMinY(table_origin_screen_frame) - self.topLayoutGuide.length);
+//    //        if (topAvailableHeight > 0) {
+//    //            if (topAvailableHeight > offset) {
+//    //                table_frame.origin.y = -offset;
+//    //            } else {
+//    //                // 向上移动到topLayoutGuide,不足部分通过缩减高度到达keyboard顶部
+//    //                table_frame.origin.y = -topAvailableHeight;
+//    //                table_frame.size.height = (end_y - self.topLayoutGuide.length);
+//    //            }
+//    //        } else {
+//    //            // contentInset = (top = 64, left = 0, bottom = 0, right = 0),topAvailableHeight = -64
+//    //            table_frame.size.height = table_origin_screen_frame.size.height - offset;
+//    //        }
+//    //
+//    //        //        table_frame.size.height = CGRectGetHeight(table_origin_screen_frame) - (CGRectGetMaxY(table_origin_screen_frame) - end_y);
+//    //    } else {
+//    //        //        table_frame.size.height = CGRectGetHeight(table_origin_screen_frame);
+//    //        table_frame = self.tableContainer.bounds;
+//    //    }
+//    //
+//    //    self.editorTable.frame = table_frame;
+//    //
+//    //    CGRect cell_screen_frame = [self.editingcell convertRect:self.editingcell.bounds toView:self.view.window];
+//    //    if (CGRectGetMaxY(cell_screen_frame) > end_y) {
+//    //        // Cell 被键盘遮挡后才滚动
+//    //        [self.editorTable scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionNone animated:NO];
+//    //    }
+//    //
+//    //    // ===============================================
+//    //    if (end_y >= [UIScreen mainScreen].bounds.size.height) {
+//    //        self.keyboard_show = NO;
+//    //    } else {
+//    //        self.keyboard_show = YES;
+//    //    }
+//
+//}
 
 //static float table_origin_h = 0;
 

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

@@ -553,32 +553,29 @@
     [RANetwork request_create_order:^(NSMutableDictionary *result) {
         NSMutableDictionary* return_json = result;
         
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-        
-        if([[return_json valueForKey:@"result"] intValue]==2)
-        {
-            int result=[[return_json valueForKey:@"result"] intValue];
-            if(result==2)
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            if([[return_json valueForKey:@"result"] intValue]==2)
             {
-                //successed.
-                
-                NSString* order_code = [return_json valueForKey:@"orderCode"];
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                appDelegate.order_code = order_code;
-                
-                
-                [self addtocart];
-                
-                
-                
-                
+                int result=[[return_json valueForKey:@"result"] intValue];
+                if(result==2)
+                {
+                    //successed.
+                    
+                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    appDelegate.order_code = order_code;
+                    [self addtocart];
+
+                }
             }
-        }
-        else
-        {
-            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-        }
+            else
+            {
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+            }
+        }];
+        
+        
+
         
         
         
@@ -774,78 +771,81 @@
             
             NSDictionary* return_json = result;
             
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            self.addCartBtn.enabled = true;
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                int result=[[return_json valueForKey:@"result"] intValue];
-                if(result==2)
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                self.addCartBtn.enabled = true;
+                
+                if([[return_json valueForKey:@"result"] intValue]==2)
                 {
-                    //successed.
-                    
-                    
-                    
-                    
-                    //      NSString* order_code = [return_json valueForKey:@"order_code"];
-                    
-                    //                    appDelegate.order_code = order_code;
-                    
+                    int result=[[return_json valueForKey:@"result"] intValue];
+                    if(result==2)
+                    {
+                        //successed.
+                        
+                        
+                        
+                        
+                        //      NSString* order_code = [return_json valueForKey:@"order_code"];
+                        
+                        //                    appDelegate.order_code = order_code;
+                        
 #ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                        [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    
-                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-#endif
-                    NSString * msg = nil;
-                    if (self.addAll) {
+                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                         
-                        unsigned long checkedCount = [return_json[@"count"] integerValue];
+                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+#endif
+                        NSString * msg = nil;
+                        if (self.addAll) {
+                            
+                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            
+                            msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
+                        } else {
+                            
+                            if(checked.count==1)
+                            {
+                                msg=@"1 item added to Cart";
+                            }
+                            else
+                            {
+                                msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
+                            }
+                            
+                            
+                        }
+                        [RAUtils message_alert:nil title:msg controller:self] ;
                         
-                        msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
-                    } else {
+                        [self end_select:2];
                         
-                        if(checked.count==1)
-                        {
-                            msg=@"1 item added to Cart";
-                        }
-                        else
-                        {
-                            msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
-                        }
                         
                         
                     }
-                    [RAUtils message_alert:nil title:msg controller:self] ;
-                    
-                    [self end_select:2];
-                    
+                }
+                else  if([[return_json valueForKey:@"result"] intValue]==8)
+                {
                     
                     
-                }
-            }
-            else  if([[return_json valueForKey:@"result"] intValue]==8)
-            {
-                
-                
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                //                    appDelegate.order_code = order_code;
-                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    //                    appDelegate.order_code = order_code;
+                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-                
-                [self end_select:2];
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-            }
-            else
-            {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-            }
+                    
+                    [self end_select:2];
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                }
+                else
+                {
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                }
+            }];
+            
+
             
             
             
@@ -860,78 +860,81 @@
             
             NSDictionary* return_json = result;
             
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            self.addCartBtn.enabled = true;
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                int result=[[return_json valueForKey:@"result"] intValue];
-                if(result==2)
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                self.addCartBtn.enabled = true;
+                
+                if([[return_json valueForKey:@"result"] intValue]==2)
                 {
-                    //successed.
-                    
-                    
-                    
-                    
-                    //      NSString* order_code = [return_json valueForKey:@"order_code"];
-                    
-                    //                    appDelegate.order_code = order_code;
-                    
+                    int result=[[return_json valueForKey:@"result"] intValue];
+                    if(result==2)
+                    {
+                        //successed.
+                        
+                        
+                        
+                        
+                        //      NSString* order_code = [return_json valueForKey:@"order_code"];
+                        
+                        //                    appDelegate.order_code = order_code;
+                        
 #ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                        [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    
-                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-#endif
-                    NSString * msg = nil;
-                    if (self.addAll) {
+                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                         
-                        unsigned long checkedCount = [return_json[@"count"] integerValue];
+                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+#endif
+                        NSString * msg = nil;
+                        if (self.addAll) {
+                            
+                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            
+                            msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
+                        } else {
+                            
+                            if(checked.count==1)
+                            {
+                                msg=@"1 item added to Cart";
+                            }
+                            else
+                            {
+                                msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
+                            }
+                            
+                            
+                        }
+                        [RAUtils message_alert:nil title:msg controller:self] ;
                         
-                        msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
-                    } else {
+                        [self end_select:2];
                         
-                        if(checked.count==1)
-                        {
-                            msg=@"1 item added to Cart";
-                        }
-                        else
-                        {
-                            msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
-                        }
                         
                         
                     }
-                    [RAUtils message_alert:nil title:msg controller:self] ;
-                    
-                    [self end_select:2];
-                    
+                }
+                else  if([[return_json valueForKey:@"result"] intValue]==8)
+                {
                     
                     
-                }
-            }
-            else  if([[return_json valueForKey:@"result"] intValue]==8)
-            {
-                
-                
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                //                    appDelegate.order_code = order_code;
-                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    //                    appDelegate.order_code = order_code;
+                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-                
-                [self end_select:2];
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-            }
-            else
-            {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-            }
+                    
+                    [self end_select:2];
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                }
+                else
+                {
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                }
+            }];
+
+            
             
             
             
@@ -1089,55 +1092,57 @@
                 [RANetwork request_addall_category:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:self.offset limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip orderCode:nil  addTo:@"portfolio" completionHandler:^(NSMutableDictionary *result) {
                     
                     NSDictionary* return_json = result;
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    self.addPortfolioBtn.enabled =true;
-                    
-                    if([[return_json valueForKey:@"result"] intValue]==2)
-                    {
-                        //                int result=[[return_json valueForKey:@"result"] intValue];
-                        //                if(result==2)
-                        //                {
-                        //                    //successed.
-                        
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
+                        self.addPortfolioBtn.enabled =true;
                         
-                        
-                        
-                        #ifdef RA_NOTIFICATION
+                        if([[return_json valueForKey:@"result"] intValue]==2)
+                        {
+                            //                int result=[[return_json valueForKey:@"result"] intValue];
+                            //                if(result==2)
+                            //                {
+                            //                    //successed.
+                            
+                            
+                            
+                            
+#ifdef RA_NOTIFICATION
                             [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-                        #else
+#else
                             AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                             [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
-                        #endif
-                        
-                        NSString * msg = nil;
-                        
-                        if (self.addAll) {
+#endif
                             
-                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            NSString * msg = nil;
                             
-                            msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
-                        } else {
-                        
-                            if(checked.count==1)
-                            {
-                                msg=@"1 item added to Portfolio";
-                            }
-                            else
-                            {
-                                msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                            if (self.addAll) {
+                                
+                                unsigned long checkedCount = [return_json[@"count"] integerValue];
+                                
+                                msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
+                            } else {
+                                
+                                if(checked.count==1)
+                                {
+                                    msg=@"1 item added to Portfolio";
+                                }
+                                else
+                                {
+                                    msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                                }
                             }
+                            
+                            [RAUtils message_alert:nil title:msg controller:self] ;
+                            
+                            
+                            [self end_select:3 ];
+                            
                         }
-                        
-                        [RAUtils message_alert:nil title:msg controller:self] ;
-                        
-                        
-                        [self end_select:3 ];
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
-                    }
+                        else
+                        {
+                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
+                        }
+                    }];
+                    
                     
                     
                     
@@ -1149,55 +1154,57 @@
                 [RANetwork request_addto_portfolio:ids withScreen:ScreenCodeCategory completionHandler:^(NSMutableDictionary *result) {
                     
                     NSDictionary* return_json = result;
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    self.addPortfolioBtn.enabled =true;
-                    
-                    if([[return_json valueForKey:@"result"] intValue]==2)
-                    {
-                        //                int result=[[return_json valueForKey:@"result"] intValue];
-                        //                if(result==2)
-                        //                {
-                        //                    //successed.
-                        
-                        
-                        
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
+                        self.addPortfolioBtn.enabled =true;
                         
-                        #ifdef RA_NOTIFICATION
+                        if([[return_json valueForKey:@"result"] intValue]==2)
+                        {
+                            //                int result=[[return_json valueForKey:@"result"] intValue];
+                            //                if(result==2)
+                            //                {
+                            //                    //successed.
+                            
+                            
+                            
+                            
+#ifdef RA_NOTIFICATION
                             [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-                        #else
+#else
                             AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                             [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
-                        #endif
-                        
-                        NSString * msg = nil;
-                        
-                        if (self.addAll) {
+#endif
                             
-                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            NSString * msg = nil;
                             
-                            msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
-                        } else {
-                        
-                            if(checked.count==1)
-                            {
-                                msg=@"1 item added to Portfolio";
-                            }
-                            else
-                            {
-                                msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                            if (self.addAll) {
+                                
+                                unsigned long checkedCount = [return_json[@"count"] integerValue];
+                                
+                                msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
+                            } else {
+                                
+                                if(checked.count==1)
+                                {
+                                    msg=@"1 item added to Portfolio";
+                                }
+                                else
+                                {
+                                    msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                                }
                             }
+                            
+                            [RAUtils message_alert:nil title:msg controller:self] ;
+                            
+                            
+                            [self end_select:3 ];
+                            
                         }
-                        
-                        [RAUtils message_alert:nil title:msg controller:self] ;
-                        
-                        
-                        [self end_select:3 ];
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
-                    }
+                        else
+                        {
+                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
+                        }
+                    }];
+                    
                     
                     
                     
@@ -1312,55 +1319,57 @@
         
         [RANetwork request_addall_category:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:self.offset limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller modelname:self.modelname modeldescrip:self.modeldescrip orderCode:nil  addTo:@"wishlist" completionHandler:^(NSMutableDictionary *result) {
             NSDictionary* return_json = result;
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            self.addWishBtn.enabled =true;
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                
-                //successed.
-                
-                //                    NSString* order_code = [return_json valueForKey:@"order_code"];
-                
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                self.addWishBtn.enabled =true;
                 
+                if([[return_json valueForKey:@"result"] intValue]==2)
+                {
+                    
+                    //successed.
+                    
+                    //                    NSString* order_code = [return_json valueForKey:@"order_code"];
+                    
+                    
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                
-                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
-#endif
-                
-                NSString * msg = nil;
-                
-                if (self.addAll) {
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                     
-                    unsigned long checkedCount = [return_json[@"count"] integerValue];
+                    [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+#endif
                     
-                    msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
-                } else {
+                    NSString * msg = nil;
                     
-                    if(checked.count==1)
-                    {
-                        msg=@"1 item added to \nWish List";
-                    }
-                    else
-                    {
-                        msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+                    if (self.addAll) {
+                        
+                        unsigned long checkedCount = [return_json[@"count"] integerValue];
+                        
+                        msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
+                    } else {
+                        
+                        if(checked.count==1)
+                        {
+                            msg=@"1 item added to \nWish List";
+                        }
+                        else
+                        {
+                            msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+                        }
                     }
+                    
+                    [RAUtils message_alert:nil title:msg controller:self] ;
+                    
+                    
+                    
+                    [self end_select:1];
+                    
                 }
-                
-                [RAUtils message_alert:nil title:msg controller:self] ;
-                
-                
-                
-                [self end_select:1];
-                
-            }
-            else
-            {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
-            }
+                else
+                {
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
+                }
+            }];
+            
             
             
             
@@ -1372,61 +1381,63 @@
     } else {
         
         [RANetwork request_addto_wishlist:ids withScreen:ScreenCodeCategory completionHandler:^(NSMutableDictionary *result) {
-                    NSDictionary* return_json = result;
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    self.addWishBtn.enabled =true;
+            NSDictionary* return_json = result;
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                self.addWishBtn.enabled =true;
+                
+                if([[return_json valueForKey:@"result"] intValue]==2)
+                {
                     
-                    if([[return_json valueForKey:@"result"] intValue]==2)
-                    {
-                        
-                        //successed.
-                        
-                        //                    NSString* order_code = [return_json valueForKey:@"order_code"];
-                        
-                        
-        #ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-        #else
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    //successed.
+                    
+                    //                    NSString* order_code = [return_json valueForKey:@"order_code"];
+                    
+                    
+#ifdef RA_NOTIFICATION
+                    [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    
+                    [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+#endif
+                    
+                    NSString * msg = nil;
+                    
+                    if (self.addAll) {
                         
-                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
-        #endif
+                        unsigned long checkedCount = [return_json[@"count"] integerValue];
                         
-                        NSString * msg = nil;
+                        msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
+                    } else {
                         
-                        if (self.addAll) {
-                            
-                            unsigned long checkedCount = [return_json[@"count"] integerValue];
-                            
-                            msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
-                        } else {
-                            
-                            if(checked.count==1)
-                            {
-                                msg=@"1 item added to \nWish List";
-                            }
-                            else
-                            {
-                                msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
-                            }
+                        if(checked.count==1)
+                        {
+                            msg=@"1 item added to \nWish List";
+                        }
+                        else
+                        {
+                            msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
                         }
-                        
-                        [RAUtils message_alert:nil title:msg controller:self] ;
-                        
-                        
-                        
-                        [self end_select:1];
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
                     }
                     
+                    [RAUtils message_alert:nil title:msg controller:self] ;
                     
                     
                     
-                }];
+                    [self end_select:1];
+                    
+                }
+                else
+                {
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
+                }
+                
+                
+            }];
+            
+            
+            
+        }];
         
         
     }
@@ -1824,7 +1835,7 @@
         // what ever you want to prepare
     } completion:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
         
-        
+        self.headerView.layer.shadowPath =[UIBezierPath bezierPathWithRect:self.headerView.bounds].CGPath;
             self.toOrientation = [UIApplication sharedApplication].statusBarOrientation;
         [self.collectionview.collectionViewLayout invalidateLayout];
     }];
@@ -2459,16 +2470,17 @@
         }
         else
         {
-            
+            BOOL offline = NO;
+#ifdef OFFLINE_MODE
+            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+            offline = appDelegate.offline_mode;
+#endif
             dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                 
                 NSData*  downloadimg_data = nil;
                 
-                BOOL offline = NO;
-#ifdef OFFLINE_MODE
-                AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-                offline = appDelegate.offline_mode;
-#endif
+                
+                
                 if (!offline) {
                     downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
                 }

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

@@ -597,8 +597,7 @@
         NSMutableDictionary* editor_json = result;
         
             
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
+        [waitalert dismissViewControllerAnimated:YES completion:^{
             if([[editor_json valueForKey:@"result"] intValue]==2)
             {
                 __block NSMutableDictionary* data_init = [[editor_json objectForKey:@"customerInfo" ] mutableCopy];
@@ -661,6 +660,9 @@
                 [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Loading Contact Information" controller:self] ;
                 //                self.btn_assign.enabled=false;
             }
+        }];
+            
+            
             
             
         

+ 73 - 20
RedAnt ERP Mobile/common/Functions/contact/CustomerEditViewController.m

@@ -260,19 +260,10 @@
         return;
     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Saving Contact"];
     __weak typeof(self) weakself = self;
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* editor_json = nil;
-     //   NSString* contactId=[upparams valueForKey:@"contactId"];
-        if(self.bnewcustomer )
-            editor_json=[RANetwork save_newCustomer:upparams];
-        else
-            editor_json=[RANetwork update_Customer:upparams];
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
-            
+    
+    resultHandler handler =^(NSMutableDictionary *result) {
+        NSDictionary* editor_json = result;
+        [waitalert dismissViewControllerAnimated:YES completion:^{
             if([[editor_json valueForKey:@"result"] intValue]==2)
             {
                 //                NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
@@ -294,7 +285,7 @@
                 
                 
 #ifdef RA_NOTIFICATION
-
+                
                 [ActiveViewController Notify:@"ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
                 AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
@@ -306,12 +297,74 @@
             {
                 [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:weakself] ;
             }
-            
-            
-            
-            
-        });
-    });
+        }];
+        
+        
+
+        
+        
+        
+        
+    } ;
+    
+    if(self.bnewcustomer )
+        [RANetwork request_add_customer:upparams completionHandler:handler];
+    else
+        [RANetwork request_update_customer:upparams completionHandler:handler];
+    
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* editor_json = nil;
+//     //   NSString* contactId=[upparams valueForKey:@"contactId"];
+//        if(self.bnewcustomer )
+//            editor_json=[RANetwork save_newCustomer:upparams];
+//        else
+//            editor_json=[RANetwork update_Customer:upparams];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//
+//            if([[editor_json valueForKey:@"result"] intValue]==2)
+//            {
+//                //                NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
+//                //
+//                //
+//                //                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                //                appDelegate.customerInfo = customerInfo;
+//                //                appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
+//                //    //     self.labelContact.text=appDelegate.contact_name;
+//                //
+//                //    NSDictionary * customerinfo = appDelegate.customerInfo;
+//                [weakself prepareReturn:nil];
+//                if(weakself.bnewcustomer  )
+//                    [weakself.navigationController popViewControllerAnimated:false];
+//                else
+//                    [weakself.navigationController popToRootViewControllerAnimated:false];
+//
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//
+//                [ActiveViewController Notify:@"ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
+//#endif
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:weakself] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
     
     
 }

+ 234 - 145
RedAnt ERP Mobile/common/Functions/contact/CustomerInfoViewController.m

@@ -97,37 +97,60 @@
     if(self.update_order && appDelegate.order_code!=nil)
     {
         
-        
-        
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        [RANetwork request_update_ordercustomer:appDelegate.order_code customerinfo:self.data_init completionHandler:^(NSMutableDictionary *result) {
             
-            NSDictionary* editor_json = [RANetwork update_OrderCustomer:appDelegate.order_code customerinfo:self.data_init];
-            
-            dispatch_async(dispatch_get_main_queue(), ^{
-                
+            NSDictionary* editor_json = result;
+            if([[editor_json valueForKey:@"result"] intValue]==2)
+            {
                 
-                if([[editor_json valueForKey:@"result"] intValue]==2)
+                [self.navigationController popViewControllerAnimated:false];
+                if(self.returnValue)
                 {
                     
-                    [self.navigationController popViewControllerAnimated:false];
-                    if(self.returnValue)
-                    {
-                        
-                        self.returnValue(self.data_init);
-                    }
-                    
-                    
-                    
-                }
-                else
-                {
-                    [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Update Order Customer Infomation" controller:self] ;
+                    self.returnValue(self.data_init);
                 }
                 
                 
                 
-            });
-        });
+            }
+            else
+            {
+                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Update Order Customer Infomation" controller:self] ;
+            }
+            
+            
+            
+        }];
+        
+//        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//            NSDictionary* editor_json = [RANetwork update_OrderCustomer:appDelegate.order_code customerinfo:self.data_init];
+//
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//                if([[editor_json valueForKey:@"result"] intValue]==2)
+//                {
+//
+//                    [self.navigationController popViewControllerAnimated:false];
+//                    if(self.returnValue)
+//                    {
+//
+//                        self.returnValue(self.data_init);
+//                    }
+//
+//
+//
+//                }
+//                else
+//                {
+//                    [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Update Order Customer Infomation" controller:self] ;
+//                }
+//
+//
+//
+//            });
+//        });
         
         
     }
@@ -160,19 +183,17 @@
         
         UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
             UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                
-                NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:ScreenCodeCustomerInfo];
-                
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+            
+            [RANetwork request_release_order:appDelegate.order_code withScreen:ScreenCodeCustomerInfo  completionHandler:^(NSMutableDictionary *result) {
+                NSDictionary* order_json = result;
+                [waitalert dismissViewControllerAnimated:YES completion:^{
                     if([[order_json valueForKey:@"result"] intValue]==2)
                     {
                         AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                         //                    appDelegate.order_code = nil;
                         [appDelegate closeOrder];
                         
-
+                        
                         
 #ifdef RA_NOTIFICATION
                         [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
@@ -186,17 +207,55 @@
                         [self.navigationController popToRootViewControllerAnimated:false];
                         
                         
-
+                        
                     }
                     else
                     {
                         [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Release Order" controller:self] ;
                     }
-                    
-                    
-                    
-                });
-            });
+                }];
+
+                
+                
+                
+            }];
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:ScreenCodeCustomerInfo];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+//                    if([[order_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                        //                    appDelegate.order_code = nil;
+//                        [appDelegate closeOrder];
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                        [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//                        [ActiveViewController Notify:@"ContactListViewController" Message:RA_NOTIFICATION_REFRESH_UI];
+//#else
+//                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//                        [((MainViewController*)appDelegate.main_vc) reloadContact:false immediately:false];
+//#endif
+//
+//                        [self.navigationController popToRootViewControllerAnimated:false];
+//
+//
+//
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Release Order" controller:self] ;
+//                    }
+//
+//
+//
+//                });
+//            });
             
         }];
         
@@ -393,8 +452,7 @@
         NSMutableDictionary* editor_json = result;
         
             
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
+        [waitalert dismissViewControllerAnimated:YES completion:^{
             if([[editor_json valueForKey:@"result"] intValue]==2)
             {
                 self.data_init = [[editor_json objectForKey:@"customerInfo" ] mutableCopy];
@@ -408,6 +466,9 @@
                 [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Loading Contact Information" controller:self] ;
                 self.btn_assign.enabled=false;
             }
+        }];
+            
+
             
             
         
@@ -496,113 +557,141 @@
 }
 
 
-#pragma mark- img changed
-
-// image 改变时执行
-- (void) imgIsChanged:(NSString *)url_down url_up:(NSString *)url_up indexPath: (NSIndexPath *) indexPath{
-    
-    // int aaa = 0;
-    // NSDictionary* aaa = self.content_data_download;
-    
-    
-    
-    UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Create Order"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        NSString* cid=[self getValue:@"customer_cid"];
-        NSDictionary* return_json = [RANetwork update_customer_img:cid img_url:url_up];
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                int result=[[return_json valueForKey:@"result"] intValue];
-                if(result==2)
-                {
-                    
-                    [RAUtils message_alert:nil title:@"Upload successful." controller:self];
-//                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Upload successful." message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-//                    
-//                    [alert show];
-                }
-            }
-            else
-            {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-            }
-            
-            
-            
-            
-        });
-    });
-    
-    //    // DebugLog(@"Sender is = %@", url);
-    //
-    //
-    //
-    //
-    //    NSMutableDictionary* section_json=nil;
-    //
-    //
-    //    //    DebugLog(@"endedit %d_%d",indexPath.section,indexPath.row);
-    //    NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
-    //
-    //    int refresh = [[item_json valueForKey:@"refresh"] intValue];
-    //
-    //    NSString* subid=[item_json valueForKey:@"subid"];
-    //
-    //    item_json[@"img_url"]=url_down;
-    //    item_json[@"avalue"]=url_up;
-    //
-    //    if(subid==nil)
-    //    {
-    //        section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
-    //        int count=0;
-    //
-    //        count=[[section_json valueForKey:@"count"] intValue];
-    //
-    //        for(int i=0;i<count;i++)
-    //        {
-    //            NSDictionary * olditem=[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]];
-    //            if([[olditem valueForKey:@"name"] isEqualToString:[item_json valueForKey:@"name" ]])
-    //                [section_json setObject:item_json  forKey:[NSString stringWithFormat:@"item_%d",i ]];
-    //
-    //
-    //        }
-    //
-    //    }
-    //    else
-    //    {
-    //        NSArray* idarr=[subid componentsSeparatedByString:@"_"];
-    //        int section = [(NSString*)idarr[0] intValue];
-    //        int item=[(NSString*)idarr[1] intValue];
-    //
-    //
-    //        section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d", section]] mutableCopy];
-    //        NSDictionary * olditem=[section_json objectForKey:[NSString stringWithFormat:@"item_%d",item ]];
-    //        item_json= [self enum_subitem_changed:[olditem mutableCopy] subid:idarr value:item_json step:2];
-    //        [item_json setValue:@"true" forKey:@"dirty"];
-    //        [section_json setObject:item_json  forKey:[NSString stringWithFormat:@"item_%d",item ]];
-    //    }
-    //
-    //
-    //
-    //    [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
-    //
-    //    self.content_data_control = [self translate_json:self.content_data_download changed: self.changed_data];
-    //
-    //    NSRange range = NSMakeRange(indexPath.section, 1);
-    //    NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
-    //    //  [self.editorTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
-    //
-    //
-    //    if(refresh==1)
-    //    {
-    //        [self refresh];
-    //    }
-}
+//#pragma mark- img changed
+//
+//// image 改变时执行
+//- (void) imgIsChanged:(NSString *)url_down url_up:(NSString *)url_up indexPath: (NSIndexPath *) indexPath{
+//
+//    // int aaa = 0;
+//    // NSDictionary* aaa = self.content_data_download;
+//
+//
+//
+//    UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Create Order"];
+//    NSString* cid=[self getValue:@"customer_cid"];
+//    [RANetwork request_update_customer_img:cid img_url:url_up completionHandler:^(NSMutableDictionary *result) {
+//        NSDictionary* return_json =result;
+//        [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//
+//                if([[return_json valueForKey:@"result"] intValue]==2)
+//                {
+//                    int result=[[return_json valueForKey:@"result"] intValue];
+//                    if(result==2)
+//                    {
+//
+//                        [RAUtils message_alert:nil title:@"Upload successful." controller:self];
+//    //                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Upload successful." message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+//    //
+//    //                    [alert show];
+//                    }
+//                }
+//                else
+//                {
+//                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//                }
+//
+//
+//
+//
+//    }];
+//
+////    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+////        NSString* cid=[self getValue:@"customer_cid"];
+////        NSDictionary* return_json = [RANetwork update_customer_img:cid img_url:url_up];
+////
+////        dispatch_async(dispatch_get_main_queue(), ^{
+////            [waitalert dismissViewControllerAnimated:YES completion:nil];
+////
+////
+////            if([[return_json valueForKey:@"result"] intValue]==2)
+////            {
+////                int result=[[return_json valueForKey:@"result"] intValue];
+////                if(result==2)
+////                {
+////
+////                    [RAUtils message_alert:nil title:@"Upload successful." controller:self];
+//////                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Upload successful." message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+//////
+//////                    [alert show];
+////                }
+////            }
+////            else
+////            {
+////                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+////            }
+////
+////
+////
+////
+////        });
+////    });
+//
+//    //    // DebugLog(@"Sender is = %@", url);
+//    //
+//    //
+//    //
+//    //
+//    //    NSMutableDictionary* section_json=nil;
+//    //
+//    //
+//    //    //    DebugLog(@"endedit %d_%d",indexPath.section,indexPath.row);
+//    //    NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
+//    //
+//    //    int refresh = [[item_json valueForKey:@"refresh"] intValue];
+//    //
+//    //    NSString* subid=[item_json valueForKey:@"subid"];
+//    //
+//    //    item_json[@"img_url"]=url_down;
+//    //    item_json[@"avalue"]=url_up;
+//    //
+//    //    if(subid==nil)
+//    //    {
+//    //        section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
+//    //        int count=0;
+//    //
+//    //        count=[[section_json valueForKey:@"count"] intValue];
+//    //
+//    //        for(int i=0;i<count;i++)
+//    //        {
+//    //            NSDictionary * olditem=[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]];
+//    //            if([[olditem valueForKey:@"name"] isEqualToString:[item_json valueForKey:@"name" ]])
+//    //                [section_json setObject:item_json  forKey:[NSString stringWithFormat:@"item_%d",i ]];
+//    //
+//    //
+//    //        }
+//    //
+//    //    }
+//    //    else
+//    //    {
+//    //        NSArray* idarr=[subid componentsSeparatedByString:@"_"];
+//    //        int section = [(NSString*)idarr[0] intValue];
+//    //        int item=[(NSString*)idarr[1] intValue];
+//    //
+//    //
+//    //        section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d", section]] mutableCopy];
+//    //        NSDictionary * olditem=[section_json objectForKey:[NSString stringWithFormat:@"item_%d",item ]];
+//    //        item_json= [self enum_subitem_changed:[olditem mutableCopy] subid:idarr value:item_json step:2];
+//    //        [item_json setValue:@"true" forKey:@"dirty"];
+//    //        [section_json setObject:item_json  forKey:[NSString stringWithFormat:@"item_%d",item ]];
+//    //    }
+//    //
+//    //
+//    //
+//    //    [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
+//    //
+//    //    self.content_data_control = [self translate_json:self.content_data_download changed: self.changed_data];
+//    //
+//    //    NSRange range = NSMakeRange(indexPath.section, 1);
+//    //    NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
+//    //    //  [self.editorTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
+//    //
+//    //
+//    //    if(refresh==1)
+//    //    {
+//    //        [self refresh];
+//    //    }
+//}
 
 - (void)didReceiveMemoryWarning {
     [super didReceiveMemoryWarning];

+ 476 - 244
RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.m

@@ -902,69 +902,126 @@
                 
                 
                 UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-                    
-                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                    [RANetwork request_addto_cart:self.product_id count:count name:self.model_label.text completionHandler:^(NSMutableDictionary *result) {
                         
-                        NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:self.model_label.text];
+                        NSDictionary* return_json = result;
                         
-                        dispatch_async(dispatch_get_main_queue(), ^{
+                        if([[return_json valueForKey:@"result"] intValue]==2)
+                        {
+                            
+                            //    NSString* order_code = [return_json valueForKey:@"order_code"];
+                            
                             
                             
                             
-                            if([[return_json valueForKey:@"result"] intValue]==2)
-                            {
-                                
-                                //    NSString* order_code = [return_json valueForKey:@"order_code"];
-                                
-                                
-
-                                
 #ifdef RA_NOTIFICATION
-                                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                            [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                                AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-                                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                            AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+                            [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-                                if(self.shopCartBlock!=nil)
-                                {
-                                    UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                                    
-                                    
-                                    CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                                    UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                                    iv.image = img;
-                                    //                        [self.contentView addSubview:iv];
-                                    self.shopCartBlock(iv);
-                                    
-                                    self.cqty +=count;
-                                    if(self.set_cqty)
-                                        self.set_cqty(self.cqty);
-                                    
-                                }
+                            if(self.shopCartBlock!=nil)
+                            {
+                                UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
                                 
                                 
-                            }
-                            else
-                            {
-                                UIViewController *vc= [RAUtils getViewController:self];
-                                NSString *msg = [return_json valueForKey:@"err_msg"];
-                                NSString *title = @"Add To Cart";
-                                if ([msg hasPrefix:@"Out of Stock.\n"]) {
-                                    title = @"Add To Cart: Out of Stock";
-                                    msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
-                                    self.btnNotifyMe.enabled = YES;
-                                    self.btnaddCart.enabled = NO;
-                                }
+                                CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                                UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                                iv.image = img;
+                                //                        [self.contentView addSubview:iv];
+                                self.shopCartBlock(iv);
+                                
+                                self.cqty +=count;
+                                if(self.set_cqty)
+                                    self.set_cqty(self.cqty);
                                 
-                                [RAUtils message_alert:msg title:title controller:vc] ;
                             }
                             
                             
+                        }
+                        else
+                        {
+                            UIViewController *vc= [RAUtils getViewController:self];
+                            NSString *msg = [return_json valueForKey:@"err_msg"];
+                            NSString *title = @"Add To Cart";
+                            if ([msg hasPrefix:@"Out of Stock.\n"]) {
+                                title = @"Add To Cart: Out of Stock";
+                                msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+                                self.btnNotifyMe.enabled = YES;
+                                self.btnaddCart.enabled = NO;
+                            }
                             
-                            
-                        });
-                    });
+                            [RAUtils message_alert:msg title:title controller:vc] ;
+                        }
+                        
+                        
+                        
+                        
+                    }];
+                    
+//                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                        NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:self.model_label.text];
+//
+//                        dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//
+//                            if([[return_json valueForKey:@"result"] intValue]==2)
+//                            {
+//
+//                                //    NSString* order_code = [return_json valueForKey:@"order_code"];
+//
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                                AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+//                                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//                                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//                                if(self.shopCartBlock!=nil)
+//                                {
+//                                    UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+//
+//
+//                                    CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+//                                    UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+//                                    iv.image = img;
+//                                    //                        [self.contentView addSubview:iv];
+//                                    self.shopCartBlock(iv);
+//
+//                                    self.cqty +=count;
+//                                    if(self.set_cqty)
+//                                        self.set_cqty(self.cqty);
+//
+//                                }
+//
+//
+//                            }
+//                            else
+//                            {
+//                                UIViewController *vc= [RAUtils getViewController:self];
+//                                NSString *msg = [return_json valueForKey:@"err_msg"];
+//                                NSString *title = @"Add To Cart";
+//                                if ([msg hasPrefix:@"Out of Stock.\n"]) {
+//                                    title = @"Add To Cart: Out of Stock";
+//                                    msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+//                                    self.btnNotifyMe.enabled = YES;
+//                                    self.btnaddCart.enabled = NO;
+//                                }
+//
+//                                [RAUtils message_alert:msg title:title controller:vc] ;
+//                            }
+//
+//
+//
+//
+//                        });
+//                    });
                     
                     
                 }];
@@ -986,66 +1043,122 @@
             }
             else
             {
-                            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                
-                                NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:self.model_label.text];
-                
-                                dispatch_async(dispatch_get_main_queue(), ^{
-                
-                
-                
-                                    if([[return_json valueForKey:@"result"] intValue]==2)
-                                    {
-                
-                                        //    NSString* order_code = [return_json valueForKey:@"order_code"];
-
                 
+                [RANetwork request_addto_cart:self.product_id count:count name:self.model_label.text completionHandler:^(NSMutableDictionary *result) {
+                    
+                    NSDictionary* return_json = result;
+                    
+                    if([[return_json valueForKey:@"result"] intValue]==2)
+                    {
+                        
+                        //    NSString* order_code = [return_json valueForKey:@"order_code"];
+                        
+                        
 #ifdef RA_NOTIFICATION
-                                        [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                        [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                                        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-                                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-                                            if(self.shopCartBlock!=nil)
-                                            {
-                                                UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                
-                
-                                                CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                                                UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                                                iv.image = img;
-                                                //                        [self.contentView addSubview:iv];
-                                                self.shopCartBlock(iv);
-                
-                                                self.cqty +=count;
-                                                if(self.set_cqty)
-                                                    self.set_cqty(self.cqty);
-                
-                                            }
-                                            
-                                        
-                                    }
-                                    else
-                                    {
-                                        UIViewController *vc= [RAUtils getViewController:self];
-                                        NSString *msg = [return_json valueForKey:@"err_msg"];
-                                        NSString *title = @"Add To Cart";
-                                        if ([msg hasPrefix:@"Out of Stock.\n"]) {
-                                            title = @"Add To Cart: Out of Stock";
-                                            msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
-                                            self.btnNotifyMe.enabled = YES;
-                                            self.btnaddCart.enabled = NO;
-                                        }
-                                        
-                                        [RAUtils message_alert:msg title:title controller:vc] ;
-                                    }
-                                    
-                                    
-                                    
-                                    
-                                });
-                            });
+                        if(self.shopCartBlock!=nil)
+                        {
+                            UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                            
+                            
+                            CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                            UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                            iv.image = img;
+                            //                        [self.contentView addSubview:iv];
+                            self.shopCartBlock(iv);
+                            
+                            self.cqty +=count;
+                            if(self.set_cqty)
+                                self.set_cqty(self.cqty);
+                            
+                        }
+                        
+                        
+                    }
+                    else
+                    {
+                        UIViewController *vc= [RAUtils getViewController:self];
+                        NSString *msg = [return_json valueForKey:@"err_msg"];
+                        NSString *title = @"Add To Cart";
+                        if ([msg hasPrefix:@"Out of Stock.\n"]) {
+                            title = @"Add To Cart: Out of Stock";
+                            msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+                            self.btnNotifyMe.enabled = YES;
+                            self.btnaddCart.enabled = NO;
+                        }
+                        
+                        [RAUtils message_alert:msg title:title controller:vc] ;
+                    }
+                    
+                    
+                    
+                    
+                }];
+//                            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                                NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:self.model_label.text];
+//
+//                                dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//
+//                                    if([[return_json valueForKey:@"result"] intValue]==2)
+//                                    {
+//
+//                                        //    NSString* order_code = [return_json valueForKey:@"order_code"];
+//
+//
+//#ifdef RA_NOTIFICATION
+//                                        [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                                        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+//                                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//                                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//                                            if(self.shopCartBlock!=nil)
+//                                            {
+//                                                UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+//
+//
+//                                                CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+//                                                UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+//                                                iv.image = img;
+//                                                //                        [self.contentView addSubview:iv];
+//                                                self.shopCartBlock(iv);
+//
+//                                                self.cqty +=count;
+//                                                if(self.set_cqty)
+//                                                    self.set_cqty(self.cqty);
+//
+//                                            }
+//
+//
+//                                    }
+//                                    else
+//                                    {
+//                                        UIViewController *vc= [RAUtils getViewController:self];
+//                                        NSString *msg = [return_json valueForKey:@"err_msg"];
+//                                        NSString *title = @"Add To Cart";
+//                                        if ([msg hasPrefix:@"Out of Stock.\n"]) {
+//                                            title = @"Add To Cart: Out of Stock";
+//                                            msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+//                                            self.btnNotifyMe.enabled = YES;
+//                                            self.btnaddCart.enabled = NO;
+//                                        }
+//
+//                                        [RAUtils message_alert:msg title:title controller:vc] ;
+//                                    }
+//
+//
+//
+//
+//                                });
+//                            });
 
             }
             
@@ -1137,70 +1250,130 @@
             
             UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
                 
-                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                [RANetwork request_addto_cart:self.product_id count:count name:self.model_label.text completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* return_json =result;
                     
-                    NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:self.model_label.text];
                     
-                    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:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                        [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                            //    NSString* order_code = [return_json valueForKey:@"order_code"];
-                            AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-                            //                            appDelegate.order_code = order_code;
-                            //
-                            //                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                            //                        appDelegate.order_code = order_code;
-                            [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                        //    NSString* order_code = [return_json valueForKey:@"order_code"];
+                        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+                        //                            appDelegate.order_code = order_code;
+                        //
+                        //                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                        //                        appDelegate.order_code = order_code;
+                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-                            if(self.shopCartBlock!=nil)
-                            {
-                                UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                                
-                                
-                                CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                                UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                                iv.image = img;
-                                //                        [self.contentView addSubview:iv];
-                                self.shopCartBlock(iv);
-                                
-                                self.cqty +=count;
-                                if(self.set_cqty)
-                                    self.set_cqty(self.cqty);
-                                
-                            }
+                        if(self.shopCartBlock!=nil)
+                        {
+                            UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
                             
                             
-                        }
-                        else
-                        {
-                            UIViewController *vc= [RAUtils getViewController:self];
-                            NSString *msg = [return_json valueForKey:@"err_msg"];
-                            NSString *title = @"Add To Cart";
-                            if ([msg hasPrefix:@"Out of Stock.\n"]) {
-                                title = @"Add To Cart: Out of Stock";
-                                msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
-                                self.btnNotifyMe.enabled = YES;
-                                self.btnaddCart.enabled = NO;
-                            }
+                            CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                            UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                            iv.image = img;
+                            //                        [self.contentView addSubview:iv];
+                            self.shopCartBlock(iv);
+                            
+                            self.cqty +=count;
+                            if(self.set_cqty)
+                                self.set_cqty(self.cqty);
                             
-                            [RAUtils message_alert:msg title:title controller:vc] ;
                         }
                         
                         
+                    }
+                    else
+                    {
+                        UIViewController *vc= [RAUtils getViewController:self];
+                        NSString *msg = [return_json valueForKey:@"err_msg"];
+                        NSString *title = @"Add To Cart";
+                        if ([msg hasPrefix:@"Out of Stock.\n"]) {
+                            title = @"Add To Cart: Out of Stock";
+                            msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+                            self.btnNotifyMe.enabled = YES;
+                            self.btnaddCart.enabled = NO;
+                        }
                         
-                        
-                    });
-                });
+                        [RAUtils message_alert:msg title:title controller:vc] ;
+                    }
+                    
+                    
+                    
+                    
+                }];
+                
+//                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                    NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:self.model_label.text];
+//
+//                    dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//
+//                        if([[return_json valueForKey:@"result"] intValue]==2)
+//                        {
+//
+//
+//
+//#ifdef RA_NOTIFICATION
+//                            [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                            //    NSString* order_code = [return_json valueForKey:@"order_code"];
+//                            AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+//                            //                            appDelegate.order_code = order_code;
+//                            //
+//                            //                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                            //                        appDelegate.order_code = order_code;
+//                            [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//                            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//                            if(self.shopCartBlock!=nil)
+//                            {
+//                                UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+//
+//
+//                                CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+//                                UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+//                                iv.image = img;
+//                                //                        [self.contentView addSubview:iv];
+//                                self.shopCartBlock(iv);
+//
+//                                self.cqty +=count;
+//                                if(self.set_cqty)
+//                                    self.set_cqty(self.cqty);
+//
+//                            }
+//
+//
+//                        }
+//                        else
+//                        {
+//                            UIViewController *vc= [RAUtils getViewController:self];
+//                            NSString *msg = [return_json valueForKey:@"err_msg"];
+//                            NSString *title = @"Add To Cart";
+//                            if ([msg hasPrefix:@"Out of Stock.\n"]) {
+//                                title = @"Add To Cart: Out of Stock";
+//                                msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+//                                self.btnNotifyMe.enabled = YES;
+//                                self.btnaddCart.enabled = NO;
+//                            }
+//
+//                            [RAUtils message_alert:msg title:title controller:vc] ;
+//                        }
+//
+//
+//
+//
+//                    });
+//                });
                 
                 
             }];
@@ -1223,66 +1396,123 @@
         else
         {
             NSString* model_name=self.model_label.text;
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            
+            [RANetwork request_addto_cart:self.product_id count:count name:model_name completionHandler:^(NSMutableDictionary *result) {
                 
-                NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:model_name];
+                NSDictionary* return_json = result;
                 
-                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:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-
-                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+                    
+                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-                        if(self.shopCartBlock!=nil)
-                        {
-                            UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                            
-                            
-                            CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                            UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                            iv.image = img;
-                            //                        [self.contentView addSubview:iv];
-                            self.shopCartBlock(iv);
-                            
-                            self.cqty +=count;
-                            if(self.set_cqty)
-                                self.set_cqty(self.cqty);
-                            
-                        }
+                    if(self.shopCartBlock!=nil)
+                    {
+                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
                         
                         
-                    }
-                    else
-                    {
-                        UIViewController *vc= [RAUtils getViewController:self];
+                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                        iv.image = img;
+                        //                        [self.contentView addSubview:iv];
+                        self.shopCartBlock(iv);
                         
-                        NSString *msg = [return_json valueForKey:@"err_msg"];
-                        NSString *title = @"Add To Cart";
-                        if ([msg hasPrefix:@"Out of Stock.\n"]) {
-                            title = @"Add To Cart: Out of Stock";
-                            msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
-                            self.btnNotifyMe.enabled = YES;
-                            self.btnaddCart.enabled = NO;
-                        }
+                        self.cqty +=count;
+                        if(self.set_cqty)
+                            self.set_cqty(self.cqty);
                         
-                        [RAUtils message_alert:msg title:title controller:vc] ;
                     }
                     
                     
+                }
+                else
+                {
+                    UIViewController *vc= [RAUtils getViewController:self];
                     
+                    NSString *msg = [return_json valueForKey:@"err_msg"];
+                    NSString *title = @"Add To Cart";
+                    if ([msg hasPrefix:@"Out of Stock.\n"]) {
+                        title = @"Add To Cart: Out of Stock";
+                        msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+                        self.btnNotifyMe.enabled = YES;
+                        self.btnaddCart.enabled = NO;
+                    }
                     
-                });
-            });
+                    [RAUtils message_alert:msg title:title controller:vc] ;
+                }
+                
+                
+                
+                
+            }];
+            
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                NSDictionary* return_json = [RANetwork add_toCart:self.product_id count:count name:model_name];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//
+//
+//
+//                    if([[return_json valueForKey:@"result"] intValue]==2)
+//                    {
+//
+//
+//#ifdef RA_NOTIFICATION
+//                        [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+//
+//                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//                        if(self.shopCartBlock!=nil)
+//                        {
+//                            UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+//
+//
+//                            CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+//                            UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+//                            iv.image = img;
+//                            //                        [self.contentView addSubview:iv];
+//                            self.shopCartBlock(iv);
+//
+//                            self.cqty +=count;
+//                            if(self.set_cqty)
+//                                self.set_cqty(self.cqty);
+//
+//                        }
+//
+//
+//                    }
+//                    else
+//                    {
+//                        UIViewController *vc= [RAUtils getViewController:self];
+//
+//                        NSString *msg = [return_json valueForKey:@"err_msg"];
+//                        NSString *title = @"Add To Cart";
+//                        if ([msg hasPrefix:@"Out of Stock.\n"]) {
+//                            title = @"Add To Cart: Out of Stock";
+//                            msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+//                            self.btnNotifyMe.enabled = YES;
+//                            self.btnaddCart.enabled = NO;
+//                        }
+//
+//                        [RAUtils message_alert:msg title:title controller:vc] ;
+//                    }
+//
+//
+//
+//
+//                });
+//            });
             
         }
         
@@ -1516,56 +1746,58 @@
     [RANetwork request_create_order:^(NSMutableDictionary *result) {
         NSMutableDictionary* return_json = result;
         
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-        
-        if([[return_json valueForKey:@"result"] intValue]==2)
-        {
-            int result=[[return_json valueForKey:@"result"] intValue];
-            if(result==2)
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            if([[return_json valueForKey:@"result"] intValue]==2)
             {
-                //successed.
-                
-                NSString* order_code = [return_json valueForKey:@"orderCode"];
-                AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-                appDelegate.order_code = order_code;
-                
-                int count=[self.quantity_text.text intValue];
-                [self addtocart:count];
-                
-                
-                //    [self ReloadData];
-                
-                
-                //                    if(self.shopCartBlock!=nil)
-                //                    {
-                //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                //
-                //
-                //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                //                        iv.image = img;
-                //                        //                        [self.contentView addSubview:iv];
-                //                        self.shopCartBlock(iv);
-                //
-                //                    }
-                
+                int result=[[return_json valueForKey:@"result"] intValue];
+                if(result==2)
+                {
+                    //successed.
+                    
+                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+                    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+                    appDelegate.order_code = order_code;
+                    
+                    int count=[self.quantity_text.text intValue];
+                    [self addtocart:count];
+                    
+                    
+                    //    [self ReloadData];
+                    
+                    
+                    //                    if(self.shopCartBlock!=nil)
+                    //                    {
+                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                    //
+                    //
+                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                    //                        iv.image = img;
+                    //                        //                        [self.contentView addSubview:iv];
+                    //                        self.shopCartBlock(iv);
+                    //
+                    //                    }
+                    
+                }
             }
-        }
-        else
-        {
-            UIViewController *vc= [RAUtils getViewController:self];
-            NSString *msg = [return_json valueForKey:@"err_msg"];
-            NSString *title = @"Add To Cart";
-            if ([msg hasPrefix:@"Out of Stock.\n"]) {
-                title = @"Add To Cart: Out of Stock";
-                msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
-                self.btnNotifyMe.enabled = YES;
-                self.btnaddCart.enabled = NO;
+            else
+            {
+                UIViewController *vc= [RAUtils getViewController:self];
+                NSString *msg = [return_json valueForKey:@"err_msg"];
+                NSString *title = @"Add To Cart";
+                if ([msg hasPrefix:@"Out of Stock.\n"]) {
+                    title = @"Add To Cart: Out of Stock";
+                    msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+                    self.btnNotifyMe.enabled = YES;
+                    self.btnaddCart.enabled = NO;
+                }
+                
+                [RAUtils message_alert:msg title:title controller:vc] ;
             }
-            
-            [RAUtils message_alert:msg title:title controller:vc] ;
-        }
+        }];
+        
+        
+        
         
         
         

+ 113 - 84
RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m

@@ -645,9 +645,7 @@ dispatch_async(dispatch_get_main_queue(), ^{
     [RANetwork request_hangtag:vc.groupName completionHandler:^(NSMutableDictionary *result) {
         NSMutableDictionary* editor_json =result;
         
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
-            
+        [waitalert dismissViewControllerAnimated:YES completion:^{
             if([[editor_json valueForKey:@"result"] intValue]==2)
             {
                 
@@ -666,7 +664,7 @@ dispatch_async(dispatch_get_main_queue(), ^{
                 NSString* company=    [appDelegate.customerInfo valueForKey:@"customer_name"];
                 
                 if(company==nil)
-                company=@"";
+                    company=@"";
                 
                 NSString* customer_email=    [appDelegate.customerInfo valueForKey:@"customer_email"];
                 
@@ -692,6 +690,10 @@ dispatch_async(dispatch_get_main_queue(), ^{
             {
                 [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Create Hang Tag" controller:vc];
             }
+        }];
+            
+            
+            
             
         
     }];
@@ -1396,37 +1398,39 @@ dispatch_async(dispatch_get_main_queue(), ^{
                     NSMutableDictionary *dic =result;
                     
                     
-                    [waitting_alert dismissViewControllerAnimated:YES completion:nil];
-//                    [waitting_alert dismissWithClickedButtonIndex:0 animated:NO];
-                    
-                    int result_code = [[dic valueForKey:@"result"] intValue];
-                    
-                    if (result_code != RESULT_TRUE && result_code != RESULT_NO_EMAIL_ADDRESS) {
-                        
-                        NSString *msg = [NSString stringWithFormat:@"The email send failed"];
-                        
-                        if ([dic valueForKey:@"err_msg"]) {
-                            msg = [dic valueForKey:@"err_msg"];
-                        }
-                        
+                    [waitting_alert dismissViewControllerAnimated:YES completion:^{
+                        int result_code = [[dic valueForKey:@"result"] intValue];
                         
-                        UIAlertController *errorAlertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:msg preferredStyle:UIAlertControllerStyleAlert];
-                        UIAlertAction *action = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                        if (result_code != RESULT_TRUE && result_code != RESULT_NO_EMAIL_ADDRESS) {
                             
-                        }];
-                        
-                        [errorAlertVC addAction:action];
-                        [weakself presentViewController:errorAlertVC animated:YES completion:nil];
-                        
-                    } else if (result_code == RESULT_TRUE){
-                        
-                        [RAUtils message_alert:@"Notification is sent to default email address." title:@"Message" controller:weakself];
-                        
-                    } else if (result_code == RESULT_NO_EMAIL_ADDRESS) {
-                        
-                        [self showEmailAddrBox];
-                        
-                    }
+                            NSString *msg = [NSString stringWithFormat:@"The email send failed"];
+                            
+                            if ([dic valueForKey:@"err_msg"]) {
+                                msg = [dic valueForKey:@"err_msg"];
+                            }
+                            
+                            
+                            UIAlertController *errorAlertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                            UIAlertAction *action = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                                
+                            }];
+                            
+                            [errorAlertVC addAction:action];
+                            [weakself presentViewController:errorAlertVC animated:YES completion:nil];
+                            
+                        } else if (result_code == RESULT_TRUE){
+                            
+                            [RAUtils message_alert:@"Notification is sent to default email address." title:@"Message" controller:weakself];
+                            
+                        } else if (result_code == RESULT_NO_EMAIL_ADDRESS) {
+                            
+                            [self showEmailAddrBox];
+                            
+                        }
+                    }];
+//                    [waitting_alert dismissWithClickedButtonIndex:0 animated:NO];
+                    
+                   
                     
                 }];
                 
@@ -2583,33 +2587,56 @@ dispatch_async(dispatch_get_main_queue(), ^{
 
     [cell begin_refresh];
 //    UIAlertController * waitalert = [RAUtils waiting_alert:selftitle:@"Refreshing"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* editor_json = [RANetwork commoneditor_partialrefresh:params url:url];
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [cell end_refresh ];
-//            [waitalert dismissViewControllerAnimated:YES completion:nil];
-             sender.enabled=true;
-            
-            if([[editor_json valueForKey:@"result"] intValue]==2)
-            {
+    [RANetwork request_commoneditor_partialrefresh:params url:url completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* editor_json =result;
+                [cell end_refresh ];
+    //            [waitalert dismissViewControllerAnimated:YES completion:nil];
+                 sender.enabled=true;
                 
-                [self.detail_data addEntriesFromDictionary:editor_json];
+                if([[editor_json valueForKey:@"result"] intValue]==2)
+                {
+                    
+                    [self.detail_data addEntriesFromDictionary:editor_json];
+                    
+                        NSRange range = NSMakeRange(sender.tag, 1);
+                        NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
+                        [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
+                    
+                }
+                else
+                {
+                    [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:self] ;
+                }
                 
-                    NSRange range = NSMakeRange(sender.tag, 1);
-                    NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
-                    [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
                 
-            }
-            else
-            {
-                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:self] ;
-            }
-            
-            
-        });
-    });
+            }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* editor_json = [RANetwork commoneditor_partialrefresh:params url:url];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [cell end_refresh ];
+////            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//             sender.enabled=true;
+//
+//            if([[editor_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//                [self.detail_data addEntriesFromDictionary:editor_json];
+//
+//                    NSRange range = NSMakeRange(sender.tag, 1);
+//                    NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
+//                    [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:self] ;
+//            }
+//
+//
+//        });
+//    });
 
     
     
@@ -2692,35 +2719,37 @@ dispatch_async(dispatch_get_main_queue(), ^{
                     DebugLog(@"email cart result: %@",result);
                     
                     
-                    [waitting_alert dismissViewControllerAnimated:YES completion:nil];
+                    [waitting_alert dismissViewControllerAnimated:YES completion:^{
+                        int resultStatus = [[result objectForKey:@"result"] intValue];
+                        if (resultStatus != RESULT_TRUE && resultStatus != RESULT_NO_EMAIL_ADDRESS) {
+                            
+                            NSString *msg = [NSString stringWithFormat:@"The email send failed"];
+                            if ([result valueForKey:@"err_msg"]) {
+                                msg = [result valueForKey:@"err_msg"];
+                            }
+                            
+                            
+                            UIAlertController *errorAlertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                            UIAlertAction *action = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                                
+                            }];
+                            
+                            [errorAlertVC addAction:action];
+                            [weakself presentViewController:errorAlertVC animated:YES completion:nil];
+                            
+                        }else if(resultStatus == RESULT_TRUE){
+                            
+                            [RAUtils message_alert:@"Notification is sent to default email address." title:@"Message" controller:weakself];
+                            
+                        } else if (resultStatus == RESULT_NO_EMAIL_ADDRESS) {
+                            
+                            [weakself showEmailAddrBox];
+                            
+                        }
+                    }];
 //                    [waitting_alert dismissWithClickedButtonIndex:0 animated:NO];
                     
-                    int resultStatus = [[result objectForKey:@"result"] intValue];
-                    if (resultStatus != RESULT_TRUE && resultStatus != RESULT_NO_EMAIL_ADDRESS) {
-                        
-                        NSString *msg = [NSString stringWithFormat:@"The email send failed"];
-                        if ([result valueForKey:@"err_msg"]) {
-                            msg = [result valueForKey:@"err_msg"];
-                        }
-                        
-                        
-                        UIAlertController *errorAlertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:msg preferredStyle:UIAlertControllerStyleAlert];
-                        UIAlertAction *action = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-                            
-                        }];
-                        
-                        [errorAlertVC addAction:action];
-                        [weakself presentViewController:errorAlertVC animated:YES completion:nil];
-                        
-                    }else if(resultStatus == RESULT_TRUE){
-                        
-                        [RAUtils message_alert:@"Notification is sent to default email address." title:@"Message" controller:weakself];
-                        
-                    } else if (resultStatus == RESULT_NO_EMAIL_ADDRESS) {
-                        
-                        [weakself showEmailAddrBox];
-                        
-                    }
+                    
                     
                     
                 }];

+ 34 - 32
RedAnt ERP Mobile/common/Functions/modelDetail/HomerModelDetailHeaderCell.m

@@ -1031,41 +1031,43 @@ self.informationLabel.frame = CGRectMake(self.informationLabel.frame.origin.x, s
         NSDictionary* return_json = [RANetwork new_Order];
         
         dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                int result=[[return_json valueForKey:@"result"] intValue];
-                if(result==2)
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                if([[return_json valueForKey:@"result"] intValue]==2)
                 {
-                    //successed.
-                    
-                    NSString* order_code = [return_json valueForKey:@"orderCode"];
-                    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-                    appDelegate.order_code = order_code;
-                    
-                    int count=[self.quantity_text.text intValue];
-                    [self addtocart:count];
-                    
-                    
-                    
+                    int result=[[return_json valueForKey:@"result"] intValue];
+                    if(result==2)
+                    {
+                        //successed.
+                        
+                        NSString* order_code = [return_json valueForKey:@"orderCode"];
+                        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+                        appDelegate.order_code = order_code;
+                        
+                        int count=[self.quantity_text.text intValue];
+                        [self addtocart:count];
+                        
+                        
+                        
+                    }
                 }
-            }
-            else
-            {
-                UIViewController *vc= [RAUtils getViewController:self];
-                NSString *msg = [return_json valueForKey:@"err_msg"];
-                NSString *title = @"Add To Cart";
-                if ([msg hasPrefix:@"Out of Stock.\n"]) {
-                    title = @"Add To Cart: Out of Stock";
-                    msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
-                    self.btnNotifyMe.enabled = YES;
-                    self.btnaddCart.enabled = NO;
+                else
+                {
+                    UIViewController *vc= [RAUtils getViewController:self];
+                    NSString *msg = [return_json valueForKey:@"err_msg"];
+                    NSString *title = @"Add To Cart";
+                    if ([msg hasPrefix:@"Out of Stock.\n"]) {
+                        title = @"Add To Cart: Out of Stock";
+                        msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+                        self.btnNotifyMe.enabled = YES;
+                        self.btnaddCart.enabled = NO;
+                    }
+                    
+                    [RAUtils message_alert:msg title:title controller:vc] ;
                 }
-                
-                [RAUtils message_alert:msg title:title controller:vc] ;
-            }
+            }];
+            
+            
+            
             
             
             

+ 78 - 74
RedAnt ERP Mobile/common/Functions/offline/OfflineSettingViewController.m

@@ -447,50 +447,52 @@
             [RANetwork request_logout:^(NSMutableDictionary *result) {
                 NSMutableDictionary* return_json=result ;
                 
-                [waitalert dismissViewControllerAnimated:YES completion:nil];
-                
-                
-                if([[return_json valueForKey:@"result"] intValue]==2)
-                {
-                    
-                    [appDelegate Logout];
-                    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
-                    [defaults removeObjectForKey:@"EnableOfflineMode"];
-                    [defaults setBool:self.switch_offline.isOn forKey:@"EnableOfflineMode"];
-                    
-                    [defaults synchronize];
+                [waitalert dismissViewControllerAnimated:YES completion:^{
+                    if([[return_json valueForKey:@"result"] intValue]==2)
+                    {
+                        
+                        [appDelegate Logout];
+                        NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+                        [defaults removeObjectForKey:@"EnableOfflineMode"];
+                        [defaults setBool:self.switch_offline.isOn forKey:@"EnableOfflineMode"];
+                        
+                        [defaults synchronize];
 #ifdef OFFLINE_MODE
-                    appDelegate.offline_mode =self.switch_offline.isOn;
+                        appDelegate.offline_mode =self.switch_offline.isOn;
 #endif
-                    
+                        
 #ifdef RA_NOTIFICATION
-                    
-                    [ActiveViewController Notify:@"PortfolioViewController,WatchListViewController,CategoryViewController,PDFListViewController,CartViewController,OrderListViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                        
+                        [ActiveViewController Notify:@"PortfolioViewController,WatchListViewController,CategoryViewController,PDFListViewController,CartViewController,OrderListViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                    [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
-                    [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
-                    
-                    [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
-                    [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
-                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                    
-                    //                        [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
-                    
-                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-                    [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
-                    //                        [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
-                    
-                    
+                        [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
+                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+                        
+                        [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
+                        [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
+                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                        
+                        //                        [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
+                        
+                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                        [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
+                        //                        [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
+                        
+                        
 #endif
-                    
-                    
-                    
-                    [((MainViewController*)appDelegate.main_vc) switchToHome];
-                }
-                else
-                {
-                    // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Sign Out" controller:self] ;
-                }
+                        
+                        
+                        
+                        [((MainViewController*)appDelegate.main_vc) switchToHome];
+                    }
+                    else
+                    {
+                        // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Sign Out" controller:self] ;
+                    }
+                }];
+                
+                
+                
                 
                 
                 
@@ -598,46 +600,48 @@
                 [RANetwork request_logout:^(NSMutableDictionary *result) {
                     NSMutableDictionary* return_json = result;
                     
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    
-                    
-                    if([[return_json valueForKey:@"result"] intValue]==2)
-                    {
-                        
-                        [appDelegate Logout];
-                        
-                        NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
-                        [defaults removeObjectForKey:@"EnableOfflineMode"];
-                        [defaults setBool:self.switch_offline.isOn forKey:@"EnableOfflineMode"];
-                        
-                        [defaults synchronize];
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
+                        if([[return_json valueForKey:@"result"] intValue]==2)
+                        {
+                            
+                            [appDelegate Logout];
+                            
+                            NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+                            [defaults removeObjectForKey:@"EnableOfflineMode"];
+                            [defaults setBool:self.switch_offline.isOn forKey:@"EnableOfflineMode"];
+                            
+                            [defaults synchronize];
 #ifdef OFFLINE_MODE
-                        appDelegate.offline_mode =self.switch_offline.isOn;
+                            appDelegate.offline_mode =self.switch_offline.isOn;
 #endif
-                        
+                            
 #ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"PortfolioViewController,WatchListViewController,CategoryViewController,PDFListViewController,CartViewController,OrderListViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                            [ActiveViewController Notify:@"PortfolioViewController,WatchListViewController,CategoryViewController,PDFListViewController,CartViewController,OrderListViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                        [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
-                        [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
-                        [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
-                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
-                        //                            [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
-                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-                        [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
-                        //                            [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
+                            [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
+                            [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
+                            [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
+                            [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                            [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+                            //                            [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
+                            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                            [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
+                            //                            [((MainViewController*)appDelegate.main_vc) reloadCategory:true immediately:false];
 #endif
-                        
-                        
-                        
-                        
-                        [((MainViewController*)appDelegate.main_vc) switchToHome];
-                    }
-                    else
-                    {
-                        // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Sign Out" controller:self] ;
-                    }
+                            
+                            
+                            
+                            
+                            [((MainViewController*)appDelegate.main_vc) switchToHome];
+                        }
+                        else
+                        {
+                            // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Sign Out" controller:self] ;
+                        }
+                    }];
+                    
+                    
+                    
                     
                     
                     

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

@@ -71,9 +71,11 @@
 }
 - (IBAction)CloseClick:(id)sender {
     
-    [self dismissViewControllerAnimated:true completion:nil];
-    if(self.returnValue)
-        self.returnValue(false);
+    [self dismissViewControllerAnimated:YES completion:^{
+        if(self.returnValue)
+            self.returnValue(false);
+    }];
+
     
     
     

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

@@ -161,30 +161,56 @@
             UIAlertAction *closeOrderAction = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                 
                 
-                [alertVC dismissViewControllerAnimated:YES completion:nil];
-                // 关闭订单
-                UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
-                NSDictionary* order_json = [RANetwork release_Order:order_code withScreen:ScreenCodeOfflineSetting];
-                
-                dispatch_async(dispatch_get_main_queue(), ^{
+                [alertVC dismissViewControllerAnimated:YES completion:^{
+                    // 关闭订单
+                    UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
                     
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-//                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    if([[order_json valueForKey:@"result"] intValue]==2)
-                    {
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        
-                        [appDelegate closeOrder];
-                        closeOrder = YES;
+                    [RANetwork request_release_order:order_code withScreen:ScreenCodeOfflineSetting completionHandler:^(NSMutableDictionary *result) {
+                        NSDictionary* order_json =result;
                         
-                        [weakself uploadButtonClicked:weakself.uploadButton];
+                        [waitalert dismissViewControllerAnimated:YES completion:^{
+                            //                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+                            if([[order_json valueForKey:@"result"] intValue]==2)
+                            {
+                                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                                
+                                [appDelegate closeOrder];
+                                closeOrder = YES;
+                                
+                                [weakself uploadButtonClicked:weakself.uploadButton];
+                                
+                            } else {
+                                // 释放失败
+                                closeOrder = NO;
+                                [RAUtils message_alert:@"Release Order Failed!" title:@"Warning" controller:weakself];
+                            }
+                        }];
                         
-                    } else {
-                        // 释放失败
-                        closeOrder = NO;
-                        [RAUtils message_alert:@"Release Order Failed!" title:@"Warning" controller:weakself];
-                    }
-                });
+                    }];
+                }];
+               
+                
+//                NSDictionary* order_json = [RANetwork release_Order:order_code withScreen:ScreenCodeOfflineSetting];
+                
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+////                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+//                    if([[order_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//
+//                        [appDelegate closeOrder];
+//                        closeOrder = YES;
+//
+//                        [weakself uploadButtonClicked:weakself.uploadButton];
+//
+//                    } else {
+//                        // 释放失败
+//                        closeOrder = NO;
+//                        [RAUtils message_alert:@"Release Order Failed!" title:@"Warning" controller:weakself];
+//                    }
+//                });
             }];
             
             [alertVC addAction:cancelAction];
@@ -208,17 +234,19 @@
         
         
         [RANetwork request_mergeorder:params completionHandler:^(NSMutableDictionary *result) {
-             NSDictionary *ret = result;
-//            [waitalert dismissWithClickedButtonIndex:0 animated:YES];
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-                   
-                   [self.navigationController dismissViewControllerAnimated:YES completion:^{
-                       
-                       if (weakself.mergeBlock) {
-                           weakself.mergeBlock(ret);
-                       }
-                       
-                   }];
+            NSDictionary *ret = result;
+            //            [waitalert dismissWithClickedButtonIndex:0 animated:YES];
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                [self.navigationController dismissViewControllerAnimated:YES completion:^{
+                    
+                    if (weakself.mergeBlock) {
+                        weakself.mergeBlock(ret);
+                    }
+                    
+                }];
+                
+            }];
+            
         }];
         
 //        NSDictionary *ret = [RANetwork merge_order:params];

+ 302 - 114
RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m

@@ -1746,12 +1746,11 @@
         UIAlertAction *action_2 = [UIAlertAction actionWithTitle:a2Title style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
             AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
             UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                
-                NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:nil];
+            
+            [RANetwork request_release_order:appDelegate.order_code withScreen:nil completionHandler:^(NSMutableDictionary *result) {
+                NSDictionary* order_json = result;
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+                [waitalert dismissViewControllerAnimated:YES completion:^{
                     if([[order_json valueForKey:@"result"] intValue]==2)
                     {
                         AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
@@ -1787,11 +1786,58 @@
                     {
                         [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 release_Order:appDelegate.order_code withScreen:nil];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+//                    if([[order_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                        //                        appDelegate.order_code = nil;
+//
+//                        [appDelegate closeOrder];
+//
+//
+//#ifdef RA_NOTIFICATION
+//                        [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//
+//                        [((MainViewController*)appDelegate.main_vc) switchToHome];
+//
+//                        if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
+//                        {
+//                            [((MainViewController*)appDelegate.main_vc) Loginout:false];
+//                        }
+//
+//                        [self prepareReturn:nil];
+//
+//
+//                        [self.navigationController popViewControllerAnimated:true];
+//                        //                        [self.navigationController dismissViewControllerAnimated:true completion:^{
+//                        //                            ;
+//                        //                        }];
+//
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
+//                    }
+//
+//
+//
+//                });
+//            });
             
             
         }];
@@ -1890,77 +1936,79 @@
     [RANetwork request_save_order:upparams completionHandler:^(NSMutableDictionary *result) {
         NSDictionary* editor_json =result;
         
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-        
-        if([[editor_json valueForKey:@"result"] intValue]==2)
-        {
-            
-            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-            
-            
-            
-            NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-            
-            
-            if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
-            {
-                appDelegate.customerInfo = customerInfo;
-                appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
-            }
-            NSString *msg = nil;
-            if ([editor_json objectForKey:@"so#"]) {
-                msg = [@"SO#:" stringByAppendingString:[editor_json objectForKey:@"so#"]];
-            }
-            [RAUtils message_alert:msg title:@"Order Saved" controller:self] ;
-            
-            if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            if([[editor_json valueForKey:@"result"] intValue]==2)
             {
-                [((MainViewController*)appDelegate.main_vc) Loginout:false];
-                [self prepareReturn:nil];
-                [self.navigationController popViewControllerAnimated:true];
-            }
-            else{
+                
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                
+                
+                
+                NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
                 
                 
+                if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+                {
+                    appDelegate.customerInfo = customerInfo;
+                    appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
+                }
+                NSString *msg = nil;
+                if ([editor_json objectForKey:@"so#"]) {
+                    msg = [@"SO#:" stringByAppendingString:[editor_json objectForKey:@"so#"]];
+                }
+                [RAUtils message_alert:msg title:@"Order Saved" controller:self] ;
+                
+                if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+                {
+                    [((MainViewController*)appDelegate.main_vc) Loginout:false];
+                    [self prepareReturn:nil];
+                    [self.navigationController popViewControllerAnimated:true];
+                }
+                else{
+                    
+                    
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                    
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-            }
-            
-            if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
+                }
                 
-                if (![Singleton sharedInstance].currentOrderIsMerged) {
-                    [self releaseOrderAfterSave];
+                if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
+                    
+                    if (![Singleton sharedInstance].currentOrderIsMerged) {
+                        [self releaseOrderAfterSave];
+                    }
+                    
+                    
                 }
                 
                 
+                //                if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
+                //                    appDelegate.order_code = nil;
+                //
+                //                }
+                //    //     self.labelContact.text=appDelegate.contact_name;
+                //
+                //    NSDictionary * customerinfo = appDelegate.customerInfo;
+                // [self prepareReturn:nil];
+                //                [self.navigationController dismissViewControllerAnimated:true completion:^{
+                //
+                //
+                //                    ;
+                //                }];
+                
             }
-            
-            
-            //                if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
-            //                    appDelegate.order_code = nil;
-            //
-            //                }
-            //    //     self.labelContact.text=appDelegate.contact_name;
-            //
-            //    NSDictionary * customerinfo = appDelegate.customerInfo;
-            // [self prepareReturn:nil];
-            //                [self.navigationController dismissViewControllerAnimated:true completion:^{
-            //
-            //
-            //                    ;
-            //                }];
-            
-        }
-        else
-        {
-            [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
-        }
+            else
+            {
+                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
+            }
+        }];
+        
+        
+        
         
         
         
@@ -2539,19 +2587,27 @@
 //}
 
 - (void)releaseOrderAfterSave {
-    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
-    [RANetwork release_Order:appDelegate.order_code withScreen:nil];
-
-    [appDelegate closeOrder]; 
-    [appDelegate SetSo:nil];
-    appDelegate.cart_count=0;
-    [appDelegate update_count_mark];
-    [((MainViewController*)appDelegate.main_vc) switchToOrder];
-
-    [self prepareReturn:nil];
-    [self.navigationController popToRootViewControllerAnimated:false];
     
+    dispatch_async(dispatch_get_main_queue(), ^{
+        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+        
+        //        [RANetwork release_Order:appDelegate.order_code withScreen:nil];
+        
+        
+        
+        
+        [RANetwork request_release_order:appDelegate.order_code withScreen:nil completionHandler:nil];
+        [appDelegate closeOrder];
+        [appDelegate SetSo:nil];
+        appDelegate.cart_count=0;
+        [appDelegate update_count_mark];
+        [((MainViewController*)appDelegate.main_vc) switchToOrder];
+        
+        [self prepareReturn:nil];
+        [self.navigationController popToRootViewControllerAnimated:false];
+        
+    });
+
 }
 
 -(NSString* )create_customer_ext:(NSDictionary*)customerinfo
@@ -3150,14 +3206,9 @@
     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Order Submission"];
     
     [upparams setValue:@"true" forKey:@"isHold"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
+    [RANetwork request_commit_order:upparams completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* editor_json =result;
+        [waitalert dismissViewControllerAnimated:YES completion:^{
             if([[editor_json valueForKey:@"result"] intValue]==2)
             {
                 
@@ -3165,7 +3216,7 @@
                 // appDelegate.customerInfo = customerInfo;
                 
                 [appDelegate closeOrder];
-
+                
                 
 #ifdef RA_NOTIFICATION
                 [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
@@ -3189,9 +3240,9 @@
                 }
                 
                 [RAUtils message_alert:msg title:title controller:self];
-//                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+                //                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                 
-//                [alert show];
+                //                [alert show];
                 
                 [self prepareReturn:nil];
                 [self.navigationController popToRootViewControllerAnimated:true];
@@ -3202,22 +3253,73 @@
             {
                 [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
             }
-        });
-    });
+        }];
+        
+        
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//            if([[editor_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                // appDelegate.customerInfo = customerInfo;
+//
+//                [appDelegate closeOrder];
+//
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//
+//                NSString* title=nil;
+//                NSString* msg=nil;
+//#ifdef OFFLINE_MODE
+//                if(appDelegate.offline_mode)
+//                {
+//                    title=TITLE_OFFLINE_SUBMIT;
+//                    msg=MSG_OFFLINE_SUBMIT;
+//                }
+//                else
+//#endif
+//                {
+//                    title=@"Order submitted sucessfully";
+//                    msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
+//                }
+//
+//                [RAUtils message_alert:msg title:title controller:self];
+////                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+//
+////                [alert show];
+//
+//                [self prepareReturn:nil];
+//                [self.navigationController popToRootViewControllerAnimated:true];
+//
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
+//            }
+//        });
+//    });
 }
 
 - (void)empolyee_commit_order:(NSMutableDictionary *)upparams {
     
     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Order Submission"];
     [upparams setValue:@"false" forKey:@"isHold"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
-            
+    [RANetwork request_commit_order:upparams completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* editor_json = result;
+        [waitalert dismissViewControllerAnimated:YES completion:^{
             if([[editor_json valueForKey:@"result"] intValue]==2)
             {
                 
@@ -3227,7 +3329,7 @@
                 NSString* send_to =appDelegate.customerInfo[@"customer_email"];
                 
                 [appDelegate closeOrder];
-
+                
                 
 #ifdef RA_NOTIFICATION
                 [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
@@ -3253,10 +3355,10 @@
                 
                 UIAlertController* message_alert=[RAUtils message_alert:msg title:title controller:self];
                 
-//                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-//
-//                [alert show];
-//
+                //                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+                //
+                //                [alert show];
+                //
                 NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
                 NSString* email_content =[editor_json valueForKey:@"email_content"];
                 NSString* soid=[editor_json valueForKey:@"so#"];
@@ -3276,10 +3378,12 @@
                 {
                     
                     
-                    [message_alert dismissViewControllerAnimated:YES completion:nil];
-                    //                        [alert dismissWithClickedButtonIndex:0 animated:FALSE];
-                    [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
-                    //  [appDelegate printPdf:pdf_url];
+                    [message_alert dismissViewControllerAnimated:YES completion:^{
+                        //                        [alert dismissWithClickedButtonIndex:0 animated:FALSE];
+                        [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
+                        //  [appDelegate printPdf:pdf_url];
+                    }];
+ 
                     
                 }
                 
@@ -3289,8 +3393,92 @@
             {
                 [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
             }
-        });
-    });
+        }];
+        
+        
+        
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//
+//            if([[editor_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//                // debug aaa
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                NSString* company= appDelegate.customerInfo[@"customer_name"];
+//                NSString* send_to =appDelegate.customerInfo[@"customer_email"];
+//
+//                [appDelegate closeOrder];
+//
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//
+//                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//
+//                NSString* title=nil;
+//                NSString* msg=nil;
+//#ifdef OFFLINE_MODE
+//                if(appDelegate.offline_mode)
+//                {
+//                    title=TITLE_OFFLINE_SUBMIT;
+//                    msg=MSG_OFFLINE_SUBMIT;
+//                }
+//                else
+//#endif
+//                {
+//                    title=@"Order submitted sucessfully";
+//                    msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
+//                }
+//
+//                UIAlertController* message_alert=[RAUtils message_alert:msg title:title controller:self];
+//
+////                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+////
+////                [alert show];
+////
+//                NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
+//                NSString* email_content =[editor_json valueForKey:@"email_content"];
+//                NSString* soid=[editor_json valueForKey:@"so#"];
+//
+//                NSMutableDictionary *value = [NSMutableDictionary dictionary];
+//                if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
+//                {
+//                    //bbb
+//                    [((MainViewController*)appDelegate.main_vc) Loginout:false];
+//                    value[@"commitorder_logout"]=@"true";
+//                }
+//                [self prepareReturn:value];
+//
+//                [self.navigationController popToRootViewControllerAnimated:true];
+//
+//                if(pdf_url.length>0)
+//                {
+//
+//
+//                    [message_alert dismissViewControllerAnimated:YES completion:nil];
+//                    //                        [alert dismissWithClickedButtonIndex:0 animated:FALSE];
+//                    [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
+//                    //  [appDelegate printPdf:pdf_url];
+//
+//                }
+//
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
+//            }
+//        });
+//    });
 }
 
 

+ 536 - 221
RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m

@@ -291,12 +291,9 @@
     
     UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
         UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-            
-            NSDictionary* order_json = [RANetwork release_Order:self.order_code withScreen:ScreenCodeOrderInfo];
-            
-            dispatch_async(dispatch_get_main_queue(), ^{
-                [waitalert dismissViewControllerAnimated:YES completion:nil];
+        [RANetwork request_release_order:self.order_code withScreen:ScreenCodeOrderInfo completionHandler:^(NSMutableDictionary *result) {
+            NSDictionary* order_json =result;
+            [waitalert dismissViewControllerAnimated:YES completion:^{
                 if([[order_json valueForKey:@"result"] intValue]==2)
                 {
                     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
@@ -315,11 +312,42 @@
                 {
                     [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 release_Order:self.order_code withScreen:ScreenCodeOrderInfo];
+//
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//                [waitalert dismissViewControllerAnimated:YES completion:nil];
+//                if([[order_json valueForKey:@"result"] intValue]==2)
+//                {
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    //                    appDelegate.order_code = nil;
+//                    [appDelegate closeOrder];
+//
+//                    //                appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
+//                    //
+//                    //                appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
+//                    //                if(self.selectOrder)
+//                    //                    self.selectOrder();
+//                    [self.navigationController popToRootViewControllerAnimated:false];
+//
+//                }
+//                else
+//                {
+//                    [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
+//                }
+//
+//
+//
+//            });
+//        });
         
     }];
     
@@ -566,13 +594,9 @@
             
             UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
             
-            dispatch_async(dispatch_get_global_queue(0, 0), ^{
-                
-                NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:ScreenCodeOrderInfo];
-                
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+            [RANetwork request_release_order:appDelegate.order_code withScreen:ScreenCodeOrderInfo completionHandler:^(NSMutableDictionary *result) {
+                NSDictionary* order_json = result;
+                [waitalert dismissViewControllerAnimated:YES completion:^{
                     if([[order_json valueForKey:@"result"] intValue]==2)
                     {
                         [appDelegate closeOrder];
@@ -581,11 +605,32 @@
                         
                     } else {
                         
-                       [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Release Order" controller:weakself] ;
+                        [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Release Order" controller:weakself] ;
                     }
-                });
-                
-            });
+                }];
+
+            }];
+            
+//            dispatch_async(dispatch_get_global_queue(0, 0), ^{
+//
+//                NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:ScreenCodeOrderInfo];
+//
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+//                    if([[order_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        [appDelegate closeOrder];
+//
+//                        [weakself copyOrder];
+//
+//                    } else {
+//
+//                       [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Release Order" controller:weakself] ;
+//                    }
+//                });
+//
+//            });
             
         }];
         
@@ -679,12 +724,9 @@
             
             {
                 UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Signature"];
-                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                    
-                    NSDictionary* order_json = [RANetwork sign_Order:self.order_code path:img_url_up];
-                    
-                    dispatch_async(dispatch_get_main_queue(), ^{
-                        [waitalert dismissViewControllerAnimated:YES completion:nil];
+                [RANetwork request_update_order_signature:self.order_code path:img_url_up completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* order_json = result;
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
                         if([[order_json valueForKey:@"result"] intValue]==2)
                         {
                             //                                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
@@ -731,7 +773,7 @@
                             
                             
 #ifdef BUILD_HMLG
-                        
+                            
                             [self.content_data setValue:img_url_down forKey:@"sign_url"];
 #endif
                             //self.btnSign.enabled = false;
@@ -745,11 +787,84 @@
                         {
                             [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:self] ;
                         }
-                        
-                        
-                        
-                    });
-                });
+                    }];
+                    
+                    
+                    
+                    
+                }];
+                
+//                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                    NSDictionary* order_json = [RANetwork sign_Order:self.order_code path:img_url_up];
+//
+//                    dispatch_async(dispatch_get_main_queue(), ^{
+//                        [waitalert dismissViewControllerAnimated:YES completion:nil];
+//                        if([[order_json valueForKey:@"result"] intValue]==2)
+//                        {
+//                            //                                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                            //                                appDelegate.order_code = self.order_code;
+//                            //                                [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];
+//                            //
+//                            //                                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//                            //                                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//                            //                                if(self.selectOrder)
+//                            //                                    self.selectOrder(self.content_data);
+//#if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
+//                            int count = [[self.content_data objectForKey:@"count"] intValue];
+//                            for (int i = 0; i < count; i++) {
+//                                NSString *key = [NSString stringWithFormat:@"section_%d",i];
+//                                NSMutableDictionary *section = [[self.content_data objectForKey:key] mutableCopy];
+//                                NSString *type = [section objectForKey:@"type"];
+//                                if ([type isEqualToString:@"sign_url"]) {
+//                                    [section setObject:img_url_down forKey:@"data"];
+//                                    [self.content_data setObject:section forKey:key];
+//                                    break;
+//                                }
+//                            }
+//#endif
+//
+//#if defined(BUILD_HOMER) || defined(BUILD_GATIT)
+//                            int count = [[self.content_data objectForKey:@"count"] intValue];
+//                            for (int i = 0; i < count; i++) {
+//                                NSString *key = [NSString stringWithFormat:@"section_%d",i];
+//                                NSMutableDictionary *section = [[self.content_data objectForKey:key] mutableCopy];
+//                                NSString *type = [section objectForKey:@"type"];
+//                                if ([type isEqualToString:@"sign_url"]) {
+//                                    [section setObject:img_url_down forKey:@"data"];
+//                                    [self.content_data setObject:section forKey:key];
+//                                    break;
+//                                }
+//                            }
+//#endif
+//
+//
+//#ifdef BUILD_HMLG
+//
+//                            [self.content_data setValue:img_url_down forKey:@"sign_url"];
+//#endif
+//                            //self.btnSign.enabled = false;
+//                            [self.detailTable reloadData];
+//
+//                            [RAUtils message_alert:@"Successful." title:@"Signature" controller:self];
+//
+//
+//                        }
+//                        else
+//                        {
+//                            [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:self] ;
+//                        }
+//
+//
+//
+//                    });
+//                });
             }
         }
         else
@@ -773,20 +888,18 @@
         UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Signature"];
         
         __weak typeof(self) weakSelf = self;
-        [NetworkUtils upload:imageData FileName:@"test.jpg" Params:params ToHost:URL_UPLOAD_IMG Result:^(NSMutableDictionary *json) {
-            
+        
+        [RANetwork request_fastupload:params filename:@"test.jpg" data:imageData url:URL_UPLOAD_IMG completionHandler:^(NSMutableDictionary *result) {
+            NSMutableDictionary *json=result;
             if([[json valueForKey:@"result"] intValue]==2)
             {
                 NSString* img_url_down = json[@"img_url_aname"];
                 NSString* img_url_up = json[@"img_url"];
                 {
-//                    UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Signature"];
-                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                        
-                        NSDictionary* order_json = [RANetwork sign_Order:weakSelf.order_code path:img_url_up];
-                        
-                        dispatch_async(dispatch_get_main_queue(), ^{
-                            [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    //                    UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Signature"];
+                    [RANetwork request_update_order_signature:self.order_code path:img_url_up completionHandler:^(NSMutableDictionary *result) {
+                        NSDictionary* order_json =result;
+                        [waitalert dismissViewControllerAnimated:YES completion:^{
                             if([[order_json valueForKey:@"result"] intValue]==2)
                             {
                                 
@@ -832,11 +945,69 @@
                             {
                                 [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:weakSelf] ;
                             }
-                            
-                            
-                            
-                        });
-                    });
+                        }];
+                        
+                        
+                        
+                        
+                    }];
+                    
+                    //                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                    //
+                    //                        NSDictionary* order_json = [RANetwork sign_Order:weakSelf.order_code path:img_url_up];
+                    //
+                    //                        dispatch_async(dispatch_get_main_queue(), ^{
+                    //                            [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    //                            if([[order_json valueForKey:@"result"] intValue]==2)
+                    //                            {
+                    //
+                    //#if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
+                    //                                int count = [[weakSelf.content_data objectForKey:@"count"] intValue];
+                    //                                for (int i = 0; i < count; i++) {
+                    //                                    NSString *key = [NSString stringWithFormat:@"section_%d",i];
+                    //                                    NSMutableDictionary *section = [[weakSelf.content_data objectForKey:key] mutableCopy];
+                    //                                    NSString *type = [section objectForKey:@"type"];
+                    //                                    if ([type isEqualToString:@"sign_url"]) {
+                    //                                        [section setObject:img_url_down forKey:@"data"];
+                    //                                        [weakSelf.content_data setObject:section forKey:key];
+                    //                                        break;
+                    //                                    }
+                    //                                }
+                    //#endif
+                    //
+                    //#if defined(BUILD_HOMER) || defined(BUILD_GATIT)
+                    //                                int count = [[weakSelf.content_data objectForKey:@"count"] intValue];
+                    //                                for (int i = 0; i < count; i++) {
+                    //                                    NSString *key = [NSString stringWithFormat:@"section_%d",i];
+                    //                                    NSMutableDictionary *section = [[weakSelf.content_data objectForKey:key] mutableCopy];
+                    //                                    NSString *type = [section objectForKey:@"type"];
+                    //                                    if ([type isEqualToString:@"sign_url"]) {
+                    //                                        [section setObject:img_url_down forKey:@"data"];
+                    //                                        [weakSelf.content_data setObject:section forKey:key];
+                    //                                        break;
+                    //                                    }
+                    //                                }
+                    //#endif
+                    //
+                    //#ifdef BUILD_HMLG
+                    //                                [weakSelf.content_data setValue:img_url_down forKey:@"sign_url"];
+                    //#endif
+                    //                                //self.btnSign.enabled = false;
+                    //                                [weakSelf.detailTable reloadData];
+                    //
+                    //                                [RAUtils message_alert:@"Successful." title:@"Signature" controller:weakSelf];
+                    //
+                    //
+                    //                            }
+                    //                            else
+                    //                            {
+                    //                                [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:weakSelf] ;
+                    //                            }
+                    //
+                    //
+                    //
+                    //                        });
+                    //                    });
                 }
                 
                 
@@ -845,17 +1016,155 @@
             {
                 dispatch_async(dispatch_get_main_queue(), ^{
                     
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    NSString *msg = [json valueForKey:@"err_msg"];
-                    if (msg.length == 0) {
-                        msg = [json objectForKey:@"msg"];
-                    }
-                    
-                    [RAUtils message_alert:msg title:@"Upload Image" controller:weakSelf] ;
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
+                        NSString *msg = [json valueForKey:@"err_msg"];
+                        if (msg.length == 0) {
+                            msg = [json objectForKey:@"msg"];
+                        }
+                        
+                        [RAUtils message_alert:msg title:@"Upload Image" controller:weakSelf] ;
+                    }];
+
                 });
             }
             
-        } Progress:nil DecryptHandler:nil];
+        }];
+//        [NetworkUtils upload:imageData FileName:@"test.jpg" Params:params ToHost:URL_UPLOAD_IMG Result:^(NSMutableDictionary *json) {
+//
+//            if([[json valueForKey:@"result"] intValue]==2)
+//            {
+//                NSString* img_url_down = json[@"img_url_aname"];
+//                NSString* img_url_up = json[@"img_url"];
+//                {
+////                    UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Signature"];
+//                    [RANetwork request_update_order_signature:self.order_code path:img_url_up completionHandler:^(NSMutableDictionary *result) {
+//                        NSDictionary* order_json =result;
+//                        [waitalert dismissViewControllerAnimated:YES completion:nil];
+//                        if([[order_json valueForKey:@"result"] intValue]==2)
+//                        {
+//
+//#if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
+//                            int count = [[weakSelf.content_data objectForKey:@"count"] intValue];
+//                            for (int i = 0; i < count; i++) {
+//                                NSString *key = [NSString stringWithFormat:@"section_%d",i];
+//                                NSMutableDictionary *section = [[weakSelf.content_data objectForKey:key] mutableCopy];
+//                                NSString *type = [section objectForKey:@"type"];
+//                                if ([type isEqualToString:@"sign_url"]) {
+//                                    [section setObject:img_url_down forKey:@"data"];
+//                                    [weakSelf.content_data setObject:section forKey:key];
+//                                    break;
+//                                }
+//                            }
+//#endif
+//
+//#if defined(BUILD_HOMER) || defined(BUILD_GATIT)
+//                            int count = [[weakSelf.content_data objectForKey:@"count"] intValue];
+//                            for (int i = 0; i < count; i++) {
+//                                NSString *key = [NSString stringWithFormat:@"section_%d",i];
+//                                NSMutableDictionary *section = [[weakSelf.content_data objectForKey:key] mutableCopy];
+//                                NSString *type = [section objectForKey:@"type"];
+//                                if ([type isEqualToString:@"sign_url"]) {
+//                                    [section setObject:img_url_down forKey:@"data"];
+//                                    [weakSelf.content_data setObject:section forKey:key];
+//                                    break;
+//                                }
+//                            }
+//#endif
+//
+//#ifdef BUILD_HMLG
+//                            [weakSelf.content_data setValue:img_url_down forKey:@"sign_url"];
+//#endif
+//                            //self.btnSign.enabled = false;
+//                            [weakSelf.detailTable reloadData];
+//
+//                            [RAUtils message_alert:@"Successful." title:@"Signature" controller:weakSelf];
+//
+//
+//                        }
+//                        else
+//                        {
+//                            [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:weakSelf] ;
+//                        }
+//
+//
+//
+//                    }];
+//
+////                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+////
+////                        NSDictionary* order_json = [RANetwork sign_Order:weakSelf.order_code path:img_url_up];
+////
+////                        dispatch_async(dispatch_get_main_queue(), ^{
+////                            [waitalert dismissViewControllerAnimated:YES completion:nil];
+////                            if([[order_json valueForKey:@"result"] intValue]==2)
+////                            {
+////
+////#if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
+////                                int count = [[weakSelf.content_data objectForKey:@"count"] intValue];
+////                                for (int i = 0; i < count; i++) {
+////                                    NSString *key = [NSString stringWithFormat:@"section_%d",i];
+////                                    NSMutableDictionary *section = [[weakSelf.content_data objectForKey:key] mutableCopy];
+////                                    NSString *type = [section objectForKey:@"type"];
+////                                    if ([type isEqualToString:@"sign_url"]) {
+////                                        [section setObject:img_url_down forKey:@"data"];
+////                                        [weakSelf.content_data setObject:section forKey:key];
+////                                        break;
+////                                    }
+////                                }
+////#endif
+////
+////#if defined(BUILD_HOMER) || defined(BUILD_GATIT)
+////                                int count = [[weakSelf.content_data objectForKey:@"count"] intValue];
+////                                for (int i = 0; i < count; i++) {
+////                                    NSString *key = [NSString stringWithFormat:@"section_%d",i];
+////                                    NSMutableDictionary *section = [[weakSelf.content_data objectForKey:key] mutableCopy];
+////                                    NSString *type = [section objectForKey:@"type"];
+////                                    if ([type isEqualToString:@"sign_url"]) {
+////                                        [section setObject:img_url_down forKey:@"data"];
+////                                        [weakSelf.content_data setObject:section forKey:key];
+////                                        break;
+////                                    }
+////                                }
+////#endif
+////
+////#ifdef BUILD_HMLG
+////                                [weakSelf.content_data setValue:img_url_down forKey:@"sign_url"];
+////#endif
+////                                //self.btnSign.enabled = false;
+////                                [weakSelf.detailTable reloadData];
+////
+////                                [RAUtils message_alert:@"Successful." title:@"Signature" controller:weakSelf];
+////
+////
+////                            }
+////                            else
+////                            {
+////                                [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:weakSelf] ;
+////                            }
+////
+////
+////
+////                        });
+////                    });
+//                }
+//
+//
+//            }
+//            else
+//            {
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+//                    NSString *msg = [json valueForKey:@"err_msg"];
+//                    if (msg.length == 0) {
+//                        msg = [json objectForKey:@"msg"];
+//                    }
+//
+//                    [RAUtils message_alert:msg title:@"Upload Image" controller:weakSelf] ;
+//                });
+//            }
+//
+//        } Progress:nil DecryptHandler:nil];
         
 //    AFHTTPRequestSerializer* serializer=[AFHTTPRequestSerializer serializer] ;
 //    DebugLog(URL_UPLOAD_IMG);
@@ -1086,40 +1395,42 @@
     [RANetwork request_open_order:self.order_code completionHandler:^(NSMutableDictionary *result) {
         NSDictionary* order_json = result;
         
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        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 dismissViewControllerAnimated:YES completion:^{
+            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 (completionBlk) {
+                    completionBlk();
+                }
+                
+                //                if(self.selectOrder)
+                //                    self.selectOrder(self.content_data);
             }
-            
-            //                if(self.selectOrder)
-            //                    self.selectOrder(self.content_data);
-        }
-        else
-        {
-            [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
-        }
+            else
+            {
+                [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
+            }
+        }];
+        
         
         
         
@@ -1260,94 +1571,68 @@
             NSDictionary* order_json = result;
             
             
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            [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
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                [self.mum stopAnimating];
+                if([[order_json valueForKey:@"result"] intValue]==2)
                 {
-                    [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Loading Order Detail" controller:self] ;
+                    self.detailTable.hidden = false;
+                    self.content_data = [order_json mutableCopy];
+                    
+                    
                 }
-            }
-            
-            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)
+                else {
+                    self.content_data = nil;
+                    if([[order_json valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
                     {
-                        if(status_code==1||status_code==30)
-                            self.btnPDF.enabled =true;
-                        
+                        self.label_net_err.hidden=false;
+                        self.detailTable.hidden=true;
                     }
                     else
                     {
-                        if(status_code==2)
-                            self.btnPDF.enabled =true;
+                        [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Loading Order Detail" controller:self] ;
                     }
                 }
-            }
-            //            [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)
+                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*/
                 {
-                    self.btnOpen.enabled =true;
-                    
-                    self.btnSign.enabled = true;
+                    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;
+                        }
+                    }
                 }
-                //                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.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.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
                     //
-                    //                    [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
+                    //                        [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
                     
                     BOOL condition = offline_edit;
 #ifdef OFFLINE_MODE
@@ -1355,44 +1640,72 @@
 #else
                     condition = YES;
 #endif
-                    if (condition)
+                    if(condition)
                     {
                         self.btnOpen.enabled =true;
                         
                         self.btnSign.enabled = true;
                     }
-                    //                    self.btnCommit.enabled =false;
+                    //                if([lock_user isEqualToString:appDelegate.user])
+                    //                {
+                    //                    self.btnCommit.enabled =true;
+                    //                }
+                    //                else
+                    //                     self.btnCommit.enabled =false;
                 }
-            BOOL lock_condition_1 = [lock_user isEqualToString:appDelegate.user];
-            BOOL lock_condition_2 = 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
-            lock_condition_1 = !appDelegate.offline_mode && lock_condition_1;
-            lock_condition_2 = appDelegate.offline_mode && [self.order_code isEqualToString:appDelegate.order_code];
+                        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
-            {
+                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 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;
+                }
+            }];
             
-            if (self.order_code == nil) {
-                self.btnCopy.enabled = false;
-            } else {
-                self.btnCopy.enabled = true;
-            }
             
             
         }];
@@ -3749,43 +4062,45 @@
     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Copy Order"];
     [RANetwork request_copy_order:self.order_code completionHandler:^(NSMutableDictionary *result) {
         NSDictionary* order_json = result;
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        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];
-            //
-            //
-            //                    }
-            
-            [RAUtils message_alert:[NSString stringWithFormat:@"New order SO#: %@",[order_json valueForKey:@"so_id"]] title:@"Copy successful." controller:self];
-            
-//            UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Copy successful." message:[NSString stringWithFormat:@"New order SO#: %@",[order_json valueForKey:@"so_id"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-//
-//            [alert show];
-//
-            
-            
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            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];
+                //
+                //
+                //                    }
+                
+                [RAUtils message_alert:[NSString stringWithFormat:@"New order SO#: %@",[order_json valueForKey:@"so_id"]] title:@"Copy successful." controller:self];
+                
+                //            UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Copy successful." message:[NSString stringWithFormat:@"New order SO#: %@",[order_json valueForKey:@"so_id"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+                //
+                //            [alert show];
+                //
+                
+                
 #ifdef RA_NOTIFICATION
-            [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] ;
+            }
+        }];
+        
         
         
         

+ 205 - 92
RedAnt ERP Mobile/common/Functions/order/OrderListViewController.m

@@ -859,56 +859,58 @@
     [RANetwork request_create_order:^(NSMutableDictionary *result) {
         NSMutableDictionary* return_json =result;
         
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-//        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-        
-        if([[return_json valueForKey:@"result"] intValue]==2)
-        {
-            int result=[[return_json valueForKey:@"result"] intValue];
-            if(result==2)
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            if([[return_json valueForKey:@"result"] intValue]==2)
             {
-                //successed.
-                
-                NSString* order_code = [return_json valueForKey:@"orderCode"];
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                appDelegate.order_code = order_code;
-                appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-                
-                
+                int result=[[return_json valueForKey:@"result"] intValue];
+                if(result==2)
+                {
+                    //successed.
+                    
+                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    appDelegate.order_code = order_code;
+                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+                    
+                    
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-                [main_vc reloadCart:true immediately:false];
+                    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+                    [main_vc reloadCart:true immediately:false];
 #endif
-                
-                [self ReloadData];
-                
-                
-                //     [self performSelector:@selector(loadpage) withObject:nil afterDelay:1];
-                //    [self loadpage];
-                
-                
-                //                    if(self.shopCartBlock!=nil)
-                //                    {
-                //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                //
-                //
-                //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                //                        iv.image = img;
-                //                        //                        [self.contentView addSubview:iv];
-                //                        self.shopCartBlock(iv);
-                //
-                //                    }
-                
+                    
+                    [self ReloadData];
+                    
+                    
+                    //     [self performSelector:@selector(loadpage) withObject:nil afterDelay:1];
+                    //    [self loadpage];
+                    
+                    
+                    //                    if(self.shopCartBlock!=nil)
+                    //                    {
+                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                    //
+                    //
+                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                    //                        iv.image = img;
+                    //                        //                        [self.contentView addSubview:iv];
+                    //                        self.shopCartBlock(iv);
+                    //
+                    //                    }
+                    
+                }
             }
-        }
-        else
-        {
-            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:self] ;
-        }
+            else
+            {
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:self] ;
+            }
+        }];
+//        [waitalert dismissViewControllerAnimated:YES completion:nil];
+        
+        
+        
         
         
         
@@ -1533,15 +1535,10 @@
             UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
                 
                 UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Delete Order"];
-                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                    
-                    NSDictionary* return_json = [RANetwork delete_Order:orderid];
-                    
-                    dispatch_async(dispatch_get_main_queue(), ^{
-//                        [waitalert dismissViewControllerAnimated:YES completion:nil];
-                        [waitalert dismissViewControllerAnimated:YES completion:nil];
-                        
-                        
+                [RANetwork request_delete_order:orderid completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* return_json = result;
+                    //                        [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
                         if([[return_json valueForKey:@"result"] intValue]==2)
                         {
                             if([appDelegate.order_code isEqualToString: [self.content_data[indexPath.row] valueForKey:@"order_code"]])
@@ -1553,9 +1550,9 @@
                                 appDelegate.cart_count=0;
                                 [appDelegate update_count_mark];
                                 
-//                                appDelegate.customerInfo = nil;
-//                                appDelegate.contact_id = nil;
-//                                appDelegate.order_customer_id = nil;
+                                //                                appDelegate.customerInfo = nil;
+                                //                                appDelegate.contact_id = nil;
+                                //                                appDelegate.order_customer_id = nil;
                             }
                             
                             [RAUtils message_alert:nil title:@"Order Delete" controller:self] ;
@@ -1565,12 +1562,55 @@
                         {
                             [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Delete Order" controller:self] ;
                         }
-                        
-                        
-                        
-                        
-                    });
-                });
+                    }];
+                    
+                    
+
+                    
+                    
+                    
+                    
+                }];
+                
+                
+//                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                    NSDictionary* return_json = [RANetwork delete_Order:orderid];
+//
+//                    dispatch_async(dispatch_get_main_queue(), ^{
+////                        [waitalert dismissViewControllerAnimated:YES completion:nil];
+//                        [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//
+//                        if([[return_json valueForKey:@"result"] intValue]==2)
+//                        {
+//                            if([appDelegate.order_code isEqualToString: [self.content_data[indexPath.row] valueForKey:@"order_code"]])
+//                            {
+//                                appDelegate.order_code= nil;
+//                                [appDelegate SetSo:nil];
+//
+//
+//                                appDelegate.cart_count=0;
+//                                [appDelegate update_count_mark];
+//
+////                                appDelegate.customerInfo = nil;
+////                                appDelegate.contact_id = nil;
+////                                appDelegate.order_customer_id = nil;
+//                            }
+//
+//                            [RAUtils message_alert:nil title:@"Order Delete" controller:self] ;
+//                            [self ReloadData];
+//                        }
+//                        else
+//                        {
+//                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Delete Order" controller:self] ;
+//                        }
+//
+//
+//
+//
+//                    });
+//                });
                 
                 
             }];
@@ -1613,15 +1653,11 @@
             UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
                 
                 UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Cancel Order"];
-                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                [RANetwork request_cancel_order:orderid order_code:nil completionHandler:^(NSMutableDictionary *result) {
                     
-                    NSDictionary* return_json = [RANetwork cancel_Order:orderid order_code:nil];
-                    
-                    dispatch_async(dispatch_get_main_queue(), ^{
-//                        [waitalert dismissViewControllerAnimated:YES completion:nil];
-                        [waitalert dismissViewControllerAnimated:YES completion:nil];
-                        
-                        
+                    NSDictionary* return_json = result;
+                    //                        [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
                         
                         if([[return_json valueForKey:@"result"] intValue]==2)
                         {
@@ -1645,12 +1681,53 @@
                         {
                             [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Cancel Order" controller:self] ;
                         }
-                        
-                        
-                        
-                        
-                    });
-                });
+                    }];
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                }];
+//                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                    NSDictionary* return_json = [RANetwork cancel_Order:orderid order_code:nil];
+//
+//                    dispatch_async(dispatch_get_main_queue(), ^{
+////                        [waitalert dismissViewControllerAnimated:YES completion:nil];
+//                        [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//
+//
+//                        if([[return_json valueForKey:@"result"] intValue]==2)
+//                        {
+//                            if([appDelegate.order_code isEqualToString: [self.content_data[indexPath.row] valueForKey:@"order_code"]])
+//                            {
+//                                appDelegate.order_code= nil;
+//                                //appDelegate.user_type = 0;
+//                                appDelegate.customerInfo = nil;
+//                                appDelegate.contact_id = nil;
+//                                appDelegate.order_customer_id = nil;
+//                                [appDelegate SetSo:nil];
+//                                appDelegate.cart_count=0;
+//                                [appDelegate update_count_mark];
+//
+//
+//                            }
+//                            [RAUtils message_alert:nil title:@"Order Canceled" controller:self] ;
+//                            [self ReloadData];
+//                        }
+//                        else
+//                        {
+//                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Cancel Order" controller:self] ;
+//                        }
+//
+//
+//
+//
+//                    });
+//                });
                 
                 
             }];
@@ -1852,15 +1929,11 @@
             UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
                 
                 UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Cancel Order"];
-                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                    
-                    NSDictionary* return_json = [RANetwork cancel_Order:orderid order_code:nil];
-                    
-                    dispatch_async(dispatch_get_main_queue(), ^{
-//                        [waitalert dismissViewControllerAnimated:YES completion:nil];
-                        [waitalert dismissViewControllerAnimated:YES completion:nil];
-                        
-                        
+                
+                [RANetwork request_cancel_order:orderid order_code:nil completionHandler:^(NSMutableDictionary *result) {
+                    NSDictionary* return_json =result;
+                    //                        [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
                         if([[return_json valueForKey:@"result"] intValue]==2)
                         {
                             if([appDelegate.order_code isEqualToString: [self.content_data[indexPath.row] valueForKey:@"order_code"]])
@@ -1883,12 +1956,52 @@
                         {
                             [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Cancel Order" controller:self] ;
                         }
-                        
-                        
-                        
-                        
-                    });
-                });
+                    }];
+                    
+                    
+                    
+                    
+                    
+                    
+                    
+                }];
+//                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//                    NSDictionary* return_json = [RANetwork cancel_Order:orderid order_code:nil];
+//
+//                    dispatch_async(dispatch_get_main_queue(), ^{
+////                        [waitalert dismissViewControllerAnimated:YES completion:nil];
+//                        [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//
+//                        if([[return_json valueForKey:@"result"] intValue]==2)
+//                        {
+//                            if([appDelegate.order_code isEqualToString: [self.content_data[indexPath.row] valueForKey:@"order_code"]])
+//                            {
+//                                appDelegate.order_code= nil;
+//                                //appDelegate.user_type = 0;
+//                                appDelegate.customerInfo = nil;
+//                                appDelegate.contact_id = nil;
+//                                appDelegate.order_customer_id = nil;
+//                                [appDelegate SetSo:nil];
+//                                appDelegate.cart_count=0;
+//                                [appDelegate update_count_mark];
+//
+//
+//                            }
+//                            [RAUtils message_alert:nil title:@"Order Canceled" controller:self] ;
+//                            [self ReloadData];
+//                        }
+//                        else
+//                        {
+//                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Cancel Order" controller:self] ;
+//                        }
+//
+//
+//
+//
+//                    });
+//                });
                 
                 
             }];

+ 101 - 47
RedAnt ERP Mobile/common/Functions/order/RAOrderEditorViewController.m

@@ -197,49 +197,90 @@ static const int totalPage = 3;
                      
                      AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                      UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
-                     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+             [RANetwork request_release_order:appDelegate.order_code withScreen:nil completionHandler:^(NSMutableDictionary *result) {
+                 NSDictionary* order_json = result;
+             //                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+                 [waitalert dismissViewControllerAnimated:YES completion:^{
+                     if([[order_json valueForKey:@"result"] intValue]==2)
+                     {
+                         AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                          
-                         NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:nil];
+                         [appDelegate closeOrder];
                          
-                         dispatch_async(dispatch_get_main_queue(), ^{
-         //                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                             [waitalert dismissViewControllerAnimated:YES completion:nil];
-                             
-                             if([[order_json valueForKey:@"result"] intValue]==2)
-                             {
-                                 AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                         
+                         //#ifdef RA_NOTIFICATION
+                         //                        [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                         //#else
+                         //                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                         //#endif
+                         [((MainViewController*)appDelegate.main_vc) switchToHome];
+                         
+                         if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
+                         {
+                             [((MainViewController*)appDelegate.main_vc) Loginout:false];
+                         }
+                         
+                         [self prepareReturn:nil];
+                         
+                         
+                         [self.navigationController popViewControllerAnimated:true];
+                         
+                         
+                     }
+                     else
+                     {
+                         [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
+                     }
+                 }];
                                  
-                                 [appDelegate closeOrder];
 
                                  
-         //#ifdef RA_NOTIFICATION
-         //                        [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-         //#else
-         //                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-         //#endif
-                                 [((MainViewController*)appDelegate.main_vc) switchToHome];
-                                 
-                                 if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
-                                 {
-                                     [((MainViewController*)appDelegate.main_vc) Loginout:false];
-                                 }
-                                 
-                                 [self prepareReturn:nil];
                                  
                                  
-                                 [self.navigationController popViewControllerAnimated:true];
-
-                                 
-                             }
-                             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 release_Order:appDelegate.order_code withScreen:nil];
+//
+//                         dispatch_async(dispatch_get_main_queue(), ^{
+//         //                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+//                             [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//                             if([[order_json valueForKey:@"result"] intValue]==2)
+//                             {
+//                                 AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//
+//                                 [appDelegate closeOrder];
+//
+//
+//         //#ifdef RA_NOTIFICATION
+//         //                        [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//         //#else
+//         //                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//         //#endif
+//                                 [((MainViewController*)appDelegate.main_vc) switchToHome];
+//
+//                                 if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
+//                                 {
+//                                     [((MainViewController*)appDelegate.main_vc) Loginout:false];
+//                                 }
+//
+//                                 [self prepareReturn:nil];
+//
+//
+//                                 [self.navigationController popViewControllerAnimated:true];
+//
+//
+//                             }
+//                             else
+//                             {
+//                                 [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
+//                             }
+//
+//
+//
+//                         });
+//                     });
                      
                      
                  }];
@@ -1026,18 +1067,31 @@ static const int totalPage = 3;
 //}
 
 - (void)releaseOrderAfterSave {
-    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    
-    [RANetwork release_Order:appDelegate.order_code withScreen:nil];
     
-    [appDelegate closeOrder];
-    [appDelegate SetSo:nil];
-    appDelegate.cart_count=0;
-    [appDelegate update_count_mark];
-    [((MainViewController*)appDelegate.main_vc) switchToOrder];
-    
-    [self prepareReturn:nil];
-    [self.navigationController popToRootViewControllerAnimated:false];
+    dispatch_async(dispatch_get_main_queue(), ^{
+            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+        [RANetwork request_release_order:appDelegate.order_code withScreen:nil completionHandler:nil];
+        [appDelegate closeOrder];
+        [appDelegate SetSo:nil];
+        appDelegate.cart_count=0;
+        [appDelegate update_count_mark];
+        [((MainViewController*)appDelegate.main_vc) switchToOrder];
+        
+        [self prepareReturn:nil];
+        [self.navigationController popToRootViewControllerAnimated:false];
+    });
+
+//
+//    [RANetwork release_Order:appDelegate.order_code withScreen:nil];
+//
+//    [appDelegate closeOrder];
+//    [appDelegate SetSo:nil];
+//    appDelegate.cart_count=0;
+//    [appDelegate update_count_mark];
+//    [((MainViewController*)appDelegate.main_vc) switchToOrder];
+//
+//    [self prepareReturn:nil];
+//    [self.navigationController popToRootViewControllerAnimated:false];
     
 }
 

+ 366 - 179
RedAnt ERP Mobile/common/Functions/order/RAOrderPreviewController.m

@@ -1755,50 +1755,92 @@
                  
                  AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                  UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
-                 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+         [RANetwork request_release_order:appDelegate.order_code withScreen:nil completionHandler:^(NSMutableDictionary *result) {
+             NSDictionary* order_json = result;
+             [waitalert dismissViewControllerAnimated:YES completion:^{
+                 if([[order_json valueForKey:@"result"] intValue]==2)
+                 {
+                     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                     //                        appDelegate.order_code = nil;
                      
-                     NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:nil];
+                     [appDelegate closeOrder];
                      
-                     dispatch_async(dispatch_get_main_queue(), ^{
-                         [waitalert dismissViewControllerAnimated:YES completion:nil];
-                         if([[order_json valueForKey:@"result"] intValue]==2)
-                         {
-                             AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                             //                        appDelegate.order_code = nil;
-                             
-                             [appDelegate closeOrder];
-                             
-                             
-     #ifdef RA_NOTIFICATION
-                             [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-     #else
-                             [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-     #endif
-                             [((MainViewController*)appDelegate.main_vc) switchToHome];
-                             
-                             if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
-                             {
-                                 [((MainViewController*)appDelegate.main_vc) Loginout:false];
-                             }
-                             
-                             [self prepareReturn:nil];
-                             
-                             
-                             [self.navigationController popToRootViewControllerAnimated:true];
-                             //                        [self.navigationController dismissViewControllerAnimated:true completion:^{
-                             //                            ;
-                             //                        }];
-                             
-                         }
-                         else
-                         {
-                             [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
-                         }
-                         
-                         
-                         
-                     });
-                 });
+                     
+#ifdef RA_NOTIFICATION
+                     [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                     [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+#endif
+                     [((MainViewController*)appDelegate.main_vc) switchToHome];
+                     
+                     if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
+                     {
+                         [((MainViewController*)appDelegate.main_vc) Loginout:false];
+                     }
+                     
+                     [self prepareReturn:nil];
+                     
+                     
+                     [self.navigationController popToRootViewControllerAnimated:true];
+                     //                        [self.navigationController dismissViewControllerAnimated:true completion:^{
+                     //                            ;
+                     //                        }];
+                     
+                 }
+                 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 release_Order:appDelegate.order_code withScreen:nil];
+//
+//                     dispatch_async(dispatch_get_main_queue(), ^{
+//                         [waitalert dismissViewControllerAnimated:YES completion:nil];
+//                         if([[order_json valueForKey:@"result"] intValue]==2)
+//                         {
+//                             AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                             //                        appDelegate.order_code = nil;
+//
+//                             [appDelegate closeOrder];
+//
+//
+//     #ifdef RA_NOTIFICATION
+//                             [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//     #else
+//                             [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//     #endif
+//                             [((MainViewController*)appDelegate.main_vc) switchToHome];
+//
+//                             if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
+//                             {
+//                                 [((MainViewController*)appDelegate.main_vc) Loginout:false];
+//                             }
+//
+//                             [self prepareReturn:nil];
+//
+//
+//                             [self.navigationController popToRootViewControllerAnimated:true];
+//                             //                        [self.navigationController dismissViewControllerAnimated:true completion:^{
+//                             //                            ;
+//                             //                        }];
+//
+//                         }
+//                         else
+//                         {
+//                             [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
+//                         }
+//
+//
+//
+//                     });
+//                 });
 
              }];
      UIAlertAction *action_4 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
@@ -1872,78 +1914,80 @@
     [RANetwork request_save_order:upparams completionHandler:^(NSMutableDictionary *result) {
         NSDictionary* editor_json =result;
         
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        //            [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-        
-        if([[editor_json valueForKey:@"result"] intValue]==2)
-        {
-            
-            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-            
-            
-            
-            NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-            
-            
-            if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
-            {
-                appDelegate.customerInfo = customerInfo;
-                appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
-            }
-            NSString *msg = nil;
-            if ([editor_json objectForKey:@"so#"]) {
-                msg = [@"SO#:" stringByAppendingString:[editor_json objectForKey:@"so#"]];
-            }
-            [RAUtils message_alert:msg title:@"Order Saved" controller:self] ;
-            
-            if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            if([[editor_json valueForKey:@"result"] intValue]==2)
             {
-                [((MainViewController*)appDelegate.main_vc) Loginout:false];
-                [self prepareReturn:nil];
-                [self.navigationController popToRootViewControllerAnimated:true];
-            }
-            else{
+                
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                 
                 
+                
+                NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
+                
+                
+                if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+                {
+                    appDelegate.customerInfo = customerInfo;
+                    appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
+                }
+                NSString *msg = nil;
+                if ([editor_json objectForKey:@"so#"]) {
+                    msg = [@"SO#:" stringByAppendingString:[editor_json objectForKey:@"so#"]];
+                }
+                [RAUtils message_alert:msg title:@"Order Saved" controller:self] ;
+                
+                if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+                {
+                    [((MainViewController*)appDelegate.main_vc) Loginout:false];
+                    [self prepareReturn:nil];
+                    [self.navigationController popToRootViewControllerAnimated:true];
+                }
+                else{
+                    
+                    
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                    
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-            }
-            
-            if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
+                }
                 
-                if (![Singleton sharedInstance].currentOrderIsMerged) {
-                    [self releaseOrderAfterSave];
+                if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
+                    
+                    if (![Singleton sharedInstance].currentOrderIsMerged) {
+                        [self releaseOrderAfterSave];
+                    }
+                    
+                    
                 }
                 
                 
+                //                if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
+                //                    appDelegate.order_code = nil;
+                //
+                //                }
+                //    //     self.labelContact.text=appDelegate.contact_name;
+                //
+                //    NSDictionary * customerinfo = appDelegate.customerInfo;
+                // [self prepareReturn:nil];
+                //                [self.navigationController dismissViewControllerAnimated:true completion:^{
+                //
+                //
+                //                    ;
+                //                }];
+                
             }
-            
-            
-            //                if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
-            //                    appDelegate.order_code = nil;
-            //
-            //                }
-            //    //     self.labelContact.text=appDelegate.contact_name;
-            //
-            //    NSDictionary * customerinfo = appDelegate.customerInfo;
-            // [self prepareReturn:nil];
-            //                [self.navigationController dismissViewControllerAnimated:true completion:^{
-            //
-            //
-            //                    ;
-            //                }];
-            
-        }
-        else
-        {
-            [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
-        }
+            else
+            {
+                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
+            }
+        }];
+        //            [waitalert dismissViewControllerAnimated:YES completion:nil];
+        
+        
+        
         
         
         
@@ -2249,18 +2293,30 @@
 //}
 
 - (void)releaseOrderAfterSave {
-    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    
-    [RANetwork release_Order:appDelegate.order_code withScreen:nil];
     
-    [appDelegate closeOrder];
-    [appDelegate SetSo:nil];
-    appDelegate.cart_count=0;
-    [appDelegate update_count_mark];
-    [((MainViewController*)appDelegate.main_vc) switchToOrder];
+    dispatch_async(dispatch_get_main_queue(), ^{
+        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+        
+        [RANetwork request_release_order:appDelegate.order_code withScreen:nil completionHandler:nil];
+        [appDelegate closeOrder];
+        [appDelegate SetSo:nil];
+        appDelegate.cart_count=0;
+        [appDelegate update_count_mark];
+        [((MainViewController*)appDelegate.main_vc) switchToOrder];
+        
+        [self prepareReturn:nil];
+        [self.navigationController popToRootViewControllerAnimated:false];
+    });
+//    [RANetwork release_Order:appDelegate.order_code withScreen:nil];
     
-    [self prepareReturn:nil];
-    [self.navigationController popToRootViewControllerAnimated:false];
+//    [appDelegate closeOrder];
+//    [appDelegate SetSo:nil];
+//    appDelegate.cart_count=0;
+//    [appDelegate update_count_mark];
+//    [((MainViewController*)appDelegate.main_vc) switchToOrder];
+//
+//    [self prepareReturn:nil];
+//    [self.navigationController popToRootViewControllerAnimated:false];
     
 }
 
@@ -2879,76 +2935,125 @@
             upparams[@"shipping"] = nil;
     
         [upparams setValue:@"true" forKey:@"isHold"];
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-            
-            NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
-            
-            dispatch_async(dispatch_get_main_queue(), ^{
+    
+    [RANetwork request_commit_order:upparams completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* editor_json =result;
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            if([[editor_json valueForKey:@"result"] intValue]==2)
+            {
                 
-                [waitalert dismissViewControllerAnimated:YES completion:nil];
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                // appDelegate.customerInfo = customerInfo;
+                
+                [appDelegate closeOrder];
                 
-                if([[editor_json valueForKey:@"result"] intValue]==2)
-                {
-                    
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    // appDelegate.customerInfo = customerInfo;
-
-                    [appDelegate closeOrder];
-                    
 #ifdef RA_NOTIFICATION
-                    [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-                    
+                [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                
 #else
-                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-
-                    
-                    
-                    NSString* title=nil;
-                    NSString* msg=nil;
+                
+                
+                
+                NSString* title=nil;
+                NSString* msg=nil;
 #ifdef OFFLINE_MODE
-                    if(appDelegate.offline_mode)
-                    {
-                        title=TITLE_OFFLINE_SUBMIT;
-                        msg=MSG_OFFLINE_SUBMIT;
-                    }
-                    else
-#endif
-                    {
-                        title=@"Order submitted sucessfully";
-                        msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
-                    }
-                    
-//                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-//
-//                    [alert show];
-                    [self back_order_submit_alert:editor_json];
-                    
-                    [self prepareReturn:nil];
-                    [self.navigationController popToRootViewControllerAnimated:true];
-
-                    
+                if(appDelegate.offline_mode)
+                {
+                    title=TITLE_OFFLINE_SUBMIT;
+                    msg=MSG_OFFLINE_SUBMIT;
                 }
                 else
+#endif
                 {
-                    [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
+                    title=@"Order submitted sucessfully";
+                    msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
                 }
-            });
-        });
+                
+                //                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+                //
+                //                    [alert show];
+                [self back_order_submit_alert:editor_json];
+                
+                [self prepareReturn:nil];
+                [self.navigationController popToRootViewControllerAnimated:true];
+                
+                
+            }
+            else
+            {
+                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
+            }
+        }];
+                    
+                    
+                }];
+//        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//            NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
+//
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//
+//                [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//                if([[editor_json valueForKey:@"result"] intValue]==2)
+//                {
+//
+//                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                    // appDelegate.customerInfo = customerInfo;
+//
+//                    [appDelegate closeOrder];
+//
+//#ifdef RA_NOTIFICATION
+//                    [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//
+//#else
+//                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//
+//
+//
+//                    NSString* title=nil;
+//                    NSString* msg=nil;
+//#ifdef OFFLINE_MODE
+//                    if(appDelegate.offline_mode)
+//                    {
+//                        title=TITLE_OFFLINE_SUBMIT;
+//                        msg=MSG_OFFLINE_SUBMIT;
+//                    }
+//                    else
+//#endif
+//                    {
+//                        title=@"Order submitted sucessfully";
+//                        msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
+//                    }
+//
+////                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+////
+////                    [alert show];
+//                    [self back_order_submit_alert:editor_json];
+//
+//                    [self prepareReturn:nil];
+//                    [self.navigationController popToRootViewControllerAnimated:true];
+//
+//
+//                }
+//                else
+//                {
+//                    [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
+//                }
+//            });
+//        });
 }
 
 - (void)empolyee_commit_order:(NSMutableDictionary *)upparams {
     
     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Order Submission"];
     [upparams setValue:@"false" forKey:@"isHold"];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
-            
+    [RANetwork request_commit_order:upparams completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* editor_json = result;
+        [waitalert dismissViewControllerAnimated:YES completion:^{
             if([[editor_json valueForKey:@"result"] intValue]==2)
             {
                 
@@ -2956,9 +3061,9 @@
                 AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                 NSString* company= appDelegate.customerInfo[@"customer_name"];
                 NSString* send_to =appDelegate.customerInfo[@"customer_email"];
-
+                
                 [appDelegate closeOrder];
-
+                
 #ifdef RA_NOTIFICATION
                 [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
                 
@@ -2981,14 +3086,14 @@
                     msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
                 }
                 
-//                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-//
-//                [alert show];
+                //                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+                //
+                //                [alert show];
                 UIViewController *alert = [self back_order_submit_alert:editor_json];
                 
                 NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
                 NSString* email_content =[editor_json valueForKey:@"email_content"];
-//                NSString* soid=[editor_json valueForKey:@"so#"];
+                //                NSString* soid=[editor_json valueForKey:@"so#"];
                 {
                     NSMutableDictionary *value = [NSMutableDictionary dictionary];
                     if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
@@ -3004,10 +3109,12 @@
                     if(pdf_url.length>0)
                     {
                         
-//                        [alert dismissWithClickedButtonIndex:0 animated:FALSE];
-                        [alert dismissViewControllerAnimated:YES completion:nil];
-                        NSString *pdf_title = [editor_json objectForKey:@"title"];
-                        [appDelegate printPdf:pdf_url company:company send_to:send_to soid:pdf_title content:email_content];
+                        //                        [alert dismissWithClickedButtonIndex:0 animated:FALSE];
+                        [alert dismissViewControllerAnimated:YES completion:^{
+                            NSString *pdf_title = [editor_json objectForKey:@"title"];
+                            [appDelegate printPdf:pdf_url company:company send_to:send_to soid:pdf_title content:email_content];
+                        }];
+
                     }
                 }
                 
@@ -3016,8 +3123,88 @@
             {
                 [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
             }
-        });
-    });
+        }];
+        
+        
+        
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            [waitalert dismissViewControllerAnimated:YES completion:nil];
+//
+//
+//            if([[editor_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//                // debug aaa
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                NSString* company= appDelegate.customerInfo[@"customer_name"];
+//                NSString* send_to =appDelegate.customerInfo[@"customer_email"];
+//
+//                [appDelegate closeOrder];
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//
+//#else
+//                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//#endif
+//
+//                NSString* title=nil;
+//                NSString* msg=nil;
+//#ifdef OFFLINE_MODE
+//                if(appDelegate.offline_mode)
+//                {
+//                    title=TITLE_OFFLINE_SUBMIT;
+//                    msg=MSG_OFFLINE_SUBMIT;
+//                }
+//                else
+//#endif
+//                {
+//                    title=@"Order submitted sucessfully";
+//                    msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
+//                }
+//
+////                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+////
+////                [alert show];
+//                UIViewController *alert = [self back_order_submit_alert:editor_json];
+//
+//                NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
+//                NSString* email_content =[editor_json valueForKey:@"email_content"];
+////                NSString* soid=[editor_json valueForKey:@"so#"];
+//                {
+//                    NSMutableDictionary *value = [NSMutableDictionary dictionary];
+//                    if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
+//                    {
+//                        //bbb
+//                        [((MainViewController*)appDelegate.main_vc) Loginout:false];
+//                        value[@"commitorder_logout"]=@"true";
+//                    }
+//                    [self prepareReturn:value];
+//
+//                    [self.navigationController popToRootViewControllerAnimated:true];
+//
+//                    if(pdf_url.length>0)
+//                    {
+//
+////                        [alert dismissWithClickedButtonIndex:0 animated:FALSE];
+//                        [alert dismissViewControllerAnimated:YES completion:nil];
+//                        NSString *pdf_title = [editor_json objectForKey:@"title"];
+//                        [appDelegate printPdf:pdf_url company:company send_to:send_to soid:pdf_title content:email_content];
+//                    }
+//                }
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
+//            }
+//        });
+//    });
 }
 
 - (UIViewController *)back_order_submit_alert:(NSDictionary *)result_json {

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

@@ -251,54 +251,97 @@
     self.btnCreatePort.enabled = false;
     
     
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        NSDictionary* return_json = [RANetwork add_toCart:ids count:-1 name:nil];
+    [RANetwork request_addto_cart:ids count:-1 name:nil completionHandler:^(NSMutableDictionary *result) {
+        NSDictionary* return_json = result;
+        self.btnCreatePort.enabled = true;
         
-        dispatch_async(dispatch_get_main_queue(), ^{
+        if([[return_json valueForKey:@"result"] intValue]==2)
+        {
             
-            self.btnCreatePort.enabled = true;
             
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-
-                
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+            [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-             
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false ];
+            
+            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+            [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false ];
 #endif
-                NSString * msg = nil;
-                if(checked.count==1)
-                {
-                    msg=@"1 item added to Cart";
-                }
-                else
-                {
-                    msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
-                }
-                
-                    [RAUtils message_alert:nil title:msg controller:self] ;
-                    
-                    //                    [self end_select];
-                    
-                    
-                    
-//                }
+            NSString * msg = nil;
+            if(checked.count==1)
+            {
+                msg=@"1 item added to Cart";
             }
             else
             {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
             }
             
+            [RAUtils message_alert:nil title:msg controller:self] ;
             
+            //                    [self end_select];
             
             
-        });
-    });
+            
+            //                }
+        }
+        else
+        {
+            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+        }
+        
+        
+        
+        
+    }];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//        NSDictionary* return_json = [RANetwork add_toCart:ids count:-1 name:nil];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//
+//            self.btnCreatePort.enabled = true;
+//
+//            if([[return_json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//
+//#ifdef RA_NOTIFICATION
+//                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
+//
+//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false ];
+//#endif
+//                NSString * msg = nil;
+//                if(checked.count==1)
+//                {
+//                    msg=@"1 item added to Cart";
+//                }
+//                else
+//                {
+//                    msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
+//                }
+//
+//                    [RAUtils message_alert:nil title:msg controller:self] ;
+//
+//                    //                    [self end_select];
+//
+//
+//
+////                }
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+//            }
+//
+//
+//
+//
+//        });
+//    });
 }
 -(void) neworder
 {
@@ -308,46 +351,48 @@
         NSMutableDictionary* return_json = result;
         
 //        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-        
-        if([[return_json valueForKey:@"result"] intValue]==2)
-        {
-            int result=[[return_json valueForKey:@"result"] intValue];
-            if(result==2)
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            
+            if([[return_json valueForKey:@"result"] intValue]==2)
             {
-                //successed.
-                
-                NSString* order_code = [return_json valueForKey:@"orderCode"];
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                appDelegate.order_code = order_code;
-                
-                
-                [self addtocart];
-                
-                
-                //    [self ReloadData];
-                
-                
-                //                    if(self.shopCartBlock!=nil)
-                //                    {
-                //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                //
-                //
-                //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                //                        iv.image = img;
-                //                        //                        [self.contentView addSubview:iv];
-                //                        self.shopCartBlock(iv);
-                //
-                //                    }
-                
+                int result=[[return_json valueForKey:@"result"] intValue];
+                if(result==2)
+                {
+                    //successed.
+                    
+                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    appDelegate.order_code = order_code;
+                    
+                    
+                    [self addtocart];
+                    
+                    
+                    //    [self ReloadData];
+                    
+                    
+                    //                    if(self.shopCartBlock!=nil)
+                    //                    {
+                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                    //
+                    //
+                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                    //                        iv.image = img;
+                    //                        //                        [self.contentView addSubview:iv];
+                    //                        self.shopCartBlock(iv);
+                    //
+                    //                    }
+                    
+                }
             }
-        }
-        else
-        {
-            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-        }
+            else
+            {
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+            }
+        }];
+        
+        
         
         
         
@@ -626,165 +671,170 @@
     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Processing"];
     [RANetwork request_portfoliopreview:params completionHandler:^(NSMutableDictionary *result) {
         NSDictionary* editor_json = result;
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-        
-        if([[editor_json valueForKey:@"result"] intValue]==2)
-        {
-            
-            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-            
-            NSString* url = [editor_json valueForKey:@"pdf_path"];
-            NSString* path = [editor_json valueForKey:@"pdf_real_path"];
-            bool isLocalFile = [[editor_json valueForKey:@"isLocalFile"] boolValue];
-            RAPDFViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
-            ViewController.url = url;
-            ViewController.canSave = true;
-            ViewController.isLocalfile=isLocalFile;
-            
-            ViewController.filename = [NSString stringWithFormat:@"%@.pdf",[TextUtils legalFilename:catelog_name]];
-            ViewController.save_name =catelog_name;
-            ViewController.save_note =internal_note;
-            
-            NSString* company=    [appDelegate.customerInfo valueForKey:@"customer_name"];
-            
-            if(company==nil)
-                company=@"";
-            
-            NSString* customer_email=    [appDelegate.customerInfo valueForKey:@"customer_email"];
-            
-            
-            NSMutableArray* send_to = [[NSMutableArray alloc]init];
-            if(customer_email.length>0)
-            {
-                send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
-            }
-            ViewController.mail_to = send_to;
-            
-            NSString* subject;
-            
-            subject =catelog_name;
-            
-            ViewController.mail_subject = subject;
-            
-            ViewController.onSavePDF=^(NSString* name,NSString* file)
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            if([[editor_json valueForKey:@"result"] intValue]==2)
             {
                 
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                 
-                NSString* del_ids = nil;
+                NSString* url = [editor_json valueForKey:@"pdf_path"];
+                NSString* path = [editor_json valueForKey:@"pdf_real_path"];
+                bool isLocalFile = [[editor_json valueForKey:@"isLocalFile"] boolValue];
+                RAPDFViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
+                ViewController.url = url;
+                ViewController.canSave = true;
+                ViewController.isLocalfile=isLocalFile;
                 
-                UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Saving..."];
-#ifdef OFFLINE_MODE
-                if (appDelegate.offline_mode)
-                {
-                    [params setValue:url forKey:@"pdfPath"];
-                }
-                else
-#endif
+                ViewController.filename = [NSString stringWithFormat:@"%@.pdf",[TextUtils legalFilename:catelog_name]];
+                ViewController.save_name =catelog_name;
+                ViewController.save_note =internal_note;
+                
+                NSString* company=    [appDelegate.customerInfo valueForKey:@"customer_name"];
+                
+                if(company==nil)
+                    company=@"";
+                
+                NSString* customer_email=    [appDelegate.customerInfo valueForKey:@"customer_email"];
+                
+                
+                NSMutableArray* send_to = [[NSMutableArray alloc]init];
+                if(customer_email.length>0)
                 {
-                    [params setValue:path forKey:@"pdfPath"];
+                    send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
                 }
-                [params setValue:name forKey:@"pdfName"];
-                [params setValue:internal_note forKey:@"pdfNote"];
-                [params setValue:del_ids forKey:@"itemIds"];
-                [params setValue:pdf_url forKey:@"configureParams"];
+                ViewController.mail_to = send_to;
+                
+                NSString* subject;
                 
-                [RANetwork request_save_portfolio:params completionHandler:^(NSMutableDictionary *result) {
-                    NSDictionary* json =result;
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+                subject =catelog_name;
+                
+                ViewController.mail_subject = subject;
+                
+                ViewController.onSavePDF=^(NSString* name,NSString* file)
+                {
                     
                     
-                    if([[json valueForKey:@"result"] intValue]==2)
+                    NSString* del_ids = nil;
+                    
+                    UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Saving..."];
+#ifdef OFFLINE_MODE
+                    if (appDelegate.offline_mode)
                     {
-                        
-                        [RAUtils message_alert:@"Portfolio saved. You can find it from View Portfolios" title:@"Portfolio" controller:self];
-                        
-                        //                                [RAUtils alert_view:nil title:@"Portfolio saved. You can find it from View Portfolios" ] ;
-                        
-                        [self.navigationController dismissViewControllerAnimated:true completion:^{
-                            
-                            
-                            
-#ifdef RA_NOTIFICATION
-                            [ActiveViewController Notify:@"PortfolioViewController,PDFListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-#else
-                            [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:true];
-                            [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
-#endif
-                        }];
+                        [params setValue:url forKey:@"pdfPath"];
                     }
                     else
+#endif
                     {
-                        [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Save Portfolio" controller:self] ;
+                        [params setValue:path forKey:@"pdfPath"];
                     }
+                    [params setValue:name forKey:@"pdfName"];
+                    [params setValue:internal_note forKey:@"pdfNote"];
+                    [params setValue:del_ids forKey:@"itemIds"];
+                    [params setValue:pdf_url forKey:@"configureParams"];
                     
-                }];
-                
-                //                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                //
-                //
-                //#ifdef OFFLINE_MODE
-                //                        if (appDelegate.offline_mode)
-                //                        {
-                //                            [params setValue:url forKey:@"pdfPath"];
-                //                        }
-                //                        else
-                //#endif
-                //                        {
-                //                            [params setValue:path forKey:@"pdfPath"];
-                //                        }
-                //                        [params setValue:name forKey:@"pdfName"];
-                //                        [params setValue:internal_note forKey:@"pdfNote"];
-                //                        [params setValue:del_ids forKey:@"itemIds"];
-                //                        [params setValue:pdf_url forKey:@"configureParams"];
-                //
-                //
-                //
-                //                        NSDictionary* json = [RANetwork save_TearSheet:params];
-                //
-                //                        dispatch_async(dispatch_get_main_queue(), ^{
-                //                            [waitalert dismissViewControllerAnimated:YES completion:nil];
-                //
-                //
-                //                            if([[json valueForKey:@"result"] intValue]==2)
-                //                            {
-                //
-                //                                [RAUtils message_alert:@"Portfolio saved. You can find it from View Portfolios" title:@"Portfolio" controller:self];
-                //
-                ////                                [RAUtils alert_view:nil title:@"Portfolio saved. You can find it from View Portfolios" ] ;
-                //
-                //                                [self.navigationController dismissViewControllerAnimated:true completion:^{
-                //
-                //
-                //
-                //#ifdef RA_NOTIFICATION
-                //                                    [ActiveViewController Notify:@"PortfolioViewController,PDFListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-                //#else
-                //                                    [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:true];
-                //                                    [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
-                //#endif
-                //                                }];
-                //                            }
-                //                            else
-                //                            {
-                //                                [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Save Portfolio" controller:self] ;
-                //                            }
-                //
-                //                        });
-                //                    });
-                
+                    [RANetwork request_save_portfolio:params completionHandler:^(NSMutableDictionary *result) {
+                        NSDictionary* json =result;
+                        [waitalert dismissViewControllerAnimated:YES completion:^{
+                            if([[json valueForKey:@"result"] intValue]==2)
+                            {
+                                
+                                [RAUtils message_alert:@"Portfolio saved. You can find it from View Portfolios" title:@"Portfolio" controller:self];
+                                
+                                //                                [RAUtils alert_view:nil title:@"Portfolio saved. You can find it from View Portfolios" ] ;
+                                
+                                [self.navigationController dismissViewControllerAnimated:true completion:^{
+                                    
+                                    
+                                    
+#ifdef RA_NOTIFICATION
+                                    [ActiveViewController Notify:@"PortfolioViewController,PDFListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                                    [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:true];
+                                    [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
+#endif
+                                }];
+                            }
+                            else
+                            {
+                                [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Save Portfolio" controller:self] ;
+                            }
+                        }];
+                        
+                        
+                        
+                        
+                    }];
+                    
+                    //                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                    //
+                    //
+                    //#ifdef OFFLINE_MODE
+                    //                        if (appDelegate.offline_mode)
+                    //                        {
+                    //                            [params setValue:url forKey:@"pdfPath"];
+                    //                        }
+                    //                        else
+                    //#endif
+                    //                        {
+                    //                            [params setValue:path forKey:@"pdfPath"];
+                    //                        }
+                    //                        [params setValue:name forKey:@"pdfName"];
+                    //                        [params setValue:internal_note forKey:@"pdfNote"];
+                    //                        [params setValue:del_ids forKey:@"itemIds"];
+                    //                        [params setValue:pdf_url forKey:@"configureParams"];
+                    //
+                    //
+                    //
+                    //                        NSDictionary* json = [RANetwork save_TearSheet:params];
+                    //
+                    //                        dispatch_async(dispatch_get_main_queue(), ^{
+                    //                            [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    //
+                    //
+                    //                            if([[json valueForKey:@"result"] intValue]==2)
+                    //                            {
+                    //
+                    //                                [RAUtils message_alert:@"Portfolio saved. You can find it from View Portfolios" title:@"Portfolio" controller:self];
+                    //
+                    ////                                [RAUtils alert_view:nil title:@"Portfolio saved. You can find it from View Portfolios" ] ;
+                    //
+                    //                                [self.navigationController dismissViewControllerAnimated:true completion:^{
+                    //
+                    //
+                    //
+                    //#ifdef RA_NOTIFICATION
+                    //                                    [ActiveViewController Notify:@"PortfolioViewController,PDFListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    //#else
+                    //                                    [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:true];
+                    //                                    [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
+                    //#endif
+                    //                                }];
+                    //                            }
+                    //                            else
+                    //                            {
+                    //                                [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Save Portfolio" controller:self] ;
+                    //                            }
+                    //
+                    //                        });
+                    //                    });
+                    
+                    
+                    
+                };
                 
+                ViewController.hidenavi = false;
+                [self.navigationController pushViewController:ViewController animated:YES];
                 
-            };
-            
-            ViewController.hidenavi = false;
-            [self.navigationController pushViewController:ViewController animated:YES];
-            
-        }
-        else
-        {
-            [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Create Portfolio" controller:self] ;
-        }
+            }
+            else
+            {
+                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Create Portfolio" controller:self] ;
+            }
+        }];
+        
+        
+
+
         
     }];
     
@@ -1127,63 +1177,66 @@
                 
                 [RANetwork request_update_portfolio_price:[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]] price:price discount:discount QTY:qty  qty_p:qty_p notes:notes completionHandler:^(NSMutableDictionary *result) {
                     NSDictionary* cart_json = result;
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    
-                    
-                    if([[cart_json valueForKey:@"result"] intValue]==2)
-                    {
-                        //                            if(qty>=0)
-                        //                                item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
-                        //                            else
-                        //                                [item_json removeObjectForKey:@"available_qty"];
-                        //                            if(qty_p>=0)
-                        //                                item_json[@"available_percent"]=[NSNumber numberWithInt:qty_p];
-                        //                            else
-                        //                                [item_json removeObjectForKey:@"available_percent"];
-                        //                            item_json[@"linenotes"]=notes;
-                        //                            item_json[@"tear_sheet_discount"]=[NSString stringWithFormat:@"%.2f",discount];
-                        //                            item_json[@"tear_sheet_price"]=[NSString stringWithFormat:@"%.2f",price];
-                        //                            self.content_data[[NSString stringWithFormat:@"item_%d",single_idx]]=item_json;
-                        //                            // item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
-                        //                            [self.itemListTable reloadData];
-                        
-                        
-                        if (!(qty == -INT32_MAX && qty_p == -MAXFLOAT)) {
-                            // qty
-                            if (qty != -INT32_MAX)
-                                item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
-                            else
-                                [item_json removeObjectForKey:@"available_qty"];
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
+                        if([[cart_json valueForKey:@"result"] intValue]==2)
+                        {
+                            //                            if(qty>=0)
+                            //                                item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
+                            //                            else
+                            //                                [item_json removeObjectForKey:@"available_qty"];
+                            //                            if(qty_p>=0)
+                            //                                item_json[@"available_percent"]=[NSNumber numberWithInt:qty_p];
+                            //                            else
+                            //                                [item_json removeObjectForKey:@"available_percent"];
+                            //                            item_json[@"linenotes"]=notes;
+                            //                            item_json[@"tear_sheet_discount"]=[NSString stringWithFormat:@"%.2f",discount];
+                            //                            item_json[@"tear_sheet_price"]=[NSString stringWithFormat:@"%.2f",price];
+                            //                            self.content_data[[NSString stringWithFormat:@"item_%d",single_idx]]=item_json;
+                            //                            // item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
+                            //                            [self.itemListTable reloadData];
+                            
+                            
+                            if (!(qty == -INT32_MAX && qty_p == -MAXFLOAT)) {
+                                // qty
+                                if (qty != -INT32_MAX)
+                                    item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
+                                else
+                                    [item_json removeObjectForKey:@"available_qty"];
+                                
+                                // qty_p
+                                if (qty_p != -MAXFLOAT)
+                                    item_json[@"available_percent"]=[NSNumber numberWithInt:qty_p];
+                                else
+                                    [item_json removeObjectForKey:@"available_percent"];
+                            }
+                            
+                            if (notes) {
+                                item_json[@"linenotes"]=notes;
+                            }
+                            
+                            if (discount != -MAXFLOAT) {
+                                item_json[@"tear_sheet_discount"]=[NSString stringWithFormat:@"%.2f",discount];
+                            }
+                            
+                            if (price != -MAXFLOAT) {
+                                item_json[@"tear_sheet_price"]=[NSString stringWithFormat:@"%.2f",price];
+                            }
+                            
+                            self.content_data[[NSString stringWithFormat:@"item_%d",single_idx]]=item_json;
+                            // item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
+                            
+                            [self.itemListTable reloadData];
                             
-                            // qty_p
-                            if (qty_p != -MAXFLOAT)
-                                item_json[@"available_percent"]=[NSNumber numberWithInt:qty_p];
-                            else
-                                [item_json removeObjectForKey:@"available_percent"];
-                        }
-                        
-                        if (notes) {
-                            item_json[@"linenotes"]=notes;
-                        }
-                        
-                        if (discount != -MAXFLOAT) {
-                            item_json[@"tear_sheet_discount"]=[NSString stringWithFormat:@"%.2f",discount];
                         }
-                        
-                        if (price != -MAXFLOAT) {
-                            item_json[@"tear_sheet_price"]=[NSString stringWithFormat:@"%.2f",price];
+                        else
+                        {
+                            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Edit Portfolio" controller:self] ;
                         }
-                        
-                        self.content_data[[NSString stringWithFormat:@"item_%d",single_idx]]=item_json;
-                        // item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
-                        
-                        [self.itemListTable reloadData];
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Edit Portfolio" controller:self] ;
-                    }
+                    }];
+                    
+                    
+                    
+
                     
                     
                     
@@ -1331,18 +1384,20 @@
             UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Updating Quantity"];
             [RANetwork request_update_portfolio_price:ids price:price discount:discount QTY:qty qty_p:qty_p notes:notes completionHandler:^(NSMutableDictionary *result) {
                 NSDictionary* cart_json = result;
-                [waitalert dismissViewControllerAnimated:YES completion:nil];
+                [waitalert dismissViewControllerAnimated:YES completion:^{
+                    if([[cart_json valueForKey:@"result"] intValue]==2)
+                    {
+                        [RAUtils message_alert:[NSString stringWithFormat:@"%ld items saved.",checked.count] title:@"Edit Portfolio" controller:self] ;
+                        [self reload_data];
+                    }
+                    else
+                    {
+                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Edit Portfolio" controller:self] ;
+                    }
+                }];
                 
                 
-                if([[cart_json valueForKey:@"result"] intValue]==2)
-                {
-                    [RAUtils message_alert:[NSString stringWithFormat:@"%ld items saved.",checked.count] title:@"Edit Portfolio" controller:self] ;
-                    [self reload_data];
-                }
-                else
-                {
-                    [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Edit Portfolio" controller:self] ;
-                }
+
                 
                 
                 
@@ -1970,48 +2025,51 @@
             [RANetwork request_update_portfolio_price:[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]] price:price discount:discount QTY:qty  qty_p:qty_p notes:notes completionHandler:^(NSMutableDictionary *result) {
                 
                 NSDictionary* cart_json = result;
-                [waitalert dismissViewControllerAnimated:YES completion:nil];
-                
-                
-                if([[cart_json valueForKey:@"result"] intValue]==2)
-                {
-                    self.editedRow = indexPath.row;
-                    
-                    if (!(qty == -INT32_MAX && qty_p == -MAXFLOAT)) {
-                        // qty
-                        if (qty != -INT32_MAX)
-                            item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
-                        else
-                            [item_json removeObjectForKey:@"available_qty"];
+                [waitalert dismissViewControllerAnimated:YES completion:^{
+                    if([[cart_json valueForKey:@"result"] intValue]==2)
+                    {
+                        self.editedRow = indexPath.row;
                         
-                        // qty_p
-                        if (qty_p != -MAXFLOAT)
-                            item_json[@"available_percent"]=[NSNumber numberWithInt:qty_p];
-                        else
-                            [item_json removeObjectForKey:@"available_percent"];
-                    }
-                    
-                    if (notes) {
-                        item_json[@"linenotes"]=notes;
-                    }
-                    
-                    if (discount != -MAXFLOAT) {
-                        item_json[@"tear_sheet_discount"]=[NSString stringWithFormat:@"%.2f",discount];
+                        if (!(qty == -INT32_MAX && qty_p == -MAXFLOAT)) {
+                            // qty
+                            if (qty != -INT32_MAX)
+                                item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
+                            else
+                                [item_json removeObjectForKey:@"available_qty"];
+                            
+                            // qty_p
+                            if (qty_p != -MAXFLOAT)
+                                item_json[@"available_percent"]=[NSNumber numberWithInt:qty_p];
+                            else
+                                [item_json removeObjectForKey:@"available_percent"];
+                        }
+                        
+                        if (notes) {
+                            item_json[@"linenotes"]=notes;
+                        }
+                        
+                        if (discount != -MAXFLOAT) {
+                            item_json[@"tear_sheet_discount"]=[NSString stringWithFormat:@"%.2f",discount];
+                        }
+                        
+                        if (price != -MAXFLOAT) {
+                            item_json[@"tear_sheet_price"]=[NSString stringWithFormat:@"%.2f",price];
+                        }
+                        
+                        self.content_data[[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]]=item_json;
+                        // item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
+                        self.indexPath=indexPath;
+                        [self.itemListTable reloadData];
                     }
-                    
-                    if (price != -MAXFLOAT) {
-                        item_json[@"tear_sheet_price"]=[NSString stringWithFormat:@"%.2f",price];
+                    else
+                    {
+                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Edit Portfolio" controller:self] ;
                     }
-                    
-                    self.content_data[[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]]=item_json;
-                   // item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
-                    self.indexPath=indexPath;
-                    [self.itemListTable reloadData];
-                }
-                else
-                {
-                    [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Edit Portfolio" controller:self] ;
-                }
+                }];
+                
+                
+                
+
                 
                 
                 

+ 228 - 219
RedAnt ERP Mobile/common/Functions/portfolio/TearSheetParamViewController.m

@@ -264,9 +264,11 @@
 //        [pdf_url appendString:[valuefrom stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
         
         
-        [pdf_url appendString:[valuefrom stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "]]];
-        
+//        [pdf_url appendString:[valuefrom stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "]]];
+  
+        [pdf_url appendString:[valuefrom stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];
         
+
         //    NSString* value=[self getValue:valuefrom];
         
         //    [ret setValue:value forKey:valuefrom];
@@ -285,220 +287,225 @@
     UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Processing"];
     [RANetwork request_portfoliopreview:upparams completionHandler:^(NSMutableDictionary *result) {
         NSDictionary* editor_json = result;
-        
+
         //            [waitalert dismissViewControllerAnimated:YES completion:nil];
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-        
-        
-        if([[editor_json valueForKey:@"result"] intValue]==2)
-        {
-            //                    NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-            
-            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-            
-            NSString* url = [editor_json valueForKey:@"pdf_path"];
-            NSString* path = [editor_json valueForKey:@"pdf_real_path"];
-            bool isLocalFile = [[editor_json valueForKey:@"isLocalFile"] boolValue];
-            RAPDFViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
-            ViewController.url = url;
-            ViewController.canSave = true;
-            ViewController.isLocalfile=isLocalFile;
-            //                    ViewController.mail_content = [self.content_data valueForKey:@"email_content"];
-            ViewController.filename = [NSString stringWithFormat:@"%@.pdf",[TextUtils legalFilename:catelog_name]];
-            ViewController.save_name =catelog_name;
-            ViewController.save_note =internal_note;
-            //ViewController.filename = catelog_name;
-            NSString* company=    [appDelegate.customerInfo valueForKey:@"customer_name"];
-            
-            if(company==nil)
-                company=@"";
-            //                    NSString* customer_email=    [appDelegate.customerInfo valueForKey:@"customer_email"];
-            
-            
-            //                    NSMutableArray* send_to = [[NSMutableArray alloc]init];
-            //                    if(customer_email.length>0)
-            //                        [send_to addObject:customer_email];
-            //                    ViewController.mail_to = send_to;
-            
-            
-            
-            //  AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-            NSString* customer_email=    [appDelegate.customerInfo valueForKey:@"customer_email"];
-            
-            
-            NSMutableArray* send_to = [[NSMutableArray alloc]init];
-            if(customer_email.length>0)
-            {
-                send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
-                //                            customer_email compo
-                //                            [send_to addObject:customer_email];
-            }
-            ViewController.mail_to = send_to;
-            
-            NSString* subject;
-            //                    if (company.length==0) {
-            
-            //         NSString* cur_time =[RAUtils current_date];
-            subject =catelog_name;//[NSString stringWithFormat:@"NPD Product List %@",cur_time];
-            
-            
-            
-            //                    }
-            //                    else
-            //                    {
-            //                        subject = [NSString stringWithFormat:@"Tear sheet for %@",company ];
-            //                    }
-            //                ViewController.attachment_name = [NSString stringWithFormat:@"%@.pdf",catelog_name];//[NSString stringWithFormat:@"NPD_Product_List %@.pdf",cur_time];
-            ViewController.mail_subject = subject;
-            
-            //                    ViewController.onLoadSuccess =^(NSString* url)
-            //                    {
-            //
-            //                    };
-            
-            
-            ViewController.onSavePDF=^(NSString* name,NSString* file)
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            if([[editor_json valueForKey:@"result"] intValue]==2)
             {
+                //                    NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
                 
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                 
-                NSString* del_ids = nil;
-                if(bremove)
-                    del_ids=[self.params valueForKey:@"item_ids"];
+                NSString* url = [editor_json valueForKey:@"pdf_path"];
+                NSString* path = [editor_json valueForKey:@"pdf_real_path"];
+                bool isLocalFile = [[editor_json valueForKey:@"isLocalFile"] boolValue];
+                RAPDFViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
+                ViewController.url = url;
+                ViewController.canSave = true;
+                ViewController.isLocalfile=isLocalFile;
+                //                    ViewController.mail_content = [self.content_data valueForKey:@"email_content"];
+                ViewController.filename = [NSString stringWithFormat:@"%@.pdf",[TextUtils legalFilename:catelog_name]];
+                ViewController.save_name =catelog_name;
+                ViewController.save_note =internal_note;
+                //ViewController.filename = catelog_name;
+                NSString* company=    [appDelegate.customerInfo valueForKey:@"customer_name"];
                 
-                UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Saving..."];
+                if(company==nil)
+                    company=@"";
+                //                    NSString* customer_email=    [appDelegate.customerInfo valueForKey:@"customer_email"];
                 
                 
-#ifdef OFFLINE_MODE
-                if (appDelegate.offline_mode)
-                {
-                    [upparams setValue:url forKey:@"pdfPath"];
-                }
-                else
-#endif
+                //                    NSMutableArray* send_to = [[NSMutableArray alloc]init];
+                //                    if(customer_email.length>0)
+                //                        [send_to addObject:customer_email];
+                //                    ViewController.mail_to = send_to;
+                
+                
+                
+                //  AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                NSString* customer_email=    [appDelegate.customerInfo valueForKey:@"customer_email"];
+                
+                
+                NSMutableArray* send_to = [[NSMutableArray alloc]init];
+                if(customer_email.length>0)
                 {
-                    [upparams setValue:path forKey:@"pdfPath"];
+                    send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
+                    //                            customer_email compo
+                    //                            [send_to addObject:customer_email];
                 }
-                [upparams setValue:name forKey:@"pdfName"];
-                [upparams setValue:internal_note forKey:@"pdfNote"];
-                [upparams setValue:del_ids forKey:@"itemIds"];
-                [upparams setValue:pdf_url forKey:@"configureParams"];
+                ViewController.mail_to = send_to;
                 
-                [RANetwork request_save_portfolio:upparams completionHandler:^(NSMutableDictionary *result) {
+                NSString* subject;
+                //                    if (company.length==0) {
+                
+                //         NSString* cur_time =[RAUtils current_date];
+                subject =catelog_name;//[NSString stringWithFormat:@"NPD Product List %@",cur_time];
+                
+                
+                
+                //                    }
+                //                    else
+                //                    {
+                //                        subject = [NSString stringWithFormat:@"Tear sheet for %@",company ];
+                //                    }
+                //                ViewController.attachment_name = [NSString stringWithFormat:@"%@.pdf",catelog_name];//[NSString stringWithFormat:@"NPD_Product_List %@.pdf",cur_time];
+                ViewController.mail_subject = subject;
+                
+                //                    ViewController.onLoadSuccess =^(NSString* url)
+                //                    {
+                //
+                //                    };
+                
+                
+                ViewController.onSavePDF=^(NSString* name,NSString* file)
+                {
                     
-                    NSDictionary* json =result;
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
                     
+                    NSString* del_ids = nil;
+                    if(bremove)
+                        del_ids=[self.params valueForKey:@"item_ids"];
                     
-                    if([[json valueForKey:@"result"] intValue]==2)
+                    UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Saving..."];
+                    
+                    
+#ifdef OFFLINE_MODE
+                    if (appDelegate.offline_mode)
                     {
-                        [RAUtils message_alert:@"Portfolio saved. You can find it from View Portfolios" title:@"Portfolio" controller:self];
-                        //                                [RAUtils alert_view:nil title: ] ;
+                        [upparams setValue:url forKey:@"pdfPath"];
+                    }
+                    else
+#endif
+                    {
+                        [upparams setValue:path forKey:@"pdfPath"];
+                    }
+                    [upparams setValue:name forKey:@"pdfName"];
+                    [upparams setValue:internal_note forKey:@"pdfNote"];
+                    [upparams setValue:del_ids forKey:@"itemIds"];
+                    [upparams setValue:pdf_url forKey:@"configureParams"];
+                    
+                    [RANetwork request_save_portfolio:upparams completionHandler:^(NSMutableDictionary *result) {
                         
-                        [self.navigationController dismissViewControllerAnimated:true completion:^{
-                            
-                            
-                            
+                        NSDictionary* json =result;
+                        [waitalert dismissViewControllerAnimated:YES completion:^{
+                            if([[json valueForKey:@"result"] intValue]==2)
+                            {
+                                [RAUtils message_alert:@"Portfolio saved. You can find it from View Portfolios" title:@"Portfolio" controller:self];
+                                //                                [RAUtils alert_view:nil title: ] ;
+                                
+                                [self.navigationController dismissViewControllerAnimated:true completion:^{
+                                    
+                                    
+                                    
 #ifdef RA_NOTIFICATION
-                            [ActiveViewController Notify:@"PortfolioViewController,PDFListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                                    [ActiveViewController Notify:@"PortfolioViewController,PDFListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                            [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:true];
-                            [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
+                                    [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:true];
+                                    [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
 #endif
-                            //                                            if(self.onDismiss)
-                            //                                                self.onDismiss(catelog_name);
+                                    //                                            if(self.onDismiss)
+                                    //                                                self.onDismiss(catelog_name);
+                                }];
+                            }
+                            else
+                            {
+                                [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Save Portfolio" controller:self] ;
+                            }
                         }];
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Save Portfolio" controller:self] ;
-                    }
+                        
+                        
+                        
+                        
+                    }];
                     
-                }];
-                
+                    
+                    //                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                    //
+                    //
+                    //#ifdef OFFLINE_MODE
+                    //                        if (appDelegate.offline_mode)
+                    //                        {
+                    //                            [upparams setValue:url forKey:@"pdfPath"];
+                    //                        }
+                    //                        else
+                    //#endif
+                    //                        {
+                    //                            [upparams setValue:path forKey:@"pdfPath"];
+                    //                        }
+                    //                        [upparams setValue:name forKey:@"pdfName"];
+                    //                        [upparams setValue:internal_note forKey:@"pdfNote"];
+                    //                        [upparams setValue:del_ids forKey:@"itemIds"];
+                    //                        [upparams setValue:pdf_url forKey:@"configureParams"];
+                    //
+                    //
+                    //
+                    //                        NSDictionary* json = [RANetwork save_TearSheet:upparams];
+                    //
+                    //                        dispatch_async(dispatch_get_main_queue(), ^{
+                    //                            [waitalert dismissViewControllerAnimated:YES completion:nil];
+                    //
+                    //
+                    //                            if([[json valueForKey:@"result"] intValue]==2)
+                    //                            {
+                    //                                [RAUtils message_alert:@"Portfolio saved. You can find it from View Portfolios" title:@"Portfolio" controller:self];
+                    ////                                [RAUtils alert_view:nil title: ] ;
+                    //
+                    //                                [self.navigationController dismissViewControllerAnimated:true completion:^{
+                    //
+                    //
+                    //
+                    //#ifdef RA_NOTIFICATION
+                    //                                    [ActiveViewController Notify:@"PortfolioViewController,PDFListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    //#else
+                    //                                    [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:true];
+                    //                                     [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
+                    //#endif
+                    //                                    //                                            if(self.onDismiss)
+                    //                                    //                                                self.onDismiss(catelog_name);
+                    //                                }];
+                    //                            }
+                    //                            else
+                    //                            {
+                    //                                [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Save Portfolio" controller:self] ;
+                    //                            }
+                    //
+                    //                        });
+                    //                    });
+                    
+                    
+                    
+                };
                 
-                //                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                //
-                //
-                //#ifdef OFFLINE_MODE
-                //                        if (appDelegate.offline_mode)
-                //                        {
-                //                            [upparams setValue:url forKey:@"pdfPath"];
-                //                        }
-                //                        else
-                //#endif
-                //                        {
-                //                            [upparams setValue:path forKey:@"pdfPath"];
-                //                        }
-                //                        [upparams setValue:name forKey:@"pdfName"];
-                //                        [upparams setValue:internal_note forKey:@"pdfNote"];
-                //                        [upparams setValue:del_ids forKey:@"itemIds"];
-                //                        [upparams setValue:pdf_url forKey:@"configureParams"];
-                //
-                //
-                //
-                //                        NSDictionary* json = [RANetwork save_TearSheet:upparams];
-                //
-                //                        dispatch_async(dispatch_get_main_queue(), ^{
-                //                            [waitalert dismissViewControllerAnimated:YES completion:nil];
-                //
-                //
-                //                            if([[json valueForKey:@"result"] intValue]==2)
-                //                            {
-                //                                [RAUtils message_alert:@"Portfolio saved. You can find it from View Portfolios" title:@"Portfolio" controller:self];
-                ////                                [RAUtils alert_view:nil title: ] ;
-                //
-                //                                [self.navigationController dismissViewControllerAnimated:true completion:^{
-                //
-                //
-                //
-                //#ifdef RA_NOTIFICATION
-                //                                    [ActiveViewController Notify:@"PortfolioViewController,PDFListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-                //#else
-                //                                    [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:true];
-                //                                     [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
-                //#endif
-                //                                    //                                            if(self.onDismiss)
-                //                                    //                                                self.onDismiss(catelog_name);
-                //                                }];
-                //                            }
-                //                            else
-                //                            {
-                //                                [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Save Portfolio" controller:self] ;
-                //                            }
-                //
-                //                        });
-                //                    });
+                //    ViewController. = self.function_name;
+                //    ViewController.behavior =BEHAVIOR_SEARCH;
+                ViewController.hidenavi = false;
+                [self.navigationController pushViewController:ViewController animated:YES];
+                //  [[self navigationController] setNavigationBarHidden:NO animated:NO];
                 
                 
+                /*
+                 if(self.return_url)
+                 self.return_url(url,path,bremove);
+                 [self.navigationController dismissViewControllerAnimated:true completion:^{
+                 if(self.onDismiss)
+                 self.onDismiss(catelog_name);
+                 }];
+                 */
                 
-            };
-            
-            //    ViewController. = self.function_name;
-            //    ViewController.behavior =BEHAVIOR_SEARCH;
-            ViewController.hidenavi = false;
-            [self.navigationController pushViewController:ViewController animated:YES];
-            //  [[self navigationController] setNavigationBarHidden:NO animated:NO];
-            
-            
-            /*
-             if(self.return_url)
-             self.return_url(url,path,bremove);
-             [self.navigationController dismissViewControllerAnimated:true completion:^{
-             if(self.onDismiss)
-             self.onDismiss(catelog_name);
-             }];
-             */
-            
-        }
-        else
-        {
-            [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Create Portfolio" controller:self] ;
-        }
-        
-        
-        
+            }
+            else
+            {
+                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Create Portfolio" controller:self] ;
+            }
+        }];
+
+
+
         
+ 
+
+
+
+
     }];
     
 //    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@@ -907,7 +914,7 @@
         
 //        [pdf_url appendString:[valuefrom stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
 //
-        [pdf_url appendString:[valuefrom stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"`#%^{}\"[]|\\<> "]]];
+        [pdf_url appendString:[valuefrom stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];
         
         
         
@@ -959,40 +966,42 @@
             [upparams setValue:saveNote forKey:@"pdfNote"];
             [RANetwork request_save_portfoliodirectly:upparams completionHandler:^(NSMutableDictionary *result) {
                 NSDictionary* editor_json =result;
-                [waitalert dismissViewControllerAnimated:YES completion:nil];
-                
-                
-                if([[editor_json valueForKey:@"result"] intValue]==2)
-                {
-                    
-                    
-                    
-                    
-                    //   [RAUtils alert_view:nil title:@"Portfolio saved. You can find it from View Portfolios" ] ;
-                    NSString* url = [editor_json valueForKey:@"pdf_path"];
-                    bool isLocalFile = [editor_json valueForKey:@"isLocalFile"];
-                    [self.navigationController dismissViewControllerAnimated:true completion:^{
+                [waitalert dismissViewControllerAnimated:YES completion:^{
+                    if([[editor_json valueForKey:@"result"] intValue]==2)
+                    {
+                        
                         
                         
                         
+                        //   [RAUtils alert_view:nil title:@"Portfolio saved. You can find it from View Portfolios" ] ;
+                        NSString* url = [editor_json valueForKey:@"pdf_path"];
+                        bool isLocalFile = [editor_json valueForKey:@"isLocalFile"];
+                        [self.navigationController dismissViewControllerAnimated:true completion:^{
+                            
+                            
+                            
 #ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"PortfolioViewController,PDFListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                            [ActiveViewController Notify:@"PortfolioViewController,PDFListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:true];
-                        [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
-                        
+                            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                            [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:true];
+                            [((MainViewController*)appDelegate.main_vc) reloadDocuments:true immediately:false];
+                            
 #endif
+                            
+                            if(self.onSaved)
+                                self.onSaved(url,saveName,isLocalFile);
+                        }];
                         
-                        if(self.onSaved)
-                            self.onSaved(url,saveName,isLocalFile);
-                    }];
-                    
-                }
-                else
-                {
-                    [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Create Portfolio" controller:self] ;
-                }
+                    }
+                    else
+                    {
+                        [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Create Portfolio" controller:self] ;
+                    }
+                }];
+                
+                
+                
                 
                 
                 

+ 54 - 6
RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchFilterViewController.m

@@ -82,7 +82,12 @@
 }
 
 - (IBAction)onSearchClick:(id)sender {
-
+//
+//    self.scrollView.scrollEnabled = true;
+//    self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width, self.scrollView.frame.size.height+200);
+//    self.treeView.scrollEnabled = false;
+//    return;
+//
     NSString* ids= [[self get_checkedIDs:self.categoryMenu]componentsJoinedByString:@","];
     
     NSString* modelname = self.textModelName.text;
@@ -211,7 +216,9 @@
     
     self.edgesForExtendedLayout = UIRectEdgeNone;
     
-    RATreeView *treeView = [[RATreeView alloc] initWithFrame:self.treeContainer.frame];
+    CGRect rect_tframe = CGRectMake(0,0,self.treeContainer.frame.size.width,self.treeContainer.frame.size.height);
+    
+    RATreeView *treeView = [[RATreeView alloc] initWithFrame:rect_tframe];
     
     treeView.delegate = self;
     treeView.dataSource = self;
@@ -390,7 +397,7 @@
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
     
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidChangeFrame:) name:UIKeyboardDidChangeFrameNotification object:nil];
  }
 -(void) dealloc
 {
@@ -817,9 +824,9 @@
 
 #pragma mark - Responding to keyboard events
 
-
-- (void)keyboardWillChangeFrame:(NSNotification *)notification {
-    NSLog(@"keyboardWillChangeFrame");
+- (void)keyboardDidChangeFrame:(NSNotification *)notification {
+//    return;
+    NSLog(@"keyboardDidChangeFrame");
     
     
     // 使用tableContainer计算frame 保证屏幕旋转后table height正确
@@ -844,6 +851,7 @@
     {
         self.scrollView.scrollEnabled = true;
         self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width, self.scrollView.frame.size.height+dark);
+//        self.scrollView.contentOffset=CGPointMake(0, dark);
         self.treeView.scrollEnabled = false;
     }
     else
@@ -856,6 +864,46 @@
   
     
 }
+//- (void)keyboardWillChangeFrame:(NSNotification *)notification {
+////    return;
+//    NSLog(@"keyboardWillChangeFrame");
+//
+//
+//    // 使用tableContainer计算frame 保证屏幕旋转后table height正确
+//    //    CGRect table_origin_screen_frame = [self.tableContainer convertRect:self.tableContainer.bounds toView:self.view.window];
+//
+//    CGRect screen_rect = [RAUtils relativeFrameForScreenWithView:self.view];
+//    //
+//    //    //    NSTimeInterval duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
+//    //    //    duration *= 0.0;
+//    CGRect end = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
+//    CGFloat keyboard_top = end.origin.y;
+//    NSLog(@"keyboard rect: %@",NSStringFromCGRect(end));
+//
+//    NSLog(@"view rect: %@",NSStringFromCGRect(self.view.frame));
+//    NSLog(@"view screen rect: %@",NSStringFromCGRect(screen_rect));
+//
+//    //    self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
+//
+//    float dark = screen_rect.origin.y+screen_rect.size.height-keyboard_top;
+//
+//    if(dark>0)
+//    {
+//        self.scrollView.scrollEnabled = true;
+//        self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width, self.scrollView.frame.size.height+dark);
+////        self.scrollView.contentOffset=CGPointMake(0, dark);
+//        self.treeView.scrollEnabled = false;
+//    }
+//    else
+//    {
+//        self.scrollView.scrollEnabled = false;
+//        self.scrollView.contentSize = self.scrollView.frame.size;
+//        self.treeView.scrollEnabled = true;
+//    }
+//
+//
+//
+//}
 
 //static float table_origin_h = 0;
 

+ 333 - 319
RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchViewController.m

@@ -1049,46 +1049,48 @@
     [RANetwork request_create_order:^(NSMutableDictionary *result) {
         NSMutableDictionary* return_json = result;
         
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-        
-        if([[return_json valueForKey:@"result"] intValue]==2)
-        {
-            int result=[[return_json valueForKey:@"result"] intValue];
-            if(result==2)
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            if([[return_json valueForKey:@"result"] intValue]==2)
             {
-                //successed.
-                
-                NSString* order_code = [return_json valueForKey:@"orderCode"];
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                appDelegate.order_code = order_code;
-                
-                
-                [self addtocart];
-                
-                
-                //    [self ReloadData];
-                
-                
-                //                    if(self.shopCartBlock!=nil)
-                //                    {
-                //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                //
-                //
-                //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                //                        iv.image = img;
-                //                        //                        [self.contentView addSubview:iv];
-                //                        self.shopCartBlock(iv);
-                //
-                //                    }
-                
+                int result=[[return_json valueForKey:@"result"] intValue];
+                if(result==2)
+                {
+                    //successed.
+                    
+                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    appDelegate.order_code = order_code;
+                    
+                    
+                    [self addtocart];
+                    
+                    
+                    //    [self ReloadData];
+                    
+                    
+                    //                    if(self.shopCartBlock!=nil)
+                    //                    {
+                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                    //
+                    //
+                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                    //                        iv.image = img;
+                    //                        //                        [self.contentView addSubview:iv];
+                    //                        self.shopCartBlock(iv);
+                    //
+                    //                    }
+                    
+                }
             }
-        }
-        else
-        {
-            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-        }
+            else
+            {
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+            }
+        }];
+        
+        
+        
         
         
         
@@ -1289,82 +1291,84 @@
         
         [RANetwork request_addall_itemsearch:self.offset limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller orderCode:appDelegate.order_code addTo:@"cart" completionHandler:^(NSMutableDictionary *result) {
                     NSDictionary* return_json =result;
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                self.addCartBtn.enabled = true;
+                
+                if([[return_json valueForKey:@"result"] intValue]==2)
+                {
+                    //                int result=[[return_json valueForKey:@"result"] intValue];
+                    //                if(result==2)
+                    //                {
+                    //                    //successed.
                     
-                    self.addCartBtn.enabled = true;
+                    //             NSString* order_code = [return_json valueForKey:@"order_code"];
                     
-                    if([[return_json valueForKey:@"result"] intValue]==2)
-                    {
-                        //                int result=[[return_json valueForKey:@"result"] intValue];
-                        //                if(result==2)
-                        //                {
-                        //                    //successed.
-                        
-                        //             NSString* order_code = [return_json valueForKey:@"order_code"];
-                        
-                        //                    appDelegate.order_code = order_code;
-                        //                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        //                appDelegate.order_code = order_code;
-                        
+                    //                    appDelegate.order_code = order_code;
+                    //                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    //                appDelegate.order_code = order_code;
+                    
+                    
+#ifdef RA_NOTIFICATION
+                    [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+#endif
+                    
+                    
+                    NSString * msg = nil;
+                    
+                    if (self.addAll) {
                         
-        #ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-        #else
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
-        #endif
+                        unsigned long checkedCount = [return_json[@"count"] integerValue];
                         
+                        msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
+                    } else {
                         
-                        NSString * msg = nil;
                         
-                        if (self.addAll) {
-                            
-                            unsigned long checkedCount = [return_json[@"count"] integerValue];
-                            
-                            msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
-                        } else {
-                            
-                            
-                            if(checked.count==1)
-                            {
-                                msg=@"1 item added to Cart";
-                            }
-                            else
-                            {
-                                msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
-                            }
+                        if(checked.count==1)
+                        {
+                            msg=@"1 item added to Cart";
+                        }
+                        else
+                        {
+                            msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
                         }
-                        
-                        
-                        [RAUtils message_alert:nil title:msg controller:self] ;
-                        
-                        [self end_select:2];
-                        
-                        
-                        
-                        //                }
-                    }
-                    else  if([[return_json valueForKey:@"result"] intValue]==8)
-                    {
-                        
-                        
-        #ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-        #else
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-        #endif
-                        
-                        [self end_select:2];
-                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
                     }
                     
                     
+                    [RAUtils message_alert:nil title:msg controller:self] ;
+                    
+                    [self end_select:2];
+                    
+                    
+                    
+                    //                }
+                }
+                else  if([[return_json valueForKey:@"result"] intValue]==8)
+                {
+                    
+                    
+#ifdef RA_NOTIFICATION
+                    [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+#endif
+                    
+                    [self end_select:2];
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                }
+                else
+                {
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                }
+            }];
+                    
+                    
+                    
+                    
                     
                     
                 }];
@@ -1372,80 +1376,82 @@
     } else {
         [RANetwork request_addto_cart_byname:ids withScreen:ScreenCodeParticularCategory completionHandler:^(NSMutableDictionary *result) {
             NSDictionary* return_json =result;
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
-            self.addCartBtn.enabled = true;
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                //                int result=[[return_json valueForKey:@"result"] intValue];
-                //                if(result==2)
-                //                {
-                //                    //successed.
-                
-                //             NSString* order_code = [return_json valueForKey:@"order_code"];
-                
-                //                    appDelegate.order_code = order_code;
-                //                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                //                appDelegate.order_code = order_code;
-                
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                self.addCartBtn.enabled = true;
                 
+                if([[return_json valueForKey:@"result"] intValue]==2)
+                {
+                    //                int result=[[return_json valueForKey:@"result"] intValue];
+                    //                if(result==2)
+                    //                {
+                    //                    //successed.
+                    
+                    //             NSString* order_code = [return_json valueForKey:@"order_code"];
+                    
+                    //                    appDelegate.order_code = order_code;
+                    //                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    //                appDelegate.order_code = order_code;
+                    
+                    
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
 #endif
-                
-                
-                NSString * msg = nil;
-                
-                if (self.addAll) {
                     
-                    unsigned long checkedCount = [return_json[@"count"] integerValue];
                     
-                    msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
-                } else {
+                    NSString * msg = nil;
                     
-                    
-                    if(checked.count==1)
-                    {
-                        msg=@"1 item added to Cart";
-                    }
-                    else
-                    {
-                        msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
+                    if (self.addAll) {
+                        
+                        unsigned long checkedCount = [return_json[@"count"] integerValue];
+                        
+                        msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
+                    } else {
+                        
+                        
+                        if(checked.count==1)
+                        {
+                            msg=@"1 item added to Cart";
+                        }
+                        else
+                        {
+                            msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
+                        }
                     }
+                    
+                    
+                    [RAUtils message_alert:nil title:msg controller:self] ;
+                    
+                    [self end_select:2];
+                    
+                    
+                    
+                    //                }
                 }
-                
-                
-                [RAUtils message_alert:nil title:msg controller:self] ;
-                
-                [self end_select:2];
-                
-                
-                
-                //                }
-            }
-            else  if([[return_json valueForKey:@"result"] intValue]==8)
-            {
-                
-                
+                else  if([[return_json valueForKey:@"result"] intValue]==8)
+                {
+                    
+                    
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
 #endif
-                
-                [self end_select:2];
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-            }
-            else
-            {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-            }
+                    
+                    [self end_select:2];
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                }
+                else
+                {
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                }
+            }];
+            
+            
             
             
             
@@ -1597,52 +1603,54 @@
             if (self.addAll) {
                 [RANetwork request_addall_itemsearch:self.offset limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller orderCode:nil addTo:@"portfolio" completionHandler:^(NSMutableDictionary *result) {
                     NSDictionary* return_json = result;
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    
-                    self.addPortfolioBtn.enabled =true;
-                    
-                    if([[return_json valueForKey:@"result"] intValue]==2)
-                    {
-                        
-                        
-                        
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
+                        self.addPortfolioBtn.enabled =true;
                         
+                        if([[return_json valueForKey:@"result"] intValue]==2)
+                        {
+                            
+                            
+                            
+                            
 #ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                            [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
+                            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                            [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
 #endif
-                        
-                        NSString * msg = nil;
-                        
-                        if (self.addAll) {
                             
-                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            NSString * msg = nil;
                             
-                            msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
-                        } else {
-                            
-                            if(checked.count==1)
-                            {
-                                msg=@"1 item added to Portfolio";
-                            }
-                            else
-                            {
-                                msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                            if (self.addAll) {
+                                
+                                unsigned long checkedCount = [return_json[@"count"] integerValue];
+                                
+                                msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
+                            } else {
+                                
+                                if(checked.count==1)
+                                {
+                                    msg=@"1 item added to Portfolio";
+                                }
+                                else
+                                {
+                                    msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                                }
                             }
+                            
+                            [RAUtils message_alert:nil title:msg controller:self] ;
+                            
+                            
+                            [self end_select:3];
+                            
                         }
-                        
-                        [RAUtils message_alert:nil title:msg controller:self] ;
-                        
-                        
-                        [self end_select:3];
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
-                    }
+                        else
+                        {
+                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
+                        }
+                    }];
+                    
+                    
                     
                     
                     
@@ -1651,52 +1659,54 @@
             } else {
                 [RANetwork request_addto_portfolio:ids withScreen:ScreenCodeParticularCategory completionHandler:^(NSMutableDictionary *result) {
                     NSDictionary* return_json = result;
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    
-                    self.addPortfolioBtn.enabled =true;
-                    
-                    if([[return_json valueForKey:@"result"] intValue]==2)
-                    {
-                        
-                        
-                        
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
+                        self.addPortfolioBtn.enabled =true;
                         
+                        if([[return_json valueForKey:@"result"] intValue]==2)
+                        {
+                            
+                            
+                            
+                            
 #ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                            [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
+                            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                            [((MainViewController*)appDelegate.main_vc) reloadPortfolio:true immediately:false];
 #endif
-                        
-                        NSString * msg = nil;
-                        
-                        if (self.addAll) {
-                            
-                            unsigned long checkedCount = [return_json[@"count"] integerValue];
                             
-                            msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
-                        } else {
+                            NSString * msg = nil;
                             
-                            if(checked.count==1)
-                            {
-                                msg=@"1 item added to Portfolio";
-                            }
-                            else
-                            {
-                                msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                            if (self.addAll) {
+                                
+                                unsigned long checkedCount = [return_json[@"count"] integerValue];
+                                
+                                msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
+                            } else {
+                                
+                                if(checked.count==1)
+                                {
+                                    msg=@"1 item added to Portfolio";
+                                }
+                                else
+                                {
+                                    msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                                }
                             }
+                            
+                            [RAUtils message_alert:nil title:msg controller:self] ;
+                            
+                            
+                            [self end_select:3];
+                            
                         }
-                        
-                        [RAUtils message_alert:nil title:msg controller:self] ;
-                        
-                        
-                        [self end_select:3];
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
-                    }
+                        else
+                        {
+                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
+                        }
+                    }];
+                    
+                    
                     
                     
                     
@@ -1811,53 +1821,55 @@
     
                 [RANetwork request_addall_itemsearch:self.offset limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller orderCode:nil addTo:@"wishlist" completionHandler:^(NSMutableDictionary *result) {
                     NSDictionary* return_json = result;
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    self.addWishBtn.enabled =true;
-                    
-                    if([[return_json valueForKey:@"result"] intValue]==2)
-                    {
-                        
-                        
-                        
-                        
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
+                        self.addWishBtn.enabled =true;
                         
+                        if([[return_json valueForKey:@"result"] intValue]==2)
+                        {
+                            
+                            
+                            
+                            
+                            
 #ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                            [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        
-                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+                            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                            
+                            [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
 #endif
-                        NSString * msg = nil;
-                        
-                        if (self.addAll) {
+                            NSString * msg = nil;
                             
-                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            if (self.addAll) {
+                                
+                                unsigned long checkedCount = [return_json[@"count"] integerValue];
+                                
+                                msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
+                            } else {
+                                
+                                
+                                if(checked.count==1)
+                                {
+                                    msg=@"1 item added to \nWish List";
+                                }
+                                else
+                                {
+                                    msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+                                }
+                            }
                             
-                            msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
-                        } else {
+                            [RAUtils message_alert:nil title:msg controller:self] ;
                             
                             
-                            if(checked.count==1)
-                            {
-                                msg=@"1 item added to \nWish List";
-                            }
-                            else
-                            {
-                                msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
-                            }
+                            [self end_select:1];
+                            
                         }
-                        
-                        [RAUtils message_alert:nil title:msg controller:self] ;
-                        
-                        
-                        [self end_select:1];
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
-                    }
+                        else
+                        {
+                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
+                        }
+                    }];
+                    
                     
                     
                     
@@ -1869,53 +1881,55 @@
                 
                 [RANetwork request_addto_wishlist:ids withScreen:ScreenCodeParticularCategory completionHandler:^(NSMutableDictionary *result) {
                     NSDictionary* return_json = result;
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    self.addWishBtn.enabled =true;
-                    
-                    if([[return_json valueForKey:@"result"] intValue]==2)
-                    {
-                        
-                        
-                        
-                        
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
+                        self.addWishBtn.enabled =true;
                         
+                        if([[return_json valueForKey:@"result"] intValue]==2)
+                        {
+                            
+                            
+                            
+                            
+                            
 #ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                            [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        
-                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+                            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                            
+                            [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
 #endif
-                        NSString * msg = nil;
-                        
-                        if (self.addAll) {
+                            NSString * msg = nil;
                             
-                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            if (self.addAll) {
+                                
+                                unsigned long checkedCount = [return_json[@"count"] integerValue];
+                                
+                                msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
+                            } else {
+                                
+                                
+                                if(checked.count==1)
+                                {
+                                    msg=@"1 item added to \nWish List";
+                                }
+                                else
+                                {
+                                    msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+                                }
+                            }
                             
-                            msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
-                        } else {
+                            [RAUtils message_alert:nil title:msg controller:self] ;
                             
                             
-                            if(checked.count==1)
-                            {
-                                msg=@"1 item added to \nWish List";
-                            }
-                            else
-                            {
-                                msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
-                            }
+                            [self end_select:1];
+                            
                         }
-                        
-                        [RAUtils message_alert:nil title:msg controller:self] ;
-                        
-                        
-                        [self end_select:1];
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
-                    }
+                        else
+                        {
+                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
+                        }
+                    }];
+                    
                     
                     
                     
@@ -2072,7 +2086,7 @@
         // what ever you want to prepare
     } completion:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
         
-        
+        self.headerView.layer.shadowPath =[UIBezierPath bezierPathWithRect:self.headerView.bounds].CGPath;
             self.toOrientation = [UIApplication sharedApplication].statusBarOrientation;
         [self.collectionview.collectionViewLayout invalidateLayout];
     }];

+ 286 - 272
RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m

@@ -674,48 +674,50 @@
     [RANetwork request_create_order:^(NSMutableDictionary *result) {
         NSMutableDictionary* return_json = result;
         
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-//        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-        
-        if([[return_json valueForKey:@"result"] intValue]==2)
-        {
-            int result=[[return_json valueForKey:@"result"] intValue];
-            if(result==2)
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            
+            //        [waitalert dismissViewControllerAnimated:YES completion:nil];
+            
+            
+            if([[return_json valueForKey:@"result"] intValue]==2)
             {
-                //successed.
-                
-                NSString* order_code = [return_json valueForKey:@"orderCode"];
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                appDelegate.order_code = order_code;
-                appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-                
-                [self addtocart];
-                
-                
-                //    [self ReloadData];
-                
-                
-                //                    if(self.shopCartBlock!=nil)
-                //                    {
-                //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
-                //
-                //
-                //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
-                //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
-                //                        iv.image = img;
-                //                        //                        [self.contentView addSubview:iv];
-                //                        self.shopCartBlock(iv);
-                //
-                //                    }
-                
+                int result=[[return_json valueForKey:@"result"] intValue];
+                if(result==2)
+                {
+                    //successed.
+                    
+                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    appDelegate.order_code = order_code;
+                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+                    
+                    [self addtocart];
+                    
+                    
+                    //    [self ReloadData];
+                    
+                    
+                    //                    if(self.shopCartBlock!=nil)
+                    //                    {
+                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                    //
+                    //
+                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                    //                        iv.image = img;
+                    //                        //                        [self.contentView addSubview:iv];
+                    //                        self.shopCartBlock(iv);
+                    //
+                    //                    }
+                    
+                }
             }
-        }
-        else
-        {
-            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-        }
+            else
+            {
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+            }
+        }];
+        
         
         
         
@@ -921,9 +923,84 @@
             {
                 
                 NSDictionary* return_json=result;
-                [waitalert dismissViewControllerAnimated:YES completion:nil];
+                [waitalert dismissViewControllerAnimated:YES completion:^{
+                    self.addCartBtn.enabled = true;
+                    
+                    if([[return_json valueForKey:@"result"] intValue]==2)
+                    {
+                        
+                        
+                        
+#ifdef RA_NOTIFICATION
+                        [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+#endif
+                        NSString * msg = nil;
+                        
+                        if (self.addAll) {
+                            
+                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            
+                            msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
+                        } else {
+                            
+                            if(checked.count==1)
+                            {
+                                msg=@"1 item added to Cart";
+                            }
+                            else
+                            {
+                                msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
+                            }
+                        }
+                        
+                        [RAUtils message_alert:nil title:msg controller:self] ;
+                        
+                        [self end_select:2];
+                        
+                        
+                        
+                        //                }
+                    }
+                    else  if([[return_json valueForKey:@"result"] intValue]==8)
+                    {
+                        
+                        
+#ifdef RA_NOTIFICATION
+                        [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                        //                    appDelegate.order_code = order_code;
+                        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+#endif
+                        [self end_select:2];
+                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                    }
+                    else
+                    {
+                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+                    }
+                }];
+                
+                
                 
                 
+                
+                
+                
+            };
+        }];
+    }
+    else
+    {
+        [RANetwork request_addto_cart_byname:ids withScreen:ScreenCodeSearch completionHandler:^(NSMutableDictionary *result) {
+            
+            NSDictionary* return_json=result;
+            [waitalert dismissViewControllerAnimated:YES completion:^{
                 self.addCartBtn.enabled = true;
                 
                 if([[return_json valueForKey:@"result"] intValue]==2)
@@ -985,81 +1062,10 @@
                     [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
                 }
                 
-                
-                
-                
-            };
-        }];
-    }
-    else
-    {
-        [RANetwork request_addto_cart_byname:ids withScreen:ScreenCodeSearch completionHandler:^(NSMutableDictionary *result) {
+            }];
             
-            NSDictionary* return_json=result;
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
             
             
-            self.addCartBtn.enabled = true;
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                
-                
-                
-#ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-#else
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-#endif
-                NSString * msg = nil;
-                
-                if (self.addAll) {
-                    
-                    unsigned long checkedCount = [return_json[@"count"] integerValue];
-                    
-                    msg=[NSString stringWithFormat:@"%lu items added to Cart",checkedCount];
-                } else {
-                    
-                    if(checked.count==1)
-                    {
-                        msg=@"1 item added to Cart";
-                    }
-                    else
-                    {
-                        msg=[NSString stringWithFormat:@"%lu items added to Cart",(unsigned long)checked.count];
-                    }
-                }
-                
-                [RAUtils message_alert:nil title:msg controller:self] ;
-                
-                [self end_select:2];
-                
-                
-                
-                //                }
-            }
-            else  if([[return_json valueForKey:@"result"] intValue]==8)
-            {
-                
-                
-#ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-#else
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                //                    appDelegate.order_code = order_code;
-                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-#endif
-                [self end_select:2];
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-            }
-            else
-            {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-            }
-            
             
             
             
@@ -1206,54 +1212,56 @@
     if (self.addAll) {
         [RANetwork request_addall_search:self.offset limit:20 keywords:self.keywords matchfull:self.loadmore_matchfull orderCode:nil addTo:@"portfolio" completionHandler:^(NSMutableDictionary *result) {
             NSMutableDictionary* return_json = result;
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
-            self.addPortfolioBtn.enabled =true;
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                
-                
-                
-                
-                
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                self.addPortfolioBtn.enabled =true;
                 
+                if([[return_json valueForKey:@"result"] intValue]==2)
+                {
+                    
+                    
+                    
+                    
+                    
+                    
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                [((MainViewController*)appDelegate.main_vc) reloadPortfolio :true immediately:false];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    [((MainViewController*)appDelegate.main_vc) reloadPortfolio :true immediately:false];
 #endif
-                
-                NSString * msg = nil;
-                
-                if (self.addAll) {
-                    
-                    unsigned long checkedCount = [return_json[@"count"] integerValue];
                     
-                    msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
-                } else {
+                    NSString * msg = nil;
                     
-                    if(checked.count==1)
-                    {
-                        msg=@"1 item added to Portfolio";
-                    }
-                    else
-                    {
-                        msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                    if (self.addAll) {
+                        
+                        unsigned long checkedCount = [return_json[@"count"] integerValue];
+                        
+                        msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
+                    } else {
+                        
+                        if(checked.count==1)
+                        {
+                            msg=@"1 item added to Portfolio";
+                        }
+                        else
+                        {
+                            msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                        }
                     }
+                    
+                    [RAUtils message_alert:nil title:msg controller:self] ;
+                    
+                    
+                    [self end_select:3];
+                    
                 }
-                
-                [RAUtils message_alert:nil title:msg controller:self] ;
-                
-                
-                [self end_select:3];
-                
-            }
-            else
-            {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
-            }
+                else
+                {
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
+                }
+            }];
+            
+            
             
             
             
@@ -1262,54 +1270,56 @@
     } else {
         [RANetwork request_addto_portfolio:ids withScreen:ScreenCodeSearch completionHandler:^(NSMutableDictionary *result) {
             NSMutableDictionary* return_json = result;
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
-            self.addPortfolioBtn.enabled =true;
-            
-            if([[return_json valueForKey:@"result"] intValue]==2)
-            {
-                
-                
-                
-                
-                
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                self.addPortfolioBtn.enabled =true;
                 
+                if([[return_json valueForKey:@"result"] intValue]==2)
+                {
+                    
+                    
+                    
+                    
+                    
+                    
 #ifdef RA_NOTIFICATION
-                [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                    [ActiveViewController Notify:@"PortfolioViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                [((MainViewController*)appDelegate.main_vc) reloadPortfolio :true immediately:false];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    [((MainViewController*)appDelegate.main_vc) reloadPortfolio :true immediately:false];
 #endif
-                
-                NSString * msg = nil;
-                
-                if (self.addAll) {
-                    
-                    unsigned long checkedCount = [return_json[@"count"] integerValue];
                     
-                    msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
-                } else {
+                    NSString * msg = nil;
                     
-                    if(checked.count==1)
-                    {
-                        msg=@"1 item added to Portfolio";
-                    }
-                    else
-                    {
-                        msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                    if (self.addAll) {
+                        
+                        unsigned long checkedCount = [return_json[@"count"] integerValue];
+                        
+                        msg=[NSString stringWithFormat:@"%lu items added to Portfolio",checkedCount];
+                    } else {
+                        
+                        if(checked.count==1)
+                        {
+                            msg=@"1 item added to Portfolio";
+                        }
+                        else
+                        {
+                            msg=[NSString stringWithFormat:@"%lu items added to Portfolio",(unsigned long)checked.count];
+                        }
                     }
+                    
+                    [RAUtils message_alert:nil title:msg controller:self] ;
+                    
+                    
+                    [self end_select:3];
+                    
                 }
-                
-                [RAUtils message_alert:nil title:msg controller:self] ;
-                
-                
-                [self end_select:3];
-                
-            }
-            else
-            {
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
-            }
+                else
+                {
+                    [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Portfolio" controller:self] ;
+                }
+            }];
+            
+            
             
             
             
@@ -1432,53 +1442,55 @@
                 [RANetwork request_addall_search:self.offset limit:20 keywords:self.keywords matchfull:self.loadmore_matchfull orderCode:nil addTo:@"wishlist" completionHandler:^(NSMutableDictionary *result) {
                     NSDictionary* return_json =result;
                     //            [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    
-                    self.addWishBtn.enabled =true;
-                    
-                    if([[return_json valueForKey:@"result"] intValue]==2)
-                    {
-                        
-                        
-                        
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
+                        self.addWishBtn.enabled =true;
                         
+                        if([[return_json valueForKey:@"result"] intValue]==2)
+                        {
+                            
+                            
+                            
+                            
 #ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                            [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        
-                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
-#endif
-                        
-                        NSString * msg = nil;
-                        
-                        if (self.addAll) {
+                            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                             
-                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+#endif
                             
-                            msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
-                        } else {
+                            NSString * msg = nil;
                             
-                            if(checked.count==1)
-                            {
-                                msg=@"1 item added to \nWish List";
-                            }
-                            else
-                            {
-                                msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+                            if (self.addAll) {
+                                
+                                unsigned long checkedCount = [return_json[@"count"] integerValue];
+                                
+                                msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
+                            } else {
+                                
+                                if(checked.count==1)
+                                {
+                                    msg=@"1 item added to \nWish List";
+                                }
+                                else
+                                {
+                                    msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+                                }
                             }
+                            
+                            [RAUtils message_alert:nil title:@" Multiple items added to \nWish List" controller:self] ;
+                            
+                            
+                            [self end_select:1];
+                            
                         }
-                        
-                        [RAUtils message_alert:nil title:@" Multiple items added to \nWish List" controller:self] ;
-                        
-                        
-                        [self end_select:1];
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
-                    }
+                        else
+                        {
+                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
+                        }
+                    }];
+                    
+                    
                     
                     
                     
@@ -1489,53 +1501,55 @@
                 [RANetwork request_addto_wishlist:ids withScreen:ScreenCodeSearch completionHandler:^(NSMutableDictionary *result) {
                     NSDictionary* return_json =result;
                     //            [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    [waitalert dismissViewControllerAnimated:YES completion:nil];
-                    
-                    self.addWishBtn.enabled =true;
-                    
-                    if([[return_json valueForKey:@"result"] intValue]==2)
-                    {
-                        
-                        
-                        
+                    [waitalert dismissViewControllerAnimated:YES completion:^{
+                        self.addWishBtn.enabled =true;
                         
+                        if([[return_json valueForKey:@"result"] intValue]==2)
+                        {
+                            
+                            
+                            
+                            
 #ifdef RA_NOTIFICATION
-                        [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                            [ActiveViewController Notify:@"WatchListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        
-                        [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
-#endif
-                        
-                        NSString * msg = nil;
-                        
-                        if (self.addAll) {
+                            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                             
-                            unsigned long checkedCount = [return_json[@"count"] integerValue];
+                            [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
+#endif
                             
-                            msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
-                        } else {
+                            NSString * msg = nil;
                             
-                            if(checked.count==1)
-                            {
-                                msg=@"1 item added to \nWish List";
-                            }
-                            else
-                            {
-                                msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+                            if (self.addAll) {
+                                
+                                unsigned long checkedCount = [return_json[@"count"] integerValue];
+                                
+                                msg=[NSString stringWithFormat:@"%lu items added to \nWish List",checkedCount];
+                            } else {
+                                
+                                if(checked.count==1)
+                                {
+                                    msg=@"1 item added to \nWish List";
+                                }
+                                else
+                                {
+                                    msg=[NSString stringWithFormat:@"%lu items added to \nWish List",(unsigned long)checked.count];
+                                }
                             }
+                            
+                            [RAUtils message_alert:nil title:@" Multiple items added to \nWish List" controller:self] ;
+                            
+                            
+                            [self end_select:1];
+                            
                         }
-                        
-                        [RAUtils message_alert:nil title:@" Multiple items added to \nWish List" controller:self] ;
-                        
-                        
-                        [self end_select:1];
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
-                    }
+                        else
+                        {
+                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Wish List" controller:self] ;
+                        }
+                    }];
+                    
+                    
                     
                     
                     
@@ -1976,7 +1990,7 @@
         // what ever you want to prepare
     } completion:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
         
-        
+        self.headerView.layer.shadowPath =[UIBezierPath bezierPathWithRect:self.headerView.bounds].CGPath;
             self.toOrientation = [UIApplication sharedApplication].statusBarOrientation;
         [self.collectionview.collectionViewLayout invalidateLayout];
     }];

+ 12 - 10
RedAnt ERP Mobile/common/Functions/sidemenu/CacheViewController.m

@@ -131,16 +131,18 @@
 //    [self.mum stopAnimating];
     
     
-    [alert dismissViewControllerAnimated:YES completion:nil];
-//     [alert dismissWithClickedButtonIndex:0 animated:FALSE];
-    
-    [self.mum startAnimating];
-    float size=[RAUtils fileSizeForDir:cachefolder];
-    // float size1=[RAUtils fileSizeForDir:img_cache];
-    
-    self.sizeLabel.text = [NSString stringWithFormat:@"Cache size: %.2f MB",size];
-    
-    [self.mum stopAnimating];
+    [alert dismissViewControllerAnimated:YES completion:^{
+        //     [alert dismissWithClickedButtonIndex:0 animated:FALSE];
+        
+        [self.mum startAnimating];
+        float size=[RAUtils fileSizeForDir:cachefolder];
+        // float size1=[RAUtils fileSizeForDir:img_cache];
+        
+        self.sizeLabel.text = [NSString stringWithFormat:@"Cache size: %.2f MB",size];
+        
+        [self.mum stopAnimating];
+    }];
+
     
 }
 

+ 164 - 159
RedAnt ERP Mobile/common/Functions/sidemenu/LoginViewController.m

@@ -198,9 +198,11 @@
 }
 - (IBAction)CloseClick:(id)sender {
     
-    [self dismissViewControllerAnimated:true completion:nil];
-    if(self.returnValue)
-        self.returnValue(false);
+    [self dismissViewControllerAnimated:true completion:^{
+        if(self.returnValue)
+            self.returnValue(false);
+    }];
+
     
     
     
@@ -259,198 +261,201 @@
     
     
     [RANetwork request_login:user password:password completionHandler:^(NSMutableDictionary *result) {
-        int ret=[result[@"result"] intValue];
         
-        [waitalert dismissViewControllerAnimated:true completion:nil];
-        
-//        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        self.btnLogin.enabled = true;
         
-        if(ret==RESULT_TRUE)
-            
-        {
-            
-            //
-            //                NSString* contactid=[self.content_data[indexPath.row] valueForKey:@"contact_id"] ;
-            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-            //                appDelegate.contact_id=contactid;
-            //                appDelegate.contact_name =[self.content_data[indexPath.row] valueForKey:@"name"];
+        [waitalert dismissViewControllerAnimated:true completion:^{
+            int ret=[result[@"result"] intValue];
+            self.btnLogin.enabled = true;
             
-            NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
-            [defaults removeObjectForKey:@"user"];
-            [defaults removeObjectForKey:@"password"];
-            NSString* encryptu=[AESCrypt encrypt:appDelegate.user password:@"usai"];
-            NSString* encryptp=[AESCrypt encrypt:self.editpass.text password:@"usai"] ;
-            if(self.checkSavePassword.selected)
-            {
+            if(ret==RESULT_TRUE)
                 
-                [defaults setValue:encryptu forKey:@"user"];
-                [defaults setValue:encryptp forKey:@"password"];
-                sqlite3 *db = [iSalesDB get_db];
+            {
                 
-                int count =[iSalesDB get_recordcount:db table:@"login_info" where:[NSString stringWithFormat:@"name='%@'",encryptu]];
+                //
+                //                NSString* contactid=[self.content_data[indexPath.row] valueForKey:@"contact_id"] ;
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                //                appDelegate.contact_id=contactid;
+                //                appDelegate.contact_name =[self.content_data[indexPath.row] valueForKey:@"name"];
                 
-                if(count==0)
+                NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+                [defaults removeObjectForKey:@"user"];
+                [defaults removeObjectForKey:@"password"];
+                NSString* encryptu=[AESCrypt encrypt:appDelegate.user password:@"usai"];
+                NSString* encryptp=[AESCrypt encrypt:self.editpass.text password:@"usai"] ;
+                if(self.checkSavePassword.selected)
                 {
                     
-                    NSString * savelogin=[NSString stringWithFormat:@"insert into login_info(name,pwd) values('%@','%@')",encryptu,encryptp];
-                    [iSalesDB execSql:savelogin db:db];
+                    [defaults setValue:encryptu forKey:@"user"];
+                    [defaults setValue:encryptp forKey:@"password"];
+                    sqlite3 *db = [iSalesDB get_db];
+                    
+                    int count =[iSalesDB get_recordcount:db table:@"login_info" where:[NSString stringWithFormat:@"name='%@'",encryptu]];
+                    
+                    if(count==0)
+                    {
+                        
+                        NSString * savelogin=[NSString stringWithFormat:@"insert into login_info(name,pwd) values('%@','%@')",encryptu,encryptp];
+                        [iSalesDB execSql:savelogin db:db];
+                    }
+                    else
+                    {
+                        NSString * savelogin=[NSString stringWithFormat:@"update login_info set pwd='%@' where name='%@'",encryptp,encryptu];
+                        [iSalesDB execSql:savelogin db:db];
+                    }
+                    
+                    [iSalesDB close_db:db];
+                    
+                    //                    [defaults setBool:TRUE forKey:@"autologin"];
                 }
                 else
                 {
-                    NSString * savelogin=[NSString stringWithFormat:@"update login_info set pwd='%@' where name='%@'",encryptp,encryptu];
-                    [iSalesDB execSql:savelogin db:db];
+                    NSString* sql=[NSString stringWithFormat:@"delete from login_info where name='%@'",encryptu];
+                    [iSalesDB execSql:sql];
                 }
+                [defaults synchronize];
                 
-                [iSalesDB close_db:db];
-                
-                //                    [defaults setBool:TRUE forKey:@"autologin"];
-            }
-            else
-            {
-                NSString* sql=[NSString stringWithFormat:@"delete from login_info where name='%@'",encryptu];
-                [iSalesDB execSql:sql];
-            }
-            [defaults synchronize];
-            
-            [self dismissViewControllerAnimated:YES completion:^{
-                
-                NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
-                
-                bool offline_dirty=[defaults boolForKey:@"OFFLINE_DIRTY"];
-                sqlite3* db = [iSalesDB get_db];
-                int offline_user_exist=[iSalesDB get_recordcount:db table:@"offline_login" where:[NSString stringWithFormat:@"username='%@'",appDelegate.user ]];
-                
-                [iSalesDB close_db:db];
-                
-                
-                BOOL condition = offline_dirty && offline_user_exist>0;
-                
-#ifdef OFFLINE_MODE
-                condition = condition && !appDelegate.offline_mode;
-#endif
-                if(condition)
-                {
+                [self dismissViewControllerAnimated:YES completion:^{
                     
-                    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Detected new offline data" message:@"Do you want to sync with server?" preferredStyle:UIAlertControllerStyleAlert];
-                    //block代码块取代了delegate
+                    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
                     
+                    bool offline_dirty=[defaults boolForKey:@"OFFLINE_DIRTY"];
+                    sqlite3* db = [iSalesDB get_db];
+                    int offline_user_exist=[iSalesDB get_recordcount:db table:@"offline_login" where:[NSString stringWithFormat:@"username='%@'",appDelegate.user ]];
                     
-                    UIAlertAction *actionTwo = [UIAlertAction actionWithTitle:@"Yes(Recommended)" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-                        
-                        
-                        
-                        
-                        UIApplication * app = [UIApplication sharedApplication];
-                        AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-                        //UIViewController* active_vc = appDelegate.active_controller;
-                        OfflineSettingViewController * offlineVC =[ [UIStoryboard storyboardWithName:@"OLM" bundle:nil] instantiateViewControllerWithIdentifier:@"OfflineSettingViewController"];
-                        //    loginvc.delegate = self;
-                        //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-                        //       appDelegate.active_controller = gunVC;
-                        //        gunVC.onDismissVC = ^(){
-                        //            appDelegate.active_controller = active_vc;
-                        //        };
-                        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:offlineVC] ;
-                        
-                        
-                        
+                    [iSalesDB close_db:db];
+                    
+                    
+                    BOOL condition = offline_dirty && offline_user_exist>0;
+                    
+#ifdef OFFLINE_MODE
+                    condition = condition && !appDelegate.offline_mode;
+#endif
+                    if(condition)
+                    {
                         
+                        UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Detected new offline data" message:@"Do you want to sync with server?" preferredStyle:UIAlertControllerStyleAlert];
+                        //block代码块取代了delegate
                         
-                        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
                         
-                        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
-                        [appDelegate.main_vc presentViewController:navi animated:YES completion:^{
+                        UIAlertAction *actionTwo = [UIAlertAction actionWithTitle:@"Yes(Recommended)" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                            
+                            
+                            
+                            
+                            UIApplication * app = [UIApplication sharedApplication];
+                            AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+                            //UIViewController* active_vc = appDelegate.active_controller;
+                            OfflineSettingViewController * offlineVC =[ [UIStoryboard storyboardWithName:@"OLM" bundle:nil] instantiateViewControllerWithIdentifier:@"OfflineSettingViewController"];
+                            //    loginvc.delegate = self;
+                            //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
+                            //       appDelegate.active_controller = gunVC;
+                            //        gunVC.onDismissVC = ^(){
+                            //            appDelegate.active_controller = active_vc;
+                            //        };
+                            UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:offlineVC] ;
                             
                             
-                            MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
                             
-                            [main_vc checklogin:true];
-                            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
                             
-                            DebugLog(@"about present.........");
                             
-                            //   self.btop = false;
-                            //  <#code#>
+                            //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
+                            
+                            navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
+                            [appDelegate.main_vc presentViewController:navi animated:YES completion:^{
+                                
+                                
+                                MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+                                
+                                [main_vc checklogin:true];
+                                //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
+                                
+                                DebugLog(@"about present.........");
+                                
+                                //   self.btop = false;
+                                //  <#code#>
+                            }];
+                            
+                            
+                            
+                            
                         }];
                         
+                        UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+                            
+                            if(self.returnValue)
+                                self.returnValue(true);
+                            [[NSNotificationCenter defaultCenter] postNotificationName:LoginOK_HandleUrgencyFile_Notification object:nil];
+                            
+                        }];
                         
+                        [alertControl addAction:actionTwo];
+                        [alertControl addAction:alertthree];
                         
                         
-                    }];
-                    
-                    UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                         
+                        [appDelegate.main_vc presentViewController:alertControl animated:YES completion:nil];
+                        
+                        
+                        
+                        
+                    }
+                    else
+                    {
                         if(self.returnValue)
                             self.returnValue(true);
                         [[NSNotificationCenter defaultCenter] postNotificationName:LoginOK_HandleUrgencyFile_Notification object:nil];
+                    }
+                }];
+                
+                
+                
+                //                if (self.delegate && [self.delegate respondsToSelector:@selector(LoginViewControllerDidLogin:)]) {
+                //                    [self.delegate LoginViewControllerDidLogin:self];
+                //                }
+                
+                [[NSNotificationCenter defaultCenter] postNotificationName:User_LoginOK_Notification object:nil];
+            }
+            else
+            {
+                NSString* msg=nil;
+                
+                switch (ret) {
                         
-                    }];
-                    
-                    [alertControl addAction:actionTwo];
-                    [alertControl addAction:alertthree];
-                    
-                    
-                    
-                    [appDelegate.main_vc presentViewController:alertControl animated:YES completion:nil];
-                    
-                    
-                    
-                    
-                }
-                else
-                {
-                    if(self.returnValue)
-                        self.returnValue(true);
-                    [[NSNotificationCenter defaultCenter] postNotificationName:LoginOK_HandleUrgencyFile_Notification object:nil];
+                    case RESULT_NET_NOTAVAILABLE:
+                        msg = MSG_NET_NOTAVAILABLE;
+                        break;
+                        
+                        
+                    case RESULT_NET_ERROR:
+                        msg = MSG_NET_ERROR;
+                        break;
+                        
+                        
+                    case RESULT_FALSE:
+                        msg = MSG_USERAUTH_ERROR;
+                        break;
+                        
+                    case RESULT_VER_LOW:
+                        msg = MSG_VER_LOW;
+                        break;
+                        
+                    case RESULT_LOGIN_DEVICE:
+                        msg= MSG_LOGIN_DEVICE;
+                        break;
+                    default:
+                        break;
                 }
-            }];
-            
-            
-            
-            //                if (self.delegate && [self.delegate respondsToSelector:@selector(LoginViewControllerDidLogin:)]) {
-            //                    [self.delegate LoginViewControllerDidLogin:self];
-            //                }
-            
-            [[NSNotificationCenter defaultCenter] postNotificationName:User_LoginOK_Notification object:nil];
-        }
-        else
-        {
-            NSString* msg=nil;
-            
-            switch (ret) {
-                    
-                case RESULT_NET_NOTAVAILABLE:
-                    msg = MSG_NET_NOTAVAILABLE;
-                    break;
-                    
-                    
-                case RESULT_NET_ERROR:
-                    msg = MSG_NET_ERROR;
-                    break;
-                    
-                    
-                case RESULT_FALSE:
-                    msg = MSG_USERAUTH_ERROR;
-                    break;
-                    
-                case RESULT_VER_LOW:
-                    msg = MSG_VER_LOW;
-                    break;
-                    
-                case RESULT_LOGIN_DEVICE:
-                    msg= MSG_LOGIN_DEVICE;
-                    break;
-                default:
-                    break;
+                
+                [RAUtils message_alert:msg title:@"Cannot sign-in" controller:self];
+                //            [RAUtils alert_view:msg title:@"Cannot sign-in"];
+                
+                
+                
             }
-            
-            [RAUtils message_alert:msg title:@"Cannot sign-in" controller:self];
-//            [RAUtils alert_view:msg title:@"Cannot sign-in"];
-            
-            
-            
-        }
+        }];
+        
+//        [waitalert dismissViewControllerAnimated:YES completion:nil];
+
         
         
         

+ 41 - 20
RedAnt ERP Mobile/common/Functions/sidemenu/RetrievePassViewController.m

@@ -47,31 +47,52 @@
     
     self.buttonRetrieve.enabled = false;
     
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    [RANetwork request_retrieve_password:user email:email completionHandler:^(NSMutableDictionary *result) {
         
+        NSDictionary* json=result;
+        self.buttonRetrieve.enabled = true;
         
-        NSDictionary* json=[RANetwork  retrieve_password:user email:email];
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
+        if([[json valueForKey:@"result"] intValue]==2)
+        {
             
-            self.buttonRetrieve.enabled = true;
+            [RAUtils message_alert:@"Please Check email later." title:@"Successful!" controller:self];
             
-            if([[json valueForKey:@"result"] intValue]==2)
-            {
-                
-                [RAUtils message_alert:@"Please Check email later." title:@"Successful!" controller:self];
-                
-//        UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Successful!" message:@"Please Check email later." delegate:nil cancelButtonTitle:NSLocalizedString(@"ok", nil) otherButtonTitles:nil, nil];
-//             [alert show];
-                
-            }
-            else
-            {
-                [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Retrieve Password" controller:self] ;
-            }
+            //        UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Successful!" message:@"Please Check email later." delegate:nil cancelButtonTitle:NSLocalizedString(@"ok", nil) otherButtonTitles:nil, nil];
+            //             [alert show];
             
-        });
-    });
+        }
+        else
+        {
+            [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Retrieve Password" controller:self] ;
+        }
+        
+    }];
+    
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//
+//
+//        NSDictionary* json=[RANetwork  retrieve_password:user email:email];
+//
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//
+//            self.buttonRetrieve.enabled = true;
+//
+//            if([[json valueForKey:@"result"] intValue]==2)
+//            {
+//
+//                [RAUtils message_alert:@"Please Check email later." title:@"Successful!" controller:self];
+//
+////        UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Successful!" message:@"Please Check email later." delegate:nil cancelButtonTitle:NSLocalizedString(@"ok", nil) otherButtonTitles:nil, nil];
+////             [alert show];
+//
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Retrieve Password" controller:self] ;
+//            }
+//
+//        });
+//    });
     
 
 }

+ 5 - 3
RedAnt ERP Mobile/common/Functions/sidemenu/ScannerSettingViewController.m

@@ -36,9 +36,11 @@
 
 - (void)onCloseClick:(UIButton *)sender {
     
-    if(self.onDismissVC)
-        self.onDismissVC();
-    [self dismissViewControllerAnimated:true completion:nil];
+
+    [self dismissViewControllerAnimated:true completion:^{
+            if(self.onDismissVC)
+            self.onDismissVC();
+    }];
 }
 
 

+ 75 - 73
RedAnt ERP Mobile/common/Functions/sidemenu/UserListViewController.m

@@ -155,88 +155,90 @@
                 int ret=[result[@"result"]intValue];
                 
                 
-                [waitalert dismissViewControllerAnimated:YES completion:nil];
-//                [waitalert dismissViewControllerAnimated:YES completion:nil];
-                
-                if(ret==RESULT_TRUE)
-                {
-                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                    
-                    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
-                    [defaults removeObjectForKey:@"user"];
-                    [defaults removeObjectForKey:@"password"];
-                    if(true)
+                [waitalert dismissViewControllerAnimated:YES completion:^{
+                    if(ret==RESULT_TRUE)
                     {
-                        NSString* encryptu=[AESCrypt encrypt:appDelegate.user password:@"usai"];
-                        NSString* encryptp=[AESCrypt encrypt:appDelegate.password password:@"usai"] ;
+                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                         
-                        [defaults setValue:encryptu forKey:@"user"];
-                        [defaults setValue:encryptp forKey:@"password"];
-                        
-                    }
-                    [defaults synchronize];
-                    
-                    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-                    if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
-                    {
-                        [main_vc checklogin:false];
-                    }
-                    else
-                    {
-                        [main_vc checklogin:false];
-                    }
-                    
-                    [self dismissViewControllerAnimated:true completion:^{
-                        if(self.returnValue)
-                            self.returnValue(true);
-                    }];
-                    
-                } // 登陆成功
-                else
-                {
-                    NSString* msg=nil;
-                    
-                    switch (ret) {
-                            
-                        case RESULT_NET_NOTAVAILABLE:
-                            msg = MSG_NET_NOTAVAILABLE;
-                            break;
+                        NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+                        [defaults removeObjectForKey:@"user"];
+                        [defaults removeObjectForKey:@"password"];
+                        if(true)
+                        {
+                            NSString* encryptu=[AESCrypt encrypt:appDelegate.user password:@"usai"];
+                            NSString* encryptp=[AESCrypt encrypt:appDelegate.password password:@"usai"] ;
                             
+                            [defaults setValue:encryptu forKey:@"user"];
+                            [defaults setValue:encryptp forKey:@"password"];
                             
-                        case RESULT_NET_ERROR:
-                            msg = MSG_NET_ERROR;
-                            break;
-                            
-                            
-                        case RESULT_FALSE:
-                            msg = MSG_USERAUTH_ERROR;
-                            break;
-                            
-                        case RESULT_VER_LOW:
-                            msg = MSG_VER_LOW;
-                            break;
-                        default:
-                            break;
-                    }
-                    
-                    
-                    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Switch User" message:msg preferredStyle:UIAlertControllerStyleAlert];
-                    //block代码块取代了delegate
-                    UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                        }
+                        [defaults synchronize];
+                        
+                        MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+                        if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
+                        {
+                            [main_vc checklogin:false];
+                        }
+                        else
+                        {
+                            [main_vc checklogin:false];
+                        }
                         
                         [self dismissViewControllerAnimated:true completion:^{
                             if(self.returnValue)
-                                self.returnValue(false);
+                                self.returnValue(true);
+                        }];
+                        
+                    } // 登陆成功
+                    else
+                    {
+                        NSString* msg=nil;
+                        
+                        switch (ret) {
+                                
+                            case RESULT_NET_NOTAVAILABLE:
+                                msg = MSG_NET_NOTAVAILABLE;
+                                break;
+                                
+                                
+                            case RESULT_NET_ERROR:
+                                msg = MSG_NET_ERROR;
+                                break;
+                                
+                                
+                            case RESULT_FALSE:
+                                msg = MSG_USERAUTH_ERROR;
+                                break;
+                                
+                            case RESULT_VER_LOW:
+                                msg = MSG_VER_LOW;
+                                break;
+                            default:
+                                break;
+                        }
+                        
+                        
+                        UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Switch User" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                        //block代码块取代了delegate
+                        UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                            
+                            [self dismissViewControllerAnimated:true completion:^{
+                                if(self.returnValue)
+                                    self.returnValue(false);
+                            }];
+                            
                         }];
                         
-                    }];
-                    
-                    
-                    [alertControl addAction:actionOne];
-                    
-                    [self presentViewController:alertControl animated:YES completion:nil];
-                    
-                } // 登陆失败
+                        
+                        [alertControl addAction:actionOne];
+                        
+                        [self presentViewController:alertControl animated:YES completion:nil];
+                        
+                    } // 登陆失败
+                }];
+//                [waitalert dismissViewControllerAnimated:YES completion:nil];
+                
+                
                 
                 
             }];

+ 4 - 2
RedAnt ERP Mobile/common/Functions/signature/SignatureViewController.m

@@ -237,10 +237,12 @@
     if (self.Signaturedelegate && [self.Signaturedelegate respondsToSelector:@selector(SignatureVCReturnData:indexPath:)]) {
         [self.Signaturedelegate SignatureVCReturnData:data indexPath:self.indexPath];
     }
+
+    
+    
+    [self.navigationController popViewControllerAnimated:true];
     if(self.onReturnImg)
         self.onReturnImg(img);
-    [self.navigationController popViewControllerAnimated:true];
-    
     //    [self.aBNewPersonNav dismissViewControllerAnimated:true completion:^{
     //        ;
     //    }];

+ 55 - 45
RedAnt ERP Mobile/common/Functions/watchlist/WatchListViewController.m

@@ -336,33 +336,35 @@
     [RANetwork request_create_order:^(NSMutableDictionary *result) {
         NSMutableDictionary* return_json =result;
         
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-//        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-        
-        if([[return_json valueForKey:@"result"] intValue]==2)
-        {
-            int result=[[return_json valueForKey:@"result"] intValue];
-            if(result==2)
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            //        [waitalert dismissViewControllerAnimated:YES completion:nil];
+            
+            
+            if([[return_json valueForKey:@"result"] intValue]==2)
             {
-                //successed.
-                
-                NSString* order_code = [return_json valueForKey:@"orderCode"];
-                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                appDelegate.order_code = order_code;
-                appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-                
-                [self addtocart];
-                
+                int result=[[return_json valueForKey:@"result"] intValue];
+                if(result==2)
+                {
+                    //successed.
+                    
+                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    appDelegate.order_code = order_code;
+                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+                    
+                    [self addtocart];
+                    
 
-                
+                    
+                }
             }
-        }
-        else
-        {
-            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-        }
+            else
+            {
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+            }
+        }];
+        
+
         
         
         
@@ -538,17 +540,21 @@
     
     //    NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
     NSString * string = [checked componentsJoinedByString:@","];
+    UIAlertController* wait_alert = [RAUtils waiting_alert:self title:@"Remove Models From Wishlist"];
     [RANetwork request_remove_wishlist:string completionHandler:^(NSMutableDictionary *result) {
         NSMutableDictionary* cart_json = result;
-        if([[cart_json valueForKey:@"result"] intValue]==2)
-        {
-            [self reload_data];
-            [self.btnselect setTitle:@"Select all"];
-        }
-        else
-        {
-            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Remove Model From Wish List" controller:self] ;
-        }
+        [wait_alert dismissViewControllerAnimated:YES completion:^{
+            if([[cart_json valueForKey:@"result"] intValue]==2)
+            {
+                [self reload_data];
+                [self.btnselect setTitle:@"Select all"];
+            }
+            else
+            {
+                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Remove Model From Wish List" controller:self] ;
+            }
+        }];
+
         
     }];
 //    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@@ -1006,21 +1012,23 @@
                      NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
                      
                      NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]];
-                     
+                     UIAlertController* wait_alert = [RAUtils waiting_alert:self title:@"Remove Model"];
                      [RANetwork request_remove_wishlist:ids completionHandler:^(NSMutableDictionary *result) {
                          NSMutableDictionary* cart_json = result;
                          
                          
+                         [wait_alert dismissViewControllerAnimated:YES completion:^{
+                             if([[cart_json valueForKey:@"result"] intValue]==2)
+                             {
+                                 [self reload_data];
+                             }
+                             else
+                             {
+                                 [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
+                             }
+                         }];
                          
-                         
-                         if([[cart_json valueForKey:@"result"] intValue]==2)
-                         {
-                             [self reload_data];
-                         }
-                         else
-                         {
-                             [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Delete Model" controller:self] ;
-                         }
+
                          
                          
                      }];
@@ -1444,8 +1452,8 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
                     DebugLog(@"email wishlist result: %@",result);
                     
                         
-                    [waitting_alert dismissViewControllerAnimated:YES completion:nil];
-//                        [waitting_alert dismissWithClickedButtonIndex:0 animated:YES];
+                    [waitting_alert dismissViewControllerAnimated:YES completion:^{
+                        //                        [waitting_alert dismissWithClickedButtonIndex:0 animated:YES];
                         
                         if ([[result objectForKey:@"result"] integerValue] != RESULT_TRUE) {
                             
@@ -1462,6 +1470,8 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
                             [RAUtils message_alert:nil title:@"Email was sent successfully" controller:weakself];
                             
                         }
+                    }];
+
                         
                     
                 }];

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

@@ -125,11 +125,9 @@
             NSDictionary *dic = result;
 
         //    [waitalert dismissWithClickedButtonIndex:0 animated:YES];
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
-            
+        [waitalert dismissViewControllerAnimated:YES completion:^{
             if ([[dic objectForKey:@"result"] integerValue] == 2) {
-            
+                
                 CategoryPriceViewController *categoryPriceVC =[ [UIStoryboard storyboardWithName:@"CUL" bundle:nil] instantiateViewControllerWithIdentifier:@"CategoryPriceViewController"];
                 
                 categoryPriceVC.categoryGivenPrice = dic.mutableCopy;
@@ -144,6 +142,10 @@
                 [RAUtils message_alert:msg title:@"Set Store Price" controller:self];
                 
             };
+        }];
+            
+            
+
     }];
     
 //    NSDictionary *dic = [RANetwork get_npd_shop_givenPrice];
@@ -240,28 +242,30 @@
     
     [RANetwork request_update_npd_shop_price_type:self.priceType completionHandler:^(NSMutableDictionary *result) {
         NSDictionary *dic=result;
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        
-        // 成功
-        if ([[dic objectForKey:@"result"] integerValue] == 2) {
-            
-            [Singleton sharedInstance].npd_shop_price_type = self.priceType;
-            
-            
-            
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            // 成功
+            if ([[dic objectForKey:@"result"] integerValue] == 2) {
+                
+                [Singleton sharedInstance].npd_shop_price_type = self.priceType;
+                
+                
+                
 #ifdef RA_NOTIFICATION
-            [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 #else
-            // 刷新 Cart、Order List
-            [[NSNotificationCenter defaultCenter] postNotificationName:Change_Price_Type_Notification object:nil];
+                // 刷新 Cart、Order List
+                [[NSNotificationCenter defaultCenter] postNotificationName:Change_Price_Type_Notification object:nil];
 #endif
+                
+            } else { // 失败
+                
+                DebugLog(@"set price type failure");
+            }
             
-        } else { // 失败
-            
-            DebugLog(@"set price type failure");
-        }
+            [self dismissViewControllerAnimated:YES completion:nil];;
+        }];
         
-        [self dismissViewControllerAnimated:YES completion:nil];;
+
     }];
     
 //    NSDictionary *dic = [RANetwork set_npd_shop_price_type:self.priceType];

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

@@ -230,20 +230,22 @@
         [RANetwork request_update_npd_shop_givenprice:@{@"base_price" : [NSString stringWithFormat:@"%ld",self.priceType],@"discount" : discount,@"category_id" : @(self.categoryID)}.mutableCopy completionHandler:^(NSMutableDictionary *result) {
             NSDictionary *dic = result;
             
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            //        [waitalert dismissWithClickedButtonIndex:0 animated:YES];
-            
-            if ([[dic objectForKey:@"result"] integerValue] == 2) {
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                //        [waitalert dismissWithClickedButtonIndex:0 animated:YES];
                 
-                [self.categoryPrice setObject:[NSString stringWithFormat:@"%ld",self.priceType] forKey:@"base_price"];
-                [self.categoryPrice setObject:discount forKey:@"price_discount"];
+                if ([[dic objectForKey:@"result"] integerValue] == 2) {
+                    
+                    [self.categoryPrice setObject:[NSString stringWithFormat:@"%ld",self.priceType] forKey:@"base_price"];
+                    [self.categoryPrice setObject:discount forKey:@"price_discount"];
+                    
+                    // 将数据返回
+                    if (self.returnBlock)
+                        self.returnBlock(self.categoryPrice);
+                }
                 
-                // 将数据返回
-                if (self.returnBlock)
-                    self.returnBlock(self.categoryPrice);
-            }
+                [self.navigationController popViewControllerAnimated:YES];
+            }];
             
-            [self.navigationController popViewControllerAnimated:YES];
         }];
         
         //        NSDictionary *dic = [RANetwork set_npd_shop_givenPrice:@{@"base_price" : [NSString stringWithFormat:@"%ld",self.priceType],@"discount" : discount,@"category_id" : @(self.categoryID)}.mutableCopy];

+ 3 - 0
RedAnt ERP Mobile/common/RAUtils.m

@@ -994,6 +994,9 @@ done:
 
 + (CGSize)sizeWithFont:(NSString*)string font:(UIFont *)font constrainedToSize:(CGSize)maxsize lineBreakMode:(NSLineBreakMode)lineBreakMode
 {
+    
+    if(string.length==0)
+        return CGSizeZero;
     // Let's make an NSAttributedString first
     NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
     //Add LineBreakMode

+ 43 - 22
RedAnt ERP Mobile/common/data_provider/RANetwork.h

@@ -60,15 +60,15 @@ extern NSString *const ScreenCodeOfflineSync;
 
 //+(NSDictionary*) add_toPortfolio:(NSString* ) item_id withScreen:(NSString *)screenName;
 //+(NSData*)get_json : (NSString*) url parameters:(NSMutableDictionary *) params;
-//+(int)Authorize : (NSString*) user password:(NSString*) password ;
++(int)Authorize : (NSString*) user password:(NSString*) password ;
 //+(NSDictionary*)logout;
 //+(NSDictionary*)request_Cagegory;
 //+(NSDictionary*)load_HomePage: (int) price_template customid:(int) customid;
-+(NSDictionary*)retrieve_password: (NSString*) user email:(NSString*) email;
+//+(NSDictionary*)retrieve_password: (NSString*) user email:(NSString*) email;
 
 //+(NSDictionary*)request_model_qty: (NSString*) fashionId;
 
-+(NSDictionary*)commoneditor_partialrefresh: (NSMutableDictionary*)params url:(NSString*)url;
+//+(NSDictionary*)commoneditor_partialrefresh: (NSMutableDictionary*)params url:(NSString*)url;
 
 //+(NSDictionary*)Search: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword;
 //+(NSDictionary*)Category: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip ;
@@ -82,18 +82,19 @@ extern NSString *const ScreenCodeOfflineSync;
 
 //+(NSDictionary*) cart_incresement:(NSString*) cart_id increse:(bool) increse;
 //+(NSDictionary*) cart_setQTY:(NSString*) cart_id value:(int) value;
-+(NSDictionary*) cart_setPrice:(NSString*) cart_id price:(float) price discount:(float) discount notes:(NSString*) notes;
-+(NSDictionary*) cart_setFree:(NSString*) cart_id isfree:(bool) isfree;
+//+(NSDictionary*) cart_setPrice:(NSString*) cart_id price:(float) price discount:(float) discount notes:(NSString*) notes;
+//+(NSDictionary*) cart_setFree:(NSString*) cart_id isfree:(bool) isfree;
 
 //+(NSDictionary*) cart_setItemNote:(NSString*) cart_id notes:(NSString*) notes;
 
 //+(NSDictionary*) cart_setGeneralNote:(NSString*) order_code notes:(NSString*) notes;
 
-+(NSDictionary*) check_Offline:(NSString* )ver  useInternalAddress:(bool)buseinternaladdress vid:(NSString*) vid;
-+(NSDictionary*) download_Offline:(NSString* )vid;
-+(NSDictionary*) finish_download_Offline:(NSString* )vid;
+//+(NSDictionary*) check_Offline:(NSString* )ver  useInternalAddress:(bool)buseinternaladdress vid:(NSString*) vid;
+//+(NSDictionary*) download_Offline:(NSString* )vid;
 
-+(NSDictionary*) add_toCart:(NSString* ) item_id count:(int) count name:(NSString *)name;
+//+(NSDictionary*) finish_download_Offline:(NSString* )vid;
+
+//+(NSDictionary*) add_toCart:(NSString* ) item_id count:(int) count name:(NSString *)name;
 //+(NSDictionary*) add_toCart_byName:(NSString* ) model_name withScreen:(NSString *)screenName;
 //+(NSDictionary*) add_toWatchList:(NSString* ) item_id withScreen:(NSString *)screenName;
 //+(NSDictionary*)request_Cart:(int)sort;
@@ -101,7 +102,7 @@ extern NSString *const ScreenCodeOfflineSync;
 //+(NSDictionary*) portfolio_setPrice:(NSString*) watchlist_id price:(float) price discount:(float) discount QTY:(int)qty qty_p:(float) qty_p notes:(NSString*)notes;
 //+(NSDictionary*) portfolio_setQTY:(NSString*) watchlist_id QTY:(int)qty;
 
-//+(NSDictionary*) cart_remove:(NSString* ) item_ids;
++(NSDictionary*) cart_remove:(NSString* ) item_ids;
 //+(NSDictionary*) cart_check:(NSString* ) item_ids;
 //+(NSDictionary*) watchlist_remove:(NSString* ) item_ids;
 
@@ -112,23 +113,23 @@ extern NSString *const ScreenCodeOfflineSync;
 //+(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*)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*)release_Order:(NSString*) order_code withScreen:(NSString *)screenName;
+//+(NSDictionary*)release_Order:(NSString*) order_code withScreen:(NSString *)screenName;
 //+(NSDictionary*)save_Order:(NSMutableDictionary*)params;
-+(NSDictionary*)delete_Order:(NSString*) order_id;
-+(NSDictionary*)cancel_Order:(NSString*) order_id order_code:(NSString*) order_code;
+//+(NSDictionary*)delete_Order:(NSString*) order_id;
+//+(NSDictionary*)cancel_Order:(NSString*) order_id order_code:(NSString*) order_code;
 //+(NSDictionary*)request_PendingOrder:(NSString* ) contactid;
 //+(NSDictionary*)request_CustomerInfo:(NSString* ) contactid;
-+(NSDictionary*)update_customer_img: (NSString*) contactid img_url:(NSString*) url ;
+//+(NSDictionary*)update_customer_img: (NSString*) contactid img_url:(NSString*) url ;
 //+(NSDictionary*) new_Customer;
-+(NSDictionary*)save_newCustomer:(NSMutableDictionary*)params;
-+(NSDictionary*)update_Customer:(NSMutableDictionary*)params;
+//+(NSDictionary*)save_newCustomer:(NSMutableDictionary*)params;
+//+(NSDictionary*)update_Customer:(NSMutableDictionary*)params;
 
-+(NSDictionary*)create_Address:(NSMutableDictionary*)params;
+//+(NSDictionary*)create_Address:(NSMutableDictionary*)params;
 //+(NSDictionary*)request_ContactList:(int) offset limit:(int)limit keywords:(NSString*) keywords type:(NSString*) contact_type adv_search:(NSDictionary*)upparams;
 
 
@@ -140,7 +141,7 @@ extern NSString *const ScreenCodeOfflineSync;
 
 
 //+(NSDictionary*)request_PDFList:(int ) offset limit:(int)limit keywords:(NSString* ) keywords ;
-//+(NSDictionary*)request_TearSheet:(NSMutableDictionary*)params;
++(NSDictionary*)request_TearSheet:(NSMutableDictionary*)params;
 //+(NSDictionary*)save_TearSheet:(NSMutableDictionary *)params;
 //+(NSDictionary*)direct_save_TearSheet:(NSMutableDictionary*)params;//(NSString*) request_url name:(NSString*)name delete:(NSString* )ids note:(NSString* )saveNote modelIds:(NSDictionary *)modelIds;
 
@@ -155,7 +156,7 @@ extern NSString *const ScreenCodeOfflineSync;
 
 //+(NSDictionary*)ItemSearch_addall:(long ) offset limit :(long)limit covertype:(NSString* ) covertype ctgid:(NSString*)ctgid modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller orderCode:(NSString*) orderCode addTo:(NSString*) addTo;
 
-+(NSDictionary*)err_log:(NSString*) up_params result:(NSString*)result module:(NSString*) module code:(int) code;
+//+(NSDictionary*)err_log:(NSString*) up_params result:(NSString*)result module:(NSString*) module code:(int) code;
 //+(NSDictionary*)category_LoadMore: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(int)offset;
 //+(NSData*)fake_json:(NSString*) url;
 //+(NSDictionary*)request_ItemDetail: (NSString* ) item_id category_id:(NSString*) category_id price_template:(int) price_template customid:(int) customid;
@@ -247,4 +248,24 @@ extern NSString *const ScreenCodeOfflineSync;
 +(void)request_itemsearch:(long ) offset limit :(long)limit covertype:(NSString* ) covertype ctgid:(NSString*)ctgid modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller completionHandler:(resultHandler)result;
 +(void)request_modelqty: (NSString*) fashionId completionHandler:(resultHandler)result;
 +(void) request_update_portfolio_price:(NSString*) watchlist_id price:(float) price discount:(float) discount QTY:(int)qty qty_p:(float) qty_p notes:(NSString*)notes completionHandler:(resultHandler)result;
++(void)request_add_customer:(NSMutableDictionary*)params completionHandler:(resultHandler)result;
++(void)request_update_customer:(NSMutableDictionary*)params completionHandler:(resultHandler)result;
++(void)request_delete_order:(NSString*) order_id completionHandler:(resultHandler)result;
++(void)request_cancel_order:(NSString*) order_id order_code:(NSString*) order_code completionHandler:(resultHandler)result;
++(void)request_release_order:(NSString*) order_code withScreen:(NSString *)screenName completionHandler:(resultHandler)result;
++(void)request_update_order_signature:(NSString*) order_code path:(NSString*)path completionHandler:(resultHandler)result;
++(void) request_update_cart_modelprice:(NSString*) cart_id price:(float) price discount:(float) discount notes:(NSString*) notes completionHandler:(resultHandler)result;
++(void) request_addto_cart:(NSString* ) item_id count:(int) count name:(NSString *)name completionHandler:(resultHandler)result;
++(void)request_retrieve_password: (NSString*) user email:(NSString*) email completionHandler:(resultHandler)result;
++(void)request_update_ordercustomer:(NSString*) order_code customerinfo:(NSMutableDictionary*)info completionHandler:(resultHandler)result;
+//+(void)request_update_customer_img: (NSString*) contactid img_url:(NSString*) url completionHandler:(resultHandler)result;
++(void)request_commoneditor_partialrefresh: (NSMutableDictionary*)params url:(NSString*)url completionHandler:(resultHandler)result;
++(void)request_add_address:(NSMutableDictionary*)params completionHandler:(resultHandler)result;
++(void)request_commit_order:(NSMutableDictionary*)params completionHandler:(resultHandler)result;
+#pragma mark offline
++(void) request_new_offline_ticket:(NSString* )ver  useInternalAddress:(bool)buseinternaladdress vid:(NSString*)vid completionHandler:(resultHandler)result;
++(void) request_complete_offline_ticket:(NSString* )vid completionHandler:(resultHandler)result;
++(void) request_download_offline:(NSString* )vid completionHandler:(resultHandler)result;
++ (void)request_fastupload:(NSMutableDictionary *)params filename:(NSString*)filename data:(NSData*) data url:(NSString *)url completionHandler:(resultHandler)result;
++(void)request_err_log:(NSString*) up_params result:(NSString*)result_str module:(NSString*) module code:(int) code completionHandler:(resultHandler)result;
 @end

Plik diff jest za duży
+ 397 - 397
RedAnt ERP Mobile/common/data_provider/RANetwork.m


+ 1 - 3
RedAnt ERP Mobile/iSales-GATIT.xcodeproj/project.pbxproj

@@ -29,7 +29,6 @@
 		3C7C797B23F67C47003F4342 /* ERP_Mobile_Search.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3C7C797423F67C47003F4342 /* ERP_Mobile_Search.storyboard */; };
 		3C7C797C23F67C47003F4342 /* ERP_Mobile_Contact.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3C7C797523F67C47003F4342 /* ERP_Mobile_Contact.storyboard */; };
 		3C7C797D23F67C47003F4342 /* ERP_Mobile_Discard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3C7C797623F67C47003F4342 /* ERP_Mobile_Discard.storyboard */; };
-		3C7C797F23F67C69003F4342 /* CommonEditor.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3C7C797E23F67C69003F4342 /* CommonEditor.storyboard */; };
 		3C7C798523F67C89003F4342 /* wkweb.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3C7C798023F67C89003F4342 /* wkweb.storyboard */; };
 		3C7C798623F67C89003F4342 /* RAPDFViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C7C798223F67C89003F4342 /* RAPDFViewController.m */; };
 		3C7C798723F67C89003F4342 /* WebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C7C798423F67C89003F4342 /* WebViewController.m */; };
@@ -2007,7 +2006,7 @@
 		713F769E1929F4A7006A7305 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
-				LastUpgradeCheck = 1020;
+				LastUpgradeCheck = 1140;
 				ORGANIZATIONNAME = "United Software Applications, Inc";
 				TargetAttributes = {
 					713F76A51929F4A7006A7305 = {
@@ -2075,7 +2074,6 @@
 				71DF74951C57614C00F2789C /* PhotoBorder.png in Resources */,
 				7162A55F1C58724700AB630E /* customer_info_template.json in Resources */,
 				3C7C795C23F67BB1003F4342 /* iPadCommonEditorCellMAction.xib in Resources */,
-				3C7C797F23F67C69003F4342 /* CommonEditor.storyboard in Resources */,
 				42D3A4A21EFA6D36007A54C1 /* PhotoList.storyboard in Resources */,
 				7141DD3D1C5726B700F7DF59 /* softScanBeep.wav in Resources */,
 				42843934200EF6D800EE3133 /* homerUI.storyboard in Resources */,

+ 0 - 6
RedAnt ERP Mobile/iSales-NPD.xcodeproj/project.pbxproj

@@ -71,13 +71,10 @@
 		42BEF3501E89FE1100632AB6 /* FirebaseCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF3271E89FE1100632AB6 /* FirebaseCore.framework */; };
 		42BEF3511E89FE1200632AB6 /* CHANGELOG.md in Sources */ = {isa = PBXBuildFile; fileRef = 42BEF3291E89FE1100632AB6 /* CHANGELOG.md */; };
 		42BEF3521E89FE1200632AB6 /* FirebaseInstanceID.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF32B1E89FE1100632AB6 /* FirebaseInstanceID.framework */; };
-		42BEF3531E89FE1200632AB6 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 42BEF32C1E89FE1100632AB6 /* README.md */; };
 		42BEF3541E89FE1200632AB6 /* GGLAnalytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF32F1E89FE1100632AB6 /* GGLAnalytics.framework */; };
 		42BEF3551E89FE1200632AB6 /* GGLCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF3301E89FE1100632AB6 /* GGLCore.framework */; };
-		42BEF3561E89FE1200632AB6 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 42BEF3391E89FE1100632AB6 /* README.md */; };
 		42BEF3571E89FE1200632AB6 /* libGoogleAnalytics.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF33C1E89FE1100632AB6 /* libGoogleAnalytics.a */; };
 		42BEF3581E89FE1200632AB6 /* GTMNSData+zlib.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BEF34B1E89FE1100632AB6 /* GTMNSData+zlib.m */; };
-		42BEF35A1E89FE1200632AB6 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 42BEF34E1E89FE1100632AB6 /* README.md */; };
 		42BEF35D1E89FECD00632AB6 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF35C1E89FECD00632AB6 /* SystemConfiguration.framework */; };
 		42BEF35F1E89FEE300632AB6 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF35E1E89FEE300632AB6 /* CoreData.framework */; };
 		42BEF3621E8A005800632AB6 /* GoogleAnalyst.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BEF3611E8A005800632AB6 /* GoogleAnalyst.m */; };
@@ -2203,7 +2200,6 @@
 				712AFEDF1DBA050200254965 /* TextDrawable.m in Sources */,
 				7162A5611C58724700AB630E /* CustomerInfoViewController.m in Sources */,
 				71DF74681C575E7900F2789C /* EnumSelectViewController.m in Sources */,
-				42BEF3531E89FE1200632AB6 /* README.md in Sources */,
 				428980471E249339005F1BD8 /* JKLockController.m in Sources */,
 				71D99D301CEF02E700CA32DE /* CustomIOSAlertView.m in Sources */,
 				7162A5731C58728D00AB630E /* DetailTopicCell.m in Sources */,
@@ -2274,7 +2270,6 @@
 				7162A5601C58724700AB630E /* CustomerEditViewController.m in Sources */,
 				718B91831C75638100265FFF /* TouchImageView.m in Sources */,
 				7162A5DC1C5876E300AB630E /* LoginViewController.m in Sources */,
-				42BEF3561E89FE1200632AB6 /* README.md in Sources */,
 				4289805D1E249375005F1BD8 /* UIColor+JK_HEX.m in Sources */,
 				7162A5811C5872EF00AB630E /* HomeTableViewCellBanner.m in Sources */,
 				7162A5E61C58781000AB630E /* iSalesNavigationController.m in Sources */,
@@ -2296,7 +2291,6 @@
 				428980041E2490C1005F1BD8 /* NotificationNameCenter.m in Sources */,
 				4289802C1E2492D2005F1BD8 /* CategoryPriceViewController.m in Sources */,
 				42BEF3511E89FE1200632AB6 /* CHANGELOG.md in Sources */,
-				42BEF35A1E89FE1200632AB6 /* README.md in Sources */,
 				71DF748D1C57608F00F2789C /* TouchLabel.m in Sources */,
 				428980171E24924D005F1BD8 /* SortItemViewController.m in Sources */,
 				42D3A4A11EFA6D36007A54C1 /* ContentPreviewController.m in Sources */,

+ 1 - 0
RedAnt ERP Mobile/iSales-NPD/config.h

@@ -9,6 +9,7 @@
 #ifndef RedAnt_ERP_Mobile_config_h
 #define RedAnt_ERP_Mobile_config_h
 #define BUILD_NPD
+#define GOOGLE_ANALYTICS
 #define BACKORDER_PROCESS // 允许backorder process
 
 # ifdef DEBUG

+ 3 - 11
RedAnt ERP Mobile/iSales-USAI.xcodeproj/project.pbxproj

@@ -60,15 +60,11 @@
 		42BEAB381FA1D23B0024D647 /* EnumSelectAndSortViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BEAB341FA1D23A0024D647 /* EnumSelectAndSortViewController.m */; };
 		42BEF34F1E89FE1100632AB6 /* FirebaseAnalytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF3241E89FE1100632AB6 /* FirebaseAnalytics.framework */; };
 		42BEF3501E89FE1100632AB6 /* FirebaseCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF3271E89FE1100632AB6 /* FirebaseCore.framework */; };
-		42BEF3511E89FE1200632AB6 /* CHANGELOG.md in Sources */ = {isa = PBXBuildFile; fileRef = 42BEF3291E89FE1100632AB6 /* CHANGELOG.md */; };
 		42BEF3521E89FE1200632AB6 /* FirebaseInstanceID.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF32B1E89FE1100632AB6 /* FirebaseInstanceID.framework */; };
-		42BEF3531E89FE1200632AB6 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 42BEF32C1E89FE1100632AB6 /* README.md */; };
 		42BEF3541E89FE1200632AB6 /* GGLAnalytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF32F1E89FE1100632AB6 /* GGLAnalytics.framework */; };
 		42BEF3551E89FE1200632AB6 /* GGLCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF3301E89FE1100632AB6 /* GGLCore.framework */; };
-		42BEF3561E89FE1200632AB6 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 42BEF3391E89FE1100632AB6 /* README.md */; };
 		42BEF3571E89FE1200632AB6 /* libGoogleAnalytics.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF33C1E89FE1100632AB6 /* libGoogleAnalytics.a */; };
 		42BEF3581E89FE1200632AB6 /* GTMNSData+zlib.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BEF34B1E89FE1100632AB6 /* GTMNSData+zlib.m */; };
-		42BEF35A1E89FE1200632AB6 /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = 42BEF34E1E89FE1100632AB6 /* README.md */; };
 		42BEF35D1E89FECD00632AB6 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF35C1E89FECD00632AB6 /* SystemConfiguration.framework */; };
 		42BEF35F1E89FEE300632AB6 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF35E1E89FEE300632AB6 /* CoreData.framework */; };
 		42BEF3621E8A005800632AB6 /* GoogleAnalyst.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BEF3611E8A005800632AB6 /* GoogleAnalyst.m */; };
@@ -118,11 +114,11 @@
 		7141DD4E1C57459B00F7DF59 /* bitstream.c in Sources */ = {isa = PBXBuildFile; fileRef = 7141DD3E1C57459B00F7DF59 /* bitstream.c */; };
 		7141DD4F1C57459B00F7DF59 /* mask.c in Sources */ = {isa = PBXBuildFile; fileRef = 7141DD401C57459B00F7DF59 /* mask.c */; };
 		7141DD501C57459B00F7DF59 /* QRCodeGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 7141DD431C57459B00F7DF59 /* QRCodeGenerator.m */; };
-		7141DD511C57459B00F7DF59 /* qrencode.c in Sources */ = {isa = PBXBuildFile; fileRef = 7141DD441C57459B00F7DF59 /* qrencode.c */; };
+		7141DD511C57459B00F7DF59 /* qrencode.c in Sources */ = {isa = PBXBuildFile; fileRef = 7141DD441C57459B00F7DF59 /* qrencode.c */; settings = {COMPILER_FLAGS = "-Wno-shorten-64-to-32"; }; };
 		7141DD521C57459B00F7DF59 /* qrinput.c in Sources */ = {isa = PBXBuildFile; fileRef = 7141DD461C57459B00F7DF59 /* qrinput.c */; };
 		7141DD531C57459B00F7DF59 /* qrspec.c in Sources */ = {isa = PBXBuildFile; fileRef = 7141DD481C57459B00F7DF59 /* qrspec.c */; };
 		7141DD541C57459B00F7DF59 /* rscode.c in Sources */ = {isa = PBXBuildFile; fileRef = 7141DD4A1C57459B00F7DF59 /* rscode.c */; };
-		7141DD551C57459B00F7DF59 /* split.c in Sources */ = {isa = PBXBuildFile; fileRef = 7141DD4C1C57459B00F7DF59 /* split.c */; };
+		7141DD551C57459B00F7DF59 /* split.c in Sources */ = {isa = PBXBuildFile; fileRef = 7141DD4C1C57459B00F7DF59 /* split.c */; settings = {COMPILER_FLAGS = "-Wno-shorten-64-to-32"; }; };
 		7141DD5F1C5747CE00F7DF59 /* AESCrypt.m in Sources */ = {isa = PBXBuildFile; fileRef = 7141DD571C5747CE00F7DF59 /* AESCrypt.m */; };
 		7141DD601C5747CE00F7DF59 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 7141DD581C5747CE00F7DF59 /* LICENSE */; };
 		7141DD611C5747CE00F7DF59 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 7141DD5A1C5747CE00F7DF59 /* NSData+Base64.m */; };
@@ -248,7 +244,7 @@
 		71BBA2291CEAC17E00C91DED /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 71BBA2281CEAC17E00C91DED /* libz.tbd */; };
 		71BBA2401CEAEF0700C91DED /* ioapi.c in Sources */ = {isa = PBXBuildFile; fileRef = 71BBA2381CEAEF0700C91DED /* ioapi.c */; };
 		71BBA2411CEAEF0700C91DED /* mztools.c in Sources */ = {isa = PBXBuildFile; fileRef = 71BBA23A1CEAEF0700C91DED /* mztools.c */; };
-		71BBA2421CEAEF0700C91DED /* unzip.c in Sources */ = {isa = PBXBuildFile; fileRef = 71BBA23C1CEAEF0700C91DED /* unzip.c */; };
+		71BBA2421CEAEF0700C91DED /* unzip.c in Sources */ = {isa = PBXBuildFile; fileRef = 71BBA23C1CEAEF0700C91DED /* unzip.c */; settings = {COMPILER_FLAGS = "-Wno-dangling-else"; }; };
 		71BBA2431CEAEF0700C91DED /* zip.c in Sources */ = {isa = PBXBuildFile; fileRef = 71BBA23E1CEAEF0700C91DED /* zip.c */; };
 		71BF06FB1D2F3CAC00981938 /* OLDataProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 71BF06FA1D2F3CAC00981938 /* OLDataProvider.m */; };
 		71BF06FE1D2F3CBA00981938 /* OfflineSettingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 71BF06FD1D2F3CBA00981938 /* OfflineSettingViewController.m */; };
@@ -2205,7 +2201,6 @@
 				712AFEDF1DBA050200254965 /* TextDrawable.m in Sources */,
 				7162A5611C58724700AB630E /* CustomerInfoViewController.m in Sources */,
 				71DF74681C575E7900F2789C /* EnumSelectViewController.m in Sources */,
-				42BEF3531E89FE1200632AB6 /* README.md in Sources */,
 				428980471E249339005F1BD8 /* JKLockController.m in Sources */,
 				71D99D301CEF02E700CA32DE /* CustomIOSAlertView.m in Sources */,
 				7162A5731C58728D00AB630E /* DetailTopicCell.m in Sources */,
@@ -2273,7 +2268,6 @@
 				7162A5601C58724700AB630E /* CustomerEditViewController.m in Sources */,
 				718B91831C75638100265FFF /* TouchImageView.m in Sources */,
 				7162A5DC1C5876E300AB630E /* LoginViewController.m in Sources */,
-				42BEF3561E89FE1200632AB6 /* README.md in Sources */,
 				4289805D1E249375005F1BD8 /* UIColor+JK_HEX.m in Sources */,
 				7162A5811C5872EF00AB630E /* HomeTableViewCellBanner.m in Sources */,
 				7162A5E61C58781000AB630E /* iSalesNavigationController.m in Sources */,
@@ -2294,8 +2288,6 @@
 				7162A5471C58719D00AB630E /* RATreeView+Private.m in Sources */,
 				428980041E2490C1005F1BD8 /* NotificationNameCenter.m in Sources */,
 				4289802C1E2492D2005F1BD8 /* CategoryPriceViewController.m in Sources */,
-				42BEF3511E89FE1200632AB6 /* CHANGELOG.md in Sources */,
-				42BEF35A1E89FE1200632AB6 /* README.md in Sources */,
 				71DF748D1C57608F00F2789C /* TouchLabel.m in Sources */,
 				3C68314E239607B500AD5BD7 /* RAYTPlayer.m in Sources */,
 				428980171E24924D005F1BD8 /* SortItemViewController.m in Sources */,

+ 1 - 1
common/NetworkUtils.h

@@ -35,5 +35,5 @@ typedef void(^dataHandler)(NSData *data);
 +(void)request_interface : (NSString*) url parameters:(NSMutableDictionary *) params  err_record_url:(NSString* )recorder_url completionHandler:(resultHandler)result retry:(int) retry;
 //+(void)request_file : (NSString*) url parameters:(NSMutableDictionary *) params  err_record_url:(NSString* )recorder_url completionHandler:(resultHandler)result;
 +(void)request_file_fast : (NSString*) url parameters:(NSMutableDictionary *) params completionHandler:(resultHandler)result;
-+(void)request_interface_d : (NSString*) url parameters:(NSMutableDictionary *) params  err_record_url:(NSString* )recorder_url completionHandler:(resultHandler)result retry:(int) retry;
++(void)request_upload_fast :(NSData *)filedata   FileName:(NSString*) filename server:(NSString*) urlString parameters:(NSMutableDictionary *) params completionHandler:(resultHandler)result;
 @end

Plik diff jest za duży
+ 195 - 918
common/NetworkUtils.m


+ 189 - 183
common/WK PDF+Web/RAPDFViewController.m

@@ -264,54 +264,56 @@
                 self.filename = result[@"suggestedFilename"];
             
             
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
-            
-            [[self navigationController] setNavigationBarHidden:self.hidenavi animated:NO];
-            self.navigationItem.title = self.save_name;
-            UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
-            //  self.content=nil;
-            if(self.content!=nil&&self.content.length>0)
-            {
-                [reF removeFromSuperview];
-                
-                
-                // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
-                NSString *path = NSTemporaryDirectory();
-                NSString *filePath = [path stringByAppendingPathComponent:self.filename];
-                //    NSError *error = nil;
-                //    BOOL bo = [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
-                //    NSAssert(bo,@"创建目录失败");
-                if (self.cachePath.length) {
-                    filePath = self.cachePath;
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                [[self navigationController] setNavigationBarHidden:self.hidenavi animated:NO];
+                self.navigationItem.title = self.save_name;
+                UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
+                //  self.content=nil;
+                if(self.content!=nil&&self.content.length>0)
+                {
+                    [reF removeFromSuperview];
+                    
+                    
+                    // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+                    NSString *path = NSTemporaryDirectory();
+                    NSString *filePath = [path stringByAppendingPathComponent:self.filename];
+                    //    NSError *error = nil;
+                    //    BOOL bo = [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
+                    //    NSAssert(bo,@"创建目录失败");
+                    if (self.cachePath.length) {
+                        filePath = self.cachePath;
+                    }
+                    
+                    [self.content writeToFile:filePath atomically:YES];
+                    
+                    self.url = filePath;
+                    self.isLocalfile = true;
+                    
+                    
+                    self.btnshare.enabled =true;
+                    
+                    
+                    self.btnemail.enabled =true;
+                    self.btnsave.enabled =true;
+                    
+                    
+                    
+                    NSURL *url = [NSURL fileURLWithPath:filePath];
+                    NSURLRequest *request = [NSURLRequest requestWithURL:url];
+                    [self.wkWebview loadRequest:request];
+                    
+                    
                 }
-                
-                [self.content writeToFile:filePath atomically:YES];
-                
-                self.url = filePath;
-                self.isLocalfile = true;
-                
-                
-                self.btnshare.enabled =true;
-                
-                
-                self.btnemail.enabled =true;
-                self.btnsave.enabled =true;
-                
-                
-                
-                NSURL *url = [NSURL fileURLWithPath:filePath];
-                NSURLRequest *request = [NSURLRequest requestWithURL:url];
-                [self.wkWebview loadRequest:request];
-                
-                
-            }
-            else
-            {
-                [RAUtils message_alert:nil  title:@"Open PDF Failed" controller:self];
-                
-                if(self.autoPrint)
-                    [self.navigationController popViewControllerAnimated:true];
-            }
+                else
+                {
+                    [RAUtils message_alert:nil  title:@"Open PDF Failed" controller:self];
+                    
+                    if(self.autoPrint)
+                        [self.navigationController popViewControllerAnimated:true];
+                }
+            }];
+            
+            
             
             
             
@@ -985,59 +987,61 @@
     
     if(appDelegate.printerURL==nil)
     {
-        [waitalert dismissViewControllerAnimated:YES completion:nil];
-//        [waitalert dismissViewControllerAnimated:YES completion:nil];
-        if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1)
-        {
-            UIPrinterPickerController *printPicker = [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:nil];
-            //   [printPicker presentFromBarButtonItem:self.btnSubmitOrder animated:yes completionHandler:
-            
-            
-            
-            //                 [ printPicker presentFromBarButtonItem:self.btnshare animated:YES completionHandler:
-            
-            
-            
-            [printPicker presentFromRect:CGRectMake(100, 100, 300, 500) inView:self.view animated:YES completionHandler:
-             
-             
-             
-             //        [printPicker presentAnimated:YES completionHandler:
-             ^(UIPrinterPickerController *printerPicker, BOOL userDidSelect, NSError *error)
-             {
-                 if (userDidSelect)
-                 {
-                     //User selected the item in the UIPrinterPickerController and got the printer details.
-                     
-                     [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:printerPicker.selectedPrinter];
-                     
-                     //Here you will get the printer and printer details.ie,
-                     // printerPicker.selectedPrinter, printerPicker.selectedPrinter.displayName, printerPicker.selectedPrinter.URL etc. So you can display the printer name in your label text or button title.
-                     
-                     
-                     
-                     
-                     appDelegate.printerURL =printerPicker.selectedPrinter.URL.absoluteString;
-                     
-                     [self startAirPrintWithData:data];
-                     
-                 }
-                 else
+        [waitalert dismissViewControllerAnimated:YES completion:^{
+            if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1)
+            {
+                UIPrinterPickerController *printPicker = [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:nil];
+                //   [printPicker presentFromBarButtonItem:self.btnSubmitOrder animated:yes completionHandler:
+                
+                
+                
+                //                 [ printPicker presentFromBarButtonItem:self.btnshare animated:YES completionHandler:
+                
+                
+                
+                [printPicker presentFromRect:CGRectMake(100, 100, 300, 500) inView:self.view animated:YES completionHandler:
+                 
+                 
+                 
+                 //        [printPicker presentAnimated:YES completionHandler:
+                 ^(UIPrinterPickerController *printerPicker, BOOL userDidSelect, NSError *error)
                  {
-                     
-                     
-                     //                          AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                     //                          if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
-                     //                          {
-                     //
-                     //                              [((MainViewController*)appDelegate.main_vc) Loginout:false];
-                     //                          }
-                     //                          [self prepareReturn:nil];
-                     
-                     //[self.navigationController popViewControllerAnimated:true];
-                 }
-             }];
-        }
+                     if (userDidSelect)
+                     {
+                         //User selected the item in the UIPrinterPickerController and got the printer details.
+                         
+                         [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:printerPicker.selectedPrinter];
+                         
+                         //Here you will get the printer and printer details.ie,
+                         // printerPicker.selectedPrinter, printerPicker.selectedPrinter.displayName, printerPicker.selectedPrinter.URL etc. So you can display the printer name in your label text or button title.
+                         
+                         
+                         
+                         
+                         appDelegate.printerURL =printerPicker.selectedPrinter.URL.absoluteString;
+                         
+                         [self startAirPrintWithData:data];
+                         
+                     }
+                     else
+                     {
+                         
+                         
+                         //                          AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                         //                          if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
+                         //                          {
+                         //
+                         //                              [((MainViewController*)appDelegate.main_vc) Loginout:false];
+                         //                          }
+                         //                          [self prepareReturn:nil];
+                         
+                         //[self.navigationController popViewControllerAnimated:true];
+                     }
+                 }];
+            }
+        }];
+//        [waitalert dismissViewControllerAnimated:YES completion:nil];
+
     }
     else
     {
@@ -1045,93 +1049,95 @@
         [airPrinter contactPrinter:^(BOOL available)
          {
             
-            [waitalert dismissViewControllerAnimated:YES completion:nil];
+            [waitalert dismissViewControllerAnimated:YES completion:^{
+                if (available&& appDelegate.printerURL.length>0)
+                {
+                    
+                    
+                    [airPrinterController printToPrinter:airPrinter completionHandler:completionHandler];
+                    DebugLog(@"AIRPRINTER AVAILABLE");
+                }
+                else
+                {
+                    appDelegate.printerURL = nil;
+                    
+                    //             [airPrinterController presentFromRect:CGRectMake(0, 0, 300, 500) inView:self.view animated:YES completionHandler:
+                    //
+                    //
+                    //
+                    //              //        [printPicker presentAnimated:YES completionHandler:
+                    //              ^(UIPrintInteractionController *printerController, BOOL userDidSelect, NSError *error)
+                    //              {
+                    //                  if (userDidSelect)
+                    //                  {
+                    //                      NSString* sid= printerController.printInfo.printerID;
+                    //                      UIPrintPaper*paper=  printerController.printPaper;
+                    //
+                    //                  }
+                    //              }];
+                    
+                    
+                    DebugLog(@"AIRPRINTER NOT AVAILABLE");
+                    
+                    
+                    
+                    if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1)
+                    {
+                        UIPrinterPickerController *printPicker = [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:nil];
+                        //   [printPicker presentFromBarButtonItem:self.btnSubmitOrder animated:yes completionHandler:
+                        
+                        
+                        
+                        //                 [ printPicker presentFromBarButtonItem:self.btnshare animated:YES completionHandler:
+                        
+                        
+                        
+                        [printPicker presentFromRect:CGRectMake(100, 100, 300, 500) inView:self.view animated:YES completionHandler:
+                         
+                         
+                         
+                         //        [printPicker presentAnimated:YES completionHandler:
+                         ^(UIPrinterPickerController *printerPicker, BOOL userDidSelect, NSError *error)
+                         {
+                             if (userDidSelect)
+                             {
+                                 //User selected the item in the UIPrinterPickerController and got the printer details.
+                                 
+                                 [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:printerPicker.selectedPrinter];
+                                 
+                                 //Here you will get the printer and printer details.ie,
+                                 // printerPicker.selectedPrinter, printerPicker.selectedPrinter.displayName, printerPicker.selectedPrinter.URL etc. So you can display the printer name in your label text or button title.
+                                 
+                                 
+                                 
+                                 
+                                 appDelegate.printerURL =printerPicker.selectedPrinter.URL.absoluteString;
+                                 
+                                 [self startAirPrintWithData:data];
+                                 
+                             }
+                             else
+                             {
+                                 appDelegate.printerURL = nil;
+                                 
+                                 //                          AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                                 //                          if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
+                                 //                          {
+                                 //
+                                 //                              [((MainViewController*)appDelegate.main_vc) Loginout:false];
+                                 //                          }
+                                 //                          [self prepareReturn:nil];
+                                 
+                                 //[self.navigationController popViewControllerAnimated:true];
+                             }
+                         }];
+                    }
+                }
+            }];
             
 //             [waitalert dismissViewControllerAnimated:YES completion:nil];
              
-             if (available&& appDelegate.printerURL.length>0)
-             {
-                 
-                 
-                 [airPrinterController printToPrinter:airPrinter completionHandler:completionHandler];
-                 DebugLog(@"AIRPRINTER AVAILABLE");
-             }
-             else
-             {
-                 appDelegate.printerURL = nil;
-                 
-                 //             [airPrinterController presentFromRect:CGRectMake(0, 0, 300, 500) inView:self.view animated:YES completionHandler:
-                 //
-                 //
-                 //
-                 //              //        [printPicker presentAnimated:YES completionHandler:
-                 //              ^(UIPrintInteractionController *printerController, BOOL userDidSelect, NSError *error)
-                 //              {
-                 //                  if (userDidSelect)
-                 //                  {
-                 //                      NSString* sid= printerController.printInfo.printerID;
-                 //                      UIPrintPaper*paper=  printerController.printPaper;
-                 //
-                 //                  }
-                 //              }];
-                 
-                 
-                 DebugLog(@"AIRPRINTER NOT AVAILABLE");
-                 
-                 
-                 
-                 if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1)
-                 {
-                     UIPrinterPickerController *printPicker = [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:nil];
-                     //   [printPicker presentFromBarButtonItem:self.btnSubmitOrder animated:yes completionHandler:
-                     
-                     
-                     
-                     //                 [ printPicker presentFromBarButtonItem:self.btnshare animated:YES completionHandler:
-                     
-                     
-                     
-                     [printPicker presentFromRect:CGRectMake(100, 100, 300, 500) inView:self.view animated:YES completionHandler:
-                      
-                      
-                      
-                      //        [printPicker presentAnimated:YES completionHandler:
-                      ^(UIPrinterPickerController *printerPicker, BOOL userDidSelect, NSError *error)
-                      {
-                          if (userDidSelect)
-                          {
-                              //User selected the item in the UIPrinterPickerController and got the printer details.
-                              
-                              [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:printerPicker.selectedPrinter];
-                              
-                              //Here you will get the printer and printer details.ie,
-                              // printerPicker.selectedPrinter, printerPicker.selectedPrinter.displayName, printerPicker.selectedPrinter.URL etc. So you can display the printer name in your label text or button title.
-                              
-                              
-                              
-                              
-                              appDelegate.printerURL =printerPicker.selectedPrinter.URL.absoluteString;
-                              
-                              [self startAirPrintWithData:data];
-                              
-                          }
-                          else
-                          {
-                              appDelegate.printerURL = nil;
-                              
-                              //                          AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                              //                          if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
-                              //                          {
-                              //
-                              //                              [((MainViewController*)appDelegate.main_vc) Loginout:false];
-                              //                          }
-                              //                          [self prepareReturn:nil];
-                              
-                              //[self.navigationController popViewControllerAnimated:true];
-                          }
-                      }];
-                 }
-             }
+
          }];
     }
     

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików