Преглед на файлове

完成 portfolio 、 cart 、 wishlist排序功能

Pen Li преди 9 години
родител
ревизия
cf75db037a

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 26 - 2
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -22,6 +22,7 @@
 #import "CartGeneralNotesViewController.h"
 #import "DefaultAppearance.h"
 #import "DefaultTableHeaderView.h"
+#import "SortItemViewController.h"
 
 
 #define ALERT_FREE 1024
@@ -31,6 +32,9 @@
 
 @interface CartViewController ()
 
+@property (nonatomic,strong) SortItemViewController *sortItemController;
+@property (nonatomic,assign) int sortIndex;
+
 @end
 
 @implementation CartViewController
@@ -516,7 +520,7 @@
         NSLog(@"reloading...");
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
             NSLog(@"BEGIN LOAD CART");
-            NSDictionary* cart_json = [iSalesNetwork request_Cart];
+            NSDictionary* cart_json = [iSalesNetwork request_Cart:self.sortIndex];
             
             dispatch_async(dispatch_get_main_queue(), ^{
                 //
@@ -619,7 +623,7 @@
     [self.itemListTable addSubview:ref];
     
     
-    
+    self.sortIndex = 0;
     
     
     self.toolpanel.layer.shadowPath =[UIBezierPath bezierPathWithRect:self.toolpanel.bounds].CGPath;
@@ -2436,6 +2440,26 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
 
 - (void)cartSortButtonClicked:(UIButton *)sender {
     DebugLog(@"cart sort button clicked");
+    
+    [self.view addSubview:self.sortItemController.view];
+}
+
+- (SortItemViewController *)sortItemController {
+    if (!_sortItemController) {
+        _sortItemController = [[SortItemViewController alloc] initWithTableOrigin:CGPointMake(20, 50)];
+        _sortItemController.sortIndex = self.sortIndex;
+        
+        __weak typeof(self) weakSelf = self;
+        _sortItemController.sortBlock = ^(int sort){
+            weakSelf.sortIndex = sort;
+            
+            [weakSelf reload_data];
+            
+        };
+    }
+//    _sortItemController.sortIndex = self.sortIndex;
+    
+    return _sortItemController;
 }
 
 

+ 60 - 4
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -706,13 +706,42 @@
     UIApplication * app = [UIApplication sharedApplication];
     AppDelegate *appDelegate = (AppDelegate *)[app delegate];
     
-    
+    int sort = [[params objectForKey:@"sort"] intValue];
+    NSString *sort_str = @"";
+    switch (sort) {
+        case 0:{
+            sort_str = @"order by w.create_time desc";
+        }
+            break;
+        case 1:{
+            sort_str = @"order by w.create_time asc";
+        }
+            break;
+        case 2:{
+            sort_str = @"order by m.name asc";
+        }
+            break;
+        case 3:{
+            sort_str = @"order by m.name desc";
+        }
+            break;
+        case 4:{
+            sort_str = @"order by m.description asc";
+        }
+            break;
+            
+        default:
+            break;
+            
+    }
+
     
     NSString* user = appDelegate.user;
     
     sqlite3 *db = [iSalesDB get_db];
     
-    NSString* sqlQuery = @"select w.product_id,m.name||'\n'||m.description,w._id from wishlist as w  left join product as m on w.product_id=m.product_id order by w.create_time;";
+    // order by w.create_time
+    NSString* sqlQuery = [NSString stringWithFormat:@"select w.product_id,m.name||'\n'||m.description,w._id from wishlist as w  left join product as m on w.product_id=m.product_id %@ ;",sort_str];
     sqlite3_stmt * statement;
     
     
@@ -2271,11 +2300,38 @@
     
     NSString* orderCode=params[@"orderCode"];
     
+    int sort = [[params objectForKey:@"sort"] intValue];
+    NSString *sort_str = @"";
+    switch (sort) {
+        case 0:{
+            sort_str = @"order by c.create_time desc";
+        }
+            break;
+        case 1:{
+            sort_str = @"order by c.create_time asc";
+        }
+            break;
+        case 2:{
+            sort_str = @"order by m.name asc";
+        }
+            break;
+        case 3:{
+            sort_str = @"order by m.name desc";
+        }
+            break;
+        case 4:{
+            sort_str = @"order by m.description asc";
+        }
+            break;
+            
+        default:
+            break;
+
+    }
     
     
     
-    
-    NSString *sqlQuery =     [ NSString stringWithFormat:@"select c.product_id,c.price,c.discount,c.item_count,c.line_note,m.name,m.description,c.item_id,m.stockUom,c._id from (select _id,product_id,decrypt(str_price) as price,discount,item_count,line_note,item_id from offline_cart where so_no='%@') c left join product m on c.product_id=m.product_id",orderCode ];
+    NSString *sqlQuery =     [ NSString stringWithFormat:@"select c.product_id,c.price,c.discount,c.item_count,c.line_note,m.name,m.description,c.item_id,m.stockUom,c._id from (select _id,product_id,decrypt(str_price) as price,discount,item_count,line_note,item_id,create_time from offline_cart where so_no='%@') c left join product m on c.product_id=m.product_id %@",orderCode,sort_str ];
 
     
 //        NSString *sqlQuery =     [ NSString stringWithFormat:@"select c.product_id,decrypt(c.str_price),c.discount,c.item_count,c.line_note,m.name,m.description,c.item_id,m.stockUom,c._id from offline_cart c  left join product m on c.product_id=m.product_id where c.so_no='%@'",orderCode ];

+ 2 - 10
RedAnt ERP Mobile/common/Functions/portfolio/PDFListViewController.m

@@ -13,9 +13,11 @@
 #import "MainViewController.h"
 #import "DefaultAppearance.h"
 #import "DefaultTableHeaderView.h"
+#import "SortItemViewController.h"
 
 @interface PDFListViewController ()
 
+
 @end
 
 @implementation PDFListViewController
@@ -36,8 +38,6 @@
     self.content_data = [[NSMutableArray alloc]init];
     
     
-    
-    
     UIRefreshControl *ref = [[UIRefreshControl alloc]init];
     ref.tag = 201 ;
     ref.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
@@ -654,14 +654,6 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
     
     
     
-}
-
-#pragma mark - sort button
-
-- (IBAction)portfolioSortButtonClicked:(UIButton *)sender {
-    
-    DebugLog(@"portfolio sort button click");
-    
 }
 
 

+ 35 - 2
RedAnt ERP Mobile/common/Functions/portfolio/PortfolioViewController.m

@@ -21,11 +21,15 @@
 #import "PDFViewController.h"
 #import "DefaultTableHeaderView.h"
 #import "DefaultAppearance.h"
+#import "SortItemViewController.h"
 
 #define ALERT_DEL 1025
 #define checked_Count @"checkedCount"
 @interface PortfolioViewController ()
 
+@property (nonatomic,strong) SortItemViewController *sortItemController;
+@property (nonatomic,assign) int sortIndex;
+
 @end
 
 @implementation PortfolioViewController
@@ -479,7 +483,7 @@
     self.label_net_err.layer.cornerRadius=15;
     self.label_net_err.layer.masksToBounds=true;
     
-    
+    self.sortIndex = 0;
     
     
     UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(refresh_btn_click:)];
