Sfoglia il codice sorgente

实现方法create portfolio和add to portfolio

Pen Li 9 anni fa
parent
commit
123f9ad39b

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 16 - 0
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -13,5 +13,21 @@
             stopOnStyle = "0">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "common/data_provider/iSalesNetwork.m"
+            timestampString = "498379632.529538"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "1337"
+            endingLineNumber = "1337"
+            landmarkName = "+request_Editor:params:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 6 - 6
RedAnt ERP Mobile/common/Functions/category/CategoryViewController.m

@@ -713,12 +713,12 @@
 -(void) addtoportfolio
 {
     
-    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-    if (appDelegate.offline_mode) {
-        
-        [RAUtils message_alert:@"offline mode does not support this function." title:@"Add to Portfolio" controller:self] ;
-        return;
-    }
+//    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+//    if (appDelegate.offline_mode) {
+//        
+//        [RAUtils message_alert:@"offline mode does not support this function." title:@"Add to Portfolio" controller:self] ;
+//        return;
+//    }
     
     NSMutableDictionary* items =[[self.category_data objectForKey:@"items"] mutableCopy];
     

+ 4 - 0
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.h

@@ -98,8 +98,12 @@
 
 + (NSData *)offline_portfolioList:(NSMutableDictionary *)params;
 
++ (NSData *)offline_createTearSheet:(NSMutableDictionary *)params;
+
 + (NSData *)offline_direct_save_TearSheet:(NSMutableDictionary *)params;
 
 + (NSData *)offline_pdfList:(NSMutableDictionary *)params;
 
++ (NSData *)offline_add2Portfolio:(NSMutableDictionary *)params;
+
 @end

+ 67 - 48
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -9627,28 +9627,6 @@
 
 + (NSData *)offline_portfolioList:(NSMutableDictionary *)params {
     
-//    {
-//        "result": 2,
-//        "min_ver": "160514",
-//        "count": 1,
-//        "can_see_price": true,
-//        "item_0": {
-//            "linenotes": "恢复肌肤就不会就附近",
-//            "check": 1,
-//            "product_id": "3732",
-//            "available_qty": 787,
-//            "description": "108237-SH-B\nCharlotte Fabric Chair Black Legs, Shark",
-//            "item_id": "13405",
-//            "fashion_id": "4858",
-//            "img": "http://192.168.0.112:8080/site//u/NPD/20151211/108237-SH-B_2916_s.jpg",
-//            "tear_sheet_discount": "20.00",
-//            "tear_sheet_price": "3109.00"
-//        },
-//        "email_content": "",
-//        "total_count": 1,
-//        "mode": "Regular Mode"
-//    }
-    
     int sort = [[params valueForKey:@"sort"] integerValue];
     int offset = [[params valueForKey:@"offset"] integerValue];
     int limit = [[params valueForKey:@"limit"] integerValue];
@@ -9680,11 +9658,15 @@
             break;
     }
     
-    NSString *sql = [NSString stringWithFormat:@"select product_id,name,description,sheet_price,sheet_discount,available_qty,percentage,item_id,fashion_id,img,line_note,percent from offline_portfolio order by %@ limit %d offset %d;",orderBy,limit,offset];
+    
+    NSString *sql = [NSString stringWithFormat:@"select product_id,name,description,ifnull(sheet_price,'null'),sheet_discount,available_qty,percentage,item_id,fashion_id,img,line_note,percent from offline_portfolio order by %@ limit %d offset %d;",orderBy,limit,offset];
     
     __block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
     
-    [iSalesDB jk_query:sql completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    
+    sqlite3 *db = [iSalesDB get_db];
+    NSDictionary *resultDic = [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
         
         [dic setValue:[NSNumber numberWithInteger:RESULT_TRUE] forKey:@"result"];
         
@@ -9702,19 +9684,24 @@
         NSString *line_note = [self textAtColumn:10 statement:stmt];
         double percent = sqlite3_column_double(stmt, 11);
         
+        NSString *price_null = [self textAtColumn:3 statement:stmt];
+        if ([price_null isEqualToString:@"null"]) {
+            price = [[self get_model_default_price:appDelegate.contact_id product_id:nil item_id:@(item_id) db:db] doubleValue];
+        }
+        
         NSMutableDictionary *item = @{
-                                @"linenotes": line_note,
-                                @"check": @(1),
-                                @"product_id": product_id_string,
-                                @"available_qty": @(qty),
-                                @"available_percent" : @(percent),
-                                @"description": description,
-                                @"item_id": [NSString stringWithFormat:@"%d",item_id],
-                                @"fashion_id": [NSString stringWithFormat:@"%d",fashion_id],
-                                @"img": img_path,
-                                @"tear_sheet_discount": [NSString stringWithFormat:@"%f",discount],
-                                @"tear_sheet_price": [NSString stringWithFormat:@"%f",price]
-                                }.mutableCopy;
+                                      @"linenotes": line_note,
+                                      @"check": @(1),
+                                      @"product_id": product_id_string,
+                                      @"available_qty": @(qty),
+                                      @"available_percent" : @(percent),
+                                      @"description": [NSString stringWithFormat:@"%@\n%@",name,description],
+                                      @"item_id": [NSString stringWithFormat:@"%d",item_id],
+                                      @"fashion_id": [NSString stringWithFormat:@"%d",fashion_id],
+                                      @"img": img_path,
+                                      @"tear_sheet_discount": [NSString stringWithFormat:@"%f",discount],
+                                      @"tear_sheet_price": [NSString stringWithFormat:@"%f",price]
+                                      }.mutableCopy;
         if (percentage) {
             [item removeObjectForKey:@"available_qty"];
         } else {
@@ -9725,17 +9712,20 @@
         [dic setObject:item forKey:[NSString stringWithFormat:@"item_%ld",*count]];
         [dic setValue:[NSNumber numberWithLong:++(*count)] forKey:@"count"];
         
-    } failure:^(NSMutableDictionary *container, NSString *err_msg) {
-        
+    }];
+    
+    if ([[resultDic objectForKey:@"result"] integerValue] == RESULT_FALSE) {
         [dic setValue:[NSNumber numberWithInteger:RESULT_FALSE] forKey:@"result"];
         
         [dic setValue:[NSNumber numberWithInteger:0] forKey:@"count"];
-    }];
+    }
+    
+    [iSalesDB close_db:db];
+    
     
