|
|
@@ -28,6 +28,7 @@
|
|
|
#import "Singleton.h"
|
|
|
#import "JKMessageBoxController.h"
|
|
|
#import "RAPDFViewController.h"
|
|
|
+#import "RAOrderEditorViewController.h"
|
|
|
|
|
|
#define ALERT_FREE 1024
|
|
|
#define ALERT_DEL 1025
|
|
|
@@ -78,6 +79,7 @@
|
|
|
{
|
|
|
[super logout];
|
|
|
[self.content_arr removeAllObjects];
|
|
|
+ self.cart_json = nil;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -425,7 +427,12 @@
|
|
|
|
|
|
NSIndexPath * indexPath = [self.itemListTable indexPathForCell:cell];
|
|
|
// DebugLog(@"shouldchangeedit %d_%d",indexPath.section,indexPath.row);
|
|
|
- NSDictionary * item_json = self.content_arr[indexPath.row];//[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
|
|
|
+ NSDictionary * item_json = nil;
|
|
|
+ if (self.back_order_flag) {
|
|
|
+ item_json = [self itemJsonAtIndexPath:indexPath];
|
|
|
+ } else {
|
|
|
+ item_json = self.content_arr[indexPath.row];//[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
|
|
|
+ }
|
|
|
|
|
|
NSString* product_id = [item_json valueForKey:@"product_id"];
|
|
|
NSString *name = [item_json valueForKey:@"model"];
|
|
|
@@ -1025,28 +1032,42 @@
|
|
|
|
|
|
*/
|
|
|
|
|
|
- NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
|
|
|
- // NSString * string = [checked componentsJoinedByString:@","];
|
|
|
- // [params setValue:string forKey:@"cart2Checkbox"];
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- CreateOrderViewController * orderinfoVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"CreateOrderViewController"];
|
|
|
-
|
|
|
- orderinfoVC.disable_dropdown_refresh=true;
|
|
|
- orderinfoVC.url_type = URL_REMOTE;
|
|
|
- orderinfoVC.request_url=URL_CARTDELIVERY;
|
|
|
-
|
|
|
- orderinfoVC.params = params;
|
|
|
-
|
|
|
- orderinfoVC.delegate=self;
|
|
|
- //
|
|
|
- // if(checked.count==count)
|
|
|
- // {
|
|
|
- // orderinfoVC.have_tail = true
|
|
|
- // }
|
|
|
-
|
|
|
- [self.navigationController pushViewController:orderinfoVC animated:true];
|
|
|
+ if (self.back_order_flag) {
|
|
|
+
|
|
|
+ NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
|
|
|
+ RAOrderEditorViewController *orderEditorVC = [self.storyboard instantiateViewControllerWithIdentifier:@"RAOrderEditorViewController"];
|
|
|
+
|
|
|
+ orderEditorVC.disable_dropdown_refresh=true;
|
|
|
+ orderEditorVC.url_type = URL_REMOTE;
|
|
|
+ orderEditorVC.request_url=URL_CARTDELIVERY;
|
|
|
+ orderEditorVC.params = params;
|
|
|
+ orderEditorVC.delegate=self;
|
|
|
+ [self.navigationController pushViewController:orderEditorVC animated:true];
|
|
|
+
|
|
|
+ } else {
|
|
|
+ NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
|
|
|
+ // NSString * string = [checked componentsJoinedByString:@","];
|
|
|
+ // [params setValue:string forKey:@"cart2Checkbox"];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ CreateOrderViewController * orderinfoVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"CreateOrderViewController"];
|
|
|
+
|
|
|
+ orderinfoVC.disable_dropdown_refresh=true;
|
|
|
+ orderinfoVC.url_type = URL_REMOTE;
|
|
|
+ orderinfoVC.request_url=URL_CARTDELIVERY;
|
|
|
+
|
|
|
+ orderinfoVC.params = params;
|
|
|
+
|
|
|
+ orderinfoVC.delegate=self;
|
|
|
+ //
|
|
|
+ // if(checked.count==count)
|
|
|
+ // {
|
|
|
+ // orderinfoVC.have_tail = true
|
|
|
+ // }
|
|
|
+
|
|
|
+ [self.navigationController pushViewController:orderinfoVC animated:true];
|
|
|
+ }
|
|
|
|
|
|
// UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:orderinfoVC] ;
|
|
|
//
|
|
|
@@ -1710,9 +1731,15 @@
|
|
|
cell.labelDiscount.hidden = false;
|
|
|
}
|
|
|
}
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
cell.onReturnQTY=^(int qty,NSDictionary* ext)
|
|
|
{
|
|
|
- NSMutableDictionary * item_json = [self.content_arr[indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
|
|
|
+ NSMutableDictionary * item_json = nil;
|
|
|
+ if (weakSelf.back_order_flag) {
|
|
|
+ item_json = [[weakSelf itemJsonAtIndexPath:indexPath] mutableCopy];
|
|
|
+ } else {
|
|
|
+ item_json = [weakSelf.content_arr[indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
|
|
|
+ }
|
|
|
|
|
|
// int count=[[item_json valueForKey:@"count"] intValue];
|
|
|
|
|
|
@@ -1730,9 +1757,14 @@
|
|
|
double unit_price = [[item_json valueForKey:@"unit_price"] doubleValue];
|
|
|
// double sub_total=[[item_json valueForKey:@"subtotal_price"] doubleValue];
|
|
|
[item_json setValue:[NSString stringWithFormat:@"%f",unit_price*qty] forKey:@"subtotal_price"];
|
|
|
- self.content_arr[indexPath.row]= item_json;
|
|
|
+
|
|
|
+ if (weakSelf.back_order_flag) {
|
|
|
+ [weakSelf updateItemJson:item_json atIndexPath:indexPath];
|
|
|
+ } else {
|
|
|
+ weakSelf.content_arr[indexPath.row]= item_json;
|
|
|
+ }
|
|
|
// [self.content_data setObject:item_json forKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
|
|
|
- [self refresh_total];
|
|
|
+ [weakSelf refresh_total];
|
|
|
};
|
|
|
// cell.delegate=self;
|
|
|
// cell.from=indexPath;
|
|
|
@@ -1989,8 +2021,13 @@
|
|
|
|
|
|
self.indexPath=indexPath;
|
|
|
|
|
|
-
|
|
|
- NSMutableDictionary * item_json = [self.content_arr[indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
|
|
|
+ NSMutableDictionary * item_json = nil;
|
|
|
+ if (self.back_order_flag) {
|
|
|
+ item_json = [[self itemJsonAtIndexPath:indexPath] mutableCopy];
|
|
|
+ } else {
|
|
|
+ item_json = [self.content_arr[indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
NSString* productID = [item_json valueForKey:@"product_id"];
|
|
|
BOOL outOfStock = [[item_json valueForKey:@"is_out_of_stock"] boolValue];
|
|
|
@@ -2078,7 +2115,13 @@
|
|
|
DebugLog(@"Wishlist click");
|
|
|
|
|
|
|
|
|
- NSMutableDictionary * item_json = [self.content_arr[indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
|
|
|
+ NSMutableDictionary * item_json = nil;
|
|
|
+ if (self.back_order_flag) {
|
|
|
+ item_json = [[self itemJsonAtIndexPath:indexPath] mutableCopy];
|
|
|
+ } else {
|
|
|
+ item_json = [self.content_arr[indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
NSString* cart_item_id = [item_json valueForKey:@"cart_item_id"];
|
|
|
[tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
|
|
|
@@ -2104,7 +2147,11 @@
|
|
|
NSString* _id =[obj_json valueForKey:@"cart_item_id"];
|
|
|
if([_id isEqualToString:cart_item_id])
|
|
|
{
|
|
|
- [self.content_arr removeObjectAtIndex:i];
|
|
|
+ if (self.back_order_flag) {
|
|
|
+ [self updateItemJson:nil atIndexPath:indexPath];
|
|
|
+ } else {
|
|
|
+ [self.content_arr removeObjectAtIndex:i];
|
|
|
+ }
|
|
|
[self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
|
|
|
appDelegate.cart_count--;
|
|
|
[appDelegate update_count_mark];
|
|
|
@@ -2191,7 +2238,13 @@
|
|
|
EditModelPriceViewController * vc =[ parentvc.storyboard instantiateViewControllerWithIdentifier:@"EditModelPriceViewController"];
|
|
|
|
|
|
|
|
|
- NSMutableDictionary * item_json = [self.content_arr[indexPath.row ] mutableCopy];// [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
|
|
|
+ NSMutableDictionary * item_json = nil;
|
|
|
+ if (self.back_order_flag) {
|
|
|
+ item_json = [[self itemJsonAtIndexPath:indexPath] mutableCopy];
|
|
|
+ } else {
|
|
|
+ item_json = [self.content_arr[indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2244,7 +2297,11 @@
|
|
|
|
|
|
[item_json setValue:[NSNumber numberWithDouble:discount ] forKey:@"discount"];
|
|
|
[item_json setValue:notes forKey:@"note"];
|
|
|
- self.content_arr[indexPath.row ] = item_json;
|
|
|
+ if (self.back_order_flag) {
|
|
|
+ [self updateItemJson:item_json atIndexPath:indexPath];
|
|
|
+ } else {
|
|
|
+ self.content_arr[indexPath.row ] = item_json;
|
|
|
+ }
|
|
|
tableView.editing = false;
|
|
|
// [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
|
|
|
// [self refresh_total];
|
|
|
@@ -2373,12 +2430,22 @@
|
|
|
ItemNotesViewController * vc =[ parentvc.storyboard instantiateViewControllerWithIdentifier:@"ItemNotesViewController"];
|
|
|
|
|
|
|
|
|
- NSMutableDictionary * item_json = [self.content_arr[indexPath.row ] mutableCopy];// [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
|
|
|
+ NSMutableDictionary * item_json = nil;
|
|
|
+ if (self.back_order_flag) {
|
|
|
+ item_json = [[self itemJsonAtIndexPath:indexPath] mutableCopy];
|
|
|
+ } else {
|
|
|
+ item_json = [self.content_arr[indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
vc.onSaveNote=^(NSString* notes){
|
|
|
[item_json setValue:notes forKey:@"note"];
|
|
|
- self.content_arr[indexPath.row ] = item_json;
|
|
|
+ if (self.back_order_flag) {
|
|
|
+ [self updateItemJson:item_json atIndexPath:indexPath];
|
|
|
+ } else {
|
|
|
+ self.content_arr[indexPath.row ] = item_json;
|
|
|
+ }
|
|
|
tableView.editing = false;
|
|
|
[tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
|
|
|
};
|
|
|
@@ -2428,7 +2495,13 @@
|
|
|
|
|
|
if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
|
|
|
{
|
|
|
- NSMutableDictionary * item_json = [self.content_arr[indexPath.row ] mutableCopy];// [[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]]
|
|
|
+ NSMutableDictionary * item_json = nil;
|
|
|
+ if (self.back_order_flag) {
|
|
|
+ item_json = [[self itemJsonAtIndexPath:indexPath] mutableCopy];
|
|
|
+ } else {
|
|
|
+ item_json = [self.content_arr[indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
|
|
|
+
|
|
|
+ }
|
|
|
NSString* product_id = [item_json valueForKey:@"product_id"];
|
|
|
|
|
|
int is_rate = [item_json[@"is_rate"] intValue];
|
|
|
@@ -2537,7 +2610,13 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:
|
|
|
if(buttonIndex!=alertView.cancelButtonIndex)
|
|
|
{
|
|
|
// [self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
|
|
|
- NSMutableDictionary * item_json = [self.content_arr[self.indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
|
|
|
+ NSMutableDictionary * item_json = nil;
|
|
|
+ if (self.back_order_flag) {
|
|
|
+ item_json = [[self itemJsonAtIndexPath:self.indexPath] mutableCopy];
|
|
|
+ } else {
|
|
|
+ item_json = [self.content_arr[self.indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]] mutableCopy];
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"cart_item_id"] intValue]];
|
|
|
|
|
|
@@ -2553,19 +2632,45 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:
|
|
|
if([[cart_json valueForKey:@"result"] intValue]==2)
|
|
|
{
|
|
|
// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
- for(int i=0;i<self.content_arr.count;i++)
|
|
|
- {
|
|
|
- NSDictionary* obj_json = self.content_arr[i];
|
|
|
- NSString* _id =[obj_json valueForKey:@"cart_item_id"];
|
|
|
- if([_id isEqualToString:ids])
|
|
|
- {
|
|
|
- [self.content_arr removeObjectAtIndex:i];
|
|
|
- // [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:self.indexPath] withRowAnimation:UITableViewRowAnimationLeft];
|
|
|
- break;
|
|
|
- // appDelegate.cart_count--;
|
|
|
- // [appDelegate update_count_mark];
|
|
|
+ if (self.back_order_flag) {
|
|
|
+
|
|
|
+ NSInteger section_count = [self sectionCount];
|
|
|
+ for (int i = 0; i < section_count; i++) {
|
|
|
+ NSInteger item_count = [self itemCountInSection:i];
|
|
|
+ BOOL ready_break = NO;
|
|
|
+
|
|
|
+ for (int j = 0; j < item_count; j++) {
|
|
|
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
|
|
|
+ NSDictionary* obj_json = [self itemJsonAtIndexPath:indexPath];
|
|
|
+ NSString* _id =[obj_json valueForKey:@"cart_item_id"];
|
|
|
+ if([_id isEqualToString:ids])
|
|
|
+ {
|
|
|
+ [self updateItemJson:nil atIndexPath:indexPath];
|
|
|
+ ready_break = YES;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ready_break) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ } else {
|
|
|
+ for(int i=0;i<self.content_arr.count;i++)
|
|
|
+ {
|
|
|
+ NSDictionary* obj_json = self.content_arr[i];
|
|
|
+ NSString* _id =[obj_json valueForKey:@"cart_item_id"];
|
|
|
+ if([_id isEqualToString:ids])
|
|
|
+ {
|
|
|
+ [self.content_arr removeObjectAtIndex:i];
|
|
|
+ // [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:self.indexPath] withRowAnimation:UITableViewRowAnimationLeft];
|
|
|
+ break;
|
|
|
+ // appDelegate.cart_count--;
|
|
|
+ // [appDelegate update_count_mark];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
[self.itemListTable reloadData];
|
|
|
[self refresh_total];
|
|
|
@@ -2625,7 +2730,12 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:
|
|
|
if(buttonIndex!=alertView.cancelButtonIndex)
|
|
|
{
|
|
|
[self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
|
|
|
- NSMutableDictionary * item_json = [self.content_arr[self.indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
|
|
|
+ NSMutableDictionary * item_json = nil;
|
|
|
+ if (self.back_order_flag) {
|
|
|
+ item_json = [[self itemJsonAtIndexPath:self.indexPath] mutableCopy];
|
|
|
+ } else {
|
|
|
+ item_json = [self.content_arr[self.indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
|
|
|
+ }
|
|
|
|
|
|
NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"cart_item_id"] intValue]];
|
|
|
|
|
|
@@ -2657,8 +2767,12 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:
|
|
|
if(buttonIndex!=alertView.cancelButtonIndex)
|
|
|
{
|
|
|
[self.itemListTable reloadRowsAtIndexPaths:@[self.indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
|
|
|
- NSMutableDictionary * item_json = [self.content_arr[self.indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
|
|
|
-
|
|
|
+ NSMutableDictionary * item_json = nil;
|
|
|
+ if (self.back_order_flag) {
|
|
|
+ item_json = [[self itemJsonAtIndexPath:self.indexPath] mutableCopy];
|
|
|
+ } else {
|
|
|
+ item_json = [self.content_arr[self.indexPath.row] mutableCopy];//[[self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)self.indexPath.row]] mutableCopy];
|
|
|
+ }
|
|
|
NSString *ids=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"cart_item_id"] intValue]];
|
|
|
|
|
|
|
|
|
@@ -2691,12 +2805,36 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:
|
|
|
{
|
|
|
int cqty=0;
|
|
|
|
|
|
- for(int i=0;i<self.content_arr.count;i++)
|
|
|
- {
|
|
|
- NSDictionary* item= self.content_arr[i];
|
|
|
- if([item[@"model"] isEqualToString:value])
|
|
|
- cqty=[item[@"count"]intValue];
|
|
|
+
|
|
|
+
|
|
|
+ if (self.back_order_flag) {
|
|
|
+
|
|
|
+ NSInteger section_count = [self sectionCount];
|
|
|
+ for (int i = 0; i < section_count; i++) {
|
|
|
+ NSInteger item_count = [self itemCountInSection:i];
|
|
|
+
|
|
|
+ for (int j = 0; j < item_count; j++) {
|
|
|
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
|
|
|
+ NSDictionary* item = [self itemJsonAtIndexPath:indexPath];
|
|
|
+ if([item[@"model"] isEqualToString:value]) {
|
|
|
+ cqty=[item[@"count"] intValue];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ for(int i=0;i<self.content_arr.count;i++)
|
|
|
+ {
|
|
|
+ NSDictionary* item= self.content_arr[i];
|
|
|
+ if([item[@"model"] isEqualToString:value])
|
|
|
+ cqty=[item[@"count"]intValue];
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
if(cqty>0)
|
|
|
{
|
|
|
|
|
|
@@ -2750,25 +2888,53 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:
|
|
|
// bool isnew=false;
|
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
// [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
|
|
|
- for(int i=0;i<self.content_arr.count;i++)
|
|
|
- {
|
|
|
- NSDictionary* obj_json = self.content_arr[i];
|
|
|
- NSString* _id =[obj_json valueForKey:@"cart_item_id"];
|
|
|
- if([_id isEqualToString:item_id])
|
|
|
- {
|
|
|
- // self.content_arr[i] = newitem;
|
|
|
-
|
|
|
+
|
|
|
+ if (self.back_order_flag) {
|
|
|
+
|
|
|
+ NSInteger section_count = [self sectionCount];
|
|
|
+ for (int i = 0; i < section_count; i++) {
|
|
|
+ NSInteger item_count = [self itemCountInSection:i];
|
|
|
+ BOOL ready_break = NO;
|
|
|
+ for (int j = 0; j < item_count; j++) {
|
|
|
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
|
|
|
+ NSDictionary* obj_json = [self itemJsonAtIndexPath:indexPath];
|
|
|
+ NSString* _id =[obj_json valueForKey:@"cart_item_id"];
|
|
|
+ if([_id isEqualToString:item_id])
|
|
|
+ {
|
|
|
+ [self updateItemJson:nil atIndexPath:indexPath];
|
|
|
+ ready_break = YES;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ready_break) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- [self.content_arr removeObjectAtIndex:i];
|
|
|
|
|
|
- break;
|
|
|
- // [self.content_arr removeObjectAtIndex:i];
|
|
|
- // [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
|
|
|
- // appDelegate.cart_count--;
|
|
|
- // [appDelegate update_count_mark];
|
|
|
}
|
|
|
|
|
|
+ } else {
|
|
|
|
|
|
+ for(int i=0;i<self.content_arr.count;i++)
|
|
|
+ {
|
|
|
+ NSDictionary* obj_json = self.content_arr[i];
|
|
|
+ NSString* _id =[obj_json valueForKey:@"cart_item_id"];
|
|
|
+ if([_id isEqualToString:item_id])
|
|
|
+ {
|
|
|
+ // self.content_arr[i] = newitem;
|
|
|
+
|
|
|
+
|
|
|
+ [self.content_arr removeObjectAtIndex:i];
|
|
|
+
|
|
|
+ break;
|
|
|
+ // [self.content_arr removeObjectAtIndex:i];
|
|
|
+ // [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
|
|
|
+ // appDelegate.cart_count--;
|
|
|
+ // [appDelegate update_count_mark];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
#ifdef OFFLINE_MODE
|
|
|
if(appDelegate.offline_mode)
|
|
|
@@ -2781,10 +2947,14 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:
|
|
|
#endif
|
|
|
{
|
|
|
|
|
|
- [self.content_arr insertObject:newitem atIndex:0];
|
|
|
-
|
|
|
- [self.itemListTable reloadData];
|
|
|
- [self refresh_total];
|
|
|
+ if (self.back_order_flag) {
|
|
|
+ [self ReloadData];
|
|
|
+ } else {
|
|
|
+ [self.content_arr insertObject:newitem atIndex:0];
|
|
|
+
|
|
|
+ [self.itemListTable reloadData];
|
|
|
+ [self refresh_total];
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -3096,6 +3266,7 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:
|
|
|
- (void) setCart_json:(NSDictionary *)cart_json {
|
|
|
_cart_json = cart_json;
|
|
|
[self fillContentArray];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (void)fillContentArray {
|
|
|
@@ -3108,6 +3279,7 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:
|
|
|
}
|
|
|
}
|
|
|
self.content_arr = arr;
|
|
|
+ [self refresh_total];
|
|
|
}
|
|
|
|
|
|
- (NSInteger)sectionCount {
|
|
|
@@ -3133,5 +3305,32 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:
|
|
|
return [section objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
|
|
|
}
|
|
|
|
|
|
+- (void)updateItemJson:(NSDictionary *)new_item_json atIndexPath:(NSIndexPath *)indexPath {
|
|
|
+
|
|
|
+ NSMutableDictionary *new_cart_json = [self.cart_json mutableCopy];
|
|
|
+ NSMutableDictionary *new_section_json = [[self jsonAtSection:indexPath.section] mutableCopy];
|
|
|
+
|
|
|
+ NSString *section_key = [NSString stringWithFormat:@"section_%ld",indexPath.section];
|
|
|
+ NSString *item_key = [NSString stringWithFormat:@"item_%ld",indexPath.row];
|
|
|
+
|
|
|
+ if (new_item_json) {
|
|
|
+ // 更新Item
|
|
|
+ [new_section_json setObject:new_item_json forKey:item_key];
|
|
|
+ } else {
|
|
|
+ // 删除Item
|
|
|
+ NSInteger item_count = [self itemCountInSection:indexPath.section];
|
|
|
+ for (NSInteger i = indexPath.row + 1; i < item_count; i++) {
|
|
|
+ item_key = [NSString stringWithFormat:@"item_%ld",i];
|
|
|
+ NSDictionary *followed_item_json = [new_section_json objectForKey:item_key];
|
|
|
+
|
|
|
+ item_key = [NSString stringWithFormat:@"item_%ld",i - 1];
|
|
|
+ [new_section_json setObject:followed_item_json forKey:item_key];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ [new_cart_json setObject:new_section_json forKey:section_key];
|
|
|
+
|
|
|
+ self.cart_json = [new_cart_json copy];
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
@end
|