@@ -857,7 +861,7 @@
     
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
-        NSDictionary* cart_json = [iSalesNetwork request_Portfolio];
+        NSDictionary* cart_json = [iSalesNetwork request_Portfolio:self.sortIndex];
         
         dispatch_async(dispatch_get_main_queue(), ^{
             [self.mum stopAnimating];
@@ -974,6 +978,12 @@
     
     DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 33)];
     
+    UIButton *sortButton = [UIButton buttonWithType:UIButtonTypeCustom];
+    sortButton.frame = CGRectMake(20, 5.5, (33 - 5.5 * 2), (33 - 5.5 * 2));
+    [sortButton setImage:[UIImage imageNamed:@"check_1_24"] forState:UIControlStateNormal];
+    [sortButton addTarget:self action:@selector(portfolioSortButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
+    [myView addSubview:sortButton];
+    
     
     UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 5.5, tableView.bounds.size.width, 22)];
     titlelabel.textColor=UIColorFromRGB(color);
@@ -1576,4 +1586,27 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
     
 }
 
+- (SortItemViewController *)sortItemController {
+    if (!_sortItemController) {
+        _sortItemController = [[SortItemViewController alloc] initWithTableOrigin:CGPointMake(40, 40)];
+        _sortItemController.sortIndex = self.sortIndex;
+
+        __weak typeof(self) weakSelf = self;
+        _sortItemController.sortBlock = ^(int sort){
+            weakSelf.sortIndex = sort;
+            [weakSelf reload_data];
+        };
+        
+    }
+//    _sortItemController.sortIndex = self.sortIndex;
+    
+    return _sortItemController;
+}
+
+- (void)portfolioSortButtonClicked:(UIButton *)sender {
+    [self.view addSubview:self.sortItemController.view];
+}
+
+
+
 @end

