Преглед изворни кода

增加方法customerInfoName: aname: control: keyboard: value: 和 customerDic: params db:,实现placeorder 方法中customer Info 部分。

Pen Li пре 9 година
родитељ
комит
b388a7f356

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


+ 157 - 4
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -5782,18 +5782,170 @@
 
 #pragma mark place order
 
++ (NSDictionary *)customerInfoName:(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 (keyboard) {
+        [dic setValue:keyboard forKey:@"keyboard"];
+    }
+    [dic setValue:name forKey:@"name"];
+    [dic setValue:value forKey:@"value"];
+    
+    return dic;
+}
+
++ (NSDictionary *)customerDic:(NSDictionary *) params db:(sqlite3 *)db {
+    
+    NSString *orderCode = [self valueInParams:params key:@"orderCode"];
+    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];
+    [iSalesDB jk_query:customerSql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
+        
+        NSString *contact_id = [self textAtColumn:0 statement:stmt];
+        NSString *img0 = [self textAtColumn:1 statement:stmt];
+        NSString *img1 = [self textAtColumn:2 statement:stmt];
+        NSString *img2 = [self textAtColumn:3 statement:stmt];
+        NSString *company_name = [self textAtColumn:4 statement:stmt];
+        NSString *addr1 = [self textAtColumn:5 statement:stmt];
+        NSString *addr2 = [self textAtColumn:6 statement:stmt];
+        NSString *addr3 = [self textAtColumn:7 statement:stmt];
+        NSString *addr4 = [self textAtColumn:8 statement:stmt];
+        NSString *first_name = [self textAtColumn:9 statement:stmt];
+        NSString *last_name = [self textAtColumn:10 statement:stmt];
+        NSString *email = [self textAtColumn:11 statement:stmt];
+        NSString *phone = [self textAtColumn:12 statement:stmt];
+        NSString *fax = [self textAtColumn:13 statement:stmt];
+        NSString *zipcode = [self textAtColumn:14 statement:stmt];
+        NSString *city = [self textAtColumn:15 statement:stmt];
+        NSString *state = [self textAtColumn:16 statement:stmt];
+        NSString *country = [self textAtColumn:17 statement:stmt];
+        
+        NSString *name = [first_name stringByAppendingFormat:@" %@",last_name];
+        
+        // contact id
+        NSMutableDictionary *contact_id_dic = [NSMutableDictionary dictionary];
+        [contact_id_dic setValue:@"Contact ID" forKey:@"aname"];
+        [contact_id_dic setValue:@"text" forKey:@"control"];
+        [contact_id_dic setValue:@"text" forKey:@"keyboard"];
+        [contact_id_dic setValue:@"customer_cid" forKey:@"name"];
+        [contact_id_dic setValue:@"true" forKey:@"required"];
+        [contact_id_dic setValue:contact_id forKey:@"value"];
+        
+        [customer_dic setValue:contact_id_dic forKey:@"item_0"];
+        
+        // business card
+        NSMutableDictionary *business_card_dic = [NSMutableDictionary dictionary];
+        [business_card_dic setValue:@"Business Card" forKey:@"aname"];
+        [business_card_dic setValue:@"img" forKey:@"control"];
+        [business_card_dic setValue:@"1" forKey:@"disable"];
+        [business_card_dic setValue:img0 forKey:@"img_url_0"];
+        [business_card_dic setValue:img1 forKey:@"img_url_1"];
+        [business_card_dic setValue:img2 forKey:@"img_url_2"];
+        [business_card_dic setValue:img0 forKey:@"img_url_aname_0"];
+        [business_card_dic setValue:img1 forKey:@"img_url_aname_1"];
+        [business_card_dic setValue:img2 forKey:@"img_url_aname_2"];
+        [business_card_dic setValue:@"business_card" forKey:@"name"];
+        
+        [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];
+        
+        [customer_dic setValue:fax_dic forKey:@"item_10"];
+        
+        // zipcode
+        NSDictionary *zipcode_dic = [self customerInfoName:@"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];
+        
+        [customer_dic setValue:city_dic forKey:@"item_12"];
+        
+        // state
+        NSDictionary *state_dic = [self customerInfoName:@"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];
+        
+        [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];
+        
+        [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];
+        
+        [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];
+        
+        [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];
+        
+        [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];
+        
+        [customer_dic setValue:addr4_dic forKey:@"item_6"];
+        
+        // Contact
+        NSDictionary *contact_dic = [self customerInfoName:@"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];
+        
+        [customer_dic setValue:email_dic forKey:@"item_8"];
+        
+        // phone
+        NSDictionary *phone_dic = [self customerInfoName:@"customer_phone" aname:@"Phone" control:@"edit" keyboard:@"text" value:phone];
+        
+        [customer_dic setValue:phone_dic forKey:@"item_9"];
+        
+        // title
+        [customer_dic setValue:@"Customer" forKey:@"title"];
+        
+        // count
+        [customer_dic setValue:[NSNumber numberWithInteger:15] forKey:@"count"];
+        
+    }];
+
+    return customer_dic;
+}
+
+
 +(NSData*) offline_placeorder :(NSMutableDictionary *) params
 {
+    
+    sqlite3 *db = [iSalesDB get_db];
+    
     // params
-    NSString *contactId = [self valueInParams:params key:@"contactId"];
     NSString *orderCode = [self valueInParams:params key:@"orderCode"];
+    orderCode = [self translateSingleQuote:orderCode];
     
     //  0 Order Type    1 Shipping Method       2 Payment Information
-    NSMutableDictionary *ret = [self dictionaryFileName:@"placeOrderTemplate.json"];
+    __block NSMutableDictionary *ret = [self dictionaryFileName:@"placeOrderTemplate.json"];
     
     //    3 Customer
-    NSDictionary *customerInfo = [self offline_contactinfo:[@{@"contactId":contactId} mutableCopy]];
+    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
     //    5 Ship From
     //    6 Freight Bill To
@@ -5804,7 +5956,8 @@
     //    11 Order Total
     //    12 Signature
     
-    return [RAUtils dict2data:ret];
+//    return [RAUtils dict2data:ret];
+    return nil;
 }
 
 #pragma mark cancel order