-    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
     
     [dic setValue:[NSNumber numberWithBool:appDelegate.can_see_price] forKey:@"can_see_price"];
-    [dic setValue:@"" forKey:@"emial_content"];
+    [dic setValue:@"" forKey:@"email_content"];
     [dic setValue:[dic objectForKey:@"count"] forKey:@"total_count"];
     [dic setValue:@"Regular Mode" forKey:@"mode"];
     
@@ -9744,12 +9734,6 @@
 
 + (NSData *)offline_direct_save_TearSheet:(NSMutableDictionary *)params {
     
-    
-    
-    
-    
-    
-    
     return nil;
 }
 
@@ -9764,7 +9748,7 @@
         
     }
     
-    NSString *sql = [NSString stringWithFormat:@"select tear_name,tear_note,createtime,create_user,pdf_path,tearsheets_id from offline_pdf %@ order by createtime desc;",where];
+    NSString *sql = [NSString stringWithFormat:@"select tear_name,tear_note,createtime,create_user,pdf_path,tearsheets_id from offline_pdf %@ order by createtime desc limit %d offset %d;",where,limit,offset];
     
     __block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
     
@@ -9806,4 +9790,39 @@
     return [RAUtils dict2data:dic];
 }
 
++ (NSData *)offline_add2Portfolio:(NSMutableDictionary *)params {
+    
+    NSString *prodct_ids = [params objectForKey:@"product_id"];
+//    NSString *user = [params objectForKey:@"user"];
+    NSString *sql = [NSString stringWithFormat:@"insert into offline_portfolio (product_id,name,description,item_id,img) select * from (select p.product_id,p.name,p.description,p.item_id,i.url from product as p left join model_image as i on i.product_id = p.product_id  where p.product_id in (%@) and p.product_id not in (select product_id from offline_portfolio) and i.type = 1  group by  p.product_id order by i.default_img desc, i._id asc );",prodct_ids];
+    
+    int result = [iSalesDB execSql:sql];
+    
+    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
+    [dic setValue:[NSNumber numberWithInteger:result] forKey:@"result"];
+    
+    if (result == RESULT_TRUE) {
+        NSArray *product_id_arr = [prodct_ids componentsSeparatedByString:@","];
+        [dic setValue:[NSNumber numberWithInteger:product_id_arr.count] forKey:@"portfolio_count"];
+    }
+    
+    [dic setValue:@"Regular Mode" forKey:@"mode"];
+    return [RAUtils dict2data:dic];
+}
+
++ (NSData *)offline_createTearSheet:(NSMutableDictionary *)params {
+    
+    
+//    {
+//        "item_ids" = "249,3859,5360,2662";
+//        password = 123456;
+//        "product_ids" = "3321,3804,4045,3732";
+//        user = EvanK;
+//    }
+    
+    NSMutableDictionary *dic = [self dictionaryFileName:@"TearSheet.json"];
+    
+    return [RAUtils dict2data:dic];
+}
+
 @end

