|
|
@@ -7,8 +7,16 @@
|
|
|
//
|
|
|
|
|
|
#import "SelectUploadOrderViewController.h"
|
|
|
+#import "iSalesDB.h"
|
|
|
+#import <sqlite3.h>
|
|
|
+#import "SelectOrderTableViewCell.h"
|
|
|
|
|
|
-@interface SelectUploadOrderViewController ()
|
|
|
+@interface SelectUploadOrderViewController ()<UITableViewDataSource,UITableViewDelegate>
|
|
|
+
|
|
|
+@property (nonatomic,strong) NSMutableArray<NSDictionary *> *sync_data;
|
|
|
+
|
|
|
+@property (strong, nonatomic) IBOutlet UITableView *syncDataTableView;
|
|
|
+@property (strong, nonatomic) IBOutlet UIButton *uploadButton;
|
|
|
|
|
|
@end
|
|
|
|
|
|
@@ -17,6 +25,10 @@
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
// Do any additional setup after loading the view.
|
|
|
+
|
|
|
+// self.syncDataTableView.delegate = self;
|
|
|
+// self.syncDataTableView.dataSource = self;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
|
@@ -24,14 +36,121 @@
|
|
|
// Dispose of any resources that can be recreated.
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
-#pragma mark - Navigation
|
|
|
+- (NSMutableArray<NSDictionary *> *)sync_data {
|
|
|
+ if (!_sync_data) {
|
|
|
+ _sync_data = [NSMutableArray array];
|
|
|
+
|
|
|
+ NSString *sql = @"select decrypt(c.company_name),o.so_id,o.sync_data from (select so_id,sync_data,customer_cid from offline_order where sync_data not null) as o join offline_contact as c on c.contact_id = o.customer_cid ;";
|
|
|
+ [iSalesDB jk_query:sql completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
+
|
|
|
+ const char *cn = (char *)sqlite3_column_text(stmt,0);
|
|
|
+ if (cn == NULL) {
|
|
|
+ cn = "";
|
|
|
+ }
|
|
|
+ const char *_id = (char *)sqlite3_column_text(stmt,1);
|
|
|
+ if (_id == NULL) {
|
|
|
+ _id = "";
|
|
|
+ }
|
|
|
+ const char *data = (char *)sqlite3_column_text(stmt,2);
|
|
|
+ if (data == NULL) {
|
|
|
+ data = "";
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *company_name = [NSString stringWithUTF8String:cn];
|
|
|
+ NSString *so_id = [NSString stringWithUTF8String:_id];
|
|
|
+ NSString *sync_data_str = [NSString stringWithUTF8String:data];
|
|
|
+
|
|
|
+ NSDictionary *dic = [@{
|
|
|
+ @"check" : @(1),
|
|
|
+ @"company_name" : company_name,
|
|
|
+ @"so_id" : so_id,
|
|
|
+ @"sync_data" : sync_data_str
|
|
|
+ } mutableCopy];
|
|
|
+ [_sync_data addObject:dic];
|
|
|
+
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ }
|
|
|
+ return _sync_data;
|
|
|
+}
|
|
|
|
|
|
-// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
|
-- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|
|
- // Get the new view controller using [segue destinationViewController].
|
|
|
- // Pass the selected object to the new view controller.
|
|
|
+- (IBAction)uploadButtonClicked:(UIButton *)sender {
|
|
|
+
|
|
|
+ NSMutableArray *uploadArray = [NSMutableArray array];
|
|
|
+
|
|
|
+ for (NSDictionary *dic in self.sync_data) {
|
|
|
+
|
|
|
+ int check = [dic[@"check"] integerValue];
|
|
|
+ NSString *so_id = dic[@"so_id"];
|
|
|
+
|
|
|
+ if (check == 0) {
|
|
|
+ [uploadArray addObject:so_id];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (self.returnValue) {
|
|
|
+ self.returnValue(uploadArray);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
-*/
|
|
|
+
|
|
|
+#pragma mark - dataSource
|
|
|
+
|
|
|
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+
|
|
|
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
+ return self.sync_data.count;
|
|
|
+}
|
|
|
+
|
|
|
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
+
|
|
|
+ SelectOrderTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SelectOrderTableViewCell" forIndexPath:indexPath];
|
|
|
+
|
|
|
+ NSDictionary *dic = [self.sync_data objectAtIndex:indexPath.row];
|
|
|
+ int check = [dic[@"check"] integerValue];
|
|
|
+ NSString *so_id = dic[@"so_id"];
|
|
|
+ NSString *company_name = dic[@"company_name"];
|
|
|
+
|
|
|
+ if (check)
|
|
|
+ cell.checkedButton.selected = YES;
|
|
|
+
|
|
|
+ cell.labelsoid.text = so_id;
|
|
|
+ cell.labelcompany.text = company_name;
|
|
|
+
|
|
|
+
|
|
|
+ return cell;
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - delegate
|
|
|
+
|
|
|
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
+ return 44;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
+
|
|
|
+ SelectOrderTableViewCell *cell = (SelectOrderTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
|
|
|
+
|
|
|
+ cell.selected = NO;
|
|
|
+ cell.checkedButton.selected = !cell.checkedButton.selected;
|
|
|
+
|
|
|
+ NSMutableDictionary *dic = (NSMutableDictionary *)[self.sync_data objectAtIndex:indexPath.row];
|
|
|
+ int check = [dic[@"check"] integerValue];
|
|
|
+
|
|
|
+ if (cell.checkedButton.selected) {
|
|
|
+ check = 1;
|
|
|
+ } else {
|
|
|
+ check = 0;
|
|
|
+ }
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:check] forKey:@"check"];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+//- (BOOL
|
|
|
+
|
|
|
|
|
|
@end
|