Jelajahi Sumber

160804
fix offline contact list cannot edit contact
add field can_update_contact_info on offline login.
add offline_editContact func in OLDataProvider.

Ray Zhang 9 tahun lalu
induk
melakukan
8061597fc9

+ 1 - 0
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.h

@@ -25,6 +25,7 @@
  *  @return 返回新建客户信息所需数据
  */
 +(NSData *) offline_createContact:(NSMutableDictionary *) params;
++(NSData *) offline_editContact:(NSMutableDictionary *) params;
 +(NSData *) offline_saveNewContact:(NSMutableDictionary *) params;
 +(NSData *) offline_saveContact:(NSMutableDictionary *) params;
 +(NSDictionary*) offline_contactlist :(NSMutableDictionary *) params;

+ 14 - 6
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -1596,7 +1596,7 @@
     
     
     
-    NSString *sqlQuery = [NSString stringWithFormat:@"select can_show_price,can_see_price,contact_id,user_type,can_cancel_order,can_set_cart_price,can_create_portfolio,can_delete_order,can_submit_order,can_set_tearsheet_price,can_create_order,mode,username from offline_login where lower(username)='%@' and password='%@'",user.lowercaseString ,[AESCrypt encrypt:password password:@"usai"]];
+    NSString *sqlQuery = [NSString stringWithFormat:@"select can_show_price,can_see_price,contact_id,user_type,can_cancel_order,can_set_cart_price,can_create_portfolio,can_delete_order,can_submit_order,can_set_tearsheet_price,can_create_order,mode,username,can_update_contact_info from offline_login where lower(username)='%@' and password='%@'",user.lowercaseString ,[AESCrypt encrypt:password password:@"usai"]];
     
     
     
@@ -1620,6 +1620,7 @@
             
             
             
+            
             int can_show_price = sqlite3_column_int(statement, 0);
             int can_see_price = sqlite3_column_int(statement, 1);
             
@@ -1650,6 +1651,8 @@
                 username="";
             NSString *nsusername= [[NSString alloc]initWithUTF8String:username];
             
+            int can_update_contact_info = sqlite3_column_int(statement, 13);
+            
             
             [header setValue:[NSNumber numberWithBool:can_show_price]   forKey:@"can_show_price"];
             [header setValue:[NSNumber numberWithBool:can_see_price]   forKey:@"can_see_price"];
@@ -1663,6 +1666,8 @@
             [header setValue:[NSNumber numberWithBool:can_set_tearsheet_price]   forKey:@"can_set_tearsheet_price"];
             [header setValue:[NSNumber numberWithBool:can_create_order]   forKey:@"can_create_order"];
             
+            [header setValue:[NSNumber numberWithBool:can_update_contact_info]   forKey:@"can_update_contact_info"];
+            
             [header setValue:nsusername   forKey:@"username"];
             
             
@@ -2102,7 +2107,7 @@
     
     if(keyword.length==0)
     {
-        sqlQuery=[NSString stringWithFormat:@"select editable,company_name,country,addr,zipcode,state,city,contact_name,phone,contact_id,addr_1,addr_2,addr_3,addr_4,first_name,last_name,fax,email from offline_contact where %@=1 order by create_time limit %d offset %d",contactType , limit, offset];
+        sqlQuery=[NSString stringWithFormat:@"select editable,company_name,country,addr,zipcode,state,city,contact_name,phone,contact_id,addr_1,addr_2,addr_3,addr_4,first_name,last_name,fax,email from offline_contact where %@=1 order by decrypt(company_name) limit %d offset %d",contactType , limit, offset];
         count=[iSalesDB get_recordcount:db table:@"offline_contact" where:[NSString stringWithFormat:@"%@='1",contactType]];
     }
     else
@@ -2112,7 +2117,7 @@
         keyword = keyword.lowercaseString;
         
         
-        sqlQuery=[NSString stringWithFormat:@"select editable,company_name,country,addr,zipcode,state,city,contact_name,phone,contact_id,addr_1,addr_2,addr_3,addr_4,first_name,last_name,fax,email from offline_contact where %@=1 and (lower(contact_id ) like'%%%@%%' or lower(decrypt(company_name)) like '%%%@%%') order by create_time limit %d offset %d",contactType , keyword,keyword,limit, offset];
+        sqlQuery=[NSString stringWithFormat:@"select editable,company_name,country,addr,zipcode,state,city,contact_name,phone,contact_id,addr_1,addr_2,addr_3,addr_4,first_name,last_name,fax,email from offline_contact where %@=1 and (lower(contact_id ) like'%%%@%%' or lower(decrypt(company_name)) like '%%%@%%') order by decrypt(company_name) limit %d offset %d",contactType , keyword,keyword,limit, offset];
         
         count=[iSalesDB get_recordcount:db table:@"offline_contact" where:[NSString stringWithFormat:@"%@=1 and (lower(contact_id ) like'%@' or lower(company_name) like'%@')",contactType,keyword,keyword]];
     }
@@ -2138,7 +2143,7 @@
             NSMutableDictionary* item = [[NSMutableDictionary alloc] init];
             
             
-            //            int editable  = sqlite3_column_int(statement, 0);
+            int editable  = sqlite3_column_int(statement, 0);
             
             
             char *company_name = (char*)sqlite3_column_text(statement, 1);
@@ -2297,7 +2302,7 @@
             
             [item setValue:name   forKey:@"name"];
             [item setValue:nscontact_id   forKey:@"contact_id"];
-            
+            [item setValue:editable==1?@"true":@"false" forKey:@"can_update"];
             [ret setObject:item forKey:[NSString stringWithFormat:@"item_%d",i]];
             i++;
             
@@ -3071,7 +3076,10 @@
 {
     return nil;
 }
-
++(NSData *) offline_editContact:(NSMutableDictionary *) params
+{
+    return nil;
+}
 + (NSData *)offline_createContact:(NSMutableDictionary *)params {
     
     NSString *path = [[NSBundle mainBundle] pathForResource:@"createContact.json" ofType:nil];

+ 7 - 1
RedAnt ERP Mobile/common/data_provider/iSalesDB.m

@@ -605,7 +605,7 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
         NSString* create_offline_setting=@"CREATE TABLE IF NOT EXISTS offline_setting ( _id INTEGER PRIMARY KEY, name VARCHAR(20),value VARCHAR(40));";
         
         
-        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, mode VARCHAR(20), default_price text, price text, user_id integer,sales_code text);";
+        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, create_time TIMESTAMP default (datetime('now', 'localtime')));";
     
@@ -673,6 +673,12 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
                     NSString* alter_search_history = @"ALTER TABLE offline_login ADD sales_code text";
                     [self execSql:alter_search_history db:db];
                 }
+    if( ![self checkForField:@"offline_login" field:@"can_update_contact_info" db:db])
+    {
+        NSString* alter_search_history = @"ALTER TABLE offline_login ADD can_update_contact_info integer";
+        [self execSql:alter_search_history db:db];
+    }
+    
         //        NSTimeInterval time=[[NSDate date] timeIntervalSince1970];
         //        double t = time-2592000;      //NSTimeInterval返回的是double类型
         //        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];

+ 5 - 0
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m

@@ -1252,6 +1252,11 @@ repeat:
         {
             json= [OLDataProvider offline_createContact:params];
         }
+        if([request_url isEqualToString:URL_EDIT_CUSTOMER])
+        {
+            json= [OLDataProvider offline_editContact:params];
+        }
+        
         else
             return [OLDataProvider offline_notimpl];
     }