Ray Zhang 10 жил өмнө
parent
commit
43f0fb2610
33 өөрчлөгдсөн 1321 нэмэгдсэн , 629 устгасан
  1. 190 65
      RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m
  2. 2 0
      RedAnt ERP Mobile/common/CommonEditor/EnumSelectViewController.h
  3. 10 1
      RedAnt ERP Mobile/common/Functions/MainViewController.h
  4. 117 85
      RedAnt ERP Mobile/common/Functions/MainViewController.m
  5. 3 1
      RedAnt ERP Mobile/common/Functions/PDF+Web/PDFViewController.m
  6. 1 1
      RedAnt ERP Mobile/common/Functions/camscan/ScannerViewController.m
  7. 124 102
      RedAnt ERP Mobile/common/Functions/cart/CartViewController.m
  8. 1 0
      RedAnt ERP Mobile/common/Functions/cart/ModelItemCell.h
  9. 23 0
      RedAnt ERP Mobile/common/Functions/category/CategorySearchFilterViewController.h
  10. 397 0
      RedAnt ERP Mobile/common/Functions/category/CategorySearchFilterViewController.m
  11. 5 0
      RedAnt ERP Mobile/common/Functions/category/CategoryViewController.h
  12. 119 55
      RedAnt ERP Mobile/common/Functions/category/CategoryViewController.m
  13. 1 14
      RedAnt ERP Mobile/common/Functions/contact/ContactListViewController.m
  14. 1 1
      RedAnt ERP Mobile/common/Functions/contact/CustomerEditViewController.m
  15. 7 3
      RedAnt ERP Mobile/common/Functions/home/HomeViewController.m
  16. 29 2
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.m
  17. 9 5
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m
  18. 139 98
      RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m
  19. 25 74
      RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m
  20. 1 1
      RedAnt ERP Mobile/common/Functions/order/OrderListViewController.m
  21. 3 47
      RedAnt ERP Mobile/common/Functions/portfolio/PortfolioViewController.m
  22. 4 3
      RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchViewController.m
  23. 9 8
      RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m
  24. 2 2
      RedAnt ERP Mobile/common/Functions/sidemenu/LoginViewController.m
  25. 26 4
      RedAnt ERP Mobile/common/Functions/signature/SignatureViewController.m
  26. 3 48
      RedAnt ERP Mobile/common/Functions/watchlist/WatchListViewController.m
  27. 8 0
      RedAnt ERP Mobile/common/RAUtils.h
  28. 1 1
      RedAnt ERP Mobile/common/const.h
  29. 34 0
      RedAnt ERP Mobile/common/customUI/ImageUploadViewController.m
  30. 2 2
      RedAnt ERP Mobile/common/customUI/TouchImageView.m
  31. 4 1
      RedAnt ERP Mobile/common/data_provider/iSalesDB.m
  32. 1 1
      RedAnt ERP Mobile/common/data_provider/iSalesNetwork.h
  33. 20 4
      RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m

+ 190 - 65
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m

@@ -27,7 +27,7 @@
 #import "RAUtils.h"
 #import "CommonEditorCellImg.h"
 
-
+#import "AFHTTPSessionManager.h"
 
 #define NUMBERS @"0123456789\n"
 @interface CommonEditorViewController ()
@@ -3042,54 +3042,51 @@
             CommonEditorCellSignature * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
             
             NSMutableString* title = [[item_json valueForKey:@"aname"] mutableCopy];
-            UIImage* signature = [item_json valueForKey:@"signature"];
             if([required isEqualToString:@"true"])
             {
                 [title appendString:@"*"];
             }
             cell.labelTitle.text = title;
             
-            if(signature!=nil)
+            NSString* img_url = [item_json valueForKey:@"avalue"];
+            
+            
+            
+            NSString* file_name=[img_url lastPathComponent];
+            NSData* img_data=[iSalesDB load_cached_img:file_name];
+            if(img_data!=nil)
             {
-                cell.imageviewSignature.image=signature;
+                
+                UIImage * img =[UIImage imageWithData:img_data];
+                cell.imageviewSignature.image=img ;
             }
             else
             {
-                NSString* img_url = [item_json valueForKey:@"img_url"];
-                NSString* file_name=[img_url lastPathComponent];
-                NSData* img_data=[iSalesDB load_cached_img:file_name];
-                if(img_data!=nil)
-                {
+                
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                     
-                    UIImage * img =[UIImage imageWithData:img_data];
-                    cell.imageviewSignature.image = img;
-                }
-                else
-                {
+                    NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
                     
-                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                    dispatch_async(dispatch_get_main_queue(), ^{
                         
-                        NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
                         
-                        dispatch_async(dispatch_get_main_queue(), ^{
-                            
-                            
-                            
-                            if(downloadimg_data!=nil)
-                            {
-                                [iSalesDB cache_img:downloadimg_data :file_name ];
-                                
-                                UIImage * img =[UIImage imageWithData:downloadimg_data];
-                                cell.imageviewSignature.image = img;
-                            }
+                        
+                        if(downloadimg_data!=nil)
+                        {
+                            [iSalesDB cache_img:downloadimg_data :file_name ];
                             
-                        });
+                            UIImage * img =[UIImage imageWithData:downloadimg_data];
+                            cell.imageviewSignature.image=img ;
+                        }
+                        else
+                            cell.imageviewSignature.image=[UIImage imageNamed:@"notfound_s"];
+                        
+                        
                     });
-                    
-                    
-                }
-            }
-            cell.backgroundColor = UIColorFromRGB(0xF2EEEA);
+                });
+                
+                
+            }            cell.backgroundColor = UIColorFromRGB(0xF2EEEA);
             return cell;
             // CommonEditorCellSignature* cell = (CommonEditorCellSignature*) [self.editorTable cellForRowAtIndexPath:indexPath];
             //cell.imageviewSignature.image = image;
@@ -3519,17 +3516,144 @@
     }
     else if([control isEqualToString:@"signature"])
     {
-        SignatureViewController * signvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"SignatureViewController"];
-        signvc.title = [item_json valueForKey:@"aname"];
-        signvc.indexPath = indexPath;
-        //        signvc.delegate = self;
-        CommonEditorCellSignature* cell = (CommonEditorCellSignature*) [self.editorTable cellForRowAtIndexPath:indexPath];
-        
-        signvc.existSignature = cell.imageviewSignature.image ;
-        
-        
+//        SignatureViewController * signvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"SignatureViewController"];
+//        signvc.title = [item_json valueForKey:@"aname"];
+//        signvc.indexPath = indexPath;
+//        //        signvc.delegate = self;
+//        CommonEditorCellSignature* cell = (CommonEditorCellSignature*) [self.editorTable cellForRowAtIndexPath:indexPath];
+//        
+//        signvc.existSignature = cell.imageviewSignature.image ;
+//        
+//        
+//        
+//        [self.navigationController pushViewController:signvc animated:true];
+        
+        
+        __block UIImage* signimg=nil;
+        SignatureViewController * vc =[ self.storyboard instantiateViewControllerWithIdentifier:@"SignatureViewController"];
+        
+        vc.onReturnImg = ^(UIImage* img)
+        {
+            signimg = img;
+            
+            if(signimg!=nil)
+            {
+                NSData *imageData = UIImagePNGRepresentation(img);
+                
+                AFHTTPRequestSerializer* serializer=[AFHTTPRequestSerializer serializer] ;
+                
+                
+                
+                NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                if(appDelegate.user!=nil)
+                    [params setValue:appDelegate.user forKey:@"user"];
+                //    if(appDelegate.contact_id!=nil)
+                //        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+                if(appDelegate.password!=nil)
+                    [params setValue:appDelegate.password forKey:@"password"];
+                
+                
+                NSMutableURLRequest *request = [serializer multipartFormRequestWithMethod:@"POST" URLString:URL_UPLOAD_IMG parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
+                    [formData appendPartWithFileData:imageData name:@"upfile" fileName:@"test.jpg" mimeType:@"image/png"];
+                } error:nil];
+                
+                
+                
+                AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
+                
+                
+                
+                
+                NSProgress *progress = nil;
+                UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Upload Signature"];
+                NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
+                    
+                    //        [progress removeObserver:self forKeyPath:@"fractionCompleted"];
+                    
+                    
+                    [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+                    
+                    if (error) {
+                        
+                        NSString* err_msg = [error localizedDescription];
+                        NSLog(@"%@",err_msg);// [self.view updateWithMessage:[NSString stringWithFormat:@"Error : %@!", error.debugDescription]];
+                        
+                        
+                        NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
+                        
+                        NSLog(@"data string: %@",str);
+                        
+                        [RAUtils message_alert:@"Can not connect to server please try again." title:@"Upload Image" controller:self] ;
+                        
+                    } else {
+                        NSLog(@"response ");
+                        
+                        
+                        
+                        NSData *data = [NSJSONSerialization dataWithJSONObject:(NSDictionary*)responseObject options:kNilOptions error:nil];
+                        
+                        // 再将NSData转为字符串
+                        NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
+                        
+                        //            NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
+                        
+                        NSLog(@"data string: %@",jsonStr);
+                        
+                        NSDictionary* json = responseObject;
+                        
+                        
+                        //NSMutableArray* arr_ret = [[NSMutableArray alloc] init];
+                        if([[json valueForKey:@"result"] intValue]==2)
+                        {
+                            NSString* img_url_down = json[@"img_url_aname"];
+//                            if(img_url_down.length==0)
+//                                img_url_down=@"";
+                            NSString* img_url_up = json[@"img_url"];
+//                            if(img_url_up.length==0)
+//                                img_url_up=@"";
+                            
+                            NSMutableDictionary* item_json =((NSMutableArray*)self.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 = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
+                            [section_json setObject:item_json forKey:[NSString stringWithFormat:@"item_%d",indexPath.row]];
+                            
+                            [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];
+
+                            
+                            CommonEditorCellSignature* cell = (CommonEditorCellSignature*) [self.editorTable cellForRowAtIndexPath:indexPath];
+                            
+                            cell.imageviewSignature.image = signimg;
+                            
+                            
+                        }
+                        else
+                        {
+                            [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:self] ;
+                        }
+                        
+                        
+                        
+                        
+                        
+                        
+                    }
+                    //
+                }];
+                
+                [uploadTask resume];
+            }
+            
+            
+            
+        };
+    
         
-        [self.navigationController pushViewController:signvc animated:true];
+        [self.navigationController pushViewController:vc animated:true];
     }
     //    else if([control isEqualToString:@"action "])
     //    {
@@ -3549,6 +3673,7 @@
     //    }
     return nil;
 }
+
 //- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 //{
 //
@@ -3834,28 +3959,28 @@
     [self.editorTable reloadData ];
     
 }
