Przeglądaj źródła

ERP MOBILE
更改order 编辑时 刷新 order list 的时机,改在save 后刷新。

Ray Zhang 7 lat temu
rodzic
commit
38e1ab1e6e

+ 13 - 839
RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m

@@ -1741,131 +1741,7 @@
     // add params check here.
     [self.lastedit endEditing:true];
     [self.lasttextview endEditing:true];
-//    self.cancommit=true;
-//    NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
-//    [upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
-//    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];
-//        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];
-//            NSString* key = [itemjson valueForKey:@"name"];
-//            if(key==nil || key.length==0)
-//                continue;
-//            if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
-//            {
-//                NSString* single_select = [itemjson valueForKey:@"single_select"];
-//                if([single_select isEqualToString:@"true"])
-//                {
-//                    NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
-//                    int count = [[cadejson valueForKey:@"count"] intValue];
-//                    bool setvalue = false;
-//                    for(int cc=0;cc<count;cc++)
-//                    {
-//                        NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
-//                        if([[valjson valueForKey:@"check"]intValue]==1)
-//                        {
-//                            [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
-//                            setvalue=true;
-//                            break;
-//                        }
-//                    }
-//                    if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
-//                    {
-//                        self.cancommit = false;
-//                    }
-//                }
-//                else
-//                {
-//                    //not support multi select for now;
-//                }
-//                /*
-//                 upparams setValue:itemjson forKey:<#(NSString *)#>
-//                 
-//                 */
-//            }else
-//                if([[itemjson valueForKey:@"control"] isEqualToString:@"action"])
-//                {
-//                    if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
-//                        self.cancommit = false;
-//                }
-//                else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
-//                {
-//                    if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"]==nil)
-//                        self.cancommit = false;
-//                    
-//                    NSString* valuestr = [itemjson valueForKey:@"value"];
-//                    [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
-//                }
-//                else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
-//                {
-//                    NSString* valuestr = [itemjson valueForKey:@"value"];
-//                    [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
-//                    
-//                    NSString* value = [itemjson valueForKey:@"value"];
-//                    NSMutableDictionary* boolitem=nil;
-//                    NSMutableDictionary* subjson=nil;
-//                    if([value isEqualToString:@"true"])
-//                    {
-//                        boolitem =[[itemjson objectForKey:@"true"] mutableCopy];
-//                        
-//                    }
-//                    else
-//                    {
-//                        boolitem =[[itemjson objectForKey:@"false"] mutableCopy];
-//                        
-//                    }
-//                    subjson=[[boolitem objectForKey:@"sub_item"] mutableCopy];
-//                    if( subjson!=nil /*&& !active*/)
-//                    {
-//                        int sub_count = [[subjson valueForKey:@"count"] intValue];
-//                        for(int l=0;l<sub_count;l++)
-//                        {
-//                            NSMutableDictionary * modify_item=[[subjson objectForKey:[NSString stringWithFormat:@"item_%d",l ]] mutableCopy];
-//                            
-//                            
-//                            
-//                            
-//                            if([modify_item valueForKey:@"value"]!=nil && ![[modify_item valueForKey:@"value"]isEqualToString:@""])
-//                                [upparams setValue:[modify_item valueForKey:@"value"] forKey:[modify_item valueForKey:@"name"]];
-//                            else
-//                            {
-//                                if([[modify_item valueForKey:@"required"] isEqualToString: @"true"] )
-//                                    self.cancommit = false;
-//                            }
-//                        }
-//                        
-//                        
-//                        
-//                    }
-//                }
-//                else
-//                {
-//                    if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
-//                        [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
-//                    else
-//                    {
-//                        if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
-//                            self.cancommit = false;
-//                    }
-//                }
-//            upparams= [self subitem_param:itemjson addto:upparams ];
-//        }
-//    }
-//    // save order 不检查必填项;
-//    self.cancommit=true;
-//    if(self.cancommit==false)
-//    {
-//        [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
-//        self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
-//        //DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
-//        //[self.editorTable reloadData ];
-//        [self.editorTable reloadData];
-//        return;
-//    }
+
     
     NSMutableDictionary* upparams = [self check_cancommit:false];
 //    if(self.cancommit==false)
@@ -1911,6 +1787,17 @@
                     [self prepareReturn:nil];
                     [self.navigationController popViewControllerAnimated:true];
                 }
