|
|
@@ -12,6 +12,8 @@
|
|
|
#import "Singleton.h"
|
|
|
#import "config.h"
|
|
|
#import "CustomIOSAlertView.h"
|
|
|
+#import "AddressEditorViewController.h"
|
|
|
+#import "CreditCardEditorViewController.h"
|
|
|
|
|
|
|
|
|
#define SUBMIT_CONFIRM 123
|
|
|
@@ -2865,4 +2867,361 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+#pragma mark - multi_action sub action clicked
|
|
|
+
|
|
|
+- (void)MActionClicked:(UIButton *)sender {
|
|
|
+
|
|
|
+ UITableViewCell *cell = (UITableViewCell *) sender.superview.superview;
|
|
|
+ NSIndexPath * indexPath = [self.editorTable indexPathForCell:cell];
|
|
|
+ int refresh =0;
|
|
|
+ NSMutableDictionary* section_json=nil;
|
|
|
+
|
|
|
+ NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
|
|
|
+ NSString* subid=[item_json valueForKey:@"subid"];
|
|
|
+ NSString* refresh_trigger = [item_json valueForKey:@"name"];
|
|
|
+ NSDictionary* sub_action = [item_json objectForKey:[NSString stringWithFormat:@"item_%ld",(long)sender.tag]];
|
|
|
+ NSString* type = [sub_action valueForKey:@"type"];
|
|
|
+ if([type isEqualToString:@"pull"])
|
|
|
+ {
|
|
|
+
|
|
|
+ [self.lastedit endEditing:true];
|
|
|
+
|
|
|
+ refresh = [[sub_action valueForKey:@"refresh"] intValue];
|
|
|
+ NSDictionary* keymap= [sub_action objectForKey:@"key_map"];
|
|
|
+
|
|
|
+ NSMutableDictionary* value=[self create_value_map:keymap];
|
|
|
+
|
|
|
+ if(subid==nil)
|
|
|
+ {
|
|
|
+ NSDictionary* jsonmap=[sub_action valueForKey:@"key_map"];
|
|
|
+ section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
|
|
|
+ int icount=[[section_json valueForKey:@"count"] intValue];
|
|
|
+ for (int ic=0;ic<icount;ic++)
|
|
|
+ {
|
|
|
+ NSMutableDictionary* modify_item= [[section_json objectForKey:[NSString stringWithFormat:@"item_%d",ic ]] mutableCopy];
|
|
|
+
|
|
|
+
|
|
|
+ NSString* mapto = [modify_item valueForKey:@"name"];
|
|
|
+ if(mapto.length==0)
|
|
|
+ continue;
|
|
|
+ NSString* valuefrom= [jsonmap valueForKey:[modify_item valueForKey:@"name"]];
|
|
|
+ if(valuefrom==nil)
|
|
|
+ continue;
|
|
|
+ NSString* valuestr=[value valueForKey:valuefrom];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // valuestr = [self getValue:valuefrom];
|
|
|
+ if(true)
|
|
|
+ {
|
|
|
+ if(valuestr.length>0)
|
|
|
+ [modify_item setValue:valuestr forKey:@"value"];
|
|
|
+ else
|
|
|
+ [modify_item setValue:@"" forKey:@"value"];
|
|
|
+ [modify_item setValue:@"true" forKey:@"dirty"];
|
|
|
+ [section_json setObject:modify_item forKey:[NSString stringWithFormat:@"item_%d",ic ]];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ NSArray* idarr=[subid componentsSeparatedByString:@"_"];
|
|
|
+ int section = [(NSString*)idarr[0] intValue];
|
|
|
+ int item=[(NSString*)idarr[1] intValue];
|
|
|
+ NSDictionary* jsonmap=[sub_action valueForKey:@"key_map"];
|
|
|
+
|
|
|
+ section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d", section]] mutableCopy];
|
|
|
+ NSMutableDictionary * olditem=[[section_json objectForKey:[NSString stringWithFormat:@"item_%d",item ]] mutableCopy];
|
|
|
+
|
|
|
+ NSString* control_type = [olditem valueForKey:@"control"];
|
|
|
+ if([control_type isEqualToString:@"switch"])
|
|
|
+ olditem= [self fill_switch_subitem:olditem subid:nil source:value mapping:jsonmap ];
|
|
|
+ else if([control_type isEqualToString:@"enum"])
|
|
|
+ {
|
|
|
+ olditem= [self fill_enum_subitem:olditem subid:nil source:value mapping:jsonmap ];
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ [RAUtils alert_view:@"" title:@"not impl"];
|
|
|
+ }
|
|
|
+
|
|
|
+ [olditem setValue:@"true" forKey:@"dirty"];
|
|
|
+ [section_json setObject:olditem forKey:[NSString stringWithFormat:@"item_%d",item ]];
|
|
|
+
|
|
|
+ }
|
|
|
+ [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
|
|
|
+ self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
|
|
|
+
|
|
|
+
|
|
|
+ if(refresh==1)
|
|
|
+ {
|
|
|
+
|
|
|
+ // if(restore_json!=nil)
|
|
|
+ // {
|
|
|
+ // int rc=[[restore_json valueForKey:@"count"] intValue];
|
|
|
+ // for(int ir=0;ir<rc;ir++)
|
|
|
+ // {
|
|
|
+ // NSString* name = [restore_json valueForKey:[NSString stringWithFormat:@"item_%d",ir]];
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
|
|
|
+ // for(int i=0;i<section_count;i++)
|
|
|
+ // {
|
|
|
+ // NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
|
|
|
+ // // NSMutableDictionary * to_sectionjson = [[to objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
|
|
|
+ // int item_count = [[sectionjson valueForKey:@"count"] intValue];
|
|
|
+ // for(int j=0;j<item_count;j++)
|
|
|
+ // {
|
|
|
+ // NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
|
|
|
+ // // NSMutableDictionary * to_itemjson=[[to_sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
|
|
|
+ //
|
|
|
+ // if([[itemjson valueForKey:@"name"] isEqualToString:name])
|
|
|
+ // {
|
|
|
+ // [itemjson removeObjectForKey:@"dirty"];
|
|
|
+ // [sectionjson setObject:itemjson forKey:[NSString stringWithFormat:@"item_%d",j ]];
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // [self.content_data_download setObject:sectionjson forKey:[NSString stringWithFormat:@"section_%d",i ]];
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ [self refresh:refresh_trigger] ;
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ // DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
|
|
|
+ [self.editorTable reloadData ];
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+ NSDictionary * item_json = sub_action;
|
|
|
+ NSString* value = [item_json valueForKey:@"value"];
|
|
|
+ if([value isEqualToString:@"new_addr"])
|
|
|
+ {
|
|
|
+ AddressEditorViewController * addressVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"AddressEditorViewController"];
|
|
|
+
|
|
|
+ addressVC.url_type = URL_REMOTE;
|
|
|
+
|
|
|
+ addressVC.request_url=URL_ADDRESS_EDOTOR;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
|
|
|
+ // NSString * string = [checked componentsJoinedByString:@","];
|
|
|
+ // [params setValue:string forKey:@"cart2Checkbox"];
|
|
|
+
|
|
|
+
|
|
|
+ params[@"is_subaction"]=@"true";
|
|
|
+ params[@"subaction_tag"]= [NSString stringWithFormat:@"%ld",(long)sender.tag];
|
|
|
+ addressVC.params = params;
|
|
|
+
|
|
|
+
|
|
|
+ addressVC.delegate = self;
|
|
|
+
|
|
|
+ addressVC.from = indexPath;
|
|
|
+ // orderinfoVC.params = params;
|
|
|
+
|
|
|
+ [self.navigationController pushViewController:addressVC animated:true];
|
|
|
+
|
|
|
+ }else if([value isEqualToString:@"credit_card"])
|
|
|
+ {
|
|
|
+ CreditCardEditorViewController * cardVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"CreditCardEditorViewController"];
|
|
|
+
|
|
|
+
|
|
|
+ NSDictionary *data = [item_json objectForKey:@"data"];
|
|
|
+
|
|
|
+ if(data!=nil)
|
|
|
+ {
|
|
|
+
|
|
|
+ cardVC.content_data_download = [data mutableCopy];
|
|
|
+ cardVC.url_type = URL_NONE;
|
|
|
+
|
|
|
+ cardVC.request_url=nil;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cardVC.url_type = URL_REMOTE;
|
|
|
+
|
|
|
+ cardVC.request_url=URL_CREDITCARD_EDOTOR;
|
|
|
+ }
|
|
|
+ NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
|
|
|
+
|
|
|
+ params[@"orderCode"]=appDelegate.order_code;
|
|
|
+
|
|
|
+ params[@"is_subaction"]=@"true";
|
|
|
+ params[@"subaction_tag"]= [NSString stringWithFormat:@"%ld",(long)sender.tag];
|
|
|
+ cardVC.params = params;
|
|
|
+
|
|
|
+ cardVC.delegate = self;
|
|
|
+
|
|
|
+ cardVC.from = indexPath;
|
|
|
+
|
|
|
+
|
|
|
+ // orderinfoVC.params = params;
|
|
|
+
|
|
|
+ [self.navigationController pushViewController:cardVC animated:true];
|
|
|
+
|
|
|
+ }
|
|
|
+ else if([value isEqualToString:@"Sales_Order_Freight_Bill_To"])
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
|
|
|
+ cvc.showNavibar = true;
|
|
|
+ cvc.contact_type = value;
|
|
|
+ cvc.is_subaction = @"true";
|
|
|
+ cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
|
|
|
+
|
|
|
+
|
|
|
+ cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
|
|
|
+
|
|
|
+ [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
|
|
|
+
|
|
|
+ //
|
|
|
+ // if(self.returnValue)
|
|
|
+ // self.returnValue(value);
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [self.navigationController pushViewController:cvc animated:true];
|
|
|
+
|
|
|
+ }
|
|
|
+ else if([value isEqualToString:@"Sales_Order_Ship_From"])
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
|
|
|
+ cvc.showNavibar = true;
|
|
|
+ cvc.contact_type = value;
|
|
|
+ cvc.is_subaction = @"true";
|
|
|
+ cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
|
|
|
+
|
|
|
+ cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
|
|
|
+
|
|
|
+ [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
|
|
|
+
|
|
|
+ //
|
|
|
+ // if(self.returnValue)
|
|
|
+ // self.returnValue(value);
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [self.navigationController pushViewController:cvc animated:true];
|
|
|
+
|
|
|
+ }
|
|
|
+ else if([value isEqualToString:@"Sales_Order_Customer"])
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
|
|
|
+ cvc.is_subaction = @"true";
|
|
|
+ cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
|
|
|
+ cvc.showNavibar = true;
|
|
|
+ cvc.contact_type = value;
|
|
|
+ __weak typeof(self) weakself = self;
|
|
|
+ cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
|
|
|
+
|
|
|
+ [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
|
|
|
+
|
|
|
+ //
|
|
|
+ // if(self.returnValue)
|
|
|
+ // self.returnValue(value);
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [self.navigationController pushViewController:cvc animated:true];
|
|
|
+
|
|
|
+ }
|
|
|
+ else if([value isEqualToString:@"Sales_Order_Merchandise_Bill_To"])
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
|
|
|
+ cvc.showNavibar = true;
|
|
|
+ cvc.contact_type = value;
|
|
|
+ cvc.is_subaction = @"true";
|
|
|
+ cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
|
|
|
+ __weak typeof(self) weakself = self;
|
|
|
+ cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
|
|
|
+
|
|
|
+ [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
|
|
|
+
|
|
|
+ //
|
|
|
+ // if(self.returnValue)
|
|
|
+ // self.returnValue(value);
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [self.navigationController pushViewController:cvc animated:true];
|
|
|
+
|
|
|
+ }
|
|
|
+ else if([value isEqualToString:@"Contact_Return_To"])
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
|
|
|
+ cvc.is_subaction = @"true";
|
|
|
+ cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
|
|
|
+ cvc.showNavibar = true;
|
|
|
+ cvc.contact_type = value;
|
|
|
+ __weak typeof(self) weakself = self;
|
|
|
+ cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
|
|
|
+
|
|
|
+ [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
|
|
|
+
|
|
|
+ //
|
|
|
+ // if(self.returnValue)
|
|
|
+ // self.returnValue(value);
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [self.navigationController pushViewController:cvc animated:true];
|
|
|
+
|
|
|
+ }
|
|
|
+ else if([value isEqualToString:@"Sales_Order_Ship_To"])
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
|
|
|
+ cvc.is_subaction = @"true";
|
|
|
+ cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
|
|
|
+ cvc.showNavibar = true;
|
|
|
+ cvc.contact_type = value;
|
|
|
+ __weak typeof(self) weakself = self;
|
|
|
+ cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
|
|
|
+
|
|
|
+ [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
|
|
|
+
|
|
|
+ //
|
|
|
+ // if(self.returnValue)
|
|
|
+ // self.returnValue(value);
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [self.navigationController pushViewController:cvc animated:true];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
@end
|