|
@@ -1464,11 +1464,95 @@
|
|
|
}];
|
|
}];
|
|
|
add2MergeListAction.backgroundColor = UIColorFromRGB(0x336699);
|
|
add2MergeListAction.backgroundColor = UIColorFromRGB(0x336699);
|
|
|
|
|
|
|
|
- if (![Singleton sharedInstance].permissions_merge_order) {
|
|
|
|
|
- // 没有合并订单的权限
|
|
|
|
|
- return @[];
|
|
|
|
|
|
|
+ // Cancel Order Action
|
|
|
|
|
+ UITableViewRowAction *cancelAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Cancel Order"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
|
|
|
|
|
+
|
|
|
|
|
+ NSLog(@"edit click");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSString * title =[NSString stringWithFormat:@"Are you sure to cancel order SO#: %@",so];
|
|
|
|
|
+
|
|
|
|
|
+ UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
|
|
|
|
|
+
|
|
|
|
|
+ UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Cancel Order"];
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
+
|
|
|
|
|
+ NSDictionary* return_json = [iSalesNetwork cancel_Order:orderid order_code:nil];
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if([[return_json valueForKey:@"result"] intValue]==2)
|
|
|
|
|
+ {
|
|
|
|
|
+ if([appDelegate.order_code isEqualToString: [self.content_data[indexPath.row] valueForKey:@"order_code"]])
|
|
|
|
|
+ {
|
|
|
|
|
+ appDelegate.order_code= nil;
|
|
|
|
|
+ //appDelegate.user_type = 0;
|
|
|
|
|
+ appDelegate.customerInfo = nil;
|
|
|
|
|
+ appDelegate.contact_id = nil;
|
|
|
|
|
+ appDelegate.order_customer_id = nil;
|
|
|
|
|
+ [appDelegate SetSo:nil];
|
|
|
|
|
+ appDelegate.cart_count=0;
|
|
|
|
|
+ [appDelegate update_count_mark];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ [RAUtils message_alert:nil title:@"Order Canceled" controller:self] ;
|
|
|
|
|
+ [self ReloadData];
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Cancel Order" controller:self] ;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+
|
|
|
|
|
+ UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
|
|
|
|
+ NSLog(@"Cancel");
|
|
|
|
|
+ }];
|
|
|
|
|
+ [alertControl addAction:actionOne];
|
|
|
|
|
+
|
|
|
|
|
+ [alertControl addAction:alertthree];
|
|
|
|
|
+
|
|
|
|
|
+ //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [self presentViewController:alertControl animated:YES completion:nil];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ cancelAction.backgroundColor = UIColorFromRGB(0xff9933);
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableArray *actionArr = [NSMutableArray array];
|
|
|
|
|
+ // 取消订单
|
|
|
|
|
+ if([order_status isEqualToString:@"Saved Order"]&&appDelegate.can_cancel_order)
|
|
|
|
|
+ [actionArr addObject:cancelAction];
|
|
|
|
|
+
|
|
|
|
|
+ if ([Singleton sharedInstance].permissions_merge_order) {// 有合并订单的权限
|
|
|
|
|
+ if (self.orderType == 0) {// Sales Order不能合并
|
|
|
|
|
+ [actionArr addObject:add2MergeListAction];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
- return @[add2MergeListAction];
|
|
|
|
|
|
|
+ return actionArr;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return @[];
|
|
return @[];
|
|
@@ -1477,21 +1561,25 @@
|
|
|
|
|
|
|
|
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
|
|
|
|
|
+ if(indexPath.row==self.content_data.count)
|
|
|
|
|
+ return NO;
|
|
|
|
|
+
|
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+ NSString* order_status= [self.content_data[indexPath.row] valueForKey:@"order_status"];
|
|
|
|
|
+
|
|
|
if(appDelegate.user_type==USER_ROLE_CUSTOMER) {
|
|
if(appDelegate.user_type==USER_ROLE_CUSTOMER) {
|
|
|
- if (self.orderType == 1) {// Sales Order不能合并
|
|
|
|
|
- return NO;
|
|
|
|
|
- }
|
|
|
|
|
- if (![Singleton sharedInstance].permissions_merge_order) {
|
|
|
|
|
- // 没有合并订单的权限
|
|
|
|
|
- return NO;
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ // saved && ((type==0 && merge_permission) || type == 1 || can_cancel)
|
|
|
|
|
+ if ([order_status isEqualToString:@"Saved Order"] && (([Singleton sharedInstance].permissions_merge_order && self.orderType == 0) || self.orderType == 1 || appDelegate.can_cancel_order)) {
|
|
|
|
|
+ NSLog(@"%d Yes",indexPath.row);
|
|
|
return YES;
|
|
return YES;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return NO;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
return YES;
|
|
return YES;
|
|
|
}
|
|
}
|
|
|
|
|
+ return YES;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)tableView:(UITableView *)tableView
|
|
- (void)tableView:(UITableView *)tableView
|