Kaynağa Gözat

Category、Item Search以及Search传给Model Detail的Product ID统一转为String类型。
Model Detail请求数据成功后才处理成员变量。
修改Place Order缺货提示。
修改Cart,缺货Model左滑增加Notify Me按钮。

Pen Li 9 yıl önce
ebeveyn
işleme
6ff719c547

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


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

@@ -233,7 +233,7 @@
         if ([self.class_name isEqualToString:@"CreateOrderViewController"]) {
             
             NSString *err_msg = msg;
-            UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:err_msg preferredStyle:UIAlertControllerStyleAlert];
+            UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Attention!!" message:err_msg preferredStyle:UIAlertControllerStyleAlert];
             __weak typeof(self) weakself = self;
             UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                 

+ 145 - 2
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -1891,6 +1891,14 @@
     self.indexPath=indexPath;
     
     
+    NSMutableDictionary * item_json = [self.content_arr[indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
+    
+    NSString* productID = [item_json valueForKey:@"product_id"];
+    BOOL outOfStock = [[item_json valueForKey:@"is_out_of_stock"] boolValue];
+    
+    __weak typeof(self) weakself = self;
+    
+    
     UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@" Delete " handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
         
         DebugLog(@"delete click");
@@ -1911,6 +1919,60 @@
     
     deleteRowAction.backgroundColor = UIColorFromRGB(0x336699);
     
+    UITableViewRowAction *notifyMeAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Notify Me" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
+        
+        {
+            
+            UIAlertView *waitting_alert = [RAUtils waiting_alert:@"Sending Email" title:@"Waiting"];
+            dispatch_async(dispatch_get_global_queue(0,0), ^{
+                
+                NSDictionary *dic = [iSalesNetwork notifyModel:productID emailAddr:nil];
+                
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    
+                    [waitting_alert dismissWithClickedButtonIndex:0 animated:NO];
+                    
+                    NSInteger result = [[dic valueForKey:@"result"] integerValue];
+                    
+                    if (result != RESULT_TRUE && result != RESULT_NO_EMAIL_ADDRESS) {
+                        
+                        NSString *msg = [NSString stringWithFormat:@"The email send failed"];
+                        
+                        if ([dic valueForKey:@"err_msg"]) {
+                            msg = [dic valueForKey:@"err_msg"];
+                        }
+                        
+                        
+                        UIAlertController *errorAlertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                        UIAlertAction *action = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                            
+                        }];
+                        
+                        [errorAlertVC addAction:action];
+                        [weakself presentViewController:errorAlertVC animated:YES completion:nil];
+                        
+                    } else if (result == RESULT_TRUE){
+                        
+                        [RAUtils message_alert:@"Notification is sent to default email address." title:@"Message" controller:weakself];
+                        
+                    } else if (result == RESULT_NO_EMAIL_ADDRESS) {
+                        
+                        [weakself showAddressBoxToEmailProduct:productID];
+                        
+                    }
+                });
+                
+                
+            });
+            
+            
+        };
+        
+        
+    }];
+    
+    notifyMeAction.backgroundColor = UIColorFromRGB(0x9BBF5A);
+    
     
     UITableViewRowAction *addWatchAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Move To Wish List" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
         
@@ -1977,7 +2039,6 @@
     
     
     // 添加一个编辑按钮
-    __weak typeof(self) weakself = self;
     UITableViewRowAction *editRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Edit Price"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
         
         DebugLog(@"edit click");
@@ -2273,6 +2334,11 @@
         int is_rate = [item_json[@"is_rate"] intValue];
 
         NSMutableArray* arr=[@[] mutableCopy];
+#ifdef BUILD_NPD
+        if (!appDelegate.offline_mode && outOfStock) {
+            [arr addObject:notifyMeAction];
+        }
+#endif
         
         if(product_id.length>0)
             [arr addObject:noteRowAction];
@@ -2293,7 +2359,7 @@
         return arr;
         //    return @[deleteRowAction,addWatchAction, editRowAction,freeRowAction];
     } else if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
-        return @[deleteRowAction,addWatchAction,editRowAction];
+        return @[notifyMeAction,deleteRowAction,addWatchAction,editRowAction];
     }
     else
         return @[deleteRowAction,addWatchAction];
@@ -2864,5 +2930,82 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
     
 }
 