+ 6 - 6
RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchViewController.m

@@ -1118,12 +1118,12 @@
 -(void) addtoportfolio
 {
     
-    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-    if (appDelegate.offline_mode) {
-        
-        [RAUtils message_alert:@"offline mode does not support this function." title:@"Add to Portfolio" controller:self] ;
-        return;
-    }
+//    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+//    if (appDelegate.offline_mode) {
+//        
+//        [RAUtils message_alert:@"offline mode does not support this function." title:@"Add to Portfolio" controller:self] ;
+//        return;
+//    }
     
     
     NSMutableDictionary* items =[[self.category_data objectForKey:@"items"] mutableCopy];

+ 6 - 6
RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m

@@ -934,12 +934,12 @@
 -(void) addtoportfolio
 {
     
-    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-    if (appDelegate.offline_mode) {
-        
-        [RAUtils message_alert:@"offline mode does not support this function." title:@"Add to Portfolio" controller:self] ;
-        return;
-    }
+//    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+//    if (appDelegate.offline_mode) {
+//        
+//        [RAUtils message_alert:@"offline mode does not support this function." title:@"Add to Portfolio" controller:self] ;
+//        return;
+//    }
     
     NSMutableDictionary* items =[[self.category_data objectForKey:@"items"] mutableCopy];
     

+ 4 - 1
RedAnt ERP Mobile/common/data_provider/iSalesDB.m

@@ -1182,9 +1182,12 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
         while (sqlite3_step(statement) == SQLITE_ROW) {
             block(statement,dic,&count);
         }
-        
+        [dic setObject:[NSNumber numberWithInteger:RESULT_TRUE] forKey:@"result"];
         sqlite3_finalize(statement);
+    } else {
+        [dic setObject:[NSNumber numberWithInteger:RESULT_FALSE] forKey:@"result"];
     }
+
     
     if (close) {
         [iSalesDB close_db:db];

+ 11 - 4
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m

@@ -1322,6 +1322,9 @@ repeat:
         {
             json= [OLDataProvider offline_addreditor:params];
         }
+        else if ([request_url isEqualToString:URL_DM_PARAMS]){
+            json = [OLDataProvider offline_createTearSheet:params];
+        }
         
         else
             return [OLDataProvider offline_notimpl];
@@ -1482,7 +1485,7 @@ repeat:
     
     if(appDelegate.offline_mode)
     {
-        json = [OLDataProvider offline_direct_save_TearSheet:params];
+        return [OLDataProvider offline_notimpl];
     }
     else
     {
@@ -1946,14 +1949,18 @@ repeat:
         [params setValue:appDelegate.password forKey:@"password"];
     
     [params setValue:item_id forKey:@"product_id"];
+    
+    NSData* json = nil;
     if(appDelegate.offline_mode)
     {
-        return [OLDataProvider offline_notimpl];
-    }
+        json = [OLDataProvider offline_add2Portfolio:params];
+    } else {
     if(![self IsNetworkAvailable])
         return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
     
-    NSData* json=[self get_json:URL_ADD_TO_PORTFOLIO parameters:params];
+        json=[self get_json:URL_ADD_TO_PORTFOLIO parameters:params];
+    }
+    
     if(json==nil)
         return nil;
     NSError *error=nil;

+ 4 - 0
RedAnt ERP Mobile/iSales-NPD.xcodeproj/project.pbxproj

@@ -26,6 +26,7 @@
 		42BED01B1DAF74DF004576E0 /* JKDotView.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BED0161DAF74DF004576E0 /* JKDotView.m */; };
 		42BED01C1DAF74DF004576E0 /* JKLockButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BED0181DAF74DF004576E0 /* JKLockButton.m */; };
 		42BED01D1DAF74DF004576E0 /* JKLockController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BED01A1DAF74DF004576E0 /* JKLockController.m */; };
