Переглянути джерело

1.完成NPD Place Order用户交互事件处理。
2.修复NPD Crash后,恢复Common Editor数据丢失。
3.修改NPD Place Order键盘事件中Table Frame处理不正确。

Pen Li 8 роки тому
батько
коміт
d202fc2e11

+ 9 - 4
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m

@@ -367,7 +367,10 @@
     
     self.cancommit = true;
     
-    
+    // 恢复编辑后重置URL Type,避免刷新Crash
+    if (self.url_type == URL_RESTORE) {
+        self.url_type = URL_REMOTE;
+    }
 }
 
 -(NSMutableDictionary*) check_cancommit :(bool) alert
@@ -5702,6 +5705,8 @@
 }
 #pragma mark Responding to keyboard events
 
+static float table_origin_h = 0;
+
 - (void)keyboardWillChangeFrame:(NSNotification *)notification {
     DebugLog(@"keyboardWillChangeFrame");
 }
@@ -5768,8 +5773,8 @@
         //        [UIView commitAnimations];//设置调整界面的动画效果
     }
     
-    
-    self.editorTable.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-self.keyboard_h);
+    table_origin_h = self.editorTable.frame.size.height;
+    self.editorTable.frame = CGRectMake(0, 0, self.editorTable.frame.size.width, self.editorTable.frame.size.height-self.keyboard_h);
     
     //    CGSize tablecontent =self.editorTable.contentSize;
     //    tablecontent.height=tablecontent.height+self.keyboard_h;
@@ -5795,7 +5800,7 @@
     tablecontent.height=tablecontent.height-self.keyboard_h;
     //    self.editorTable.contentSize=tablecontent;
     
-    self.editorTable.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
+    self.editorTable.frame = CGRectMake(0, 0, self.editorTable.frame.size.width, table_origin_h);
     
     self.keyboard_h= 0;
     DebugLog(@"before refresh %@",NSStringFromCGSize(self.editorTable.contentSize));

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

@@ -1031,10 +1031,10 @@
      }
      
      */