+- (void)showAddressBoxToEmailProduct:(NSString *)productID {
+    //    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+    
+    JKMessageBoxController *emailAddrVC = [JKMessageBoxController messageBoxControllerWithTip:@"E-mail not setup, please enter your default e-mail address" ContentSize:CGSizeMake(400, 150)];
+    emailAddrVC.textFiled.secureTextEntry = NO;
+    emailAddrVC.yesButtonTitle = @"send";
+    
+    __weak typeof(emailAddrVC) weakVC = emailAddrVC;
+    __weak typeof(self) weakself = self;
+    
+    emailAddrVC.textHandler = ^(NSString *text){
+        
+        // 验证邮箱格式是否正确
+        NSString *match = EMAIL_MATCHES;
+        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",match];
+        BOOL isEmailAddr = [predicate evaluateWithObject:text];
+        if (isEmailAddr) {
+            
+            // 验证是邮件地址,发送邮件
+            [weakVC dismissViewControllerAnimated:YES completion:^{
+                
+                UIAlertView *waitting_alert = [RAUtils waiting_alert:@"Sending Email" title:@"Waiting"];
+                
+                dispatch_async(dispatch_get_global_queue(0, 0), ^{
+                    
+                    NSDictionary *result = [iSalesNetwork notifyModel:productID emailAddr:text];
+                    
+                    dispatch_async(dispatch_get_main_queue(), ^{
+                        
+                        [waitting_alert dismissWithClickedButtonIndex:0 animated:NO];
+                        
+                        int resultStatus = [[result objectForKey:@"result"] intValue];
+                        if (resultStatus != RESULT_TRUE && resultStatus != RESULT_NO_EMAIL_ADDRESS) {
+                            
+                            NSString *msg = [NSString stringWithFormat:@"The email send failed"];
+                            if (resultStatus == 8) {
+                                if ([result valueForKey:@"err_msg"]) {
+                                    msg = [result valueForKey:@"err_msg"];
+                                }
+                            }
+                            
+                            UIAlertController *errorAlertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                            UIAlertAction *action = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                                
+                            }];
+                            
+                            [errorAlertVC addAction:action];
+                            [weakself presentViewController:errorAlertVC animated:YES completion:nil];
+                            
+                        }else if(resultStatus == RESULT_TRUE){
+                            
+                            [RAUtils message_alert:@"Notification is sent to default email address." title:@"Message" controller:weakself];
+                            
+                        } else if (resultStatus == RESULT_NO_EMAIL_ADDRESS) {
+                            
+                            [weakself showAddressBoxToEmailProduct:productID];
+                            
+                        }
+                        
+                    });
+                    
+                });
+                
+            }];
+            
+        } else {
+            
+            // 非邮件地址,警告
+            [weakVC warning:@"Please enter right email address"];
+            
+        }
+        
+    };
+    
+    [self presentViewController:emailAddrVC animated:YES completion:nil];
+}
+
 
 @end

+ 18 - 14
RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m

@@ -116,22 +116,26 @@ dispatch_async(dispatch_get_main_queue(), ^{
         
         dispatch_async(dispatch_get_main_queue(), ^{
             [self.mum stopAnimating];
-            self.detail_data = [detail_json mutableCopy];
-//            self.product_id = [NSString stringWithFormat:@"%d",[[detail_json valueForKey:@"product_id"] intValue] ];
-            NSDictionary* imgsection = [detail_json objectForKey:@"img_section"];
-            //          AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-            if(/*appDelegate.user_type==USER_ROLE_CUSTOMER*/true)
-                self.quantity =[[imgsection valueForKey:@"stockUom"] intValue];
-            else
-                self.quantity =1;
-            
-            if(self.quantity==0)
-                self.quantity=1;
-            self.step=self.quantity;
-            [self.detailTable reloadData];
+          
             
             if([[detail_json valueForKey:@"result"] intValue]==2)
             {
+                
+                self.detail_data = [detail_json mutableCopy];
+                self.product_id = [NSString stringWithFormat:@"%d",[[detail_json valueForKey:@"product_id"] intValue] ];
+                NSDictionary* imgsection = [detail_json objectForKey:@"img_section"];
+                //          AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                if(/*appDelegate.user_type==USER_ROLE_CUSTOMER*/true)
+                    self.quantity =[[imgsection valueForKey:@"stockUom"] intValue];
+                else
+                    self.quantity =1;
+                
+                if(self.quantity==0)
+                    self.quantity=1;
+                self.step=self.quantity;
+                [self.detailTable reloadData];
+                
+                //
                 self.detailTable.hidden = false;
                 
                 NSString* model_name = self.detail_data[@"img_section"][@"model_name"];
@@ -1892,7 +1896,7 @@ self.isrefreshing=false;
                         
                         [waitting_alert dismissWithClickedButtonIndex:0 animated:NO];
                         
-                        int resultStatus = [[result objectForKey:@"result"] integerValue];
+                        int resultStatus = [[result objectForKey:@"result"] intValue];
                         if (resultStatus != RESULT_TRUE && resultStatus != RESULT_NO_EMAIL_ADDRESS) {
                             
                             NSString *msg = [NSString stringWithFormat:@"The email send failed"];

+ 1 - 1
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -10678,7 +10678,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
         
         NSMutableDictionary *resultDic = [NSMutableDictionary dictionary];
         
-        [resultDic setObject:@"item is out of stock,after sync try again" forKey:@"err_msg"];
+        [resultDic setObject:@"some item(s) are out of stock,please remove them from cart before placing order with NPD or try again after sync" forKey:@"err_msg"];
         [resultDic setObject:[NSNumber numberWithInt:8] forKey:@"result"];
         
         return [RAUtils dict2data:resultDic];

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

@@ -1993,7 +1993,7 @@
     }
     else
     {
-        NSString* detail_id=    [item valueForKey:@"product_id"] ;
+        NSString* detail_id = [NSString stringWithFormat:@"%@",[item valueForKey:@"product_id"]];
         
         [self showDetailat:detail_id category_id:nil index:indexPath.row];
     }

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

@@ -2018,7 +2018,7 @@
     }
     else
     {
-        NSString* detail_id=    [item valueForKey:@"product_id"] ;
+        NSString* detail_id = [NSString stringWithFormat:@"%@",[item valueForKey:@"product_id"]];
         
         [self showDetailat:detail_id category_id:nil index:indexPath.row];
     }

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

@@ -11,7 +11,7 @@
 #define BUILD_NPD
 
 # ifdef DEBUG
-//#define test_server
+#define test_server
 # endif
 
 #define exception_switch 1