+		42C2E8BC1DB49D02006C0495 /* TearSheet.json in Resources */ = {isa = PBXBuildFile; fileRef = 42C2E8BB1DB49D02006C0495 /* TearSheet.json */; };
 		42C9FB151D5B28FA001DCA8B /* contactAdvanceSearch.json in Resources */ = {isa = PBXBuildFile; fileRef = 42C9FB141D5B28FA001DCA8B /* contactAdvanceSearch.json */; };
 		42DC31131D546FBE00BCD1C6 /* category.json in Resources */ = {isa = PBXBuildFile; fileRef = 42DC31121D546FBE00BCD1C6 /* category.json */; };
 		42E58BFB1D7E5EF50092810A /* SortButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 42E58BFA1D7E5EF50092810A /* SortButton.m */; };
@@ -248,6 +249,7 @@
 		42BED0181DAF74DF004576E0 /* JKLockButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JKLockButton.m; sourceTree = "<group>"; };
 		42BED0191DAF74DF004576E0 /* JKLockController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JKLockController.h; sourceTree = "<group>"; };
 		42BED01A1DAF74DF004576E0 /* JKLockController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JKLockController.m; sourceTree = "<group>"; };
+		42C2E8BB1DB49D02006C0495 /* TearSheet.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = TearSheet.json; sourceTree = "<group>"; };
 		42C9FB141D5B28FA001DCA8B /* contactAdvanceSearch.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = contactAdvanceSearch.json; sourceTree = "<group>"; };
 		42DC31121D546FBE00BCD1C6 /* category.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = category.json; sourceTree = "<group>"; };
 		42E58BF91D7E5EF50092810A /* SortButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortButton.h; sourceTree = "<group>"; };
@@ -937,6 +939,7 @@
 				42A51BF31D62F60300F13667 /* more_info.html */,
 				42B3C9BA1D642C880053985C /* order_info.html */,
 				42A225321D6E7D1D00235B62 /* placeOrderTemplate.json */,
+				42C2E8BB1DB49D02006C0495 /* TearSheet.json */,
 			);
 			name = utils;
 			sourceTree = "<group>";
@@ -1413,6 +1416,7 @@
 				7162A55F1C58724700AB630E /* customer_info_template.json in Resources */,
 				71D46D111CE1D9EF00A081AC /* OLM.storyboard in Resources */,
 				423B49EF1DAC8071004181C2 /* CUL.storyboard in Resources */,
+				42C2E8BC1DB49D02006C0495 /* TearSheet.json in Resources */,
 				42B3C9BB1D642C880053985C /* order_info.html in Resources */,
 				42A225331D6E7D1D00235B62 /* placeOrderTemplate.json in Resources */,
 				7141DD3D1C5726B700F7DF59 /* softScanBeep.wav in Resources */,

+ 215 - 0
RedAnt ERP Mobile/iSales-NPD/TearSheet.json