-    
     if (self.back_order_flag) {
         
         NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
+        [params setObject:@(0) forKey:@"step"];
         RAOrderEditorViewController *orderEditorVC = [self.storyboard instantiateViewControllerWithIdentifier:@"RAOrderEditorViewController"];
         
         orderEditorVC.disable_dropdown_refresh=true;

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

@@ -99,7 +99,7 @@
 
 - (void)onSaveClick:(UIButton *)sender {
     // add params check here.
-    
+
     [self.lastedit endEditing:true];
     [self.lasttextview endEditing:true];
 //    self.cancommit=true;
@@ -369,7 +369,7 @@
         
         [urgencyDic setValue:weakSelf.class_name forKey:@"class_name"];
         
-        
+        [urgencyDic setValue:@(weakSelf.bnewcustomer) forKey:@"new_customer"];
         
         if ([weakSelf.class_name isEqualToString:@"CustomerEditViewController"]) {
             // CustomerEditViewController

+ 3 - 0
RedAnt ERP Mobile/common/Functions/order/RAOrderEditorViewController.h

@@ -10,6 +10,9 @@
 
 @interface RAOrderEditorViewController : CommonEditorViewController
 
+@property bool have_tail;
 @property (nonatomic,assign) BOOL resumeOrder;///<恢复订单
 
+- (void)recoveryFromUrgencyDic:(NSDictionary *)urgencyDic;
+
 @end

+ 1085 - 12
RedAnt ERP Mobile/common/Functions/order/RAOrderEditorViewController.m

@@ -9,9 +9,15 @@
 #import "RAOrderEditorViewController.h"
 #import "AppDelegate.h"
 #import "MainViewController.h"
+#import "AddressEditorViewController.h"
+#import "CreditCardEditorViewController.h"
+#import "JKTimerManager.h"
+
 
 
 #define CLOSE_ACTION 567
+static const int totalPage = 3;
+
 @interface RAOrderEditorViewController ()
 
 @property (nonatomic,assign) BOOL isResume;///<恢复
@@ -51,17 +57,58 @@
     
     self.navigationItem.leftBarButtonItem = closeButton;
     
+    
+//    UIBarButtonItem *savebtn = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"save"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+//                                               style:UIBarButtonItemStylePlain
+//                                              target:self
+//                                              action:@selector(onSaveClick:)];
+//
+//    self.navigationItem.rightBarButtonItem = savebtn;
+    
+    
     [self setupPageControlBar];
 }
 
-- (void)viewWillAppear:(BOOL)animated {
+-(void) viewWillAppear:(BOOL)animated
+{
     [super viewWillAppear:animated];
+    
+    [self start_urgency_timer];
+    
+    self.isResume = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_resume"] boolValue];
+    self.userType = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_userType"] integerValue];
+    
+    if (!self.isResume) {
+        // 正常情况
+        
+    } else {
+        // 恢复
+        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"urgency_resume"];
+        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"urgency_userType"];
+    }
+
+    self.navigationController.navigationBarHidden=false;
+    
 }
 
 - (void)didReceiveMemoryWarning {
     [super didReceiveMemoryWarning];
     // Dispose of any resources that can be recreated.
 }
+
+- (void)dealloc {
+    
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    
+    [appDelegate.urgencyDic removeObjectForKey:[NSString stringWithFormat:@"level_%d",self.level]];
+    [appDelegate.urgencyDic setValue:[NSNumber numberWithInteger:self.level] forKey:@"count"];
+    
+    if (self.isResume && self.userType == USER_ROLE_CUSTOMER) {
+        [self releaseOrderAfterSave];
+    }
+    
+}
+
 - (void)awakeFromNib {
     [super awakeFromNib];
     self.navigationItem.rightBarButtonItem = nil;
@@ -198,7 +245,6 @@
 
 - (void)setupPageControlBar {
     
-    int totalPage = 1;
     // 1. 控制ToolBar Item显隐
     NSMutableArray *items = [self.pageControlToolBar.items mutableCopy];
     if (self.pageIndex == 0) {
@@ -208,10 +254,16 @@
         }
         
     } else if (self.pageIndex == totalPage - 1) {
-        // 尾页不需要后一页
-        if ([items containsObject:self.nextBarItem]) {
-            [items removeObject:self.nextBarItem];
+//        // 尾页不需要后一页
+//        if ([items containsObject:self.nextBarItem]) {
+//            [items removeObject:self.nextBarItem];
+//        }
+        
+        // 尾页点击Next进入Preview
+        if (![items containsObject:self.nextBarItem]) {
+            [items addObject:self.nextBarItem];
         }
+        
     } else {
         // 中间显示前一页、后一页按钮
         if (![items containsObject:self.frontBarItem]) {
@@ -232,7 +284,7 @@
     self.pageIndex--;
     
     // 1.恢复当前页面数据
-    NSMutableDictionary* upparams = [self.pageUpParams lastObject]; // 前页上行参数
+    NSMutableDictionary* upparams = [self.pageUpParams lastObject]; // 前页上行参数
     __weak typeof(self) weakSelf = self;
     [upparams enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
         
@@ -240,6 +292,7 @@
         
     }];
     [self.pageUpParams removeLastObject];
+    [self.params setObject:@(self.pageIndex) forKey:@"step"];
     
     self.content_data_control = [self.pageContentControlArray lastObject];
     [self.pageContentControlArray removeLastObject];
@@ -262,6 +315,17 @@
     
     NSMutableDictionary* upparams = [self check_cancommit:false]; // 当前页上行参数
     
+    if (self.pageIndex == totalPage) {
+        
+        // 尾页 进入Preview
+        
+        return;
+    }
+    
+
+    // 请求页码
+    [upparams setObject:@(self.pageIndex) forKey:@"step"];
+    
     // 1.保存当前页面数据
     if (upparams == nil) {
         upparams = [NSMutableDictionary dictionary];
@@ -285,13 +349,18 @@
     
     // 2.请求下一页数据
     __weak typeof(self) weakSelf = self;
-    [upparams enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
-       
-        [weakSelf.params setObject:obj forKey:key];
-        
-    }];
+    for (NSDictionary *page_params in self.pageUpParams) {
+        // 当前页及之前所有页参数均上传
+        [page_params enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
+            
+            [weakSelf.params setObject:obj forKey:key];
+            
+        }];
+    }
     
-    [self setupPageControlBar];
+//    [self setupPageControlBar];
+
+    self.content_data_download = [NSMutableDictionary dictionary];
     [self refresh:nil];
 }
 
@@ -299,8 +368,1012 @@
 
 - (void)download_success {
     
+    NSString *title = [self.content_data_download objectForKey:@"title"];
+    self.title = title;
+    
     [self setupPageControlBar];
     
+    // 用于处理不同child,在成功去的数据后,需要附加的操作。
+    
+    self.have_tail=[[self.content_data_download valueForKey:@"has_reItem"] boolValue];
+    
+    NSString* order_customerid=[self getValue:@"customer_cid"];
+    
+    
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    appDelegate.order_customer_id = order_customerid;
+    
+}
+
+#pragma mark - Place Order
+
+- (void)alertMessage:(NSString *)msg {
+
+    if (notifyMe_switch) {
+        
+        if ([self.class_name isEqualToString:@"RAOrderEditorViewController"]) {
+            
+            NSString *err_msg = msg;
+            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) {
+                
+                [weakself.navigationController popViewControllerAnimated:YES];
+                
+            }];
+            [alertVC addAction:action];
+            
+            [self presentViewController:alertVC animated:YES completion:nil];
+            
+        } else {
+            
+            [RAUtils message_alert:msg title:nil controller:self] ;
+        }
+        
+    } else {
+        
+        [RAUtils message_alert:msg title:nil controller:self] ;
+    }
+}
+
+-(void) commonAction:(NSString *)value index:(NSIndexPath*) indexPath data:(NSMutableDictionary*) item_json
+{
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if([value isEqualToString:@"new_addr"])
+    {
+        AddressEditorViewController * addressVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"AddressEditorViewController"];
+        
+        addressVC.url_type = URL_REMOTE;
+        
+        addressVC.request_url=URL_ADDRESS_EDOTOR;
+
+        
+        NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
+
+        
+        addressVC.params = params;
+        
+        
+        addressVC.delegate = self;
+        
+        addressVC.from = indexPath;
+        //            orderinfoVC.params = params;
+        
+        [self.navigationController pushViewController:addressVC animated:true];
+        
+    }else if([value isEqualToString:@"credit_card"])
+    {
+        CreditCardEditorViewController * cardVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"CreditCardEditorViewController"];
+        
+        
+        NSDictionary *data = [item_json objectForKey:@"data"];
+        
+        if(data!=nil)
+        {
+            
+            cardVC.content_data_download = [data mutableCopy];
+            cardVC.url_type = URL_NONE;
+            
+            cardVC.request_url=nil;
+        }
+        else
+        {
+            cardVC.url_type = URL_REMOTE;
+            
+            cardVC.request_url=URL_CREDITCARD_EDOTOR;
+        }
+        NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
+        
+        params[@"orderCode"]=appDelegate.order_code;
+        cardVC.params = params;
+        
+        cardVC.delegate = self;
+        
+        cardVC.from = indexPath;
+        
+        
+        [self.navigationController pushViewController:cardVC animated:true];
+        
+    }
+    else if([value isEqualToString:@"Sales_Order_Freight_Bill_To"])
+    {
+        
+        
+        ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+        cvc.showNavibar = true;
+        cvc.contact_type = value;
+        __weak typeof(self) weakself = self;
+        cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+            
+            [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+
+        };
+        
+        
+        
+        [self.navigationController pushViewController:cvc animated:true];
+        
+    }
+    else if([value isEqualToString:@"Sales_Order_Ship_From"])
+    {
+        
+        
+        ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+        cvc.showNavibar = true;
+        cvc.contact_type = value;
+        __weak typeof(self) weakself = self;
+        cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+            
+            [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+
+        };
+        
+        
+        
+        [self.navigationController pushViewController:cvc animated:true];
+        
+    }
+    else if([value isEqualToString:@"Sales_Order_Customer"])
+    {
+        
+        
+        ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+        
+        cvc.contact_type = value;
+        cvc.showNavibar = true;
+        __weak typeof(self) weakself = self;
+        cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+            
+            [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+
+        };
+        
+        
+        
+        [self.navigationController pushViewController:cvc animated:true];
+        
+    }
+    else if([value isEqualToString:@"Sales_Order_Merchandise_Bill_To"])
+    {
+        
+        
+        ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+        cvc.showNavibar = true;
+        cvc.contact_type = value;
+        __weak typeof(self) weakself = self;
+        cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+            
+            [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+
+        };
+        
+        
+        
+        [self.navigationController pushViewController:cvc animated:true];
+        
+    }
+    else if([value isEqualToString:@"Contact_Return_To"])
+    {
+        
+        
+        ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+        cvc.showNavibar = true;
+        cvc.contact_type = value;
+        __weak typeof(self) weakself = self;
+        cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+            
+            [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+            
+        };
+        
+        
+        
+        [self.navigationController pushViewController:cvc animated:true];
+        
+    }
+    else if([value isEqualToString:@"Sales_Order_Ship_To"])
+    {
+        
+        
+        ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+        cvc.showNavibar = true;
+        cvc.contact_type = value;
+        __weak typeof(self) weakself = self;
+        cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+            
+            [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+
+        };
+        
+        
+        
+        [self.navigationController pushViewController:cvc animated:true];
+        
+    }
+    
+}
+
+- (UIView *)createDemoView:(NSString*) msg
+{
+    UIView *demoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 290, 200)];
+    
+    //    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 270, 180)];
+    //    [imageView setImage:[UIImage imageNamed:@"demo"]];
+    
+    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 270, 10)];
+    titleLabel.font = [UIFont boldSystemFontOfSize:20];
+    titleLabel.text=@"Order Submission";
+    titleLabel.numberOfLines = 0;
+    titleLabel.lineBreakMode =NSLineBreakByWordWrapping;
+    //    titleLabel.textAlignment = NSTextAlignmentRight;
+    titleLabel.textAlignment = NSTextAlignmentCenter;
+    CGSize constraintkey = CGSizeMake(270, 20000.0f);//key label width is 40% cell width;
+    CGSize sizetitle = [titleLabel.text=@"Order Submission" sizeWithFont:[UIFont systemFontOfSize:20.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
+    
+    //[titleLabel sizeToFit];
+    //    titleLabel.center.x = demoView.center.x;
+    titleLabel.frame = CGRectMake(10, 10, 270, sizetitle.height);
+    [demoView addSubview:titleLabel];
+    
+    UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 260, 10)];
+    lineLabel.font = [UIFont systemFontOfSize:17];
+    lineLabel.text=msg;
+    lineLabel.numberOfLines = 0;
+    lineLabel.lineBreakMode =NSLineBreakByWordWrapping;
+    
+    CGSize sizemsg = [msg sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
+    
+    lineLabel.frame = CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 260, sizemsg.height);
+    //[lineLabel sizeToFit];
+    
+    [demoView addSubview:lineLabel];
+    demoView.frame = CGRectMake(0, 0, 290, lineLabel.frame.origin.y+lineLabel.frame.size.height+25);
+    return demoView;
+}
+
+-(float) getprice:(NSString*) name section :(long) index
+{
+    NSMutableDictionary* section_json=nil;
+    section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",index ]] mutableCopy];
+    int count=0;
+    
+    count=[[section_json valueForKey:@"count"] intValue];
+    
+    for(int i=0;i<count;i++)
+    {
+        NSDictionary * olditem=[[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]] mutableCopy];
+        if([[olditem valueForKey:@"name"] isEqualToString:name])
+        {
+            return [[olditem valueForKey:@"value"] floatValue];
+            
+        }
+        
+    }
+    
+    return 0;
+}
+
+- (void)textFieldDidEndEditing:(UITextField *)textField
+{
+    
+    [super textFieldDidEndEditing:textField];
+    
+    UITableViewCell *cell = (UITableViewCell *) textField.superview.superview;
+    NSIndexPath *   indexPath = [self.editorTable indexPathForCell:cell];
+    
+    
+    NSMutableDictionary* section_json=nil;
+    
+    
+    //    DebugLog(@"endedit %d_%d",indexPath.section,indexPath.row);
+    NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
+    
+    
+    NSString* name = [item_json valueForKey:@"name"];
+    
+    if([name isEqualToString:@"shipping"]|| [name isEqualToString:@"handling_fee_value"]||[name isEqualToString:@"lift_gate_value"]||[name isEqualToString:@"tax_percentage"])
+    {
+        float shipping = [self getprice:@"shipping" section:indexPath.section];
+        float paymentsAndCredits = [self getprice:@"paymentsAndCredits" section:indexPath.section];
+        float handling_fee_value = [self getprice:@"handling_fee_value" section:indexPath.section];
+        float lift_gate =[self getprice:@"lift_gate_value" section:indexPath.section];
+        float tax = [self getprice:@"tax_percentage" section:indexPath.section]/100.0*paymentsAndCredits;
+        float totalprice=shipping+paymentsAndCredits+handling_fee_value+lift_gate+tax;
+        
+        section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
+        int count=0;
+        
+        count=[[section_json valueForKey:@"count"] intValue];
+        
+        int total_row_idx=-1;
+        
+        for(int i=0;i<count;i++)
+        {
+            NSDictionary * olditem=[[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]] mutableCopy];
+            if([[olditem valueForKey:@"name"] isEqualToString:@"totalPrice" ])
+            {
+                [olditem setValue:[NSString stringWithFormat:@"%.2f",totalprice] forKey:@"value"];
+                [olditem setValue:@"true" forKey:@"dirty"];
+                [section_json setObject:olditem  forKey:[NSString stringWithFormat:@"item_%d",i ]];
+                
+                total_row_idx=i;
+                
+            }
+            
+        }
+        
+        [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
+        
+        
+        self.content_data_control = [self translate_json:self.content_data_download changed: self.changed_data];
+        
+        
+        if(total_row_idx>=0)
+        {
+            
+            
+            
+            NSUInteger newIndex[] = {indexPath.section, total_row_idx};
+            NSIndexPath *newPath = [[NSIndexPath alloc] initWithIndexes:newIndex length:2];
+            //        DebugLog(@"before refresh %@",NSStringFromCGSize(self.editorTable.contentSize));
+            [self.editorTable reloadRowsAtIndexPaths:@[newPath]withRowAnimation:UITableViewRowAnimationMiddle];
+
+        }
+        
+    }
+
+}
+
+- (IBAction)onSaveClick:(id)sender {
+
+    id a = nil;
+    NSMutableArray *arr = [NSMutableArray array];
+    [arr addObject:a];
+    
+    [self.lastedit endEditing:true];
+    [self.lasttextview endEditing:true];
+    
+    NSMutableDictionary* upparams = [self check_cancommit:false];
+    
+    if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
+        upparams[@"shipping"] = nil;
+    
+    
+    UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Saving Order"];
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        
+        NSDictionary* editor_json = [RANetwork save_Order:upparams];
+        
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+            
+            
+            if([[editor_json valueForKey:@"result"] intValue]==2)
+            {
+                
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                
+                NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
+                
+                if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+                {
+                    appDelegate.customerInfo = customerInfo;
+                    appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
+                }
+                NSString *msg = nil;
+                if ([editor_json objectForKey:@"so#"]) {
+                    msg = [@"SO#:" stringByAppendingString:[editor_json objectForKey:@"so#"]];
+                }
+                [RAUtils message_alert:msg title:@"Order Saved" controller:self] ;
+                
+                if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
+                {
+                    [((MainViewController*)appDelegate.main_vc) Loginout:false];
+                    [self prepareReturn:nil];
+                    [self.navigationController popViewControllerAnimated:true];
+                }
+                
+                if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
+                    
+                    if (![Singleton sharedInstance].currentOrderIsMerged) {
+                        [self releaseOrderAfterSave];
+                    }
+                    
+                    
+                }
+
+            }
+            else
+            {
+                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
+            }
+
+        });
+    });
+    
+}
+
+- (void)releaseOrderAfterSave {
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    
+    [RANetwork release_Order:appDelegate.order_code withScreen:nil];
+    
+    [appDelegate closeOrder];
+    [appDelegate SetSo:nil];
+    appDelegate.cart_count=0;
+    [appDelegate update_count_mark];
+    [((MainViewController*)appDelegate.main_vc) switchToOrder];
+    
+    [self prepareReturn:nil];
+    [self.navigationController popToRootViewControllerAnimated:false];
+    
+}
+
+-(NSString* )create_customer_ext:(NSDictionary*)customerinfo
+{
+    NSString* ret=nil;
+    NSString* customer_address1= [customerinfo valueForKey:@"customer_address1"];
+    NSString* customer_address2= [customerinfo valueForKey:@"customer_address2"];
+    NSString* customer_address3= [customerinfo valueForKey:@"customer_address3"];
+    NSString* customer_address4= [customerinfo valueForKey:@"customer_address4"];
+    
+    NSMutableArray* arraddr = [[NSMutableArray alloc] init];
+    if(customer_address1.length>0)
+        [arraddr addObject:customer_address1];
+    if(customer_address2.length>0)
+        [arraddr addObject:customer_address2];
+    if(customer_address3.length>0)
+        [arraddr addObject:customer_address3];
+    if(customer_address4.length>0)
+        [arraddr addObject:customer_address4];
+    NSString *addr_string = [arraddr componentsJoinedByString:@"\r\n"];
+    
+    
+    NSString* customer_city= [customerinfo valueForKey:@"customer_city"];
+    NSString* customer_country= [customerinfo valueForKey:@"customer_country"];
+    NSString* customer_zipcode= [customerinfo valueForKey:@"customer_zipcode"];
+    NSString* customer_state= [customerinfo valueForKey:@"customer_state"];
+    
+    NSMutableArray* arrcty = [[NSMutableArray alloc] init];
+    if(customer_city.length>0)
+        [arrcty addObject:customer_city];
+    if(customer_state.length>0)
+        [arrcty addObject:customer_state];
+    if(customer_zipcode.length>0)
+        [arrcty addObject:customer_zipcode];
+    if(customer_country.length>0)
+        [arrcty addObject:customer_country];
+    NSString *cty_string = [arrcty componentsJoinedByString:@", "];
+    
+    
+    NSMutableArray* arrext = [[NSMutableArray alloc] init];
+    if(addr_string.length>0)
+        [arrext addObject:addr_string];
+    if(cty_string.length>0)
+        [arrext addObject:cty_string];
+    
+    ret = [arrext componentsJoinedByString:@"\r\n"];
+    
+    
+    return ret;
+}
+
+-(NSMutableDictionary*)create_cusromer_info_from_table
+{
+    
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    
+    NSMutableDictionary* ret= [appDelegate.customerInfo mutableCopy] ;
+    
+    [ret setValue:[self getValue:@"customer_country"] forKey:@"customer_country"];
+    [ret setValue:[self getValue:@"customer_phone"] forKey:@"customer_phone"];
+    [ret setValue:[self getValue:@"customer_email"] forKey:@"customer_email"];
+    [ret setValue:[self getValue:@"customer_name"] forKey:@"customer_name"];
+    [ret setValue:[self getValue:@"customer_address4"] forKey:@"customer_address4"];
+    [ret setValue:[self getValue:@"customer_address3"] forKey:@"customer_address3"];
+    [ret setValue:[self getValue:@"customer_address2"] forKey:@"customer_address2"];
+    [ret setValue:[self getValue:@"customer_address1"] forKey:@"customer_address1"];
+    [ret setValue:[self getValue:@"customer_zipcode"] forKey:@"customer_zipcode"];
+    [ret setValue:[self getValue:@"customer_city"] forKey:@"customer_city"];
+    [ret setValue:[self getValue:@"customer_state"] forKey:@"customer_state"];
+    [ret setValue:[self getValue:@"customer_cid"] forKey:@"customer_cid"];
+    [ret setValue:[self getValue:@"customer_state"] forKey:@"customer_state"];
+    [ret setValue:[self getValue:@"customer_contact"] forKey:@"customer_contact"];
+    [ret setValue:[self getValue:@"customer_fax"] forKey:@"customer_fax"];
+    
+    NSString * firstname =nil;
+    
+    NSString* lastname = nil;
+    NSString* contact_name = [self getValue:@"customer_contact"];
+    if(contact_name!=nil)
+    {
+        NSArray *_arr = [contact_name componentsSeparatedByString:NSLocalizedString(@" ", nil)];
+        
+        
+        
+        if(_arr.count>=1)
+        {
+            firstname =_arr[0];
+            if(_arr.count>1)
+            {
+                
+                lastname=[[_arr subarrayWithRange:NSMakeRange(1, _arr.count-1)] componentsJoinedByString:@" "];
+            }
+        }
+    }
+    [ret setValue:firstname forKey:@"customer_first_name"];
+    [ret setValue:lastname forKey:@"customer_last_name"];
+    
+    //    [ret setValue:[self create_customer_ext:ret] forKey:@"customer_contact_ext"];
+    
+    return ret;
+}
+
+-(NSMutableDictionary*)create_value_map:(NSDictionary*)key_map
+{
+    NSMutableDictionary* ret= [[NSMutableDictionary alloc] init];
+    NSArray *keys= [key_map allKeys];
+    //遍历keys
+    for(int i=0;i<[keys count];i++)
+    {
+        //得到当前key
+        NSString *key=[keys objectAtIndex:i];
+        //如果key不是pic,说明value是字符类型,比如name:Boris
+        NSString* valuefrom = [key_map valueForKey:key];
+        
+        if(valuefrom.length==0)
+            continue;
+        NSString* value=[self getValue:valuefrom];
+        
+        [ret setValue:value forKey:valuefrom];
+    }
+    NSDictionary * customerinfo =[self create_cusromer_info_from_table];
+    [ret setValue:[self create_customer_ext:customerinfo] forKey:@"customer_contact_ext"];
+    [ret setValue:customerinfo[@"customer_first_name"] forKey:@"customer_first_name"];
+    [ret setValue:customerinfo[@"customer_last_name"] forKey:@"customer_last_name"];
+    return ret;
+}
+
+#pragma mark - multi_action sub action clicked
+
+- (void)MActionClicked:(UIButton *)sender {
+    
+    UITableViewCell *cell = (UITableViewCell *) sender.superview.superview;
+    NSIndexPath *   indexPath = [self.editorTable indexPathForCell:cell];
+    int refresh =0;
+    NSMutableDictionary* section_json=nil;
+    
+    NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
+    NSString* subid=[item_json valueForKey:@"subid"];
+    NSString* refresh_trigger = [item_json valueForKey:@"name"];
+    NSDictionary* sub_action = [item_json objectForKey:[NSString stringWithFormat:@"item_%ld",(long)sender.tag]];
+    NSString* type = [sub_action valueForKey:@"type"];
+    if([type isEqualToString:@"pull"])
+    {
+        
+        [self.lastedit endEditing:true];
+        
+        refresh = [[sub_action valueForKey:@"refresh"] intValue];
+        NSDictionary* keymap= [sub_action objectForKey:@"key_map"];
+        
+        NSMutableDictionary* value=[self create_value_map:keymap];
+        
+        if(subid==nil)
+        {
+            NSDictionary* jsonmap=[sub_action valueForKey:@"key_map"];
+            section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
+            int icount=[[section_json valueForKey:@"count"] intValue];
+            for (int ic=0;ic<icount;ic++)
+            {
+                NSMutableDictionary* modify_item= [[section_json objectForKey:[NSString stringWithFormat:@"item_%d",ic ]] mutableCopy];
+                
+                
+                NSString* mapto = [modify_item valueForKey:@"name"];
+                if(mapto.length==0)
+                    continue;
+                NSString* valuefrom= [jsonmap valueForKey:[modify_item valueForKey:@"name"]];
+                if(valuefrom==nil)
+                    continue;
+                NSString* valuestr=[value valueForKey:valuefrom];
+                
+                
+                
+                
+                
+                //                valuestr = [self getValue:valuefrom];
+                if(true)
+                {
+                    if(valuestr.length>0)
+                        [modify_item setValue:valuestr forKey:@"value"];
+                    else
+                        [modify_item setValue:@"" forKey:@"value"];
+                    [modify_item setValue:@"true" forKey:@"dirty"];
+                    [section_json setObject:modify_item  forKey:[NSString stringWithFormat:@"item_%d",ic ]];
+                }
+            }
+        }
+        else
+        {
+            
+            NSArray* idarr=[subid componentsSeparatedByString:@"_"];
+            int section = [(NSString*)idarr[0] intValue];
+            int item=[(NSString*)idarr[1] intValue];
+            NSDictionary* jsonmap=[sub_action valueForKey:@"key_map"];
+            
+            section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d", section]] mutableCopy];
+            NSMutableDictionary * olditem=[[section_json objectForKey:[NSString stringWithFormat:@"item_%d",item ]] mutableCopy];
+            
+            NSString* control_type = [olditem valueForKey:@"control"];
+            if([control_type isEqualToString:@"switch"])
+                olditem=   [self fill_switch_subitem:olditem subid:nil source:value mapping:jsonmap ];
+            else if([control_type isEqualToString:@"enum"])
+            {
+                olditem=   [self fill_enum_subitem:olditem subid:nil source:value mapping:jsonmap ];
+                
+            }
+            else
+            {
+                [RAUtils alert_view:@"" title:@"not impl"];
+            }
+            
+            [olditem setValue:@"true" forKey:@"dirty"];
+            [section_json setObject:olditem  forKey:[NSString stringWithFormat:@"item_%d",item ]];
+            
+        }
+        [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
+        self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
+        
+        
+        if(refresh==1)
+        {
+            
+            //            if(restore_json!=nil)
+            //            {
+            //                int rc=[[restore_json valueForKey:@"count"] intValue];
+            //                for(int ir=0;ir<rc;ir++)
+            //                {
+            //                    NSString* name = [restore_json valueForKey:[NSString stringWithFormat:@"item_%d",ir]];
+            //
+            //
+            //                    int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
+            //                    for(int i=0;i<section_count;i++)
+            //                    {
+            //                        NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
+            //                        //                    NSMutableDictionary * to_sectionjson = [[to objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
+            //                        int item_count = [[sectionjson valueForKey:@"count"] intValue];
+            //                        for(int j=0;j<item_count;j++)
+            //                        {
+            //                            NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
+            //                            //             NSMutableDictionary * to_itemjson=[[to_sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
+            //
+            //                            if([[itemjson valueForKey:@"name"] isEqualToString:name])
+            //                            {
+            //                                [itemjson removeObjectForKey:@"dirty"];
+            //                                [sectionjson setObject:itemjson forKey:[NSString stringWithFormat:@"item_%d",j ]];
+            //                            }
+            //
+            //                        }
+            //                        [self.content_data_download setObject:sectionjson forKey:[NSString stringWithFormat:@"section_%d",i ]];
+            //                    }
+            //
+            //
+            //                }
+            //
+            //            }
+            [self refresh:refresh_trigger] ;
+            return ;
+        }
+        
+        //    DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
+        [self.editorTable reloadData ];
+        
+        
+    }
+    else
+    {
+        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+        NSDictionary * item_json = sub_action;
+        NSString* value = [item_json valueForKey:@"value"];
+        if([value isEqualToString:@"new_addr"])
+        {
+            AddressEditorViewController * addressVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"AddressEditorViewController"];
+            
+            addressVC.url_type = URL_REMOTE;
+            
+            addressVC.request_url=URL_ADDRESS_EDOTOR;
+            
+            
+            
+            
+            NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
+            //            NSString * string = [checked componentsJoinedByString:@","];
+            //            [params setValue:string forKey:@"cart2Checkbox"];
+            
+            
+            params[@"is_subaction"]=@"true";
+            params[@"subaction_tag"]= [NSString stringWithFormat:@"%ld",(long)sender.tag];
+            addressVC.params = params;
+            
+            
+            addressVC.delegate = self;
+            
+            addressVC.from = indexPath;
+            //            orderinfoVC.params = params;
+            
+            [self.navigationController pushViewController:addressVC animated:true];
+            
+        }else if([value isEqualToString:@"credit_card"])
+        {
+            CreditCardEditorViewController * cardVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"CreditCardEditorViewController"];
+            
+            
+            NSDictionary *data = [item_json objectForKey:@"data"];
+            
+            if(data!=nil)
+            {
+                
+                cardVC.content_data_download = [data mutableCopy];
+                cardVC.url_type = URL_NONE;
+                
+                cardVC.request_url=nil;
+            }
+            else
+            {
+                cardVC.url_type = URL_REMOTE;
+                
+                cardVC.request_url=URL_CREDITCARD_EDOTOR;
+            }
+            NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
+            
+            params[@"orderCode"]=appDelegate.order_code;
+            
+            params[@"is_subaction"]=@"true";
+            params[@"subaction_tag"]= [NSString stringWithFormat:@"%ld",(long)sender.tag];
+            cardVC.params = params;
+            
+            cardVC.delegate = self;
+            
+            cardVC.from = indexPath;
+            
+            
+            //            orderinfoVC.params = params;
+            
+            [self.navigationController pushViewController:cardVC animated:true];
+            
+        }
+        else if([value isEqualToString:@"Sales_Order_Freight_Bill_To"])
+        {
+            
+            
+            ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+            cvc.showNavibar = true;
+            cvc.contact_type = value;
+            cvc.is_subaction = @"true";
+            cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
+            
+            
+            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+                
+                [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                
+                //
+                //                if(self.returnValue)
+                //                    self.returnValue(value);
+            };
+            
+            
+            
+            [self.navigationController pushViewController:cvc animated:true];
+            
+        }
+        else if([value isEqualToString:@"Sales_Order_Ship_From"])
+        {
+            
+            
+            ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+            cvc.showNavibar = true;
+            cvc.contact_type = value;
+            cvc.is_subaction = @"true";
+            cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
+            
+            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+                
+                [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                
+                //
+                //                if(self.returnValue)
+                //                    self.returnValue(value);
+            };
+            
+            
+            
+            [self.navigationController pushViewController:cvc animated:true];
+            
+        }
+        else if([value isEqualToString:@"Sales_Order_Customer"])
+        {
+            
+            
+            ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+            cvc.is_subaction = @"true";
+            cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
+            cvc.showNavibar = true;
+            cvc.contact_type = value;
+            __weak typeof(self) weakself = self;
+            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+                
+                [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                
+                //
+                //                if(self.returnValue)
+                //                    self.returnValue(value);
+            };
+            
+            
+            
+            [self.navigationController pushViewController:cvc animated:true];
+            
+        }
+        else if([value isEqualToString:@"Sales_Order_Merchandise_Bill_To"])
+        {
+            
+            
+            ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+            cvc.showNavibar = true;
+            cvc.contact_type = value;
+            cvc.is_subaction = @"true";
+            cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
+            __weak typeof(self) weakself = self;
+            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+                
+                [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                
+                //
+                //                if(self.returnValue)
+                //                    self.returnValue(value);
+            };
+            
+            
+            
+            [self.navigationController pushViewController:cvc animated:true];
+            
+        }
+        else if([value isEqualToString:@"Contact_Return_To"])
+        {
+            
+            
+            ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+            cvc.is_subaction = @"true";
+            cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
+            cvc.showNavibar = true;
+            cvc.contact_type = value;
+            __weak typeof(self) weakself = self;
+            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+                
+                [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                
+                //
+                //                if(self.returnValue)
+                //                    self.returnValue(value);
+            };
+            
+            
+            
+            [self.navigationController pushViewController:cvc animated:true];
+            
+        }
+        else if([value isEqualToString:@"Sales_Order_Ship_To"])
+        {
+            
+            
+            ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+            cvc.is_subaction = @"true";
+            cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
+            cvc.showNavibar = true;
+            cvc.contact_type = value;
+            __weak typeof(self) weakself = self;
+            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+                
+                [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                
+                //
+                //                if(self.returnValue)
+                //                    self.returnValue(value);
+            };
+            
+            
+            
+            [self.navigationController pushViewController:cvc animated:true];
+            
+        }
+        
+        
+    }
+}
+
+#pragma mark - Urgency
+
+
+
+-(void) viewWillDisappear:(BOOL)animated
+{
+    [super viewWillDisappear:animated];
+    [self cancel_urgency_timer];
+}
+
+- (void)start_urgency_timer {
+    
+    if (!self.editable) {
+        return;
+    }
+    
+    __weak typeof(self) weakSelf = self;
+    
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    
+    [appDelegate.urgencyDic setValue:appDelegate.user forKey:@"user"];
+#ifdef OFFLINE_MODE
+    [appDelegate.urgencyDic setValue:[NSNumber numberWithBool:appDelegate.offline_mode] forKey:@"offline_mode"];
+#endif
+    [[JKTimerManager sharedTimerManager] scheduledDispatchTimerWithName:self.urgency_timer_name timeInterval:1 queue:nil repeats:YES action:^{
+        
+        NSMutableDictionary *urgencyDic = [NSMutableDictionary dictionary];
+        
+        //        DebugLog(@"timer start....");
+        
+        [urgencyDic setValue:weakSelf.content_data_download forKey:[NSString stringWithFormat:@"%@_restored_data",self.class_name]];
+        
+        [urgencyDic setValue:weakSelf.class_name forKey:@"class_name"];
+        
+        
+        
+        if ([weakSelf.class_name isEqualToString:@"RAOrderEditorViewController"]) {
+            // CreateOrderViewController
+            
+            
+            [urgencyDic setValue:appDelegate.order_code forKey:@"order_code"];
+            MainViewController *mainVC = (MainViewController *)appDelegate.main_vc;
+            NSString *so = [mainVC.labelSo.text substringFromIndex:5];
+            [urgencyDic setValue:so forKey:@"order_so"];
+            [urgencyDic setValue:[NSNumber numberWithInt:appDelegate.order_status ] forKey:@"order_status"];
+            
+            [urgencyDic setValue:appDelegate.order_customer_id forKey:@"order_customer_id"];
+            
+            // page
+            [urgencyDic setObject:@(weakSelf.pageIndex) forKey:@"page_index"];
+            [urgencyDic setObject:weakSelf.pageContentDownloadArray forKey:@"download_content_array"];
+            [urgencyDic setObject:weakSelf.pageContentControlArray forKey:@"control_content_array"];
+            [urgencyDic setObject:weakSelf.pageChangeDataArray forKey:@"changed_data_array"];
+            [urgencyDic setObject:weakSelf.pageUpParams forKey:@"up_param_array"];
+            [urgencyDic setObject:weakSelf.request_url forKey:@"request_url"];
+        }
+        
+        [appDelegate.urgencyDic setValue:urgencyDic forKey:[NSString stringWithFormat:@"level_%d",weakSelf.level]];
+        [appDelegate.urgencyDic setValue:[NSNumber numberWithInteger:weakSelf.level + 1] forKey:@"count"];
+        
+    }];
+}
+
+- (void)cancel_urgency_timer {
+    [[JKTimerManager sharedTimerManager] cancelTimerWithName:self.urgency_timer_name];
+}
+
+- (void)recoveryFromUrgencyDic:(NSDictionary *)urgencyDic {
+    
+    
+    self.disable_dropdown_refresh=true;
+    self.url_type = URL_RESTORE;
+    self.params = [NSMutableDictionary dictionary];
+    self.content_data_download = [urgencyDic objectForKey:[NSString stringWithFormat:@"%@_restored_data",self.class_name]];
+    self.resumeOrder = YES;
+    
+    self.pageIndex = [[urgencyDic objectForKey:@"page_index"] integerValue];
+    self.pageContentDownloadArray = [urgencyDic objectForKey:@"download_content_array"];
+    self.pageContentControlArray = [urgencyDic objectForKey:@"control_content_array"];
+    self.pageChangeDataArray = [urgencyDic objectForKey:@"changed_data_array"];
+    self.pageUpParams = [urgencyDic objectForKey:@"up_param_array"];
+    self.request_url = [urgencyDic objectForKey:@"request_url"];
 }
 
