|
|
@@ -11,6 +11,8 @@
|
|
|
#import "MainViewController.h"
|
|
|
#import "Singleton.h"
|
|
|
#import "config.h"
|
|
|
+#import "CustomIOSAlertView.h"
|
|
|
+
|
|
|
|
|
|
#define SUBMIT_CONFIRM 123
|
|
|
#define KEEP_TAIL 456
|
|
|
@@ -178,22 +180,690 @@
|
|
|
if(appDelegate.user_type == USER_ROLE_CUSTOMER) {
|
|
|
|
|
|
NSString *specialInstuction = [Singleton sharedInstance].specialInstruction;
|
|
|
- msg = [NSString stringWithFormat:@"Are you sure to submit order?\n1.Current Price Type is %@",[self currentPriceTypeName]];
|
|
|
+ msg = [NSString stringWithFormat:@"Are you sure to submit order?\n\n1. Current Price Type is %@",[self currentPriceTypeName]];
|
|
|
if (specialInstuction.length) {
|
|
|
- msg = [msg stringByAppendingFormat:@"\n2.Special Instruction is %@.",specialInstuction];
|
|
|
+ msg = [msg stringByAppendingFormat:@"\n2. Special Instruction: %@.",specialInstuction];
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Submit Confirm.", nil) message:NSLocalizedString(msg, nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
|
|
|
|
|
|
- alert.tag = SUBMIT_CONFIRM;
|
|
|
- [alert show];
|
|
|
|
|
|
+ CustomIOSAlertView *alertView = [[CustomIOSAlertView alloc] init];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // Add some custom content to the alert view
|
|
|
+ [alertView setContainerView:[self createDemoView:msg]];
|
|
|
+
|
|
|
+ // Modify the parameters
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [alertView setButtonTitles:[NSMutableArray arrayWithObjects:@"NO",@"YES", nil]];
|
|
|
+ //[alertView setDelegate:self];
|
|
|
+
|
|
|
+ // You may use a Block, rather than a delegate.
|
|
|
+ [alertView setOnButtonTouchUpInside:^(CustomIOSAlertView *alertView, int buttonIndex) {
|
|
|
+ // DebugLog(@"Block: Button at position %d is clicked on alertView %d.", buttonIndex, (int)[alertView tag]);
|
|
|
+ if(buttonIndex==0)
|
|
|
+ [alertView close];
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // 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"] = 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:@"Submit Order"];
|
|
|
+ [upparams setValue:@"false" forKey:@"isHold"];
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+
|
|
|
+ NSDictionary* editor_json = [iSalesNetwork 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;
|
|
|
+ if(appDelegate.offline_mode)
|
|
|
+ {
|
|
|
+ title=TITLE_OFFLINE_SUBMIT;
|
|
|
+ msg=MSG_OFFLINE_SUBMIT;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ title=@"Submit successful.";
|
|
|
+ msg=[NSString stringWithFormat:@"SO#: %@",[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:@"Submit Order" 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:@"Submit Order"];
|
|
|
+
|
|
|
+ [upparams setValue:@"true" forKey:@"isHold"];
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+
|
|
|
+ NSDictionary* editor_json = [iSalesNetwork 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;
|
|
|
+ if(appDelegate.offline_mode)
|
|
|
+ {
|
|
|
+ title=TITLE_OFFLINE_SUBMIT;
|
|
|
+ msg=MSG_OFFLINE_SUBMIT;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ title=@"Submit successful.";
|
|
|
+ msg=[NSString stringWithFormat:@"SO#: %@",[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:@"Submit Order" 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:@"Submit Order"];
|
|
|
+ [upparams setValue:@"false" forKey:@"isHold"];
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+
|
|
|
+ NSDictionary* editor_json = [iSalesNetwork 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;
|
|
|
+ if(appDelegate.offline_mode)
|
|
|
+ {
|
|
|
+ title=TITLE_OFFLINE_SUBMIT;
|
|
|
+ msg=MSG_OFFLINE_SUBMIT;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ title=@"Submit successful.";
|
|
|
+ msg=[NSString stringWithFormat:@"SO#: %@",[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:@"Submit Order" 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:@"Submit Order"];
|
|
|
+
|
|
|
+ [upparams setValue:@"true" forKey:@"isHold"];
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+
|
|
|
+ NSDictionary* editor_json = [iSalesNetwork 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;
|
|
|
+ if(appDelegate.offline_mode)
|
|
|
+ {
|
|
|
+ title=TITLE_OFFLINE_SUBMIT;
|
|
|
+ msg=MSG_OFFLINE_SUBMIT;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ title=@"Submit successful.";
|
|
|
+ msg=[NSString stringWithFormat:@"SO#: %@",[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:@"Submit Order" controller:self] ;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }];
|
|
|
+
|
|
|
+ // [alertView setUseMotionEffects:true];
|
|
|
+
|
|
|
+ // And launch the dialog
|
|
|
|
|
|
+ [alertView sizeToFit];
|
|
|
+ [alertView show];
|
|
|
|
|
|
+// UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Submit Confirm.", nil) message:NSLocalizedString(msg, nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
|
|
|
+//
|
|
|
+// alert.tag = SUBMIT_CONFIRM;
|
|
|
+// [alert show];
|
|
|
+//
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+- (UIView *)createDemoView:(NSString*) msg
|
|
|
+{
|
|
|
+ UIView *demoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 290, 200)];
|
|
|
+
|
|
|
+ // UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 270, 180)];
|
|
|
+ // [imageView setImage:[UIImage imageNamed:@"demo"]];
|
|
|
+
|
|
|
+ UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 270, 10)];
|
|
|
+ titleLabel.font = [UIFont boldSystemFontOfSize:20];
|
|
|
+ titleLabel.text=@"Submit Confirm.";
|
|
|
+ titleLabel.numberOfLines = 0;
|
|
|
+ titleLabel.lineBreakMode =NSLineBreakByWordWrapping;
|
|
|
+ // titleLabel.textAlignment = NSTextAlignmentRight;
|
|
|
+ titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
+ CGSize constraintkey = CGSizeMake(270, 20000.0f);//key label width is 40% cell width;
|
|
|
+ CGSize sizetitle = [titleLabel.text=@"Submit Confirm." sizeWithFont:[UIFont systemFontOfSize:20.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
|
|
|
+
|
|
|
+ //[titleLabel sizeToFit];
|
|
|
+ // titleLabel.center.x = demoView.center.x;
|
|
|
+ titleLabel.frame = CGRectMake(10, 10, 270, sizetitle.height);
|
|
|
+ [demoView addSubview:titleLabel];
|
|
|
+
|
|
|
+ UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 260, 10)];
|
|
|
+ lineLabel.font = [UIFont systemFontOfSize:17];
|
|
|
+ lineLabel.text=msg;
|
|
|
+ lineLabel.numberOfLines = 0;
|
|
|
+ lineLabel.lineBreakMode =NSLineBreakByWordWrapping;
|
|
|
+
|
|
|
+ CGSize sizemsg = [msg sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
|
|
|
+
|
|
|
+ lineLabel.frame = CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 260, sizemsg.height);
|
|
|
+ //[lineLabel sizeToFit];
|
|
|
+
|
|
|
+ [demoView addSubview:lineLabel];
|
|
|
+ demoView.frame = CGRectMake(0, 0, 290, lineLabel.frame.origin.y+lineLabel.frame.size.height+25);
|
|
|
+ return demoView;
|
|
|
}
|
|
|
- (void)onCloseClick:(UIButton *)sender {
|
|
|
|