Ray Zhang пре 10 година
родитељ
комит
e1964f8d3f

+ 5 - 2
RedAnt ERP Mobile/common/Functions/portfolio/PortfolioEditQTYViewController.h

@@ -11,14 +11,17 @@
 @interface PortfolioEditQTYViewController : UIViewController<UITextFieldDelegate, UITextViewDelegate>
 @interface PortfolioEditQTYViewController : UIViewController<UITextFieldDelegate, UITextViewDelegate>
 @property int qty;
 @property int qty;
 @property (strong, nonatomic) IBOutlet UITextField *editQTY;
 @property (strong, nonatomic) IBOutlet UITextField *editQTY;
-@property (nonatomic , copy) void (^onSetValue)(int qty , double price, double discount, NSString* notes);
+@property (nonatomic , copy) void (^onSetValue)(int qty , double percentage, double price, double discount, NSString* notes);
 @property (strong, nonatomic) IBOutlet UILabel *labelQueryQTY;
 @property (strong, nonatomic) IBOutlet UILabel *labelQueryQTY;
+@property (strong, nonatomic) IBOutlet UILabel *labelQTYTitle;
+@property (strong, nonatomic) IBOutlet UISwitch *switchQTY;
+
 @property (strong, nonatomic) IBOutlet UIButton *buttonRefresh;
 @property (strong, nonatomic) IBOutlet UIButton *buttonRefresh;
 //@property (strong, nonatomic)  NSString * fashionid;
 //@property (strong, nonatomic)  NSString * fashionid;
 @property (strong, nonatomic) NSMutableArray* arr_fashion_ids;
 @property (strong, nonatomic) NSMutableArray* arr_fashion_ids;
 
 
 @property  double price;
 @property  double price;
-
+@property  double qty_p;
 @property  double discount;
 @property  double discount;
 @property (strong, nonatomic) NSString* linenotes;
 @property (strong, nonatomic) NSString* linenotes;
 
 

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

@@ -21,9 +21,17 @@
     
     
     self.edgesForExtendedLayout = UIRectEdgeNone;
     self.edgesForExtendedLayout = UIRectEdgeNone;
     
     
-    
+    self.tv_linenote.delegate = self;
      self.tv_linenote.text=self.linenotes ;
      self.tv_linenote.text=self.linenotes ;
+    if(self.qty>=0)
+    {
     self.editQTY.text = [NSString stringWithFormat:@"%d",self.qty];
     self.editQTY.text = [NSString stringWithFormat:@"%d",self.qty];
+    }
+    else if(self.qty_p>=0)
+    {
+        self.editQTY.text= [NSString stringWithFormat:@"%.2f",self.qty_p];
+        [self.switchQTY setOn: true];
+    }
     [self requestqty];
     [self requestqty];
     
     
     
     
@@ -115,6 +123,27 @@
         });
         });
     });
     });
 }
 }