-#pragma mark SignatureViewControllerDelegate
-//-(void)SignatureVCReturnData:(NSData *)imagedata indexPath:(NSIndexPath *)indexPath
+//#pragma mark SignatureViewControllerDelegate
+////-(void)SignatureVCReturnData:(NSData *)imagedata indexPath:(NSIndexPath *)indexPath
+////{
+////
+////}
+//-(void)SignatureVCReturnImage:(UIImage *)image indexPath:(NSIndexPath *)indexPath
 //{
-//
+//    
+//    //    NSMutableDictionary* item_json =((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row];
+//    //
+//    //    if(image==nil)
+//    //        [item_json removeObjectForKey:@"signature"];
+//    //    else
+//    //        [item_json setObject:image forKey:@"signature"];
+//    //    [section_json setObject:item_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
+//    //    [self.content_data setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
+//    //
+//    //
+//    //
+//    //    CommonEditorCellSignature* cell = (CommonEditorCellSignature*) [self.editorTable cellForRowAtIndexPath:indexPath];
+//    //    cell.imageviewSignature.image = image;
 //}
--(void)SignatureVCReturnImage:(UIImage *)image indexPath:(NSIndexPath *)indexPath
-{
-    
-    //    NSMutableDictionary* item_json =((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row];
-    //
-    //    if(image==nil)
-    //        [item_json removeObjectForKey:@"signature"];
-    //    else
-    //        [item_json setObject:image forKey:@"signature"];
-    //    [section_json setObject:item_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
-    //    [self.content_data setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
-    //
-    //
-    //
-    //    CommonEditorCellSignature* cell = (CommonEditorCellSignature*) [self.editorTable cellForRowAtIndexPath:indexPath];
-    //    cell.imageviewSignature.image = image;
-}
 #pragma mark textView delegate
 //- (BOOL)textViewShouldBeginEditing:(UITextView *)textView;
 //- (BOOL)textViewShouldEndEditing:(UITextView *)textView;
@@ -3882,7 +4007,7 @@
 }
 - (void)textViewDidEndEditing:(UITextView *)textView
 {
-    UITableViewCell *cell = (UITableViewCell *) textView.superview.superview;
+ //   UITableViewCell *cell = (UITableViewCell *) textView.superview.superview;
     NSIndexPath *   indexPath = self.lasttextview_from;//[self.editorTable indexPathForCell:cell];
     
     
@@ -4070,7 +4195,7 @@
 {
     
     NSLog(@"textFieldDidEndEditing");
-    UITableViewCell *cell = (UITableViewCell *) textField.superview.superview;
+  //  UITableViewCell *cell = (UITableViewCell *) textField.superview.superview;
     NSIndexPath *   indexPath = self.lastedit_from;
     
     

+ 2 - 0
RedAnt ERP Mobile/common/CommonEditor/EnumSelectViewController.h

@@ -27,6 +27,8 @@
 @property bool dirty ;
 @property int max_select ;
 @property bool is_dialog ;
+
+
 @property (strong, nonatomic) IBOutlet UITableView *tableEnum;
 @property (nonatomic , copy) void (^returnValue)(NSMutableDictionary* value);
 @property bool hide_navibar;

+ 10 - 1
RedAnt ERP Mobile/common/Functions/MainViewController.h

@@ -92,6 +92,14 @@
 
 
 
+@property (strong, nonatomic) IBOutlet UIView *employee_bp;
+@property (strong, nonatomic) IBOutlet UIView *customer_bp;
+@property (strong, nonatomic) IBOutlet UILabel *label_cccount;
+@property (strong, nonatomic) IBOutlet UILabel *label_cwcount;
+
+
+@property (strong, nonatomic) IBOutlet UILabel *label_wcount;
+
 -(void) logoutDocuments;
 -(void) logoutCart;
 -(void) logoutWish;
@@ -101,9 +109,10 @@
 -(void) logoutCategory;
 
 -(void) switchToPreviousVC;
-
+-(void) Loginout;
 -(void) switchToOrder;
 -(void) switchToCart;
+-(void)switchToHome;
 @property (strong, nonatomic) IBOutlet UILabel *label_ccount;
 
 

+ 117 - 85
RedAnt ERP Mobile/common/Functions/MainViewController.m

@@ -389,6 +389,18 @@
     self.label_ccount.layer.cornerRadius=10.5;
     self.label_ccount.layer.masksToBounds=true;
     
+    self.label_wcount.layer.cornerRadius=10.5;
+    self.label_wcount.layer.masksToBounds=true;
+    
+    self.label_cccount.layer.cornerRadius=10.5;
+    self.label_cccount.layer.masksToBounds=true;
+    
+    self.label_cwcount.layer.cornerRadius=10.5;
+    self.label_cwcount.layer.masksToBounds=true;
+    
+    
+    self.employee_bp.hidden = false;
+    self.customer_bp.hidden = true;
     
     
     UIApplication * app = [UIApplication sharedApplication];
@@ -429,15 +441,20 @@
         //                    self.returnValue(value);
     };
     
+    //Capturing strongly  warring;
+    __block MainViewController *brself= self;
     
     self.orderViewController.selectOrder=^(NSMutableDictionary* order_detail){
         //main view 下打开order
-        self.cartViewController.onFinishLoad=^()
+        
+        //Capturing strongly  warring;
+        __block MainViewController *brbrself= brself;
+        brself.cartViewController.onFinishLoad=^()
         {
-            [self.cartViewController placeOrder];
-            self.cartViewController.onFinishLoad=nil;
+            [brbrself.cartViewController placeOrder];
+            brbrself.cartViewController.onFinishLoad=nil;
         };
-        [self switchToCart:nil];
+        [brself switchToCart:nil];
         
     };
     self.watchListViewController =[ self.storyboard instantiateViewControllerWithIdentifier:@"WatchListViewController"];
@@ -518,10 +535,8 @@
     //    [self showMenu];
     
 }
-- (IBAction)OnLoginClick:(UIButton *)sender {
-    
-    
-    
+-(void) Loginout
+{
     UIApplication * app = [UIApplication sharedApplication];
     AppDelegate *appDelegate = (AppDelegate *)[app delegate];
     
@@ -596,6 +611,12 @@
             
         }];
     }