+                else{
+                    
+                    
+#ifdef RA_NOTIFICATION
+                    [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                    
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+#endif
+                }
                 
                 if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
                     
@@ -2077,714 +1964,7 @@
 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
 {
     
-    if(buttonIndex!=alertView.cancelButtonIndex && alertView.tag == SUBMIT_CONFIRM)
-    {
-//        // add params check here.
-//        [self.lastedit endEditing:true];
-//        [self.lasttextview endEditing:true];
-//
-//
-//
-////        self.cancommit=true;
-////        NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
-////        [upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
-////        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];
-////            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];
-////                NSString* key = [itemjson valueForKey:@"name"];
-////                if(key==nil || key.length==0)
-////                    continue;
-////                if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
-////                {
-////                    NSString* single_select = [itemjson valueForKey:@"single_select"];
-////                    if([single_select isEqualToString:@"true"])
-////                    {
-////                        NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
-////                        int count = [[cadejson valueForKey:@"count"] intValue];
-////                        bool setvalue = false;
-////                        for(int cc=0;cc<count;cc++)
-////                        {
-////                            NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
-////                            if([[valjson valueForKey:@"check"]intValue]==1)
-////                            {
-////                                [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
-////                                setvalue=true;
-////                                break;
-////                            }
-////                        }
-////                        if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
-////                        {
-////                            self.cancommit = false;
-////                        }
-////                    }
-////                    else
-////                    {
-////                        //not support multi select for now;
-////                    }
-////                    /*
-////                     upparams setValue:itemjson forKey:<#(NSString *)#>
-////
-////                     */
-////                }else
-////                    if([[itemjson valueForKey:@"control"] isEqualToString:@"action"])
-////                    {
-////                        if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
-////                            self.cancommit = false;
-////                    }
-////                    else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
-////                    {
-////                        if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"] ==nil)
-////                            self.cancommit = false;
-////
-////                        NSString* valuestr = [itemjson valueForKey:@"value"];
-////                        [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
-////                    }
-////                    else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
-////                    {
-////                        NSString* valuestr = [itemjson valueForKey:@"value"];
-////                        [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
-////
-////                        NSString* value = [itemjson valueForKey:@"value"];
-////                        NSMutableDictionary* boolitem=nil;
-////                        NSMutableDictionary* subjson=nil;
-////                        if([value isEqualToString:@"true"])
-////                        {
-////                            boolitem =[[itemjson objectForKey:@"true"] mutableCopy];
-////
-////                        }
-////                        else
-////                        {
-////                            boolitem =[[itemjson objectForKey:@"false"] mutableCopy];
-////
-////                        }
-////                        subjson=[[boolitem objectForKey:@"sub_item"] mutableCopy];
-////                        if( subjson!=nil /*&& !active*/)
-////                        {
-////                            int sub_count = [[subjson valueForKey:@"count"] intValue];
-////                            for(int l=0;l<sub_count;l++)
-////                            {
-////                                NSMutableDictionary * modify_item=[[subjson objectForKey:[NSString stringWithFormat:@"item_%d",l ]] mutableCopy];
-////
-////
-////
-////
-////                                if([modify_item valueForKey:@"value"]!=nil && ![[modify_item valueForKey:@"value"]isEqualToString:@""])
-////                                    [upparams setValue:[modify_item valueForKey:@"value"] forKey:[modify_item valueForKey:@"name"]];
-////                                else
-////                                {
-////                                    if([[modify_item valueForKey:@"required"] isEqualToString: @"true"] )
-////                                        self.cancommit = false;
-////                                }
-////                            }
-////
-////
-////
-////                        }
-////                    }
-////                    else
-////                    {
-////                        if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
-////                            [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
-////                        else
-////                        {
-////                            if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
-////                                self.cancommit = false;
-////                        }
-////                    }
-////                upparams= [self subitem_param:itemjson addto:upparams ];
-////            }
-////        }
-////        if(self.cancommit==false)
-////        {
-////            [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
-////            self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
-////            //DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
-////            //[self.editorTable reloadData ];
-////            [self.editorTable reloadData];
-////            //  [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-////            return;
-////        }
-//
-//        NSMutableDictionary* upparams = [self check_cancommit:true];
-//        if(self.cancommit==false)
-//            return;
-//
-//        if(upparams[@"shipping"]==nil)
-//            goto commit_order;
-//        if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
-//        {
-//            upparams[@"shipping"] = nil;
-//            goto commit_order;
-//        }
-//        else if([upparams[@"shipping"] doubleValue]==0)
-//        {
-//
-//
-//            UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Shipping is $0.00, continue submit?" message:nil preferredStyle:UIAlertControllerStyleAlert];
-//            //block代码块取代了delegate
-//
-//
-//
-//            UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
-//                                        {
-//
-//                                            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//
-//                                            if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
-//                                            {
-//
-//                                                if(/*!self.have_tail*/ true)
-//                                                {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
-//                                                    [upparams setValue:@"false" forKey:@"isHold"];
-//                                                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//
-//                                                        NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
-//
-//                                                        dispatch_async(dispatch_get_main_queue(), ^{
-//                                                            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-//
-//
-//                                                            if([[editor_json valueForKey:@"result"] intValue]==2)
-//                                                            {
-//                                                                //          NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-//
-//                                                                // debug aaa
-//                                                                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//                                                                NSString* company= appDelegate.customerInfo[@"customer_name"];
-//                                                                NSString* send_to =appDelegate.customerInfo[@"customer_email"];
-//
-//                                                                //                                appDelegate.customerInfo = customerInfo;
-//                                                                //                                appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
-//                                                                //                                appDelegate.order_code = nil;
-//                                                                [appDelegate closeOrder];
-//                                                                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-//
-//                                                                NSString* title=nil;
-//                                                                NSString* msg=nil;
-//#ifdef OFFLINE_MODE
-//                                                                if(appDelegate.offline_mode)
-//                                                                {
-//                                                                    title=TITLE_OFFLINE_SUBMIT;
-//                                                                    msg=MSG_OFFLINE_SUBMIT;
-//                                                                }
-//                                                                else
-//#endif
-//                                                                {
-//                                                                    title=@"Order submitted sucessfully";
-//                                                                    msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
-//                                                                }
-//
-//                                                                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-//
-//                                                                [alert show];
-//
-//                                                                NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
-//                                                                NSString* email_content =[editor_json valueForKey:@"email_content"];
-//                                                                NSString* soid=[editor_json valueForKey:@"so#"];
-////                                                                if(pdf_url.length>0)
-////                                                                {
-////
-////                                                                    [alert dismissWithClickedButtonIndex:0 animated:FALSE];
-////                                                                    //[self downloadpdf:pdf_url];
-////
-////
-////                                                                    if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
-////                                                                    {
-////                                                                        //bbb
-////                                                                        [((MainViewController*)appDelegate.main_vc) Loginout:false];
-////                                                                    }
-////
-////                                                                    [self prepareReturn:nil];
-////
-////                                                                    [self.navigationController popViewControllerAnimated:true];
-////
-////                                                                    [appDelegate printPdf:pdf_url];
-//////                                                                    if(self.printPdfCallback)
-//////                                                                        self.printPdfCallback(pdf_url);
-////                                                                }
-////                                                                else
-//                                                                {
-//                                                                    if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
-//                                                                    {
-//                                                                        //bbb
-//                                                                        [((MainViewController*)appDelegate.main_vc) Loginout:false];
-//                                                                    }
-//                                                                    [self prepareReturn:nil];
-//
-//                                                                    [self.navigationController popViewControllerAnimated:true];
-//
-//                                                                    if(pdf_url.length>0)
-//                                                                    {
-//
-//                                                                        [alert dismissWithClickedButtonIndex:0 animated:FALSE];
-//                                                                        [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
-//                                                                      //  [appDelegate printPdf:pdf_url];
-//
-//                                                                    }
-//                                                                }
-//
-//                                                            }
-//                                                            else
-//                                                            {
-//                                                                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
-//                                                            }
-//
-//
-//
-//
-//                                                        });
-//                                                    });
-//                                                }
-//                                                else
-//                                                {
-//                                                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Retain models", nil) message:NSLocalizedString(@"There are some models left in cart,do you want to keep them?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
-//
-//
-//                                                    alert.tag = KEEP_TAIL;
-//
-//
-//                                                    self.upparams = upparams;
-//
-//                                                    [alert show];
-//                                                }
-//
-//                                            }
-//                                            else
-//                                            { //USER_ROLE_CUSTOMER
-//
-//                                                //            if(self.have_tail)
-//                                                //            [upparams setValue:@"true" forKey:@"isHold"];
-//                                                //            else
-//                                                //                [upparams setValue:@"false" forKey:@"isHold"];
-//                                                UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
-//
-//                                                [upparams setValue:@"true" forKey:@"isHold"];
-//                                                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//
-//                                                    NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
-//
-//                                                    dispatch_async(dispatch_get_main_queue(), ^{
-//
-//                                                        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-//
-//                                                        if([[editor_json valueForKey:@"result"] intValue]==2)
-//                                                        {
-//                                                            //       NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-//
-//
-//                                                            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//                                                            // appDelegate.customerInfo = customerInfo;
-//
-////                                                            NSString* orderCode = [editor_json valueForKey:@"orderCode"];
-////                                                            appDelegate.order_code = orderCode;
-////                                                            appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
-//                                                            [appDelegate closeOrder];
-//                                                            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-//
-//                                                            NSString* title=nil;
-//                                                            NSString* msg=nil;
-//#ifdef OFFLINE_MODE
-//                                                            if(appDelegate.offline_mode)
-//                                                            {
-//                                                                title=TITLE_OFFLINE_SUBMIT;
-//                                                                msg=MSG_OFFLINE_SUBMIT;
-//                                                            }
-//                                                            else
-//#endif
-//                                                            {
-//                                                                title=@"Order submitted sucessfully";
-//                                                                msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
-//                                                            }
-//
-//                                                            UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-//
-//                                                            [alert show];
-//                                                            //    //     self.labelContact.text=appDelegate.contact_name;
-//                                                            //
-//                                                            //    NSDictionary * customerinfo = appDelegate.customerInfo;
-//                                                            [self prepareReturn:nil];
-//                                                            [self.navigationController popViewControllerAnimated:true];
-//                                                            //                                    [self.navigationController dismissViewControllerAnimated:true completion:^{
-//                                                            //
-//                                                            //
-//                                                            //                                        ;
-//                                                            //                                    }];
-//
-//                                                        }
-//                                                        else
-//                                                        {
-//                                                            [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
-//                                                        }
-//
-//
-//
-//
-//                                                    });
-//                                                });
-//
-//                                            }
-//
-//
-//
-//                                        }];
-//
-//            UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
-//                //DebugLog(@"Cancel");
-//
-//
-//            }];
-//            [alertControl addAction:actionOne];
-//
-//            [alertControl addAction:alertthree];
-//
-//            //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
-//
-//
-//
-//
-//            [self presentViewController:alertControl animated:YES completion:nil];
-//
-//
-//
-//        }
-//        else
-//        {
-//        commit_order:
-//
-//            {
-//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//
-//                if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
-//                {
-//
-//                    if(/*!self.have_tail*/ true)
-//                    {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
-//                        [upparams setValue:@"false" forKey:@"isHold"];
-//                        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//
-//                            NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
-//
-//                            dispatch_async(dispatch_get_main_queue(), ^{
-//                                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-//
-//
-//                                if([[editor_json valueForKey:@"result"] intValue]==2)
-//                                {
-//
-//                                    //debug bbb
-//                                    //    NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-//
-//
-//                                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//                                    NSString* company= appDelegate.customerInfo[@"customer_name"];
-//                                    NSString* send_to =appDelegate.customerInfo[@"customer_email"];
-//                                    //                                appDelegate.customerInfo = customerInfo;
-//                                    //                                appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
-//                                    //                                appDelegate.order_code = nil;
-//                                    [appDelegate closeOrder];
-//                                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-//
-//                                    NSString* title=nil;
-//                                    NSString* msg=nil;
-//#ifdef OFFLINE_MODE
-//                                    if(appDelegate.offline_mode)
-//                                    {
-//                                        title=TITLE_OFFLINE_SUBMIT;
-//                                        msg=MSG_OFFLINE_SUBMIT;
-//                                    }
-//                                    else
-//#endif
-//                                    {
-//                                        title=@"Order submitted sucessfully";
-//                                        msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
-//                                    }
-//
-//                                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-//
-//                                    [alert show];
-//
-//                                    NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
-//                                    NSString* email_content =[editor_json valueForKey:@"email_content"];
-//                                    NSString* soid=[editor_json valueForKey:@"so#"];
-////                                    if(pdf_url.length>0)
-////                                    {
-////
-////                                        [alert dismissWithClickedButtonIndex:0 animated:FALSE];
-//////                                        [self downloadpdf:pdf_url];
-////
-////
-////                                        if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
-////                                        {
-////                                            //bbb
-////                                            [((MainViewController*)appDelegate.main_vc) Loginout:false];
-////                                        }
-////
-////                                        [self prepareReturn:nil];
-////
-////                                        [self.navigationController popViewControllerAnimated:true];
-////
-////                                        [appDelegate printPdf:pdf_url];
-////
-//////                                        if(self.printPdfCallback)
-//////                                            self.printPdfCallback(pdf_url);
-////                                    }
-////                                    else
-//                                    {
-//                                        if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
-//                                        {
-//                                            //bbb
-//                                            [((MainViewController*)appDelegate.main_vc) Loginout:false];
-//                                        }
-//                                        [self prepareReturn:nil];
-//
-//                                        [self.navigationController popViewControllerAnimated:true];
-//
-//
-//                                        if(pdf_url.length>0)
-//                                        {
-//
-//                                            [alert dismissWithClickedButtonIndex:0 animated:FALSE];
-//
-//                                            [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
-//
-//
-//                                        }
-//
-//
-//                                    }
-//                                    //    //     self.labelContact.text=appDelegate.contact_name;
-//                                    //
-//                                    //    NSDictionary * customerinfo = appDelegate.customerInfo;
-//
-//
-//
-//
-//
-//
-//                                }
-//                                else
-//                                {
-//                                    [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
-//                                }
-//
-//
-//
-//
-//                            });
-//                        });
-//                    }
-//                    else
-//                    {
-//                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Retain models", nil) message:NSLocalizedString(@"There are some models left in cart,do you want to keep them?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
-//
-//
-//                        alert.tag = KEEP_TAIL;
-//
-//
-//                        self.upparams = upparams;
-//
-//                        [alert show];
-//                    }
-//
-//                }
-//                else
-//                { //USER_ROLE_CUSTOMER
-//
-//                    //            if(self.have_tail)
-//                    //            [upparams setValue:@"true" forKey:@"isHold"];
-//                    //            else
-//                    //                [upparams setValue:@"false" forKey:@"isHold"];
-//                    UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
-//
-//                    [upparams setValue:@"true" forKey:@"isHold"];
-//                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//
-//                        NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
-//
-//                        dispatch_async(dispatch_get_main_queue(), ^{
-//
-//                            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-//
-//                            if([[editor_json valueForKey:@"result"] intValue]==2)
-//                            {
-//                                //       NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-//
-//
-//                                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//                                // appDelegate.customerInfo = customerInfo;
-//
-////                                NSString* orderCode = [editor_json valueForKey:@"orderCode"];
-////                                appDelegate.order_code = orderCode;
-////                                appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
-//                                [appDelegate closeOrder];
-//                                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-//
-//                                NSString* title=nil;
-//                                NSString* msg=nil;
-//#ifdef OFFLINE_MODE
-//                                if(appDelegate.offline_mode)
-//                                {
-//                                    title=TITLE_OFFLINE_SUBMIT;
-//                                    msg=MSG_OFFLINE_SUBMIT;
-//                                }
-//                                else
-//#endif
-//                                {
-//                                    title=@"Order submitted sucessfully";
-//                                    msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
-//                                }
-//
-//
-//                                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-//
-//                                [alert show];
-//                                //    //     self.labelContact.text=appDelegate.contact_name;
-//                                //
-//                                //    NSDictionary * customerinfo = appDelegate.customerInfo;
-//                                [self prepareReturn:nil];
-//                                //                            [self.navigationController dismissViewControllerAnimated:true completion:^{
-//                                //
-//                                //
-//                                //                                ;
-//                                //                            }];
-//                                [self.navigationController popViewControllerAnimated:true];
-//
-//                            }
-//                            else
-//                            {
-//                                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
-//                            }
-//
-//
-//
-//
-//                        });
-//                    });
-//
-//                }
-//            }
-//
-//
-//
-//
-//        }
-//
-        
-        
-        
-        
-        
-        
-        
-        
-        
-        
-    }
-    
-    //    else if( alertView.tag == KEEP_TAIL)
-    //    {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Submit Order"];
-    //        if(buttonIndex!=alertView.cancelButtonIndex)
-    //        {//keep tail;
-    //
-    //            [self.upparams setValue:@"true" forKey:@"isHold"];
-    //            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-    //
-    //                NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:self.upparams];
-    //
-    //                dispatch_async(dispatch_get_main_queue(), ^{
-    //                    [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-    //
-    //
-    //                    if([[editor_json valueForKey:@"result"] intValue]==2)
-    //                    {
-    //                        NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-    //                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Submit successful." message:[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-    //
-    //                        [alert show];
-    //
-    //                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    //                        appDelegate.customerInfo = customerInfo;
-    //                        appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
-    //                        NSString* orderCode = [editor_json valueForKey:@"orderCode"];
-    //                        appDelegate.order_code = orderCode;
-    //                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-    //                        //    //     self.labelContact.text=appDelegate.contact_name;
-    //                        //
-    //                        //    NSDictionary * customerinfo = appDelegate.customerInfo;
-    //                        [self prepareReturn:nil];
-    ////                        [self.navigationController dismissViewControllerAnimated:true completion:^{
-    ////
-    ////
-    ////                            ;
-    ////                        }];
-    //                        [self.navigationController popViewControllerAnimated:true];
-    //
-    //                    }
-    //                    else
-    //                    {
-    //                        [RAUtils message_alert:[editor_json valueForKey:@"err_msg"]  title:@"Submit Order" controller:self] ;
-    //                    }
-    //
-    //
-    //
-    //
-    //                });
-    //            });
-    //        }
-    //        else
-    //        {// not keep tail;
-    //            [self.upparams setValue:@"false" forKey:@"isHold"];
-    //            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-    //
-    //                NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:self.upparams];
-    //
-    //                dispatch_async(dispatch_get_main_queue(), ^{
-    //                    [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-    //
-    //
-    //                    if([[editor_json valueForKey:@"result"] intValue]==2)
-    //                    {
-    //                        //    NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-    //                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Submit successful." message:[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-    //
-    //                        [alert show];
-    //
-    //                        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    //                        //                        appDelegate.customerInfo = customerInfo;
-    //                        //                        appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
-    //                        //                        appDelegate.order_code = nil;
-    //                        [appDelegate closeOrder];
-    //                        [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-    //                        //    //     self.labelContact.text=appDelegate.contact_name;
-    //                        //
-    //                        //    NSDictionary * customerinfo = appDelegate.customerInfo;
-    //                        [self prepareReturn:nil];
-    ////                        [self.navigationController dismissViewControllerAnimated:true completion:^{
-    ////
-    ////
-    ////                            ;
-    ////                        }];
-    //                        [self.navigationController popViewControllerAnimated:true];
-    //
-    //                    }
-    //                    else
-    //                    {
-    //                        [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Submit Order" controller:self] ;
-    //                    }
-    //
-    //
-    //
-    //
-    //                });
-    //            });
-    //        }
-    //    }
-    else if(alertView.tag == CLOSE_ACTION)
+    if(alertView.tag == CLOSE_ACTION)
     {
         if(buttonIndex==1)
         {
@@ -2808,13 +1988,7 @@
 
             AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
             
-#ifdef RA_NOTIFICATION
-            [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-#else
 
-            
-            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-#endif
             [((MainViewController*)appDelegate.main_vc) switchToOrder];
             // back to cart;
             //            [self.navigationController dismissViewControllerAnimated:true completion:^{

+ 14 - 728
RedAnt ERP Mobile/common/Functions/order/RAOrderPreviewController.m

@@ -1742,131 +1742,7 @@
     // add params check here.
     [self.lastedit endEditing:true];
     [self.lasttextview endEditing:true];
-    //    self.cancommit=true;
-    //    NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
-    //    [upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
-    //    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];
-    //        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];
-    //            NSString* key = [itemjson valueForKey:@"name"];
-    //            if(key==nil || key.length==0)
-    //                continue;
-    //            if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
-    //            {
-    //                NSString* single_select = [itemjson valueForKey:@"single_select"];
-    //                if([single_select isEqualToString:@"true"])
-    //                {
-    //                    NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
-    //                    int count = [[cadejson valueForKey:@"count"] intValue];
-    //                    bool setvalue = false;
-    //                    for(int cc=0;cc<count;cc++)
-    //                    {
-    //                        NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
-    //                        if([[valjson valueForKey:@"check"]intValue]==1)
-    //                        {
-    //                            [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
-    //                            setvalue=true;
-    //                            break;
-    //                        }
-    //                    }
-    //                    if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
-    //                    {
-    //                        self.cancommit = false;
-    //                    }
-    //                }
-    //                else
-    //                {
-    //                    //not support multi select for now;
-    //                }
-    //                /*
-    //                 upparams setValue:itemjson forKey:<#(NSString *)#>
-    //
-    //                 */
-    //            }else
-    //                if([[itemjson valueForKey:@"control"] isEqualToString:@"action"])
-    //                {
-    //                    if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
-    //                        self.cancommit = false;
-    //                }
-    //                else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
-    //                {
-    //                    if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"]==nil)
-    //                        self.cancommit = false;
-    //
-    //                    NSString* valuestr = [itemjson valueForKey:@"value"];
-    //                    [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
-    //                }
-    //                else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
-    //                {
-    //                    NSString* valuestr = [itemjson valueForKey:@"value"];
-    //                    [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
-    //
-    //                    NSString* value = [itemjson valueForKey:@"value"];
-    //                    NSMutableDictionary* boolitem=nil;
-    //                    NSMutableDictionary* subjson=nil;
-    //                    if([value isEqualToString:@"true"])
-    //                    {
-    //                        boolitem =[[itemjson objectForKey:@"true"] mutableCopy];
-    //
-    //                    }
-    //                    else
-    //                    {
-    //                        boolitem =[[itemjson objectForKey:@"false"] mutableCopy];
-    //
-    //                    }
-    //                    subjson=[[boolitem objectForKey:@"sub_item"] mutableCopy];
-    //                    if( subjson!=nil /*&& !active*/)
-    //                    {
-    //                        int sub_count = [[subjson valueForKey:@"count"] intValue];
-    //                        for(int l=0;l<sub_count;l++)
-    //                        {
-    //                            NSMutableDictionary * modify_item=[[subjson objectForKey:[NSString stringWithFormat:@"item_%d",l ]] mutableCopy];
-    //
-    //
-    //
-    //
-    //                            if([modify_item valueForKey:@"value"]!=nil && ![[modify_item valueForKey:@"value"]isEqualToString:@""])
-    //                                [upparams setValue:[modify_item valueForKey:@"value"] forKey:[modify_item valueForKey:@"name"]];
-    //                            else
-    //                            {
-    //                                if([[modify_item valueForKey:@"required"] isEqualToString: @"true"] )
-    //                                    self.cancommit = false;
-    //                            }
-    //                        }
-    //
-    //
-    //
-    //                    }
-    //                }
-    //                else
-    //                {
-    //                    if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
-    //                        [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
-    //                    else
-    //                    {
-    //                        if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
-    //                            self.cancommit = false;
-    //                    }
-    //                }
-    //            upparams= [self subitem_param:itemjson addto:upparams ];
-    //        }
-    //    }
-    //    // save order 不检查必填项;
-    //    self.cancommit=true;
-    //    if(self.cancommit==false)
-    //    {
-    //        [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
-    //        self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
-    //        //DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
-    //        //[self.editorTable reloadData ];
-    //        [self.editorTable reloadData];
-    //        return;
-    //    }
+    
     
     NSMutableDictionary* upparams = [self check_cancommit:false];
     //    if(self.cancommit==false)
@@ -1917,6 +1793,17 @@
                     [self prepareReturn:nil];
                     [self.navigationController popToRootViewControllerAnimated:true];
                 }
+                else{
+                    
+                    
+#ifdef RA_NOTIFICATION
+                    [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                    
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+#endif
+                }
                 
                 if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
                     
@@ -2083,605 +1970,9 @@
 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
 {
     
-    if(buttonIndex!=alertView.cancelButtonIndex && alertView.tag == SUBMIT_CONFIRM)
-    {
-//        // add params check here.
-//        [self.lastedit endEditing:true];
-//        [self.lasttextview endEditing:true];
-//
-//
-//
-//        //        self.cancommit=true;
-//        //        NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
-//        //        [upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
-//        //        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];
-//        //            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];
-//        //                NSString* key = [itemjson valueForKey:@"name"];
-//        //                if(key==nil || key.length==0)
-//        //                    continue;
-//        //                if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
-//        //                {
-//        //                    NSString* single_select = [itemjson valueForKey:@"single_select"];
-//        //                    if([single_select isEqualToString:@"true"])
-//        //                    {
-//        //                        NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
-//        //                        int count = [[cadejson valueForKey:@"count"] intValue];
-//        //                        bool setvalue = false;
-//        //                        for(int cc=0;cc<count;cc++)
-//        //                        {
-//        //                            NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
-//        //                            if([[valjson valueForKey:@"check"]intValue]==1)
-//        //                            {
-//        //                                [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
-//        //                                setvalue=true;
-//        //                                break;
-//        //                            }
-//        //                        }
-//        //                        if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
-//        //                        {
-//        //                            self.cancommit = false;
-//        //                        }
-//        //                    }
-//        //                    else
-//        //                    {
-//        //                        //not support multi select for now;
-//        //                    }
-//        //                    /*
-//        //                     upparams setValue:itemjson forKey:<#(NSString *)#>
-//        //
-//        //                     */
-//        //                }else
-//        //                    if([[itemjson valueForKey:@"control"] isEqualToString:@"action"])
-//        //                    {
-//        //                        if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
-//        //                            self.cancommit = false;
-//        //                    }
-//        //                    else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
-//        //                    {
-//        //                        if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"] ==nil)
-//        //                            self.cancommit = false;
-//        //
-//        //                        NSString* valuestr = [itemjson valueForKey:@"value"];
-//        //                        [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
-//        //                    }
-//        //                    else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
-//        //                    {
-//        //                        NSString* valuestr = [itemjson valueForKey:@"value"];
-//        //                        [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
-//        //
-//        //                        NSString* value = [itemjson valueForKey:@"value"];
-//        //                        NSMutableDictionary* boolitem=nil;
-//        //                        NSMutableDictionary* subjson=nil;
-//        //                        if([value isEqualToString:@"true"])
-//        //                        {
-//        //                            boolitem =[[itemjson objectForKey:@"true"] mutableCopy];
-//        //
-//        //                        }
-//        //                        else
-//        //                        {
-//        //                            boolitem =[[itemjson objectForKey:@"false"] mutableCopy];
-//        //
-//        //                        }
-//        //                        subjson=[[boolitem objectForKey:@"sub_item"] mutableCopy];
-//        //                        if( subjson!=nil /*&& !active*/)
-//        //                        {
-//        //                            int sub_count = [[subjson valueForKey:@"count"] intValue];
-//        //                            for(int l=0;l<sub_count;l++)
-//        //                            {
-//        //                                NSMutableDictionary * modify_item=[[subjson objectForKey:[NSString stringWithFormat:@"item_%d",l ]] mutableCopy];
-//        //
-//        //
-//        //
-//        //
-//        //                                if([modify_item valueForKey:@"value"]!=nil && ![[modify_item valueForKey:@"value"]isEqualToString:@""])
-//        //                                    [upparams setValue:[modify_item valueForKey:@"value"] forKey:[modify_item valueForKey:@"name"]];
-//        //                                else
-//        //                                {
-//        //                                    if([[modify_item valueForKey:@"required"] isEqualToString: @"true"] )
-//        //                                        self.cancommit = false;
-//        //                                }
-//        //                            }
-//        //
-//        //
-//        //
-//        //                        }
-//        //                    }
-//        //                    else
-//        //                    {
-//        //                        if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
-//        //                            [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
-//        //                        else
-//        //                        {
-//        //                            if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
-//        //                                self.cancommit = false;
-//        //                        }
-//        //                    }
-//        //                upparams= [self subitem_param:itemjson addto:upparams ];
-//        //            }
-//        //        }
-//        //        if(self.cancommit==false)
-//        //        {
-//        //            [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
-//        //            self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
-//        //            //DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
-//        //            //[self.editorTable reloadData ];
-//        //            [self.editorTable reloadData];
-//        //            //  [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-//        //            return;
-//        //        }
-//
-//        NSMutableDictionary* upparams = [self check_cancommit:true];
-//        if(self.cancommit==false)
-//            return;
-//
-//        if(upparams[@"shipping"]==nil)
-//            goto commit_order;
-//        if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
-//        {
-//            upparams[@"shipping"] = nil;
-//            goto commit_order;
-//        }
-//        else if([upparams[@"shipping"] doubleValue]==0)
-//        {
-//
-//
-//            UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Shipping is $0.00, continue submit?" message:nil preferredStyle:UIAlertControllerStyleAlert];
-//            //block代码块取代了delegate
-//
-//
-//
-//            UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
-//                                        {
-//
-//                                            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//
-//                                            if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
-//                                            {
-//
-//                                                if(/*!self.have_tail*/ true)
-//                                                {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
-//                                                    [upparams setValue:@"false" forKey:@"isHold"];
-//                                                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//
-//                                                        NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
-//
-//                                                        dispatch_async(dispatch_get_main_queue(), ^{
-//                                                            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-//
-//
-//                                                            if([[editor_json valueForKey:@"result"] intValue]==2)
-//                                                            {
-//                                                                //          NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-//
-//                                                                // debug aaa
-//                                                                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//                                                                NSString* company= appDelegate.customerInfo[@"customer_name"];
-//                                                                NSString* send_to =appDelegate.customerInfo[@"customer_email"];
-//
-//                                                                //                                appDelegate.customerInfo = customerInfo;
-//                                                                //                                appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
-//                                                                //                                appDelegate.order_code = nil;
-//                                                                [appDelegate closeOrder];
-//                                                                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-//
-//                                                                NSString* title=nil;
-//                                                                NSString* msg=nil;
-//#ifdef OFFLINE_MODE
-//                                                                if(appDelegate.offline_mode)
-//                                                                {
-//                                                                    title=TITLE_OFFLINE_SUBMIT;
-//                                                                    msg=MSG_OFFLINE_SUBMIT;
-//                                                                }
-//                                                                else
-//#endif
-//                                                                {
-//                                                                    title=@"Order submitted sucessfully";
-//                                                                    msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
-//                                                                }
-//
-//                                                                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-//
-//                                                                [alert show];
-//
-//                                                                NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
-//                                                                NSString* email_content =[editor_json valueForKey:@"email_content"];
-//                                                                NSString* soid=[editor_json valueForKey:@"so#"];
-//                                                                //                                                                if(pdf_url.length>0)
-//                                                                //                                                                {
-//                                                                //
-//                                                                //                                                                    [alert dismissWithClickedButtonIndex:0 animated:FALSE];
-//                                                                //                                                                    //[self downloadpdf:pdf_url];
-//                                                                //
-//                                                                //
-//                                                                //                                                                    if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
-//                                                                //                                                                    {
-//                                                                //                                                                        //bbb
-//                                                                //                                                                        [((MainViewController*)appDelegate.main_vc) Loginout:false];
-//                                                                //                                                                    }
-//                                                                //
-//                                                                //                                                                    [self prepareReturn:nil];
-//                                                                //
-//                                                                //                                                                    [self.navigationController popViewControllerAnimated:true];
-//                                                                //
-//                                                                //                                                                    [appDelegate printPdf:pdf_url];
-//                                                                ////                                                                    if(self.printPdfCallback)
-//                                                                ////                                                                        self.printPdfCallback(pdf_url);
-//                                                                //                                                                }
-//                                                                //                                                                else
-//                                                                {
-//                                                                    if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
-//                                                                    {
-//                                                                        //bbb
-//                                                                        [((MainViewController*)appDelegate.main_vc) Loginout:false];
-//                                                                    }
-//                                                                    [self prepareReturn:nil];
-//
-//                                                                    [self.navigationController popToRootViewControllerAnimated:true];
-//
-//                                                                    if(pdf_url.length>0)
-//                                                                    {
-//
-//                                                                        [alert dismissWithClickedButtonIndex:0 animated:FALSE];
-//                                                                        [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
-//                                                                        //  [appDelegate printPdf:pdf_url];
-//
-//                                                                    }
-//                                                                }
-//
-//                                                            }
-//                                                            else
-//                                                            {
-//                                                                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
-//                                                            }
-//
-//
-//
-//
-//                                                        });
-//                                                    });
-//                                                }
-//                                                else
-//                                                {
-//                                                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Retain models", nil) message:NSLocalizedString(@"There are some models left in cart,do you want to keep them?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
-//
-//
-//                                                    alert.tag = KEEP_TAIL;
-//
-//
-//                                                    self.upparams = upparams;
-//
-//                                                    [alert show];
-//                                                }
-//
-//                                            }
-//                                            else
-//                                            { //USER_ROLE_CUSTOMER
-//
-//                                                //            if(self.have_tail)
-//                                                //            [upparams setValue:@"true" forKey:@"isHold"];
-//                                                //            else
-//                                                //                [upparams setValue:@"false" forKey:@"isHold"];
-//                                                UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
-//
-//                                                [upparams setValue:@"true" forKey:@"isHold"];
-//                                                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//
-//                                                    NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
-//
-//                                                    dispatch_async(dispatch_get_main_queue(), ^{
-//
-//                                                        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-//
-//                                                        if([[editor_json valueForKey:@"result"] intValue]==2)
-//                                                        {
-//                                                            //       NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-//
-//
-//                                                            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//                                                            // appDelegate.customerInfo = customerInfo;
-//
-//                                                            //                                                            NSString* orderCode = [editor_json valueForKey:@"orderCode"];
-//                                                            //                                                            appDelegate.order_code = orderCode;
-//                                                            //                                                            appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
-//                                                            [appDelegate closeOrder];
-//                                                            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-//
-//                                                            NSString* title=nil;
-//                                                            NSString* msg=nil;
-//#ifdef OFFLINE_MODE
-//                                                            if(appDelegate.offline_mode)
-//                                                            {
-//                                                                title=TITLE_OFFLINE_SUBMIT;
-//                                                                msg=MSG_OFFLINE_SUBMIT;
-//                                                            }
-//                                                            else
-//#endif
-//                                                            {
-//                                                                title=@"Order submitted sucessfully";
-//                                                                msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
-//                                                            }
-//
-//                                                            UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-//
-//                                                            [alert show];
-//                                                            //    //     self.labelContact.text=appDelegate.contact_name;
-//                                                            //
-//                                                            //    NSDictionary * customerinfo = appDelegate.customerInfo;
-//                                                            [self prepareReturn:nil];
-//                                                            [self.navigationController popToRootViewControllerAnimated:true];
-//                                                            //                                    [self.navigationController dismissViewControllerAnimated:true completion:^{
-//                                                            //
-//                                                            //
-//                                                            //                                        ;
-//                                                            //                                    }];
-//
-//                                                        }
-//                                                        else
-//                                                        {
-//                                                            [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
-//                                                        }
-//
-//
-//
-//
-//                                                    });
-//                                                });
-//
-//                                            }
-//
-//
-//
-//                                        }];
-//
-//            UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
-//                //DebugLog(@"Cancel");
-//
-//
-//            }];
-//            [alertControl addAction:actionOne];
-//
-//            [alertControl addAction:alertthree];
-//
-//            //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
-//
-//
-//
-//
-//            [self presentViewController:alertControl animated:YES completion:nil];
-//
-//
-//
-//        }
-//        else
-//        {
-//        commit_order:
-//
-//            {
-//                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//
-//                if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
-//                {
-//
-//                    if(/*!self.have_tail*/ true)
-//                    {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
-//                        [upparams setValue:@"false" forKey:@"isHold"];
-//                        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//
-//                            NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
-//
-//                            dispatch_async(dispatch_get_main_queue(), ^{
-//                                [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-//
-//
-//                                if([[editor_json valueForKey:@"result"] intValue]==2)
-//                                {
-//
-//                                    //debug bbb
-//                                    //    NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-//
-//
-//                                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//                                    NSString* company= appDelegate.customerInfo[@"customer_name"];
-//                                    NSString* send_to =appDelegate.customerInfo[@"customer_email"];
-//                                    //                                appDelegate.customerInfo = customerInfo;
-//                                    //                                appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
-//                                    //                                appDelegate.order_code = nil;
-//                                    [appDelegate closeOrder];
-//                                    [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-//
-//                                    NSString* title=nil;
-//                                    NSString* msg=nil;
-//#ifdef OFFLINE_MODE
-//                                    if(appDelegate.offline_mode)
-//                                    {
-//                                        title=TITLE_OFFLINE_SUBMIT;
-//                                        msg=MSG_OFFLINE_SUBMIT;
-//                                    }
-//                                    else
-//#endif
-//                                    {
-//                                        title=@"Order submitted sucessfully";
-//                                        msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
-//                                    }
-//
-//                                    UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-//
-//                                    [alert show];
-//
-//                                    NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
-//                                    NSString* email_content =[editor_json valueForKey:@"email_content"];
-//                                    NSString* soid=[editor_json valueForKey:@"so#"];
-//                                    //                                    if(pdf_url.length>0)
-//                                    //                                    {
-//                                    //
-//                                    //                                        [alert dismissWithClickedButtonIndex:0 animated:FALSE];
-//                                    ////                                        [self downloadpdf:pdf_url];
-//                                    //
-//                                    //
-//                                    //                                        if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
-//                                    //                                        {
-//                                    //                                            //bbb
-//                                    //                                            [((MainViewController*)appDelegate.main_vc) Loginout:false];
-//                                    //                                        }
-//                                    //
-//                                    //                                        [self prepareReturn:nil];
-//                                    //
-//                                    //                                        [self.navigationController popViewControllerAnimated:true];
-//                                    //
-//                                    //                                        [appDelegate printPdf:pdf_url];
-//                                    //
-//                                    ////                                        if(self.printPdfCallback)
-//                                    ////                                            self.printPdfCallback(pdf_url);
-//                                    //                                    }
-//                                    //                                    else
-//                                    {
-//                                        if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
-//                                        {
-//                                            //bbb
-//                                            [((MainViewController*)appDelegate.main_vc) Loginout:false];
-//                                        }
-//                                        [self prepareReturn:nil];
-//
-//                                        [self.navigationController popToRootViewControllerAnimated:true];
-//
-//
-//                                        if(pdf_url.length>0)
-//                                        {
-//
-//                                            [alert dismissWithClickedButtonIndex:0 animated:FALSE];
-//
-//                                            [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
-//
-//
-//                                        }
-//
-//
-//                                    }
-//                                    //    //     self.labelContact.text=appDelegate.contact_name;
-//                                    //
-//                                    //    NSDictionary * customerinfo = appDelegate.customerInfo;
-//
-//
-//
-//
-//
-//
-//                                }
-//                                else
-//                                {
-//                                    [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
-//                                }
-//
-//
-//
-//
-//                            });
-//                        });
-//                    }
-//                    else
-//                    {
-//                        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Retain models", nil) message:NSLocalizedString(@"There are some models left in cart,do you want to keep them?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
-//
-//
-//                        alert.tag = KEEP_TAIL;
-//
-//
-//                        self.upparams = upparams;
-//
-//                        [alert show];
-//                    }
-//
-//                }
-//                else
-//                { //USER_ROLE_CUSTOMER
-//
-//                    //            if(self.have_tail)
-//                    //            [upparams setValue:@"true" forKey:@"isHold"];
-//                    //            else
-//                    //                [upparams setValue:@"false" forKey:@"isHold"];
-//                    UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
-//
-//                    [upparams setValue:@"true" forKey:@"isHold"];
-//                    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//
-//                        NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
-//
-//                        dispatch_async(dispatch_get_main_queue(), ^{
-//
-//                            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-//
-//                            if([[editor_json valueForKey:@"result"] intValue]==2)
-//                            {
-//                                //       NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-//
-//
-//                                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//                                // appDelegate.customerInfo = customerInfo;
-//
-//                                //                                NSString* orderCode = [editor_json valueForKey:@"orderCode"];
-//                                //                                appDelegate.order_code = orderCode;
-//                                //                                appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
-//                                [appDelegate closeOrder];
-//                                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-//
-//                                NSString* title=nil;
-//                                NSString* msg=nil;
-//#ifdef OFFLINE_MODE
-//                                if(appDelegate.offline_mode)
-//                                {
-//                                    title=TITLE_OFFLINE_SUBMIT;
-//                                    msg=MSG_OFFLINE_SUBMIT;
-//                                }
-//                                else
-//#endif
-//                                {
-//                                    title=@"Order submitted sucessfully";
-//                                    msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
-//                                }
-//
-//
-//                                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-//
-//                                [alert show];
-//                                //    //     self.labelContact.text=appDelegate.contact_name;
-//                                //
-//                                //    NSDictionary * customerinfo = appDelegate.customerInfo;
-//                                [self prepareReturn:nil];
-//                                //                            [self.navigationController dismissViewControllerAnimated:true completion:^{
-//                                //
-//                                //
-//                                //                                ;
-//                                //                            }];
-//                                [self.navigationController popToRootViewControllerAnimated:true];
-//
-//                            }
-//                            else
-//                            {
-//                                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
-//                            }
-//
-//
-//
-//
-//                        });
-//                    });
-//
-//                }
-//            }
-//
-//        }
-//
-        
-    }
-    
 
-    else if(alertView.tag == CLOSE_ACTION)
+
+    if(alertView.tag == CLOSE_ACTION)
     {
         if (buttonIndex == 1) {
             // back edit order
@@ -2704,12 +1995,7 @@
             
             
             
-#ifdef RA_NOTIFICATION
-            [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
 
-#else
-            [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-#endif
             [((MainViewController*)appDelegate.main_vc) switchToOrder];
 
         }