+- (IBAction)QTYPercentageValueChanged:(id)sender {
+    UISwitch * switchqty =(UISwitch*)sender;
+    if(switchqty.isOn)
+    {
+        if([self.editQTY.text intValue]>100)
+            self.editQTY.text=@"100";
+        
+        
+        self.labelQTYTitle.text = @"Available QTY %";
+        self.editQTY.placeholder =@"Percentage";
+    }
+    else
+    {
+        self.editQTY.text=[NSString stringWithFormat:@"%d",[self.editQTY.text intValue]];
+        
+        self.labelQTYTitle.text = @"Available QTY";
+        self.editQTY.placeholder =@"QTY";
+    }
+}
+
+
 - (IBAction)onSaveClick:(id)sender {
 - (IBAction)onSaveClick:(id)sender {
     
     
     
     
@@ -143,7 +172,20 @@
         //
         //
         //        [alert show];
         //        [alert show];
         
         
-        [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
+        [RAUtils alert_view:@"Percentage must less than 100." title:@"Input Error"];
+        
+        self.editDiscount.text=@"0";
+        
+        return;
+    }
+    if([self.editQTY.text floatValue]>100.0 && self.switchQTY.isOn)
+    {
+        //        UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Discount error" message:@"Discount must less than 100" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
+        //
+        //
+        //        [alert show];
+        
+        [RAUtils alert_view:@"Percentage must less than 100." title:@"Input Error"];
         
         
         self.editDiscount.text=@"0";
         self.editDiscount.text=@"0";
         
         
@@ -153,16 +195,29 @@
     
     
     [self update_newprice];
     [self update_newprice];
     
     
-    
+    bool qtypercentage = self.switchQTY.isOn;
     
     
     if(self.editQTY.text.length==0)
     if(self.editQTY.text.length==0)
-        self.qty=0;
+    {
+        self.qty=-1;
+        self.qty_p=-1;
+    }
     else
     else
+        if(qtypercentage)
+        {
+            self.qty_p=[self.editQTY.text floatValue];
+            self.qty=-1;
+        }
+    else
+    {
         self.qty=[self.editQTY.text intValue];
         self.qty=[self.editQTY.text intValue];
+        self.qty_p=-1;
+    }
     [self dismissViewControllerAnimated:NO
     [self dismissViewControllerAnimated:NO
                              completion:^{
                              completion:^{
                                  if(self.onSetValue)
                                  if(self.onSetValue)
-                                     self.onSetValue( self.qty,self.price,self.discount, self.linenotes);
+                                     
+                                     self.onSetValue( self.qty, self.qty_p,self.price,self.discount, self.linenotes);
                                  
                                  
                              }];
                              }];
 }
 }
@@ -187,6 +242,13 @@
 {
 {
      [self update_newprice];
      [self update_newprice];
 }
 }
+- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
+{
+    int lenth = 20;
+   return lenth>textView.text.length;
+   
+}
+
 #pragma mark textField delegate
 #pragma mark textField delegate
 - (BOOL)textFieldShouldReturn:(UITextField *)textField {
 - (BOOL)textFieldShouldReturn:(UITextField *)textField {
     [textField resignFirstResponder];
     [textField resignFirstResponder];
@@ -246,8 +308,9 @@
     //    if(![keyboard isEqualToString:@"number"])
     //    if(![keyboard isEqualToString:@"number"])
     //        return TRUE;
     //        return TRUE;
     NSCharacterSet *cs;
     NSCharacterSet *cs;
-    if(textField.tag==199)
+    if(textField.tag==199&& ! self.switchQTY.isOn)
     {
     {
+        
         cs = [[NSCharacterSet characterSetWithCharactersInString:INTNUMBERS]invertedSet];
         cs = [[NSCharacterSet characterSetWithCharactersInString:INTNUMBERS]invertedSet];
     }
     }
     else
     else
@@ -265,6 +328,7 @@
 }
 }
 -(void) update_newprice
 -(void) update_newprice
 {
 {
+    
     self.price = [self.editPrice.text doubleValue];
     self.price = [self.editPrice.text doubleValue];
     
     
     self.discount = [self.editDiscount.text doubleValue];
     self.discount = [self.editDiscount.text doubleValue];
@@ -278,7 +342,9 @@
 - (void)textFieldDidEndEditing:(UITextField *)textField
 - (void)textFieldDidEndEditing:(UITextField *)textField
 {
 {
     
     
-    if(textField.tag==2)
+    
+    
+    if(textField.tag==2 || (textField.tag==199&& self.switchQTY.isOn))
     {
     {
         if(textField.text.length==0)
         if(textField.text.length==0)
             textField.text=@"0";
             textField.text=@"0";
@@ -291,7 +357,7 @@
             
             
             
             
             
             
-            [RAUtils alert_view:@"Discount must less than 100." title:@"Input Error."];
+            [RAUtils alert_view:@"Percentage must less than 100." title:@"Input Error."];
             textField.text=@"0";
             textField.text=@"0";
         }
         }
     }
     }

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

@@ -551,24 +551,140 @@
 }
 }
 - (IBAction)onEditClick:(id)sender {
 - (IBAction)onEditClick:(id)sender {
     NSMutableArray* checked = [[NSMutableArray alloc] init];
     NSMutableArray* checked = [[NSMutableArray alloc] init];
-    
+    NSMutableArray* fashion_ids = [[NSMutableArray alloc] init];
     
     
     
     
     int count = [[self.content_data valueForKey:@"count"] intValue];
     int count = [[self.content_data valueForKey:@"count"] intValue];
+    int single_idx=0;
     for(int i=0;i<count;i++)
     for(int i=0;i<count;i++)
     {
     {
+        
+        
         NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%d",i]] mutableCopy];
         NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%d",i]] mutableCopy];
         int check = [[item_json valueForKey:@"check"] intValue];
         int check = [[item_json valueForKey:@"check"] intValue];
         if(check==1)
         if(check==1)
         {
         {
+            single_idx = i;
             [checked addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"item_id"] intValue]]];
             [checked addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"item_id"] intValue]]];
-            
+            [fashion_ids addObject:[NSNumber numberWithInt:[[item_json valueForKey:@"fashion_id"] intValue]]];
         }
         }
     }
     }
     // disable for debug
     // disable for debug
     if(checked.count==0)
     if(checked.count==0)
         return;
         return;
-    
+    if(checked.count==1)
+    {
+        //只选中一个和右滑一样处理。
+        {
+            
+            NSLog(@"edit click");
+            
+            
+            
+            UIViewController* parentvc=self;
+            
+            
+            
+            
+            PortfolioEditQTYViewController * vc =[ parentvc.storyboard instantiateViewControllerWithIdentifier:@"PortfolioEditQTYViewController"];
+            
+            
+            NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%d",single_idx]] mutableCopy];
+            
+            vc.arr_fashion_ids = fashion_ids;
+            
+            //        vc.fashionid =        [NSString stringWithFormat:@"%d",[[item_json valueForKey:@"fashion_id"] intValue]];
+            if([[item_json allKeys] containsObject:@"available_qty"])
+                vc.qty = [[item_json valueForKey:@"available_qty"] intValue];
+            else
+                vc.qty=-1;
+            if([[item_json allKeys] containsObject:@"available_percent"])
+                vc.qty_p = [[item_json valueForKey:@"available_percent"] intValue];
+            else
+                vc.qty_p=-1;
+            vc.linenotes=[item_json valueForKey:@"linenotes"] ;
+            vc.discount=[[item_json valueForKey:@"tear_sheet_discount"] floatValue];
+            vc.price = [[item_json valueForKey:@"tear_sheet_price"] floatValue];
+            vc.title=@"Edit Portfolio";
+            
+            //    vc.delegate = parentvc.self;
+            //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
+            vc.onSetValue = ^(int qty,double qty_p, double price, double discount , NSString* notes){
+                
+                
+                UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Updating Quantity"];
+                
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                    
+                    NSDictionary* cart_json = nil;
+                    
+                    cart_json= [iSalesNetwork portfolio_setPrice:[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]] price:price discount:discount QTY:qty  qty_p:qty_p notes:notes];
+                    
+                    dispatch_async(dispatch_get_main_queue(), ^{
+                        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+                        
+                        
+                        if([[cart_json valueForKey:@"result"] intValue]==2)
+                        {
+                            if(qty>=0)
+                                item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
+                            else
+                                [item_json removeObjectForKey:@"available_qty"];
+                            if(qty_p>=0)
+                                item_json[@"available_percent"]=[NSNumber numberWithInt:qty_p];
+                            else
+                                [item_json removeObjectForKey:@"available_percent"];
+                            item_json[@"linenotes"]=notes;
+                            item_json[@"tear_sheet_discount"]=[NSString stringWithFormat:@"%.2f",discount];
+                            item_json[@"tear_sheet_price"]=[NSString stringWithFormat:@"%.2f",price];
+                            self.content_data[[NSString stringWithFormat:@"item_%d",single_idx]]=item_json;
+                            // item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
+                            [self.itemListTable reloadData];
+                        }
+                        else
+                        {
+                            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Edit QTY" controller:self] ;
+                        }
+                        
+                        
+                        
+                        
+                    });
+                });
+                //
+                //
+                //
+                //  [self reload_data];//[main_vc checklogin:true];
+            };
+            
+            
+            UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:vc] ;
+            
+            
+            
+            
+            
+            //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
+            
+            navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
+            [parentvc presentViewController:navi animated:YES completion:^{
+                
+                //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
+                
+                NSLog(@"EditModelPriceViewController present.........");
+                
+                //   self.btop = false;
+                //  <#code#>
+            }];
+            
+           // [//tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
+            
+            
+            
+            
+        }
+        return;
+    }
     //    NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
     //    NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
     NSString * ids = [checked componentsJoinedByString:@","];
     NSString * ids = [checked componentsJoinedByString:@","];
     
     