+ 26 - 3
RedAnt ERP Mobile/common/Functions/watchlist/WatchListViewController.m

@@ -18,11 +18,15 @@
 #import "ContactListViewController.h"
 #import "DefaultTableHeaderView.h"
 #import "DefaultAppearance.h"
+#import "SortItemViewController.h"
 
 #define ALERT_DEL 1025
 //#import "PDFViewController.h"
 @interface WatchListViewController ()
 
+@property (nonatomic,strong) SortItemViewController *sortItemController;
+@property (nonatomic,assign) int sortIndex;
+
 @end
 
 @implementation WatchListViewController
@@ -407,7 +411,7 @@
     self.label_net_err.layer.masksToBounds=true;
     
     
-    
+    self.sortIndex = 0;
     
     UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(refresh_btn_click:)];
     //            tap.minimumPressDuration = 0.8; //定义按的时间
@@ -554,7 +558,7 @@
     
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
-        NSDictionary* cart_json = [iSalesNetwork request_WatchList];
+        NSDictionary* cart_json = [iSalesNetwork request_WatchList:self.sortIndex];
         
         dispatch_async(dispatch_get_main_queue(), ^{
             
@@ -668,7 +672,7 @@
     DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 33)];
 
     UIButton *sortButton = [UIButton buttonWithType:UIButtonTypeCustom];
