|
|
@@ -7,6 +7,7 @@
|
|
|
|
|
|
#import "TFEditorViewController.h"
|
|
|
#import "config.h"
|
|
|
+#import "RAUtils.h"
|
|
|
|
|
|
@interface TFEditorViewController ()
|
|
|
|
|
|
@@ -53,7 +54,12 @@
|
|
|
- (void)menuItemClick:(id)sender {
|
|
|
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
|
|
|
|
|
|
+ [self.lastedit endEditing:true];
|
|
|
+ [self.lasttextview endEditing:true];
|
|
|
|
|
|
+
|
|
|
+ NSMutableDictionary* upparams = [self check_cancommit:false];
|
|
|
+
|
|
|
for(int i=0;i<self.injectMenu.count;i++)
|
|
|
{
|
|
|
NSDictionary* item = self.injectMenu[i];
|
|
|
@@ -62,13 +68,137 @@
|
|
|
|
|
|
UIAlertAction *injectAction = [UIAlertAction actionWithTitle:NSLocalizedString(item[@"title"], nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
|
- if([item[@"name"] isEqualToString:@"save_detail"])
|
|
|
+ if([item[@"name"] isEqualToString:@"save"])
|
|
|
{
|
|
|
+ NSMutableDictionary* params= item[@"params"];
|
|
|
+ [upparams addEntriesFromDictionary:params];
|
|
|
+
|
|
|
+ [RADataProvider SaveEditor:upparams completionHandler:^(NSMutableDictionary *result) {
|
|
|
+ int ret=[result[@"result"] intValue];
|
|
|
+
|
|
|
+ if (ret==RESULT_TRUE)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ [RAUtils message_alert:@"Successful" title:@"Save" controller:self action_handler:^(UIAlertAction * _Nonnull action) {
|
|
|
+ [self.navigationController popViewControllerAnimated:YES];;
|
|
|
+ } completion:^{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }];
|
|
|
+ // NSUser
|
|
|
+
|
|
|
+// [self.navigationController popViewControllerAnimated:true];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:RA_NOTIFICATION_LOGIN_FAILED object:nil];
|
|
|
+ // int a = RESULT_NET_NOTAVAILABLE;
|
|
|
+ NSString* message = nil;
|
|
|
+ switch (ret) {
|
|
|
+ case RESULT_NET_NOTAVAILABLE:
|
|
|
+ message = NSLocalizedString(@"net_not_available", nil);
|
|
|
+ break;
|
|
|
+ case RESULT_NET_ERROR:
|
|
|
+ message = NSLocalizedString(@"net_error", nil);
|
|
|
+ break;
|
|
|
+ case RESULT_FALSE:
|
|
|
+ message = NSLocalizedString(@"auth_error", nil);
|
|
|
+ break;
|
|
|
+ case RESULT_VER_LOW:
|
|
|
+ message = NSLocalizedString(@"ver_low", nil);
|
|
|
+ break;
|
|
|
+ case RESULT_FAILED_WITH_MESSAGE:
|
|
|
+ message = result[@"err_msg"];
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ message=[NSString stringWithFormat:@"Failed to login code %d",ret];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"alert_title_error", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+ UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"ok", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ [alertVC addAction:action];
|
|
|
+
|
|
|
+ [self presentViewController:alertVC animated:YES completion:nil];
|
|
|
+ }
|
|
|
+
|
|
|
+ }];
|
|
|
|
|
|
}else
|
|
|
- if([item[@"name"] isEqualToString:@"save_detail&submit"])
|
|
|
+ if([item[@"name"] isEqualToString:@"save&submit"])
|
|
|
{
|
|
|
+ NSMutableDictionary* params= item[@"params"];
|
|
|
+ [upparams addEntriesFromDictionary:params];
|
|
|
|
|
|
+ [RADataProvider SaveEditor:upparams completionHandler:^(NSMutableDictionary *result) {
|
|
|
+ int ret=[result[@"result"] intValue];
|
|
|
+
|
|
|
+ if (ret==RESULT_TRUE)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ [RAUtils message_alert:@"Successful" title:@"Save" controller:self action_handler:^(UIAlertAction * _Nonnull action) {
|
|
|
+ [self.navigationController popToRootViewControllerAnimated:YES];;
|
|
|
+ } completion:^{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }];
|
|
|
+ // NSUser
|
|
|
+
|
|
|
+ // [self.navigationController popViewControllerAnimated:true];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:RA_NOTIFICATION_LOGIN_FAILED object:nil];
|
|
|
+ // int a = RESULT_NET_NOTAVAILABLE;
|
|
|
+ NSString* message = nil;
|
|
|
+ switch (ret) {
|
|
|
+ case RESULT_NET_NOTAVAILABLE:
|
|
|
+ message = NSLocalizedString(@"net_not_available", nil);
|
|
|
+ break;
|
|
|
+ case RESULT_NET_ERROR:
|
|
|
+ message = NSLocalizedString(@"net_error", nil);
|
|
|
+ break;
|
|
|
+ case RESULT_FALSE:
|
|
|
+ message = NSLocalizedString(@"auth_error", nil);
|
|
|
+ break;
|
|
|
+ case RESULT_VER_LOW:
|
|
|
+ message = NSLocalizedString(@"ver_low", nil);
|
|
|
+ break;
|
|
|
+ case RESULT_FAILED_WITH_MESSAGE:
|
|
|
+ message = result[@"err_msg"];
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ message=[NSString stringWithFormat:@"Failed to login code %d",ret];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"alert_title_error", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+ UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"ok", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ [alertVC addAction:action];
|
|
|
+
|
|
|
+ [self presentViewController:alertVC animated:YES completion:nil];
|
|
|
+ }
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
if([item[@"name"] isEqualToString:@"save_container"])
|
|
|
@@ -97,7 +227,182 @@
|
|
|
|
|
|
[self presentViewController:alertVC animated:YES completion:nil];
|
|
|
}
|
|
|
-
|
|
|
+-(void) commonAction:(NSString *)value index:(NSIndexPath*) indexPath data:(NSMutableDictionary*) item_json
|
|
|
+{
|
|
|
+// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+ if([value isEqualToString:@"new_addr"])
|
|
|
+ {
|
|
|
+// AddressEditorViewController * addressVC = [[AddressEditorViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
|
|
|
+//
|
|
|
+// addressVC.url_type = URL_REMOTE;
|
|
|
+//
|
|
|
+// addressVC.request_url=URL_ADDRESS_EDOTOR;
|
|
|
+//
|
|
|
+//
|
|
|
+// NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
|
|
|
+//
|
|
|
+//
|
|
|
+// addressVC.params = params;
|
|
|
+//
|
|
|
+//
|
|
|
+// addressVC.delegate = self;
|
|
|
+//
|
|
|
+// addressVC.from = indexPath;
|
|
|
+// // orderinfoVC.params = params;
|
|
|
+//
|
|
|
+// [self.navigationController pushViewController:addressVC animated:true];
|
|
|
+
|
|
|
+ }else if([value isEqualToString:@"credit_card"])
|
|
|
+ {
|
|
|
+// CreditCardEditorViewController * cardVC = [[CreditCardEditorViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
|
|
|
+//
|
|
|
+//
|
|
|
+// NSDictionary *data = [item_json objectForKey:@"data"];
|
|
|
+//
|
|
|
+// if(data!=nil)
|
|
|
+// {
|
|
|
+//
|
|
|
+// cardVC.content_data_download = [data mutableCopy];
|
|
|
+// cardVC.url_type = URL_NONE;
|
|
|
+//
|
|
|
+// cardVC.request_url=nil;
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// cardVC.url_type = URL_REMOTE;
|
|
|
+//
|
|
|
+// cardVC.request_url=URL_CREDITCARD_EDOTOR;
|
|
|
+// }
|
|
|
+// NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
|
|
|
+//
|
|
|
+// params[@"orderCode"]=appDelegate.order_code;
|
|
|
+// cardVC.params = params;
|
|
|
+//
|
|
|
+// cardVC.delegate = self;
|
|
|
+//
|
|
|
+// cardVC.from = indexPath;
|
|
|
+//
|
|
|
+//
|
|
|
+// [self.navigationController pushViewController:cardVC animated:true];
|
|
|
+
|
|
|
+ }
|
|
|
+ else if([value isEqualToString:@"Sales_Order_Freight_Bill_To"])
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+// ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
|
|
|
+// cvc.showNavibar = true;
|
|
|
+// cvc.contact_type = value;
|
|
|
+// __weak typeof(self) weakself = self;
|
|
|
+// cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
|
|
|
+//
|
|
|
+// [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
|
|
|
+//
|
|
|
+// };
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// [self.navigationController pushViewController:cvc animated:true];
|
|
|
+
|
|
|
+ }
|
|
|
+ else if([value isEqualToString:@"Sales_Order_Ship_From"])
|
|
|
+ {
|
|
|
+
|
|
|
+//
|
|
|
+// ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
|
|
|
+// cvc.showNavibar = true;
|
|
|
+// cvc.contact_type = value;
|
|
|
+// __weak typeof(self) weakself = self;
|
|
|
+// cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
|
|
|
+//
|
|
|
+// [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
|
|
|
+//
|
|
|
+// };
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// [self.navigationController pushViewController:cvc animated:true];
|
|
|
+//
|
|
|
+ }
|
|
|
+ else if([value isEqualToString:@"Sales_Order_Customer"])
|
|
|
+ {
|
|
|
+
|
|
|
+//
|
|
|
+// ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
|
|
|
+//
|
|
|
+// cvc.contact_type = value;
|
|
|
+// cvc.showNavibar = true;
|
|
|
+// __weak typeof(self) weakself = self;
|
|
|
+// cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
|
|
|
+//
|
|
|
+// [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
|
|
|
+//
|
|
|
+// };
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// [self.navigationController pushViewController:cvc animated:true];
|
|
|
+
|
|
|
+ }
|
|
|
+ else if([value isEqualToString:@"Sales_Order_Merchandise_Bill_To"])
|
|
|
+ {
|
|
|
+
|
|
|
+//
|
|
|
+// ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
|
|
|
+// cvc.showNavibar = true;
|
|
|
+// cvc.contact_type = value;
|
|
|
+// __weak typeof(self) weakself = self;
|
|
|
+// cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
|
|
|
+//
|
|
|
+// [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
|
|
|
+//
|
|
|
+// };
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// [self.navigationController pushViewController:cvc animated:true];
|
|
|
+//
|
|
|
+ }
|
|
|
+ else if([value isEqualToString:@"Contact_Return_To"])
|
|
|
+ {
|
|
|
+
|
|
|
+//
|
|
|
+// ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
|
|
|
+// cvc.showNavibar = true;
|
|
|
+// cvc.contact_type = value;
|
|
|
+// __weak typeof(self) weakself = self;
|
|
|
+// cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
|
|
|
+//
|
|
|
+// [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
|
|
|
+//
|
|
|
+// };
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// [self.navigationController pushViewController:cvc animated:true];
|
|
|
+
|
|
|
+ }
|
|
|
+ else if([value isEqualToString:@"Sales_Order_Ship_To"])
|
|
|
+ {
|
|
|
+
|
|
|
+//
|
|
|
+// ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
|
|
|
+// cvc.showNavibar = true;
|
|
|
+// cvc.contact_type = value;
|
|
|
+// __weak typeof(self) weakself = self;
|
|
|
+// cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
|
|
|
+//
|
|
|
+// [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
|
|
|
+//
|
|
|
+// };
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// [self.navigationController pushViewController:cvc animated:true];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
/*
|
|
|
#pragma mark - Navigation
|
|
|
|