|
|
@@ -5158,7 +5158,7 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
- double discount = sqlite3_column_int(stmt, 2);
|
|
|
+ double discount = sqlite3_column_double(stmt, 2);
|
|
|
int item_count = sqlite3_column_int(stmt, 3);
|
|
|
|
|
|
char *line_note = (char*)sqlite3_column_text(stmt, 4);
|
|
|
@@ -5782,16 +5782,24 @@
|
|
|
|
|
|
#pragma mark place order
|
|
|
|
|
|
-+ (NSDictionary *)customerInfoName:(NSString *)name aname:(NSString *)aname control:(NSString *)control keyboard:(NSString *)keyboard value:(id)value {
|
|
|
++ (NSDictionary *)infoName:(NSString *)name aname:(NSString *)aname control:(NSString *)control keyboard:(NSString *)keyboard value:(id)value {
|
|
|
|
|
|
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
- [dic setValue:aname forKey:@"aname"];
|
|
|
- [dic setValue:control forKey:@"control"];
|
|
|
+ if (aname) {
|
|
|
+ [dic setValue:aname forKey:@"aname"];
|
|
|
+ }
|
|
|
+ if (control) {
|
|
|
+ [dic setValue:control forKey:@"control"];
|
|
|
+ }
|
|
|
if (keyboard) {
|
|
|
[dic setValue:keyboard forKey:@"keyboard"];
|
|
|
}
|
|
|
- [dic setValue:name forKey:@"name"];
|
|
|
- [dic setValue:value forKey:@"value"];
|
|
|
+ if (name) {
|
|
|
+ [dic setValue:name forKey:@"name"];
|
|
|
+ }
|
|
|
+ if (value) {
|
|
|
+ [dic setValue:value forKey:@"value"];
|
|
|
+ }
|
|
|
|
|
|
return dic;
|
|
|
}
|
|
|
@@ -5802,7 +5810,8 @@
|
|
|
orderCode = [self translateSingleQuote:orderCode];
|
|
|
|
|
|
__block NSMutableDictionary *customer_dic = [NSMutableDictionary dictionary];
|
|
|
- NSString *customerSql = [NSString stringWithFormat:@"select c.contact_id,c.img_0,c.img_1,c.img_2,descrypt(c.company_name),descrypt(c.addr_1),c.addr_2,c.addr_3,c.addr_4,c.first_name,c.last_name,c.email,descrypt(c.phone),c.fax,c.zipcode,c.city,c.state,c.country from offline_contact as c join offline_order as o on c.contact_id = o.customer_cid where o.so_id = '%@';",orderCode];
|
|
|
+
|
|
|
+ NSString *customerSql = [NSString stringWithFormat:@"select c.contact_id,c.img_0,c.img_1,c.img_2,decrypt(c.company_name),decrypt(c.addr_1),c.addr_2,c.addr_3,c.addr_4,c.first_name,c.last_name,c.email,decrypt(c.phone),c.fax,c.zipcode,c.city,c.state,c.country from offline_contact as c join offline_order as o on c.contact_id = o.customer_cid where o.so_id = '%@';",orderCode];
|
|
|
[iSalesDB jk_query:customerSql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
|
|
|
NSString *contact_id = [self textAtColumn:0 statement:stmt];
|
|
|
@@ -5853,67 +5862,67 @@
|
|
|
[customer_dic setValue:business_card_dic forKey:@"item_1"];
|
|
|
|
|
|
// fax
|
|
|
- NSDictionary *fax_dic = [self customerInfoName:@"customer_fax" aname:@"Fax" control:@"edit" keyboard:@"text" value:fax];
|
|
|
+ NSDictionary *fax_dic = [self infoName:@"customer_fax" aname:@"Fax" control:@"edit" keyboard:@"text" value:fax];
|
|
|
|
|
|
[customer_dic setValue:fax_dic forKey:@"item_10"];
|
|
|
|
|
|
// zipcode
|
|
|
- NSDictionary *zipcode_dic = [self customerInfoName:@"customer_zipcode" aname:@"Zipcode" control:@"text" keyboard:nil value:zipcode];
|
|
|
+ NSDictionary *zipcode_dic = [self infoName:@"customer_zipcode" aname:@"Zipcode" control:@"text" keyboard:nil value:zipcode];
|
|
|
|
|
|
[customer_dic setValue:zipcode_dic forKey:@"item_11"];
|
|
|
|
|
|
// city
|
|
|
- NSDictionary *city_dic = [self customerInfoName:@"customer_city" aname:@"City" control:@"text" keyboard:nil value:city];
|
|
|
+ NSDictionary *city_dic = [self infoName:@"customer_city" aname:@"City" control:@"text" keyboard:nil value:city];
|
|
|
|
|
|
[customer_dic setValue:city_dic forKey:@"item_12"];
|
|
|
|
|
|
// state
|
|
|
- NSDictionary *state_dic = [self customerInfoName:@"customer_state" aname:@"State" control:@"text" keyboard:nil value:state];
|
|
|
+ NSDictionary *state_dic = [self infoName:@"customer_state" aname:@"State" control:@"text" keyboard:nil value:state];
|
|
|
|
|
|
[customer_dic setValue:state_dic forKey:@"item_13"];
|
|
|
|
|
|
// country
|
|
|
- NSDictionary *country_dic = [self customerInfoName:@"customer_country" aname:@"Country" control:@"text" keyboard:nil value:country];
|
|
|
+ NSDictionary *country_dic = [self infoName:@"customer_country" aname:@"Country" control:@"text" keyboard:nil value:country];
|
|
|
|
|
|
[customer_dic setValue:country_dic forKey:@"item_14"];
|
|
|
|
|
|
// company name
|
|
|
- NSDictionary *company_dic = [self customerInfoName:@"customer_name" aname:@"Company Name" control:@"text" keyboard:nil value:company_name];
|
|
|
+ NSDictionary *company_dic = [self infoName:@"customer_name" aname:@"Company Name" control:@"text" keyboard:nil value:company_name];
|
|
|
|
|
|
[customer_dic setValue:company_dic forKey:@"item_2"];
|
|
|
|
|
|
// addr_1
|
|
|
- NSDictionary *addr1_dic = [self customerInfoName:@"customer_address1" aname:@"Address_1" control:@"text" keyboard:nil value:addr1];
|
|
|
+ NSDictionary *addr1_dic = [self infoName:@"customer_address1" aname:@"Address_1" control:@"text" keyboard:nil value:addr1];
|
|
|
|
|
|
[customer_dic setValue:addr1_dic forKey:@"item_3"];
|
|
|
|
|
|
// addr_2
|
|
|
- NSDictionary *addr2_dic = [self customerInfoName:@"customer_address2" aname:@"Address_2" control:@"text" keyboard:nil value:addr2];
|
|
|
+ NSDictionary *addr2_dic = [self infoName:@"customer_address2" aname:@"Address_2" control:@"text" keyboard:nil value:addr2];
|
|
|
|
|
|
[customer_dic setValue:addr2_dic forKey:@"item_4"];
|
|
|
|
|
|
// addr_3
|
|
|
- NSDictionary *addr3_dic = [self customerInfoName:@"customer_address3" aname:@"Address_3" control:@"text" keyboard:nil value:addr3];
|
|
|
+ NSDictionary *addr3_dic = [self infoName:@"customer_address3" aname:@"Address_3" control:@"text" keyboard:nil value:addr3];
|
|
|
|
|
|
[customer_dic setValue:addr3_dic forKey:@"item_5"];
|
|
|
|
|
|
// addr_4
|
|
|
- NSDictionary *addr4_dic = [self customerInfoName:@"customer_address4" aname:@"Address_4" control:@"text" keyboard:nil value:addr4];
|
|
|
+ NSDictionary *addr4_dic = [self infoName:@"customer_address4" aname:@"Address_4" control:@"text" keyboard:nil value:addr4];
|
|
|
|
|
|
[customer_dic setValue:addr4_dic forKey:@"item_6"];
|
|
|
|
|
|
// Contact
|
|
|
- NSDictionary *contact_dic = [self customerInfoName:@"customer_contact" aname:@"Contact" control:@"edit" keyboard:@"text" value:name];
|
|
|
+ NSDictionary *contact_dic = [self infoName:@"customer_contact" aname:@"Contact" control:@"edit" keyboard:@"text" value:name];
|
|
|
|
|
|
[customer_dic setValue:contact_dic forKey:@"item_7"];
|
|
|
|
|
|
// email
|
|
|
- NSDictionary *email_dic = [self customerInfoName:@"customer_email" aname:@"Email" control:@"edit" keyboard:@"text" value:email];
|
|
|
+ NSDictionary *email_dic = [self infoName:@"customer_email" aname:@"Email" control:@"edit" keyboard:@"text" value:email];
|
|
|
|
|
|
[customer_dic setValue:email_dic forKey:@"item_8"];
|
|
|
|
|
|
// phone
|
|
|
- NSDictionary *phone_dic = [self customerInfoName:@"customer_phone" aname:@"Phone" control:@"edit" keyboard:@"text" value:phone];
|
|
|
+ NSDictionary *phone_dic = [self infoName:@"customer_phone" aname:@"Phone" control:@"edit" keyboard:@"text" value:phone];
|
|
|
|
|
|
[customer_dic setValue:phone_dic forKey:@"item_9"];
|
|
|
|
|
|
@@ -5928,6 +5937,851 @@
|
|
|
return customer_dic;
|
|
|
}
|
|
|
|
|
|
++ (NSDictionary *)shipToDic:(NSDictionary *)params db:(sqlite3 *)db {
|
|
|
+
|
|
|
+ __block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
+
|
|
|
+ NSString *orderCode = [self valueInParams:params key:@"orderCode"];
|
|
|
+ orderCode = [self translateSingleQuote:orderCode];
|
|
|
+
|
|
|
+
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select receive_cid,receive_name,receive_ext,receive_contact,receive_email,receive_fax,receive_phone from offline_order where so_id = '%@';",orderCode];
|
|
|
+
|
|
|
+
|
|
|
+ [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
+
|
|
|
+ NSString *cid = [self textAtColumn:0 statement:stmt];
|
|
|
+ NSString *name = [self textAtColumn:1 statement:stmt];
|
|
|
+ NSString *ext = [self textAtColumn:2 statement:stmt];
|
|
|
+ NSString *contact = [self textAtColumn:3 statement:stmt];
|
|
|
+ NSString *email = [self textAtColumn:4 statement:stmt];
|
|
|
+ NSString *fax = [self textAtColumn:5 statement:stmt];
|
|
|
+ NSString *phone = [self textAtColumn:6 statement:stmt];
|
|
|
+
|
|
|
+ // count
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:8] forKey:@"count"];
|
|
|
+
|
|
|
+ // title
|
|
|
+ [dic setValue:@"Ship To" forKey:@"title"];
|
|
|
+
|
|
|
+ // choose
|
|
|
+ NSMutableDictionary *choose_dic = [NSMutableDictionary dictionary];
|
|
|
+ [choose_dic setValue:@"choose" forKey:@"aname"];
|
|
|
+ [choose_dic setValue:@"multi_action" forKey:@"control"];
|
|
|
+ [choose_dic setValue:[NSNumber numberWithInteger:3] forKey:@"count"];
|
|
|
+ NSDictionary *same_as_customer_dic = @{@"aname" : @"Same as customer",
|
|
|
+ @"key_map" : @{@"receive_cid" : @"customer_cid",
|
|
|
+ @"receive_contact" : @"customer_contact",
|
|
|
+ @"receive_email" : @"customer_email",
|
|
|
+ @"receive_ext" : @"customer_contact_ext",
|
|
|
+ @"receive_fax" : @"customer_fax",
|
|
|
+ @"receive_name" : @"customer_name",
|
|
|
+ @"receive_phone" : @"customer_phone"},
|
|
|
+ @"refresh" : [NSNumber numberWithInteger:1],
|
|
|
+ @"type" : @"pull"};
|
|
|
+ [choose_dic setValue:same_as_customer_dic forKey:@"item_0"];
|
|
|
+ NSDictionary *create_new_ship_to_dic = @{@"aname" : @"Create new ship to",
|
|
|
+ @"name" : @"Add new address",
|
|
|
+ @"refresh" : [NSNumber numberWithInteger:1],
|
|
|
+ @"value" : @"new_addr"
|
|
|
+ };
|
|
|
+ [choose_dic setValue:create_new_ship_to_dic forKey:@"item_1"];
|
|
|
+ NSDictionary *select_ship_to_dic = @{@"aname" : @"Select ship to",
|
|
|
+ @"key_map" : @{@"receive_cid" : @"customer_cid",
|
|
|
+ @"receive_contact" : @"customer_contact",
|
|
|
+ @"receive_email" : @"customer_email",
|
|
|
+ @"receive_ext" : @"customer_contact_ext",
|
|
|
+ @"receive_fax" : @"customer_fax",
|
|
|
+ @"receive_name" : @"customer_name",
|
|
|
+ @"receive_phone" : @"customer_phone"},
|
|
|
+ @"name" : @"select_ship_to",
|
|
|
+ @"refresh" : [NSNumber numberWithInteger:1],
|
|
|
+ @"value" : @"Sales_Order_Ship_To"};
|
|
|
+ [choose_dic setValue:select_ship_to_dic forKey:@"item_2"];
|
|
|
+
|
|
|
+ [dic setValue:choose_dic forKey:@"item_0"];
|
|
|
+
|
|
|
+ // contact id
|
|
|
+ NSDictionary *contact_id_dic = [[self infoName:@"receive_cid" aname:@"Contact ID" control:@"edit" keyboard:@"text" value:cid] mutableCopy];
|
|
|
+ [contact_id_dic setValue:@"1" forKey:@"disable"];
|
|
|
+ [contact_id_dic setValue:@"true" forKey:@"required"];
|
|
|
+
|
|
|
+ [dic setValue:contact_id_dic forKey:@"item_1"];
|
|
|
+
|
|
|
+ // company name
|
|
|
+ NSDictionary *company_name_dic = [self infoName:@"receive_name" aname:@"Company Name" control:@"edit" keyboard:@"text" value:name];
|
|
|
+
|
|
|
+ [dic setValue:company_name_dic forKey:@"item_2"];
|
|
|
+
|
|
|
+ // address
|
|
|
+ NSDictionary *ext_dic = [self infoName:@"receive_ext" aname:@"Address" control:@"text_view" keyboard:@"text" value:ext];
|
|
|
+
|
|
|
+ [dic setValue:ext_dic forKey:@"item_3"];
|
|
|
+
|
|
|
+ // contact
|
|
|
+ NSDictionary *contact_dic = [self infoName:@"receive_contact" aname:@"Contact" control:@"edit" keyboard:@"text" value:contact];
|
|
|
+
|
|
|
+ [dic setValue:contact_dic forKey:@"item_4"];
|
|
|
+
|
|
|
+ // phone
|
|
|
+ NSDictionary *phone_dic = [self infoName:@"receive_phone" aname:@"Phone" control:@"edit" keyboard:@"text" value:phone];
|
|
|
+
|
|
|
+ [dic setValue:phone_dic forKey:@"item_5"];
|
|
|
+
|
|
|
+ // fax
|
|
|
+ NSDictionary *fax_dic = [self infoName:@"receive_fax" aname:@"Fax" control:@"edit" keyboard:@"text" value:fax];
|
|
|
+ [dic setValue:fax_dic forKey:@"item_6"];
|
|
|
+
|
|
|
+ // email
|
|
|
+ NSDictionary *email_dic = [self infoName:@"receive_email" aname:@"Email" control:@"edit" keyboard:@"text" value:email];
|
|
|
+
|
|
|
+ [dic setValue:email_dic forKey:@"item_7"];
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ return dic;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSDictionary *)shipFromDic:(NSDictionary *)params db:(sqlite3 *)db {
|
|
|
+ __block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
+
|
|
|
+ NSString *orderCode = [self valueInParams:params key:@"orderCode"];
|
|
|
+ orderCode = [self translateSingleQuote:orderCode];
|
|
|
+
|
|
|
+
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select sender_cid,sender_name,sender_ext,sender_contact,sender_email,sender_fax,sender_phone from offline_order where so_id = '%@';",orderCode];
|
|
|
+
|
|
|
+
|
|
|
+ [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
+
|
|
|
+ NSString *cid = [self textAtColumn:0 statement:stmt];
|
|
|
+ NSString *name = [self textAtColumn:1 statement:stmt];
|
|
|
+ NSString *ext = [self textAtColumn:2 statement:stmt];
|
|
|
+ NSString *contact = [self textAtColumn:3 statement:stmt];
|
|
|
+ NSString *email = [self textAtColumn:4 statement:stmt];
|
|
|
+ NSString *fax = [self textAtColumn:5 statement:stmt];
|
|
|
+ NSString *phone = [self textAtColumn:6 statement:stmt];
|
|
|
+
|
|
|
+ // count
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:8] forKey:@"count"];
|
|
|
+
|
|
|
+ // title
|
|
|
+ [dic setValue:@"Ship From" forKey:@"title"];
|
|
|
+
|
|
|
+ // hide
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:1] forKey:@"hide"];
|
|
|
+
|
|
|
+ // choose
|
|
|
+ NSMutableDictionary *choose_dic = [NSMutableDictionary dictionary];
|
|
|
+ [choose_dic setValue:@"choose" forKey:@"aname"];
|
|
|
+ [choose_dic setValue:@"multi_action" forKey:@"control"];
|
|
|
+ [choose_dic setValue:[NSNumber numberWithInteger:1] forKey:@"count"];
|
|
|
+
|
|
|
+ NSDictionary *select_ship_from_dic = @{@"aname" : @"Select ship from",
|
|
|
+ @"key_map" : @{@"sender_cid" : @"customer_cid",
|
|
|
+ @"sender_contact" : @"customer_contact",
|
|
|
+ @"sender_email" : @"customer_email",
|
|
|
+ @"sender_ext" : @"customer_contact_ext",
|
|
|
+ @"sender_fax" : @"customer_fax",
|
|
|
+ @"sender_name" : @"customer_name",
|
|
|
+ @"sender_phone" : @"customer_phone"},
|
|
|
+ @"name" : @"select_cid",
|
|
|
+ @"refresh" : [NSNumber numberWithInteger:0],
|
|
|
+ @"value" : @"Sales_Order_Ship_From"};
|
|
|
+ [choose_dic setValue:select_ship_from_dic forKey:@"item_0"];
|
|
|
+
|
|
|
+ [dic setValue:choose_dic forKey:@"item_0"];
|
|
|
+
|
|
|
+ // contact id
|
|
|
+ NSDictionary *contact_id_dic = [[self infoName:@"sender_cid" aname:@"Contact ID" control:@"edit" keyboard:@"text" value:cid] mutableCopy];
|
|
|
+ [contact_id_dic setValue:@"1" forKey:@"disable"];
|
|
|
+ [contact_id_dic setValue:@"true" forKey:@"required"];
|
|
|
+
|
|
|
+ [dic setValue:contact_id_dic forKey:@"item_1"];
|
|
|
+
|
|
|
+ // company name
|
|
|
+ NSDictionary *company_name_dic = [self infoName:@"sender_name" aname:@"Company Name" control:@"edit" keyboard:@"text" value:name];
|
|
|
+
|
|
|
+ [dic setValue:company_name_dic forKey:@"item_2"];
|
|
|
+
|
|
|
+ // address
|
|
|
+ NSDictionary *ext_dic = [self infoName:@"sender_ext" aname:@"Address" control:@"text_view" keyboard:@"text" value:ext];
|
|
|
+
|
|
|
+ [dic setValue:ext_dic forKey:@"item_3"];
|
|
|
+
|
|
|
+ // contact
|
|
|
+ NSDictionary *contact_dic = [self infoName:@"sender_contact" aname:@"Contact" control:@"edit" keyboard:@"text" value:contact];
|
|
|
+
|
|
|
+ [dic setValue:contact_dic forKey:@"item_4"];
|
|
|
+
|
|
|
+ // phone
|
|
|
+ NSDictionary *phone_dic = [self infoName:@"sender_phone" aname:@"Phone" control:@"edit" keyboard:@"text" value:phone];
|
|
|
+
|
|
|
+ [dic setValue:phone_dic forKey:@"item_5"];
|
|
|
+
|
|
|
+ // fax
|
|
|
+ NSDictionary *fax_dic = [self infoName:@"sender_fax" aname:@"Fax" control:@"edit" keyboard:@"text" value:fax];
|
|
|
+ [dic setValue:fax_dic forKey:@"item_6"];
|
|
|
+
|
|
|
+ // email
|
|
|
+ NSDictionary *email_dic = [self infoName:@"sender_email" aname:@"Email" control:@"edit" keyboard:@"text" value:email];
|
|
|
+
|
|
|
+ [dic setValue:email_dic forKey:@"item_7"];
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ return dic;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSDictionary *)freightBillToDic:(NSDictionary *) params db:(sqlite3 *)db {
|
|
|
+ __block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
+
|
|
|
+ NSString *orderCode = [self valueInParams:params key:@"orderCode"];
|
|
|
+ orderCode = [self translateSingleQuote:orderCode];
|
|
|
+
|
|
|
+
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select shipping_billto_cid,shipping_billto_name,shipping_billto_ext,shipping_billto_contact,shipping_billto_email,shipping_billto_fax,shipping_billto_phone from offline_order where so_id = '%@';",orderCode];
|
|
|
+
|
|
|
+
|
|
|
+ [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
+
|
|
|
+ NSString *cid = [self textAtColumn:0 statement:stmt];
|
|
|
+ NSString *name = [self textAtColumn:1 statement:stmt];
|
|
|
+ NSString *ext = [self textAtColumn:2 statement:stmt];
|
|
|
+ NSString *contact = [self textAtColumn:3 statement:stmt];
|
|
|
+ NSString *email = [self textAtColumn:4 statement:stmt];
|
|
|
+ NSString *fax = [self textAtColumn:5 statement:stmt];
|
|
|
+ NSString *phone = [self textAtColumn:6 statement:stmt];
|
|
|
+
|
|
|
+ // count
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:8] forKey:@"count"];
|
|
|
+
|
|
|
+ // title
|
|
|
+ [dic setValue:@"Freight Bill To" forKey:@"title"];
|
|
|
+
|
|
|
+ // hide
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:1] forKey:@"hide"];
|
|
|
+
|
|
|
+ // choose
|
|
|
+ NSMutableDictionary *choose_dic = [NSMutableDictionary dictionary];
|
|
|
+ [choose_dic setValue:@"choose" forKey:@"aname"];
|
|
|
+ [choose_dic setValue:@"multi_action" forKey:@"control"];
|
|
|
+ [choose_dic setValue:[NSNumber numberWithInteger:4] forKey:@"count"];
|
|
|
+ NSDictionary *same_as_ship_to_dic = @{@"aname" : @"Same as ship to",
|
|
|
+ @"key_map" : @{@"shipping_billto_cid" : @"receive_cid",
|
|
|
+ @"shipping_billto_contact" : @"receive_contact",
|
|
|
+ @"shipping_billto_email" : @"receive_email",
|
|
|
+ @"shipping_billto_ext" : @"receive_ext",
|
|
|
+ @"shipping_billto_fax" : @"receive_fax",
|
|
|
+ @"shipping_billto_name" : @"receive_name",
|
|
|
+ @"shipping_billto_phone" : @"receive_phone"},
|
|
|
+ @"type" : @"pull"};
|
|
|
+ [choose_dic setValue:same_as_ship_to_dic forKey:@"item_0"];
|
|
|
+
|
|
|
+ NSDictionary *same_as_customer_dic = @{@"aname" : @"Same as customer",
|
|
|
+ @"type" : @"pull",
|
|
|
+ @"key_map" : @{@"shipping_billto_cid" : @"customer_cid",
|
|
|
+ @"shipping_billto_contact" : @"customer_contact",
|
|
|
+ @"shipping_billto_email" : @"customer_email",
|
|
|
+ @"shipping_billto_ext" : @"customer_contact_ext",
|
|
|
+ @"shipping_billto_fax" : @"customer_fax",
|
|
|
+ @"shipping_billto_name" : @"customer_name",
|
|
|
+ @"shipping_billto_phone" : @"customer_phone"}
|
|
|
+ };
|
|
|
+ [choose_dic setValue:same_as_customer_dic forKey:@"item_1"];
|
|
|
+
|
|
|
+ NSDictionary *same_as_ship_from_dic = @{@"aname" : @"Same as ship from",
|
|
|
+ @"key_map" : @{@"shipping_billto_cid" : @"sender_cid",
|
|
|
+ @"shipping_billto_contact" : @"sender_contact",
|
|
|
+ @"shipping_billto_email" : @"sender_email",
|
|
|
+ @"shipping_billto_ext" : @"sender_ext",
|
|
|
+ @"shipping_billto_fax" : @"sender_fax",
|
|
|
+ @"shipping_billto_name" : @"sender_name",
|
|
|
+ @"shipping_billto_phone" : @"sender_phone"},
|
|
|
+ @"type" : @"pull"
|
|
|
+ };
|
|
|
+ [choose_dic setValue:same_as_ship_from_dic forKey:@"item_2"];
|
|
|
+
|
|
|
+ NSDictionary *select_freight_bill_to_dic = @{
|
|
|
+ @"aname" : @"Select freight bill to",
|
|
|
+ @"name" : @"select_cid",
|
|
|
+ @"refresh" : [NSNumber numberWithInteger:0],
|
|
|
+ @"value" : @"Sales_Order_Freight_Bill_To",
|
|
|
+ @"key_map" : @{
|
|
|
+ @"shipping_billto_cid" : @"customer_cid",
|
|
|
+ @"shipping_billto_contact" : @"customer_contact",
|
|
|
+ @"shipping_billto_email" : @"customer_email",
|
|
|
+ @"shipping_billto_ext" : @"customer_contact_ext",
|
|
|
+ @"shipping_billto_fax" : @"customer_fax",
|
|
|
+ @"shipping_billto_name" : @"customer_name",
|
|
|
+ @"shipping_billto_phone" : @"customer_phone"
|
|
|
+ }
|
|
|
+ };
|
|
|
+ [choose_dic setValue:select_freight_bill_to_dic forKey:@"item_3"];
|
|
|
+
|
|
|
+ [dic setValue:choose_dic forKey:@"item_0"];
|
|
|
+
|
|
|
+ // contact id
|
|
|
+ NSDictionary *contact_id_dic = [[self infoName:@"shipping_billto_cid" aname:@"Contact ID" control:@"edit" keyboard:@"text" value:cid] mutableCopy];
|
|
|
+ [contact_id_dic setValue:@"1" forKey:@"disable"];
|
|
|
+ [contact_id_dic setValue:@"true" forKey:@"required"];
|
|
|
+
|
|
|
+ [dic setValue:contact_id_dic forKey:@"item_1"];
|
|
|
+
|
|
|
+ // company name
|
|
|
+ NSDictionary *company_name_dic = [self infoName:@"shipping_billto_name" aname:@"Company Name" control:@"edit" keyboard:@"text" value:name];
|
|
|
+
|
|
|
+ [dic setValue:company_name_dic forKey:@"item_2"];
|
|
|
+
|
|
|
+ // address
|
|
|
+ NSDictionary *ext_dic = [self infoName:@"shipping_billto_ext" aname:@"Address" control:@"text_view" keyboard:@"text" value:ext];
|
|
|
+
|
|
|
+ [dic setValue:ext_dic forKey:@"item_3"];
|
|
|
+
|
|
|
+ // contact
|
|
|
+ NSDictionary *contact_dic = [self infoName:@"shipping_billto_contact" aname:@"Contact" control:@"edit" keyboard:@"text" value:contact];
|
|
|
+
|
|
|
+ [dic setValue:contact_dic forKey:@"item_4"];
|
|
|
+
|
|
|
+ // phone
|
|
|
+ NSDictionary *phone_dic = [self infoName:@"shipping_billto_phone" aname:@"Phone" control:@"edit" keyboard:@"text" value:phone];
|
|
|
+
|
|
|
+ [dic setValue:phone_dic forKey:@"item_5"];
|
|
|
+
|
|
|
+ // fax
|
|
|
+ NSDictionary *fax_dic = [self infoName:@"shipping_billto_fax" aname:@"Fax" control:@"edit" keyboard:@"text" value:fax];
|
|
|
+ [dic setValue:fax_dic forKey:@"item_6"];
|
|
|
+
|
|
|
+ // email
|
|
|
+ NSDictionary *email_dic = [self infoName:@"shipping_billto_email" aname:@"Email" control:@"edit" keyboard:@"text" value:email];
|
|
|
+
|
|
|
+ [dic setValue:email_dic forKey:@"item_7"];
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ return dic;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSDictionary *)merchandiseBillToDic:(NSDictionary *)params db:(sqlite3 *)db {
|
|
|
+ __block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
+
|
|
|
+ NSString *orderCode = [self valueInParams:params key:@"orderCode"];
|
|
|
+ orderCode = [self translateSingleQuote:orderCode];
|
|
|
+
|
|
|
+
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select billing_cid,billing_name,billing_ext,billing_contact,billing_email,billing_fax,billing_phone from offline_order where so_id = '%@';",orderCode];
|
|
|
+
|
|
|
+
|
|
|
+ [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
+
|
|
|
+ NSString *cid = [self textAtColumn:0 statement:stmt];
|
|
|
+ NSString *name = [self textAtColumn:1 statement:stmt];
|
|
|
+ NSString *ext = [self textAtColumn:2 statement:stmt];
|
|
|
+ NSString *contact = [self textAtColumn:3 statement:stmt];
|
|
|
+ NSString *email = [self textAtColumn:4 statement:stmt];
|
|
|
+ NSString *fax = [self textAtColumn:5 statement:stmt];
|
|
|
+ NSString *phone = [self textAtColumn:6 statement:stmt];
|
|
|
+
|
|
|
+ // count
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:8] forKey:@"count"];
|
|
|
+
|
|
|
+ // title
|
|
|
+ [dic setValue:@"Merchandise Bill To" forKey:@"title"];
|
|
|
+
|
|
|
+ // hide
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:1] forKey:@"hide"];
|
|
|
+
|
|
|
+ // choose
|
|
|
+ NSMutableDictionary *choose_dic = [NSMutableDictionary dictionary];
|
|
|
+ [choose_dic setValue:@"choose" forKey:@"aname"];
|
|
|
+ [choose_dic setValue:@"multi_action" forKey:@"control"];
|
|
|
+ [choose_dic setValue:[NSNumber numberWithInteger:3] forKey:@"count"];
|
|
|
+ NSDictionary *same_as_ship_to_dic = @{@"aname" : @"Same as ship to",
|
|
|
+ @"key_map" : @{@"billing_cid" : @"receive_cid",
|
|
|
+ @"billing_contact" : @"receive_contact",
|
|
|
+ @"billing_email" : @"receive_email",
|
|
|
+ @"billing_ext" : @"receive_ext",
|
|
|
+ @"billing_fax" : @"receive_fax",
|
|
|
+ @"billing_name" : @"receive_name",
|
|
|
+ @"billing_phone" : @"receive_phone"},
|
|
|
+ @"type" : @"pull"};
|
|
|
+ [choose_dic setValue:same_as_ship_to_dic forKey:@"item_0"];
|
|
|
+
|
|
|
+ NSDictionary *same_as_customer_dic = @{@"aname" : @"Same as customer",
|
|
|
+ @"type" : @"pull",
|
|
|
+ @"key_map" : @{@"billing_cid" : @"customer_cid",
|
|
|
+ @"billing_contact" : @"customer_contact",
|
|
|
+ @"billing_email" : @"customer_email",
|
|
|
+ @"billing_ext" : @"customer_contact_ext",
|
|
|
+ @"billing_fax" : @"customer_fax",
|
|
|
+ @"billing_name" : @"customer_name",
|
|
|
+ @"billing_phone" : @"customer_phone"}
|
|
|
+ };
|
|
|
+ [choose_dic setValue:same_as_customer_dic forKey:@"item_1"];
|
|
|
+
|
|
|
+
|
|
|
+ NSDictionary *select_bill_to_dic = @{
|
|
|
+ @"aname" : @"Select bill to",
|
|
|
+ @"name" : @"select_cid",
|
|
|
+ @"refresh" : [NSNumber numberWithInteger:0],
|
|
|
+ @"value" : @"Sales_Order_Merchandise_Bill_To",
|
|
|
+ @"key_map" : @{
|
|
|
+ @"billing_cid" : @"customer_cid",
|
|
|
+ @"billing_contact" : @"customer_contact",
|
|
|
+ @"billing_email" : @"customer_email",
|
|
|
+ @"billing_ext" : @"customer_contact_ext",
|
|
|
+ @"billing_fax" : @"customer_fax",
|
|
|
+ @"billing_name" : @"customer_name",
|
|
|
+ @"billing_phone" : @"customer_phone"
|
|
|
+ }
|
|
|
+ };
|
|
|
+ [choose_dic setValue:select_bill_to_dic forKey:@"item_2"];
|
|
|
+
|
|
|
+ [dic setValue:choose_dic forKey:@"item_0"];
|
|
|
+
|
|
|
+ // contact id
|
|
|
+ NSDictionary *contact_id_dic = [[self infoName:@"billing_cid" aname:@"Contact ID" control:@"edit" keyboard:@"text" value:cid] mutableCopy];
|
|
|
+ [contact_id_dic setValue:@"1" forKey:@"disable"];
|
|
|
+ [contact_id_dic setValue:@"true" forKey:@"required"];
|
|
|
+
|
|
|
+ [dic setValue:contact_id_dic forKey:@"item_1"];
|
|
|
+
|
|
|
+ // company name
|
|
|
+ NSDictionary *company_name_dic = [self infoName:@"billing_name" aname:@"Company Name" control:@"edit" keyboard:@"text" value:name];
|
|
|
+
|
|
|
+ [dic setValue:company_name_dic forKey:@"item_2"];
|
|
|
+
|
|
|
+ // address
|
|
|
+ NSDictionary *ext_dic = [self infoName:@"billing_ext" aname:@"Address" control:@"text_view" keyboard:@"text" value:ext];
|
|
|
+
|
|
|
+ [dic setValue:ext_dic forKey:@"item_3"];
|
|
|
+
|
|
|
+ // contact
|
|
|
+ NSDictionary *contact_dic = [self infoName:@"billing_contact" aname:@"Contact" control:@"edit" keyboard:@"text" value:contact];
|
|
|
+
|
|
|
+ [dic setValue:contact_dic forKey:@"item_4"];
|
|
|
+
|
|
|
+ // phone
|
|
|
+ NSDictionary *phone_dic = [self infoName:@"billing_phone" aname:@"Phone" control:@"edit" keyboard:@"text" value:phone];
|
|
|
+
|
|
|
+ [dic setValue:phone_dic forKey:@"item_5"];
|
|
|
+
|
|
|
+ // fax
|
|
|
+ NSDictionary *fax_dic = [self infoName:@"billing_fax" aname:@"Fax" control:@"edit" keyboard:@"text" value:fax];
|
|
|
+ [dic setValue:fax_dic forKey:@"item_6"];
|
|
|
+
|
|
|
+ // email
|
|
|
+ NSDictionary *email_dic = [self infoName:@"billing_email" aname:@"Email" control:@"edit" keyboard:@"text" value:email];
|
|
|
+
|
|
|
+ [dic setValue:email_dic forKey:@"item_7"];
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ return dic;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSDictionary *)returnToDic:(NSDictionary *)params db:(sqlite3 *)db {
|
|
|
+ __block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
+
|
|
|
+ NSString *orderCode = [self valueInParams:params key:@"orderCode"];
|
|
|
+ orderCode = [self translateSingleQuote:orderCode];
|
|
|
+
|
|
|
+
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select returnto_cid,returnto_name,returnto_ext,returnto_contact,returnto_email,returnto_fax,returnto_phone from offline_order where so_id = '%@';",orderCode];
|
|
|
+
|
|
|
+
|
|
|
+ [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
+
|
|
|
+ NSString *cid = [self textAtColumn:0 statement:stmt];
|
|
|
+ NSString *name = [self textAtColumn:1 statement:stmt];
|
|
|
+ NSString *ext = [self textAtColumn:2 statement:stmt];
|
|
|
+ NSString *contact = [self textAtColumn:3 statement:stmt];
|
|
|
+ NSString *email = [self textAtColumn:4 statement:stmt];
|
|
|
+ NSString *fax = [self textAtColumn:5 statement:stmt];
|
|
|
+ NSString *phone = [self textAtColumn:6 statement:stmt];
|
|
|
+
|
|
|
+ // count
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:8] forKey:@"count"];
|
|
|
+
|
|
|
+ // title
|
|
|
+ [dic setValue:@"Return To" forKey:@"title"];
|
|
|
+
|
|
|
+ // hide
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:1] forKey:@"hide"];
|
|
|
+
|
|
|
+ // choose
|
|
|
+ NSMutableDictionary *choose_dic = [NSMutableDictionary dictionary];
|
|
|
+ [choose_dic setValue:@"choose" forKey:@"aname"];
|
|
|
+ [choose_dic setValue:@"multi_action" forKey:@"control"];
|
|
|
+ [choose_dic setValue:[NSNumber numberWithInteger:2] forKey:@"count"];
|
|
|
+ NSDictionary *same_as_ship_from_dic = @{@"aname" : @"Same as ship from",
|
|
|
+ @"key_map" : @{@"returnto_cid" : @"sender_cid",
|
|
|
+ @"returnto_contact" : @"sender_contact",
|
|
|
+ @"returnto_email" : @"sender_email",
|
|
|
+ @"returnto_ext" : @"sender_ext",
|
|
|
+ @"returnto_fax" : @"sender_fax",
|
|
|
+ @"returnto_name" : @"sender_name",
|
|
|
+ @"returnto_phone" : @"sender_phone"},
|
|
|
+ @"type" : @"pull"};
|
|
|
+ [choose_dic setValue:same_as_ship_from_dic forKey:@"item_0"];
|
|
|
+
|
|
|
+
|
|
|
+ NSDictionary *select_return_to_dic = @{
|
|
|
+ @"aname" : @"Select return to",
|
|
|
+ @"name" : @"select_cid",
|
|
|
+ @"refresh" : [NSNumber numberWithInteger:0],
|
|
|
+ @"value" : @"Contact_Return_To",
|
|
|
+ @"key_map" : @{
|
|
|
+ @"returnto_cid" : @"customer_cid",
|
|
|
+ @"returnto_contact" : @"customer_contact",
|
|
|
+ @"returnto_email" : @"customer_email",
|
|
|
+ @"returnto_ext" : @"customer_contact_ext",
|
|
|
+ @"returnto_fax" : @"customer_fax",
|
|
|
+ @"returnto_name" : @"customer_name",
|
|
|
+ @"returnto_phone" : @"customer_phone"
|
|
|
+ }
|
|
|
+ };
|
|
|
+ [choose_dic setValue:select_return_to_dic forKey:@"item_1"];
|
|
|
+
|
|
|
+ [dic setValue:choose_dic forKey:@"item_0"];
|
|
|
+
|
|
|
+ // contact id
|
|
|
+ NSDictionary *contact_id_dic = [[self infoName:@"returnto_cid" aname:@"Contact ID" control:@"edit" keyboard:@"text" value:cid] mutableCopy];
|
|
|
+ [contact_id_dic setValue:@"1" forKey:@"disable"];
|
|
|
+ [contact_id_dic setValue:@"true" forKey:@"required"];
|
|
|
+
|
|
|
+ [dic setValue:contact_id_dic forKey:@"item_1"];
|
|
|
+
|
|
|
+ // company name
|
|
|
+ NSDictionary *company_name_dic = [self infoName:@"returnto_name" aname:@"Company Name" control:@"edit" keyboard:@"text" value:name];
|
|
|
+
|
|
|
+ [dic setValue:company_name_dic forKey:@"item_2"];
|
|
|
+
|
|
|
+ // address
|
|
|
+ NSDictionary *ext_dic = [self infoName:@"returnto_ext" aname:@"Address" control:@"text_view" keyboard:@"text" value:ext];
|
|
|
+
|
|
|
+ [dic setValue:ext_dic forKey:@"item_3"];
|
|
|
+
|
|
|
+ // contact
|
|
|
+ NSDictionary *contact_dic = [self infoName:@"returnto_contact" aname:@"Contact" control:@"edit" keyboard:@"text" value:contact];
|
|
|
+
|
|
|
+ [dic setValue:contact_dic forKey:@"item_4"];
|
|
|
+
|
|
|
+ // phone
|
|
|
+ NSDictionary *phone_dic = [self infoName:@"returnto_phone" aname:@"Phone" control:@"edit" keyboard:@"text" value:phone];
|
|
|
+
|
|
|
+ [dic setValue:phone_dic forKey:@"item_5"];
|
|
|
+
|
|
|
+ // fax
|
|
|
+ NSDictionary *fax_dic = [self infoName:@"returnto_fax" aname:@"Fax" control:@"edit" keyboard:@"text" value:fax];
|
|
|
+ [dic setValue:fax_dic forKey:@"item_6"];
|
|
|
+
|
|
|
+ // email
|
|
|
+ NSDictionary *email_dic = [self infoName:@"returnto_email" aname:@"Email" control:@"edit" keyboard:@"text" value:email];
|
|
|
+
|
|
|
+ [dic setValue:email_dic forKey:@"item_7"];
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ return dic;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSDictionary *)modelInfoDic:(NSDictionary *)params db:(sqlite3 *)db {
|
|
|
+
|
|
|
+ NSString *orderCode = [self valueInParams:params key:@"orderCode"];
|
|
|
+ orderCode = [self translateSingleQuote:orderCode];
|
|
|
+
|
|
|
+ __block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
+ __block double TotalCuft = 0;
|
|
|
+ __block double TotalWeight = 0;
|
|
|
+ __block int TotalCarton = 0;
|
|
|
+ __block double payments = 0;
|
|
|
+
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select c.item_id,c.item_count,m.stockUom,c.price,c.discount,m.name,m.description from (select _id,product_id,decrypt(str_price) as price,discount,item_count,line_note,item_id from offline_cart where so_no='%@') c left join product m on c.product_id=m.product_id;",orderCode];
|
|
|
+
|
|
|
+ AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
+
|
|
|
+ [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
+
|
|
|
+ NSMutableDictionary *model_dic = [NSMutableDictionary dictionary];
|
|
|
+
|
|
|
+ // item id
|
|
|
+ int item_id = sqlite3_column_int(stmt, 0);
|
|
|
+
|
|
|
+ // count
|
|
|
+ int item_count = sqlite3_column_int(stmt, 1);
|
|
|
+
|
|
|
+ // stockUom
|
|
|
+ int stockUom = sqlite3_column_int(stmt, 2);
|
|
|
+
|
|
|
+ // unit price
|
|
|
+ NSString *str_price = [self textAtColumn:3 statement:stmt];
|
|
|
+ NSString* Price=nil;
|
|
|
+ if(str_price==nil)
|
|
|
+ {
|
|
|
+ NSNumber* price = [self get_model_default_price:appDelegate.contact_id product_id:nil item_id:@(item_id) db:db];
|
|
|
+ if(price==nil)
|
|
|
+ Price=@"No Price.";
|
|
|
+ else
|
|
|
+ Price=[NSString stringWithFormat:@"%.2f",price.floatValue];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Price=[NSString stringWithFormat:@"%.2f",[str_price floatValue]];
|
|
|
+ }
|
|
|
+
|
|
|
+ // discount
|
|
|
+ double discount = sqlite3_column_double(stmt, 4);
|
|
|
+
|
|
|
+ // name
|
|
|
+ NSString *name = [self textAtColumn:5 statement:stmt];
|
|
|
+
|
|
|
+ // description
|
|
|
+ NSString *description = [self textAtColumn:6 statement:stmt];
|
|
|
+ description = [NSString stringWithFormat:@"%@\n%@",name,description ];
|
|
|
+
|
|
|
+ // img
|
|
|
+ NSString *img = [self item_image:[NSString stringWithFormat:@"%@",[NSNumber numberWithInt:item_id]] db:db];
|
|
|
+
|
|
|
+
|
|
|
+ NSDictionary *combine = [self model_bundle:item_id db:db compute_part:false];
|
|
|
+
|
|
|
+ double subTotal = item_count * [Price doubleValue] * (1.0 - discount / 100.0);
|
|
|
+ if(combine != nil)
|
|
|
+ {
|
|
|
+ // int citem=0;
|
|
|
+
|
|
|
+ int bcount=[[combine valueForKey:@"count"] intValue];
|
|
|
+ for(int bc=0;bc<bcount;bc++)
|
|
|
+ {
|
|
|
+ NSDictionary * bitem = [combine objectForKey:[NSString stringWithFormat:@"item_%d",bc]];
|
|
|
+ int modulus= [[bitem valueForKey:@"modulus"] intValue];
|
|
|
+ double uprice= [[bitem valueForKey:@"unit_price"]doubleValue];
|
|
|
+ subTotal += uprice * modulus * item_count;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ [model_dic setValue:[NSString stringWithFormat:@"%d",item_id] forKey:@"cart_item_id"];
|
|
|
+ [model_dic setValue:@"model" forKey:@"control"];
|
|
|
+ [model_dic setValue:[NSString stringWithFormat:@"%d",item_count] forKey:@"count"];
|
|
|
+ [model_dic setValue:description forKey:@"description"];
|
|
|
+ [model_dic setValue:img forKey:@"img_url"];
|
|
|
+ [model_dic setValue:[NSNumber numberWithInteger:stockUom] forKey:@"stockUom"];
|
|
|
+ [model_dic setValue:[NSString stringWithFormat:@"%.2f",subTotal] forKey:@"total_price"];
|
|
|
+ [model_dic setValue:Price forKey:@"unit_price"];
|
|
|
+ [model_dic setValue:[NSString stringWithFormat:@"%.2f",discount] forKey:@"discount"];
|
|
|
+ if (combine) {
|
|
|
+ [model_dic setValue:combine forKey:@"combine"];
|
|
|
+ }
|
|
|
+
|
|
|
+ // well,what under the row is the info for total
|
|
|
+ NSDictionary* bsubtotaljson=[self model_subtotal:item_id count:item_count db:db compute_part:true];
|
|
|
+ double cuft=[bsubtotaljson[@"cuft"] doubleValue];
|
|
|
+ double weight=[bsubtotaljson[@"weight"] doubleValue];
|
|
|
+ int carton=[bsubtotaljson[@"carton"] intValue];
|
|
|
+
|
|
|
+ TotalCuft += cuft;
|
|
|
+ TotalWeight += weight;
|
|
|
+ TotalCarton += carton;
|
|
|
+
|
|
|
+ payments += subTotal;
|
|
|
+
|
|
|
+ //---------------------------
|
|
|
+ [dic setValue:model_dic forKey:[NSString stringWithFormat:@"item_%ld",(*count)++]];
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:(*count)] forKey:@"count"];
|
|
|
+ }];
|
|
|
+
|
|
|
+ [dic setValue:@"Model Information" forKey:@"title"];
|
|
|
+
|
|
|
+ [dic setValue:@{@"payments" : [NSNumber numberWithDouble:payments],@"totalCuft" : [NSNumber numberWithDouble:TotalCuft],@"totalWeight" : [NSNumber numberWithDouble:TotalWeight],@"totalCarton" : [NSNumber numberWithInteger:TotalCarton]} forKey:@"toOrderTotal"];
|
|
|
+
|
|
|
+ return dic;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSDictionary *)remarksContentDic:(NSDictionary *)params db:(sqlite3 *)db {
|
|
|
+ NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
+
|
|
|
+ [dic setValue:@"Remarks Content" forKey:@"title"];
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:4] forKey:@"count"];
|
|
|
+
|
|
|
+ NSString *orderCode = [self valueInParams:params key:@"orderCode"];
|
|
|
+ orderCode = [self translateSingleQuote:orderCode];
|
|
|
+
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select poNumber,must_call,internal_notes,general_notes from offline_order where so_id = '%@';",orderCode];
|
|
|
+
|
|
|
+ [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
+
|
|
|
+ NSString *poNumber = [self textAtColumn:0 statement:stmt];
|
|
|
+ int mustCall = sqlite3_column_int(stmt, 1);
|
|
|
+ NSString *internalNotes = [self textAtColumn:2 statement:stmt];
|
|
|
+ NSString *generalNotes = [self textAtColumn:3 statement:stmt];
|
|
|
+
|
|
|
+ NSDictionary *po_dic = @{
|
|
|
+ @"aname" : @"PO#",
|
|
|
+ @"control" : @"edit",
|
|
|
+ @"keyboard" : @"text",
|
|
|
+ @"name" : @"poNumber",
|
|
|
+ @"value" : poNumber
|
|
|
+ };
|
|
|
+ NSDictionary *must_call_dic = @{
|
|
|
+ @"aname" : @"MUST CALL BEFORE DELIVERY",
|
|
|
+ @"control" : @"switch",
|
|
|
+ @"name" : @"must_call",
|
|
|
+ @"value" : mustCall ? @"true" : @"false"
|
|
|
+ };
|
|
|
+
|
|
|
+ NSDictionary *general_notes_dic = @{
|
|
|
+ @"aname" : @"General notes",
|
|
|
+ @"control" : @"text_view",
|
|
|
+ @"keyboard" : @"text",
|
|
|
+ @"name" : @"comments",
|
|
|
+ @"value" : generalNotes
|
|
|
+ };
|
|
|
+
|
|
|
+ NSDictionary *internal_notes_dic = @{
|
|
|
+ @"aname" : @"Internal notes",
|
|
|
+ @"control" : @"text_view",
|
|
|
+ @"keyboard" : @"text",
|
|
|
+ @"name" : @"internal_notes",
|
|
|
+ @"value" : internalNotes
|
|
|
+ };
|
|
|
+
|
|
|
+ [dic setValue:po_dic forKey:@"item_0"];
|
|
|
+ [dic setValue:must_call_dic forKey:@"item_1"];
|
|
|
+ [dic setValue:general_notes_dic forKey:@"item_2"];
|
|
|
+ [dic setValue:internal_notes_dic forKey:@"item_3"];
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+ return dic;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSDictionary *)orderTotalDic:(NSDictionary *)params otherTotal:(NSDictionary *)total db:(sqlite3 *)db {
|
|
|
+ // params
|
|
|
+ NSString *orderCode = [self valueInParams:params key:@"orderCode"];
|
|
|
+ orderCode = [self translateSingleQuote:orderCode];
|
|
|
+
|
|
|
+ NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
+
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select lift_gate,lift_gate_value,shipping,handling_fee_value from offline_order where so_id = '%@';",orderCode];
|
|
|
+
|
|
|
+ __block double lift_gate_value = 0;
|
|
|
+ __block double handling_fee = 0;
|
|
|
+ __block double shipping = 0;
|
|
|
+
|
|
|
+ [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
+
|
|
|
+ int lift_gate = sqlite3_column_int(stmt, 0);
|
|
|
+ lift_gate_value = sqlite3_column_double(stmt, 1);
|
|
|
+ shipping = sqlite3_column_double(stmt, 2);
|
|
|
+ handling_fee = sqlite3_column_double(stmt, 3);
|
|
|
+
|
|
|
+ if (!lift_gate) {
|
|
|
+ lift_gate_value = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ double totalCuft = [[total valueForKey:@"totalCuft"] doubleValue];
|
|
|
+ double totalWeight = [[total valueForKey:@"totalWeight"] doubleValue];
|
|
|
+ int totalCarton = [[total valueForKey:@"totalCarton"] doubleValue];
|
|
|
+ double payments = [[total valueForKey:@"payments"] doubleValue];
|
|
|
+ double totalPrice = payments + lift_gate_value + shipping + handling_fee;
|
|
|
+
|
|
|
+ [dic setValue:@"Order Total" forKey:@"title"];
|
|
|
+
|
|
|
+ NSDictionary *payments_dic = @{
|
|
|
+ @"align" : @"right",
|
|
|
+ @"aname" : @"Payments/Credits",
|
|
|
+ @"control" : @"text",
|
|
|
+ @"name" : @"paymentsAndCredits",
|
|
|
+ @"type" : @"price",
|
|
|
+ @"value" : [NSString stringWithFormat:@"%.2f",payments]
|
|
|
+ };
|
|
|
+ [dic setValue:payments_dic forKey:@"item_0"];
|
|
|
+
|
|
|
+ NSDictionary *handling_fee_dic = @{
|
|
|
+ @"align" : @"right",
|
|
|
+ @"aname" : @"Handling Fee",
|
|
|
+ @"control" : @"text",
|
|
|
+ @"name" : @"handling_fee_value",
|
|
|
+ @"required" : @"true",
|
|
|
+ @"type" : @"price",
|
|
|
+ @"value" : [NSString stringWithFormat:@"%.2f",handling_fee]
|
|
|
+ };
|
|
|
+ [dic setValue:handling_fee_dic forKey:@"item_1"];
|
|
|
+
|
|
|
+ NSDictionary *total_price_dic = @{
|
|
|
+ @"align" : @"right",
|
|
|
+ @"aname" : @"Total",
|
|
|
+ @"control" : @"text",
|
|
|
+ @"name" : @"totalPrice",
|
|
|
+ @"type" : @"price",
|
|
|
+ @"value" : [NSString stringWithFormat:@"%.2f",totalPrice]
|
|
|
+ };
|
|
|
+ [dic setValue:total_price_dic forKey:@"item_2"];
|
|
|
+
|
|
|
+ NSDictionary *total_cuft_dic = @{
|
|
|
+ @"align" : @"right",
|
|
|
+ @"aname" : @"Total Cuft",
|
|
|
+ @"control" : @"text",
|
|
|
+ @"name" : @"",
|
|
|
+ @"value" : [NSString stringWithFormat:@"%.2f",totalCuft]
|
|
|
+ };
|
|
|
+ [dic setValue:total_cuft_dic forKey:@"item_3"];
|
|
|
+
|
|
|
+ NSDictionary *total_weight_dic = @{
|
|
|
+ @"align" : @"right",
|
|
|
+ @"aname" : @"Total Weight",
|
|
|
+ @"control" : @"text",
|
|
|
+ @"name" : @"",
|
|
|
+ @"value" : [NSString stringWithFormat:@"%.2f",totalWeight]
|
|
|
+ };
|
|
|
+ [dic setValue:total_weight_dic forKey:@"item_4"];
|
|
|
+
|
|
|
+ NSDictionary *total_carton_dic = @{
|
|
|
+ @"align" : @"right",
|
|
|
+ @"aname" : @"Total Carton",
|
|
|
+ @"control" : @"text",
|
|
|
+ @"name" : @"",
|
|
|
+ @"value" : [NSString stringWithFormat:@"%d",totalCarton]
|
|
|
+ };
|
|
|
+ [dic setValue:total_carton_dic forKey:@"item_5"];
|
|
|
+
|
|
|
+ return dic;
|
|
|
+}
|
|
|
+
|
|
|
++ (NSDictionary *)signatureDic:(NSDictionary *)params db:(sqlite3 *)db {
|
|
|
+
|
|
|
+ NSString *orderCode = [self valueInParams:params key:@"orderCode"];
|
|
|
+ orderCode = [self translateSingleQuote:orderCode];
|
|
|
+
|
|
|
+ NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
+
|
|
|
+ [dic setValue:@"Signature" forKey:@"title"];
|
|
|
+
|
|
|
+ __block NSString *pic_path = @"";
|
|
|
+
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select sign_picpath from offline_order where so_id = '%@';",orderCode];
|
|
|
+
|
|
|
+ [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
+
|
|
|
+ pic_path = [self textAtColumn:0 statement:stmt];
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ NSDictionary *pic_dic = @{
|
|
|
+ @"aname" : @"Signature",
|
|
|
+ @"avalue" :pic_path,
|
|
|
+ @"control" : @"signature",
|
|
|
+ @"name" : @"sign_picpath",
|
|
|
+ @"value" : pic_path
|
|
|
+ };
|
|
|
+ [dic setValue:pic_dic forKey:@"item_0"];
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:1] forKey:@"count"];
|
|
|
+
|
|
|
+ return dic;
|
|
|
+}
|
|
|
|
|
|
+(NSData*) offline_placeorder :(NSMutableDictionary *) params
|
|
|
{
|
|
|
@@ -5944,20 +6798,54 @@
|
|
|
// 3 Customer
|
|
|
NSDictionary *customer_dic = [self customerDic:params db:db];
|
|
|
[ret setValue:customer_dic forKey:@"section_3"];
|
|
|
-
|
|
|
- NSString *sql = [NSString stringWithFormat:@"select o._id,o.so_id,o.poNumber,o.create_time,o.status,decrypt(c.company_name),o.customer_contact,decrypt(c.addr_1),c.addr_2,c.addr_3,c.addr_4,o.logist,o.shipping,o.lift_gate_value,o.general_notes,o.internal_notes,o.paymentType,o.lift_gate,o.receive_name,o.receive_contact,o.receive_ext,o.sender_name,o.sender_contact,o.sender_ext,o.shipping_billto_name,o.shipping_billto_contact,o.shipping_billto_ext,o.billing_name,o.billing_contact,o.billing_ext,o.returnto_name,o.returnto_contact,o.returnto_ext,o.handling_fee_value,o.paymentsAndCredits,o.total_price,o.customer_cid,o.credit_card_first_name,o.credit_card_last_name,o.credit_card_address1,o.credit_card_address2,o.credit_card_zipcode,o.credit_card_type,decrypt(o.credit_card_number),decrypt(o.credit_card_security_code),decrypt(o.credit_card_expiration_month),o.credit_card_city,o.credit_card_state,o.shipNull,o.erpOrderStatus,decrypt(o.credit_card_expiration_year),o.sign_picpath from (select _id,so_id,poNumber,create_time,status,customer_cid,customer_contact,logist,shipping,lift_gate_value,general_notes,internal_notes,paymentType,lift_gate,receive_name,receive_contact,receive_ext,sender_name,sender_contact,sender_ext,shipping_billto_name,shipping_billto_contact,shipping_billto_ext,billing_name,billing_contact,billing_ext,returnto_name,returnto_contact,returnto_ext,handling_fee_value,paymentsAndCredits,total_price,customer_cid,credit_card_first_name,credit_card_last_name,credit_card_address1,credit_card_address2,credit_card_zipcode,credit_card_type,credit_card_number,credit_card_security_code,credit_card_expiration_month,credit_card_city,credit_card_state,ifnull(shipping,'ship_null') as shipNull,erpOrderStatus,credit_card_expiration_year,sign_picpath from offline_order where so_id = %@) o left join offline_contact c on o.customer_cid=c.contact_id",orderCode];
|
|
|
+
|
|
|
// 4 Ship To
|
|
|
+ NSDictionary *ship_to_dic = [self shipToDic:params db:db];
|
|
|
+ [ret setValue:ship_to_dic forKey:@"section_4"];
|
|
|
+
|
|
|
// 5 Ship From
|
|
|
+ NSDictionary *ship_from_dic = [self shipFromDic:params db:db];
|
|
|
+ [ret setValue:ship_from_dic forKey:@"section_5"];
|
|
|
+
|
|
|
// 6 Freight Bill To
|
|
|
+ NSDictionary *freight_bill_to = [self freightBillToDic:params db:db];
|
|
|
+ [ret setValue:freight_bill_to forKey:@"section_6"];
|
|
|
+
|
|
|
// 7 Merchandise Bill To
|
|
|
+ NSDictionary *merchandise_bill_to_dic = [self merchandiseBillToDic:params db:db];
|
|
|
+ [ret setValue:merchandise_bill_to_dic forKey:@"section_7"];
|
|
|
+
|
|
|
// 8 Return To
|
|
|
+ NSDictionary *return_to_dic = [self returnToDic:params db:db];
|
|
|
+ [ret setValue:return_to_dic forKey:@"section_8"];
|
|
|
+
|
|
|
// 9 Model Information
|
|
|
+ NSMutableDictionary *model_info_dic = [[self modelInfoDic:params db:db] mutableCopy];
|
|
|
+
|
|
|
+ NSDictionary *toOrderTotal = [model_info_dic valueForKey:@"toOrderTotal"];
|
|
|
+ [model_info_dic removeObjectForKey:@"toOrderTotal"];
|
|
|
+
|
|
|
+ [ret setValue:model_info_dic forKey:@"section_9"];
|
|
|
+
|
|
|
// 10 Remarks Content
|
|
|
+ NSDictionary *remarks_content_dic = [self remarksContentDic:params db:db];
|
|
|
+
|
|
|
+ [ret setValue:remarks_content_dic forKey:@"section_10"];
|
|
|
+
|
|
|
// 11 Order Total
|
|
|
+ NSDictionary *order_total_dic = [self orderTotalDic:params otherTotal:toOrderTotal db:db];
|
|
|
+
|
|
|
+ [ret setValue:order_total_dic forKey:@"section_11"];
|
|
|
+
|
|
|
// 12 Signature
|
|
|
+ NSDictionary *sign_dic = [self signatureDic:params db:db];
|
|
|
|
|
|
-// return [RAUtils dict2data:ret];
|
|
|
- return nil;
|
|
|
+ [ret setValue:sign_dic forKey:@"section_12"];
|
|
|
+
|
|
|
+ [iSalesDB close_db:db];
|
|
|
+
|
|
|
+ return [RAUtils dict2data:ret];
|
|
|
+// return nil;
|
|
|
}
|
|
|
|
|
|
#pragma mark cancel order
|