|
|
@@ -1255,7 +1255,7 @@
|
|
|
NSString *contact_name=[RAUtils arr2string:arr_name separator:@" " trim:true];
|
|
|
|
|
|
|
|
|
- NSString* sql_neworder=[NSString stringWithFormat:@"insert into offline_order(so_id,status,customer_cid,customer_contact,customer_email,customer_fax,customer_phone,sales_rep,create_by,customer_contact) values('OFFLINE'||hex(randomblob(16)),-1,'%@','%@','%@','%@','%@','%@','%@','%@')",customer_cid,customer_contact,customer_email,customer_fax,customer_phone,customer_sales_rep,create_by ,contact_name];
|
|
|
+ NSString* sql_neworder=[NSString stringWithFormat:@"insert into offline_order(so_id,status,customer_cid,customer_contact,customer_email,customer_fax,customer_phone,sales_rep,create_by,customer_contact) values('OFFLINE'||hex(randomblob(16)),0,'%@','%@','%@','%@','%@','%@','%@','%@')",customer_cid,customer_contact,customer_email,customer_fax,customer_phone,customer_sales_rep,create_by ,contact_name];
|
|
|
|
|
|
int result =[iSalesDB execSql:sql_neworder ];
|
|
|
[ret setValue:[NSNumber numberWithInt:result] forKey:@"result"];
|
|
|
@@ -1368,7 +1368,223 @@
|
|
|
}
|
|
|
+(NSData*) offline_orderdetail :(NSMutableDictionary *) params
|
|
|
{
|
|
|
- return nil;
|
|
|
+
|
|
|
+ int orderId = [params[@"orderId"] intValue];
|
|
|
+ NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
+// [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"debug_category_filter" ofType:@"json" ]];
|
|
|
+
|
|
|
+// NSString* content = [NSString stringWithContentsOfFile:thepath encoding:NSUTF8StringEncoding error:nil];
|
|
|
+
|
|
|
+ NSString* sql=[NSString stringWithFormat:@"select o._id,o.so_id,o.poNumber,o.create_time,o.status,o.TotalCuft,o.TotalWeight,o.TotalCarton,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 from (select _id,so_id,poNumber,create_time,status,TotalCuft,TotalWeight,TotalCarton,customer_cid,customer_contact,logist,shipping,lift_gate_value,general_notes,internal_notes,paymentType,lift_gate from offline_order where _id=%d) o left join offline_contact c on o.customer_cid=c.contact_id",orderId ];
|
|
|
+ sqlite3 *db = [iSalesDB get_db];
|
|
|
+ sqlite3_stmt * statement;
|
|
|
+
|
|
|
+
|
|
|
+ if (sqlite3_prepare_v2(db, [sql UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ if (sqlite3_step(statement) == SQLITE_ROW)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// NSMutableDictionary* item=[[NSMutableDictionary alloc]init];
|
|
|
+
|
|
|
+ int order_id = sqlite3_column_int(statement, 0);
|
|
|
+
|
|
|
+
|
|
|
+ char *soid = (char*)sqlite3_column_text(statement, 1);
|
|
|
+ if(soid==nil)
|
|
|
+ soid= "";
|
|
|
+ NSString *nssoid= [[NSString alloc]initWithUTF8String:soid];
|
|
|
+
|
|
|
+
|
|
|
+ char *poNumber = (char*)sqlite3_column_text(statement, 2);
|
|
|
+ if(poNumber==nil)
|
|
|
+ poNumber= "";
|
|
|
+ NSString *nspoNumber= [[NSString alloc]initWithUTF8String:poNumber];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ char *create_time = (char*)sqlite3_column_text(statement, 3);
|
|
|
+ if(create_time==nil)
|
|
|
+ create_time= "";
|
|
|
+ NSString *nscreate_time= [[NSString alloc]initWithUTF8String:create_time];
|
|
|
+
|
|
|
+ int status = sqlite3_column_int(statement, 4);
|
|
|
+ NSString* nsstatus=@"";
|
|
|
+ switch (status) {
|
|
|
+ case 0:
|
|
|
+ {
|
|
|
+ nsstatus=@"Temp Order";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 1:
|
|
|
+ {
|
|
|
+ nsstatus=@"Saved Order";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 10:
|
|
|
+ {
|
|
|
+ nsstatus=@"Quote Submitted";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 11:
|
|
|
+ {
|
|
|
+ nsstatus=@"Sales Order Submitted";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 12:
|
|
|
+ {
|
|
|
+ nsstatus=@"Processing";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 13:
|
|
|
+ {
|
|
|
+ nsstatus=@"Shipped";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 14:
|
|
|
+ {
|
|
|
+ nsstatus=@"Closed";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 15:
|
|
|
+ {
|
|
|
+ nsstatus=@"Cancelled";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ double TotalCuft = sqlite3_column_double(statement, 5);
|
|
|
+ double TotalWeight = sqlite3_column_double(statement, 6);
|
|
|
+ double TotalCarton = sqlite3_column_double(statement, 7);
|
|
|
+
|
|
|
+
|
|
|
+ char *company_name = (char*)sqlite3_column_text(statement, 8);
|
|
|
+ if(company_name==nil)
|
|
|
+ company_name= "";
|
|
|
+ NSString *nscompany_name= [[NSString alloc]initWithUTF8String:company_name];
|
|
|
+
|
|
|
+
|
|
|
+ char *customer_contact = (char*)sqlite3_column_text(statement, 9);
|
|
|
+ if(customer_contact==nil)
|
|
|
+ customer_contact= "";
|
|
|
+ NSString *nscustomer_contact= [[NSString alloc]initWithUTF8String:customer_contact];
|
|
|
+
|
|
|
+
|
|
|
+ char *addr_1 = (char*)sqlite3_column_text(statement, 10);
|
|
|
+ if(addr_1==nil)
|
|
|
+ addr_1="";
|
|
|
+ NSString *nsaddr_1= [[NSString alloc]initWithUTF8String:addr_1];
|
|
|
+
|
|
|
+ char *addr_2 = (char*)sqlite3_column_text(statement, 11);
|
|
|
+ if(addr_2==nil)
|
|
|
+ addr_2="";
|
|
|
+ NSString *nsaddr_2= [[NSString alloc]initWithUTF8String:addr_2];
|
|
|
+
|
|
|
+
|
|
|
+ char *addr_3 = (char*)sqlite3_column_text(statement, 12);
|
|
|
+ if(addr_3==nil)
|
|
|
+ addr_3="";
|
|
|
+ NSString *nsaddr_3= [[NSString alloc]initWithUTF8String:addr_3];
|
|
|
+
|
|
|
+
|
|
|
+ char *addr_4 = (char*)sqlite3_column_text(statement, 13);
|
|
|
+ if(addr_4==nil)
|
|
|
+ addr_4="";
|
|
|
+ NSString *nsaddr_4= [[NSString alloc]initWithUTF8String:addr_4];
|
|
|
+
|
|
|
+ NSMutableArray* arr_addr = [[NSMutableArray alloc] init];
|
|
|
+ [arr_addr addObject:nsaddr_1];
|
|
|
+ [arr_addr addObject:nsaddr_2];
|
|
|
+ [arr_addr addObject:nsaddr_3];
|
|
|
+ [arr_addr addObject:nsaddr_4];
|
|
|
+ NSString * customer_address = [RAUtils arr2string:arr_addr separator:@"<br>" trim:true];
|
|
|
+
|
|
|
+
|
|
|
+ char *logist = (char*)sqlite3_column_text(statement, 14);
|
|
|
+ if(logist==nil)
|
|
|
+ logist= "";
|
|
|
+ NSString *nslogist=[[NSString alloc]initWithUTF8String:logist];
|
|
|
+
|
|
|
+ double shipping = sqlite3_column_double(statement, 15);
|
|
|
+
|
|
|
+ double lift_gate = sqlite3_column_double(statement, 16);
|
|
|
+
|
|
|
+ char *general_notes = (char*)sqlite3_column_text(statement, 17);
|
|
|
+ if(general_notes==nil)
|
|
|
+ general_notes= "";
|
|
|
+ NSString *nsgeneral_notes=[[NSString alloc]initWithUTF8String:general_notes];
|
|
|
+
|
|
|
+ char *internal_notes = (char*)sqlite3_column_text(statement, 18);
|
|
|
+ if(internal_notes==nil)
|
|
|
+ internal_notes= "";
|
|
|
+ NSString *nsinternal_notes=[[NSString alloc]initWithUTF8String:internal_notes];
|
|
|
+
|
|
|
+ char *payment_type = (char*)sqlite3_column_text(statement, 19);
|
|
|
+ if(payment_type==nil)
|
|
|
+ payment_type= "";
|
|
|
+ NSString *nspayment_type=[[NSString alloc]initWithUTF8String:payment_type];
|
|
|
+
|
|
|
+ int have_lift_gate = sqlite3_column_int(statement, 20);
|
|
|
+
|
|
|
+ NSError *error = nil;
|
|
|
+ NSString* orderinfo = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"orderinfo" ofType:@"template"] encoding:NSUTF8StringEncoding error:&error];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"SO_PLACEHOLDER" withString:nssoid];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"PO_PLACEHOLDER" withString:nspoNumber];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"ORDERDATE_PLACEHOLDER" withString:nscreate_time];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"ORDERSTATUS_PLACEHOLDER" withString:nsstatus];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"CUFT_PLACEHOLDER" withString:[NSString stringWithFormat:@"%.2f",TotalCuft]];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"WEIGHT_PLACEHOLDER" withString:[NSString stringWithFormat:@"%.2f",TotalWeight]];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"CARTON_PLACEHOLDER" withString:[NSString stringWithFormat:@"%.2f",TotalCarton]];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"COMPANY_PLACEHOLDER" withString:nscompany_name];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"CONTACT_PLACEHOLDER" withString:nscustomer_contact];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"ADDRESS_PLACEHOLDER" withString:customer_address];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"SHIPPINGMETHOD_PLACEHOLDER" withString:nslogist];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"SHIPPING_PLACEHOLDER" withString:[NSString stringWithFormat:@"%.2f",shipping]];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"LIFTGATE_PLACEHOLDER" withString:[NSString stringWithFormat:@"%.2f",lift_gate]];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"GENERALNOTES_PLACEHOLDER" withString:nsgeneral_notes];
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"INTERNALNOTES_PLACEHOLDER" withString:nsinternal_notes];
|
|
|
+
|
|
|
+ NSString *payment = nil;
|
|
|
+ if([nspayment_type isEqualToString:@"Credit Card"])
|
|
|
+ {
|
|
|
+ payment=[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"creditcardpayment" ofType:@"template"] encoding:NSUTF8StringEncoding error:&error];
|
|
|
+ //payment=[payment stringByReplacingOccurrencesOfString:@"PAYMENTTYPE_PLACEHOLDER" withString:nspayment_type];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ payment=[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"normalpayment" ofType:@"template"] encoding:NSUTF8StringEncoding error:&error];
|
|
|
+ payment=[payment stringByReplacingOccurrencesOfString:@"PAYMENTTYPE_PLACEHOLDER" withString:nspayment_type];
|
|
|
+ }
|
|
|
+ orderinfo=[orderinfo stringByReplacingOccurrencesOfString:@"PAYMENT_PLACEHOLDER" withString:payment];
|
|
|
+ ret[@"order_info"]= orderinfo;
|
|
|
+ ret[@"result"]= [NSNumber numberWithInt:2];
|
|
|
+
|
|
|
+ ret[@"result"]= [NSNumber numberWithInt:2];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ sqlite3_finalize(statement);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ [iSalesDB close_db:db];
|
|
|
+
|
|
|
+
|
|
|
+ return [RAUtils dict2data:ret];
|
|
|
}
|
|
|
|
|
|
+(NSDictionary*) offline_login :(NSMutableDictionary *) params
|