|
|
@@ -84,101 +84,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
-//// UILabel* titleLabel= [[UILabel alloc] initWithFrame:CGRectMake(100, 0, 100
|
|
|
-//
|
|
|
-// , 44)];
|
|
|
-// titleLabel.text=@"Contacts";
|
|
|
-// // titleLabel.backgroundColor =[UIColor yellowColor];
|
|
|
-// titleLabel.textAlignment=NSTextAlignmentCenter;
|
|
|
-// // [titleLabel sizeToFit];
|
|
|
-//
|
|
|
-// //将搜索条放在一个UIView上
|
|
|
-// // UIView *searchView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 1768, 44)];
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// searchView.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleWidth;
|
|
|
-//
|
|
|
-// titleLabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
|
|
|
-// titleLabel.center=searchView.center;
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// self.searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(searchView.frame.size.width-200.0f-8.0f,0.0f,200.0f,44.0f)];
|
|
|
-// self.searchBar.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
|
|
|
-// self.searchBar.delegate = self;
|
|
|
-// [self.searchBar setPlaceholder:@"name/address"];
|
|
|
-// //searchBar.barTintColor=[UIColor clearColor];
|
|
|
-// self.searchBar.searchBarStyle=UISearchBarStyleMinimal;
|
|
|
-// [searchView addSubview:titleLabel];
|
|
|
-// [searchView addSubview:self.searchBar];
|
|
|
-//
|
|
|
-// self.navigationItem.titleView = searchView;
|
|
|
+ //// UILabel* titleLabel= [[UILabel alloc] initWithFrame:CGRectMake(100, 0, 100
|
|
|
+ //
|
|
|
+ // , 44)];
|
|
|
+ // titleLabel.text=@"Contacts";
|
|
|
+ // // titleLabel.backgroundColor =[UIColor yellowColor];
|
|
|
+ // titleLabel.textAlignment=NSTextAlignmentCenter;
|
|
|
+ // // [titleLabel sizeToFit];
|
|
|
+ //
|
|
|
+ // //将搜索条放在一个UIView上
|
|
|
+ // // UIView *searchView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 1768, 44)];
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // searchView.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleWidth;
|
|
|
+ //
|
|
|
+ // titleLabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
|
|
|
+ // titleLabel.center=searchView.center;
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // self.searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(searchView.frame.size.width-200.0f-8.0f,0.0f,200.0f,44.0f)];
|
|
|
+ // self.searchBar.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
|
|
|
+ // self.searchBar.delegate = self;
|
|
|
+ // [self.searchBar setPlaceholder:@"name/address"];
|
|
|
+ // //searchBar.barTintColor=[UIColor clearColor];
|
|
|
+ // self.searchBar.searchBarStyle=UISearchBarStyleMinimal;
|
|
|
+ // [searchView addSubview:titleLabel];
|
|
|
+ // [searchView addSubview:self.searchBar];
|
|
|
+ //
|
|
|
+ // self.navigationItem.titleView = searchView;
|
|
|
|
|
|
-// NSMutableArray * items = [[NSMutableArray alloc]init];
|
|
|
-//
|
|
|
-//
|
|
|
-// UIBarButtonItem *Btnback = nil;//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onSaveClick:)];
|
|
|
-//
|
|
|
-// Btnback = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
|
|
|
-// style:UIBarButtonItemStylePlain
|
|
|
-// target:self
|
|
|
-// action:@selector(onBack:)];
|
|
|
-//
|
|
|
-//
|
|
|
-// UIBarButtonItem *btnAS = nil;
|
|
|
-// btnAS =[[UIBarButtonItem alloc] initWithTitle:@"Advanced search"
|
|
|
-// style:UIBarButtonItemStylePlain
|
|
|
-// target:self
|
|
|
-// action:@selector(onASearch:)];
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// //savebtn setBackgroundImage:(nullable UIImage *) forState:<#(UIControlState)#> style:<#(UIBarButtonItemStyle)#> barMetrics:<#(UIBarMetrics)#>
|
|
|
-// //[savebtn setImage:[UIImage imageNamed:@"save"] ];
|
|
|
-//
|
|
|
-//
|
|
|
-// /*
|
|
|
-// UIBarMetricsDefault,
|
|
|
-// UIBarMetricsCompact,
|
|
|
-// UIBarMetricsDefaultPrompt = 101, // Applicable only in bars with the prompt property, such as UINavigationBar and UISearchBar
|
|
|
-// UIBarMetricsCompactPrompt
|
|
|
-//
|
|
|
-// */
|
|
|
-// // [savebtn setBackgroundImage:[UIImage imageNamed:@"save"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
|
|
-// // UIBarButtonItem *item1 = [[UIBarButtonItem alloc] init];
|
|
|
-// // item1.title = @"item1";
|
|
|
-// //// item1.image = [UIImage imageNamed:@"rect_setting"];
|
|
|
-// // UIBarButtonItem *item2 = [[UIBarButtonItem alloc] init];
|
|
|
-// //// item2.image = [UIImage imageNamed:@"rect_about"];
|
|
|
-// // item2.title = @"item2";
|
|
|
-//
|
|
|
-//
|
|
|
-// UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
|
|
|
-// fixedItem.width = 20.0f;
|
|
|
-//
|
|
|
-//// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
-////
|
|
|
-//// if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
|
|
|
-//
|
|
|
-// [items addObject:Btnback];
|
|
|
-//
|
|
|
-// [items addObject:fixedItem];
|
|
|
-//
|
|
|
-// [items addObject:btnAS];
|
|
|
-// // [items addObject:item2];
|
|
|
-// self.navigationItem.leftBarButtonItems=items;
|
|
|
+ // NSMutableArray * items = [[NSMutableArray alloc]init];
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // UIBarButtonItem *Btnback = nil;//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onSaveClick:)];
|
|
|
+ //
|
|
|
+ // Btnback = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
|
|
|
+ // style:UIBarButtonItemStylePlain
|
|
|
+ // target:self
|
|
|
+ // action:@selector(onBack:)];
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // UIBarButtonItem *btnAS = nil;
|
|
|
+ // btnAS =[[UIBarButtonItem alloc] initWithTitle:@"Advanced search"
|
|
|
+ // style:UIBarButtonItemStylePlain
|
|
|
+ // target:self
|
|
|
+ // action:@selector(onASearch:)];
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // //savebtn setBackgroundImage:(nullable UIImage *) forState:<#(UIControlState)#> style:<#(UIBarButtonItemStyle)#> barMetrics:<#(UIBarMetrics)#>
|
|
|
+ // //[savebtn setImage:[UIImage imageNamed:@"save"] ];
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // /*
|
|
|
+ // UIBarMetricsDefault,
|
|
|
+ // UIBarMetricsCompact,
|
|
|
+ // UIBarMetricsDefaultPrompt = 101, // Applicable only in bars with the prompt property, such as UINavigationBar and UISearchBar
|
|
|
+ // UIBarMetricsCompactPrompt
|
|
|
+ //
|
|
|
+ // */
|
|
|
+ // // [savebtn setBackgroundImage:[UIImage imageNamed:@"save"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
|
|
+ // // UIBarButtonItem *item1 = [[UIBarButtonItem alloc] init];
|
|
|
+ // // item1.title = @"item1";
|
|
|
+ // //// item1.image = [UIImage imageNamed:@"rect_setting"];
|
|
|
+ // // UIBarButtonItem *item2 = [[UIBarButtonItem alloc] init];
|
|
|
+ // //// item2.image = [UIImage imageNamed:@"rect_about"];
|
|
|
+ // // item2.title = @"item2";
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
|
|
|
+ // fixedItem.width = 20.0f;
|
|
|
+ //
|
|
|
+ //// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+ ////
|
|
|
+ //// if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
|
|
|
+ //
|
|
|
+ // [items addObject:Btnback];
|
|
|
+ //
|
|
|
+ // [items addObject:fixedItem];
|
|
|
+ //
|
|
|
+ // [items addObject:btnAS];
|
|
|
+ // // [items addObject:item2];
|
|
|
+ // self.navigationItem.leftBarButtonItems=items;
|
|
|
|
|
|
|
|
|
- self.offset = 0;
|
|
|
- [self.content_data removeAllObjects];
|
|
|
+ self.offset = 0;
|
|
|
+ [self.content_data removeAllObjects];
|
|
|
NSLog(@"%s removeAllObjects",__func__);
|
|
|
// [self loadpage];
|
|
|
-
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
-(void)manually_refresh
|
|
|
{
|
|
|
@@ -189,8 +189,8 @@
|
|
|
return;
|
|
|
}
|
|
|
reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Refreshing"];
|
|
|
- if ([self respondsToSelector:@selector(ReloadData)])
|
|
|
- [self performSelector:@selector(ReloadData) withObject:nil afterDelay:1];
|
|
|
+ if ([self respondsToSelector:@selector(ReloadData)])
|
|
|
+ [self performSelector:@selector(ReloadData) withObject:nil afterDelay:1];
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -211,7 +211,7 @@
|
|
|
[self loadpage];
|
|
|
|
|
|
// [self loadpage];
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
- (void)didReceiveMemoryWarning {
|
|
|
[super didReceiveMemoryWarning];
|
|
|
@@ -221,10 +221,10 @@
|
|
|
-(void) viewWillAppear:(BOOL)animated
|
|
|
{
|
|
|
[super viewWillAppear:animated];
|
|
|
-// [[self navigationController] setNavigationBarHidden:NO animated:NO];
|
|
|
-// self.offset = 0;
|
|
|
-// [self.content_data removeAllObjects];
|
|
|
-// [self loadpage];
|
|
|
+ // [[self navigationController] setNavigationBarHidden:NO animated:NO];
|
|
|
+ // self.offset = 0;
|
|
|
+ // [self.content_data removeAllObjects];
|
|
|
+ // [self loadpage];
|
|
|
|
|
|
[[self navigationController] setNavigationBarHidden:!self.showNavibar animated:NO];
|
|
|
}
|
|
|
@@ -258,42 +258,40 @@
|
|
|
if (self.dataOperationQueue.operationCount > 1) {
|
|
|
return;
|
|
|
}
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- if(self.isrefreshing)
|
|
|
- return;
|
|
|
-
|
|
|
-self.label_net_err.hidden=true;
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ if(self.isrefreshing)
|
|
|
+ return;
|
|
|
|
|
|
- self.isrefreshing=true;
|
|
|
- if(self.offset==0)
|
|
|
- {
|
|
|
- self.table.hidden = true;
|
|
|
- // [self.params setValue:[NSString stringWithFormat:@"%ld",self.offset] forKey:@"offset"];
|
|
|
- self.mum.center = self.view.center;
|
|
|
-
|
|
|
+ self.label_net_err.hidden=true;
|
|
|
|
|
|
- self.mum.hidden = false;
|
|
|
- [self.mum startAnimating];
|
|
|
- }
|
|
|
- // self.btnrefresh.enabled = false;
|
|
|
- //
|
|
|
- // NSTimeInterval animationDuration = 0.30f;
|
|
|
- // [UIView beginAnimations:@"ResizeView" context:nil];
|
|
|
- // [UIView setAnimationDuration:animationDuration];
|
|
|
- // self.prepageButton.enabled=false;
|
|
|
- // self.nextpageButton.enabled=false;
|
|
|
- // self.mum.hidden = false;
|
|
|
- // self.grid.hidden = true;
|
|
|
- // self.mum.hidden = false;
|
|
|
- // self.tableview.hidden = true;
|
|
|
-
|
|
|
- // [UIView commitAnimations];
|
|
|
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+ self.isrefreshing=true;
|
|
|
+ if(self.offset==0)
|
|
|
+ {
|
|
|
+ self.table.hidden = true;
|
|
|
+ // [self.params setValue:[NSString stringWithFormat:@"%ld",self.offset] forKey:@"offset"];
|
|
|
+ self.mum.center = self.view.center;
|
|
|
+
|
|
|
+
|
|
|
+ self.mum.hidden = false;
|
|
|
+ [self.mum startAnimating];
|
|
|
+ }
|
|
|
+ // self.btnrefresh.enabled = false;
|
|
|
+ //
|
|
|
+ // NSTimeInterval animationDuration = 0.30f;
|
|
|
+ // [UIView beginAnimations:@"ResizeView" context:nil];
|
|
|
+ // [UIView setAnimationDuration:animationDuration];
|
|
|
+ // self.prepageButton.enabled=false;
|
|
|
+ // self.nextpageButton.enabled=false;
|
|
|
+ // self.mum.hidden = false;
|
|
|
+ // self.grid.hidden = true;
|
|
|
+ // self.mum.hidden = false;
|
|
|
+ // self.tableview.hidden = true;
|
|
|
|
|
|
+ // [UIView commitAnimations];
|
|
|
|
|
|
- NSMutableDictionary* content=nil;
|
|
|
- content=[[RANetwork request_ContactList:self.offset limit : self.limit keywords:self.keywords type:self.contact_type adv_search:self.adv_search] mutableCopy];
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [RANetwork request_contactlist:self.offset limit:self.limit keywords:self.keywords type:self.contact_type adv_search:self.adv_search completionHandler:^(NSMutableDictionary *result) {
|
|
|
+ NSMutableDictionary* content=result;
|
|
|
+
|
|
|
|
|
|
[self.mum stopAnimating];
|
|
|
self.isrefreshing=false;
|
|
|
@@ -346,16 +344,85 @@ self.label_net_err.hidden=true;
|
|
|
{
|
|
|
[RAUtils message_alert:[content valueForKey:@"err_msg"] title:@"Loading Contact List" controller:self] ;
|
|
|
}
|
|
|
-
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
self.isrefreshing=false;
|
|
|
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ return;
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+
|
|
|
+
|
|
|
+ NSMutableDictionary* content=nil;
|
|
|
+ content=[[RANetwork request_ContactList:self.offset limit : self.limit keywords:self.keywords type:self.contact_type adv_search:self.adv_search] mutableCopy];
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+
|
|
|
+ [self.mum stopAnimating];
|
|
|
+ self.isrefreshing=false;
|
|
|
+ if (self.dataOperationQueue.operationCount > 1) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if([[content valueForKey:@"result"] intValue]==2)
|
|
|
+ {
|
|
|
+ self.table.hidden =false;
|
|
|
+ int count = [[content valueForKey:@"count" ] intValue] ;
|
|
|
+
|
|
|
+ self.offset += count;
|
|
|
+ for(int i=0;i<count;i++)
|
|
|
+ {
|
|
|
+
|
|
|
+ NSDictionary* objmsg = [content objectForKey:[NSString stringWithFormat:@"item_%d",i]];
|
|
|
+ [self.content_data addObject:[NSMutableDictionary dictionaryWithDictionary:objmsg]];
|
|
|
+
|
|
|
+ }
|
|
|
+ if(count<self.limit)
|
|
|
+ {
|
|
|
+
|
|
|
+ // int i =self.btnrefresh.state;
|
|
|
+ self.load_more_hint=@"All loaded";
|
|
|
+ // self.btnrefresh.titleLabel.text =NSLocalizedString(@"no_more", nil);
|
|
|
+ // [self.btnrefresh setTitle:@"No more" forState:UIControlStateNormal];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ self.load_more_hint=@"Load more...";
|
|
|
+ // self.btnrefresh.enabled = true;
|
|
|
+ // self.btnrefresh.titleLabel.text =NSLocalizedString(@"load_more",nil);
|
|
|
+ // [self.btnrefresh setTitle:@"Load more" forState:UIControlStateNormal];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [self.table reloadData ];
|
|
|
+ NSLog(@"%s reloadData",__FUNCTION__);
|
|
|
+
|
|
|
+ }
|
|
|
+ else if([[content valueForKey:@"result"] intValue]==RESULT_NET_ERROR &&self.offset==0)
|
|
|
+ {
|
|
|
+ self.label_net_err.hidden=false;
|
|
|
+ self.table.hidden = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ [RAUtils message_alert:[content valueForKey:@"err_msg"] title:@"Loading Contact List" controller:self] ;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ self.isrefreshing=false;
|
|
|
+
|
|
|
+ });
|
|
|
});
|
|
|
});
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
-(void) loadpage {
|
|
|
@@ -383,10 +450,10 @@ self.label_net_err.hidden=true;
|
|
|
- (IBAction)onBack:(UIBarButtonItem *)sender {
|
|
|
if(self.onCancel)
|
|
|
self.onCancel();
|
|
|
- [self.navigationController popViewControllerAnimated:(false)];
|
|
|
+ [self.navigationController popViewControllerAnimated:(false)];
|
|
|
}
|
|
|
- (IBAction)onASearch:(UIBarButtonItem *)sender {
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
ContactAdvanceSearchViewController * vc = [[ContactAdvanceSearchViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
|
|
|
@@ -398,31 +465,31 @@ self.label_net_err.hidden=true;
|
|
|
|
|
|
|
|
|
NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
|
|
|
- vc.params = params;
|
|
|
+ vc.params = params;
|
|
|
|
|
|
vc.data_init = self.adv_search;
|
|
|
|
|
|
- // vc.update_order = true;
|
|
|
+ // vc.update_order = true;
|
|
|
|
|
|
- // vc.contactId=contactid;
|
|
|
+ // vc.contactId=contactid;
|
|
|
// vc.delegate = self;
|
|
|
|
|
|
vc.returnValue = ^(NSMutableDictionary* value){
|
|
|
-
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
self.adv_search = value;
|
|
|
|
|
|
self.keywords=nil;
|
|
|
self.offset = 0;
|
|
|
[self.content_data removeAllObjects];
|
|
|
- NSLog(@"%s removeAllObjects",__func__);
|
|
|
+ NSLog(@"%s removeAllObjects",__func__);
|
|
|
[self loadpage];
|
|
|
|
|
|
-// appDelegate.contact_id=[value valueForKey:@"customer_cid"];
|
|
|
-// appDelegate.customerInfo = value;
|
|
|
+ // appDelegate.contact_id=[value valueForKey:@"customer_cid"];
|
|
|
+ // appDelegate.customerInfo = value;
|
|
|
};
|
|
|
|
|
|
|
|
|
@@ -431,9 +498,9 @@ self.label_net_err.hidden=true;
|
|
|
- (IBAction)onNewCustomerClick:(id)sender {
|
|
|
|
|
|
|
|
|
- NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
|
|
|
+ NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
|
|
|
+
|
|
|
|
|
|
-
|
|
|
|
|
|
CustomerEditViewController * cuseditVC = [[CustomerEditViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
|
|
|
cuseditVC.bnewcustomer=true;
|
|
|
@@ -448,17 +515,17 @@ self.label_net_err.hidden=true;
|
|
|
// {
|
|
|
// orderinfoVC.have_tail = true
|
|
|
// }
|
|
|
- [[self navigationController] setNavigationBarHidden:NO animated:NO];
|
|
|
+ [[self navigationController] setNavigationBarHidden:NO animated:NO];
|
|
|
[self.navigationController pushViewController:cuseditVC animated:false];
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
- (IBAction)resetContactId:(id)sender {
|
|
|
|
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
appDelegate.contact_id=nil;
|
|
|
appDelegate.customerInfo = nil;
|
|
|
-// appDelegate.contact_name =nil;
|
|
|
+ // appDelegate.contact_name =nil;
|
|
|
|
|
|
if(self.onReset)
|
|
|
self.onReset();
|
|
|
@@ -507,12 +574,87 @@ self.label_net_err.hidden=true;
|
|
|
DebugLog(@"indexPath is = %i",indexPath.row);
|
|
|
|
|
|
|
|
|
- NSString* contactid=[self.content_data[indexPath.row] valueForKey:@"contact_id"] ;
|
|
|
+ NSString* contactid=[self.content_data[indexPath.row] valueForKey:@"contact_id"] ;
|
|
|
|
|
|
|
|
|
|
|
|
UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Getting Contact information"];
|
|
|
|
|
|
+ [RANetwork request_contactinfo:contactid completionHandler:^(NSMutableDictionary *result) {
|
|
|
+ NSMutableDictionary* editor_json = result;
|
|
|
+
|
|
|
+
|
|
|
+ [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
+
|
|
|
+ if([[editor_json valueForKey:@"result"] intValue]==2)
|
|
|
+ {
|
|
|
+ __block NSMutableDictionary* data_init = [[editor_json objectForKey:@"customerInfo" ] mutableCopy];
|
|
|
+
|
|
|
+ //---------------- construct customer_contact----------------------
|
|
|
+ NSString* customer_first_name = [data_init valueForKey:@"customer_first_name"];
|
|
|
+ if(customer_first_name==nil)
|
|
|
+ customer_first_name=@"";
|
|
|
+
|
|
|
+ NSString* customer_last_name= [data_init valueForKey:@"customer_last_name"];
|
|
|
+ if(customer_last_name==nil)
|
|
|
+ customer_last_name=@"";
|
|
|
+ NSString* customer_contact = [NSString stringWithFormat:@"%@ %@",customer_first_name,customer_last_name];
|
|
|
+ customer_contact=[customer_contact stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
|
|
+ [data_init setValue:customer_contact forKey:@"customer_contact"];
|
|
|
+
|
|
|
+ data_init[@"is_subaction"]=self.is_subaction;
|
|
|
+ data_init[@"subaction_tag"]= self.subaction_tag;
|
|
|
+ [self.navigationController popToRootViewControllerAnimated:false];
|
|
|
+
|
|
|
+
|
|
|
+ [self.table reloadData];
|
|
|
+ NSLog(@"%s reloadData",__FUNCTION__);
|
|
|
+ if(self.returnValue)
|
|
|
+ self.returnValue(data_init,self.from);
|
|
|
+
|
|
|
+ // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+ // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+ // NSDictionary* editor_json = [iSalesNetwork update_OrderCustomer:appDelegate.order_code customerinfo:data_init];
|
|
|
+ //
|
|
|
+ // dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // if([[editor_json valueForKey:@"result"] intValue]==2)
|
|
|
+ // {
|
|
|
+ //
|
|
|
+ //// [self.navigationController popViewControllerAnimated:false];
|
|
|
+ //// if(self.returnValue)
|
|
|
+ //// {
|
|
|
+ ////
|
|
|
+ //// self.returnValue(data_init);
|
|
|
+ //// }
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Update Order Customer Infomation" controller:self] ;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Loading Contact Information" controller:self] ;
|
|
|
+ // self.btn_assign.enabled=false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ return ;
|
|
|
+
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
|
NSDictionary* editor_json = [RANetwork request_CustomerInfo:contactid];
|
|
|
@@ -547,48 +689,48 @@ self.label_net_err.hidden=true;
|
|
|
if(self.returnValue)
|
|
|
self.returnValue(data_init,self.from);
|
|
|
|
|
|
-// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
-// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
-// NSDictionary* editor_json = [iSalesNetwork update_OrderCustomer:appDelegate.order_code customerinfo:data_init];
|
|
|
-//
|
|
|
-// dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
-//
|
|
|
-//
|
|
|
-// if([[editor_json valueForKey:@"result"] intValue]==2)
|
|
|
-// {
|
|
|
-//
|
|
|
-//// [self.navigationController popViewControllerAnimated:false];
|
|
|
-//// if(self.returnValue)
|
|
|
-//// {
|
|
|
-////
|
|
|
-//// self.returnValue(data_init);
|
|
|
-//// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Update Order Customer Infomation" controller:self] ;
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// });
|
|
|
-// });
|
|
|
+ // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+ // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+ // NSDictionary* editor_json = [iSalesNetwork update_OrderCustomer:appDelegate.order_code customerinfo:data_init];
|
|
|
+ //
|
|
|
+ // dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // if([[editor_json valueForKey:@"result"] intValue]==2)
|
|
|
+ // {
|
|
|
+ //
|
|
|
+ //// [self.navigationController popViewControllerAnimated:false];
|
|
|
+ //// if(self.returnValue)
|
|
|
+ //// {
|
|
|
+ ////
|
|
|
+ //// self.returnValue(data_init);
|
|
|
+ //// }
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Update Order Customer Infomation" controller:self] ;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // });
|
|
|
+ // });
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
[RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Loading Contact Information" controller:self] ;
|
|
|
-// self.btn_assign.enabled=false;
|
|
|
+ // self.btn_assign.enabled=false;
|
|
|
}
|
|
|
|
|
|
|
|
|
});
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|
|
|
#pragma mark - Table view data source
|
|
|
@@ -596,7 +738,7 @@ self.label_net_err.hidden=true;
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
|
|
|
{
|
|
|
|
|
|
-
|
|
|
+
|
|
|
if(indexPath.row==self.content_data.count)
|
|
|
return 44;
|
|
|
|
|
|
@@ -605,7 +747,7 @@ self.label_net_err.hidden=true;
|
|
|
|
|
|
float width = tableView.frame.size.width;
|
|
|
|
|
|
-// 40+15+8
|
|
|
+ // 40+15+8
|
|
|
width-=63;
|
|
|
CGSize constraintkey = CGSizeMake(width-2*LABEL_MARGIN, 10.0f);//key label width is 40% cell width;
|
|
|
// CGSize constraintval = CGSizeMake(width*0.6-2*LABEL_MARGIN, 20000.0f);//val label width is 60% cell width;
|
|
|
@@ -725,7 +867,7 @@ self.label_net_err.hidden=true;
|
|
|
{
|
|
|
// if(tableView==self.itemListTable)
|
|
|
// {
|
|
|
-// DebugLog(@"row %ld",(long)indexPath.row);
|
|
|
+ // DebugLog(@"row %ld",(long)indexPath.row);
|
|
|
if(indexPath.row==self.content_data.count)
|
|
|
{
|
|
|
UITableViewCell *moreCell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"mores"];
|
|
|
@@ -747,7 +889,7 @@ self.label_net_err.hidden=true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-// UITableViewCell *cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ContactListCell"];
|
|
|
+ // UITableViewCell *cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ContactListCell"];
|
|
|
|
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
NSString *CellIdentifier = @"ContactListTableViewCell";
|
|
|
@@ -759,18 +901,18 @@ self.label_net_err.hidden=true;
|
|
|
|
|
|
cell.btn_assign.hidden = !(self.assig_icon&&(appDelegate.contact_id.length==0));
|
|
|
|
|
|
- /* NSString* name= [self.content_data[indexPath.row] valueForKey:@"name"];
|
|
|
- NSString* address= [self.content_data[indexPath.row] valueForKey:@"address"];
|
|
|
- cell.detailTextLabel.text=address;
|
|
|
- cell.textLabel.text=name;
|
|
|
-
|
|
|
- //cell.sep
|
|
|
-// [UIColor rg]*/
|
|
|
+ /* NSString* name= [self.content_data[indexPath.row] valueForKey:@"name"];
|
|
|
+ NSString* address= [self.content_data[indexPath.row] valueForKey:@"address"];
|
|
|
+ cell.detailTextLabel.text=address;
|
|
|
+ cell.textLabel.text=name;
|
|
|
+
|
|
|
+ //cell.sep
|
|
|
+ // [UIColor rg]*/
|
|
|
cell.backgroundColor = [UIColor whiteColor];
|
|
|
-// cell.separator.backgroundColor = [UIColor grayColor];
|
|
|
+ // cell.separator.backgroundColor = [UIColor grayColor];
|
|
|
return cell;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
{
|
|
|
@@ -783,8 +925,8 @@ self.label_net_err.hidden=true;
|
|
|
|
|
|
|
|
|
bool editable =[[self.content_data[indexPath.row] valueForKey:@"can_update"]boolValue] ;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
CustomerInfoViewController * vc=[[CustomerInfoViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
|
|
|
|
|
|
@@ -793,10 +935,10 @@ self.label_net_err.hidden=true;
|
|
|
vc.request_url=LOCAL_URL_CUSTOMER_INFO_EDITOR;
|
|
|
|
|
|
vc.update_order = self.update_order;
|
|
|
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
if(self.ui_type==CONTACT_LIST)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
vc.edit_icon = self.edit_icon&&editable&&appDelegate.can_update_contact_info;
|
|
|
vc.assig_icon = self.assig_icon&&(appDelegate.contact_id.length==0);
|
|
|
vc.reset_icon = self.reset_icon&&(appDelegate.contact_id.length!=0);
|
|
|
@@ -807,30 +949,30 @@ self.label_net_err.hidden=true;
|
|
|
vc.assig_icon = self.assig_icon;
|
|
|
vc.reset_icon = self.reset_icon;
|
|
|
}
|
|
|
-
|
|
|
|
|
|
-// NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
|
|
|
-// // NSString * string = [checked componentsJoinedByString:@","];
|
|
|
-// // [params setValue:string forKey:@"cart2Checkbox"];
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// addressVC.params = params;
|
|
|
+
|
|
|
+ // NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
|
|
|
+ // // NSString * string = [checked componentsJoinedByString:@","];
|
|
|
+ // // [params setValue:string forKey:@"cart2Checkbox"];
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // addressVC.params = params;
|
|
|
vc.contactId=contactid;
|
|
|
-// vc.delegate = self;
|
|
|
+ // vc.delegate = self;
|
|
|
|
|
|
vc.from = indexPath;
|
|
|
// orderinfoVC.params = params;
|
|
|
vc.returnValue = ^(NSMutableDictionary* value){
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
value[@"is_subaction"]=self.is_subaction;
|
|
|
value[@"subaction_tag"]= self.subaction_tag;
|
|
|
[self.navigationController popViewControllerAnimated:false];
|
|
|
-
|
|
|
+
|
|
|
|
|
|
if(self.returnValue)
|
|
|
self.returnValue(value,self.from);
|
|
|
@@ -839,22 +981,22 @@ self.label_net_err.hidden=true;
|
|
|
|
|
|
[self.navigationController pushViewController:vc animated:true];
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
/*
|
|
|
-#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 - 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 - searchBar delegate;
|
|
|
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
self.keywords=searchBar.text;
|
|
|
self.offset = 0;
|
|
|
[self.content_data removeAllObjects];
|
|
|
@@ -877,7 +1019,7 @@ self.label_net_err.hidden=true;
|
|
|
NSLog(@"%s removeAllObjects",__func__);
|
|
|
self.adv_search=nil;
|
|
|
[self loadpage];
|
|
|
-// [self loadpage];
|
|
|
+ // [self loadpage];
|
|
|
}
|
|
|
else
|
|
|
self.reset = false;
|