|
|
@@ -35,7 +35,7 @@
|
|
|
#define INTNUMBERS @"0123456789\n"
|
|
|
#define NUMBERS @"0123456789.\n"
|
|
|
#import "OLDataProvider.h"
|
|
|
-
|
|
|
+#import <objc/objc.h>
|
|
|
|
|
|
|
|
|
@interface subitem_data ()
|
|
|
@@ -46,10 +46,30 @@
|
|
|
@end
|
|
|
@interface CommonEditorViewController ()
|
|
|
|
|
|
+
|
|
|
+@property (nonatomic,copy) NSString *class_name;
|
|
|
+
|
|
|
+@property (nonatomic,copy) NSString *urgency_timer_name;
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation CommonEditorViewController
|
|
|
|
|
|
+- (NSString *)class_name {
|
|
|
+ if (!_class_name) {
|
|
|
+ const char *class_name_ch = object_getClassName([self class]);
|
|
|
+ _class_name = [NSString stringWithUTF8String:class_name_ch];
|
|
|
+ }
|
|
|
+ return _class_name;
|
|
|
+}
|
|
|
+
|
|
|
+- (NSString *)urgency_timer_name {
|
|
|
+ if (!_urgency_timer_name) {
|
|
|
+ _urgency_timer_name = [NSString stringWithFormat:@"%@_urgency_timer",self.class_name];
|
|
|
+ }
|
|
|
+ return _urgency_timer_name;
|
|
|
+}
|
|
|
+
|
|
|
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
|
|
{
|
|
|
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
|
|
@@ -74,6 +94,7 @@
|
|
|
-(void) viewWillDisappear:(BOOL)animated
|
|
|
{
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
+ [self cancel_urgency_timer];
|
|
|
}
|
|
|
|
|
|
-(void)manually_refresh
|
|
|
@@ -98,10 +119,73 @@
|
|
|
reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
|
|
|
[self refresh:nil];
|
|
|
}
|
|
|
+
|
|
|
+- (void)start_urgency_timer {
|
|
|
+
|
|
|
+ AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
+
|
|
|
+
|
|
|
+ [[JKTimerManager sharedTimerManager] scheduledDispatchTimerWithName:self.urgency_timer_name timeInterval:2 queue:nil repeats:YES action:^{
|
|
|
+
|
|
|
+ [appDelegate.urgencyDic setValue:appDelegate.user forKey:@"user"];
|
|
|
+ [appDelegate.urgencyDic setValue:[NSNumber numberWithBool:appDelegate.offline_mode] forKey:@"offline_mode"];
|
|
|
+
|
|
|
+ if ([self.class_name isEqualToString:@"CustomerEditViewController"]) {
|
|
|
+ // CustomerEditViewController
|
|
|
+ __block NSString *contact_id = @"";
|
|
|
+
|
|
|
+ [self.content_data_download enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
|
|
|
+
|
|
|
+ // section_0
|
|
|
+ if ([key isEqualToString:@"section_0"]) {
|
|
|
+ NSDictionary *section_0 = (NSDictionary *)obj;
|
|
|
+ [section_0 enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
|
|
|
+
|
|
|
+ // Contact ID
|
|
|
+ if ([obj isKindOfClass:[NSDictionary class]]) {
|
|
|
+ if ([[obj objectForKey:@"aname"] isEqualToString:@"Contact ID"]) {
|
|
|
+ contact_id = [obj objectForKey:@"value"];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }];
|
|
|
+ }
|
|
|
+
|
|
|
+ }];
|
|
|
+ [appDelegate.urgencyDic setValue:self.class_name forKey:@"firt_class_name"];
|
|
|
+ [appDelegate.urgencyDic setValue:contact_id forKey:@"contact_id"];
|
|
|
+
|
|
|
+
|
|
|
+ } else if ([self.class_name isEqualToString:@"CreateOrderViewController"]) {
|
|
|
+ // CreateOrderViewController
|
|
|
+ [appDelegate.urgencyDic setValue:self.class_name forKey:@"firt_class_name"];
|
|
|
+
|
|
|
+
|
|
|
+ } else if ([self.class_name isEqualToString:@"AddressEditorViewController"]) {
|
|
|
+ // AddressEditorViewController
|
|
|
+
|
|
|
+ [appDelegate.urgencyDic setValue:self.class_name forKey:@"second_class_name"];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ [appDelegate.urgencyDic setValue:self.changed_data forKey:[NSString stringWithFormat:@"%@_changed_data",self.class_name]];
|
|
|
+
|
|
|
+
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)cancel_urgency_timer {
|
|
|
+ [[JKTimerManager sharedTimerManager] cancelTimerWithName:self.urgency_timer_name];
|
|
|
+}
|
|
|
+
|
|
|
- (void)viewDidLoad
|
|
|
{
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
+ [self start_urgency_timer];
|
|
|
+
|
|
|
+
|
|
|
if(self.loading_msg==nil)
|
|
|
self.loading_msg = @"Please Wait";
|
|
|
if(self.loading_title==nil)
|