|
|
@@ -3004,6 +3004,10 @@
|
|
|
return [[dic objectForKey:key] mutableCopy];
|
|
|
}
|
|
|
|
|
|
++ (NSString *)translateSingleQuote:(NSString *)string {
|
|
|
+ return [string stringByReplacingOccurrencesOfString:@"'" withString:@"''"];
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark create new contact
|
|
|
|
|
|
+ (NSData *)offline_createContact:(NSMutableDictionary *)params {
|
|
|
@@ -3096,6 +3100,7 @@
|
|
|
} else {
|
|
|
companyName = @"";
|
|
|
}
|
|
|
+ companyName = [self translateSingleQuote:companyName];
|
|
|
|
|
|
NSString *addr1 = [params objectForKey:@"address"];
|
|
|
if (addr1) {
|
|
|
@@ -3103,18 +3108,25 @@
|
|
|
} else {
|
|
|
addr1 = @"";
|
|
|
}
|
|
|
+ addr1 = [self translateSingleQuote:addr1];
|
|
|
+
|
|
|
NSString *addr2 = [params objectForKey:@"address2"];
|
|
|
if (!addr2) {
|
|
|
addr2 = @"";
|
|
|
}
|
|
|
+ addr2 = [self translateSingleQuote:addr2];
|
|
|
+
|
|
|
NSString *addr3 = [params objectForKey:@"address_3"];
|
|
|
if (!addr3) {
|
|
|
addr3 = @"";
|
|
|
}
|
|
|
+ addr3 = [self translateSingleQuote:addr3];
|
|
|
+
|
|
|
NSString *addr4 = [params objectForKey:@"address_4"];
|
|
|
if (!addr4) {
|
|
|
addr4 = @"";
|
|
|
}
|
|
|
+ addr4 = [self translateSingleQuote:addr4];
|
|
|
|
|
|
NSString *country = [params objectForKey:@"country"];
|
|
|
if (country) {
|
|
|
@@ -3122,27 +3134,37 @@
|
|
|
} else {
|
|
|
country = @"";
|
|
|
}
|
|
|
+ country = [self translateSingleQuote:country];
|
|
|
+
|
|
|
NSString *state = [params objectForKey:@"state"];
|
|
|
if (!state) {
|
|
|
state = @"";
|
|
|
}
|
|
|
+ state = [self translateSingleQuote:state];
|
|
|
+
|
|
|
NSString *city = [params objectForKey:@"city"];
|
|
|
if (!city) {
|
|
|
city = @"";
|
|
|
}
|
|
|
+ city = [self translateSingleQuote:city];
|
|
|
+
|
|
|
NSString *zipcode = [params objectForKey:@"zipcode"];
|
|
|
if (!zipcode) {
|
|
|
zipcode = @"";
|
|
|
}
|
|
|
+ zipcode = [self translateSingleQuote:zipcode];
|
|
|
|
|
|
NSString *fistName = [params objectForKey:@"firstname"];
|
|
|
if (!fistName) {
|
|
|
fistName = @"";
|
|
|
}
|
|
|
+ fistName = [self translateSingleQuote:fistName];
|
|
|
+
|
|
|
NSString *lastName = [params objectForKey:@"lastname"];
|
|
|
if (!lastName) {
|
|
|
lastName = @"";
|
|
|
}
|
|
|
+ lastName = [self translateSingleQuote:lastName];
|
|
|
|
|
|
NSString *phone = [params objectForKey:@"phone"];
|
|
|
if (phone) {
|
|
|
@@ -3150,19 +3172,25 @@
|
|
|
} else {
|
|
|
phone = @"";
|
|
|
}
|
|
|
+ phone = [self translateSingleQuote:phone];
|
|
|
|
|
|
NSString *fax = [params objectForKey:@"fax"];
|
|
|
if (!fax) {
|
|
|
fax = @"";
|
|
|
}
|
|
|
+ fax = [self translateSingleQuote:fax];
|
|
|
+
|
|
|
NSString *email = [params objectForKey:@"email"];
|
|
|
if (!email) {
|
|
|
email = @"";
|
|
|
}
|
|
|
+ email = [self translateSingleQuote:email];
|
|
|
+
|
|
|
NSString *notes = [params objectForKey:@"contact_notes"];
|
|
|
if (!notes) {
|
|
|
notes = @"";
|
|
|
}
|
|
|
+ notes = [self translateSingleQuote:notes];
|
|
|
|
|
|
NSString *price = [params objectForKey:@"price_name"];
|
|
|
if (price) {
|
|
|
@@ -3170,12 +3198,15 @@
|
|
|
} else {
|
|
|
price = @"";
|
|
|
}
|
|
|
+ price = [self translateSingleQuote:price];
|
|
|
+
|
|
|
NSString *salesRep = [params objectForKey:@"sales_rep"];
|
|
|
if (salesRep) {
|
|
|
salesRep = [self salesRepCodeById:salesRep];
|
|
|
} else {
|
|
|
salesRep = @"";
|
|
|
}
|
|
|
+ salesRep = [self translateSingleQuote:salesRep];
|
|
|
|
|
|
NSString *img = [params objectForKey:@"business_card"];
|
|
|
NSArray *array = [img componentsSeparatedByString:@","];
|
|
|
@@ -3183,19 +3214,25 @@
|
|
|
if (!img_0) {
|
|
|
img_0 = @"";
|
|
|
}
|
|
|
+ img_0 = [self translateSingleQuote:img_0];
|
|
|
+
|
|
|
NSString *img_1 = array[1];
|
|
|
if (!img_1) {
|
|
|
img_1 = @"";
|
|
|
}
|
|
|
+ img_1 = [self translateSingleQuote:img_1];
|
|
|
+
|
|
|
NSString *img_2 = array[2];
|
|
|
if (!img_2) {
|
|
|
img_2 = @"";
|
|
|
}
|
|
|
+ img_2 = [self translateSingleQuote:img_2];
|
|
|
|
|
|
NSString *contact_id = [NSUUID UUID].UUIDString;
|
|
|
|
|
|
NSMutableDictionary *sync_dic = [params mutableCopy];
|
|
|
|
|
|
+
|
|
|
NSString *sync_data = nil;
|
|
|
|
|
|
NSString *sql = nil;
|
|
|
@@ -3205,14 +3242,19 @@
|
|
|
contact_id = @"";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
[sync_dic setValue:contact_id forKey:@"contact_id"];
|
|
|
sync_data = [RAUtils dict2string:sync_dic];
|
|
|
+ sync_data = [self translateSingleQuote:sync_data];
|
|
|
|
|
|
sql = [NSString stringWithFormat:@"update offline_contact set company_name = '%@',addr_1 = '%@',addr_2 = '%@',addr_3 = '%@',addr_4 = '%@',country = '%@',state = '%@',city = '%@',zipcode = '%@',first_name = '%@',last_name = '%@',phone = '%@',fax = '%@',email = '%@',notes = '%@',price_type = '%@',sales_rep = '%@',img_0 = '%@',img_1 = '%@',img_2 = '%@',sync_data = '%@' where contact_id = '%@';",companyName,addr1,addr2,addr3,addr4,country,state,city,zipcode,fistName,lastName,phone,fax,email,notes,price,salesRep,img_0,img_1,img_2,sync_data,contact_id];
|
|
|
} else {
|
|
|
|
|
|
+ contact_id = [self translateSingleQuote:contact_id];
|
|
|
+
|
|
|
[sync_dic setValue:contact_id forKey:@"contact_id"];
|
|
|
sync_data = [RAUtils dict2string:sync_dic];
|
|
|
+ sync_data = [self translateSingleQuote:sync_data];
|
|
|
|
|
|
sql = [NSString stringWithFormat:@"insert into offline_contact (company_name,addr_1,addr_2,addr_3,addr_4,country,state,city,zipcode,first_name,last_name,phone,fax,email,notes,price_type,sales_rep,img_0,img_1,img_2,editable,contact_id,Sales_Order_Customer,Sales_Order_Freight_Bill_To,Sales_Order_Ship_From,Sales_Order_Merchandise_Bill_To,Contact_Return_To,Sales_Order_Ship_To,sync_data) values ('%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@','%@',1,'%@',1,1,0,1,0,1,'%@')",companyName,addr1,addr2,addr3,addr4,country,state,city,zipcode,fistName,lastName,phone,fax,email,notes,price,salesRep,img_0,img_1,img_2,contact_id,sync_data];
|
|
|
}
|