Ray Zhang 10 жил өмнө
parent
commit
08f3dd1110

+ 98 - 20
RedAnt ERP Mobile/common/Functions/cart/ModelItemCell.m

@@ -308,32 +308,110 @@
     
     if(qty==0)
         qty=self.stepper.minimumValue;
-    [self set_Count:qty];
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+    
+    
+    
         
-        NSDictionary* cart_json = [iSalesNetwork cart_setQTY:self.cart_id value:qty];
+        int c=qty;
         
-        dispatch_async(dispatch_get_main_queue(), ^{
+        int m=c%(int)(self.stepper.stepValue);
+        if(m!=0)
+        {
+            
+            
+            
+            UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Sold in quantities of %d, Are you sure?",(int)(self.stepper.stepValue)] message:nil preferredStyle:UIAlertControllerStyleAlert];
+            //block代码块取代了delegate
+            
             
-            if([[cart_json valueForKey:@"result"] intValue]==2)
-            {
-//                if (self.delegate && [self.delegate respondsToSelector:@selector(returnQTY:)]) {
-//                    [self.delegate returnQTY:qty];
-//                }
-                
-                if(self.onReturnQTY)
-                    self.onReturnQTY(qty);
-            }
-            else
-            {
-                UIViewController* vc=[RAUtils getViewController :self];
-                [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Change Model Count" controller:vc] ;
-            }
             
+            UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
+                [self set_Count:qty];
+                
+                
+                
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                    
+                    NSDictionary* cart_json = [iSalesNetwork cart_setQTY:self.cart_id value:qty];
+                    
+                    dispatch_async(dispatch_get_main_queue(), ^{
+                        
+                        if([[cart_json valueForKey:@"result"] intValue]==2)
+                        {
+                            //                if (self.delegate && [self.delegate respondsToSelector:@selector(returnQTY:)]) {
+                            //                    [self.delegate returnQTY:qty];
+                            //                }
+                            
+                            if(self.onReturnQTY)
+                                self.onReturnQTY(qty);
+                        }
+                        else
+                        {
+                            UIViewController* vc=[RAUtils getViewController :self];
+                            [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Change Model Count" controller:vc] ;
+                        }
+                        
+                        
+                        
+                    });
+                });
 
+            }];
             
-        });
-    });
+            UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+                NSLog(@"No");
+            }];
+            [alertControl addAction:actionOne];
+            
+            [alertControl addAction:alertthree];
+            
+            //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
+            
+            UIViewController *vc= [RAUtils getViewController:self];
+            [vc presentViewController:alertControl animated:YES completion:nil];
+            
+            
+            
+        }
+        else
+        {
+            [self set_Count:qty];
+            
+            
+            
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                
+                NSDictionary* cart_json = [iSalesNetwork cart_setQTY:self.cart_id value:qty];
+                
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    
+                    if([[cart_json valueForKey:@"result"] intValue]==2)
+                    {
+                        //                if (self.delegate && [self.delegate respondsToSelector:@selector(returnQTY:)]) {
+                        //                    [self.delegate returnQTY:qty];
+                        //                }
+                        
+                        if(self.onReturnQTY)
+                            self.onReturnQTY(qty);
+                    }
+                    else
+                    {
+                        UIViewController* vc=[RAUtils getViewController :self];
+                        [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Change Model Count" controller:vc] ;
+                    }
+                    
+                    
+                    
+                });
+            });
+
+        }
+        
+    
+        
+    
+    
+    
     
 
 }

+ 4 - 2
RedAnt ERP Mobile/common/Functions/category/CategorySearchFilterViewController.h

@@ -12,12 +12,14 @@
 @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) IBOutlet UIButton *buttonQTY;
 @property (strong, nonatomic) IBOutlet UIButton *buttonAlert;
 @property (strong, nonatomic) IBOutlet UIButton *buttonAvailability;
+@property (strong, nonatomic) IBOutlet UIButton *buttonPrice;
 
-@property (nonatomic , copy) void (^OkClick)(NSString* available,NSString* QTY,NSString* alert);
+@property (strong, nonatomic) IBOutlet UILabel *labelPrice;
+@property (nonatomic , copy) void (^OkClick)(NSString* available,NSString* QTY,NSString* alert,NSString* price);
 @property (nonatomic , copy) void (^ResetClick)(void);
 @end

+ 80 - 2
RedAnt ERP Mobile/common/Functions/category/CategorySearchFilterViewController.m

@@ -7,6 +7,7 @@
 //
 
 #import "CategorySearchFilterViewController.h"
+#import "AppDelegate.h"
 
 @interface CategorySearchFilterViewController ()
 
@@ -17,6 +18,22 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
     
+    
+    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:UIImageRenderingModeAlwaysOriginal]
                                                                     style:UIBarButtonItemStylePlain
                                                                    target:self
