AddressEditorViewController.m 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. //
  2. // AddressEditorViewController.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 8/18/15.
  6. // Copyright (c) 2015 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "AddressEditorViewController.h"
  9. #import "iSalesNetwork.h"
  10. @interface AddressEditorViewController ()
  11. @end
  12. @implementation AddressEditorViewController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. self.editable = YES;
  16. UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  17. style:UIBarButtonItemStylePlain
  18. target:self
  19. action:@selector( onBackClick:)];
  20. // [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onBackClick:)];
  21. self.navigationItem.leftBarButtonItem = backButton;
  22. // UIBarButtonItem *closeButton =
  23. UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"save"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  24. style:UIBarButtonItemStylePlain
  25. target:self
  26. action:@selector(onSaveClick:)];
  27. self.navigationItem.rightBarButtonItem = saveButton;
  28. // Do any additional setup after loading the view.
  29. }
  30. - (void)didReceiveMemoryWarning {
  31. [super didReceiveMemoryWarning];
  32. // Dispose of any resources that can be recreated.
  33. }
  34. - (void)onBackClick:(UIButton *)sender {
  35. [self.navigationController popViewControllerAnimated:(false)];
  36. // [self.navigationController dismissViewControllerAnimated:true completion:^{
  37. // ;
  38. // }];
  39. }
  40. - (IBAction)onSaveClick:(id)sender {
  41. // add params check here.
  42. [self.lastedit endEditing:true];
  43. [self.lasttextview endEditing:true];
  44. // self.cancommit=true;
  45. // NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
  46. // //[upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
  47. // int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
  48. // for(int i=0;i<section_count;i++)
  49. // {
  50. //
  51. // NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
  52. // int item_count = [[sectionjson valueForKey:@"count"] intValue];
  53. // for(int j=0;j<item_count;j++)
  54. // {
  55. // NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
  56. // NSString* key = [itemjson valueForKey:@"name"];
  57. // if(key==nil || key.length==0)
  58. // continue;
  59. // if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
  60. // {
  61. // NSString* single_select = [itemjson valueForKey:@"single_select"];
  62. // if([single_select isEqualToString:@"true"])
  63. // {
  64. // NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
  65. // int count = [[cadejson valueForKey:@"count"] intValue];
  66. // bool setvalue = false;
  67. // for(int cc=0;cc<count;cc++)
  68. // {
  69. // NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
  70. // if([[valjson valueForKey:@"check"]intValue]==1)
  71. // {
  72. // [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
  73. // setvalue=true;
  74. // break;
  75. // }
  76. // }
  77. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
  78. // {
  79. // self.cancommit = false;
  80. // }
  81. // }
  82. // else
  83. // {
  84. // //not support multi select for now;
  85. // }
  86. // /*
  87. // upparams setValue:itemjson forKey:<#(NSString *)#>
  88. //
  89. // */
  90. // }
  91. // else
  92. // {
  93. // if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
  94. // [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
  95. // else
  96. // {
  97. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
  98. // self.cancommit = false;
  99. // }
  100. // }
  101. //
  102. // upparams= [self subitem_param:itemjson addto:upparams ];
  103. // }
  104. // }
  105. //
  106. //
  107. // if(self.cancommit==false)
  108. // {
  109. //// UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Some requried field is missing" message:@"Fields with * mark cannot be empty." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  110. //// // UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error!" message:@"User&Password can not be empty!" delegate:nil cancelButtonTitle:NSLocalizedString(@"ok", nil) , nil];
  111. //// [alert show];
  112. //
  113. //
  114. // [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
  115. //
  116. // self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
  117. //
  118. //
  119. // // DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
  120. //// [self.editorTable reloadData ];
  121. //
  122. // [self.editorTable reloadData];
  123. // return;
  124. //
  125. // }
  126. NSMutableDictionary* upparams = [self check_cancommit:true];
  127. if(self.cancommit==false)
  128. return;
  129. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  130. NSDictionary* editor_json = [iSalesNetwork create_Address:upparams];
  131. dispatch_async(dispatch_get_main_queue(), ^{
  132. if([[editor_json valueForKey:@"result"] intValue]==2)
  133. {
  134. // int result = [[editor_json valueForKey:@"result"] intValue];
  135. // if(result==2)
  136. {
  137. [self prepareReturn: nil];
  138. [self.navigationController popViewControllerAnimated:true];
  139. }
  140. }
  141. else
  142. {
  143. [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Create Address" controller:self] ;
  144. }
  145. });
  146. });
  147. }
  148. /*
  149. #pragma mark - Navigation
  150. // In a storyboard-based application, you will often want to do a little preparation before navigation
  151. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  152. // Get the new view controller using [segue destinationViewController].
  153. // Pass the selected object to the new view controller.
  154. }
  155. */
  156. @end