-    sortButton.frame = CGRectMake(10, 5.5, (33 - 5.5 * 2), (33 - 5.5 * 2));
+    sortButton.frame = CGRectMake(20, 5.5, (33 - 5.5 * 2), (33 - 5.5 * 2));
     [sortButton setImage:[UIImage imageNamed:@"check_1_24"] forState:UIControlStateNormal];
     [sortButton addTarget:self action:@selector(wishlistSortButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
     [myView addSubview:sortButton];
@@ -1103,6 +1107,8 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
 
 - (void)wishlistSortButtonClicked:(UIButton *)sender {
     DebugLog(@"wish list sort button clicked");
+    
+    [self.view addSubview:self.sortItemController.view];
 }
 
 
@@ -1117,5 +1123,22 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
  }
  */
 
+- (SortItemViewController *)sortItemController {
+    if (!_sortItemController) {
+        _sortItemController = [[SortItemViewController alloc] initWithTableOrigin:CGPointMake(40, 40)];
+        _sortItemController.sortIndex = self.sortIndex;
+
+        __weak typeof(self) weakSelf = self;
+        _sortItemController.sortBlock = ^(int sort){
+            weakSelf.sortIndex = sort;
+
+            [weakSelf reload_data];
+        };
+
+    }
+//    _sortItemController.sortIndex = self.sortIndex;
+    
+    return _sortItemController;
+}
 
 @end

+ 4 - 4
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.h

@@ -16,7 +16,7 @@
 @interface iSalesNetwork : NSObject
 +(void) LoadImage:(NSString*) url into:(UIImageView*) container;
 +(NSDictionary*) portfolio_remove:(NSString* ) item_ids;
-+(NSDictionary*)request_Portfolio;
++(NSDictionary*)request_Portfolio:(int)sort;
 
 +(NSDictionary*) delete_portfoliolist:(NSString* ) listid;
 
@@ -57,8 +57,8 @@
 +(NSDictionary*) add_toCart:(NSString* ) item_id count:(int) count;
 +(NSDictionary*) add_toCart_byName:(NSString* ) model_name;
 +(NSDictionary*) add_toWatchList:(NSString* ) item_id;
-+(NSDictionary*)request_Cart;
-+(NSDictionary*)request_WatchList;
++(NSDictionary*)request_Cart:(int)sort;
++(NSDictionary*)request_WatchList:(int)sort;
 +(NSDictionary*) portfolio_setPrice:(NSString*) watchlist_id price:(float) price discount:(float) discount QTY:(int)qty qty_p:(float) qty_p notes:(NSString*)notes;
 //+(NSDictionary*) portfolio_setQTY:(NSString*) watchlist_id QTY:(int)qty;
 
@@ -101,7 +101,7 @@
 +(NSString*)DataTOjsonString:(id)object;
 
 
-+(NSDictionary*)request_PDFList:(int ) offset limit:(int)limit keywords:(NSString* ) keywords;
++(NSDictionary*)request_PDFList:(int ) offset limit:(int)limit keywords:(NSString* ) keywords ;
 +(NSDictionary*)request_TearSheet:(NSString*) request_url ;
 +(NSDictionary*)save_TearSheet:(NSString*) path name:(NSString*)name delete:(NSString* )ids note:(NSString* )note;
 +(NSDictionary*)direct_save_TearSheet:(NSString*) request_url name:(NSString*)name delete:(NSString* )ids note:(NSString* )saveNote;

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

@@ -1394,6 +1394,7 @@ repeat:
     
     [params setValue:[NSString stringWithFormat:@"%d",limit]  forKey:@"limit"];
     [params setValue:[NSString stringWithFormat:@"%d",offset]  forKey:@"offset"];
+
     if(appDelegate.offline_mode)
     {
         return [OLDataProvider offline_notimpl];
@@ -2237,7 +2238,7 @@ repeat:
     //    }
     return jsobj;
 }
-+(NSDictionary*)request_Cart
++(NSDictionary*)request_Cart:(int)sort
 {
     
     NSLog(@"iSalesNetwork::request_Cart");
@@ -2255,6 +2256,7 @@ repeat:
     if(appDelegate.order_code!=nil)
         [params setValue:appDelegate.order_code forKey:@"orderCode"];
     
+    [params setValue:[NSNumber numberWithInt:sort] forKey:@"sort"];
     NSData* json=nil;
     if(appDelegate.offline_mode)
     {
@@ -2284,7 +2286,7 @@ repeat:
     }
     return jsobj;
 }
-+(NSDictionary*)request_Portfolio
++(NSDictionary*)request_Portfolio:(int)sort
 {
     
     
@@ -2300,6 +2302,8 @@ repeat:
     
     [params setValue:[NSString stringWithFormat:@"%d",0 ] forKey:@"offset"];
     [params setValue:[NSString stringWithFormat:@"%d",INT_MAX ] forKey:@"limit"];
+    [params setValue:[NSNumber numberWithInt:sort] forKey:@"sort"];
+    
     if(appDelegate.offline_mode)
     {
         return [OLDataProvider offline_notimpl];
@@ -2325,7 +2329,7 @@ repeat:
     }
     return jsobj;
 }
-+(NSDictionary*)request_WatchList
++(NSDictionary*)request_WatchList:(int)sort
 {
     
     NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
@@ -2339,6 +2343,8 @@ repeat:
     
     [params setValue:[NSString stringWithFormat:@"%d",0 ] forKey:@"offset"];
     [params setValue:[NSString stringWithFormat:@"%d",INT_MAX ] forKey:@"limit"];
+    
+    [params setValue:[NSNumber numberWithInt:sort] forKey:@"sort"];
     if(appDelegate.offline_mode)
     {
         return [OLDataProvider offline_wishlist:params];

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

@@ -13,6 +13,9 @@
 		42A51BF41D62F60300F13667 /* more_info.html in Resources */ = {isa = PBXBuildFile; fileRef = 42A51BF31D62F60300F13667 /* more_info.html */; };
 		42A51BF61D62F9AB00F13667 /* orderDetail.json in Resources */ = {isa = PBXBuildFile; fileRef = 42A51BF51D62F9AB00F13667 /* orderDetail.json */; };
 		42B3C9BB1D642C880053985C /* order_info.html in Resources */ = {isa = PBXBuildFile; fileRef = 42B3C9BA1D642C880053985C /* order_info.html */; };
+		42B99E131D7D032300E773CD /* SortItemViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42B99E121D7D032300E773CD /* SortItemViewController.m */; };
+		42B99E161D7D052A00E773CD /* SortItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42B99E151D7D052A00E773CD /* SortItemCell.m */; };
+		42B99E1A1D7D206A00E773CD /* UIImage+ColorImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 42B99E191D7D206A00E773CD /* UIImage+ColorImage.m */; };
 		42C9FB151D5B28FA001DCA8B /* contactAdvanceSearch.json in Resources */ = {isa = PBXBuildFile; fileRef = 42C9FB141D5B28FA001DCA8B /* contactAdvanceSearch.json */; };
 		42DC31131D546FBE00BCD1C6 /* category.json in Resources */ = {isa = PBXBuildFile; fileRef = 42DC31121D546FBE00BCD1C6 /* category.json */; };
 		710274251CC606C4009FD219 /* UserListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 710274241CC606C4009FD219 /* UserListViewController.m */; };
