فهرست منبع

160816

Add offline order detail func
Ray Zhang 9 سال پیش
والد
کامیت
6aa609c6c2

+ 218 - 2
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -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

+ 6 - 2
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m

@@ -1551,14 +1551,18 @@ repeat:
     
     [params setValue:orderid forKey:@"orderId"];
     //    [params setValue:[NSString stringWithFormat:@"%d",limit ] forKey:@"limit"];
+    NSData* json=nil;
     if(appDelegate.offline_mode)
     {
-        return [OLDataProvider offline_notimpl];
+        json= [OLDataProvider offline_orderdetail:params];
     }
+    else
+    {
     if(![self IsNetworkAvailable])
         return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
     
-    NSData* json=[self get_json:URL_ORDER_DETAIL parameters:params];
+    json=[self get_json:URL_ORDER_DETAIL parameters:params];
+    }
     if(json==nil)
         return nil;
     NSError *error=nil;

+ 12 - 0
RedAnt ERP Mobile/iSales-NPD.xcodeproj/project.pbxproj

@@ -45,6 +45,9 @@
 		714B1F401C7BF74100539193 /* OrderDetailSignatureCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 714B1F3F1C7BF74100539193 /* OrderDetailSignatureCell.m */; };
 		715001FF1D114D9100F5927F /* BundleDetailButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 715001FE1D114D9100F5927F /* BundleDetailButton.m */; };
 		715850461CF6F0E500856B20 /* DefaultAppearance.m in Sources */ = {isa = PBXBuildFile; fileRef = 715850451CF6F0E500856B20 /* DefaultAppearance.m */; };
+		7161FEB51D61B24900157EE1 /* creditcardpayment.html in Resources */ = {isa = PBXBuildFile; fileRef = 7161FEB21D61B24900157EE1 /* creditcardpayment.html */; };
+		7161FEB61D61B24900157EE1 /* normalpayment.html in Resources */ = {isa = PBXBuildFile; fileRef = 7161FEB31D61B24900157EE1 /* normalpayment.html */; };
+		7161FEB71D61B24900157EE1 /* orderinfo.html in Resources */ = {isa = PBXBuildFile; fileRef = 7161FEB41D61B24900157EE1 /* orderinfo.html */; };
 		7162A4FE1C585FFB00AB630E /* PDFViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7162A4FB1C585FFB00AB630E /* PDFViewController.m */; };
 		7162A4FF1C585FFB00AB630E /* WebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7162A4FD1C585FFB00AB630E /* WebViewController.m */; };
 		7162A5021C586F5B00AB630E /* AddressEditorViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7162A5011C586F5B00AB630E /* AddressEditorViewController.m */; };
@@ -259,6 +262,9 @@
 		715001FE1D114D9100F5927F /* BundleDetailButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BundleDetailButton.m; path = common/Functions/BundleDetailButton.m; sourceTree = SOURCE_ROOT; };
 		715850441CF6F0E500856B20 /* DefaultAppearance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DefaultAppearance.h; path = common/Functions/DefaultAppearance.h; sourceTree = SOURCE_ROOT; };
 		715850451CF6F0E500856B20 /* DefaultAppearance.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DefaultAppearance.m; path = common/Functions/DefaultAppearance.m; sourceTree = SOURCE_ROOT; };
+		7161FEB21D61B24900157EE1 /* creditcardpayment.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = creditcardpayment.html; path = common/Functions/offline/creditcardpayment.html; sourceTree = SOURCE_ROOT; };
+		7161FEB31D61B24900157EE1 /* normalpayment.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = normalpayment.html; path = common/Functions/offline/normalpayment.html; sourceTree = SOURCE_ROOT; };
+		7161FEB41D61B24900157EE1 /* orderinfo.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = orderinfo.html; path = common/Functions/offline/orderinfo.html; sourceTree = SOURCE_ROOT; };
 		7162A4FA1C585FFB00AB630E /* PDFViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PDFViewController.h; path = "common/Functions/PDF+Web/PDFViewController.h"; sourceTree = SOURCE_ROOT; };
 		7162A4FB1C585FFB00AB630E /* PDFViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PDFViewController.m; path = "common/Functions/PDF+Web/PDFViewController.m"; sourceTree = SOURCE_ROOT; };
 		7162A4FC1C585FFB00AB630E /* WebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebViewController.h; path = "common/Functions/PDF+Web/WebViewController.h"; sourceTree = SOURCE_ROOT; };
@@ -877,6 +883,9 @@
 		717AE10B1D1A5E99007DC5CA /* offline */ = {
 			isa = PBXGroup;
 			children = (
+				7161FEB21D61B24900157EE1 /* creditcardpayment.html */,
+				7161FEB31D61B24900157EE1 /* normalpayment.html */,
+				7161FEB41D61B24900157EE1 /* orderinfo.html */,
 				71BF06FC1D2F3CBA00981938 /* OfflineSettingViewController.h */,
 				71BF06FD1D2F3CBA00981938 /* OfflineSettingViewController.m */,
 				71BF07061D2F3D2800981938 /* SyncControlPanelViewController.h */,
@@ -1258,7 +1267,9 @@
 				7162A5A01C58733400AB630E /* status_filter_cadedate_open.json in Resources */,
 				71D30A211CFBEDC6006F9477 /* default_appearance.json in Resources */,
 				42969C021D52F31C00FF190A /* editContact.json in Resources */,
+				7161FEB71D61B24900157EE1 /* orderinfo.html in Resources */,
 				42C9FB151D5B28FA001DCA8B /* contactAdvanceSearch.json in Resources */,
+				7161FEB51D61B24900157EE1 /* creditcardpayment.html in Resources */,
 				71777FC61C8AC97300DA2511 /* debug_category_filter.json in Resources */,
 				71DF74951C57614C00F2789C /* PhotoBorder.png in Resources */,
 				7162A55F1C58724700AB630E /* customer_info_template.json in Resources */,
@@ -1269,6 +1280,7 @@
 				42DC31131D546FBE00BCD1C6 /* category.json in Resources */,
 				423A4ADC1D503A53005ECE4A /* createContact.json in Resources */,
 				7111E5721C76C557004763B3 /* customer_info_template_edit.json in Resources */,
+				7161FEB61D61B24900157EE1 /* normalpayment.html in Resources */,
 				71DF74961C57614C00F2789C /* PhotoBorder@2x.png in Resources */,
 				7162A55E1C58724700AB630E /* customer_advanced_search.json in Resources */,
 				7162A5A11C58733400AB630E /* status_filter_cadedate.json in Resources */,