@@ -0,0 +1,215 @@
+{
+	"section_0": {
+		"title": "General Information",
+		"count": 8,
+		"item_1": {
+			"control": "edit",
+			"keyboard": "text",
+			"name": "catalog_name",
+			"value": "",
+			"required": "true",
+			"aname": "Portfolio Name"
+		},
+		"item_0": {
+			"control": "text",
+			"keyboard": "text",
+			"name": "company_name",
+			"value": "New Pacific Direct,Inc.",
+			"aname": "Company Name"
+		},
+		"item_3": {
+			"control": "switch",
+			"name": "show_stockout",
+			"value": "true",
+			"aname": "Display out of stock"
+		},
+		"item_2": {
+			"control": "edit",
+			"keyboard": "text_view",
+			"name": "internal_note",
+			"value": "",
+			"aname": "Notes"
+		},
+		"item_5": {
+			"control": "switch",
+			"name": "remove_item",
+			"value": "false",
+			"aname": "Remove models from list after creating portfolio"
+		},
+		"item_4": {
+			"control": "switch",
+			"name": "show_line_note",
+			"value": "true",
+			"aname": "Show Line Note"
+		},
+		"item_7": {
+			"control": "enum",
+			"name": "pdf_style",
+			"cadedate": {
+				"count": 2,
+				"val_1": {
+					"value": "3X2(Landscape)",
+					"value_id": 1
+				},
+				"val_0": {
+					"check": 1,
+					"value": "2X3(Portrait)",
+					"value_id": 0
+				}
+			},
+			"single_select": "true",
+			"aname": "PDF Style"
+		},
+		"item_6": {
+			"control": "switch",
+			"name": "show_barcode",
+			"value": "false",
+			"aname": "Show 2D barcode"
+		}
+	},
+	"result": 2,
+	"section_1": {
+		"count": 18,
+		"item_17": {
+			"control": "switch",
+			"name": "made",
+			"value": "false",
+			"aname": "Made in"
+		},
+		"item_15": {
+			"control": "switch",
+			"name": "fabric_content",
+			"value": "false",
+			"aname": "Fabric Content"
+		},
+		"item_16": {
+			"control": "switch",
+			"name": "assembling",
+			"value": "false",
+			"aname": "Assembling"
+		},
+		"title": "Show Fields",
+		"item_1": {
+			"control": "switch",
+			"name": "description",
+			"value": "true",
+			"aname": "Description"
+		},
+		"item_0": {
+			"control": "switch",
+			"name": "model_name",
+			"value": "true",
+			"aname": "Item#"
+		},
+		"item_3": {
+			"control": "switch",
+			"name": "entered_price",
+			"value": "false",
+			"aname": "Show Entered Price"
+		},
+		"item_2": {
+			"control": "enum",
+			"name": "regular_price",
+			"cadedate": {
+				"count": 6,
+				"val_1": {
+					"value": "West Wholesale Price",
+					"value_id": 17
+				},
+				"val_0": {
+					"check": 1,
+					"value": "West Dealer Price",
+					"value_id": 16
+				},
+				"val_3": {
+					"value": "East Wholesale Price",
+					"value_id": 15
+				},
+				"val_2": {
+					"value": "East Dealer Price",
+					"value_id": 14
+				},
+				"val_5": {
+					"value": "None",
+					"value_id": 0
+				},
+				"val_4": {
+					"value": "Container",
+					"value_id": 13
+				}
+			},
+			"single_select": "true",
+			"aname": "Regular Price"
+		},
+		"item_14": {
+			"control": "switch",
+			"name": "load_ability",
+			"value": "false",
+			"aname": "Load Ability"
+		},
+		"item_5": {
+			"control": "switch",
+			"name": "leg_color",
+			"value": "true",
+			"aname": "Leg Color"
+		},
+		"item_13": {
+			"control": "switch",
+			"name": "set",
+			"value": "false",
+			"aname": "Set"
+		},
+		"item_4": {
+			"control": "switch",
+			"name": "color",
+			"value": "true",
+			"aname": "Color"
+		},
+		"item_12": {
+			"control": "switch",
+			"name": "weight",
+			"value": "false",
+			"aname": "Weight"
+		},
+		"item_7": {
+			"control": "switch",
+			"name": "dimension",
+			"value": "true",
+			"aname": "Dimensions"
+		},
+		"item_11": {
+			"control": "switch",
+			"name": "volume",
+			"value": "true",
+			"aname": "Volume"
+		},
+		"item_6": {
+			"control": "switch",
+			"name": "availability",
+			"value": "false",
+			"aname": "Availability"
+		},
+		"item_9": {
+			"control": "switch",
+			"name": "material",
+			"value": "false",
+			"aname": "Material"
+		},
+		"item_10": {
+			"control": "switch",
+			"name": "box_dimension",
+			"value": "false",
+			"aname": "Box Dimensions"
+		},
+		"item_8": {
+			"control": "switch",
+			"name": "seat_height",
+			"value": "false",
+			"aname": "Seat Height"
+		}
+	},
+	"section_count": 2,
+	"title": "Portfolio Product Information",
+	"pdf_url": "",
+	"mode": "Regular Mode"
+}