// // CreditCardEditorViewController.m // RedAnt ERP Mobile // // Created by Ray on 8/18/15. // Copyright (c) 2015 United Software Applications, Inc. All rights reserved. // #import "CreditCardEditorViewController.h" #import "MainViewController.h" #import "RAUtils.h" #import "JKTimerManager.h" @interface CreditCardEditorViewController () @end @implementation CreditCardEditorViewController - (void)viewDidLoad { [super viewDidLoad]; UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"back", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onBackClick:)]; self.navigationItem.leftBarButtonItem = backButton; // Do any additional setup after loading the view. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)onBackClick:(UIButton *)sender { [self.navigationController popViewControllerAnimated:(false)]; } - (IBAction)onRightBtnClick:(id)sender { [self.lastedit endEditing:true]; [self.lasttextview endEditing:true]; // self.cancommit=true; // NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init]; // int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue]; // for(int i=0;i // // */ // } // 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]; // return; // // } // NSMutableDictionary* upparams = [self check_cancommit:true]; if(self.cancommit==false) return; [self prepareReturn:self.content_data_download]; [self.navigationController popViewControllerAnimated:(false)]; } //-(void) finish //{ // if (self.delegate && [self.delegate respondsToSelector:@selector(returnValue)]) { // [self.delegate returnValue]; // } // if(self.returnValue) // self.returnValue(self.content_data_download); //} /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ #pragma mark - Urgency - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self start_urgency_timer]; } -(void) viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self cancel_urgency_timer]; } - (void)dealloc { AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; [appDelegate.urgencyDic removeObjectForKey:[NSString stringWithFormat:@"level_%d",self.level]]; [appDelegate.urgencyDic setValue:[NSNumber numberWithInteger:self.level] forKey:@"count"]; } - (void)start_urgency_timer { if (!self.editable) { return; } __weak typeof(self) weakSelf = self; AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; [appDelegate.urgencyDic setValue:RASingleton.sharedInstance.user forKey:@"user"]; #ifdef OFFLINE_MODE [appDelegate.urgencyDic setValue:[NSNumber numberWithBool:appDelegate.offline_mode] forKey:@"offline_mode"]; #endif [[JKTimerManager sharedTimerManager] scheduledDispatchTimerWithName:self.urgency_timer_name timeInterval:1 queue:nil repeats:YES action:^{ NSMutableDictionary *urgencyDic = [NSMutableDictionary dictionary]; // DebugLog(@"timer start...."); [urgencyDic setValue:weakSelf.content_data_download forKey:[NSString stringWithFormat:@"%@_restored_data",self.class_name]]; [urgencyDic setValue:weakSelf.class_name forKey:@"class_name"]; [appDelegate.urgencyDic setValue:urgencyDic forKey:[NSString stringWithFormat:@"level_%d",weakSelf.level]]; [appDelegate.urgencyDic setValue:[NSNumber numberWithInteger:weakSelf.level + 1] forKey:@"count"]; }]; } - (void)cancel_urgency_timer { [[JKTimerManager sharedTimerManager] cancelTimerWithName:self.urgency_timer_name]; } @end