@@ -206,6 +209,12 @@
 		42A51BF31D62F60300F13667 /* more_info.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = more_info.html; sourceTree = "<group>"; };
 		42A51BF51D62F9AB00F13667 /* orderDetail.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = orderDetail.json; sourceTree = "<group>"; };
 		42B3C9BA1D642C880053985C /* order_info.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = order_info.html; sourceTree = "<group>"; };
+		42B99E111D7D032300E773CD /* SortItemViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortItemViewController.h; sourceTree = "<group>"; };
+		42B99E121D7D032300E773CD /* SortItemViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortItemViewController.m; sourceTree = "<group>"; };
+		42B99E141D7D052A00E773CD /* SortItemCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortItemCell.h; sourceTree = "<group>"; };
+		42B99E151D7D052A00E773CD /* SortItemCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortItemCell.m; sourceTree = "<group>"; };
+		42B99E181D7D206A00E773CD /* UIImage+ColorImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+ColorImage.h"; sourceTree = "<group>"; };
+		42B99E191D7D206A00E773CD /* UIImage+ColorImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+ColorImage.m"; sourceTree = "<group>"; };
 		42C9FB141D5B28FA001DCA8B /* contactAdvanceSearch.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = contactAdvanceSearch.json; sourceTree = "<group>"; };
 		42DC31121D546FBE00BCD1C6 /* category.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = category.json; sourceTree = "<group>"; };
 		56528CA8B8A71F67C2EE5366 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
@@ -576,6 +585,15 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+		42B99E171D7D206A00E773CD /* UIImage+ColorImage */ = {
+			isa = PBXGroup;
+			children = (
+				42B99E181D7D206A00E773CD /* UIImage+ColorImage.h */,
+				42B99E191D7D206A00E773CD /* UIImage+ColorImage.m */,
+			);
+			path = "UIImage+ColorImage";
+			sourceTree = "<group>";
+		};
 		710212821B8D59DE00E1788B /* watchlist */ = {
 			isa = PBXGroup;
 			children = (
@@ -808,6 +826,7 @@
 		716387C71953CDB4006E65E6 /* utils */ = {
 			isa = PBXGroup;
 			children = (
+				42B99E171D7D206A00E773CD /* UIImage+ColorImage */,
 				71BBA2171CEAC10200C91DED /* zip */,
 				71B1250B1C55BD4600118904 /* QRCODE */,
 				71BE066E1BA1607400FA6544 /* AES */,
@@ -1158,6 +1177,10 @@
 				719562411CF5828200C74A49 /* DefaultTableHeaderView.m */,
 				715001FD1D114D9100F5927F /* BundleDetailButton.h */,
 				715001FE1D114D9100F5927F /* BundleDetailButton.m */,
+				42B99E111D7D032300E773CD /* SortItemViewController.h */,
+				42B99E121D7D032300E773CD /* SortItemViewController.m */,
+				42B99E141D7D052A00E773CD /* SortItemCell.h */,
+				42B99E151D7D052A00E773CD /* SortItemCell.m */,
 			);
 			name = CommonUI;
 			sourceTree = "<group>";
@@ -1394,6 +1417,7 @@
 				71DF74621C575E7900F2789C /* CommonEditorCellSignature.m in Sources */,
 				7162A5E01C5876E300AB630E /* SettingViewController.m in Sources */,
 				71DF748B1C57608F00F2789C /* SimpleGrid.m in Sources */,
+				42B99E131D7D032300E773CD /* SortItemViewController.m in Sources */,
 				71DF74651C575E7900F2789C /* CommonEditorViewController.m in Sources */,
 				7162A5171C58704600AB630E /* BundleModelViewController.m in Sources */,
 				71DF745B1C575E7900F2789C /* CommonEditorCellAction.m in Sources */,
@@ -1403,6 +1427,7 @@
 				7162A5AD1C58735900AB630E /* TearSheetParamViewController.m in Sources */,
 				7141DD611C5747CE00F7DF59 /* NSData+Base64.m in Sources */,
 				71BBA2431CEAEF0700C91DED /* zip.c in Sources */,
+				42B99E1A1D7D206A00E773CD /* UIImage+ColorImage.m in Sources */,
 				7141DD5F1C5747CE00F7DF59 /* AESCrypt.m in Sources */,
 				7162A5991C58733400AB630E /* OrderDetailHtmlCell.m in Sources */,
 				7162A5091C586FC100AB630E /* CycleScrollView.m in Sources */,
@@ -1419,6 +1444,7 @@
 				719562421CF5828200C74A49 /* DefaultTableHeaderView.m in Sources */,
 				716AF8E11D7AA0E0001188E0 /* SelectUploadOrderViewController.m in Sources */,
 				7162A5611C58724700AB630E /* CustomerInfoViewController.m in Sources */,
+				42B99E161D7D052A00E773CD /* SortItemCell.m in Sources */,
 				7162A5AB1C58735900AB630E /* PDFListViewController.m in Sources */,
 				71DF74681C575E7900F2789C /* EnumSelectViewController.m in Sources */,
 				71D99D301CEF02E700CA32DE /* CustomIOSAlertView.m in Sources */,

+ 0 - 11
RedAnt ERP Mobile/iSales-NPD/Base.lproj/Main.storyboard

@@ -2800,17 +2800,6 @@
                                 <color key="barTintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                 <items>
                                     <navigationItem title="View Portfolios" id="SSH-WU-EMm">
-                                        <barButtonItem key="leftBarButtonItem" style="plain" id="FrP-8F-lwn">
-                                            <button key="customView" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="F7e-bA-1gp">
-                                                <rect key="frame" x="20" y="10" width="24" height="24"/>
-                                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
-                                                <state key="normal" image="check_1_24"/>
-                                                <connections>
-                                                    <action selector="portfolioSortButtonClicked:" destination="6Y6-6I-VU5" eventType="touchUpInside" id="NI9-aQ-LYW"/>
-                                                </connections>
-                                            </button>
-                                        </barButtonItem>
                                         <barButtonItem key="rightBarButtonItem" style="plain" id="cOa-Md-aHw">
                                             <searchBar key="customView" contentMode="redraw" searchBarStyle="minimal" placeholder="Name" id="hIq-6S-g7M">
                                                 <rect key="frame" x="468" y="0.0" width="280" height="44"/>

+ 16 - 2
RedAnt ERP Mobile/iSales-NPD/Base.lproj/OLM.storyboard

@@ -117,6 +117,20 @@
             </objects>
             <point key="canvasLocation" x="887" y="803"/>
         </scene>
+        <!--Sort Item View Controller-->
+        <scene sceneID="ikc-XA-PRq">
+            <objects>
+                <viewController storyboardIdentifier="SortItemViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="KGB-4A-pg4" customClass="SortItemViewController" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="pae-Dr-xbo">
+                        <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                    </view>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="ryb-NY-iqX" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="3919" y="633"/>
+        </scene>
         <!--Sync Control Panel View Controller-->
         <scene sceneID="INA-Kf-FWJ">
             <objects>
@@ -206,7 +220,7 @@
                                                     <rect key="frame" x="48" y="15" width="202" height="21"/>
                                                     <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="17"/>
-                                                    <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+                                                    <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="hrK-DY-RbO">
@@ -222,7 +236,7 @@
                                                     <rect key="frame" x="381" y="15" width="341" height="21"/>
                                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="17"/>
-                                                    <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+                                                    <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                             </subviews>

+ 21 - 0
RedAnt ERP Mobile/iSales-NPD/SortItemCell.h

@@ -0,0 +1,21 @@
+//
+//  SortItemCell.h
+//  iSales-NPD
+//
+//  Created by Jack on 16/9/5.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+#define CellIdentifier @"sortItemCell"
+
+@interface SortItemCell : UITableViewCell
+
+@property (nonatomic,strong) UILabel *sortTitleLabel;
+
+@property (nonatomic,copy) NSString *sortTitle;
+
+@property (nonatomic,assign) BOOL selectedSort;
+
+@end

+ 88 - 0
RedAnt ERP Mobile/iSales-NPD/SortItemCell.m

@@ -0,0 +1,88 @@
+//
+//  SortItemCell.m
+//  iSales-NPD
+//
+//  Created by Jack on 16/9/5.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "SortItemCell.h"
+#import "UIImage+ColorImage.h"
+
+@interface SortItemCell ()
+
+@property (nonatomic,strong) UIButton *selectedView;
+
+@end
+
+@implementation SortItemCell
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Initialization code
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    [super setSelected:selected animated:animated];
+
+    // Configure the view for the selected state
+}
+
+- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
+    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
+        
+        [self addSubview:self.selectedView];
+        [self addSubview:self.sortTitleLabel];
+    }
+    return self;
+}
+
+- (void)setFrame:(CGRect)frame {
+    [super setFrame:frame];
+    CGFloat w = CGRectGetWidth(frame);
+    CGFloat h = CGRectGetHeight(frame);
+    
+    self.sortTitleLabel.frame = CGRectMake(40, 0, w - 15, h);
+    self.selectedView.frame = CGRectMake(10, (h - 18) / 2, 18, 18);
+}
+
+- (UILabel *)sortTitleLabel {
+    if (!_sortTitleLabel) {
+        CGFloat w = CGRectGetWidth(self.bounds);
+        CGFloat h = CGRectGetHeight(self.bounds);
+        
+        _sortTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 0, w - 15, h)];
+        _sortTitleLabel.backgroundColor = [UIColor clearColor];
+        _sortTitleLabel.font = [UIFont systemFontOfSize:17];
+        _sortTitleLabel.textColor = [UIColor blackColor];
+        _sortTitleLabel.textAlignment = NSTextAlignmentLeft;
+        
+    }
+    return _sortTitleLabel;
+}
+
+- (UIButton *)selectedView {
+    if (!_selectedView) {
+
+        CGFloat h = CGRectGetHeight(self.bounds);
+        _selectedView = [[UIButton alloc] initWithFrame:CGRectMake(10, (h - 18) / 2, 18, 18)];
+        [_selectedView setImage:[UIImage imageNamed:@"check_1_24"] forState:UIControlStateSelected];
+        _selectedView.userInteractionEnabled = NO;
+    }
+    return _selectedView;
+}
+
+- (void)setSortTitle:(NSString *)sortTitle {
+    _sortTitle = sortTitle;
+    
+    self.sortTitleLabel.text = sortTitle;
+   
+}
+
+- (void)setSelectedSort:(BOOL)selectedSort {
+    _selectedSort = selectedSort;
+    self.selectedView.selected = selectedSort;
+}
+
+
+@end