+}
+- (IBAction)OnLoginClick:(UIButton *)sender {
+    
+    
+    [self Loginout];
+
     
     
     
@@ -622,7 +643,56 @@
 {
     if([self.current_VC isKindOfClass:[WatchListViewController class]])
         return;
+    
+    
+    if([self.current_VC isKindOfClass:[OrderListViewController class]])
+        return;
+    
+    
+    UIApplication * app = [UIApplication sharedApplication];
+    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+    if(appDelegate.bLogin==false)
+    {
+        LoginViewController * loginvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
+        //        loginvc.delegate = self;
+        //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
+        
+        loginvc.returnValue = ^(bool blogin){
+            
+            
+            if(blogin)
+            {
+                [self checklogin:true];
+                
+                
+                [self flipFromViewController:self.current_VC toViewController:self.watchListViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
+            }
+            
+            
+        };
+        
+        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
+        
+        
+        
+        
+        
+        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
+        
+        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
+        [self presentViewController:navi animated:YES completion:^{
+            
+            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
+            
+            NSLog(@"LoginViewController present.........");
+            
+            //   self.btop = false;
+            //  <#code#>
+        }];
+    }
+    else
     [self flipFromViewController:self.current_VC toViewController:self.watchListViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
+
 }
 - (IBAction)switchToContact:(UIButton *)sender {
     [self switchtocontact];
@@ -652,7 +722,15 @@
                 [self checklogin:true];
                 
                 
+                if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
+                {
                 [self flipFromViewController:self.current_VC toViewController:self.contactListViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
+                }
+                else
+                {
+                    [RAUtils message_alert:@"Customer Login does not support this feature." title:@"Contact List" controller:self] ;
+                }
+                
             }
             
             
@@ -954,10 +1032,8 @@
     //    [self.cagegoryViewController didMoveToParentViewController:self];
 }
 - (IBAction)switchToHome:(UIButton *)sender {
-    if([self.current_VC isKindOfClass:[HomeViewController class]])
-        return;
-    [self flipFromViewController:self.current_VC toViewController:self.homeViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-    
+  
+    [self switchToHome];
     //    self.current_vc = VC_HOME;
     
     //    self.is_home = true;
@@ -969,6 +1045,13 @@
     //    [self.container addSubview:self.homeViewController.view]; //2
     //    [self.homeViewController didMoveToParentViewController:self];
 }
+-(void)switchToHome
+{
+    if([self.current_VC isKindOfClass:[HomeViewController class]])
+        return;
+    [self flipFromViewController:self.current_VC toViewController:self.homeViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
+    
+}
 
 -(void) switchToPreviousVC
 {
@@ -993,66 +1076,7 @@
     if([self.current_VC isKindOfClass:[CartViewController class]])
         return;
     
-    
-//    
-//    UIApplication * app = [UIApplication sharedApplication];
-//    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-//    if(appDelegate.bLogin==false)
-//    {
-//        LoginViewController * loginvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
-//        //        loginvc.delegate = self;
-//        //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-//        
-//        loginvc.returnValue = ^(bool blogin){
-//            
-//            
-//            //            UIApplication * app = [UIApplication sharedApplication];
-//            //            AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-//            //            MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-//            
-//            
-//            if(blogin)
-//            {
-//                [self checklogin:true];
-//                
-//                
-//                
-//                self.previous_VC = self.current_VC;
-//                //self.cartViewController =[ self.storyboard instantiateViewControllerWithIdentifier:@"CartViewController"];
-//                
-//                [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-//            }
-//            
-//            //            [self reload_data];
-//            
-//            
-//            
-//        };
-//        
-//        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-//        
-//        
-//        
-//        
-//        
-//        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-//        
-//        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
-//        [self presentViewController:navi animated:YES completion:^{
-//            
-//            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-//            
-//            NSLog(@"CreateOrderViewController present.........");
-//            
-//            //   self.btop = false;
-//            //  <#code#>
-//        }];
-//    }
-//    else
-//    {
-//        self.previous_VC = self.current_VC;
-//        [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-//    }
+  
 
     UIApplication * app = [UIApplication sharedApplication];
     AppDelegate *appDelegate = (AppDelegate *)[app delegate];
@@ -1107,6 +1131,8 @@
                 else
                 {
                     [self checklogin:true];
+                    self.previous_VC = self.current_VC;
+                    [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
                 }
             }
             
@@ -1131,7 +1157,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>
@@ -1465,11 +1491,12 @@
         [map setValue:@"rect_market_news" forKey:@"img"];
         [self.sideMenuItems addObject:map.copy];
         
-        [map setValue:@"Portfolio" forKey:@"title"];
-        [map setValue:@"rect_market_news" forKey:@"img"];
-        [self.sideMenuItems addObject:map.copy];
+
         
     }
+    
+    
+
     // if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
     {
         [map setValue:@"Cam Scan" forKey:@"title"];
@@ -1484,6 +1511,11 @@
 //        [map setValue:@"rect_contact_list" forKey:@"img"];
 //        [self.sideMenuItems addObject:map.copy];
         
+        
+        [map setValue:@"Portfolio" forKey:@"title"];
+        [map setValue:@"rect_market_news" forKey:@"img"];
+        [self.sideMenuItems addObject:map.copy];
+        
         [map setValue:@"View Portfolios" forKey:@"title"];
         [map setValue:@"rect_pdf_list" forKey:@"img"];
         [self.sideMenuItems addObject:map.copy];
@@ -1521,15 +1553,15 @@
     [self.sideMenuItems addObject:map.copy];
 
     
-    if(appDelegate.user!=nil)
-    {
-        [map setValue:@"Offline data" forKey:@"title"];
-        [map setValue:@"rect_market_news" forKey:@"img"];
-        [self.sideMenuItems addObject:map.copy];
-        
-
-        
-    }
+//    if(appDelegate.user!=nil)
+//    {
+//        [map setValue:@"Offline data" forKey:@"title"];
+//        [map setValue:@"rect_market_news" forKey:@"img"];
+//        [self.sideMenuItems addObject:map.copy];
+//        
+//
+//        
+//    }
     
     [map setValue:@"About" forKey:@"title"];
     [map setValue:@"rect_change_password" forKey:@"img"];

+ 3 - 1
RedAnt ERP Mobile/common/Functions/PDF+Web/PDFViewController.m

@@ -129,6 +129,8 @@
 }
 -(void) loadcontent
 {
+    
+    UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Loading..."];
     self.mum.hidden=false;
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
@@ -156,7 +158,7 @@
         
         
         dispatch_async(dispatch_get_main_queue(), ^{
-            
+            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
             self.navigationItem.title = self.save_name;
             UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
           //  self.content=nil;

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

@@ -496,7 +496,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>

+ 124 - 102
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -660,7 +660,7 @@
 {
     
     
-    NSMutableArray* checked = [[NSMutableArray alloc] init];
+//    NSMutableArray* checked = [[NSMutableArray alloc] init];
     
     bool have_free = false;
     
@@ -675,28 +675,33 @@
     for(int i=0;i<count;i++)
     {
         NSMutableDictionary * item_json = [self.content_arr[i] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%d",i]] mutableCopy];
-        bool check = [[item_json valueForKey:@"check"] boolValue];
-        if(check)
+//        bool check = [[item_json valueForKey:@"check"] boolValue];
+        NSString* product_id = [item_json valueForKey:@"product_id"];
+//        if(check)
+//        {
+//            [checked addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"cart_item_id"] intValue]]];
+//            
+//        }
+        if(product_id.length==0)
         {
-            [checked addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"cart_item_id"] intValue]]];
-            
+            [RAUtils message_alert:@"Some models in cart does not exist, you must remove them before place order." title:@"No Such Model" controller:self] ;
+            return;
         }
-        
         bool is_free = [[item_json valueForKey:@"is_free"]boolValue];
         if(is_free)
             have_free=true;
     }
     //     disable for debug
-    if(checked.count==0)
-    {
-        [RAUtils message_alert:@"You must select at least one model." title:@"Cannot Place Order" controller:self] ;
-        return;
-    }
+//    if(checked.count==0)
+//    {
+//        [RAUtils message_alert:@"You must select at least one model." title:@"Cannot Place Order" controller:self] ;
+//        return;
+//    }
     
     
     
     //  NSDictionary * freejson = [self.content_data objectForKey:@"freeGiveaway"];
-    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+ //   AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
     
     
     /*   FREE GIVE AWAY
@@ -983,92 +988,92 @@
     }];
     
 }
-- (IBAction)onSelectAll:(UIButton *)sender {
-    
-    
-    NSMutableArray* arr_ids = [[NSMutableArray alloc] init];
-    
-    
-    
-    
-    
-    
-    if([self.btnselect.titleLabel.text isEqualToString:@"Select all"])
-    {
-        
-        long count = self.content_arr.count;// [[self.content_data valueForKey:@"count"] intValue];
-        for(int i=0;i<count;i++)
-        {
-            NSMutableDictionary * item_json = [self.content_arr[i] mutableCopy]; //[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%d",i]] mutableCopy];
-            if(![[item_json valueForKey:@"check"] boolValue])
-                [arr_ids addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"cart_item_id"] intValue]]];
-            
-        }
-        [self.btnselect setTitle: @"Deselect all" forState: UIControlStateNormal];
-    }
-    else
-    {
-        long count = self.content_arr.count;//[[self.content_data valueForKey:@"count"] intValue];
-        for(int i=0;i<count;i++)
-        {
-            NSMutableDictionary * item_json = [self.content_arr[i] mutableCopy]; //[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%d",i]] mutableCopy];
-            if([[item_json valueForKey:@"check"] boolValue])
-                [arr_ids addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"cart_item_id"] intValue]]];
-            
-        }
-        [self.btnselect setTitle: @"Select all" forState: UIControlStateNormal];
-    }
-    
-    NSString * ids = [arr_ids componentsJoinedByString:@","];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        
-        NSDictionary* check_json = [iSalesNetwork cart_check:ids];
-        
-        dispatch_async(dispatch_get_main_queue(), ^{
-            
-            
-            
-            if([[check_json valueForKey:@"result"] intValue]==2)
-            {
-                
-                long count = self.content_arr.count;
-                for(int i=0;i<count;i++)
-                {
-                    NSMutableDictionary * item_json = [self.content_arr[i] mutableCopy];
-                    if([item_json[@"check"] boolValue])
-                        item_json[@"check"]= @"false";
-                    else
-                        item_json[@"check"]= @"true";
-                    
-                    self.content_arr[i] = item_json;
-                    //[self.content_data setObject:item_json forKey:[NSString stringWithFormat:@"item_%d",i]];
-                }
-                
-                [self reload_container_getdata:false];
-                
-                // [self reload_data];
-            }
-            else
-            {
-                [RAUtils message_alert:[check_json valueForKey:@"err_msg"] title:nil controller:self] ;
-            }
-            
-            
-            
-        });
-    });
-    
-    
-    
-    
-    
-    
-    //  [self refresh_total];
-    //  self.labelTotal.text=[NSString stringWithFormat:@"$%.2f",self.total];
-    //    NSLog(self.btnselect.titleLabel.text);
-    //    if(self.btnselect.titleLabel.text)
-}
+//- (IBAction)onSelectAll:(UIButton *)sender {
+//    
+//    
+//    NSMutableArray* arr_ids = [[NSMutableArray alloc] init];
+//    
+//    
+//    
+//    
+//    
+//    
+//    if([self.btnselect.titleLabel.text isEqualToString:@"Select all"])
+//    {
+//        
+//        long count = self.content_arr.count;// [[self.content_data valueForKey:@"count"] intValue];
+//        for(int i=0;i<count;i++)
+//        {
+//            NSMutableDictionary * item_json = [self.content_arr[i] mutableCopy]; //[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%d",i]] mutableCopy];
+//            if(![[item_json valueForKey:@"check"] boolValue])
+//                [arr_ids addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"cart_item_id"] intValue]]];
+//            
+//        }
+//        [self.btnselect setTitle: @"Deselect all" forState: UIControlStateNormal];
+//    }
+//    else
+//    {
+//        long count = self.content_arr.count;//[[self.content_data valueForKey:@"count"] intValue];
+//        for(int i=0;i<count;i++)
+//        {
+//            NSMutableDictionary * item_json = [self.content_arr[i] mutableCopy]; //[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%d",i]] mutableCopy];
+//            if([[item_json valueForKey:@"check"] boolValue])
+//                [arr_ids addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"cart_item_id"] intValue]]];
+//            
+//        }
+//        [self.btnselect setTitle: @"Select all" forState: UIControlStateNormal];
+//    }
+//    
+//    NSString * ids = [arr_ids componentsJoinedByString:@","];
+//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//        
+//        
+//        NSDictionary* check_json = [iSalesNetwork cart_check:ids];
+//        
+//        dispatch_async(dispatch_get_main_queue(), ^{
+//            
+//            
+//            
+//            if([[check_json valueForKey:@"result"] intValue]==2)
+//            {
+//                
+//                long count = self.content_arr.count;
+//                for(int i=0;i<count;i++)
+//                {
+//                    NSMutableDictionary * item_json = [self.content_arr[i] mutableCopy];
+//                    if([item_json[@"check"] boolValue])
+//                        item_json[@"check"]= @"false";
+//                    else
+//                        item_json[@"check"]= @"true";
+//                    
+//                    self.content_arr[i] = item_json;
+//                    //[self.content_data setObject:item_json forKey:[NSString stringWithFormat:@"item_%d",i]];
+//                }
+//                
+//                [self reload_container_getdata:false];
+//                
+//                // [self reload_data];
+//            }
+//            else
+//            {
+//                [RAUtils message_alert:[check_json valueForKey:@"err_msg"] title:nil controller:self] ;
+//            }
+//            
+//            
+//            
+//        });
+//    });
+//    
+//    
+//    
+//    
+//    
+//    
+//    //  [self refresh_total];
+//    //  self.labelTotal.text=[NSString stringWithFormat:@"$%.2f",self.total];
+//    //    NSLog(self.btnselect.titleLabel.text);
+//    //    if(self.btnselect.titleLabel.text)
+//}
 //#pragma mark - MODEL cell delegate
 //-(void) returnQTY:(int)qty
 //{
@@ -1257,6 +1262,15 @@
     
     double discount =[[item_json valueForKey:@"discount"] doubleValue];
     
+    
+    NSString* product_id = [item_json valueForKey:@"product_id"];
+    
+    // handle no such model
+    if(product_id.length==0)
+        cell.labelNoSuchModel.hidden=false;
+    else
+        cell.labelNoSuchModel.hidden=true;
+    
     //    discount = 5.0;
     cell.discount = discount;
     
@@ -1892,20 +1906,28 @@
     
     
     noteRowAction.backgroundColor = [UIColor lightGrayColor];
-    
+
+
     
     
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
     if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
     {
+        NSMutableDictionary * item_json = [self.content_arr[indexPath.row ] mutableCopy];// [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]]
+        NSString* product_id = [item_json valueForKey:@"product_id"];
+        
+        
         NSMutableArray* arr=[@[] mutableCopy];
         
-        [arr addObject:noteRowAction];
+        if(product_id.length>0)
+            [arr addObject:noteRowAction];
         
         [arr addObject:deleteRowAction];
-        [arr addObject:addWatchAction];
         
-        if(appDelegate.can_set_cart_price)
+        if(product_id.length>0)
+            [arr addObject:addWatchAction];
+        
+        if(appDelegate.can_set_cart_price && product_id.length>0)
         {
             [arr addObject:editRowAction];
             // [arr addObject:freeRowAction];

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

@@ -51,6 +51,7 @@
 @property bool noprice;
 @property (strong, nonatomic) IBOutlet UIImageView *img_checkmark;
 
+@property (strong, nonatomic) IBOutlet UILabel *labelNoSuchModel;
 
 @property (nonatomic , copy) void (^onReturnQTY)(int qty);
 

+ 23 - 0
RedAnt ERP Mobile/common/Functions/category/CategorySearchFilterViewController.h

@@ -0,0 +1,23 @@
+//
+//  CategoryFilterViewController.h
+//  iSales-NPD
+//
+//  Created by Ray on 3/4/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "EnumSelectViewController.h"
+@interface CategorySearchFilterViewController : UIViewController//<EnumSelectViewControllerDelegate>
+@property (strong, nonatomic) NSDictionary* alert_cadedate;
+@property (strong, nonatomic) NSDictionary* qty_cadedate;
+@property (strong, nonatomic) NSDictionary* availability_cadedate;
+
+
+@property (strong, nonatomic) IBOutlet UIButton *buttonQTY;
+@property (strong, nonatomic) IBOutlet UIButton *buttonAlert;
+@property (strong, nonatomic) IBOutlet UIButton *buttonAvailability;
+
+@property (nonatomic , copy) void (^OkClick)(NSString* available,NSString* QTY,NSString* alert);
+@property (nonatomic , copy) void (^ResetClick)(void);
+@end

+ 397 - 0
RedAnt ERP Mobile/common/Functions/category/CategorySearchFilterViewController.m

@@ -0,0 +1,397 @@
+//
+//  CategoryFilterViewController.m
+//  iSales-NPD
+//
+//  Created by Ray on 3/4/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "CategorySearchFilterViewController.h"
+
+@interface CategorySearchFilterViewController ()
+
+@end
+
+@implementation CategorySearchFilterViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    
+    UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
+                                                                    style:UIBarButtonItemStylePlain
+                                                                   target:self
+                                                                   action:@selector( onCloseClick:)];
+    
+    
+    self.navigationItem.rightBarButtonItem = closeButton;
+    
+    
+    self.edgesForExtendedLayout = UIRectEdgeNone;
+    
+    
+    {
+        
+        NSString* qty =@"";
+        int count = [[self.alert_cadedate valueForKey:@"count"] intValue];
+        for(int i=0;i<count;i++)
+        {
+            NSDictionary* val_json =[self.qty_cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
+            int check = [[val_json valueForKey:@"check"] intValue];
+            if(check==1)
+            {
+                qty = [qty stringByAppendingString:[val_json valueForKey:@"value"]];
+                break;
+            }
+        }
+        if(qty.length>0)
+            [self.buttonQTY setTitle:qty forState:UIControlStateNormal];
+        
+    }
+    
+    {
+        
+        NSString* availiablity =@"";
+        int count = [[self.availability_cadedate valueForKey:@"count"] intValue];
+        for(int i=0;i<count;i++)
+        {
+            NSDictionary* val_json =[self.availability_cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
+            int check = [[val_json valueForKey:@"check"] intValue];
+            if(check==1)
+            {
+                availiablity = [availiablity stringByAppendingString:[val_json valueForKey:@"value"]];
+                break;
+            }
+        }
+        if(availiablity.length>0)
+            [self.buttonAvailability setTitle:availiablity forState:UIControlStateNormal];
+        
+    }
+    
+    {
+        NSString* alert =@"";
+        int count = [[self.alert_cadedate valueForKey:@"count"] intValue];
+        for(int i=0;i<count;i++)
+        {
+            NSDictionary* val_json =[self.alert_cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
+            int check = [[val_json valueForKey:@"check"] intValue];
+            if(check==1)
+            {
+                alert = [alert stringByAppendingString:[val_json valueForKey:@"value"]];
+                break;
+            }
+        }
+        if(alert.length>0)
+            [self.buttonAlert setTitle:alert forState:UIControlStateNormal];
+    }
+    // Do any additional setup after loading the view.
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+/*
+ #pragma mark - Navigation
+ 
+ // In a storyboard-based application, you will often want to do a little preparation before navigation
+ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+ // Get the new view controller using [segue destinationViewController].
+ // Pass the selected object to the new view controller.
+ }
+ */
+- (IBAction)onResetClick:(id)sender {
+    
+    if(self.ResetClick)
+        self.ResetClick();
+    [self dismissViewControllerAnimated:true completion:nil];
+}
+- (IBAction)onCloseClick:(id)sender {
+    [self dismissViewControllerAnimated:true completion:nil];
+}
+- (IBAction)onAvailabilityClick:(id)sender {
+    EnumSelectViewController* enumvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"EnumSelectorViewController"];
+  //  enumvc.delegate = self;
+    enumvc.max_select = 1;
+    //enumvc.updatePosition = indexPath;
+    //        if([[required lowercaseString] isEqualToString:@"true"])
+    //        enumvc.canbeEmpty = false;
+    //        else
+    //        enumvc.canbeEmpty =true;
+    enumvc.cadedate = [self.availability_cadedate mutableCopy];
+    enumvc.title = @"Select";
+    //       enumvc.value = [value_json mutableCopy];
+    enumvc.single_select =true;
+    
+    
+    enumvc.returnValue = ^(NSMutableDictionary* value){
+        self.availability_cadedate = value;
+        
+        
+        NSString* available =@"";
+        int count = [[value valueForKey:@"count"] intValue];
+        for(int i=0;i<count;i++)
+        {
+            NSDictionary* val_json =[value objectForKey:[NSString stringWithFormat:@"val_%d",i]];
+            int check = [[val_json valueForKey:@"check"] intValue];
+            if(check==1)
+            {
+                available = [available stringByAppendingString:[val_json valueForKey:@"value"]];
+                break;
+            }
+        }
+        
+        [self.buttonAvailability setTitle:available forState:UIControlStateNormal];
+    };
+    
+    [self.navigationController pushViewController:enumvc animated:true];
+}
+- (IBAction)onQTYClick:(id)sender {
+    EnumSelectViewController* enumvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"EnumSelectorViewController"];
+ //   enumvc.delegate = self;
+    enumvc.max_select = 1;
+    //enumvc.updatePosition = indexPath;
+    //        if([[required lowercaseString] isEqualToString:@"true"])
+    //        enumvc.canbeEmpty = false;
+    //        else
+    //        enumvc.canbeEmpty =true;
+    enumvc.cadedate = [self.qty_cadedate mutableCopy];
+    enumvc.title = @"Select";
+    //       enumvc.value = [value_json mutableCopy];
+    enumvc.single_select =true;
+    
+    
+    enumvc.returnValue = ^(NSMutableDictionary* value){
+        self.qty_cadedate = value;
+        
+        
+        NSString* qty =@"";
+        int count = [[value valueForKey:@"count"] intValue];
+        for(int i=0;i<count;i++)
+        {
+            NSDictionary* val_json =[value objectForKey:[NSString stringWithFormat:@"val_%d",i]];
+            int check = [[val_json valueForKey:@"check"] intValue];
+            if(check==1)
+            {
+                qty = [qty stringByAppendingString:[val_json valueForKey:@"value"]];
+                break;
+            }
+        }
+        
+        [self.buttonQTY setTitle:qty forState:UIControlStateNormal];
+    };
+    
+    [self.navigationController pushViewController:enumvc animated:true];
+}
+- (IBAction)onAlertClick:(id)sender {
+    
+    
+    
+    
+    
+    
+    
+    EnumSelectViewController* enumvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"EnumSelectorViewController"];
+ //   enumvc.delegate = self;
+    enumvc.max_select = 1;
+    //enumvc.updatePosition = indexPath;
+    //        if([[required lowercaseString] isEqualToString:@"true"])
+    //        enumvc.canbeEmpty = false;
+    //        else
+    //        enumvc.canbeEmpty =true;
+    enumvc.cadedate = [self.alert_cadedate mutableCopy];
+    enumvc.title = @"Select";
+    //       enumvc.value = [value_json mutableCopy];
+    enumvc.single_select =true;
+    
+    enumvc.returnValue = ^(NSMutableDictionary* value){
+        self.alert_cadedate = value;
+        
+        
+        NSString* alert =@"";
+        int count = [[value valueForKey:@"count"] intValue];
+        for(int i=0;i<count;i++)
+        {
+            NSDictionary* val_json =[value objectForKey:[NSString stringWithFormat:@"val_%d",i]];
+            int check = [[val_json valueForKey:@"check"] intValue];
+            if(check==1)
+            {
+                alert = [alert stringByAppendingString:[val_json valueForKey:@"value"]];
+                break;
+            }
+        }
+        
+        [self.buttonAlert setTitle:alert forState:UIControlStateNormal];
+    };
+    
+    [self.navigationController pushViewController:enumvc animated:true];
+    
+}
+- (IBAction)onSearchClick:(id)sender {
+    
+    
+    NSString* qty = [self.buttonQTY titleForState:UIControlStateNormal];
+    if(qty.length==0 || [qty isEqualToString:@"Click to select"])
+        qty = nil;
+    
+    NSString* available = [self.buttonAvailability titleForState:UIControlStateNormal];
+    if(available.length==0 || [available isEqualToString:@"Click to select"])
+        available = nil;
+    
+    NSString* alert = [self.buttonAlert titleForState:UIControlStateNormal];
+    if(alert.length==0 || [alert isEqualToString:@"Click to select"])
+        alert = nil;
+    
+    
+    if(self.OkClick)
+        self.OkClick( available, qty, alert);
+    [self dismissViewControllerAnimated:true completion:nil];
+}
+
+//
+//#pragma mark EnumSelectViewControllerDelegate
+//-(void) EnumValueChanged:(NSMutableDictionary *)value indexPath :(NSIndexPath*) indexPath
+//{
+//    
+//    
+//    self.alert_cadedate = value;
+//    
+//    
+//    NSString* alert =@"";
+//    int count = [[value valueForKey:@"count"] intValue];
+//    for(int i=0;i<count;i++)
+//    {
+//        NSDictionary* val_json =[value objectForKey:[NSString stringWithFormat:@"val_%d",i]];
+//        int check = [[val_json valueForKey:@"check"] intValue];
+//        if(check==1)
+//        {
+//            alert = [alert stringByAppendingString:[val_json valueForKey:@"value"]];
+//            break;
+//        }
+//    }
+//    
+//    [self.buttonAlert setTitle:alert forState:UIControlStateNormal];
+//    
+//    //    UITableViewCell *cell = [self.editorTable cellForRowAtIndexPath:indexPath];
+//    //
+//    //
+//    //    //    if(/*self.cancommit==false &&*/ string.length==0 && (textField.text.length<=1|| textField.text==nil))
+//    //    //    {
+//    //    //        CALayer *layer = [cell.contentView layer];
+//    //    //        //            layer.borderColor = [[UIColor redColor] CGColor];
+//    //    //        //            layer.borderWidth = 1.0;
+//    //    //
+//    //    //        layer.shadowColor = [UIColor redColor].CGColor;
+//    //    //        layer.shadowOffset = CGSizeMake(0, 0);
+//    //    //        layer.shadowOpacity = 1;
+//    //    //        layer.shadowRadius = 2.0;
+//    //    //    }
+//    //    //    else
+//    //    {
+//    //        CALayer *layer = [cell.contentView layer];
+//    //        //            layer.borderColor = [[UIColor redColor] CGColor];
+//    //        //            layer.borderWidth = 1.0;
+//    //
+//    //        layer.shadowColor = [UIColor clearColor].CGColor;
+//    //        layer.shadowOffset = CGSizeMake(0, 0);
+//    //        layer.shadowOpacity = 1;
+//    //        layer.shadowRadius = 2.0;
+//    //    }
+//    //
+//    //    NSLog(@"enum changed %ld_%ld",(long)indexPath.section,(long)indexPath.row);
+//    //
+//    //    NSMutableDictionary* section_json=nil;
+//    //
+//    //    NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
+//    //
+//    //
+//    //    //    NSString* param_name=[item_json valueForKey:@"name"];
+//    //    //    NSString* param_val=nil;
+//    //    //
+//    //    //    bool single_select =[[item_json valueForKey:@"single_select"] boolValue];
+//    //    //
+//    //    //    int cade_count = [[value valueForKey:@"count"] intValue];
+//    //    //
+//    //    //    NSMutableArray* arr_val = [[NSMutableArray alloc] init];
+//    //    //
+//    //    //
+//    //    //    for(int cc=0;cc<cade_count;cc++)
+//    //    //    {
+//    //    //        NSDictionary * valjson=[value objectForKey:[NSString stringWithFormat:@"val_%d",cc ]];
+//    //    //        if([[valjson valueForKey:@"check"] boolValue])
+//    //    //        {
+//    //    //            [arr_val addObject: [valjson valueForKey:@"value_id"]];
+//    //    //            if(single_select)
+//    //    //                break;
+//    //    //        }
+//    //    //
+//    //    //    }
+//    //    //
+//    //    //    param_val = [arr_val componentsJoinedByString:@","];
+//    //    //
+//    //    //    [self.changed_data setObject:param_val forKey:param_name];
+//    //
+//    //    int refresh = [[item_json valueForKey:@"refresh"] intValue];
+//    //
+//    //
+//    //    NSString* subid=[item_json valueForKey:@"subid"];
+//    //
+//    //    [item_json setObject:value forKey:@"cadedate"];
+//    //
+//    //
+//    //    if(subid==nil)
+//    //    {
+//    //        [item_json setValue:@"true" forKey:@"dirty"];
+//    //        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 ]];
+//    //
+//    //    }
+//    //
+//    //
+//    //    //    [section_json setObject:item_json forKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row ]];
+//    //
+//    //    [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];
+//    //
+//    //
+//    //    if(refresh==1)
+//    //    {
+//    //        [self refresh] ;
+//    //        return ;
+//    //    }
+//    //
+//    //
+//    //    NSLog(@"CONTENT UPDATE:%@",[iSalesNetwork DataTOjsonString:self.content_data_download]);
+//    //
+//    //
+//    //
+//    //    //    NSLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
+//    //    [self.editorTable reloadData ];
+//    
+//}
+@end

+ 5 - 0
RedAnt ERP Mobile/common/Functions/category/CategoryViewController.h

@@ -51,6 +51,11 @@
 @property int select_count;
 @property (strong, nonatomic) IBOutlet UILabel *label_net_err;
 
+@property (strong,nonatomic) NSString* p_alert;
+@property (strong,nonatomic) NSString* p_available;
+@property (strong,nonatomic) NSString* p_QTY;
+
+
 
 //@property bool disable_refresh;
 @end

+ 119 - 55
RedAnt ERP Mobile/common/Functions/category/CategoryViewController.m

@@ -7,6 +7,7 @@
 //
 
 #import "CategoryViewController.h"
+#import "CategorySearchFilterViewController.h"
 #import "DetailHeaderCell.h"
 #import "DetailImageCell.h"
 #import "iSalesNetwork.h"
@@ -134,6 +135,67 @@
 //             }
 //
 //     }
+
+- (IBAction)onFilterClicked:(id)sender {
+    
+    CategorySearchFilterViewController * filterVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"CategorySearchFilterViewController"];
+    
+    //----------fake category filter----------------
+    NSData* json =nil;
+    json=[NSData dataWithContentsOfFile:[[NSBundle mainBundle]  pathForResource:@"debug_category_filter" ofType:@"json" ]];
+    NSError *error=nil;
+    NSMutableDictionary* filter = [[NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error] mutableCopy];
+    [self.category_data setObject:filter forKey:@"filter"];
+    //----------fake category filter----------------
+    
+    filterVC.alert_cadedate =[[self.category_data objectForKey:@"filter"] objectForKey:@"alert"];
+    filterVC.qty_cadedate=[[self.category_data objectForKey:@"filter"] objectForKey:@"qty"];
+    filterVC.availability_cadedate=[[self.category_data objectForKey:@"filter"] objectForKey:@"availability"];
+    filterVC.OkClick =^(NSString* available,NSString* QTY,NSString* alert)
+    {
+        self.p_alert=available;
+        self.p_QTY=QTY;
+        self.p_available=alert;
+        
+        
+        self.offset = 0;
+        [self reload];
+        
+    };
+    
+    filterVC.ResetClick =^()
+    {
+        
+        self.p_alert=nil;
+        self.p_QTY=nil;
+        self.p_available=nil;
+        
+        
+        self.offset = 0;
+        [self reload];
+        
+    };
+    
+    UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:filterVC] ;
+    
+    
+    
+    
+    
+    
+    navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
+    [self presentViewController:navi animated:YES completion:^{
+        
+        //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
+        
+        NSLog(@"bundle present.........");
+        
+        //   self.btop = false;
+        //  <#code#>
+    }];
+    
+}
+
 - (IBAction)onSelectClick:(id)sender {
     
     [self begin_select];
@@ -245,6 +307,7 @@
                 else
                 {
                     [main_vc checklogin:false];
+                    [self addtocart];
                 }
             }
             
@@ -269,7 +332,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>
@@ -418,7 +481,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>
@@ -470,7 +533,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>
@@ -742,56 +805,57 @@
     
     [categorymenuVC SetMenu:self.categoryMenu];
 }
-- (IBAction)onSortClick:(id)sender {
-    
-    
-    NSMutableDictionary* sort_json = [self.category_data objectForKey:@"sort"];
-    //   NSDictionary* item_json =[section_json objectForKey:[NSString stringWithFormat:@"item_%d",indexPath.row ]];
-    //    NSString* control = [item_json valueForKey:@"control"];
-    //    if([control isEqualToString:@"enum"])//||[control isEqualToString:@"ui"])
-    //    {
-    
-    //    NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%d",indexPath.row]];
-    //     NSDictionary* cadedate_json = [sort_json objectForKey:@"cadedate"];
-    //   NSDictionary* value_json = [item_json objectForKey:@"value"];
-    //        NSString* single_select = [item_json valueForKey:@"single_select"];
-    //        NSString* required =[item_json valueForKey:@"required"];
-    
-    
-    
-    EnumSelectViewController* enumvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"EnumSelectorViewController"];
-    //        if([[required lowercaseString] isEqualToString:@"true"])
-    //        enumvc.canbeEmpty = false;
-    //        else
-    //        enumvc.canbeEmpty =true;
-    enumvc.cadedate = [sort_json mutableCopy];
-    //       enumvc.value = [value_json mutableCopy];
-    enumvc.single_select =true;
-    enumvc.auto_close = true;
-    enumvc.title = @"sort";
-    enumvc.is_dialog = true;
-    
-    
-    enumvc.returnValue = ^(NSMutableDictionary* value){
-        [self.category_data setObject:value forKey:@"sort"];
-        // NSLog(@"点击了第%d个",pageIndex);
-    };
-    
-    ///    PopupNavigationController * navi=[[PopupNavigationController alloc] initWithRootViewController:enumvc];
-    
-    //  self.aBNewPersonNav = [[UINavigationController alloc] initWithRootViewController:enumvc] ;
-    
-    enumvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-    
-    //  enumvc.delegate = self;
-    [self presentViewController:enumvc animated:YES completion:^{
-        
-        NSLog(@"login.........");
-        //  <#code#>
-    }];
-    //  [self.navigationController pushViewController:enumvc animated:true];
-    
-}
+//
+//- (IBAction)onSortClick:(id)sender {
+//    
+//    
+//    NSMutableDictionary* sort_json = [self.category_data objectForKey:@"sort"];
+//    //   NSDictionary* item_json =[section_json objectForKey:[NSString stringWithFormat:@"item_%d",indexPath.row ]];
+//    //    NSString* control = [item_json valueForKey:@"control"];
+//    //    if([control isEqualToString:@"enum"])//||[control isEqualToString:@"ui"])
+//    //    {
+//    
+//    //    NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%d",indexPath.row]];
+//    //     NSDictionary* cadedate_json = [sort_json objectForKey:@"cadedate"];
+//    //   NSDictionary* value_json = [item_json objectForKey:@"value"];
+//    //        NSString* single_select = [item_json valueForKey:@"single_select"];
+//    //        NSString* required =[item_json valueForKey:@"required"];
+//    
+//    
+//    
+//    EnumSelectViewController* enumvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"EnumSelectorViewController"];
+//    //        if([[required lowercaseString] isEqualToString:@"true"])
+//    //        enumvc.canbeEmpty = false;
+//    //        else
+//    //        enumvc.canbeEmpty =true;
+//    enumvc.cadedate = [sort_json mutableCopy];
+//    //       enumvc.value = [value_json mutableCopy];
+//    enumvc.single_select =true;
+//    enumvc.auto_close = true;
+//    enumvc.title = @"sort";
+//    enumvc.is_dialog = true;
+//    
+//    
+//    enumvc.returnValue = ^(NSMutableDictionary* value, int idx){
+//        [self.category_data setObject:value forKey:@"sort"];
+//        // NSLog(@"点击了第%d个",pageIndex);
+//    };
+//    
+//    ///    PopupNavigationController * navi=[[PopupNavigationController alloc] initWithRootViewController:enumvc];
+//    
+//    //  self.aBNewPersonNav = [[UINavigationController alloc] initWithRootViewController:enumvc] ;
+//    
+//    enumvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
+//    
+//    //  enumvc.delegate = self;
+//    [self presentViewController:enumvc animated:YES completion:^{
+//        
+//        NSLog(@"login.........");
+//        //  <#code#>
+//    }];
+//    //  [self.navigationController pushViewController:enumvc animated:true];
+//    
+//}
 -(void)viewWillLayoutSubviews
 {
     //    if(self.showDetail==true)
@@ -865,7 +929,7 @@
     self.isrefreshing=true;
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
-        NSDictionary* category_more=[iSalesNetwork Category:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:self.offset limit:20] ;
+        NSDictionary* category_more=[iSalesNetwork 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] ;
         
         dispatch_async(dispatch_get_main_queue(), ^{
             
@@ -943,7 +1007,7 @@
         
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
             
-            NSDictionary* category_data=[iSalesNetwork Category:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:0 limit:20];
+            NSDictionary* category_data=[iSalesNetwork Category:self.categoryid customid:0 price_template:0 sort:0 filter:nil keyword:nil offset:0 limit:20 alert:self.p_alert qty:self.p_QTY available:self.p_available];
             
             dispatch_async(dispatch_get_main_queue(), ^{
                 

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

@@ -406,20 +406,7 @@ self.label_net_err.hidden=true;
      [[self navigationController] setNavigationBarHidden:NO animated:NO];
     [self.navigationController pushViewController:cuseditVC animated:false];
     
-//    UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:cuseditVC] ;
-//    
-//    
-//    
-//    
-//    
-//    navi.modalPresentationStyle = UIModalPresentationPageSheet;//有三种状态,自己看看是哪种
-//    [self presentViewController:navi animated:YES completion:^{
-//        
-//        NSLog(@"CreateOrderViewController present.........");
-//        
-//        //   self.btop = false;
-//        //  <#code#>
-//    }];
+
 }
 - (IBAction)resetContactId:(id)sender {
     

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

@@ -253,7 +253,7 @@
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
         NSDictionary* editor_json = nil;
-        NSString* contactId=[upparams valueForKey:@"contactId"];
+     //   NSString* contactId=[upparams valueForKey:@"contactId"];
         if(self.bnewcustomer )
             editor_json=[iSalesNetwork save_newCustomer:upparams];
         else

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

@@ -252,7 +252,7 @@
 #pragma mark - Table view data source
 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
 {
-    UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];
+  //  UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];
     //    if (UIInterfaceOrientationIsLandscape(orientation)|| UIInterfaceOrientationIsPortrait(orientation))
     //    {
     //        self.orientation = orientation;
@@ -404,11 +404,15 @@
             
         }
         
+        
+        //Capturing strongly  warring;
+        __block CycleScrollView *brimgScroll= imgScroll;
+        
         imgScroll.fetchContentViewAtIndex = ^UIView *(NSInteger pageIndex){
             
             
             
-            SliderPage* page =imgScroll.arr_Pages[pageIndex];
+            SliderPage* page =brimgScroll.arr_Pages[pageIndex];
             [page loadImage];
             
             
@@ -419,7 +423,7 @@
             //                return viewsArray[pageIndex];
         };
         imgScroll.totalPagesCount = ^NSInteger(void){
-            return imgScroll.arr_Pages.count; //viewsArray.count;
+            return brimgScroll.arr_Pages.count; //viewsArray.count;
         };
         imgScroll.TapActionBlock = ^(NSInteger pageIndex){
             NSLog(@"点击了第%ld个",(long)pageIndex);

+ 29 - 2
RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.m

@@ -137,7 +137,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>
@@ -221,6 +221,33 @@
                 else
                 {
                     [main_vc checklogin:true];
+                    
+                    int c=[self.count_Label.text intValue];
+                    NSLog(@"count label : %@ , convert:%d", self.count_Label.text ,c);
+                    
+                    NSString* ct=[self.count_Label.text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
+                    
+                    
+                    
+                    if(c<count)
+                    {
+                        
+                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Availability %@",ct ] message:NSLocalizedString(@"Confirm add to cart. ", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Confirm", nil), nil];
+                        
+                        // alert.
+                        
+                        alert.tag = 1234;
+                        [alert show];
+                    }
+                    else
+                    {
+                        if(appDelegate.order_code==nil)
+                            [ self neworder];
+                        else
+                            [self addtocart:count];
+                    }
+                    
+                    
                 }
             }
             
@@ -245,7 +272,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>

+ 9 - 5
RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m

@@ -350,21 +350,25 @@ self.isrefreshing=false;
         CGFloat height = 70*selector_count;
         self.dropDown =[[NIDropDown alloc] showDropDown:self.detailTable based:(id)trigger height:height data:self.selector direction:@"down" current_sel:current_sel];
         
+        
+        //Capturing strongly  warring;
+        __block DetailViewController *brself= self;
+        
         self.dropDown.selectChanged =^(long index){
             
             
-            NSDictionary* item = [self.selector objectForKey:[NSString stringWithFormat:@"item_%ld",index]];
+            NSDictionary* item = [brself.selector objectForKey:[NSString stringWithFormat:@"item_%ld",index]];
             
             NSDictionary* params = [item objectForKey:@"params"];
             
             NSString* detail_id=[[[params objectForKey:@"param_0"] valueForKey:@"val" ] stringValue];
             
             
-            self.product_id = detail_id;
-            self.use_model_name = false;
-            [self reload];
+            brself.product_id = detail_id;
+            brself.use_model_name = false;
+            [brself reload];
             NSLog(@"color selected");
-            self.dropDown = nil;
+            brself.dropDown = nil;
             
             
             

+ 139 - 98
RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m

@@ -225,6 +225,14 @@
                     if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
                         self.cancommit = false;
                 }
+                else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
+                {
+                    if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"]==nil)
+                        self.cancommit = false;
+                    
+                    NSString* valuestr = [itemjson valueForKey:@"value"];
+                    [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
+                }
                 else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
                 {
                     NSString* valuestr = [itemjson valueForKey:@"value"];
@@ -320,6 +328,13 @@
                 
                 [RAUtils message_alert:nil title:@"Order Saved" controller:self] ;
                 
+                if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+                {
+                    [((MainViewController*)appDelegate.main_vc) Loginout];
+                    [self prepareReturn:nil];
+                    [self.navigationController popViewControllerAnimated:true];
+                }
+                
                 
                 //                if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
                 //                    appDelegate.order_code = nil;
@@ -532,6 +547,14 @@
                         if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
                             self.cancommit = false;
                     }
+                    else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
+                    {
+                        if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"] ==nil)
+                            self.cancommit = false;
+                        
+                        NSString* valuestr = [itemjson valueForKey:@"value"];
+                        [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
+                    }
                     else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
                     {
                         NSString* valuestr = [itemjson valueForKey:@"value"];
@@ -644,6 +667,12 @@
                                     [appDelegate closeOrder];
                                     [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
                                     
+                                    
+                                    if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
+                                    {
+                                        [((MainViewController*)appDelegate.main_vc) Loginout];
+                                    }
+                                    
                                     //    //     self.labelContact.text=appDelegate.contact_name;
                                     //
                                     //    NSDictionary * customerinfo = appDelegate.customerInfo;
@@ -799,6 +828,11 @@
                                     //                                appDelegate.order_code = nil;
                                     [appDelegate closeOrder];
                                     [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                                    
+                                    if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
+                                    {
+                                        [((MainViewController*)appDelegate.main_vc) Loginout];
+                                    }
                                     //    //     self.labelContact.text=appDelegate.contact_name;
                                     //
                                     //    NSDictionary * customerinfo = appDelegate.customerInfo;
@@ -917,104 +951,104 @@
         
     }
     
-    else if( alertView.tag == KEEP_TAIL)
-    {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Submit Order"];
-        if(buttonIndex!=alertView.cancelButtonIndex)
-        {//keep tail;
-            
-            [self.upparams setValue:@"true" forKey:@"isHold"];
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                
-                NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:self.upparams];
-                
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-                    
-                    
-                    if([[editor_json valueForKey:@"result"] intValue]==2)
-                    {
-                        NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Submit successful." message:[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-                        
-                        [alert show];
-                        
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        appDelegate.customerInfo = customerInfo;
-                        appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
-                        NSString* orderCode = [editor_json valueForKey:@"orderCode"];
-                        appDelegate.order_code = orderCode;
-                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-                        //    //     self.labelContact.text=appDelegate.contact_name;
-                        //
-                        //    NSDictionary * customerinfo = appDelegate.customerInfo;
-                        [self prepareReturn:nil];
-//                        [self.navigationController dismissViewControllerAnimated:true completion:^{
-//                            
-//                            
-//                            ;
-//                        }];
-                        [self.navigationController popViewControllerAnimated:true];
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[editor_json valueForKey:@"err_msg"]  title:@"Submit Order" controller:self] ;
-                    }
-                    
-                    
-                    
-                    
-                });
-            });
-        }
-        else
-        {// not keep tail;
-            [self.upparams setValue:@"false" forKey:@"isHold"];
-            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-                
-                NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:self.upparams];
-                
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-                    
-                    
-                    if([[editor_json valueForKey:@"result"] intValue]==2)
-                    {
-                        //    NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Submit successful." message:[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-                        
-                        [alert show];
-                        
-                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-                        //                        appDelegate.customerInfo = customerInfo;
-                        //                        appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
-                        //                        appDelegate.order_code = nil;
-                        [appDelegate closeOrder];
-                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-                        //    //     self.labelContact.text=appDelegate.contact_name;
-                        //
-                        //    NSDictionary * customerinfo = appDelegate.customerInfo;
-                        [self prepareReturn:nil];
-//                        [self.navigationController dismissViewControllerAnimated:true completion:^{
-//                            
-//                            
-//                            ;
-//                        }];
-                        [self.navigationController popViewControllerAnimated:true];
-                        
-                    }
-                    else
-                    {
-                        [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Submit Order" controller:self] ;
-                    }
-                    
-                    
-                    
-                    
-                });
-            });
-        }
-    }
+//    else if( alertView.tag == KEEP_TAIL)
+//    {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Submit Order"];
+//        if(buttonIndex!=alertView.cancelButtonIndex)
+//        {//keep tail;
+//            
+//            [self.upparams setValue:@"true" forKey:@"isHold"];
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//                
+//                NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:self.upparams];
+//                
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//                    [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//                    
+//                    
+//                    if([[editor_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
+//                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Submit successful." message:[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+//                        
+//                        [alert show];
+//                        
+//                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                        appDelegate.customerInfo = customerInfo;
+//                        appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
+//                        NSString* orderCode = [editor_json valueForKey:@"orderCode"];
+//                        appDelegate.order_code = orderCode;
+//                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//                        //    //     self.labelContact.text=appDelegate.contact_name;
+//                        //
+//                        //    NSDictionary * customerinfo = appDelegate.customerInfo;
+//                        [self prepareReturn:nil];
+////                        [self.navigationController dismissViewControllerAnimated:true completion:^{
+////                            
+////                            
+////                            ;
+////                        }];
+//                        [self.navigationController popViewControllerAnimated:true];
+//                        
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[editor_json valueForKey:@"err_msg"]  title:@"Submit Order" controller:self] ;
+//                    }
+//                    
+//                    
+//                    
+//                    
+//                });
+//            });
+//        }
+//        else
+//        {// not keep tail;
+//            [self.upparams setValue:@"false" forKey:@"isHold"];
+//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+//                
+//                NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:self.upparams];
+//                
+//                dispatch_async(dispatch_get_main_queue(), ^{
+//                    [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+//                    
+//                    
+//                    if([[editor_json valueForKey:@"result"] intValue]==2)
+//                    {
+//                        //    NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
+//                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Submit successful." message:[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+//                        
+//                        [alert show];
+//                        
+//                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                        //                        appDelegate.customerInfo = customerInfo;
+//                        //                        appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
+//                        //                        appDelegate.order_code = nil;
+//                        [appDelegate closeOrder];
+//                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+//                        //    //     self.labelContact.text=appDelegate.contact_name;
+//                        //
+//                        //    NSDictionary * customerinfo = appDelegate.customerInfo;
+//                        [self prepareReturn:nil];
+////                        [self.navigationController dismissViewControllerAnimated:true completion:^{
+////                            
+////                            
+////                            ;
+////                        }];
+//                        [self.navigationController popViewControllerAnimated:true];
+//                        
+//                    }
+//                    else
+//                    {
+//                        [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Submit Order" controller:self] ;
+//                    }
+//                    
+//                    
+//                    
+//                    
+//                });
+//            });
+//        }
+//    }
     else if(alertView.tag == CLOSE_ACTION)
     {
         if(buttonIndex==1)
@@ -1069,6 +1103,13 @@
                         
                         [appDelegate closeOrder];
                         [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+                         [((MainViewController*)appDelegate.main_vc) switchToHome];
+                        
+                        if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
+                        {
+                            [((MainViewController*)appDelegate.main_vc) Loginout];
+                        }
+                        
                         [self prepareReturn:nil];
                         
                         

+ 25 - 74
RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m

@@ -35,6 +35,19 @@
 @end
 
 @implementation OrderDetailViewController
+-(void) reload_container_getdata:(bool) update_data
+{
+    
+    [super reload_container_getdata:update_data];
+    if(update_data)
+        [self reload_data];
+    else
+    {
+        [self.detailTable reloadData];
+       
+    }
+}
+
 - (void)onBackClick:(UIButton *)sender {
     
     
@@ -187,7 +200,7 @@
     self.btnOpen.enabled =false;
     self.btnSign.enabled = false;
     
-    //            self.btnCommit.enabled =false;
+    self.btnCopy.enabled =false;
     self.btnPDF.enabled =false;
     self.btnRelease.enabled =false;
     //    if(self.isTempOrder)
@@ -212,7 +225,7 @@
     
     
     [self loaddata];
-    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+  //  AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
 }
 
 
@@ -325,12 +338,12 @@
     ViewController.mail_subject = subject;
     
     
-    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Select Sales Order style:" message:nil preferredStyle:UIAlertControllerStyleAlert];
+    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"View Sales Order:" message:nil preferredStyle:UIAlertControllerStyleAlert];
     //block代码块取代了delegate
     
     
     
-    UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"With model thumb" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+    UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"With item images" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
         NSString* url=[self.content_data valueForKey:@"pdfUrl"];
         
         
@@ -345,7 +358,7 @@
         
     }];
     