@@ -588,7 +704,7 @@
         
         
 //        NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
 //        NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
         
         
-        vc.arr_fashion_ids = checked;
+        vc.arr_fashion_ids = nil;
         
         
         //        vc.fashionid =        [NSString stringWithFormat:@"%d",[[item_json valueForKey:@"fashion_id"] intValue]];
         //        vc.fashionid =        [NSString stringWithFormat:@"%d",[[item_json valueForKey:@"fashion_id"] intValue]];
 //        vc.qty = [[item_json valueForKey:@"available_qty"] intValue];
 //        vc.qty = [[item_json valueForKey:@"available_qty"] intValue];
@@ -599,7 +715,7 @@
         
         
         //    vc.delegate = parentvc.self;
         //    vc.delegate = parentvc.self;
         //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
         //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-        vc.onSetValue = ^(int qty,double price, double discount , NSString* notes){
+        vc.onSetValue = ^(int qty,double qty_p,double price, double discount , NSString* notes){
             
             
             
             
             UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Updating Quantity"];
             UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Updating Quantity"];
@@ -608,7 +724,7 @@
                 
                 
                 NSDictionary* cart_json = nil;
                 NSDictionary* cart_json = nil;
                 
                 
-                cart_json= [iSalesNetwork portfolio_setPrice:ids price:price discount:discount QTY:qty notes:notes];
+                cart_json= [iSalesNetwork portfolio_setPrice:ids price:-1 discount:discount QTY:qty qty_p:qty_p notes:notes];
                 
                 
                 dispatch_async(dispatch_get_main_queue(), ^{
                 dispatch_async(dispatch_get_main_queue(), ^{
                     [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
                     [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
@@ -616,11 +732,12 @@
                     
                     
                     if([[cart_json valueForKey:@"result"] intValue]==2)
                     if([[cart_json valueForKey:@"result"] intValue]==2)
                     {
                     {
+                        [RAUtils message_alert:[NSString stringWithFormat:@"%d items saved.",checked.count] title:@"Edit Portfolio" controller:self] ;
                         [self reload_data];
                         [self reload_data];
                     }
                     }
                     else
                     else
                     {
                     {
-                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Edit QTY" controller:self] ;
+                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Edit Portfolio" controller:self] ;
                     }
                     }
                     
                     
                     
                     
@@ -880,22 +997,51 @@
     //    cell.labelIdentifier.text = identifier;
     //    cell.labelIdentifier.text = identifier;
     
     
     
     
-    int qty= [[item_json valueForKey:@"available_qty"] intValue];
+    int qty;
+    if([[item_json allKeys] containsObject:@"available_qty"])
+     qty= [[item_json valueForKey:@"available_qty"] intValue];
+    else
+        qty=-1;
+    float qty_p;
+    
+    if([[item_json allKeys] containsObject:@"available_percent"])
+        qty_p= [[item_json valueForKey:@"available_percent"] floatValue];
+    else
+        qty_p=-1;
+    
     
     
+//    if(![[item_json allKeys] containsObject:@"available_qty"])
+//    {
+//        cell.available_qty_label.hidden=true;
+//        cell.available_qty_value_label.hidden=true;
+//    }
+//    else
+//    {
+//        cell.available_qty_label.hidden=false;
+//        cell.available_qty_value_label.hidden=false;
+//        cell.available_qty_value_label.text = [NSString stringWithFormat:@"%d",qty];
+//        
+//    }
     
     
     
     
-    if(![[item_json allKeys] containsObject:@"available_qty"])
+    if(qty>=0)
     {
     {
-        cell.available_qty_label.hidden=true;
-        cell.available_qty_value_label.hidden=true;
+        cell.available_qty_label.hidden=false;
+        cell.available_qty_value_label.hidden=false;
+        cell.available_qty_value_label.text = [NSString stringWithFormat:@"%d",qty];
+
     }
     }
-    else
+    else if(qty_p>=0)
     {
     {
         cell.available_qty_label.hidden=false;
         cell.available_qty_label.hidden=false;
         cell.available_qty_value_label.hidden=false;
         cell.available_qty_value_label.hidden=false;
-        cell.available_qty_value_label.text = [NSString stringWithFormat:@"%d",qty];
-        
+        cell.available_qty_value_label.text = [NSString stringWithFormat:@"%.2f %%",qty_p];
     }
     }
+    else
+            {
+                cell.available_qty_label.hidden=true;
+                cell.available_qty_value_label.hidden=true;
+            }
     NSString* str_price =[NSString stringWithFormat:@"%.2f",price * (1.0-discount/100)];
     NSString* str_price =[NSString stringWithFormat:@"%.2f",price * (1.0-discount/100)];
     if(price<0)
     if(price<0)
         str_price=@"No Price";
         str_price=@"No Price";
@@ -1036,95 +1182,7 @@
         
         
     }];
     }];
     deleteRowAction.backgroundColor = UIColorFromRGB(0x336699);
     deleteRowAction.backgroundColor = UIColorFromRGB(0x336699);
-    
-//    // 添加一个编辑按钮
-//    
-//    UITableViewRowAction *editRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"  Edit   "handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
-//        
-//        NSLog(@"edit click");
-//        
-//        
-//        
-//        UIViewController* parentvc=self;
-//        
-//        
-//        
-//        
-//        EditModelPriceViewController * vc =[ parentvc.storyboard instantiateViewControllerWithIdentifier:@"EditModelPriceViewController"];
-//        
-//        
-//        NSMutableDictionary * item_json = [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
-//        
-//        
-//        
-//        vc.set_watch_list=true;
-//        vc.discount=[[item_json valueForKey:@"tear_sheet_discount"] floatValue];
-//        vc.price = [[item_json valueForKey:@"tear_sheet_price"] floatValue];
-//        vc.cart_id = [NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]];
-//        //    vc.delegate = parentvc.self;
-//        //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-//        vc.onSetValue = ^(double price,double discount){
-//            
-//
-//            UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Update Price"];
-//            
-//            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//                
-//                NSDictionary* cart_json = nil;
-//                
-//                cart_json= [iSalesNetwork portfolio_setPrice:[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]] price:price discount:discount];
-//                
-//                dispatch_async(dispatch_get_main_queue(), ^{
-//                    [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-//                    
-//                    
-//                    if([[cart_json valueForKey:@"result"] intValue]==2)
-//                    {
-//                        [self reload_data];
-//                    }
-//                    else
-//                    {
-//                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Edit Price" controller:self] ;
-//                    }
-//                    
-//                    
-//                    
-//                    
-//                });
-//            });
-//            
-//            
-//            
-//           
-//        };
-//        
-//        
-//        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:vc] ;
-//        
-//        
-//        
-//        
-//        
-//        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-//        
-//        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
-//        [parentvc presentViewController:navi animated:YES completion:^{
-//            
-//            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-//            
-//            NSLog(@"EditModelPriceViewController present.........");
-//            
-//            //   self.btop = false;
-//            //  <#code#>
-//        }];
-//        
-//        [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
-//        
-//        
-//    }];
-//    editRowAction.backgroundColor = UIColorFromRGB(0xff9933);
-//
-    
+ 
     
     
     // edit qty
     // edit qty
     
     
@@ -1147,15 +1205,22 @@
         vc.arr_fashion_ids = [[NSArray arrayWithObject:[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"fashion_id"] intValue]]] mutableCopy];
         vc.arr_fashion_ids = [[NSArray arrayWithObject:[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"fashion_id"] intValue]]] mutableCopy];
 
 
 //        vc.fashionid =        [NSString stringWithFormat:@"%d",[[item_json valueForKey:@"fashion_id"] intValue]];
 //        vc.fashionid =        [NSString stringWithFormat:@"%d",[[item_json valueForKey:@"fashion_id"] intValue]];
