|
@@ -7485,6 +7485,299 @@
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
++ (NSDictionary *)offline_getStateByCountryCode:(NSString *)countryCode checkedState:(NSString *)state_code db:(sqlite3 *)db {
|
|
|
|
|
+ countryCode = [self translateSingleQuote:countryCode];
|
|
|
|
|
+ NSString *sqlQuery = [NSString stringWithFormat:@"select _id,name,code,country_code from offline_state where country_code = '%@';",countryCode];
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary *ret = [[iSalesDB jk_query:sqlQuery db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
|
|
+
|
|
|
|
|
+ char *name = (char *) sqlite3_column_text(stmt, 1); // value
|
|
|
|
|
+ char *code = (char *) sqlite3_column_text(stmt, 2); // value_id
|
|
|
|
|
+
|
|
|
|
|
+ if (name == NULL) {
|
|
|
|
|
+ name = "";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (code == NULL) {
|
|
|
|
|
+ code = "";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary *stateDic = [NSMutableDictionary dictionaryWithCapacity:2];
|
|
|
|
|
+ [stateDic setValue:[NSString stringWithUTF8String:name] forKey:@"value"];
|
|
|
|
|
+ [stateDic setValue:[NSString stringWithUTF8String:code] forKey:@"value_id"];
|
|
|
|
|
+ [stateDic setValue:[NSNumber numberWithInt:0] forKey:@"check"];
|
|
|
|
|
+
|
|
|
|
|
+ if (state_code && [[NSString stringWithUTF8String:code] isEqualToString:state_code]) {
|
|
|
|
|
+ [stateDic setValue:[NSNumber numberWithInt:1] forKey:@"check"];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ NSString *key = [NSString stringWithFormat:@"val_%ld",(*count)++];
|
|
|
|
|
+ [container setValue:stateDic forKey:key];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }] mutableCopy];
|
|
|
|
|
+
|
|
|
|
|
+ // failure 可以不用了,一样的
|
|
|
|
|
+ if (ret.allKeys.count == 0) {
|
|
|
|
|
+ NSMutableDictionary *stateDic = [NSMutableDictionary dictionaryWithCapacity:2];
|
|
|
|
|
+ [stateDic setValue:@"Other" forKey:@"value"];
|
|
|
|
|
+ [stateDic setValue:@"" forKey:@"value_id"];
|
|
|
|
|
+ [stateDic setValue:[NSNumber numberWithInt:0] forKey:@"check"];
|
|
|
|
|
+
|
|
|
|
|
+ if (state_code && [@"" isEqualToString:state_code]) {
|
|
|
|
|
+ [stateDic setValue:[NSNumber numberWithInt:1] forKey:@"check"];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ NSString *key = [NSString stringWithFormat:@"val_0"];
|
|
|
|
|
+ [ret setValue:stateDic forKey:key];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ [ret setValue:[NSNumber numberWithInt:ret.allKeys.count] forKey:@"count"];
|
|
|
|
|
+
|
|
|
|
|
+ return ret;
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++ (NSDictionary *)paymentInfoDic:(NSDictionary *)params db:(sqlite3 *)db {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSString *orderCode = [self valueInParams:params key:@"orderCode"];
|
|
|
|
|
+ orderCode = [self translateSingleQuote:orderCode];
|
|
|
|
|
+
|
|
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select paymentType,credit_card_first_name,credit_card_last_name,credit_card_address1,credit_card_address2,credit_card_zipcode,credit_card_type,decrypt(credit_card_number),decrypt(credit_card_security_code),decrypt(credit_card_expiration_month),decrypt(credit_card_expiration_year),credit_card_city,credit_card_state from offline_order where so_id = '%@';",orderCode];
|
|
|
|
|
+
|
|
|
|
|
+ __block NSString *payType = @"";
|
|
|
|
|
+ __block NSString *firstName = @"";
|
|
|
|
|
+ __block NSString *lastName = @"";
|
|
|
|
|
+ __block NSString *addr1 = @"";
|
|
|
|
|
+ __block NSString *addr2 = @"";
|
|
|
|
|
+ __block NSString *zipcode = @"";
|
|
|
|
|
+ __block NSString *cardType = @"";
|
|
|
|
|
+ __block NSString *cardNumber = @"";
|
|
|
|
|
+ __block NSString *securityCode = @"";
|
|
|
|
|
+ __block NSString *month = @"";
|
|
|
|
|
+ __block NSString *year = @"";
|
|
|
|
|
+ __block NSString *city = @"";
|
|
|
|
|
+ __block NSString *state = @"";
|
|
|
|
|
+ [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
|
|
+
|
|
|
|
|
+ payType = [self textAtColumn:0 statement:stmt];
|
|
|
|
|
+ firstName = [self textAtColumn:1 statement:stmt];
|
|
|
|
|
+ lastName = [self textAtColumn:2 statement:stmt];
|
|
|
|
|
+ addr1 = [self textAtColumn:3 statement:stmt];
|
|
|
|
|
+ addr2 = [self textAtColumn:4 statement:stmt];
|
|
|
|
|
+ zipcode = [self textAtColumn:5 statement:stmt];
|
|
|
|
|
+ cardType = [self textAtColumn:6 statement:stmt];
|
|
|
|
|
+ cardNumber = [self textAtColumn:7 statement:stmt];
|
|
|
|
|
+ securityCode = [self textAtColumn:8 statement:stmt];
|
|
|
|
|
+ month = [self textAtColumn:9 statement:stmt];
|
|
|
|
|
+ year = [self textAtColumn:10 statement:stmt];
|
|
|
|
|
+ city = [self textAtColumn:11 statement:stmt];
|
|
|
|
|
+ state = [self textAtColumn:12 statement:stmt];
|
|
|
|
|
+ }];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // "section_2"
|
|
|
|
|
+ NSDictionary *dic = @{
|
|
|
|
|
+ @"count" : @(1),
|
|
|
|
|
+ @"item_0" : @{
|
|
|
|
|
+ @"aname" : @"Payment",
|
|
|
|
|
+ @"cadedate" : @{
|
|
|
|
|
+ @"count" : @(6),
|
|
|
|
|
+ @"val_0" : @{
|
|
|
|
|
+ @"check" : [payType isEqualToString:@"Check"] ? @(1) : @(0),
|
|
|
|
|
+ @"value" : @"Check",
|
|
|
|
|
+ @"value_id" : @"Check"
|
|
|
|
|
+ },
|
|
|
|
|
+ @"val_1" : @{
|
|
|
|
|
+ @"check" : [payType isEqualToString:@"Cash"] ? @(1) : @(0),
|
|
|
|
|
+ @"value" : @"Cash",
|
|
|
|
|
+ @"value_id" : @"Cash"
|
|
|
|
|
+ },
|
|
|
|
|
+ @"val_2" : @{
|
|
|
|
|
+ @"check" : [payType isEqualToString:@"NET 30"] ? @(1) : @(0),
|
|
|
|
|
+ @"value" : @"NET 30",
|
|
|
|
|
+ @"value_id" : @"NET 30"
|
|
|
|
|
+ },
|
|
|
|
|
+ @"val_3" : @{
|
|
|
|
|
+ @"check" : [payType isEqualToString:@"Wire Transfer"] ? @(1) : @(0),
|
|
|
|
|
+ @"value" : @"Wire Transfer",
|
|
|
|
|
+ @"value_id" : @"Wire Transfer"
|
|
|
|
|
+ },
|
|
|
|
|
+ @"val_4" : @{
|
|
|
|
|
+ @"check" : [payType isEqualToString:@"Credit Card"] ? @(1) : @(0),
|
|
|
|
|
+ @"sub_item" : @{
|
|
|
|
|
+ @"count" : @(3),
|
|
|
|
|
+ @"item_0" : @{
|
|
|
|
|
+ @"aname" : @"choose",
|
|
|
|
|
+ @"control" : @"multi_action",
|
|
|
|
|
+ @"count" : @(1),
|
|
|
|
|
+ @"item_0" : @{
|
|
|
|
|
+ @"aname" : @"Same as customer",
|
|
|
|
|
+ @"key_map" : @{
|
|
|
|
|
+ @"credit_card_address1" : @"customer_address1",
|
|
|
|
|
+ @"credit_card_address2" : @"customer_address2",
|
|
|
|
|
+ @"credit_card_city" : @"customer_city",
|
|
|
|
|
+ @"credit_card_first_name" : @"customer_first_name",
|
|
|
|
|
+ @"credit_card_last_name" : @"customer_last_name",
|
|
|
|
|
+ @"credit_card_state" : @"customer_state",
|
|
|
|
|
+ @"credit_card_zipcode" : @"customer_zipcode"
|
|
|
|
|
+ },
|
|
|
|
|
+ @"type" : @"pull"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ @"item_1" : @{
|
|
|
|
|
+ @"aname" : @"",
|
|
|
|
|
+ @"color" : @"red",
|
|
|
|
|
+ @"control" : @"text",
|
|
|
|
|
+ @"name" : @"",
|
|
|
|
|
+ @"value" : @"USA Credit cards only"
|
|
|
|
|
+ },
|
|
|
|
|
+ @"item_2" : @{
|
|
|
|
|
+ @"aname" : @"Fill",
|
|
|
|
|
+ @"cadedate" : @{
|
|
|
|
|
+ @"count" : @(2),
|
|
|
|
|
+ @"val_0" : @{
|
|
|
|
|
+ @"check" : @(1),
|
|
|
|
|
+ @"sub_item" : @{
|
|
|
|
|
+ @"count" : @(11),
|
|
|
|
|
+ @"item_0" : @{
|
|
|
|
|
+ @"aname" : @"Type",
|
|
|
|
|
+ @"cadedate" : @{
|
|
|
|
|
+ @"count" : @(2),
|
|
|
|
|
+ @"val_0" : @{
|
|
|
|
|
+ @"check" : [cardType isEqualToString:@"VISA"] ? @(1) : @(0),
|
|
|
|
|
+ @"value" : @"VISA",
|
|
|
|
|
+ @"value_id" : @(0)
|
|
|
|
|
+ },
|
|
|
|
|
+ @"val_1" : @{
|
|
|
|
|
+ @"check" : [cardType isEqualToString:@"MASTER CARD"] ? @(1) : @(0),
|
|
|
|
|
+ @"value" : @"MASTER CARD",
|
|
|
|
|
+ @"value_id" : @(1)
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ @"control" : @"enum",
|
|
|
|
|
+ @"name" : @"credit_card_type",
|
|
|
|
|
+ @"required" : @"true",
|
|
|
|
|
+ @"single_select" : @"true"
|
|
|
|
|
+ },
|
|
|
|
|
+ @"item_1" : @{
|
|
|
|
|
+ @"aname" : @"Number",
|
|
|
|
|
+ @"control" : @"edit",
|
|
|
|
|
+ @"keyboard" : @"int",
|
|
|
|
|
+ @"length" : @"16",
|
|
|
|
|
+ @"name" : @"credit_card_number",
|
|
|
|
|
+ @"required" : @"true",
|
|
|
|
|
+ @"value" : cardNumber
|
|
|
|
|
+ },
|
|
|
|
|
+ @"item_10" : @{
|
|
|
|
|
+ @"aname" : @"State",
|
|
|
|
|
+ @"cadedate" : [self offline_getStateByCountryCode:@"US" checkedState:state db:db],
|
|
|
|
|
+ @"control" : @"enum",
|
|
|
|
|
+ @"enum" : @"true",
|
|
|
|
|
+ @"name" : @"credit_card_state",
|
|
|
|
|
+ @"required" : @"true",
|
|
|
|
|
+ @"single_select" : @"true"
|
|
|
|
|
+ },
|
|
|
|
|
+ @"item_2" : @{
|
|
|
|
|
+ @"aname" : @"Expiration Date",
|
|
|
|
|
+ @"control" : @"monthpicker",
|
|
|
|
|
+ @"name" : @"credit_card_expiration",
|
|
|
|
|
+ @"required" : @"true",
|
|
|
|
|
+ @"type" : @"date",
|
|
|
|
|
+ @"value" : @"08/16"/*[NSString stringWithFormat:@"%@/%@",month,year]*/
|
|
|
|
|
+ },
|
|
|
|
|
+ @"item_3" : @{
|
|
|
|
|
+ @"aname" : @"Security Code",
|
|
|
|
|
+ @"control" : @"edit",
|
|
|
|
|
+ @"keyboard" : @"int",
|
|
|
|
|
+ @"length" : @"3",
|
|
|
|
|
+ @"name" : @"credit_card_security_code",
|
|
|
|
|
+ @"required" : @"true",
|
|
|
|
|
+ @"value" : securityCode
|
|
|
|
|
+ },
|
|
|
|
|
+ @"item_4" : @{
|
|
|
|
|
+ @"aname" : @"First Name",
|
|
|
|
|
+ @"control" : @"edit",
|
|
|
|
|
+ @"keyboard" : @"text",
|
|
|
|
|
+ @"name" : @"credit_card_first_name",
|
|
|
|
|
+ @"required" : @"true",
|
|
|
|
|
+ @"value" : firstName
|
|
|
|
|
+ },
|
|
|
|
|
+ @"item_5" : @{
|
|
|
|
|
+ @"aname" : @"Last Name",
|
|
|
|
|
+ @"control" : @"edit",
|
|
|
|
|
+ @"keyboard" : @"text",
|
|
|
|
|
+ @"name" : @"credit_card_last_name",
|
|
|
|
|
+ @"required" : @"true",
|
|
|
|
|
+ @"value" : lastName
|
|
|
|
|
+ },
|
|
|
|
|
+ @"item_6" : @{
|
|
|
|
|
+ @"aname" : @"Address 1",
|
|
|
|
|
+ @"control" : @"edit",
|
|
|
|
|
+ @"keyboard" : @"text",
|
|
|
|
|
+ @"name" : @"credit_card_address1",
|
|
|
|
|
+ @"required" : @"true",
|
|
|
|
|
+ @"value" : addr1
|
|
|
|
|
+ },
|
|
|
|
|
+ @"item_7" : @{
|
|
|
|
|
+ @"aname" : @"Address 2",
|
|
|
|
|
+ @"control" : @"edit",
|
|
|
|
|
+ @"keyboard" : @"text",
|
|
|
|
|
+ @"name" : @"credit_card_address2",
|
|
|
|
|
+ @"value" : addr2
|
|
|
|
|
+ },
|
|
|
|
|
+ @"item_8" : @{
|
|
|
|
|
+ @"aname" : @"zip code",
|
|
|
|
|
+ @"control" : @"edit",
|
|
|
|
|
+ @"keyboard" : @"text",
|
|
|
|
|
+ @"name" : @"credit_card_zipcode",
|
|
|
|
|
+ @"required" : @"true",
|
|
|
|
|
+ @"value" : zipcode
|
|
|
|
|
+ },
|
|
|
|
|
+ @"item_9" : @{
|
|
|
|
|
+ @"aname" : @"City",
|
|
|
|
|
+ @"control" : @"edit",
|
|
|
|
|
+ @"keyboard" : @"text",
|
|
|
|
|
+ @"name" : @"credit_card_city",
|
|
|
|
|
+ @"required" : @"true",
|
|
|
|
|
+ @"value" : city
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ @"value" : @"Fill Now",
|
|
|
|
|
+ @"value_id" : @""
|
|
|
|
|
+ },
|
|
|
|
|
+ @"val_1" : @{
|
|
|
|
|
+ @"check" : @(0),
|
|
|
|
|
+ @"value" : @"Fill Later",
|
|
|
|
|
+ @"value_id" : @""
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ @"control" : @"enum",
|
|
|
|
|
+ @"name" : @"",
|
|
|
|
|
+ @"single_select" : @"true"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ @"value" : @"Credit Card",
|
|
|
|
|
+ @"value_id" : @"Credit Card"
|
|
|
|
|
+ },
|
|
|
|
|
+ @"val_5" : @{
|
|
|
|
|
+ @"check" : [payType isEqualToString:@"FOLLOW EXISTING"] ? @(1) : @(0),
|
|
|
|
|
+ @"value" : @"FOLLOW EXISTING",
|
|
|
|
|
+ @"value_id" : @"FOLLOW EXISTING"
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ @"control" : @"enum",
|
|
|
|
|
+ @"name" : @"paymentType",
|
|
|
|
|
+ @"single_select" : @"true"
|
|
|
|
|
+ },
|
|
|
|
|
+ @"title" : @"Payment Information"
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return dic;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
+(NSData*) offline_placeorder :(NSMutableDictionary *) params
|
|
+(NSData*) offline_placeorder :(NSMutableDictionary *) params
|
|
|
{
|
|
{
|
|
|
|
|
|
|
@@ -7505,6 +7798,10 @@
|
|
|
NSDictionary *shipping_method_dic = [self shippingMethodDic:params db:db];
|
|
NSDictionary *shipping_method_dic = [self shippingMethodDic:params db:db];
|
|
|
[ret setValue:shipping_method_dic forKey:@"section_1"];
|
|
[ret setValue:shipping_method_dic forKey:@"section_1"];
|
|
|
|
|
|
|
|
|
|
+ // 2 Payment Information
|
|
|
|
|
+ NSDictionary *payment_info_dic = [self paymentInfoDic:params db:db];
|
|
|
|
|
+ [ret setValue:payment_info_dic forKey:@"section_2"];
|
|
|
|
|
+
|
|
|
// 3 Customer
|
|
// 3 Customer
|
|
|
NSDictionary *customer_dic = [self customerDic:params db:db];
|
|
NSDictionary *customer_dic = [self customerDic:params db:db];
|
|
|
[ret setValue:customer_dic forKey:@"section_3"];
|
|
[ret setValue:customer_dic forKey:@"section_3"];
|
|
@@ -7811,7 +8108,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
NSString *paymentType = [self valueInParams:param key:@"paymentType" translateSingleQuote:YES];
|
|
NSString *paymentType = [self valueInParams:param key:@"paymentType" translateSingleQuote:YES];
|
|
|
- paymentsAndCredits = [paymentsAndCredits isEqualToString:@""] ? @"" : [NSString stringWithFormat:@"paymentType = '%@',",paymentsAndCredits];
|
|
|
|
|
|
|
+ paymentType = [paymentType isEqualToString:@""] ? @"" : [NSString stringWithFormat:@"paymentType = '%@',",paymentType];
|
|
|
|
|
|
|
|
NSString *credit_card_address1 = [self valueInParams:param key:@"credit_card_address1" translateSingleQuote:YES];
|
|
NSString *credit_card_address1 = [self valueInParams:param key:@"credit_card_address1" translateSingleQuote:YES];
|
|
|
credit_card_address1 = [credit_card_address1 isEqualToString:@""] ? @"" : [NSString stringWithFormat:@"credit_card_address1 = '%@',",credit_card_address1];
|
|
credit_card_address1 = [credit_card_address1 isEqualToString:@""] ? @"" : [NSString stringWithFormat:@"credit_card_address1 = '%@',",credit_card_address1];
|
|
@@ -7843,8 +8140,9 @@
|
|
|
NSString *credit_card_state = [self valueInParams:param key:@"credit_card_state" translateSingleQuote:YES];
|
|
NSString *credit_card_state = [self valueInParams:param key:@"credit_card_state" translateSingleQuote:YES];
|
|
|
credit_card_state = [credit_card_state isEqualToString:@""] ? @"" : [NSString stringWithFormat:@"credit_card_state = '%@',",credit_card_state];
|
|
credit_card_state = [credit_card_state isEqualToString:@""] ? @"" : [NSString stringWithFormat:@"credit_card_state = '%@',",credit_card_state];
|
|
|
|
|
|
|
|
- NSString *credit_card_type = [self valueInParams:param key:@"credit_card_type" translateSingleQuote:YES];
|
|
|
|
|
- credit_card_type = [credit_card_type isEqualToString:@""] ? @"" : [NSString stringWithFormat:@"credit_card_type = '%@',",credit_card_type];
|
|
|
|
|
|
|
+ NSNumber *card_type_number = [param objectForKey:@"credit_card_type"];
|
|
|
|
|
+ NSString *credit_card_type = card_type_number ? [NSString stringWithFormat:@"credit_card_type = '%@',",[card_type_number integerValue] == 0 ? @"VISA" : @"MASTER CARD"] : @"";
|
|
|
|
|
+
|
|
|
|
|
|
|
|
NSString *credit_card_zipcode = [self valueInParams:param key:@"credit_card_zipcode" translateSingleQuote:YES];
|
|
NSString *credit_card_zipcode = [self valueInParams:param key:@"credit_card_zipcode" translateSingleQuote:YES];
|
|
|
credit_card_zipcode = [credit_card_zipcode isEqualToString:@""] ? @"" : [NSString stringWithFormat:@"credit_card_zipcode = '%@',",credit_card_zipcode];
|
|
credit_card_zipcode = [credit_card_zipcode isEqualToString:@""] ? @"" : [NSString stringWithFormat:@"credit_card_zipcode = '%@',",credit_card_zipcode];
|