-    UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Without model thumb" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+    UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Without item images" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
         NSString* url=[self.content_data valueForKey:@"pdfUrl"];
         NSLog(@"pdf url:%@",url);
         ViewController.url = url;
@@ -596,73 +609,7 @@
     
     
     UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-        //      int count =[[self.content_data valueForKey:@"model_count"] intValue];
-        
-        //        if(count>0)
-        //        {
-        //        /*
-        //
-        //         //检查赠品符合条件
-        //         NSDictionary * freejson = [self.content_data objectForKey:@"freeGiveaway"];
-        //
-        //         int free_count = [[freejson valueForKey:@"count"]intValue];
-        //         for(int ic=free_count-1;ic>=0;ic--)
-        //         {
-        //         float compare_price = [[freejson valueForKey:[NSString stringWithFormat:@"item_%d",ic]] floatValue];
-        //         if(self.total>=compare_price && !have_free)
-        //         {
-        //
-        //         UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Free give away available.", nil) message:[NSString stringWithFormat:@"Order total price more than %.2f, do you want to add free give away item before place order?", compare_price] delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
-        //         alert.tag = ALERT_FREE;
-        //         [alert show];
-        //         return;
-        //
-        //         }
-        //         }
-        //
-        //
-        //         */
-        //
-        //
-        //            NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
-        //            //   NSString * string = [checked componentsJoinedByString:@","];
-        //            //  [params setValue:string forKey:@"cart2Checkbox"];
-        //
-        //
-        //
-        //            CreateOrderViewController * orderinfoVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"CreateOrderViewController"];
-        //
-        //
-        //            orderinfoVC.url_type = URL_REMOTE;
-        //            orderinfoVC.request_url=URL_CARTDELIVERY;
-        //
-        //            orderinfoVC.params = params;
-        //
-        //            orderinfoVC.delegate=self;
-        //            //
-        //            //    if(checked.count==count)
-        //            //    {
-        //            //    orderinfoVC.have_tail = true
-        //            //    }
-        //
-        //            UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:orderinfoVC] ;
-        //
-        //
-        //
-        //
-        //
-        //            navi.modalPresentationStyle = UIModalPresentationPageSheet;//有三种状态,自己看看是哪种
-        //            [self presentViewController:navi animated:YES completion:^{
-        //
-        //                NSLog(@"CreateOrderViewController present.........");
-        //
-        //                //   self.btop = false;
-        //                //  <#code#>
-        //            }];
-        //
-        //        }
-        //
-        //        else
+     
         {
             UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Open Order"];
             dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@@ -779,7 +726,11 @@
                         [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Loading Order Detail" controller:self] ;
                     }
                 
-                
+                bool web_order =[[self.content_data valueForKey:@"from_online"] boolValue];
+                if(web_order)
+                    self.btnCopy.enabled = false;
+                else
+                    self.btnCopy.enabled = true;
                 int model_count =[[self.content_data valueForKey:@"model_count"] intValue];
                 if(model_count>0)
                     self.btnPDF.enabled =true;
@@ -1591,7 +1542,7 @@
                 [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
                 if([[order_json valueForKey:@"result"] intValue]==2)
                 {
-                    NSString* orderCode = [order_json valueForKey:@"orderCode"];
+               //     NSString* orderCode = [order_json valueForKey:@"orderCode"];
                     
                     //                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                     //                    if([appDelegate.order_code isEqualToString: self.order_code])

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

@@ -702,7 +702,7 @@ dispatch_async(dispatch_get_main_queue(), ^{
     modellabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
     modellabel.textColor=[UIColor whiteColor];
     modellabel.backgroundColor = [UIColor clearColor];
-    modellabel.text=NSLocalizedString(@"Model", nil);
+    modellabel.text=NSLocalizedString(@"Items/QTY", nil);
     [modellabel sizeToFit];
     [myView addSubview:modellabel];
     

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

@@ -135,7 +135,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>
@@ -464,7 +464,7 @@
     navi.modalPresentationStyle = UIModalPresentationPageSheet;//有三种状态,自己看看是哪种
     [self presentViewController:navi animated:YES completion:^{
         
-        NSLog(@"CreateOrderViewController present.........");
+        NSLog(@"TearSheetParamViewController present.........");
         
         //   self.btop = false;
         //  <#code#>
@@ -627,51 +627,7 @@
     [super viewWillAppear:animated];
     
 
-    //
-    //    UIApplication * app = [UIApplication sharedApplication];
-    //    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-    //    if(appDelegate.bLogin==false)
-    //    {
-    //        LoginViewController * loginvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
-    //        //        loginvc.delegate = self;
-    //        //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-    //
-    //        loginvc.returnValue = ^(bool blogin){
-    //
-    //
-    //            UIApplication * app = [UIApplication sharedApplication];
-    //            AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-    //            MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-    //
-    //            [main_vc checklogin:true];
-    //
-    //            //            [self reload_data];
-    //
-    //            [[self navigationController] setNavigationBarHidden:YES animated:NO];
-    //
-    //        };
-    //
-    //        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-    //
-    //
-    //
-    //
-    //
-    //        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-    //
-    //        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
-    //        [self presentViewController:navi animated:YES completion:^{
-    //
-    //            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-    //
-    //            NSLog(@"CreateOrderViewController present.........");
-    //
-    //            //   self.btop = false;
-    //            //  <#code#>
-    //        }];
-    //    }
-    //    else
-    //        [self reload_data];
+   
     
     [[self navigationController] setNavigationBarHidden:YES animated:NO];
 }

+ 4 - 3
RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchViewController.m

@@ -633,6 +633,7 @@
                 else
                 {
                     [main_vc checklogin:false];
+                    [self addtocart];
                 }
             }
             
@@ -657,7 +658,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>
@@ -806,7 +807,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>
@@ -858,7 +859,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>

+ 9 - 8
RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m

@@ -121,11 +121,11 @@
         [self.collectionview reloadData];
 }
 - (IBAction)onSelectClick:(id)sender {
-    
-    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    
-    [appDelegate test_onDecodedDataResult:@"108530-HS01"];
-    return;
+//    
+//    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//    
+//    [appDelegate test_onDecodedDataResult:@"108530-HS01"];
+//    return;
     
     [self begin_select];
 }
@@ -558,6 +558,7 @@
                 else
                 {
                     [main_vc checklogin:false];
+                    [self addtocart];
                 }
             }
             
@@ -582,7 +583,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>
@@ -730,7 +731,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>
@@ -782,7 +783,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>

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

@@ -96,14 +96,14 @@
     
     
     self.btnLogin.enabled = false;
-    
+    UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Login"];
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
         
         int ret=[iSalesNetwork  Authorize:user password:password];
         
         dispatch_async(dispatch_get_main_queue(), ^{
-            
+            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
             self.btnLogin.enabled = true;
             
             if(ret==RESULT_TRUE)

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

@@ -7,7 +7,7 @@
 //
 
 #import "SignatureViewController.h"
-
+#import "const.h"
 @interface SignatureViewController ()
 
 @end
@@ -22,14 +22,36 @@
     }
     return self;
 }
-
+- (void)onBackClick:(UIButton *)sender {
+    
+    
+    [self.navigationController popViewControllerAnimated:FALSE];
+}
 - (void)viewDidLoad
 {
     [super viewDidLoad];
     self.navigationItem.title = self.title;
     
-    UIBarButtonItem *clearBtn=[[UIBarButtonItem alloc]initWithTitle:@"Clear" style:UIBarButtonItemStylePlain target:self action:@selector(onClear:)];
-    UIBarButtonItem *doneBtn=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(onDone:)];
+    
+    UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                                                    style:UIBarButtonItemStylePlain
+                                                                   target:self
+                                                                   action:@selector( onBackClick:)];
+    
+    closeButton.tintColor = UIColorFromRGB(0x996633);
+    self.navigationItem.leftBarButtonItem=closeButton;
+    
+    
+    UIBarButtonItem *clearBtn=[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"clear"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                                               style:UIBarButtonItemStylePlain
+                                                              target:self
+                                                              action:@selector( onClear:)];
+        clearBtn.tintColor = UIColorFromRGB(0x996633);
+    UIBarButtonItem *doneBtn=[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"save"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                                              style:UIBarButtonItemStylePlain
+                                                             target:self
+                                                             action:@selector( onDone:)];
+        doneBtn.tintColor = UIColorFromRGB(0x996633);
     
     //  id aa = self.navigationItem;
     

+ 3 - 48
RedAnt ERP Mobile/common/Functions/watchlist/WatchListViewController.m

@@ -123,7 +123,7 @@
             
             //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
             
-            NSLog(@"CreateOrderViewController present.........");
+            NSLog(@"LoginViewController present.........");
             
             //   self.btop = false;
             //  <#code#>
@@ -453,7 +453,7 @@
     navi.modalPresentationStyle = UIModalPresentationPageSheet;//有三种状态,自己看看是哪种
     [self presentViewController:navi animated:YES completion:^{
         
-        NSLog(@"CreateOrderViewController present.........");
+        NSLog(@"TearSheetParamViewController present.........");
         
         //   self.btop = false;
         //  <#code#>
@@ -599,52 +599,7 @@
 {
     
     [super viewWillAppear:animated];
-//    
-//    UIApplication * app = [UIApplication sharedApplication];
-//    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-//    if(appDelegate.bLogin==false)
-//    {
-//        LoginViewController * loginvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
-//        //        loginvc.delegate = self;
-//        //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-//        
-//        loginvc.returnValue = ^(bool blogin){
-//            
-//            
-//            UIApplication * app = [UIApplication sharedApplication];
-//            AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-//            MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-//            
-//            [main_vc checklogin:true];
-//            
-//            //            [self reload_data];
-//            
-//            [[self navigationController] setNavigationBarHidden:YES animated:NO];
-//            
-//        };
-//        
-//        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-//        
-//        
-//        
-//        
-//        
-//        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-//        
-//        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
-//        [self presentViewController:navi animated:YES completion:^{
-//            
-//            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-//            
-//            NSLog(@"CreateOrderViewController present.........");
-//            
-//            //   self.btop = false;
-//            //  <#code#>
-//        }];
-//    }
-//    else
-//        [self reload_data];
-    
+
     [[self navigationController] setNavigationBarHidden:YES animated:NO];
 }
 

+ 8 - 0
RedAnt ERP Mobile/common/RAUtils.h

@@ -7,6 +7,14 @@
 //
 
 #import <Foundation/Foundation.h>
+//typedef  struct {
+//    
+//    NSString* id;
+//    
+//    float  height;
+//    
+//    
+//}MyTestStruct;
 
 @interface RAUtils : NSObject
 +(NSString*) FloatFormat:(float)value;

+ 1 - 1
RedAnt ERP Mobile/common/const.h

@@ -88,7 +88,7 @@
 
 #define USER_ROLE_CUSTOMER 0
 #define USER_ROLE_EMPLOYEE 1
-
+#define USER_ROLE_UNKNOWN 2
 // 如何处理commoneditor action 类型调用的返回值
 #define  ACTION_SAVE_DATA 0
 #define ACTION_FILL_SECTION 1

+ 34 - 0
RedAnt ERP Mobile/common/customUI/ImageUploadViewController.m

@@ -116,6 +116,40 @@
     self.navigationItem.leftBarButtonItem = closeButton;
     
     self.imgview.image = self.img;
+    
+    
+    UIApplication * app = [UIApplication sharedApplication];
+    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+//    [appDelegate didRotated];
+    
+ 
+    
+    NSTimeInterval animationDuration = 0.30f;
+    [UIView beginAnimations:nil context:nil];
+    [UIView setAnimationDuration:animationDuration];
+    
+    UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];
+    if (UIInterfaceOrientationIsLandscape(orientation))
+    {
+        
+        
+        self.buttonAlbum.frame = CGRectMake(942,120,48,48);
+        self.buttonCamera.frame = CGRectMake(942,200,48,48);
+        self.buttonUpload.frame = CGRectMake(942,363,48,48);
+        //        @property (strong, nonatomic) IBOutlet UIButton *buttonAlbum;
+        //        @property (strong, nonatomic) IBOutlet UIButton *buttonCamera;
+        //        @property (strong, nonatomic) IBOutlet UIButton *buttonUpload;
+    }
+    else
+    {
+        self.buttonAlbum.frame = CGRectMake(82,918,48,48);
+        self.buttonCamera.frame = CGRectMake(173,918,48,48);
+        self.buttonUpload.frame = CGRectMake(635,918,48,48);
+        
+    }
+    
+    [UIView commitAnimations];
+    
     // Do any additional setup after loading the view.
 }
 - (void)onBackClick:(UIButton *)sender {

+ 2 - 2
RedAnt ERP Mobile/common/customUI/TouchImageView.m

@@ -27,8 +27,8 @@
 */
 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
     //    [self setTextColor:COLOR(0,0,0,1.0)];
-    UITouch *touch = [touches anyObject];
-    CGPoint points = [touch locationInView:self];
+  //  UITouch *touch = [touches anyObject];
+ //   CGPoint points = [touch locationInView:self];
 //    if (points.x >= self.frame.origin.x && points.y >= self.frame.origin.x && points.x <= self.frame.size.width && points.y <= self.frame.size.height)
 //    {
         [delegate TouchImageViewOnTouche:self];

+ 4 - 1
RedAnt ERP Mobile/common/data_provider/iSalesDB.m

@@ -207,7 +207,7 @@
 {
     sqlite3* db = nil;
     
-    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+  //  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
     NSString *documents = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];//[paths objectAtIndex:0];
     NSString *database_path = [documents stringByAppendingPathComponent:DBNAME];
     
@@ -372,6 +372,8 @@
 + (BOOL) initializeDb {
     DebugLog (@"initializeDB");
     
+    return false;
+    
     //   NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
     NSString *documents = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];//[paths objectAtIndex:0];
     NSString *database_path = [documents stringByAppendingPathComponent:DBNAME];
@@ -460,6 +462,7 @@
         //    //    [self execSql:[NSString stringWithFormat:@"delete from search_history where h_time<%@",timestr ] db:db];
         //        [self execSql:@"delete from search_history where julianday('now', 'localtime')-julianday(h_time, 'localtime')>30" db:db];
         int ret=sqlite3_close(db);
+        return ret;
         //        int aaa = 0;
     }
     return YES;

+ 1 - 1
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.h

@@ -30,7 +30,7 @@
 
 
 //+(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;
++(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;
 
 +(bool) IsNetworkAvailable;
 +(int)parse_authinfo : (NSData *) json user:(NSString*) user password:(NSString*) password;

+ 20 - 4
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m

@@ -1919,8 +1919,10 @@ repeat:{
 //    return jsobj;
 //    
 //}
-+(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
++(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
 {
+    
+
         AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
 
     
@@ -1936,6 +1938,11 @@ repeat:{
         [params setValue:appDelegate.password forKey:@"password"];
     if(appDelegate.order_code!=nil)
         [params setValue:appDelegate.order_code forKey:@"orderCode"];
+    
+    [params setValue:alert forKey:@"alert"];
+    [params setValue:qty forKey:@"sold_by_qty"];
+    [params setValue:available forKey:@"available"];
+    
     [params setValue:[NSString stringWithFormat:@"%d",price_template]  forKey:@"price_template"];
     [params setValue:[NSString stringWithFormat:@"%d",customid]  forKey:@"custom_id"];
     [params setValue:[NSString stringWithFormat:@"%@",category]  forKey:@"category"];
@@ -2169,10 +2176,13 @@ repeat:{
         appDelegate.can_set_tearsheet_price =false;
         appDelegate.can_update_contact_info = false;
         
-        appDelegate.ipad_perm =nil ;
+        appDelegate.save_order_logout = false;
+        appDelegate.submit_order_logout = false;
         
+        appDelegate.ipad_perm =nil ;
+        appDelegate.user_type = USER_ROLE_UNKNOWN;
         [appDelegate SetSo:nil];
-        
+        [appDelegate set_main_button_panel];
     }
     return jsobj;
 }
@@ -2380,13 +2390,19 @@ repeat:{
         appDelegate.can_update_contact_info =[[objheader valueForKey:@"can_update_contact_info"] boolValue];
         appDelegate.can_submit_order =[[objheader valueForKey:@"can_submit_order"] boolValue];
         appDelegate.can_set_tearsheet_price =[[objheader valueForKey:@"can_set_tearsheet_price"] boolValue];
-        
+
+        appDelegate.save_order_logout =[[objheader valueForKey:@"save_order_logout"] boolValue];
+        appDelegate.submit_order_logout =[[objheader valueForKey:@"submit_order_logout"] boolValue];
+
         
         
 
         
         appDelegate.ipad_perm =[objheader valueForKey:@"ipad_perm"] ;
         
+        
+        [appDelegate set_main_button_panel];
+        
 
         //        DebugLog(@"sessionid=%@ ",appDelegate.sessionid);
         //        if ([[objheader valueForKey:@"update"] boolValue]==false)