-        vc.qty = [[item_json valueForKey:@"available_qty"] intValue];
+        if([[item_json allKeys] containsObject:@"available_qty"])
+            vc.qty = [[item_json valueForKey:@"available_qty"] intValue];
+        else
+            vc.qty=-1;
+        if([[item_json allKeys] containsObject:@"available_percent"])
+        vc.qty_p = [[item_json valueForKey:@"available_percent"] intValue];
+        else
+            vc.qty_p=-1;
         vc.linenotes=[item_json valueForKey:@"linenotes"] ;
         vc.linenotes=[item_json valueForKey:@"linenotes"] ;
         vc.discount=[[item_json valueForKey:@"tear_sheet_discount"] floatValue];
         vc.discount=[[item_json valueForKey:@"tear_sheet_discount"] floatValue];
         vc.price = [[item_json valueForKey:@"tear_sheet_price"] floatValue];
         vc.price = [[item_json valueForKey:@"tear_sheet_price"] floatValue];
-        
+        vc.title=@"Edit Portfolio";
         
         
         //    vc.delegate = parentvc.self;
         //    vc.delegate = parentvc.self;
         //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
         //    loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-        vc.onSetValue = ^(int qty,double price, double discount , NSString* notes){
+        vc.onSetValue = ^(int qty,double qty_p, double price, double discount , NSString* notes){
             
             
             
             
             UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Updating Quantity"];
             UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Updating Quantity"];
@@ -1164,7 +1229,7 @@
                 
                 
                 NSDictionary* cart_json = nil;
                 NSDictionary* cart_json = nil;
                 
                 
-                cart_json= [iSalesNetwork portfolio_setPrice:[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]] price:price discount:discount QTY:qty notes:notes];
+                cart_json= [iSalesNetwork portfolio_setPrice:[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"item_id"] intValue]] price:price discount:discount QTY:qty  qty_p:qty_p notes:notes];
                 
                 
                 dispatch_async(dispatch_get_main_queue(), ^{
                 dispatch_async(dispatch_get_main_queue(), ^{
                     [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
                     [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
@@ -1172,7 +1237,20 @@
                     
                     
                     if([[cart_json valueForKey:@"result"] intValue]==2)
                     if([[cart_json valueForKey:@"result"] intValue]==2)
                     {
                     {
-                        [self reload_data];
+                        if(qty>=0)
+                        item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
+                        else
+                            [item_json removeObjectForKey:@"available_qty"];
+                        if(qty_p>=0)
+                        item_json[@"available_percent"]=[NSNumber numberWithInt:qty_p];
+                        else
+                            [item_json removeObjectForKey:@"available_percent"];
+                        item_json[@"linenotes"]=notes;
+                        item_json[@"tear_sheet_discount"]=[NSString stringWithFormat:@"%.2f",discount];
+                        item_json[@"tear_sheet_price"]=[NSString stringWithFormat:@"%.2f",price];
+                        self.content_data[[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]]=item_json;
+                       // item_json[@"available_qty"]=[NSNumber numberWithInt:qty];
+                        [self.itemListTable reloadData];
                     }
                     }
                     else
                     else
                     {
                     {

+ 16 - 2
RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchFilterViewController.h

@@ -11,18 +11,32 @@
 #import "EnumSelectViewController.h"
 #import "EnumSelectViewController.h"
 //#import "AppDelegate.h"
 //#import "AppDelegate.h"
 
 
-@interface ItemSearchFilterViewController : UIViewController<RATreeViewDelegate, RATreeViewDataSource,EnumSelectViewControllerDelegate>
+@interface ItemSearchFilterViewController : UIViewController<RATreeViewDelegate, RATreeViewDataSource>//,EnumSelectViewControllerDelegate>
 @property (strong, nonatomic) IBOutlet UIView *treeContainer;
 @property (strong, nonatomic) IBOutlet UIView *treeContainer;
 @property (weak, nonatomic) RATreeView *treeView;
 @property (weak, nonatomic) RATreeView *treeView;
 //@property (strong, nonatomic) IBOutlet UIView *RadioContainer;
 //@property (strong, nonatomic) IBOutlet UIView *RadioContainer;
 @property (strong,nonatomic)NSDictionary* categoryMenu;
 @property (strong,nonatomic)NSDictionary* categoryMenu;
 @property (strong, nonatomic) IBOutlet UITextField *textModelName;
 @property (strong, nonatomic) IBOutlet UITextField *textModelName;
 @property (strong, nonatomic) IBOutlet UITextField *textModelDescription;
 @property (strong, nonatomic) IBOutlet UITextField *textModelDescription;
+
+
+@property (strong, nonatomic) IBOutlet UIButton *buttonQTY;
 @property (strong, nonatomic) IBOutlet UIButton *buttonAlert;
 @property (strong, nonatomic) IBOutlet UIButton *buttonAlert;
-@property (nonatomic , copy) void (^SearchClick)(NSString* ids,NSString* modelname,NSString* modeldescrip,NSString* alert);
+@property (strong, nonatomic) IBOutlet UIButton *buttonAvailability;
+@property (strong, nonatomic) IBOutlet UIButton *buttonPrice;
+@property (strong, nonatomic) IBOutlet UIButton *buttonBestSeller;
+@property (nonatomic , copy) void (^SearchClick)(NSString* ids,NSString* modelname,NSString* modeldescrip,NSString* alert,NSString* available,NSString* QTY,NSString* price , NSString* bestseller);
 @property (nonatomic , copy) void (^ResetClick)();
 @property (nonatomic , copy) void (^ResetClick)();
 
 
 @property (strong, nonatomic) NSDictionary* alert_cadedate;
 @property (strong, nonatomic) NSDictionary* alert_cadedate;
+@property (strong, nonatomic) NSDictionary* qty_cadedate;
+@property (strong, nonatomic) NSDictionary* availability_cadedate;
+@property (strong, nonatomic) NSDictionary* price_cadedate;
+@property (strong, nonatomic) NSDictionary* bestseller_cadedate;
+
+@property (strong, nonatomic) IBOutlet UILabel *labelPrice;
+
+
 @property (strong, nonatomic) NSString* modelname;
 @property (strong, nonatomic) NSString* modelname;
 @property (strong, nonatomic) NSString* modeldescrip;
 @property (strong, nonatomic) NSString* modeldescrip;
 @end
 @end

+ 366 - 48
RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchFilterViewController.m

@@ -10,6 +10,8 @@
 #import "RATreeView.h"
 #import "RATreeView.h"
 #import "const.h"
 #import "const.h"
 #import "EnumSelectViewController.h"
 #import "EnumSelectViewController.h"
+#import "DefaultAppearance.h"
+#import "AppDelegate.h"
 @interface ItemSearchFilterViewController ()
 @interface ItemSearchFilterViewController ()
 
 
 @end
 @end
@@ -71,8 +73,27 @@
         alert = nil;
         alert = nil;
    // NSLog(ids);
    // NSLog(ids);
     
     
+    
+    NSString* qty = [self.buttonQTY titleForState:UIControlStateNormal];
+    if(qty.length==0 || [qty isEqualToString:@"Click to select"])
+        qty = nil;
+    
+    NSString* price = [self.buttonPrice titleForState:UIControlStateNormal];
+    if(price.length==0 || [price isEqualToString:@"Click to select"])
+        price = nil;
+    
+    NSString* available = [self.buttonAvailability titleForState:UIControlStateNormal];
+    if(available.length==0 || [available isEqualToString:@"Click to select"])
+        available = nil;
+    
+      
+    NSString* bestseller = [self.buttonBestSeller titleForState:UIControlStateNormal];
+    if(bestseller.length==0 || [bestseller isEqualToString:@"Click to select"])
+        alert = nil;
+
+    
     if(self.SearchClick)
     if(self.SearchClick)
-        self.SearchClick(ids, modelname, modeldescrip, alert);
+        self.SearchClick(ids, modelname, modeldescrip, alert,available, qty, price,bestseller);
     [self dismissViewControllerAnimated:true completion:nil];
     [self dismissViewControllerAnimated:true completion:nil];
 }
 }
 -(int) is_check:(NSString*) cid source:(NSDictionary*) json
 -(int) is_check:(NSString*) cid source:(NSDictionary*) json
@@ -140,6 +161,24 @@
     
     
     
     
     
     
+    UIApplication * app = [UIApplication sharedApplication];
+    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+    if(appDelegate.bLogin)
+    {
+        self.labelPrice.hidden=false;
+        self.buttonPrice.hidden=false;
+        
+    }
+    else
+    {
+        self.labelPrice.hidden=true;
+        self.buttonPrice.hidden=true;
+    }
+    
+
+    
+    
+    
     UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
     UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
                                                                     style:UIBarButtonItemStylePlain
                                                                     style:UIBarButtonItemStylePlain
                                                                    target:self
                                                                    target:self
@@ -173,8 +212,15 @@
             self.treeView.treeHeaderView = line;
             self.treeView.treeHeaderView = line;
     */
     */
     
     
+    
+    NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultColor" valuename:@"frontcolor"];
+    
+    if(value==nil)
+        value=@"";
+    unsigned long frontcolor = strtoul([value UTF8String],0,16);
+    
     UILabel *CategoryLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 5.5, self.view.frame.size.width, 33)];
     UILabel *CategoryLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 5.5, self.view.frame.size.width, 33)];
-   CategoryLabel.textColor=UIColorFromRGB(0x996633);
+   CategoryLabel.textColor=UIColorFromRGB(frontcolor);
 //    CategoryLabel.backgroundColor = [UIColor redColor];
 //    CategoryLabel.backgroundColor = [UIColor redColor];
     CategoryLabel.text=NSLocalizedString(@" Category", nil);
     CategoryLabel.text=NSLocalizedString(@" Category", nil);
 //    [CategoryLabel sizeToFit];
 //    [CategoryLabel sizeToFit];
@@ -187,39 +233,290 @@
     
     
     self.textModelDescription.text = self.modeldescrip;
     self.textModelDescription.text = self.modeldescrip;
     
     
-    NSString* alert =@"";
-    int count = [[self.alert_cadedate valueForKey:@"count"] intValue];
-    for(int i=0;i<count;i++)
+//    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];
+
+    [treeView setBackgroundColor: [UIColor whiteColor]];
+    
+    
+    
     {
     {
-        NSDictionary* val_json =[self.alert_cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
-        int check = [[val_json valueForKey:@"check"] intValue];
-        if(check==1)
+        
+        NSString* qty =@"";
+        int count = [[self.qty_cadedate valueForKey:@"count"] intValue];
+        for(int i=0;i<count;i++)
         {
         {
-            alert = [alert stringByAppendingString:[val_json valueForKey:@"value"]];
-            break;
+            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];
+        
     }
     }
     
     
-    if(alert.length>0)
-    [self.buttonAlert setTitle:alert forState:UIControlStateNormal];
-
-    [treeView setBackgroundColor: [UIColor whiteColor]];
-
     
     
-    self.treeView.layer.shadowPath =[UIBezierPath bezierPathWithRect:self.treeView.bounds].CGPath;
-    self.treeView.layer.masksToBounds = false;
-    //添加四个边阴影
+    {
+        
+        NSString* price =@"";
+        int count = [[self.price_cadedate valueForKey:@"count"] intValue];
+        for(int i=0;i<count;i++)
+        {
+            NSDictionary* val_json =[self.price_cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
+            int check = [[val_json valueForKey:@"check"] intValue];
+            if(check==1)
+            {
+                price = [price stringByAppendingString:[val_json valueForKey:@"value"]];
+                break;
+            }
+        }
+        if(price.length>0)
+            [self.buttonPrice setTitle:price 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];
+    }
+    
     
     
-    self.treeView.layer.shadowColor = [UIColor blackColor].CGColor;
-    self.treeView.layer.shadowOffset = CGSizeMake(0, 0);
-    self.treeView.layer.shadowOpacity = 0.5;
-    self.treeView.layer.shadowRadius = 2.0;
+    {
+        NSString* bestseller =@"";
+        int count = [[self.bestseller_cadedate valueForKey:@"count"] intValue];
+        for(int i=0;i<count;i++)
+        {
+            NSDictionary* val_json =[self.bestseller_cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
+            int check = [[val_json valueForKey:@"check"] intValue];
+            if(check==1)
+            {
+                bestseller = [bestseller stringByAppendingString:[val_json valueForKey:@"value"]];
+                break;
+            }
+        }
+        if(bestseller.length>0)
+            [self.buttonBestSeller setTitle:bestseller forState:UIControlStateNormal];
+    }
+
+    self.treeView.layer.borderColor=[UIColor lightGrayColor].CGColor;
+    self.treeView.layer.borderWidth = 0.5;
+    
+//    self.treeView.layer.shadowPath =[UIBezierPath bezierPathWithRect:self.treeView.bounds].CGPath;
+//    self.treeView.layer.masksToBounds = false;
+//    //添加四个边阴影
+//    
+//    self.treeView.layer.shadowColor = [UIColor blackColor].CGColor;
+//    self.treeView.layer.shadowOffset = CGSizeMake(0, 0);
+//    self.treeView.layer.shadowOpacity = 0.5;
+//    self.treeView.layer.shadowRadius = 2.0;
 
 
     // Do any additional setup after loading the view.
     // Do any additional setup after loading the view.
 }
 }
 - (IBAction)onCloseClick:(id)sender {
 - (IBAction)onCloseClick:(id)sender {
     [self dismissViewControllerAnimated:true completion:nil];
     [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 = @"";
+    //       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)onBestSellerClick:(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.bestseller_cadedate mutableCopy];
+    enumvc.title = @"";
+    //       enumvc.value = [value_json mutableCopy];
+    enumvc.single_select =true;
+    
+    
+    enumvc.returnValue = ^(NSMutableDictionary* value){
+        self.bestseller_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.buttonBestSeller setTitle:qty 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 = @"";
+    //       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)onPriceClick:(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.price_cadedate mutableCopy];
+    enumvc.title = @"";
+    //       enumvc.value = [value_json mutableCopy];
+    enumvc.single_select =true;
+    
+    
+    enumvc.returnValue = ^(NSMutableDictionary* value){
+        self.price_cadedate = value;
+        
+        
+        NSString* price =@"";
+        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)
+            {
+                price = [price stringByAppendingString:[val_json valueForKey:@"value"]];
+                break;
+            }
+        }
+        
+        [self.buttonPrice setTitle:price forState:UIControlStateNormal];
+    };
+    
+    [self.navigationController pushViewController:enumvc animated:true];
+}
+
+
+
 - (IBAction)onAlertClick:(id)sender {
 - (IBAction)onAlertClick:(id)sender {
     
     
  
  
@@ -240,7 +537,26 @@
     enumvc.title = @"Alert";
     enumvc.title = @"Alert";
     //       enumvc.value = [value_json mutableCopy];
     //       enumvc.value = [value_json mutableCopy];
     enumvc.single_select =true;
     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];
     [self.navigationController pushViewController:enumvc animated:true];
     
     
 }
 }
@@ -281,6 +597,8 @@
 
 
 - (BOOL)treeView:(RATreeView *)treeView shouldItemBeExpandedAfterDataReload:(id)item treeDepthLevel:(NSInteger)treeDepthLevel
 - (BOOL)treeView:(RATreeView *)treeView shouldItemBeExpandedAfterDataReload:(id)item treeDepthLevel:(NSInteger)treeDepthLevel
 {
 {
+    if([item[@"check"] intValue]==1)
+        return YES;
 //    if ([item isEqual:self.expanded]) {
 //    if ([item isEqual:self.expanded]) {
 //        return YES;
 //        return YES;
 //    }
 //    }
@@ -415,29 +733,29 @@
      */
      */
 }
 }
 
 
-#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];
-    
-    
-}
+//#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];
+//    
+//    
+//}
 @end
 @end

+ 7 - 2
RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchViewController.h

@@ -15,6 +15,7 @@
 @property (strong, nonatomic) IBOutlet UISearchBar *searchBar;
 @property (strong, nonatomic) IBOutlet UISearchBar *searchBar;
 @property long offset;
 @property long offset;
 @property bool loadall;
 @property bool loadall;
+@property bool showalert;
 @property int categoryViewType;
 @property int categoryViewType;
 
 
 @property (strong, nonatomic) IBOutlet UIView *headerView;
 @property (strong, nonatomic) IBOutlet UIView *headerView;
@@ -23,7 +24,7 @@
 @property (strong, nonatomic) NSMutableDictionary* display_type;
 @property (strong, nonatomic) NSMutableDictionary* display_type;
 @property (strong, nonatomic) NSMutableDictionary* category_data;
 @property (strong, nonatomic) NSMutableDictionary* category_data;
 
 
-
+@property (strong, nonatomic) NSMutableDictionary* default_filter;
 //@property (strong, nonatomic) NSMutableArray* selected;
 //@property (strong, nonatomic) NSMutableArray* selected;
 
 
 //@property (strong, nonatomic) IBOutlet UIView *detailView;
 //@property (strong, nonatomic) IBOutlet UIView *detailView;
@@ -40,9 +41,13 @@
 @property (strong,nonatomic) NSString* modelname;
 @property (strong,nonatomic) NSString* modelname;
 @property (strong,nonatomic) NSString* modeldescrip;
 @property (strong,nonatomic) NSString* modeldescrip;
 @property (strong,nonatomic) NSString* alert;
 @property (strong,nonatomic) NSString* alert;
-@property (strong,nonatomic) NSString* available;
+//@property (strong,nonatomic) NSString* available;
 
 
 
 
+@property (strong,nonatomic) NSString* p_available;
+@property (strong,nonatomic) NSString* p_QTY;
+@property (strong,nonatomic) NSString* p_price;
+@property (strong,nonatomic) NSString* p_bestseller;
 
 
 
 
 @property bool isSelectionMode;
 @property bool isSelectionMode;

+ 58 - 9
RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchViewController.m

@@ -279,21 +279,56 @@
     //    DebugLog(@"refresh!!!!!!!!");
     //    DebugLog(@"refresh!!!!!!!!");
     
     
 }
 }
+-(NSMutableDictionary*) resetFilter:(NSMutableDictionary*)filter
+{
+    NSString* str= [RAUtils dict2string:filter];
+    str=[str stringByReplacingOccurrencesOfString:@"\"check\":1" withString:@"\"check\":0"];
+    str=[str stringByReplacingOccurrencesOfString:@"\"check\":\"1\"" withString:@"\"check\":\"0\""];
+    filter=[[RAUtils string2dict:str]mutableCopy];
+    filter[@"model_name"]=@"";
+    filter[@"model_description"]=@"";
+    filter[@"price"][@"val_0"][@"check"]=@"1";
+    filter[@"alert"][@"val_0"][@"check"]=@"1";
+    filter[@"qty"][@"val_0"][@"check"]=@"1";
+    filter[@"availability"][@"val_0"][@"check"]=@"1";
+    filter[@"best_seller"][@"val_1"][@"check"]=@"1";
+    return filter;
+}
 - (IBAction)onFilterClicked:(id)sender {
 - (IBAction)onFilterClicked:(id)sender {
     
     
     ItemSearchFilterViewController * filterVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"ItemSearchFilterViewController"];
     ItemSearchFilterViewController * filterVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"ItemSearchFilterViewController"];
     
     
-    filterVC.categoryMenu = [[self.category_data objectForKey:@"filter"] objectForKey:@"category"];
-    filterVC.alert_cadedate =[[self.category_data objectForKey:@"filter"] objectForKey:@"alert"];
-    filterVC.modelname=[[self.category_data objectForKey:@"filter"] valueForKey:@"model_name"];
-    filterVC.modeldescrip=[[self.category_data objectForKey:@"filter"] valueForKey:@"model_description"];
-    filterVC.SearchClick =^(NSString* ids,NSString* modelname,NSString* modeldescrip,NSString* alert)
+    if(self.default_filter==nil)
+        self.default_filter = [self.category_data objectForKey:@"filter"];
+    
+    filterVC.categoryMenu = [self.default_filter objectForKey:@"category"];
+    filterVC.alert_cadedate =[self.default_filter objectForKey:@"alert"];
+    filterVC.modelname=[self.default_filter valueForKey:@"model_name"];
+    filterVC.modeldescrip=[self.default_filter valueForKey:@"model_description"];
+    
+    
+    filterVC.qty_cadedate=[self.default_filter objectForKey:@"qty"];
+    filterVC.availability_cadedate=[self.default_filter objectForKey:@"availability"];
+    filterVC.price_cadedate=[self.default_filter objectForKey:@"price"];
+    filterVC.bestseller_cadedate=[self.default_filter objectForKey:@"best_seller"];
+    
+    
+    filterVC.SearchClick =^(NSString* ids,NSString* modelname,NSString* modeldescrip,NSString* alert,NSString* available,NSString* QTY,NSString* price,NSString* bestseller)
     {
     {
+        
+        self.default_filter= [self resetFilter:self.default_filter];
         self.ctgid = ids;
         self.ctgid = ids;
         self.modelname = modelname;
         self.modelname = modelname;
         self.modeldescrip = modeldescrip;
         self.modeldescrip = modeldescrip;
         self.alert = alert;
         self.alert = alert;
         self.covertype = nil;
         self.covertype = nil;
+        
+        
+        self.p_QTY=QTY;
+        self.p_available=available;
+        self.p_price=price;
+        self.p_bestseller=bestseller;
+        self.offset = 0;
             self.offset = 0;
             self.offset = 0;
             //  [self.content_data removeAllObjects];
             //  [self.content_data removeAllObjects];
             [self reload];
             [self reload];
@@ -304,6 +339,13 @@
     
     
     filterVC.ResetClick =^()
     filterVC.ResetClick =^()
     {
     {
+        
+        
+        self.p_QTY=nil;
+        self.p_available=nil;
+        self.p_price=nil;
+        self.p_bestseller=nil;
+        
         self.ctgid = nil;
         self.ctgid = nil;
         self.modelname = nil;
         self.modelname = nil;
         self.modeldescrip = nil;
         self.modeldescrip = nil;
@@ -381,9 +423,14 @@
 -(void) loadMore
 -(void) loadMore
 {
 {
     dispatch_async(dispatch_get_main_queue(), ^{
     dispatch_async(dispatch_get_main_queue(), ^{
-        if(self.loadall)
+        if(self.loadall )
         {
         {
-            [RAUtils message_alert:@"All loaded" title:@"Loading Category" controller:self] ;
+            
+            if(self.showalert)
+            {
+                self.showalert=false;
+            [RAUtils message_alert:@"All loaded" title:@"Loading items" controller:self] ;
+            }
             return;
             return;
             
             
         }
         }
@@ -396,7 +443,7 @@
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
         
     
     
-        NSDictionary* category_more=[iSalesNetwork ItemSearch:self.offset limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert available:self.available
+        NSDictionary* category_more=[iSalesNetwork ItemSearch:self.offset limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller
                                      ];
                                      ];
         dispatch_async(dispatch_get_main_queue(), ^{
         dispatch_async(dispatch_get_main_queue(), ^{
             [self.mum stopAnimating];
             [self.mum stopAnimating];
@@ -493,8 +540,10 @@
      dispatch_async(dispatch_get_main_queue(), ^{
      dispatch_async(dispatch_get_main_queue(), ^{
          
          
          
          
+         
          if(self.isrefreshing)
          if(self.isrefreshing)
              return;
              return;
+         self.showalert=true;
          self.isrefreshing=true;
          self.isrefreshing=true;
          self.loadall = false;
          self.loadall = false;
     UIRefreshControl *reF = (UIRefreshControl *)[self.collectionview viewWithTag:200];
     UIRefreshControl *reF = (UIRefreshControl *)[self.collectionview viewWithTag:200];
@@ -511,7 +560,7 @@
          [self.mum startAnimating];
          [self.mum startAnimating];
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
         
-        NSDictionary* category_data=[iSalesNetwork ItemSearch:0 limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert available:self.available
+        NSDictionary* category_data=[iSalesNetwork ItemSearch:0 limit:20 covertype:self.covertype ctgid:self.ctgid modelname:self.modelname modeldescrip:self.modeldescrip alert:self.alert qty:self.p_QTY available:self.p_available price:self.p_price bestseller:self.p_bestseller
                                                              ];
                                                              ];
         
         
         dispatch_async(dispatch_get_main_queue(), ^{
         dispatch_async(dispatch_get_main_queue(), ^{

+ 1 - 0
RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.h

@@ -14,6 +14,7 @@
 @property (strong, nonatomic) IBOutlet UISearchBar *searchBar;
 @property (strong, nonatomic) IBOutlet UISearchBar *searchBar;
 @property long offset;
 @property long offset;
 @property bool loadall;
 @property bool loadall;
+@property bool showalert;
 @property int categoryViewType;
 @property int categoryViewType;
 
 
 @property (strong, nonatomic) IBOutlet UIView *headerView;
 @property (strong, nonatomic) IBOutlet UIView *headerView;

+ 6 - 2
RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m

@@ -1043,9 +1043,12 @@
         
         
         if(self.loadall)
         if(self.loadall)
         {
         {
-            [RAUtils message_alert:@"All loaded" title:@"Loading Category" controller:self] ;
+            if(self.showalert)
+            {
+                self.showalert=false;
+                [RAUtils message_alert:@"All loaded" title:@"Loading items" controller:self] ;
+            }
             return;
             return;
-            
         }
         }
         
         
         self.mum.hidden = false;
         self.mum.hidden = false;
@@ -1151,6 +1154,7 @@
     dispatch_async(dispatch_get_main_queue(), ^{
     dispatch_async(dispatch_get_main_queue(), ^{
         if(self.isrefreshing)
         if(self.isrefreshing)
             return;
             return;
+        self.showalert=true;
         self.isrefreshing=true;
         self.isrefreshing=true;
         self.loadall = false;
         self.loadall = false;
     UIRefreshControl *reF = (UIRefreshControl *)[self.collectionview viewWithTag:200];
     UIRefreshControl *reF = (UIRefreshControl *)[self.collectionview viewWithTag:200];