@@ -32,7 +49,7 @@
     {
         
         NSString* qty =@"";
-        int count = [[self.alert_cadedate valueForKey:@"count"] intValue];
+        int count = [[self.qty_cadedate valueForKey:@"count"] intValue];
         for(int i=0;i<count;i++)
         {
             NSDictionary* val_json =[self.qty_cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
@@ -48,6 +65,26 @@
         
     }
     
+    
+    {
+        
+        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 =@"";
@@ -183,6 +220,43 @@
     
     [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 = @"Select";
+    //       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 {
     
     
@@ -234,6 +308,10 @@
     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;
@@ -244,7 +322,7 @@
     
     
     if(self.OkClick)
-        self.OkClick( available, qty, alert);
+        self.OkClick( available, qty, alert,price);
     [self dismissViewControllerAnimated:true completion:nil];
 }
 

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

@@ -54,7 +54,7 @@
 @property (strong,nonatomic) NSString* p_alert;
 @property (strong,nonatomic) NSString* p_available;
 @property (strong,nonatomic) NSString* p_QTY;
-
+@property (strong,nonatomic) NSString* p_price;
 
 
 //@property bool disable_refresh;

+ 17 - 14
RedAnt ERP Mobile/common/Functions/category/CategoryViewController.m

@@ -141,22 +141,23 @@
     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"];
+//    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)
+    filterVC.price_cadedate=[[self.category_data objectForKey:@"filter"] objectForKey:@"price"];
+    filterVC.OkClick =^(NSString* available,NSString* QTY,NSString* alert,NSString* price)
     {
-        self.p_alert=available;
+        self.p_alert=alert;
         self.p_QTY=QTY;
-        self.p_available=alert;
-        
+        self.p_available=available;
+        self.p_price=price;
         
         self.offset = 0;
         [self reload];
@@ -169,7 +170,7 @@
         self.p_alert=nil;
         self.p_QTY=nil;
         self.p_available=nil;
-        
+        self.p_price=nil;
         
         self.offset = 0;
         [self reload];
@@ -929,7 +930,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 alert:self.p_alert qty:self.p_QTY available:self.p_available] ;
+        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 price:self.p_price] ;
         
         dispatch_async(dispatch_get_main_queue(), ^{
             
@@ -1007,7 +1008,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 alert:self.p_alert qty:self.p_QTY available:self.p_available];
+            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 price:self.p_price];
             
             dispatch_async(dispatch_get_main_queue(), ^{
                 
@@ -1940,6 +1941,8 @@
     
     CGRect frame =self.collectionview.frame;
     
+    CGSize size123 =self.collectionview.contentSize;
+    
     UICollectionViewFlowLayout *flowLayout =(UICollectionViewFlowLayout*)[self.collectionview collectionViewLayout];
     if(flowLayout.scrollDirection== UICollectionViewScrollDirectionVertical)
     {
@@ -1949,7 +1952,7 @@
         //        NSLog(@"frame.size.height %f",frame.size.height);
         //        NSLog(@"self.collectionview.contentSize.height %f",self.collectionview.contentSize.height);
         
-        if (contentOffsetPoint.y == (self.collectionview.contentSize.height - frame.size.height) || self.collectionview.contentSize.height < frame.size.height)
+        if (contentOffsetPoint.y == (self.collectionview.contentSize.height - frame.size.height) /*|| self.collectionview.contentSize.height < frame.size.height*/)
             
         {
             
@@ -1971,7 +1974,7 @@
         //        NSLog(@"frame.size.height %f",frame.size.height);
         //        NSLog(@"self.collectionview.contentSize.height %f",self.collectionview.contentSize.height);
         
-        if (contentOffsetPoint.x == (self.collectionview.contentSize.width - frame.size.width) || self.collectionview.contentSize.width < frame.size.width)
+        if (contentOffsetPoint.x == (self.collectionview.contentSize.width - frame.size.width) /*|| self.collectionview.contentSize.width < frame.size.width*/)
             
         {
             if(self.isrefreshing)

+ 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 alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available;
++(NSDictionary*)Category: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price;
 
 +(bool) IsNetworkAvailable;
 +(int)parse_authinfo : (NSData *) json user:(NSString*) user password:(NSString*) password;

+ 3 - 2
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m

@@ -1919,7 +1919,7 @@ 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 alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available
++(NSDictionary*)Category: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword  offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price
 {
     
 
@@ -1942,6 +1942,7 @@ repeat:{
     [params setValue:alert forKey:@"alert"];
     [params setValue:qty forKey:@"sold_by_qty"];
     [params setValue:available forKey:@"available"];
+    [params setValue:price forKey:@"price"];
     
     [params setValue:[NSString stringWithFormat:@"%d",price_template]  forKey:@"price_template"];
     [params setValue:[NSString stringWithFormat:@"%d",customid]  forKey:@"custom_id"];
@@ -2274,7 +2275,7 @@ repeat:{
         [params setValue:appDelegate.password forKey:@"password"];
     [params setValue:contactid forKey:@"contactId"];
     [params setValue:url forKey:@"business_card"];
-    [params setValue:[NSNumber numberWithInt:index ] forKey:@"index"];
+ //   [params setValue:[NSNumber numberWithInt:index ] forKey:@"index"];
     NSData* json=[self get_json:URL_UPDATE_CUSTOMER_BCARD parameters:params];
     if(json==nil)
         return nil;

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

@@ -287,6 +287,6 @@
 //#define  URL_CART_GENERAL_NOTES  @"https://www.newpacificdirect.com/isales/updateGeneralNote.htm"
 //#define  URL_CART_ITEM_NOTES  @"https://www.newpacificdirect.com/isales/setItemNotes.htm"
 //#define  URL_EDIT_CUSTOMER  @"https://www.newpacificdirect.com/isales/getUpdateCustomerInfoByContact.htm"
-
+//
 
 #endif