+ 21 - 0
RedAnt ERP Mobile/iSales-NPD/SortItemViewController.h

@@ -0,0 +1,21 @@
+//
+//  SortItemViewController.h
+//  iSales-NPD
+//
+//  Created by Jack on 16/9/5.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+typedef void(^sortRequestBlock)(int sort);
+
+@interface SortItemViewController : UIViewController
+
+@property (nonatomic,copy) sortRequestBlock sortBlock;
+
+@property (nonatomic,assign) int sortIndex;
+
+- (instancetype)initWithTableOrigin:(CGPoint)origin;
+
+@end

+ 154 - 0
RedAnt ERP Mobile/iSales-NPD/SortItemViewController.m

@@ -0,0 +1,154 @@
+//
+//  SortItemViewController.m
+//  iSales-NPD
+//
+//  Created by Jack on 16/9/5.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "SortItemViewController.h"
+#import "SortItemCell.h"
+
+@interface SortItemViewController ()<UITableViewDelegate,UITableViewDataSource>
+{
+    CGSize tableSize;
+    CGPoint tableOrigin;
+}
+@property (nonatomic,strong) UITableView *sortTable;
+
+@property (nonatomic,strong) UIView *tableBackgroundView;
+
+@end
+
+@implementation SortItemViewController
+
+- (instancetype)initWithTableOrigin:(CGPoint)origin {
+    if (self = [super init]) {
+        tableOrigin = origin;
+    }
+    return self;
+}
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    tableSize = CGSizeMake(180, 200);
+    self.view.backgroundColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:0.5];
+    
+    [self.view addSubview:self.tableBackgroundView];
+    
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (UIView *)tableBackgroundView {
+    if (!_tableBackgroundView) {
+        
+        _tableBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(tableOrigin.x, tableOrigin.y, tableSize.width, tableSize.height + 20)];
+        _tableBackgroundView.layer.cornerRadius = 5;
+        _tableBackgroundView.layer.masksToBounds = YES;
+        _tableBackgroundView.backgroundColor = [UIColor whiteColor];
+        
+        [_tableBackgroundView addSubview:self.sortTable];
+        
+    }
+    return _tableBackgroundView;
+}
+
+- (UITableView *)sortTable {
+    if (!_sortTable) {
+        _sortTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 10, tableSize.width, tableSize.height) style:UITableViewStylePlain];
+        _sortTable.backgroundColor = [UIColor whiteColor];
+        _sortTable.showsVerticalScrollIndicator = NO;
+        _sortTable.showsHorizontalScrollIndicator = NO;
+        _sortTable.dataSource = self;
+        _sortTable.delegate = self;
+    }
+    return _sortTable;
+}
+
+#pragma mark data source
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    return 5;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    SortItemCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+    if (!cell) {
+        cell = [[SortItemCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
+    }
+//    cell.selectionStyle = UITableViewCellSelectionStyleNone;
+    
+    switch (indexPath.row) {
+        case 0:{
+            cell.sortTitle = @"Newest";
+        }
+            break;
+        case 1:{
+            cell.sortTitle = @"Oldest";
+        }
+            break;
+        case 2:{
+            cell.sortTitle = @"Item number a-z";
+        }
+            break;
+        case 3:{
+            cell.sortTitle = @"Item number z-a";
+        }
+            break;
+        case 4:{
+            cell.sortTitle = @"Description";
+        }
+            break;
+            
+        default:
+            break;
+    }
+    
+    if (self.sortIndex == indexPath.row) {
+        cell.selectedSort = YES;
+    }
+    
+    return cell;
+}
+
+#pragma mark delegate
+
+- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+    return 40;
+}
+
+- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    SortItemCell *cell = [tableView cellForRowAtIndexPath:indexPath];
+    cell.selected = NO;
+    
+//    dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, 0.25 * NSEC_PER_SEC);
+//    dispatch_after(time, dispatch_get_main_queue(), ^{
+//       
+//    });
+
+    if (indexPath.row != self.sortIndex) {
+        NSIndexPath *oldIndexPath = [NSIndexPath indexPathForRow:self.sortIndex inSection:0];
+        SortItemCell *oldCell = [tableView cellForRowAtIndexPath:oldIndexPath];
+        oldCell.selectedSort = NO;
+        
+        self.sortIndex = indexPath.row;
+        cell.selectedSort = YES;
+        
+        if (self.sortBlock) {
+            self.sortBlock(self.sortIndex);
+        }
+        
+    }
+    
+    [self.view removeFromSuperview];
+    
+}
+
+
+@end