+
 @end

+ 24 - 16
RedAnt ERP Mobile/iSales-NPD/AppDelegate.m

@@ -28,6 +28,7 @@
 #import "GoogleAnalyst.h"
 #import "ERPUtils.h"
 #import "RANetwork.h"
+#import "RAOrderEditorViewController.h"
 
 #define UNZIP_OPEN_FAILED 0
 #define UNZIP_SUCCESS 1
@@ -622,15 +623,16 @@ void UncaughtExceptionHandler(NSException *exception) {
                     // CustomerEditViewController
                     
                     NSString *contact_id = [urgencyDic objectForKey:@"contact_id"];
+                    BOOL new_customer = [urgencyDic objectForKey:@"new_customer"];
                     
                     NSMutableDictionary *params = [NSMutableDictionary dictionary];
                     
                     [params setValue:contact_id forKey:@"contact_id"];
                     CustomerEditViewController * cuseditVC =[mainStoryBoard instantiateViewControllerWithIdentifier:@"CustomerEditViewController"];
                     
-                    cuseditVC.bnewcustomer=false;
-                    cuseditVC.url_type = URL_REMOTE;
-                    cuseditVC.request_url=URL_NEW_CUSTOMER;
+                    cuseditVC.bnewcustomer=new_customer;
+                    cuseditVC.url_type = URL_RESTORE;
+                    cuseditVC.request_url= new_customer ? URL_NEW_CUSTOMER : URL_EDIT_CUSTOMER;
                     
                     cuseditVC.params = params;
                     cuseditVC.content_data_download = restored_data;
@@ -643,7 +645,7 @@ void UncaughtExceptionHandler(NSException *exception) {
                     
                     
                     
-                } else if ([className isEqualToString:@"CreateOrderViewController"]) {
+                } else if ([className isEqualToString:@"CreateOrderViewController"] || [className isEqualToString:@"RAOrderEditorViewController"]) {
                     // CreateOrderViewController
                     
                     NSString *order_code = [urgencyDic objectForKey:@"order_code"];
@@ -686,19 +688,25 @@ void UncaughtExceptionHandler(NSException *exception) {
                     
                     
                     // 再place order
-                    
                     NSMutableDictionary *params = [NSMutableDictionary dictionary];
                     
-                    CreateOrderViewController * orderinfoVC =[mainStoryBoard instantiateViewControllerWithIdentifier:@"CreateOrderViewController"];
-                    
-                    orderinfoVC.disable_dropdown_refresh=true;
-                    orderinfoVC.url_type = URL_REMOTE;
-                    orderinfoVC.request_url=URL_CARTDELIVERY;
-                    orderinfoVC.params = params;
-                    orderinfoVC.content_data_download = restored_data;
-                    orderinfoVC.resumeOrder = YES;
-                    
-                    [mainVC.navigationController pushViewController:orderinfoVC animated:true];
+                    if ([className isEqualToString:@"CreateOrderViewController"]) {
+                        CreateOrderViewController * orderinfoVC =[mainStoryBoard instantiateViewControllerWithIdentifier:@"CreateOrderViewController"];
+                        
+                        orderinfoVC.disable_dropdown_refresh=true;
+                        orderinfoVC.url_type = URL_RESTORE;
+                        orderinfoVC.request_url=URL_CARTDELIVERY;
+                        orderinfoVC.params = params;
+                        orderinfoVC.content_data_download = restored_data;
+                        orderinfoVC.resumeOrder = YES;
+                        
+                        [mainVC.navigationController pushViewController:orderinfoVC animated:true];
+                    } else if ([className isEqualToString:@"RAOrderEditorViewController"]) {
+                        
+                        RAOrderEditorViewController *orderEditorVC = [mainStoryBoard instantiateViewControllerWithIdentifier:@"RAOrderEditorViewController"];
+                        [orderEditorVC recoveryFromUrgencyDic:urgencyDic];
+                        [mainVC.navigationController pushViewController:orderEditorVC animated:YES];
+                    }
                     
                     
                 } else  if ([className isEqualToString:@"AddressEditorViewController"]) {
@@ -706,7 +714,7 @@ void UncaughtExceptionHandler(NSException *exception) {
                     
                     AddressEditorViewController * addressVC =[mainStoryBoard instantiateViewControllerWithIdentifier:@"AddressEditorViewController"];
                     
-                    addressVC.url_type = URL_REMOTE;
+                    addressVC.url_type = URL_RESTORE;
                     addressVC.request_url=URL_ADDRESS_EDOTOR;
                     
                     NSMutableDictionary * params= [[NSMutableDictionary alloc] init];

Різницю між файлами не показано, бо вона завелика
+ 124 - 124
RedAnt ERP Mobile/iSales-NPD/Base.lproj/Main.storyboard


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

@@ -47,6 +47,8 @@
 #ifdef test_server
 
 //------------------- chen server-----------------------
+#define  URL_CART_DELIVERY_A  @"http://192.168.0.133:8080/site/isales/cartDeliveryStepA.htm"
+
 #define  URL_UPDATE_AUTH  @"http://192.168.0.133:8080/site/isales/login.htm"
 #define  URL_LOGOUT  @"http://192.168.0.133:8080/site/isales/loginOut.htm"
 #define  URL_RETRIEVE_PASS  @"http://192.168.0.133:8080/site/isales/forgotPassword.htm"

Деякі файли не було показано, через те що забагато файлів було змінено