|
|
@@ -461,65 +461,74 @@
|
|
|
{
|
|
|
NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
sqlite3 *db = [iSalesDB get_db];
|
|
|
- for(int i=0;i<arr_soid.count;i++)
|
|
|
+
|
|
|
+ NSString *sqlQuery =@"select _id,sync_data,sign_picpath,so_id from offline_order where order_id is null";
|
|
|
+ // for(int i=0;i<arr_soid.count;i++)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ sqlite3_stmt * statement;
|
|
|
+
|
|
|
+
|
|
|
+ [ret setValue:[NSNumber numberWithInt:AP_USER_NOT_AUTH ] forKey:@"result"];
|
|
|
+
|
|
|
+ //int count=0;
|
|
|
+ int dbresult=sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil);
|
|
|
+ if ( dbresult== SQLITE_OK)
|
|
|
{
|
|
|
-
|
|
|
- NSMutableDictionary* itemjson = [[NSMutableDictionary alloc] init];
|
|
|
-
|
|
|
- NSString *sqlQuery =[NSString stringWithFormat:@"select _id,sync_data,sign_picpath,so_id from offline_order where so_id='%@'",arr_soid[i]];
|
|
|
- sqlite3_stmt * statement;
|
|
|
-
|
|
|
-
|
|
|
- [ret setValue:[NSNumber numberWithInt:AP_USER_NOT_AUTH ] forKey:@"result"];
|
|
|
-
|
|
|
- //int count=0;
|
|
|
- int dbresult=sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil);
|
|
|
- if ( dbresult== SQLITE_OK)
|
|
|
+ int count=0;
|
|
|
+ while (sqlite3_step(statement) == SQLITE_ROW)
|
|
|
{
|
|
|
- if (sqlite3_step(statement) == SQLITE_ROW)
|
|
|
+ NSMutableDictionary* itemjson = [[NSMutableDictionary alloc] init];
|
|
|
+ int _id = sqlite3_column_int(statement, 0);
|
|
|
+
|
|
|
+ char *sync_data = (char*)sqlite3_column_text(statement, 1);
|
|
|
+ NSString* nssync_data=nil;
|
|
|
+ if(sync_data!=nil)
|
|
|
{
|
|
|
- int _id = sqlite3_column_int(statement, 0);
|
|
|
-
|
|
|
- char *sync_data = (char*)sqlite3_column_text(statement, 1);
|
|
|
- NSString* nssync_data=nil;
|
|
|
- if(sync_data!=nil)
|
|
|
- {
|
|
|
- nssync_data= [[NSString alloc]initWithUTF8String:sync_data];
|
|
|
-
|
|
|
- }
|
|
|
- char *img_1 = (char*)sqlite3_column_text(statement, 2);
|
|
|
- NSString* nsimg_1=nil;
|
|
|
- if(img_1!=nil)
|
|
|
- {
|
|
|
- nsimg_1= [[NSString alloc]initWithUTF8String:img_1];
|
|
|
- [self copy_upImg:serial file:nsimg_1];
|
|
|
- }
|
|
|
- char *so_no = (char*)sqlite3_column_text(statement, 3);
|
|
|
- NSString* nsso_no=nil;
|
|
|
- if(so_no!=nil)
|
|
|
- {
|
|
|
- nsso_no= [[NSString alloc]initWithUTF8String:so_no];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ nssync_data= [[NSString alloc]initWithUTF8String:sync_data];
|
|
|
|
|
|
- itemjson[@"_id"]=[NSNumber numberWithInt:_id];
|
|
|
- itemjson[@"json_data"]= nssync_data;
|
|
|
+ }
|
|
|
+ char *img_1 = (char*)sqlite3_column_text(statement, 2);
|
|
|
+ NSString* nsimg_1=nil;
|
|
|
+ if(img_1!=nil)
|
|
|
+ {
|
|
|
+ nsimg_1= [[NSString alloc]initWithUTF8String:img_1];
|
|
|
+ [self copy_upImg:serial file:nsimg_1];
|
|
|
+ }
|
|
|
+ char *so_no = (char*)sqlite3_column_text(statement, 3);
|
|
|
+ NSString* nsso_no=nil;
|
|
|
+ if(so_no!=nil)
|
|
|
+ {
|
|
|
+ nsso_no= [[NSString alloc]initWithUTF8String:so_no];
|
|
|
|
|
|
- itemjson[@"order_items"]=[self preparecart:nsso_no db:db];
|
|
|
}
|
|
|
+ if([arr_soid indexOfObject:nsso_no]!= NSNotFound)
|
|
|
+ itemjson[@"order_type"]=@"submit order";
|
|
|
+ else
|
|
|
+ itemjson[@"order_type"]=@"archive order";
|
|
|
|
|
|
+ itemjson[@"_id"]=[NSNumber numberWithInt:_id];
|
|
|
+ itemjson[@"json_data"]= nssync_data;
|
|
|
|
|
|
- ret[@"result"]=[NSNumber numberWithInt:RESULT_TRUE ];
|
|
|
-
|
|
|
+ itemjson[@"order_items"]=[self preparecart:nsso_no db:db];
|
|
|
+ ret[[NSString stringWithFormat:@"item_%d",count]]=itemjson;
|
|
|
+ count++;
|
|
|
}
|
|
|
|
|
|
- sqlite3_finalize(statement);
|
|
|
- ret[[NSString stringWithFormat:@"item_%d",i]]=itemjson;
|
|
|
-
|
|
|
+ ret[@"count"]=[NSNumber numberWithInt:arr_soid.count ];
|
|
|
+ ret[@"result"]=[NSNumber numberWithInt:RESULT_TRUE ];
|
|
|
|
|
|
}
|
|
|
- ret[@"count"]=[NSNumber numberWithInt:arr_soid.count ];
|
|
|
+
|
|
|
+ sqlite3_finalize(statement);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
[iSalesDB close_db:db];
|
|
|
|
|
|
|