+ 24 - 0
RedAnt ERP Mobile/iSales-NPD/UIImage+ColorImage/UIImage+ColorImage.h

@@ -0,0 +1,24 @@
+//
+//  UIImage+ColorImage.h
+//  
+//
+//  Created by emerys on 16/4/1.
+//  Copyright © 2016年 Emerys. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface UIImage (ColorImage)
+
+/**
+ *  @author Jack Lee, 16-04-01 19:04:02
+ *
+ *  @brief 生成一个颜色为color的image对象
+ *
+ *  @param color image颜色
+ */
++ (instancetype)imageWithColor:(UIColor *)color;
+
++ (instancetype)imageWithColor:(UIColor *)color size:(CGSize)size;
+
+@end

+ 28 - 0
RedAnt ERP Mobile/iSales-NPD/UIImage+ColorImage/UIImage+ColorImage.m

@@ -0,0 +1,28 @@
+//
+//  UIImage+ColorImage.m
+//  
+//
+//  Created by emerys on 16/4/1.
+//  Copyright © 2016年 Emerys. All rights reserved.
+//
+
+#import "UIImage+ColorImage.h"
+
+@implementation UIImage (ColorImage)
+
++(instancetype)imageWithColor:(UIColor *)color{
+    return [self imageWithColor:color size:CGSizeMake(1, 1)];
+}
+
++ (instancetype)imageWithColor:(UIColor *)color size:(CGSize)size{
+    UIGraphicsBeginImageContext(size);
+    CGContextRef ctx = UIGraphicsGetCurrentContext();
+    CGContextAddEllipseInRect(ctx, CGRectMake(0, 0, size.width, size.height));
+    CGContextSetFillColorWithColor(ctx, color.CGColor);
+    CGContextFillPath(ctx);
+    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
+    UIGraphicsEndImageContext();
+    return img;
+}
+
+@end