|
|
@@ -358,8 +358,8 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
{
|
|
|
|
|
|
|
|
|
-
|
|
|
- [dblock lock];
|
|
|
+
|
|
|
+ [dblock lock];
|
|
|
|
|
|
sqlite3* db = nil;
|
|
|
|
|
|
@@ -375,7 +375,7 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
DebugLog(@"sqlite3_open failed. msg:%s",sqlite3_errmsg(db));
|
|
|
[iSalesDB close_db:db];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
[self AddExFunction:db];
|
|
|
return db;
|
|
|
|
|
|
@@ -410,10 +410,10 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
if (sqlite3_open([path UTF8String], &db) != SQLITE_OK) {
|
|
|
|
|
|
DebugLog(@"sqlite3_open failed. msg:%s",sqlite3_errmsg(db));
|
|
|
- sqlite3_close(db);
|
|
|
+ sqlite3_close(db);
|
|
|
//[iSalesDB close_db:db];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return db;
|
|
|
|
|
|
}
|
|
|
@@ -619,25 +619,27 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
// end move;
|
|
|
|
|
|
|
|
|
- if(dblock==nil)
|
|
|
- dblock= [[NSLock alloc] init];
|
|
|
+ if(dblock==nil)
|
|
|
+ dblock= [[NSLock alloc] init];
|
|
|
|
|
|
|
|
|
-// [iSalesDB execSql:@"PRAGMA journal_mode = DELETE;"];
|
|
|
+ // [iSalesDB execSql:@"PRAGMA journal_mode = DELETE;"];
|
|
|
|
|
|
sqlite3 *db = [self get_db];
|
|
|
|
|
|
|
|
|
-// int result= [iSalesDB AddExFunction:db];
|
|
|
+ // int result= [iSalesDB AddExFunction:db];
|
|
|
+
|
|
|
+ // [iSalesDB execSql:@"update model_price set price=decrypt(price);" db:db];
|
|
|
|
|
|
-// [iSalesDB execSql:@"update model_price set price=decrypt(price);" db:db];
|
|
|
|
|
|
+ // [self execSql:@"PRAGMA journal_mode = WAL;" db:db];
|
|
|
|
|
|
- // [self execSql:@"PRAGMA journal_mode = WAL;" db:db];
|
|
|
+ NSString* create_product=@"CREATE TABLE IF NOT EXISTS product ( _id INTEGER PRIMARY KEY, name VARCHAR(20,0), description VARCHAR(20,0), product_id INTEGER, color VARCHAR(20,0), legcolor VARCHAR(20,0), availability INTEGER, incoming_stock INTEGER, ETA DATE, demension VARCHAR(20,0), seat_height VARCHAR(20,0), material VARCHAR(20,0), box_dim VARCHAR(20,0), volume VARCHAR(20,0), weight VARCHAR(20,0), model_set VARCHAR(20,0), load_ability VARCHAR(20,0), default_category VARCHAR(20,0), category VARCHAR(100,0), fabric_content VARCHAR(20,0), assembling VARCHAR(20,0), made_in VARCHAR(20,0), special_remarks VARCHAR(20,0), stockUom integer, fashion VARCHAR(20,0), isnew integer, property_field VARCHAR(20,0), property_display VARCHAR(20,0), selector_field VARCHAR(20,0), selector_display VARCHAR(20,0), product_group VARCHAR(20,0), packaging VARCHAR(20,0), closeout integer ,best_seller integer,alert VARCHAR(20,0),has_bundle integer,is_active integer,item_id integer);";
|
|
|
|
|
|
- NSString* create_model=@"CREATE TABLE IF NOT EXISTS model ( _id INTEGER, name VARCHAR(20,0), description VARCHAR(20,0), product_id INTEGER, color VARCHAR(20,0), legcolor VARCHAR(20,0), availability INTEGER, incoming_stock INTEGER, ETA DATE, demension VARCHAR(20,0), seat_height VARCHAR(20,0), material VARCHAR(20,0), box_dim VARCHAR(20,0), volume VARCHAR(20,0), weight VARCHAR(20,0), model_set VARCHAR(20,0), load_ability VARCHAR(20,0), default_category VARCHAR(20,0), category VARCHAR(100,0), fabric_content VARCHAR(20,0), assembling VARCHAR(20,0), made_in VARCHAR(20,0), special_remarks VARCHAR(20,0), stockUom integer, fashion VARCHAR(20,0), isnew integer, property_field VARCHAR(20,0), property_display VARCHAR(20,0), selector_field VARCHAR(20,0), selector_display VARCHAR(20,0), product_group VARCHAR(20,0), packaging VARCHAR(20,0), closeout integer ,best_seller integer,bundle_item text,alert VARCHAR(20,0),has_bundle integer,cuft double,weight1 double, carton integer,is_active integer,PRIMARY KEY(_id));";
|
|
|
+ NSString* create_catelog=@"CREATE TABLE IF NOT EXISTS catelog ( _id INTEGER PRIMARY KEY, name VARCHAR(20,0), description VARCHAR(20,0), item_id INTEGER,is_active integer,ulength float,uwidth float,uheight float,uweight float,pcs integer,mpack integer,mlength float,mwidth float,mheight float,mweigth float,ipack integer,ilength float,iwidth float,iheight float, iweight float,is_single_model integer, is_master_model integer,is_rate integer,is_part integer);";
|
|
|
|
|
|
- NSString* create_bundle=@"CREATE TABLE IF NOT EXISTS bundle ( _id INTEGER PRIMARY KEY, name text, description text,product_id integer,unit_price double,qty integer,cuft double,weight double,carton integer, serial_no VARCHAR(40,0));";
|
|
|
+ NSString* create_bundle=@"CREATE TABLE IF NOT EXISTS bundle ( _id INTEGER PRIMARY KEY, product_id integer,item_id integer,unit_price double,use_unitprice integer,qty integer);";
|
|
|
|
|
|
NSString* create_price=@"CREATE TABLE IF NOT EXISTS price ( _id INTEGER PRIMARY KEY, name text, type integer, order_by integer);";
|
|
|
|
|
|
@@ -645,9 +647,9 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
NSString* create_wishlist=@"CREATE TABLE IF NOT EXISTS wishlist ( _id INTEGER PRIMARY KEY, user_id INTEGER, product_id integer , create_time TIMESTAMP default (datetime('now', 'localtime')));";
|
|
|
|
|
|
|
|
|
- NSString* create_image=@"CREATE TABLE IF NOT EXISTS model_image ( _id INTEGER PRIMARY KEY, name VARCHAR(20), url text, type integer, product_id INTEGER, default_img integer,picture_id integer);";
|
|
|
+ NSString* create_image=@"CREATE TABLE IF NOT EXISTS model_image ( _id INTEGER PRIMARY KEY, name VARCHAR(20), url text, type integer, product_id INTEGER,item_id integer, default_img integer,picture_id integer);";
|
|
|
|
|
|
- NSString* create_model_price=@"CREATE TABLE IF NOT EXISTS model_price ( _id INTEGER PRIMARY KEY, product_id INTEGER,price text , type integer, price_name text, expire_datetime datetime);";
|
|
|
+ NSString* create_model_price=@"CREATE TABLE IF NOT EXISTS model_price ( _id INTEGER PRIMARY KEY, product_id INTEGER,item_id integer, price text , type integer, price_name text, expire_datetime datetime);";
|
|
|
|
|
|
//NSString* create_model_ext=@"CREATE TABLE IF NOT EXISTS model_ext ( _id INTEGER PRIMARY KEY, product_id INTEGER,carton integer, cuft double, weight double;";
|
|
|
|
|
|
@@ -657,18 +659,18 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
|
|
|
NSString* create_offline_login=@"CREATE TABLE IF NOT EXISTS offline_login ( _id INTEGER PRIMARY KEY, username VARCHAR(40),password VARCHAR(40), can_show_price integer ,can_see_price integer,contact_id VARCHAR(20),user_type integer,can_cancel_order integer,can_set_cart_price integer,can_create_portfolio integer, can_delete_order integer,can_submit_order integer,can_set_tearsheet_price integer,can_create_order integer, can_update_contact_info integer, mode VARCHAR(20), default_price text, price text, user_id integer,sales_code text);";
|
|
|
|
|
|
- NSString* create_offline_order=@"CREATE TABLE IF NOT EXISTS offline_order ( _id INTEGER PRIMARY KEY,so_id text, order_id text ,status integer, general_notes TEXT ,internal_notes text,signature text,user_type integer,contact_id text,sales_rep TEXT,create_by TEXT, total_price float, erpOrderStatus integer, logist text, lift_gate integer, logistic_note text, paymentType text, credit_card_first_name text, credit_card_last_name text, credit_card_address1 text, credit_card_address2 text, credit_card_zipcode text, credit_card_type text, credit_card_number text, credit_card_security_code text, credit_card_expiration text,credit_card_city text, credit_card_state text,customer_cid text,customer_contact text,customer_email text,customer_phone text,customer_fax text,receive_cid text,receive_name text,receive_ext text,receive_contact text, receive_phone text,receive_fax text,receive_email text,sender_cid text,sender_name text,sender_ext text,sender_contact text, sender_phone text,sender_fax text,sender_email text,shipping_billto_cid text,shipping_billto_name text,shipping_billto_ext text,shipping_billto_contact text, shipping_billto_phone text,shipping_billto_fax text,shipping_billto_email text,billing_cid text,billing_name text,billing_ext text,billing_contact text, billing_phone text,billing_fax text,billing_email text,returnto_cid text,returnto_name text,returnto_ext text,returnto_contact text, returnto_phone text,returnto_fax text,returnto_email text, must_call int,poNumber text,comments text,comments_ext text,paymentsAndCredits float,shipping float,lift_gate_value float,handling_fee_value float,TotalCuft float,TotalWeight float,TotalCarton float,sign_picpath text,type integer,sync_data text,create_time TIMESTAMP default (datetime('now', 'localtime')));";
|
|
|
+ NSString* create_offline_order=@"CREATE TABLE IF NOT EXISTS offline_order ( _id INTEGER PRIMARY KEY,so_id text, order_id text ,status integer, submit_as integer,general_notes TEXT ,internal_notes text,sales_rep TEXT,create_by TEXT, total_price float, erpOrderStatus integer, logist text, lift_gate integer, logistic_note text, paymentType text, credit_card_first_name text, credit_card_last_name text, credit_card_address1 text, credit_card_address2 text, credit_card_zipcode text, credit_card_type text, credit_card_number text, credit_card_security_code text, credit_card_expiration_month text , credit_card_expiration_year text,credit_card_city text, credit_card_state text,customer_cid text,customer_contact text,customer_email text,customer_phone text,customer_fax text,receive_cid text,receive_name text,receive_ext text,receive_contact text, receive_phone text,receive_fax text,receive_email text,sender_cid text,sender_name text,sender_ext text,sender_contact text, sender_phone text,sender_fax text,sender_email text,shipping_billto_cid text,shipping_billto_name text,shipping_billto_ext text,shipping_billto_contact text, shipping_billto_phone text,shipping_billto_fax text,shipping_billto_email text,billing_cid text,billing_name text,billing_ext text,billing_contact text, billing_phone text,billing_fax text,billing_email text,returnto_cid text,returnto_name text,returnto_ext text,returnto_contact text, returnto_phone text,returnto_fax text,returnto_email text, must_call int,poNumber text,comments text,comments_ext text,paymentsAndCredits float,shipping float,lift_gate_value float,handling_fee_value float,sign_picpath text,sync_data text,create_time TIMESTAMP default (datetime('now', 'localtime')));";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- NSString* create_offline_cart=@"CREATE TABLE IF NOT EXISTS offline_cart ( _id INTEGER PRIMARY KEY, product_id INTEGER,price float , discount float , so_no VARCHAR(40), item_count integer,line_note text,bundle_item text,type integer);";
|
|
|
- NSString* create_offline_wish=@"CREATE TABLE IF NOT EXISTS offline_wishlist ( _id INTEGER PRIMARY KEY, product_id INTEGER);";
|
|
|
+ NSString* create_offline_cart=@"CREATE TABLE IF NOT EXISTS offline_cart ( _id INTEGER PRIMARY KEY, orderitem_id integer,product_id INTEGER,item_id integer,str_price text , discount float , so_no VARCHAR(40), item_count integer,line_note text,bundle_item text,type integer,create_time TIMESTAMP default (datetime('now', 'localtime')));";
|
|
|
+ NSString* create_offline_wish=@"CREATE TABLE IF NOT EXISTS offline_wishlist ( _id INTEGER PRIMARY KEY, product_id INTEGER,qty integer, create_time TIMESTAMP default (datetime('now', 'localtime')));";
|
|
|
|
|
|
|
|
|
NSString* create_offline_contact=@"CREATE TABLE IF NOT EXISTS offline_contact (_id INTEGER, country VARCHAR(40,0), company_name VARCHAR(40,0), contact_id VARCHAR(20,0), addr_1 text, addr_2 text, addr_3 text, addr_4 text, zipcode varchar(20,0), state VARCHAR(40,0), city VARCHAR(40,0), first_name VARCHAR(40,0), last_name VARCHAR(40,0), phone VARCHAR(40,0), fax VARCHAR(40,0), email VARCHAR(40,0), notes text, price_type VARCHAR(40,0), sales_rep VARCHAR(40,0), type VARCHAR(40,0), create_time timestamp default (datetime('now', 'localtime')), editable integer, contact_name text, addr text, Sales_Order_Customer integer, Sales_Order_Freight_Bill_To integer, Sales_Order_Ship_From integer, Sales_Order_Merchandise_Bill_To integer, Contact_Return_To integer, Sales_Order_Ship_To integer,img_0 TEXT,img_1 TEXT,img_2 TEXT,related_cid VARCHAR(20,0),is_active integer,sync_data text, PRIMARY KEY(_id) );";
|
|
|
|
|
|
- NSString* create_contact_image=@"CREATE TABLE IF NOT EXISTS contact_image ( _id INTEGER PRIMARY KEY, name VARCHAR(20), url VARCHAR(256), contact_id VARCHAR(20));";
|
|
|
+// NSString* create_contact_image=@"CREATE TABLE IF NOT EXISTS contact_image ( _id INTEGER PRIMARY KEY, name VARCHAR(20), url VARCHAR(256), contact_id VARCHAR(20));";
|
|
|
|
|
|
|
|
|
NSString* create_login_info=@"CREATE TABLE IF NOT EXISTS login_info ( _id INTEGER PRIMARY KEY, name VARCHAR(256), pwd VARCHAR(256), lastlogin timestamp );";
|
|
|
@@ -687,7 +689,7 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
|
|
|
//if(appDelegate.offline_mode)
|
|
|
{
|
|
|
- [self execSql:create_model db:db];
|
|
|
+ [self execSql:create_product db:db];
|
|
|
[self execSql:create_wishlist db:db];
|
|
|
[self execSql:create_price db:db];
|
|
|
[self execSql:create_image db:db];
|
|
|
@@ -704,7 +706,7 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
|
|
|
[self execSql:create_offline_contact db:db];
|
|
|
|
|
|
- [self execSql:create_contact_image db:db];
|
|
|
+// [self execSql:create_contact_image db:db];
|
|
|
|
|
|
[self execSql:create_offline_order db:db];
|
|
|
|
|
|
@@ -713,6 +715,7 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
[self execSql:create_offline_zipcode db:db];
|
|
|
[self execSql:create_offline_salesrep db:db];
|
|
|
[self execSql:create_bundle db:db];
|
|
|
+ [self execSql:create_catelog db:db];
|
|
|
|
|
|
|
|
|
}
|
|
|
@@ -770,10 +773,10 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
// [iSalesDB close_db:db];
|
|
|
|
|
|
}
|
|
|
-// else
|
|
|
-// {
|
|
|
-// int result=sqlite3_wal_checkpoint(db, NULL);
|
|
|
-// }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // int result=sqlite3_wal_checkpoint(db, NULL);
|
|
|
+ // }
|
|
|
return ret;
|
|
|
}
|
|
|
+ (NSDictionary*) search_pdf:(int) offset limit:(int)limit keywords:(NSString*) keywords
|
|
|
@@ -906,7 +909,7 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
}
|
|
|
+ (int) get_insertid:(NSString*) tablename db:(sqlite3*)db
|
|
|
{
|
|
|
- // sqlite3 *db = [self get_db];
|
|
|
+ // sqlite3 *db = [self get_db];
|
|
|
|
|
|
int ret = -1;
|
|
|
NSString *sqlQuery = [NSString stringWithFormat:@"select last_insert_rowid() from %@ ",tablename];
|
|
|
@@ -928,7 +931,7 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
}
|
|
|
sqlite3_finalize(statement);
|
|
|
}
|
|
|
- // [iSalesDB close_db:db];
|
|
|
+ // [iSalesDB close_db:db];
|
|
|
return ret;
|
|
|
|
|
|
}
|