CreditCardEditorViewController.m 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. //
  2. // CreditCardEditorViewController.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 "CreditCardEditorViewController.h"
  9. #import "MainViewController.h"
  10. #import "RAUtils.h"
  11. #import "JKTimerManager.h"
  12. @interface CreditCardEditorViewController ()
  13. @end
  14. @implementation CreditCardEditorViewController
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"back", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onBackClick:)];
  18. self.navigationItem.leftBarButtonItem = backButton;
  19. // Do any additional setup after loading the view.
  20. }
  21. - (void)didReceiveMemoryWarning {
  22. [super didReceiveMemoryWarning];
  23. // Dispose of any resources that can be recreated.
  24. }
  25. - (void)onBackClick:(UIButton *)sender {
  26. [self.navigationController popViewControllerAnimated:(false)];
  27. }
  28. - (IBAction)onRightBtnClick:(id)sender {
  29. [self.lastedit endEditing:true];
  30. [self.lasttextview endEditing:true];
  31. // self.cancommit=true;
  32. // NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
  33. // int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
  34. // for(int i=0;i<section_count;i++)
  35. // {
  36. // NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
  37. // int item_count = [[sectionjson valueForKey:@"count"] intValue];
  38. // for(int j=0;j<item_count;j++)
  39. // {
  40. // NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
  41. // NSString* key = [itemjson valueForKey:@"name"];
  42. // if(key==nil || key.length==0)
  43. // continue;
  44. // if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
  45. // {
  46. // NSString* single_select = [itemjson valueForKey:@"single_select"];
  47. // if([single_select isEqualToString:@"true"])
  48. // {
  49. // NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
  50. // int count = [[cadejson valueForKey:@"count"] intValue];
  51. // bool setvalue = false;
  52. // for(int cc=0;cc<count;cc++)
  53. // {
  54. // NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
  55. // if([[valjson valueForKey:@"check"]intValue]==1)
  56. // {
  57. // [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
  58. // setvalue=true;
  59. // break;
  60. // }
  61. // }
  62. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
  63. // {
  64. // self.cancommit = false;
  65. // }
  66. // }
  67. // else
  68. // {
  69. // //not support multi select for now;
  70. // }
  71. // /*
  72. // upparams setValue:itemjson forKey:<#(NSString *)#>
  73. //
  74. // */
  75. // }
  76. // else
  77. // {
  78. // if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
  79. // [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
  80. // else
  81. // {
  82. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
  83. // self.cancommit = false;
  84. // }
  85. // }
  86. // upparams= [self subitem_param:itemjson addto:upparams ];
  87. // }
  88. // }
  89. //
  90. //
  91. // if(self.cancommit==false)
  92. // {
  93. //[RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
  94. //
  95. // self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
  96. //
  97. //
  98. // // DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
  99. // // [self.editorTable reloadData ];
  100. //
  101. // [self.editorTable reloadData];
  102. // return;
  103. //
  104. // }
  105. // NSMutableDictionary* upparams =
  106. [self check_cancommit:true];
  107. if(self.cancommit==false)
  108. return;
  109. [self prepareReturn:self.content_data_download];
  110. [self.navigationController popViewControllerAnimated:(false)];
  111. }
  112. //-(void) finish
  113. //{
  114. // if (self.delegate && [self.delegate respondsToSelector:@selector(returnValue)]) {
  115. // [self.delegate returnValue];
  116. // }
  117. // if(self.returnValue)
  118. // self.returnValue(self.content_data_download);
  119. //}
  120. /*
  121. #pragma mark - Navigation
  122. // In a storyboard-based application, you will often want to do a little preparation before navigation
  123. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  124. // Get the new view controller using [segue destinationViewController].
  125. // Pass the selected object to the new view controller.
  126. }
  127. */
  128. #pragma mark - Urgency
  129. - (void)viewWillAppear:(BOOL)animated {
  130. [super viewWillAppear:animated];
  131. [self start_urgency_timer];
  132. }
  133. -(void) viewWillDisappear:(BOOL)animated
  134. {
  135. [super viewWillDisappear:animated];
  136. [self cancel_urgency_timer];
  137. }
  138. - (void)dealloc {
  139. AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  140. [appDelegate.urgencyDic removeObjectForKey:[NSString stringWithFormat:@"level_%d",self.level]];
  141. [appDelegate.urgencyDic setValue:[NSNumber numberWithInteger:self.level] forKey:@"count"];
  142. }
  143. - (void)start_urgency_timer {
  144. if (!self.editable) {
  145. return;
  146. }
  147. __weak typeof(self) weakSelf = self;
  148. AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  149. [appDelegate.urgencyDic setValue:RASingleton.sharedInstance.user forKey:@"user"];
  150. #ifdef OFFLINE_MODE
  151. [appDelegate.urgencyDic setValue:[NSNumber numberWithBool:appDelegate.offline_mode] forKey:@"offline_mode"];
  152. #endif
  153. [[JKTimerManager sharedTimerManager] scheduledDispatchTimerWithName:self.urgency_timer_name timeInterval:1 queue:nil repeats:YES action:^{
  154. NSMutableDictionary *urgencyDic = [NSMutableDictionary dictionary];
  155. // DebugLog(@"timer start....");
  156. [urgencyDic setValue:weakSelf.content_data_download forKey:[NSString stringWithFormat:@"%@_restored_data",self.class_name]];
  157. [urgencyDic setValue:weakSelf.class_name forKey:@"class_name"];
  158. [appDelegate.urgencyDic setValue:urgencyDic forKey:[NSString stringWithFormat:@"level_%d",weakSelf.level]];
  159. [appDelegate.urgencyDic setValue:[NSNumber numberWithInteger:weakSelf.level + 1] forKey:@"count"];
  160. }];
  161. }
  162. - (void)cancel_urgency_timer {
  163. [[JKTimerManager sharedTimerManager] cancelTimerWithName:self.urgency_timer_name];
  164. }
  165. @end