Ray Zhang 10 年之前
父节点
当前提交
d2a1f4c6db
共有 23 个文件被更改,包括 846 次插入117 次删除
  1. 10 10
      RedAnt ERP Mobile/common/Functions/PDF+Web/PDFViewController.m
  2. 1 1
      RedAnt ERP Mobile/common/Functions/category/CategoryViewController.m
  3. 3 1
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.h
  4. 9 0
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.m
  5. 4 0
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailTopicCell.h
  6. 16 0
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailTopicCell.m
  7. 32 7
      RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m
  8. 2 0
      RedAnt ERP Mobile/common/Functions/order/OrderListViewController.h
  9. 79 37
      RedAnt ERP Mobile/common/Functions/order/OrderListViewController.m
  10. 1 1
      RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchViewController.m
  11. 1 1
      RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m
  12. 6 1
      RedAnt ERP Mobile/common/Functions/sidemenu/LoginViewController.h
  13. 114 11
      RedAnt ERP Mobile/common/Functions/sidemenu/LoginViewController.m
  14. 1 0
      RedAnt ERP Mobile/common/Functions/sidemenu/ScannerSettingViewController.h
  15. 28 5
      RedAnt ERP Mobile/common/Functions/sidemenu/ScannerSettingViewController.m
  16. 18 0
      RedAnt ERP Mobile/common/Functions/sidemenu/UserListViewController.h
  17. 298 0
      RedAnt ERP Mobile/common/Functions/sidemenu/UserListViewController.m
  18. 1 0
      RedAnt ERP Mobile/common/data_provider/iSalesDB.h
  19. 82 39
      RedAnt ERP Mobile/common/data_provider/iSalesDB.m
  20. 2 0
      RedAnt ERP Mobile/common/data_provider/iSalesNetwork.h
  21. 63 3
      RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m
  22. 22 0
      RedAnt ERP Mobile/iSales-NPD/OfflineSettingViewController.h
  23. 53 0
      RedAnt ERP Mobile/iSales-NPD/OfflineSettingViewController.m

+ 10 - 10
RedAnt ERP Mobile/common/Functions/PDF+Web/PDFViewController.m

@@ -385,16 +385,16 @@
         
     }
 }
-- (void) sendEmail:(NSString *)to cc:(NSString*)cc subject:(NSString*)subject body:(NSString*)body
-{
-    NSString* str = [NSString stringWithFormat:@"mailto:%@?cc=%@&subject=%@&body=%@",
-                     to, cc, subject, body];
-    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-    
-    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
-    
-    
-}
+//- (void) sendEmail:(NSString *)to cc:(NSString*)cc subject:(NSString*)subject body:(NSString*)body
+//{
+//    NSString* str = [NSString stringWithFormat:@"mailto:%@?cc=%@&subject=%@&body=%@",
+//                     to, cc, subject, body];
+//    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+//    
+//    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
+//    
+//    
+//}
 
 #pragma mark methods for the UIDocumentInteractionControllerDelegate
 

+ 1 - 1
RedAnt ERP Mobile/common/Functions/category/CategoryViewController.m

@@ -1471,7 +1471,7 @@
         static NSString * CellIdentifier = @"CategoryCellNPDLarge";
         CategoryCellNPD * cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
         NSDictionary * item_json =[[self.category_data objectForKey:@"items" ] objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
-        NSString* img_url =[item_json valueForKey:@"img"];
+        NSString* img_url =[item_json valueForKey:@"img_big"];
         NSString* description =[item_json valueForKey:@"description"];
         
         NSString* name =[item_json valueForKey:@"name"];

+ 3 - 1
RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.h

@@ -38,6 +38,8 @@
 @property (weak, nonatomic) IBOutlet UIPageControl *pageControl;
 -(void)setup;
 @property (nonatomic, strong) NSArray *photos;
+
+@property (nonatomic, strong) NSArray *urls;
 @property (nonatomic, strong) NSString *product_id;
 //@property long detailID;
 //@property (strong, nonatomic) IBOutlet UILabel *itemIDLabel;
@@ -78,7 +80,7 @@
 - (void)AddPhoto :(UIImage*)photo ;
 @property (strong, nonatomic) IBOutlet UILabel *selector_label;
 
-
+-(void)ClearPhotos;
 @property int cqty;
 @property int step;
 @property int quantity;

+ 9 - 0
RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.m

@@ -1061,7 +1061,16 @@
 
 #pragma mark -
 #pragma mark Actions
+-(void)ClearPhotos
+{
+    NSMutableArray *photosMutable = [self.photos mutableCopy];
+    [photosMutable removeAllObjects];
+    self.photos = photosMutable;
+    [self.photoStack reloadData];
+    
+
 
+}
 - (void)AddPhoto :(UIImage*)photo {
     
     NSMutableArray *photosMutable = [self.photos mutableCopy];

+ 4 - 0
RedAnt ERP Mobile/common/Functions/modelDetail/DetailTopicCell.h

@@ -30,6 +30,10 @@
 
 @property (weak, nonatomic) id <DetailRelatedCellDelegate> itemdelegate;
 @property (strong, nonatomic) NSDictionary* related_data;
+-(void) begin_refresh;
+-(void) end_refresh;
+@property (strong, nonatomic) IBOutlet UILabel *refreshLabel;
+
 @end
 
 

+ 16 - 0
RedAnt ERP Mobile/common/Functions/modelDetail/DetailTopicCell.m

@@ -26,6 +26,22 @@
 - (void)awakeFromNib
 {
     // Initialization code
+    
+    self.refreshLabel.layer.borderColor = [UIColor darkGrayColor].CGColor;
+    self.refreshLabel.layer.borderWidth = 2.0;
+    self.refreshLabel.layer.cornerRadius=15;
+    self.refreshLabel.layer.masksToBounds=true;
+}
+-(void) begin_refresh
+{
+    self.topicCollectionView.hidden=true;
+    self.refreshLabel.hidden=false;
+    
+}
+-(void) end_refresh
+{
+    self.topicCollectionView.hidden=false;
+    self.refreshLabel.hidden=true;
 }
 
 - (void)setSelected:(BOOL)selected animated:(BOOL)animated

+ 32 - 7
RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m

@@ -89,6 +89,11 @@
 -(void) reload
 {
 dispatch_async(dispatch_get_main_queue(), ^{
+    
+    
+    
+   
+    
     if(self.isrefreshing)
         return;
 
@@ -99,6 +104,8 @@ dispatch_async(dispatch_get_main_queue(), ^{
     self.mum.hidden = false;
     [self.mum startAnimating];
     
+    //self.detailTable.hidden=true;
+    
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
         NSDictionary* detail_json = [iSalesNetwork request_ItemDetail:self.product_id model_name:self.model_name category_id:self.category_id use_name:self.use_model_name];
@@ -136,6 +143,9 @@ dispatch_async(dispatch_get_main_queue(), ^{
                 
                 [RAUtils add_recent_model:item];
                 
+                NSUInteger ii[2] = {0,0};
+                
+                [self.detailTable  scrollToRowAtIndexPath:[NSIndexPath indexPathWithIndexes:ii length:2] atScrollPosition:UITableViewScrollPositionTop animated:YES];
                 
                 
 //                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
@@ -592,7 +602,7 @@ self.isrefreshing=false;
     UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-100-15, 0, 100, 33)];
         btn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
     btn.tag=section;
-    [btn addTarget:self action:@selector(RefreshSction:) forControlEvents:UIControlEventTouchUpInside];
+    [btn addTarget:self action:@selector(RefreshSection:) forControlEvents:UIControlEventTouchUpInside];
     [btn setTitle:btntitle forState:UIControlStateNormal];
     [myView addSubview:btn];
     }
@@ -1114,6 +1124,7 @@ self.isrefreshing=false;
         cell.product_id = self.product_id;
 //        cell.itemIDLabel.text = [NSString stringWithFormat:@"Item id:%d",3947105];
         [cell setup];
+        [cell ClearPhotos];
          NSDictionary* imgs_json = [section_json objectForKey:@"images"];
         int count = [[imgs_json valueForKey:@"img_count"]intValue];
         if(count<2-1)//1 for qrcode;
@@ -1121,6 +1132,9 @@ self.isrefreshing=false;
         else
             cell.pageControl.hidden = false;
         
+       // NSMutableArray* urls= [[NSMutableArray alloc]init];
+        
+       // cell.urls = urls;
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
             
             for(int i=0;i<count;i++)
@@ -1129,6 +1143,11 @@ self.isrefreshing=false;
                 NSDictionary* img_json=[imgs_json objectForKey:[NSString stringWithFormat:@"img_%d",i]];
                 
                 NSString* img_url = [img_json valueForKey:@"s"];
+                
+                
+            //    NSString* img_url_l = [img_json valueForKey:@"l"];
+            //    if(img_url_l.length>0)
+             //      [urls addObject:img_url_l];
                 NSString* file_name=[img_url lastPathComponent];
                 NSData* img_data=[iSalesDB load_cached_img:file_name];
                 if(img_data!=nil)
@@ -1523,10 +1542,10 @@ self.isrefreshing=false;
     }
 }
 #pragma mark - hide section button clicked
-- (void)RefreshSction:(UIButton *)sender {
-    
+- (void)RefreshSection:(UIButton *)sender {
     
     
+    sender.enabled=false;
     NSDictionary* section_json = nil;
     
     
@@ -1558,17 +1577,23 @@ self.isrefreshing=false;
     if(params==nil)
         params = [[NSMutableDictionary alloc] init];
     
+
     
+    NSUInteger ii[2] = {sender.tag,0};
+    NSIndexPath* indexpath= [NSIndexPath indexPathWithIndexes:ii length:2];
     
-    UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..."title:@"Refreshing"];
+    DetailTopicCell * cell=[self.detailTable cellForRowAtIndexPath:indexpath];
+
+    [cell begin_refresh];
+//    UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..."title:@"Refreshing"];
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
         NSDictionary* editor_json = [iSalesNetwork commoneditor_partialrefresh:params url:url];
         
         dispatch_async(dispatch_get_main_queue(), ^{
-            
-            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-            
+            [cell end_refresh ];
+//            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+             sender.enabled=true;
             
             if([[editor_json valueForKey:@"result"] intValue]==2)
             {

+ 2 - 0
RedAnt ERP Mobile/common/Functions/order/OrderListViewController.h

@@ -19,9 +19,11 @@
 @property (strong, nonatomic) IBOutlet UITableView *table_order;
 @property (strong, nonatomic) IBOutlet UIActivityIndicatorView *mum;
 @property (strong,nonatomic) NSMutableArray * content_data;
+@property dispatch_queue_t  loading_queue;
 @property int offset;
 @property int limit;
 @property bool showNavibar;
+@property bool reset_result;
 //@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
 @property (strong,nonatomic) NSString* load_more_hint;
 @property (strong,nonatomic) NSString* time_zone;

+ 79 - 37
RedAnt ERP Mobile/common/Functions/order/OrderListViewController.m

@@ -25,6 +25,7 @@
 {
     self.offset = 0;
     [self.content_data removeAllObjects];
+    [self.table_order reloadData];
     self.status_cadedate = nil;
 }
 -(void) reload_container_getdata:(bool) update_data
@@ -32,8 +33,9 @@
     [super reload_container_getdata:update_data];
     if(update_data)
     {
-    self.offset = 0;
-    [self.content_data removeAllObjects];
+//    self.offset = 0;
+//    [self.content_data removeAllObjects];
+        self.reset_result=true;
     self.norefresh=true;
     [self loadpage];
     }
@@ -67,6 +69,7 @@
     [super viewDidLoad];
         self.edgesForExtendedLayout = UIRectEdgeNone;
     
+    self.loading_queue = dispatch_queue_create("orderlist_loading", NULL);
     
     self.label_net_err.layer.borderColor = [UIColor darkGrayColor].CGColor;
     self.label_net_err.layer.borderWidth = 2.0;
@@ -284,8 +287,8 @@
 {
     
     
-    [self.content_data removeAllObjects];
-    [self.table_order reloadData];
+//    [self.content_data removeAllObjects];
+//    [self.table_order reloadData];
 
     
    // self.table_order.hidden = true;
@@ -296,7 +299,8 @@
     reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
     
     self.keywords=self.searchbar.text;
-    self.offset = 0;
+//    self.offset = 0;
+    self.reset_result=true;
 //    [self.content_data removeAllObjects];
 //    [self.table_order reloadData];
     
@@ -308,25 +312,67 @@
 }
 -(void) loadpage
 {
-
-dispatch_async(dispatch_get_main_queue(), ^{
+    dispatch_async(self.loading_queue, ^{
+        
+        dispatch_sync(dispatch_get_main_queue(), ^{
+            if(self.reset_result)
+            {
+                self.offset = 0;
+                [self.content_data removeAllObjects];
+                [self.table_order reloadData];
+            }
+            
+//            NSMutableArray* arr_status = [[NSMutableArray alloc] init];
+            
+            NSMutableArray* arr_statusname = [[NSMutableArray alloc] init];
+            int count = [[self.status_cadedate valueForKey:@"count"] intValue];
+            for(int i=0;i<count;i++)
+            {
+                NSDictionary* val_json =[self.status_cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
+                int check = [[val_json valueForKey:@"check"] intValue];
+                if(check==1)
+                {
+//                    [arr_status addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value_id"]]];
+                    [arr_statusname addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value"]]];
+                    
+                    // break;
+                }
+            }
+            
+//            NSString * str_status = [arr_status componentsJoinedByString:@","];
+            NSString * str_statusname = [arr_statusname componentsJoinedByString:@","];
+            if(str_statusname.length==0)
+                str_statusname = @"All";
+            self.label_filter.text = str_statusname;
+            if(self.offset==0)
+            {
+                self.table_order.hidden = true;
+                
+                self.mum.center = self.view.center;
+                
+                self.mum.hidden = false;
+                [self.mum startAnimating];
+            }
+            self.label_net_err.hidden=true;
+            
+        });
+    });
+dispatch_async(self.loading_queue, ^{
     if(self.isrefreshing)
         return;
     self.isrefreshing=true;
-    if(self.offset==0)
-    {
-        self.table_order.hidden = true;
     
-    self.mum.center = self.view.center;
     
-    self.mum.hidden = false;
-    [self.mum startAnimating];
-    }
-    self.label_net_err.hidden=true;
+
+
+    
+
+
+    
     
     NSMutableArray* arr_status = [[NSMutableArray alloc] init];
     
-    NSMutableArray* arr_statusname = [[NSMutableArray alloc] init];
+//    NSMutableArray* arr_statusname = [[NSMutableArray alloc] init];
     int count = [[self.status_cadedate valueForKey:@"count"] intValue];
     for(int i=0;i<count;i++)
     {
@@ -335,26 +381,18 @@ dispatch_async(dispatch_get_main_queue(), ^{
         if(check==1)
         {
             [arr_status addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value_id"]]];
-            [arr_statusname addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value"]]];
-
-           // break;
+//            [arr_statusname addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value"]]];
+            
+            // break;
         }
     }
+    
     NSString * str_status = [arr_status componentsJoinedByString:@","];
-    NSString * str_statusname = [arr_statusname componentsJoinedByString:@","];
-    if(str_statusname.length==0)
-        str_statusname = @"All";
-    self.label_filter.text = str_statusname;
     
-    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        
-        
-        
-        
-        
+    
         NSMutableDictionary* content=nil;
         content=[[iSalesNetwork request_OrderList:self.offset limit : self.limit keywords:self.keywords status:str_status customer:self.customer_id] mutableCopy];
-        dispatch_async(dispatch_get_main_queue(), ^{
+        dispatch_sync(dispatch_get_main_queue(), ^{
             
             
             
@@ -398,6 +436,7 @@ dispatch_async(dispatch_get_main_queue(), ^{
                 
                 
                 self.table_order.hidden = false;
+                self.reset_result=false;
                 [self.table_order reloadData ];
             }
             else if(result==RESULT_NET_ERROR &&self.offset==0)
@@ -427,7 +466,7 @@ dispatch_async(dispatch_get_main_queue(), ^{
             
             
         });
-    });
+
     
     });
 }
@@ -930,8 +969,9 @@ dispatch_async(dispatch_get_main_queue(), ^{
 - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
 {
     self.keywords=searchBar.text;
-        self.offset = 0;
-        [self.content_data removeAllObjects];
+//        self.offset = 0;
+//        [self.content_data removeAllObjects];
+    self.reset_result=true;
         [self loadpage];
 }
 - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
@@ -943,8 +983,9 @@ dispatch_async(dispatch_get_main_queue(), ^{
         self.reset=true;
         self.keywords=nil;
         
-        self.offset = 0;
-        [self.content_data removeAllObjects];
+//        self.offset = 0;
+//        [self.content_data removeAllObjects];
+        self.reset_result=true;
         [self loadpage];
     }
     else
@@ -1228,8 +1269,9 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
     
     
 //    self.keywords=searchBar.text;
-    self.offset = 0;
-    [self.content_data removeAllObjects];
+//    self.offset = 0;
+//    [self.content_data removeAllObjects];
+    self.reset_result=true;
     [self loadpage];
     
     //[self.btnStatusFilter setTitle:setTitle:alert ];

+ 1 - 1
RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchViewController.m

@@ -1341,7 +1341,7 @@
         static NSString * CellIdentifier = @"CategoryCellNPDLarge";
         CategoryCellNPD * cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
         NSDictionary * item_json =[[self.category_data objectForKey:@"items" ] objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
-        NSString* img_url =[item_json valueForKey:@"img"];
+        NSString* img_url =[item_json valueForKey:@"mg_big"];
         NSString* description =[item_json valueForKey:@"description"];
         
         NSString* modelid =[item_json valueForKey:@"fash_name"];

+ 1 - 1
RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m

@@ -1387,7 +1387,7 @@
         static NSString * CellIdentifier = @"CategoryCellNPDLarge";
         CategoryCellNPD * cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
         NSDictionary * item_json =[[self.category_data objectForKey:@"items" ] objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
-        NSString* img_url =[item_json valueForKey:@"img"];
+        NSString* img_url =[item_json valueForKey:@"mg_big"];
         NSString* description =[item_json valueForKey:@"description"];
         
         NSString* name =[item_json valueForKey:@"fash_name"];

+ 6 - 1
RedAnt ERP Mobile/common/Functions/sidemenu/LoginViewController.h

@@ -9,7 +9,7 @@
 #import <UIKit/UIKit.h>
 #import "iSalesNetwork.h"
 #import "AESCrypt.h"
-
+//#import "MyAutocompleteView.h"
 @class LoginViewController;
 @protocol LoginViewControllerDelegate <NSObject>
 
@@ -28,4 +28,9 @@
 @property (strong, nonatomic) IBOutlet UITextField *edituser;
 @property (strong, nonatomic) IBOutlet UITextField *editpass;
 @property (nonatomic , copy) void (^returnValue)(bool blogin);
+
+@property (strong, nonatomic) IBOutlet UITableView *Loginlist;
+@property (strong, nonatomic)  NSArray *logindata;
+@property bool showList;
+//@property (strong,nonatomic) MyAutocompleteView * autocompleteView;
 @end

+ 114 - 11
RedAnt ERP Mobile/common/Functions/sidemenu/LoginViewController.m

@@ -11,6 +11,8 @@
 #import "RetrievePassViewController.h"
 #import "UILabel+FontAppearance.h"
 
+
+
 @interface LoginViewController ()
 
 @end
@@ -29,7 +31,9 @@
 - (void)viewDidLoad
 {
     [super viewDidLoad];
+    self.showList = false;
     
+  
     self.bb_close.image=[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
     
     [self.checkSavePassword setImage:[UIImage imageNamed:@"checkbox"] forState:UIControlStateNormal];
@@ -53,8 +57,33 @@
     
     
     [self.checkSavePassword addTarget:self action:@selector(checkboxClick:) forControlEvents:UIControlEventTouchUpInside];
+    
+    
+    self.logindata = [iSalesDB get_saveduser];
+    
+    
+    
+    UIButton* combobutton=[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 24, 24)];
+    [combobutton setBackgroundImage:[UIImage imageNamed:@"combo_24"] forState:UIControlStateNormal];
+        [combobutton addTarget:self action:@selector(LoginList:) forControlEvents:UIControlEventTouchUpInside];
+    
+    self.edituser.rightView = combobutton;
+    self.edituser.rightViewMode=UITextFieldViewModeAlways;
+    
+    
+    
+    self.Loginlist.layer.borderColor = [UIColor lightGrayColor].CGColor;
+    self.Loginlist.layer.borderWidth = 1.0;
+  //  self.Loginlist.layer.cornerRadius=15;
+    self.Loginlist.layer.masksToBounds=true;
     // Do any additional setup after loading the view.
 }
+- (void)LoginList:(UIButton *)sender {
+    [self.edituser endEditing:true];
+    self.showList= !self.showList;
+    self.Loginlist.hidden = !self.showList;
+//    showList;
+}
 -(void)checkboxClick:(UIButton *)btn
 {
     btn.selected = !btn.selected;
@@ -119,14 +148,38 @@
                 NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
                 [defaults removeObjectForKey:@"user"];
                 [defaults removeObjectForKey:@"password"];
+                NSString* encryptu=[AESCrypt encrypt:appDelegate.user password:@"usai"];
+                NSString* encryptp=[AESCrypt encrypt:self.editpass.text password:@"usai"] ;
                 if(self.checkSavePassword.selected)
                 {
                     
+                    [defaults setValue:encryptu forKey:@"user"];
+                    [defaults setValue:encryptp forKey:@"password"];
+                    sqlite3 *db = [iSalesDB get_db];
+                    
+                    int count =[iSalesDB get_recordcount:db table:@"login_info" where:[NSString stringWithFormat:@"name='%@'",encryptu]];
                     
-                    [defaults setValue:[AESCrypt encrypt:appDelegate.user password:@"usai"] forKey:@"user"];
-                    [defaults setValue:[AESCrypt encrypt:self.editpass.text password:@"usai"] forKey:@"password"];
+                    if(count==0)
+                    {
+                    
+                    NSString * savelogin=[NSString stringWithFormat:@"insert into login_info(name,pwd) values('%@','%@')",encryptu,encryptp];
+                    [iSalesDB execSql:savelogin db:db];
+                    }
+                    else
+                    {
+                        NSString * savelogin=[NSString stringWithFormat:@"update login_info set pwd='%@' where name='%@'",encryptp,encryptu];
+                        [iSalesDB execSql:savelogin db:db];
+                    }
+                    
+                    sqlite3_close(db);
+
 //                    [defaults setBool:TRUE forKey:@"autologin"];
                 }
+                else
+                {
+                    NSString* sql=[NSString stringWithFormat:@"delete from login_info where name='%@'",encryptu];
+                    [iSalesDB execSql:sql];
+                }
                 [defaults synchronize];
                 
                 [self dismissViewControllerAnimated:YES completion:nil];
@@ -166,15 +219,7 @@
                 
                 [RAUtils alert_view:msg title:@"Sign in"];
                 
-//                UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Login Failed." message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-//                
-//                [alert show];
-                
-                //handel error message;
-                //                [self dismissViewControllerAnimated:YES completion:^{
-                //                    // <#code#>
-                //                }];
-                
+
                 
             }
             
@@ -192,6 +237,64 @@
     // Dispose of any resources that can be recreated.
 }
 
+#pragma mark - Table view data source
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
+{
+    return 44;
+    
+    
+}
+
 
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+    return 1;
+}
 
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+    return self.logindata.count;
+    
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+    
+    NSMutableDictionary* up = self.logindata[indexPath.row];
+    
+    
+    
+    NSString *CellIdentifier = @"LoginListCell";
+    UITableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
+    NSString* name=up[@"name"];
+    cell.textLabel.text = name;
+       return cell;
+
+}
+
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ 
+    NSMutableDictionary* up = self.logindata[indexPath.row];
+    self.edituser.text = up[@"name"];
+    self.editpass.text = up[@"pwd"];
+    
+    self.showList=false;
+    self.Loginlist.hidden=true;
+    self.checkSavePassword.selected=true;
+
+}
+//- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
+//{
+//    
+//    return true;
+//}
+- (void)textFieldDidBeginEditing:(UITextField *)textField
+{
+    
+    self.showList=false;
+    self.Loginlist.hidden=true;
+    
+}
 @end

+ 1 - 0
RedAnt ERP Mobile/common/Functions/sidemenu/ScannerSettingViewController.h

@@ -27,6 +27,7 @@
 //@property (strong, nonatomic) NSTimer* ScanApiConsumer;
 //@property (nonatomic) BOOL doAppDataConfirmation;
 @property (strong, nonatomic) IBOutlet UILabel *appinfoLabel;
+@property (strong, nonatomic) IBOutlet UISwitch *auto_launch_switch;
 
 @property (nonatomic , copy) void (^onDismissVC)();
 //@property (strong, nonatomic) NSString *scanApiVersion;

+ 28 - 5
RedAnt ERP Mobile/common/Functions/sidemenu/ScannerSettingViewController.m

@@ -40,6 +40,7 @@
     [self dismissViewControllerAnimated:true completion:nil];
 }
 
+
 - (void)viewDidLoad {
     [super viewDidLoad];
 
@@ -115,6 +116,17 @@
 
 //    }
     // Do any additional setup after loading the view, typically from a nib.
+    
+    
+    
+    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+    bool  autolaunch = [defaults boolForKey:@"EnableScannerOnLaunch"] ;
+    
+    self.auto_launch_switch.on = autolaunch;
+
+    
+
+
 }
 
 - (void)didReceiveMemoryWarning {
@@ -148,7 +160,15 @@
 #pragma mark -control events
 //- (IBAction)onScannerClick:(id)sender {
 //}
-
+- (IBAction)onChangeAutolaunch:(id)sender {
+    
+    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+    [defaults removeObjectForKey:@"EnableScannerOnLaunch"];
+    [defaults setBool:self.auto_launch_switch.isOn forKey:@"EnableScannerOnLaunch"];
+    
+    [defaults synchronize];
+    
+}
 -(void) alert_view :(NSString*) msg title:(NSString*) title
 {
     if(title==nil)
@@ -192,6 +212,9 @@
     
     
     MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
+    
+    if(mc==nil)
+        return;
     mc.mailComposeDelegate = self;
     [mc setSubject:@"scaner test log"];
     
@@ -232,10 +255,10 @@
 }
 
 
-- (IBAction)onConnectClick:(id)sender {
-    
-
-}
+//- (IBAction)onConnectClick:(id)sender {
+//
+//
+//}
 
 - (IBAction)onSwitchChanged:(id)sender {
     

+ 18 - 0
RedAnt ERP Mobile/common/Functions/sidemenu/UserListViewController.h

@@ -0,0 +1,18 @@
+//
+//  UserListViewController.h
+//  iSales-NPD
+//
+//  Created by Ray on 4/19/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "iSalesNetwork.h"
+#import "AESCrypt.h"
+
+@interface UserListViewController : UIViewController
+@property (strong, nonatomic)  NSArray *logindata;
+@property (strong, nonatomic) IBOutlet UIBarButtonItem *bb_close;
+@property (strong, nonatomic) IBOutlet UIButton *btnclose;
+@property (nonatomic , copy) void (^returnValue)(bool blogin);
+@end

+ 298 - 0
RedAnt ERP Mobile/common/Functions/sidemenu/UserListViewController.m

@@ -0,0 +1,298 @@
+//
+//  UserListViewController.m
+//  iSales-NPD
+//
+//  Created by Ray on 4/19/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "UserListViewController.h"
+#import "MainViewController.h"
+
+@interface UserListViewController ()
+
+@end
+
+@implementation UserListViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    
+    self.edgesForExtendedLayout = UIRectEdgeNone;
+    
+    self.bb_close.image=[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
+    
+    
+    
+    self.logindata = [iSalesDB get_saveduser];
+    
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+- (IBAction)CloseClick:(id)sender {
+    
+    [self dismissViewControllerAnimated:true completion:nil];
+    //    if(self.returnValue)
+    //        self.returnValue(false);
+    
+    
+    
+}
+/*
+ #pragma mark - Navigation
+ 
+ // 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.
+ }
+ */
+#pragma mark - Table view data source
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
+{
+    return 44;
+    
+    
+}
+
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+    return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+    return self.logindata.count;
+    
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+    
+    NSMutableDictionary* up = self.logindata[indexPath.row];
+    
+    
+    
+    NSString *CellIdentifier = @"LoginListCell";
+    UITableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
+    NSString* name=up[@"name"];
+    cell.textLabel.text = name;
+    return cell;
+    
+}
+
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+    
+    
+    NSMutableDictionary* up = self.logindata[indexPath.row];
+    
+    
+    
+    UIApplication * app = [UIApplication sharedApplication];
+    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+    
+    if(appDelegate.bLogin)
+    {
+        UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Switch user"];
+        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            
+            NSDictionary* return_json = [iSalesNetwork logout];
+            
+            dispatch_async(dispatch_get_main_queue(), ^{
+                
+                
+                appDelegate.cart_count = 0;
+                appDelegate.wish_count =0;
+                appDelegate.port_count =0;
+                
+                [appDelegate update_count_mark];
+                
+                
+                appDelegate.can_show_price =false;
+                appDelegate.can_see_price =false;
+                appDelegate.can_create_portfolio =false;
+                appDelegate.can_create_order =false;
+                
+                
+                appDelegate.can_cancel_order =false;
+                appDelegate.can_set_cart_price =false;
+                appDelegate.can_delete_order =false;
+                appDelegate.can_submit_order =false;
+                appDelegate.can_set_tearsheet_price =false;
+                appDelegate.can_update_contact_info = false;
+                
+                appDelegate.save_order_logout = false;
+                appDelegate.submit_order_logout = false;
+                appDelegate.alert_sold_in_quantities = false;
+                
+                appDelegate.ipad_perm =nil ;
+                appDelegate.user_type = USER_ROLE_UNKNOWN;
+                appDelegate.OrderFilter= nil;
+                [appDelegate SetSo:nil];
+                [appDelegate set_main_button_panel];
+                
+                
+                
+                [appDelegate Logout];
+                // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+                    
+                    
+                    int ret=[iSalesNetwork  Authorize:up[@"name"] password:up[@"pwd"]];
+                    
+                    dispatch_async(dispatch_get_main_queue(), ^{
+                        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+                        
+                        
+                        if(ret==RESULT_TRUE)
+                            
+                        {
+                            
+                            //
+                            //                NSString* contactid=[self.content_data[indexPath.row] valueForKey:@"contact_id"] ;
+                            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                            //                appDelegate.contact_id=contactid;
+                            //                appDelegate.contact_name =[self.content_data[indexPath.row] valueForKey:@"name"];
+                            
+                            NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+                            [defaults removeObjectForKey:@"user"];
+                            [defaults removeObjectForKey:@"password"];
+                            if(true)
+                            {
+                                NSString* encryptu=[AESCrypt encrypt:appDelegate.user password:@"usai"];
+                                NSString* encryptp=[AESCrypt encrypt:up[@"pwd"] password:@"usai"] ;
+                                
+                                [defaults setValue:encryptu forKey:@"user"];
+                                [defaults setValue:encryptp forKey:@"password"];
+                                
+                                
+                                //                    [defaults setBool:TRUE forKey:@"autologin"];
+                            }
+                            [defaults synchronize];
+                            
+                            
+                            
+                            
+                            
+                            MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+                            if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
+                            {
+                                
+                                [main_vc checklogin:false];
+                                
+                            }
+                            
+                            else
+                            {
+                                
+                                [main_vc checklogin:false];
+                                
+                            }
+                                [self dismissViewControllerAnimated:true completion:^{
+                                    if(self.returnValue)
+                                        self.returnValue(true);
+                                }];
+                            
+                            
+                            
+                        }
+                        else
+                        {
+                            NSString* msg=nil;
+                            
+                            switch (ret) {
+                                    
+                                case RESULT_NET_NOTAVAILABLE:
+                                    msg = MSG_NET_NOTAVAILABLE;
+                                    break;
+                                    
+                                    
+                                case RESULT_NET_ERROR:
+                                    msg = MSG_NET_ERROR;
+                                    break;
+                                    
+                                    
+                                case RESULT_FALSE:
+                                    msg = MSG_USERAUTH_ERROR;
+                                    break;
+                                    
+                                case RESULT_VER_LOW:
+                                    msg = MSG_VER_LOW;
+                                    break;
+                                default:
+                                    break;
+                            }
+                            
+                            
+                            UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Switch User" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                            //block代码块取代了delegate
+                            
+                            
+                            
+                            UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                                
+                                
+                                [self dismissViewControllerAnimated:true completion:^{
+                                    if(self.returnValue)
+                                        self.returnValue(false);
+                                }];
+                                
+                                
+                                
+                            }];
+                            
+                            
+                            [alertControl addAction:actionOne];
+                            
+
+                            
+                            //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
+                            
+                            
+                            [self presentViewController:alertControl animated:YES completion:nil];
+                            
+
+                            
+                            //[RAUtils alert_view:msg title:@"Sign in"];
+                            
+
+                            
+                            
+                        }
+                        
+                        
+                    });
+                });
+                
+                
+                
+                
+                
+                
+                
+            });
+        });
+    }
+    
+    
+    //    self.edituser.text = up[@"name"];
+    //    self.editpass.text = up[@"pwd"];
+    //
+    //    self.showList=false;
+    //    self.Loginlist.hidden=true;
+    
+    
+}
+//- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
+//{
+//
+//    return true;
+//}
+
+@end

+ 1 - 0
RedAnt ERP Mobile/common/data_provider/iSalesDB.h

@@ -32,4 +32,5 @@
 
 
 + (NSDictionary*) search_pdf:(int) offset limit:(int)limit keywords:(NSString*) keywords;
++(NSArray*) get_saveduser;
 @end

+ 82 - 39
RedAnt ERP Mobile/common/data_provider/iSalesDB.m

@@ -7,10 +7,54 @@
 //
 
 #import "iSalesDB.h"
+#import "AESCrypt.h"
 #import "AppDelegate.h"
 @implementation iSalesDB
 
-
++(NSArray*) get_saveduser
+{
+    {
+        sqlite3* db = [self get_db ];
+        NSMutableArray* ret = [[NSMutableArray alloc] init];
+//        ApexMobileAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
+//        NSString* user = appDelegate.user;
+        NSString *sqlQuery = @"select name,pwd from login_info ";
+        sqlite3_stmt * statement;
+        
+        if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
+        {
+            while (sqlite3_step(statement) == SQLITE_ROW)
+            {
+                //            char *name = (char*)sqlite3_column_text(statement, 1);
+                //            NSString *nsNameStr = [[NSString alloc]initWithUTF8String:name];
+                
+                NSString *name = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 0)];
+                NSString *pwd = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 1)];
+                
+                
+                
+                
+                name = [AESCrypt decrypt:name password:@"usai"];
+                pwd = [AESCrypt decrypt:pwd password:@"usai"];
+                
+               
+                NSMutableDictionary* up = [[NSMutableDictionary alloc]init];
+                up[@"name"]=name;
+                up[@"pwd"]=pwd;
+                [ret addObject:up];
+                //            char *address = (char*)sqlite3_column_text(statement, 3);
+                //            NSString *nsAddressStr = [[NSString alloc]initWithUTF8String:address];
+                
+                
+            }
+            sqlite3_finalize(statement);
+        }
+        
+        sqlite3_close(db);
+        
+        return ret;
+    }
+}
 +(void)testdata
 {
     
@@ -207,8 +251,8 @@
 {
     sqlite3* db = nil;
     
-  //  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
-    NSString *documents = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];//[paths objectAtIndex:0];
+    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+    NSString *documents = /*[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];*/[paths objectAtIndex:0];
     NSString *database_path = [documents stringByAppendingPathComponent:DBNAME];
     
     DebugLog(@"DB path:%@",database_path);
@@ -372,22 +416,22 @@
 + (BOOL) initializeDb {
     DebugLog (@"initializeDB");
     
-    return false;
-    
-    //   NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
-    NSString *documents = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];//[paths objectAtIndex:0];
-    NSString *database_path = [documents stringByAppendingPathComponent:DBNAME];
-    
+//    return false;
+//    
+//       NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+//    NSString *documents = /*[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];*/[paths objectAtIndex:0];
+//    NSString *database_path = [documents stringByAppendingPathComponent:DBNAME];
+//    
     
     // move db file from document to cache ;
     //   NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
-    NSString *documentFolderPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] ;//[searchPaths objectAtIndex: 0];
-    NSString* dbFilePath = [documentFolderPath stringByAppendingPathComponent:DBNAME];
-    if ([[NSFileManager defaultManager] fileExistsAtPath: dbFilePath])
-    {
-        [[NSFileManager defaultManager] moveItemAtPath:dbFilePath toPath:database_path error:nil];
-        
-    }
+//    NSString *documentFolderPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] ;//[searchPaths objectAtIndex: 0];
+//    NSString* dbFilePath = [documentFolderPath stringByAppendingPathComponent:DBNAME];
+//    if ([[NSFileManager defaultManager] fileExistsAtPath: dbFilePath])
+//    {
+//        [[NSFileManager defaultManager] moveItemAtPath:dbFilePath toPath:database_path error:nil];
+//        
+//    }
     // end move;
     
     
@@ -421,31 +465,30 @@
         NSString* create_offline_contact=@"CREATE TABLE IF NOT EXISTS offline_contact ( _id INTEGER PRIMARY KEY, country VARCHAR(40),company_name VARCHAR(40),contact_id VARCHAR(20),addr_1 text, addr_2 text , addr_3 text, addr_4 text, zipcode varchar(20),state  VARCHAR(40), city VARCHAR(40), first_name VARCHAR(40) ,last_name  VARCHAR(40),phone VARCHAR(40),fax VARCHAR(40),email VARCHAR(40),notes text, price_type  VARCHAR(40), sales_rep VARCHAR(40), type VARCHAR(40),create_time timestamp,editable integer,contact_name VARCHAR(40) , addr text);";
         
         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));";
-        //        CREATE TABLE users (_id integer PRIMARY KEY,name varchar(20),pass varchar(20));
-        //        [self execSql:create_actions_info db:db];
-        //        [self execSql:create_fields_info db:db];
-        //        [self execSql:create_search_history db:db];
-        //        [self execSql:create_push_message db:db];
-        //        [self execSql:create_favorites db:db];
-        //        [self execSql:create_history db:db];
-        //        [self execSql:create_location db:db];
-        [self execSql:create_model db:db];
-        
-        [self execSql:create_image db:db];
-        
-        [self execSql:create_model_price db:db];
-        [self execSql:create_category db:db];
-        [self execSql:create_offline_setting db:db];
-        
-        [self execSql:create_offline_login db:db];
-        
-        [self execSql:create_offline_cart db:db];
-        
-        [self execSql:create_offline_wish db:db];
         
-        [self execSql:create_offline_contact db:db];
         
-        [self execSql:create_contact_image db:db];
+        NSString* create_login_info=@"CREATE TABLE IF NOT EXISTS login_info ( _id INTEGER PRIMARY KEY, name VARCHAR(256), pwd VARCHAR(256), lastlogin timestamp);";
+//    
+//        [self execSql:create_model db:db];
+//        
+//        [self execSql:create_image db:db];
+//        
+//        [self execSql:create_model_price db:db];
+//        [self execSql:create_category db:db];
+//        [self execSql:create_offline_setting db:db];
+//        
+//        [self execSql:create_offline_login db:db];
+//        
+//        [self execSql:create_offline_cart db:db];
+//        
+//        [self execSql:create_offline_wish db:db];
+//        
+//        [self execSql:create_offline_contact db:db];
+//        
+//        [self execSql:create_contact_image db:db];
+//        
+        
+        [self execSql:create_login_info db:db];
         
         //        if( ![self checkForField:@"search_history" field:@"level" db:db])
         //        {

+ 2 - 0
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.h

@@ -51,6 +51,8 @@
 
 +(NSDictionary*) cart_setGeneralNote:(NSString*) order_code notes:(NSString*) notes;
 
++(NSDictionary*) check_Offline:(NSString* )ver;
++(NSDictionary*) download_Offline:(NSString* )vid;
 
 +(NSDictionary*) add_toCart:(NSString* ) item_id count:(int) count;
 +(NSDictionary*) add_toCart_byName:(NSString* ) model_name;

+ 63 - 3
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m

@@ -1846,6 +1846,66 @@ repeat:{
     return jsobj;
 }
 
++(NSDictionary*) download_Offline:(NSString* )vid
+{
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    
+//    if(appDelegate.user!=nil)
+//        [params setValue:appDelegate.user forKey:@"user"];
+//    //    if(appDelegate.contact_id!=nil)
+//    //        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+//    if(appDelegate.password!=nil)
+//        [params setValue:appDelegate.password forKey:@"password"];
+    [params setValue:vid forKey:@"vid"];
+    NSData* json=[self get_json:URL_DOWNLOAD_OFFLINE parameters:params];
+    if(json==nil)
+        return nil;
+    NSError *error=nil;
+    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+    //    int result = [[jsobj valueForKey:@"result"] intValue];
+    //
+    //    if (result==2)
+    //    {
+    //
+    ////        appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
+    ////        //appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
+    ////        //    appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
+    ////
+    ////        [appDelegate update_count_mark];
+    //    }
+    return jsobj;
+}
++(NSDictionary*) check_Offline:(NSString* )ver
+{
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+
+    if(appDelegate.user!=nil)
+        [params setValue:appDelegate.user forKey:@"user"];
+    //    if(appDelegate.contact_id!=nil)
+    //        [params setValue:appDelegate.contact_id forKey:@"contactId"];
+    if(appDelegate.password!=nil)
+        [params setValue:appDelegate.password forKey:@"password"];
+    [params setValue:ver forKey:@"ver"];
+    NSData* json=[self get_json:URL_CHECK_OFFLINE parameters:params];
+    if(json==nil)
+        return nil;
+    NSError *error=nil;
+    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
+//    int result = [[jsobj valueForKey:@"result"] intValue];
+//    
+//    if (result==2)
+//    {
+//        
+////        appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
+////        //appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
+////        //    appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
+////        
+////        [appDelegate update_count_mark];
+//    }
+    return jsobj;
+}
 +(NSDictionary*)request_Cart
 {
     
@@ -2283,9 +2343,9 @@ repeat:{
     if (result==2)
     {
         
-        appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
-        appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
-            appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
+        appDelegate.cart_count = 0;//[[jsobj valueForKey:@"cart_count"] intValue];
+        appDelegate.wish_count =0;//[[jsobj valueForKey:@"wish_count"] intValue];
+        appDelegate.port_count =0;//[[jsobj valueForKey:@"portfolio_count"] intValue];
         
         [appDelegate update_count_mark];
         

+ 22 - 0
RedAnt ERP Mobile/iSales-NPD/OfflineSettingViewController.h

@@ -0,0 +1,22 @@
+//
+//  OfflineSettingViewController.h
+//  iSales-NPD
+//
+//  Created by Ray on 5/11/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface OfflineSettingViewController : UIViewController
+
+@property (strong, nonatomic) IBOutlet UISwitch *switch_offline;
+@property (strong, nonatomic) IBOutlet UILabel *label_ver;
+@property (strong, nonatomic) IBOutlet UILabel *label_cachesize;
+@property (strong, nonatomic) IBOutlet UIButton *btn_checkupdate;
+@property (strong, nonatomic) IBOutlet UIButton *btn_submitlocal;
+
+@property (strong, nonatomic) IBOutlet UIProgressView *progress_update;
+@property (strong, nonatomic) IBOutlet UIButton *btn_clearcache;
+@property (strong, nonatomic) IBOutlet UITextView *tv_log;
+@end

+ 53 - 0
RedAnt ERP Mobile/iSales-NPD/OfflineSettingViewController.m

@@ -0,0 +1,53 @@
+//
+//  OfflineSettingViewController.m
+//  iSales-NPD
+//
+//  Created by Ray on 5/11/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "OfflineSettingViewController.h"
+
+@interface OfflineSettingViewController ()
+
+@end
+
+@implementation OfflineSettingViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    
+    
+    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+    bool  offline = [defaults boolForKey:@"EnableOfflineMode"] ;
+    
+    self.switch_offline.on = offline;
+    
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+- (IBAction)onChangeOfflineSwitch:(id)sender {
+    
+    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+    [defaults removeObjectForKey:@"EnableOfflineMode"];
+    [defaults setBool:self.switch_offline.isOn forKey:@"EnableOfflineMode"];
+    
+    [defaults synchronize];
+    
+}
+/*
+#pragma mark - Navigation
+
+// 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.
+}
+*/
+
+@end