Răsfoiți Sursa

修改文件结构

Pen Li 9 ani în urmă
părinte
comite
6380149fc9
37 a modificat fișierele cu 3684 adăugiri și 106 ștergeri
  1. 246 0
      RedAnt ERP Mobile/HMLG Mobile.xcodeproj/project.pbxproj
  2. 7 0
      RedAnt ERP Mobile/HMLG Mobile.xcodeproj/xcuserdata/macmini1.xcuserdatad/xcschemes/HMLG Mobile.xcscheme
  3. 147 101
      RedAnt ERP Mobile/HMLG Mobile/config.h
  4. 14 0
      RedAnt ERP Mobile/common/CartUtils.h
  5. 756 0
      RedAnt ERP Mobile/common/CartUtils.m
  6. 3 1
      RedAnt ERP Mobile/common/Functions/sidemenu/LoginViewController.m
  7. 25 0
      RedAnt ERP Mobile/common/JKLock/JKDotView.h
  8. 88 0
      RedAnt ERP Mobile/common/JKLock/JKDotView.m
  9. 23 0
      RedAnt ERP Mobile/common/JKLock/JKLockButton.h
  10. 119 0
      RedAnt ERP Mobile/common/JKLock/JKLockButton.m
  11. 30 0
      RedAnt ERP Mobile/common/JKLock/JKLockController.h
  12. 433 0
      RedAnt ERP Mobile/common/JKLock/JKLockController.m
  13. 31 0
      RedAnt ERP Mobile/common/JKLock/JKMessageBoxController.h
  14. 171 0
      RedAnt ERP Mobile/common/JKLock/JKMessageBoxController.m
  15. 38 0
      RedAnt ERP Mobile/common/JKTimer/JKTimerManager.h
  16. 106 0
      RedAnt ERP Mobile/common/JKTimer/JKTimerManager.m
  17. 25 0
      RedAnt ERP Mobile/common/NotificationNameCenter.h
  18. 25 0
      RedAnt ERP Mobile/common/NotificationNameCenter.m
  19. 15 0
      RedAnt ERP Mobile/common/Price Setting/CategoryPriceCell.h
  20. 73 0
      RedAnt ERP Mobile/common/Price Setting/CategoryPriceCell.m
  21. 17 0
      RedAnt ERP Mobile/common/Price Setting/CategoryPriceViewController.h
  22. 143 0
      RedAnt ERP Mobile/common/Price Setting/CategoryPriceViewController.m
  23. 16 0
      RedAnt ERP Mobile/common/Price Setting/PriceSettingViewController.h
  24. 225 0
      RedAnt ERP Mobile/common/Price Setting/PriceSettingViewController.m
  25. 23 0
      RedAnt ERP Mobile/common/Price Setting/SetCategoryPriceController.h
  26. 325 0
      RedAnt ERP Mobile/common/Price Setting/SetCategoryPriceController.m
  27. 48 0
      RedAnt ERP Mobile/common/Singleton.h
  28. 36 0
      RedAnt ERP Mobile/common/Singleton.m
  29. 19 0
      RedAnt ERP Mobile/common/UIColor+HEX/UIColor+JK_HEX.h
  30. 37 0
      RedAnt ERP Mobile/common/UIColor+HEX/UIColor+JK_HEX.m
  31. 5 4
      RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m
  32. 19 0
      RedAnt ERP Mobile/common/sort/SortButton.h
  33. 73 0
      RedAnt ERP Mobile/common/sort/SortButton.m
  34. 23 0
      RedAnt ERP Mobile/common/sort/SortItemCell.h
  35. 122 0
      RedAnt ERP Mobile/common/sort/SortItemCell.m
  36. 21 0
      RedAnt ERP Mobile/common/sort/SortItemViewController.h
  37. 157 0
      RedAnt ERP Mobile/common/sort/SortItemViewController.m

+ 246 - 0
RedAnt ERP Mobile/HMLG Mobile.xcodeproj/project.pbxproj

@@ -7,6 +7,38 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		428980011E24902E005F1BD8 /* JKTimerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980001E24902E005F1BD8 /* JKTimerManager.m */; };
+		428980071E2490E3005F1BD8 /* NotificationNameCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980061E2490E3005F1BD8 /* NotificationNameCenter.m */; };
+		4289800D1E2491A6005F1BD8 /* CartUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 4289800C1E2491A6005F1BD8 /* CartUtils.m */; };
+		4289801F1E24925A005F1BD8 /* SortButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 4289801A1E24925A005F1BD8 /* SortButton.m */; };
+		428980201E24925A005F1BD8 /* SortItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4289801C1E24925A005F1BD8 /* SortItemCell.m */; };
+		428980211E24925A005F1BD8 /* SortItemViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4289801E1E24925A005F1BD8 /* SortItemViewController.m */; };
+		428980381E2492E0005F1BD8 /* CategoryPriceCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980311E2492E0005F1BD8 /* CategoryPriceCell.m */; };
+		428980391E2492E0005F1BD8 /* CategoryPriceViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980331E2492E0005F1BD8 /* CategoryPriceViewController.m */; };
+		4289803A1E2492E0005F1BD8 /* PriceSettingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980351E2492E0005F1BD8 /* PriceSettingViewController.m */; };
+		4289803B1E2492E0005F1BD8 /* SetCategoryPriceController.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980371E2492E0005F1BD8 /* SetCategoryPriceController.m */; };
+		428980521E249340005F1BD8 /* JKDotView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4289804B1E249340005F1BD8 /* JKDotView.m */; };
+		428980531E249340005F1BD8 /* JKLockButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 4289804D1E249340005F1BD8 /* JKLockButton.m */; };
+		428980541E249340005F1BD8 /* JKLockController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4289804F1E249340005F1BD8 /* JKLockController.m */; };
+		428980551E249340005F1BD8 /* JKMessageBoxController.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980511E249340005F1BD8 /* JKMessageBoxController.m */; };
+		428980591E24935E005F1BD8 /* UIColor+JK_HEX.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980581E24935E005F1BD8 /* UIColor+JK_HEX.m */; };
+		4289806A1E24A9DE005F1BD8 /* OfflineUnlockViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980651E24A9DE005F1BD8 /* OfflineUnlockViewController.m */; };
+		4289806B1E24A9DE005F1BD8 /* SelectOrderTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980671E24A9DE005F1BD8 /* SelectOrderTableViewCell.m */; };
+		4289806C1E24A9DE005F1BD8 /* SelectUploadOrderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980691E24A9DE005F1BD8 /* SelectUploadOrderViewController.m */; };
+		4289806F1E24AEA6005F1BD8 /* Singleton.m in Sources */ = {isa = PBXBuildFile; fileRef = 4289806E1E24AEA6005F1BD8 /* Singleton.m */; };
+		4289808A1E24B2C2005F1BD8 /* BasicDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980751E24B2C2005F1BD8 /* BasicDrawable.m */; };
+		4289808B1E24B2C2005F1BD8 /* GridDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980771E24B2C2005F1BD8 /* GridDrawable.m */; };
+		4289808C1E24B2C2005F1BD8 /* GroupDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980791E24B2C2005F1BD8 /* GroupDrawable.m */; };
+		4289808D1E24B2C2005F1BD8 /* ImageDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 4289807B1E24B2C2005F1BD8 /* ImageDrawable.m */; };
+		4289808E1E24B2C2005F1BD8 /* LineDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 4289807D1E24B2C2005F1BD8 /* LineDrawable.m */; };
+		4289808F1E24B2C2005F1BD8 /* pdfCreator.m in Sources */ = {isa = PBXBuildFile; fileRef = 4289807F1E24B2C2005F1BD8 /* pdfCreator.m */; };
+		428980901E24B2C2005F1BD8 /* PDFDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980811E24B2C2005F1BD8 /* PDFDrawable.m */; };
+		428980911E24B2C2005F1BD8 /* PDFPage.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980831E24B2C2005F1BD8 /* PDFPage.m */; };
+		428980921E24B2C2005F1BD8 /* RectDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980851E24B2C2005F1BD8 /* RectDrawable.m */; };
+		428980931E24B2C2005F1BD8 /* TableDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980871E24B2C2005F1BD8 /* TableDrawable.m */; };
+		428980941E24B2C2005F1BD8 /* TextDrawable.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980891E24B2C2005F1BD8 /* TextDrawable.m */; };
+		428980971E24B2E7005F1BD8 /* ImageUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980961E24B2E7005F1BD8 /* ImageUtils.m */; };
+		4289809A1E24B304005F1BD8 /* TextUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 428980991E24B304005F1BD8 /* TextUtils.m */; };
 		715002021D13CDBE00F5927F /* BundleDetailButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 715002011D13CDBE00F5927F /* BundleDetailButton.m */; };
 		715850431CF6F0C400856B20 /* DefaultAppearance.m in Sources */ = {isa = PBXBuildFile; fileRef = 715850421CF6F0C400856B20 /* DefaultAppearance.m */; };
 		716AF8DE1D792157001188E0 /* offline_status_filter_cadedate.json in Resources */ = {isa = PBXBuildFile; fileRef = 716AF8DD1D792157001188E0 /* offline_status_filter_cadedate.json */; };
@@ -189,6 +221,70 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+		42897FFF1E24902E005F1BD8 /* JKTimerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JKTimerManager.h; sourceTree = "<group>"; };
+		428980001E24902E005F1BD8 /* JKTimerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JKTimerManager.m; sourceTree = "<group>"; };
+		428980051E2490E3005F1BD8 /* NotificationNameCenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NotificationNameCenter.h; path = common/NotificationNameCenter.h; sourceTree = SOURCE_ROOT; };
+		428980061E2490E3005F1BD8 /* NotificationNameCenter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NotificationNameCenter.m; path = common/NotificationNameCenter.m; sourceTree = SOURCE_ROOT; };
+		4289800B1E2491A6005F1BD8 /* CartUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CartUtils.h; path = common/CartUtils.h; sourceTree = SOURCE_ROOT; };
+		4289800C1E2491A6005F1BD8 /* CartUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CartUtils.m; path = common/CartUtils.m; sourceTree = SOURCE_ROOT; };
+		428980191E24925A005F1BD8 /* SortButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortButton.h; sourceTree = "<group>"; };
+		4289801A1E24925A005F1BD8 /* SortButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortButton.m; sourceTree = "<group>"; };
+		4289801B1E24925A005F1BD8 /* SortItemCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortItemCell.h; sourceTree = "<group>"; };
+		4289801C1E24925A005F1BD8 /* SortItemCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortItemCell.m; sourceTree = "<group>"; };
+		4289801D1E24925A005F1BD8 /* SortItemViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SortItemViewController.h; sourceTree = "<group>"; };
+		4289801E1E24925A005F1BD8 /* SortItemViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SortItemViewController.m; sourceTree = "<group>"; };
+		428980301E2492E0005F1BD8 /* CategoryPriceCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CategoryPriceCell.h; sourceTree = "<group>"; };
+		428980311E2492E0005F1BD8 /* CategoryPriceCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CategoryPriceCell.m; sourceTree = "<group>"; };
+		428980321E2492E0005F1BD8 /* CategoryPriceViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CategoryPriceViewController.h; sourceTree = "<group>"; };
+		428980331E2492E0005F1BD8 /* CategoryPriceViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CategoryPriceViewController.m; sourceTree = "<group>"; };
+		428980341E2492E0005F1BD8 /* PriceSettingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PriceSettingViewController.h; sourceTree = "<group>"; };
+		428980351E2492E0005F1BD8 /* PriceSettingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PriceSettingViewController.m; sourceTree = "<group>"; };
+		428980361E2492E0005F1BD8 /* SetCategoryPriceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SetCategoryPriceController.h; sourceTree = "<group>"; };
+		428980371E2492E0005F1BD8 /* SetCategoryPriceController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SetCategoryPriceController.m; sourceTree = "<group>"; };
+		4289804A1E249340005F1BD8 /* JKDotView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JKDotView.h; sourceTree = "<group>"; };
+		4289804B1E249340005F1BD8 /* JKDotView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JKDotView.m; sourceTree = "<group>"; };
+		4289804C1E249340005F1BD8 /* JKLockButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JKLockButton.h; sourceTree = "<group>"; };
+		4289804D1E249340005F1BD8 /* JKLockButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JKLockButton.m; sourceTree = "<group>"; };
+		4289804E1E249340005F1BD8 /* JKLockController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JKLockController.h; sourceTree = "<group>"; };
+		4289804F1E249340005F1BD8 /* JKLockController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JKLockController.m; sourceTree = "<group>"; };
+		428980501E249340005F1BD8 /* JKMessageBoxController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JKMessageBoxController.h; sourceTree = "<group>"; };
+		428980511E249340005F1BD8 /* JKMessageBoxController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JKMessageBoxController.m; sourceTree = "<group>"; };
+		428980571E24935E005F1BD8 /* UIColor+JK_HEX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+JK_HEX.h"; sourceTree = "<group>"; };
+		428980581E24935E005F1BD8 /* UIColor+JK_HEX.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+JK_HEX.m"; sourceTree = "<group>"; };
+		428980641E24A9DE005F1BD8 /* OfflineUnlockViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OfflineUnlockViewController.h; path = common/Functions/offline/OfflineUnlockViewController.h; sourceTree = SOURCE_ROOT; };
+		428980651E24A9DE005F1BD8 /* OfflineUnlockViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OfflineUnlockViewController.m; path = common/Functions/offline/OfflineUnlockViewController.m; sourceTree = SOURCE_ROOT; };
+		428980661E24A9DE005F1BD8 /* SelectOrderTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SelectOrderTableViewCell.h; path = common/Functions/offline/SelectOrderTableViewCell.h; sourceTree = SOURCE_ROOT; };
+		428980671E24A9DE005F1BD8 /* SelectOrderTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SelectOrderTableViewCell.m; path = common/Functions/offline/SelectOrderTableViewCell.m; sourceTree = SOURCE_ROOT; };
+		428980681E24A9DE005F1BD8 /* SelectUploadOrderViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SelectUploadOrderViewController.h; path = common/Functions/offline/SelectUploadOrderViewController.h; sourceTree = SOURCE_ROOT; };
+		428980691E24A9DE005F1BD8 /* SelectUploadOrderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SelectUploadOrderViewController.m; path = common/Functions/offline/SelectUploadOrderViewController.m; sourceTree = SOURCE_ROOT; };
+		4289806D1E24AEA6005F1BD8 /* Singleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Singleton.h; path = common/Singleton.h; sourceTree = SOURCE_ROOT; };
+		4289806E1E24AEA6005F1BD8 /* Singleton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Singleton.m; path = common/Singleton.m; sourceTree = SOURCE_ROOT; };
+		428980741E24B2C2005F1BD8 /* BasicDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BasicDrawable.h; sourceTree = "<group>"; };
+		428980751E24B2C2005F1BD8 /* BasicDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BasicDrawable.m; sourceTree = "<group>"; };
+		428980761E24B2C2005F1BD8 /* GridDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GridDrawable.h; sourceTree = "<group>"; };
+		428980771E24B2C2005F1BD8 /* GridDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GridDrawable.m; sourceTree = "<group>"; };
+		428980781E24B2C2005F1BD8 /* GroupDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupDrawable.h; sourceTree = "<group>"; };
+		428980791E24B2C2005F1BD8 /* GroupDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GroupDrawable.m; sourceTree = "<group>"; };
+		4289807A1E24B2C2005F1BD8 /* ImageDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageDrawable.h; sourceTree = "<group>"; };
+		4289807B1E24B2C2005F1BD8 /* ImageDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageDrawable.m; sourceTree = "<group>"; };
+		4289807C1E24B2C2005F1BD8 /* LineDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineDrawable.h; sourceTree = "<group>"; };
+		4289807D1E24B2C2005F1BD8 /* LineDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LineDrawable.m; sourceTree = "<group>"; };
+		4289807E1E24B2C2005F1BD8 /* pdfCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pdfCreator.h; sourceTree = "<group>"; };
+		4289807F1E24B2C2005F1BD8 /* pdfCreator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = pdfCreator.m; sourceTree = "<group>"; };
+		428980801E24B2C2005F1BD8 /* PDFDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PDFDrawable.h; sourceTree = "<group>"; };
+		428980811E24B2C2005F1BD8 /* PDFDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PDFDrawable.m; sourceTree = "<group>"; };
+		428980821E24B2C2005F1BD8 /* PDFPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PDFPage.h; sourceTree = "<group>"; };
+		428980831E24B2C2005F1BD8 /* PDFPage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PDFPage.m; sourceTree = "<group>"; };
+		428980841E24B2C2005F1BD8 /* RectDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RectDrawable.h; sourceTree = "<group>"; };
+		428980851E24B2C2005F1BD8 /* RectDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RectDrawable.m; sourceTree = "<group>"; };
+		428980861E24B2C2005F1BD8 /* TableDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableDrawable.h; sourceTree = "<group>"; };
+		428980871E24B2C2005F1BD8 /* TableDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TableDrawable.m; sourceTree = "<group>"; };
+		428980881E24B2C2005F1BD8 /* TextDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextDrawable.h; sourceTree = "<group>"; };
+		428980891E24B2C2005F1BD8 /* TextDrawable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextDrawable.m; sourceTree = "<group>"; };
+		428980951E24B2E7005F1BD8 /* ImageUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ImageUtils.h; path = common/ImageUtils.h; sourceTree = SOURCE_ROOT; };
+		428980961E24B2E7005F1BD8 /* ImageUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ImageUtils.m; path = common/ImageUtils.m; sourceTree = SOURCE_ROOT; };
+		428980981E24B304005F1BD8 /* TextUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextUtils.h; path = common/TextUtils.h; sourceTree = SOURCE_ROOT; };
+		428980991E24B304005F1BD8 /* TextUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TextUtils.m; path = common/TextUtils.m; sourceTree = SOURCE_ROOT; };
 		715002001D13CDBE00F5927F /* BundleDetailButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BundleDetailButton.h; path = common/Functions/BundleDetailButton.h; sourceTree = SOURCE_ROOT; };
 		715002011D13CDBE00F5927F /* BundleDetailButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BundleDetailButton.m; path = common/Functions/BundleDetailButton.m; sourceTree = SOURCE_ROOT; };
 		715850411CF6F0C400856B20 /* DefaultAppearance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DefaultAppearance.h; path = common/Functions/DefaultAppearance.h; sourceTree = SOURCE_ROOT; };
@@ -548,6 +644,102 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+		42897FFE1E24902E005F1BD8 /* JKTimer */ = {
+			isa = PBXGroup;
+			children = (
+				42897FFF1E24902E005F1BD8 /* JKTimerManager.h */,
+				428980001E24902E005F1BD8 /* JKTimerManager.m */,
+			);
+			name = JKTimer;
+			path = common/JKTimer;
+			sourceTree = SOURCE_ROOT;
+		};
+		428980181E24925A005F1BD8 /* sort */ = {
+			isa = PBXGroup;
+			children = (
+				428980191E24925A005F1BD8 /* SortButton.h */,
+				4289801A1E24925A005F1BD8 /* SortButton.m */,
+				4289801B1E24925A005F1BD8 /* SortItemCell.h */,
+				4289801C1E24925A005F1BD8 /* SortItemCell.m */,
+				4289801D1E24925A005F1BD8 /* SortItemViewController.h */,
+				4289801E1E24925A005F1BD8 /* SortItemViewController.m */,
+			);
+			name = sort;
+			path = common/sort;
+			sourceTree = SOURCE_ROOT;
+		};
+		4289802F1E2492E0005F1BD8 /* Price Setting */ = {
+			isa = PBXGroup;
+			children = (
+				428980301E2492E0005F1BD8 /* CategoryPriceCell.h */,
+				428980311E2492E0005F1BD8 /* CategoryPriceCell.m */,
+				428980321E2492E0005F1BD8 /* CategoryPriceViewController.h */,
+				428980331E2492E0005F1BD8 /* CategoryPriceViewController.m */,
+				428980341E2492E0005F1BD8 /* PriceSettingViewController.h */,
+				428980351E2492E0005F1BD8 /* PriceSettingViewController.m */,
+				428980361E2492E0005F1BD8 /* SetCategoryPriceController.h */,
+				428980371E2492E0005F1BD8 /* SetCategoryPriceController.m */,
+			);
+			name = "Price Setting";
+			path = "common/Price Setting";
+			sourceTree = SOURCE_ROOT;
+		};
+		428980491E249340005F1BD8 /* JKLock */ = {
+			isa = PBXGroup;
+			children = (
+				4289804A1E249340005F1BD8 /* JKDotView.h */,
+				4289804B1E249340005F1BD8 /* JKDotView.m */,
+				4289804C1E249340005F1BD8 /* JKLockButton.h */,
+				4289804D1E249340005F1BD8 /* JKLockButton.m */,
+				4289804E1E249340005F1BD8 /* JKLockController.h */,
+				4289804F1E249340005F1BD8 /* JKLockController.m */,
+				428980501E249340005F1BD8 /* JKMessageBoxController.h */,
+				428980511E249340005F1BD8 /* JKMessageBoxController.m */,
+			);
+			name = JKLock;
+			path = common/JKLock;
+			sourceTree = SOURCE_ROOT;
+		};
+		428980561E24935E005F1BD8 /* UIColor+HEX */ = {
+			isa = PBXGroup;
+			children = (
+				428980571E24935E005F1BD8 /* UIColor+JK_HEX.h */,
+				428980581E24935E005F1BD8 /* UIColor+JK_HEX.m */,
+			);
+			name = "UIColor+HEX";
+			path = "common/UIColor+HEX";
+			sourceTree = SOURCE_ROOT;
+		};
+		428980731E24B2C2005F1BD8 /* pdfCreator */ = {
+			isa = PBXGroup;
+			children = (
+				428980741E24B2C2005F1BD8 /* BasicDrawable.h */,
+				428980751E24B2C2005F1BD8 /* BasicDrawable.m */,
+				428980761E24B2C2005F1BD8 /* GridDrawable.h */,
+				428980771E24B2C2005F1BD8 /* GridDrawable.m */,
+				428980781E24B2C2005F1BD8 /* GroupDrawable.h */,
+				428980791E24B2C2005F1BD8 /* GroupDrawable.m */,
+				4289807A1E24B2C2005F1BD8 /* ImageDrawable.h */,
+				4289807B1E24B2C2005F1BD8 /* ImageDrawable.m */,
+				4289807C1E24B2C2005F1BD8 /* LineDrawable.h */,
+				4289807D1E24B2C2005F1BD8 /* LineDrawable.m */,
+				4289807E1E24B2C2005F1BD8 /* pdfCreator.h */,
+				4289807F1E24B2C2005F1BD8 /* pdfCreator.m */,
+				428980801E24B2C2005F1BD8 /* PDFDrawable.h */,
+				428980811E24B2C2005F1BD8 /* PDFDrawable.m */,
+				428980821E24B2C2005F1BD8 /* PDFPage.h */,
+				428980831E24B2C2005F1BD8 /* PDFPage.m */,
+				428980841E24B2C2005F1BD8 /* RectDrawable.h */,
+				428980851E24B2C2005F1BD8 /* RectDrawable.m */,
+				428980861E24B2C2005F1BD8 /* TableDrawable.h */,
+				428980871E24B2C2005F1BD8 /* TableDrawable.m */,
+				428980881E24B2C2005F1BD8 /* TextDrawable.h */,
+				428980891E24B2C2005F1BD8 /* TextDrawable.m */,
+			);
+			name = pdfCreator;
+			path = common/pdfCreator;
+			sourceTree = SOURCE_ROOT;
+		};
 		7183E83B1CF2913E00524787 = {
 			isa = PBXGroup;
 			children = (
@@ -592,8 +784,13 @@
 				7183E9C71CF29FCB00524787 /* Signature */,
 				7183E9DE1CF29FCB00524787 /* sideMenu */,
 				7183E9E11CF29FCB00524787 /* watchlist */,
+				4289802F1E2492E0005F1BD8 /* Price Setting */,
 				7183EA391CF2A04000524787 /* AppDelegate.h */,
 				7183EA3A1CF2A04000524787 /* AppDelegate.m */,
+				4289806D1E24AEA6005F1BD8 /* Singleton.h */,
+				4289806E1E24AEA6005F1BD8 /* Singleton.m */,
+				428980051E2490E3005F1BD8 /* NotificationNameCenter.h */,
+				428980061E2490E3005F1BD8 /* NotificationNameCenter.m */,
 				7183EA3B1CF2A04000524787 /* MainViewController.h */,
 				7183EA3C1CF2A04000524787 /* MainViewController.m */,
 				7183E8531CF2913E00524787 /* Assets.xcassets */,
@@ -677,6 +874,10 @@
 		7183E8931CF29F3900524787 /* utils */ = {
 			isa = PBXGroup;
 			children = (
+				428980731E24B2C2005F1BD8 /* pdfCreator */,
+				428980561E24935E005F1BD8 /* UIColor+HEX */,
+				428980491E249340005F1BD8 /* JKLock */,
+				42897FFE1E24902E005F1BD8 /* JKTimer */,
 				7183E86C1CF29F3900524787 /* zip */,
 				7183E87D1CF29F3900524787 /* QRCODE */,
 				7183E8871CF29F3900524787 /* AES */,
@@ -685,6 +886,12 @@
 				7183E88A1CF29F3900524787 /* const.h */,
 				7183E88B1CF29F3900524787 /* RAUtils.h */,
 				7183E88C1CF29F3900524787 /* RAUtils.m */,
+				428980951E24B2E7005F1BD8 /* ImageUtils.h */,
+				428980961E24B2E7005F1BD8 /* ImageUtils.m */,
+				4289800B1E2491A6005F1BD8 /* CartUtils.h */,
+				4289800C1E2491A6005F1BD8 /* CartUtils.m */,
+				428980981E24B304005F1BD8 /* TextUtils.h */,
+				428980991E24B304005F1BD8 /* TextUtils.m */,
 				7183E88D1CF29F3900524787 /* iSalesDB.h */,
 				7183E88E1CF29F3900524787 /* iSalesDB.m */,
 				7183E88F1CF29F3900524787 /* iSalesNetwork.h */,
@@ -786,6 +993,7 @@
 		7183E8F41CF29F4500524787 /* CommonUI */ = {
 			isa = PBXGroup;
 			children = (
+				428980181E24925A005F1BD8 /* sort */,
 				7183E8B11CF29F4500524787 /* photoStack */,
 				7183E8CE1CF29F4500524787 /* customUI */,
 				7183E8EF1CF29F4500524787 /* CommonEditor */,
@@ -1191,6 +1399,12 @@
 		71BF07021D2F3CE000981938 /* offline */ = {
 			isa = PBXGroup;
 			children = (
+				428980641E24A9DE005F1BD8 /* OfflineUnlockViewController.h */,
+				428980651E24A9DE005F1BD8 /* OfflineUnlockViewController.m */,
+				428980661E24A9DE005F1BD8 /* SelectOrderTableViewCell.h */,
+				428980671E24A9DE005F1BD8 /* SelectOrderTableViewCell.m */,
+				428980681E24A9DE005F1BD8 /* SelectUploadOrderViewController.h */,
+				428980691E24A9DE005F1BD8 /* SelectUploadOrderViewController.m */,
 				71BF07031D2F3CF300981938 /* OfflineSettingViewController.h */,
 				71BF07041D2F3CF300981938 /* OfflineSettingViewController.m */,
 				71AD1E081D3E039E008B7685 /* SyncControlPanelViewController.h */,
@@ -1292,22 +1506,28 @@
 				7183E9EF1CF29FCB00524787 /* CategoryCellNPD.m in Sources */,
 				7183E8961CF29F3900524787 /* unzip.c in Sources */,
 				7183EA261CF29FCB00524787 /* FilterCellCadedate.m in Sources */,
+				428980011E24902E005F1BD8 /* JKTimerManager.m in Sources */,
 				719562391CF57BFC00C74A49 /* CategoryHeaderView.m in Sources */,
+				428980201E24925A005F1BD8 /* SortItemCell.m in Sources */,
 				7183E91E1CF29F4500524787 /* SRMonthPicker.m in Sources */,
 				7183EA2B1CF29FCB00524787 /* SignatureView.m in Sources */,
 				7183EA3E1CF2A04000524787 /* MainViewController.m in Sources */,
+				4289808C1E24B2C2005F1BD8 /* GroupDrawable.m in Sources */,
 				7183E91B1CF29F4500524787 /* EnumSelectorCell.m in Sources */,
 				7183EA061CF29FCB00524787 /* CustomerEditViewController.m in Sources */,
 				7183E9021CF29F4500524787 /* ImageScrollerView.m in Sources */,
 				7183EA311CF29FCB00524787 /* RetrievePassViewController.m in Sources */,
+				4289808E1E24B2C2005F1BD8 /* LineDrawable.m in Sources */,
 				7183E90D1CF29F4500524787 /* TouchImageView.m in Sources */,
 				7183EA081CF29FCB00524787 /* DetailHeaderCell.m in Sources */,
 				7183E9FB1CF29FCB00524787 /* RATreeView+TableViewDataSource.m in Sources */,
 				715002021D13CDBE00F5927F /* BundleDetailButton.m in Sources */,
 				7183E9171CF29F4500524787 /* CommonEditorCellSwitch.m in Sources */,
 				7183E9EE1CF29FCB00524787 /* CartGeneralNotesViewController.m in Sources */,
+				4289806A1E24A9DE005F1BD8 /* OfflineUnlockViewController.m in Sources */,
 				7183E89D1CF29F3900524787 /* qrinput.c in Sources */,
 				7183E9061CF29F4500524787 /* NIDropDown.m in Sources */,
+				428980911E24B2C2005F1BD8 /* PDFPage.m in Sources */,
 				7183EA0A1CF29FCB00524787 /* DetailKVCell.m in Sources */,
 				7183EA331CF29FCB00524787 /* SettingViewController.m in Sources */,
 				7183E9E51CF29FCB00524787 /* CycleScrollView.m in Sources */,
@@ -1317,9 +1537,12 @@
 				7183E9141CF29F4500524787 /* CommonEditorCellMAction.m in Sources */,
 				7183EA2D1CF29FCB00524787 /* AboutViewController.m in Sources */,
 				7183EA091CF29FCB00524787 /* DetailImageCell.m in Sources */,
+				4289806B1E24A9DE005F1BD8 /* SelectOrderTableViewCell.m in Sources */,
 				7183EA011CF29FCB00524787 /* ContactListTableViewCell.m in Sources */,
 				7183EA0B1CF29FCB00524787 /* DetailTopicCell.m in Sources */,
+				428980921E24B2C2005F1BD8 /* RectDrawable.m in Sources */,
 				7183E9191CF29F4500524787 /* CommonEditorViewController.m in Sources */,
+				428980211E24925A005F1BD8 /* SortItemViewController.m in Sources */,
 				7183E9F61CF29FCB00524787 /* RATreeNodeInfo.m in Sources */,
 				7183E9ED1CF29FCB00524787 /* ItemNotesViewController.m in Sources */,
 				7183EA251CF29FCB00524787 /* SCShapeView.m in Sources */,
@@ -1327,6 +1550,7 @@
 				7183E8FF1CF29F4500524787 /* PhotoStackView.m in Sources */,
 				7183E9031CF29F4500524787 /* ImageScrollerViewController.m in Sources */,
 				7183E9F21CF29FCB00524787 /* CategoryViewController.m in Sources */,
+				4289809A1E24B304005F1BD8 /* TextUtils.m in Sources */,
 				7183EA6F1CF2B05C00524787 /* NSString+Base64.m in Sources */,
 				7183E91F1CF29F4500524787 /* ActiveViewController.m in Sources */,
 				7183EA071CF29FCB00524787 /* CustomerInfoViewController.m in Sources */,
@@ -1339,6 +1563,7 @@
 				7183E9071CF29F4500524787 /* PulldownMenu.m in Sources */,
 				7183E9E31CF29FCB00524787 /* WebViewController.m in Sources */,
 				7183E9FC1CF29FCB00524787 /* RATreeView+TableViewDelegate.m in Sources */,
+				428980531E249340005F1BD8 /* JKLockButton.m in Sources */,
 				7183E9101CF29F4500524787 /* CommonEditorCellEdit.m in Sources */,
 				7183EA101CF29FCB00524787 /* HomeTableViewCellSlide.m in Sources */,
 				7183E91C1CF29F4500524787 /* EnumSelectViewController.m in Sources */,
@@ -1347,24 +1572,33 @@
 				7183EA351CF29FCB00524787 /* SimplifiedBuyingProgramViewController.m in Sources */,
 				7183EA471CF2A06E00524787 /* iSalesNavigationController.m in Sources */,
 				7183E9EA1CF29FCB00524787 /* CartViewController.m in Sources */,
+				4289808B1E24B2C2005F1BD8 /* GridDrawable.m in Sources */,
 				7183E8A01CF29F3900524787 /* split.c in Sources */,
 				7183EA2F1CF29FCB00524787 /* LoginViewController.m in Sources */,
 				7183E8981CF29F3900524787 /* ZipArchive.mm in Sources */,
+				4289808A1E24B2C2005F1BD8 /* BasicDrawable.m in Sources */,
+				428980381E2492E0005F1BD8 /* CategoryPriceCell.m in Sources */,
 				7183EA341CF29FCB00524787 /* FunctionTestViewController.m in Sources */,
 				7183E9211CF29F4500524787 /* DeviceInfo.m in Sources */,
 				7183E90F1CF29F4500524787 /* CommonEditorCellAction.m in Sources */,
+				428980591E24935E005F1BD8 /* UIColor+JK_HEX.m in Sources */,
 				7183EA211CF29FCB00524787 /* TearSheetParamViewController.m in Sources */,
 				7183EA0F1CF29FCB00524787 /* HomeTableViewCellButtonBanner.m in Sources */,
 				7183EA2C1CF29FCB00524787 /* SignatureViewController.m in Sources */,
 				7183E9EB1CF29FCB00524787 /* EditModelPriceViewController.m in Sources */,
 				7183EA221CF29FCB00524787 /* PortfolioEditQTYViewController.m in Sources */,
 				7183EA2E1CF29FCB00524787 /* CacheViewController.m in Sources */,
+				4289806F1E24AEA6005F1BD8 /* Singleton.m in Sources */,
 				71D30A2A1CFC0EDD006F9477 /* DefaultImageButton.m in Sources */,
 				7183E8941CF29F3900524787 /* ioapi.c in Sources */,
 				7183E8A61CF29F3900524787 /* Reachability.m in Sources */,
 				7183EA6D1CF2B05C00524787 /* NSData+Base64.m in Sources */,
 				7183E9F91CF29FCB00524787 /* RATreeView+Enums.m in Sources */,
+				428980391E2492E0005F1BD8 /* CategoryPriceViewController.m in Sources */,
+				4289808D1E24B2C2005F1BD8 /* ImageDrawable.m in Sources */,
 				7183EA151CF29FCB00524787 /* OrderDetailInfoCell.m in Sources */,
+				428980551E249340005F1BD8 /* JKMessageBoxController.m in Sources */,
+				4289808F1E24B2C2005F1BD8 /* pdfCreator.m in Sources */,
 				7183E89A1CF29F3900524787 /* mask.c in Sources */,
 				7183E8A91CF29F3900524787 /* iSalesNetwork.m in Sources */,
 				7183E9081CF29F4500524787 /* RadioButton.m in Sources */,
@@ -1374,10 +1608,13 @@
 				7183E91D1CF29F4500524787 /* MonthPickerViewController.m in Sources */,
 				7183EA2A1CF29FCB00524787 /* SearchViewController.m in Sources */,
 				7183EA3D1CF2A04000524787 /* AppDelegate.m in Sources */,
+				428980941E24B2C2005F1BD8 /* TextDrawable.m in Sources */,
+				4289803B1E2492E0005F1BD8 /* SetCategoryPriceController.m in Sources */,
 				7183E9111CF29F4500524787 /* CommonEditorCellEnum.m in Sources */,
 				7183E8A11CF29F3900524787 /* AESCrypt.m in Sources */,
 				7183EA141CF29FCB00524787 /* OrderDetailHtmlCell.m in Sources */,
 				7183EA321CF29FCB00524787 /* ScannerSettingViewController.m in Sources */,
+				428980901E24B2C2005F1BD8 /* PDFDrawable.m in Sources */,
 				7183E9FD1CF29FCB00524787 /* RATreeView+UIScrollView.m in Sources */,
 				7183EA021CF29FCB00524787 /* ContactListViewController.m in Sources */,
 				7183EA231CF29FCB00524787 /* ScannerControllerView.m in Sources */,
@@ -1387,21 +1624,28 @@
 				7183E9E81CF29FCB00524787 /* BundleModelCell.m in Sources */,
 				71BF07011D2F3CCC00981938 /* OLDataProvider.m in Sources */,
 				7183E8971CF29F3900524787 /* zip.c in Sources */,
+				428980971E24B2E7005F1BD8 /* ImageUtils.m in Sources */,
 				7183EA1A1CF29FCB00524787 /* OrderListViewController.m in Sources */,
 				7183E91A1CF29F4500524787 /* DatePickerViewController.m in Sources */,
 				7183E8491CF2913E00524787 /* main.m in Sources */,
 				7183E9E91CF29FCB00524787 /* BundleModelViewController.m in Sources */,
 				7183E8991CF29F3900524787 /* bitstream.c in Sources */,
+				428980541E249340005F1BD8 /* JKLockController.m in Sources */,
 				7183E9F51CF29FCB00524787 /* RATreeNodeCollectionController.m in Sources */,
 				7183EA281CF29FCB00524787 /* ItemSearchFilterViewController.m in Sources */,
 				7183E9201CF29F4500524787 /* CommonGridViewController.m in Sources */,
 				7183EA1D1CF29FCB00524787 /* OrderDetailSignatureCell.m in Sources */,
 				7183E9091CF29F4500524787 /* RTLabel.m in Sources */,
 				7183E9F41CF29FCB00524787 /* RATreeNode.m in Sources */,
+				4289803A1E2492E0005F1BD8 /* PriceSettingViewController.m in Sources */,
+				4289800D1E2491A6005F1BD8 /* CartUtils.m in Sources */,
 				7183E89E1CF29F3900524787 /* qrspec.c in Sources */,
 				7183E9151CF29F4500524787 /* CommonEditorCellModel.m in Sources */,
 				7183E90E1CF29F4500524787 /* UILabel+FontAppearance.m in Sources */,
 				7183E9121CF29F4500524787 /* CommonEditorCellImg.m in Sources */,
+				428980071E2490E3005F1BD8 /* NotificationNameCenter.m in Sources */,
+				4289806C1E24A9DE005F1BD8 /* SelectUploadOrderViewController.m in Sources */,
+				428980521E249340005F1BD8 /* JKDotView.m in Sources */,
 				7183E89B1CF29F3900524787 /* QRCodeGenerator.m in Sources */,
 				7183EA191CF29FCB00524787 /* OrderListTableViewCell.m in Sources */,
 				7183E9FA1CF29FCB00524787 /* RATreeView+Private.m in Sources */,
@@ -1431,7 +1675,9 @@
 				7183EA131CF29FCB00524787 /* CreateOrderViewController.m in Sources */,
 				7183E9E21CF29FCB00524787 /* PDFViewController.m in Sources */,
 				7183E9FF1CF29FCB00524787 /* CreditCardEditorViewController.m in Sources */,
+				4289801F1E24925A005F1BD8 /* SortButton.m in Sources */,
 				7183E9F81CF29FCB00524787 /* RATreeView.m in Sources */,
+				428980931E24B2C2005F1BD8 /* TableDrawable.m in Sources */,
 				7183EA271CF29FCB00524787 /* FilterCellValue.m in Sources */,
 				7183EA1E1CF29FCB00524787 /* PDFListTableViewCell.m in Sources */,
 				7183EA121CF29FCB00524787 /* HomeViewController.m in Sources */,

+ 7 - 0
RedAnt ERP Mobile/HMLG Mobile.xcodeproj/xcuserdata/macmini1.xcuserdatad/xcschemes/HMLG Mobile.xcscheme

@@ -61,6 +61,13 @@
             ReferencedContainer = "container:HMLG Mobile.xcodeproj">
          </BuildableReference>
       </BuildableProductRunnable>
+      <EnvironmentVariables>
+         <EnvironmentVariable
+            key = "OS_ACTIVITY_MODE"
+            value = "disable"
+            isEnabled = "YES">
+         </EnvironmentVariable>
+      </EnvironmentVariables>
       <AdditionalOptions>
       </AdditionalOptions>
    </LaunchAction>

+ 147 - 101
RedAnt ERP Mobile/HMLG Mobile/config.h

@@ -16,6 +16,13 @@
 
 #define CONTACT_LIST 1
 
+#define test_server
+#import "Singleton.h"
+#define notifyMe_switch 1
+#define exception_switch 1
+#define PDF_DEBUG 1
+#define flat_price @"MSRP"
+#define given_price @"store price"
 
 #define LOCAL_URL_CUSTOMER_INFO_EDITOR @"customer_info_template"
 #define LOCAL_URL_CUSTOMER_INFO_EDIT @"customer_info_template_edit"
@@ -23,110 +30,148 @@
 
 
 ////-------------------HMLG chen server-----------------------
-//#define  URL_CUSTOMER_ADV_SEARCH @"http://192.168.0.111/pj/isales/getContactAdvance.htm"
-//
-//#define  URL_UPDATE_AUTH  @"http://192.168.0.111/pj/isales/login.htm"
-//#define  URL_LOGOUT  @"http://192.168.0.111/pj/isales/loginOut.htm"
-//#define  URL_RETRIEVE_PASS  @"http://192.168.0.111/pj/isales/forgotPassword.htm"
-//
-//#define  URL_REQUEST_CATMENU  @"http://192.168.0.111/pj/isales/menu.htm"
-//#define  URL_LOAD_HOME  @"http://192.168.0.111/pj/isales/homePage.htm"
-//#define  URL_CATEGORY @"http://192.168.0.111/pj/isales/distinctCategory.htm"
-//#define  URL_SEARCH  @"http://192.168.0.111/pj/isales/search.htm"
-//#define  URL_ITEM_SEARCH  @"http://192.168.0.111/pj/isales/itemSearch.htm"
-//#define  URL_CATEGORY_LOADMORE  @"http://192.168.0.111/pj/isales/categoryMore.htm"
-//
-//
-//
-//#define  URL_ORDER_LIST  @"http://192.168.0.111/pj/isales/orderList.htm"
-//#define  URL_ORDER_DETAIL  @"http://192.168.0.111/pj/isales/orderDetail.htm"
-//#define URL_COMMIT_ORDER @"http://192.168.0.111/pj/isales/createOrder.htm"
-//#define URL_COPY_ORDER @"http://192.168.0.111/pj/isales/copyOrder.htm"
-//#define URL_SIGN_ORDER @"http://192.168.0.111/pj/isales/updateOrderSign.htm"
-//#define URL_SAVE_ORDER @"http://192.168.0.111/pj/isales/saveOrder.htm"
-//#define URL_UPDATE_ORDERCUSTOMER @"http://192.168.0.111/pj/isales/updateOrderCustomerInfo.htm"
-//#define  URL_NEW_ORDER  @"http://192.168.0.111/pj/isales/createNewOrder.htm"
-//#define  URL_OPEN_ORDER  @"http://192.168.0.111/pj/isales/openOrder.htm"
-//#define  URL_RELEASE_ORDER  @"http://192.168.0.111/pj/isales/closeOrder.htm"
-//#define  URL_DELETE_ORDER  @"http://192.168.0.111/pj/isales/deleteOrder.htm"
-//#define  URL_CANCEL_ORDER  @"http://192.168.0.111/pj/isales/cancelOrder.htm"
-//
-//
-//#define  URL_CART_SET_PRICE  @"http://192.168.0.111/pj/isales/setPrice.htm"
-//#define  URL_CART_ITEM_NOTES  @"http://192.168.0.111/pj/isales/setItemNotes.htm"
-//#define  URL_CART_GENERAL_NOTES  @"http://192.168.0.111/pj/isales/updateGeneralNote.htm"
-//
-//#define  URL_CART_INCRESEMENT  @"http://192.168.0.111/pj/isales/increment.htm"
-//#define  URL_CART  @"http://192.168.0.111/pj/isales/cartDtail.htm"
-//#define  URL_CARTDELIVERY  @"http://192.168.0.111/pj/isales/cartDelivery.htm"
-//#define  URL_ADD_TO_CART  @"http://192.168.0.111/pj/isales/addToCart.htm"
-//#define  URL_CART_REMOVE  @"http://192.168.0.111/pj/isales/deleteToCart.htm"
-//#define  URL_CART_CHECK  @"http://192.168.0.111/pj/isales/checkCartItem.htm"
-//#define  URL_CART2WISH  @"http://192.168.0.111/pj/isales/cartRemoveToWishlist.htm"
-//#define  URL_WISH2CART  @"http://192.168.0.111/pj/isales/wishlistRemoveToCart.htm"
-//
-//
-//
-//
-//#define  URL_ITEM_DETAIL  @"http://192.168.0.111/pj/isales/modelDetail.htm"
-//
-//#define  URL_ADD_TO_WATCHLIST  @"http://192.168.0.111/pj/isales/addToWishList.htm"
-//#define  URL_WATCHLIST  @"http://192.168.0.111/pj/isales/wishList.htm"
-//#define  URL_WATCHLIST_REMOVE  @"http://192.168.0.111/pj/isales/deleteToWishList.htm"
-//
-//
-//
-//#define  URL_ADD_TO_PORTFOLIO @"http://192.168.0.111/pj/isales/addToPortfolio.htm"
-//#define  URL_PORTFOLIO_REMOVE  @"http://192.168.0.111/pj/isales/deleteToPortfolio.htm"
-//#define  URL_PORTFOLIOLIST_REMOVE  @"http://192.168.0.111/pj/isales/deleteTearSheetPdf.htm"
-//#define  URL_PORTFOLIO  @"http://192.168.0.111/pj/isales/portfolios.htm"
-//#define  URL_PORTFOLIO_SET_PRICE  @"http://192.168.0.111/pj/isales/setTearSheetPrice.htm"
-//#define  URL_DM_PARAMS @"http://192.168.0.111/pj/isales/selectTearSheetParam.htm"
-//#define  URL_REQUEST_DM @"http://192.168.0.111/pj/isales/getTearSheetPdf.htm"
-//#define  URL_SAVE_DM_DIRECT @"http://192.168.0.111/pj/isales/getTearSheetPdf.htm"
-//#define  URL_SAVE_DM @"http://192.168.0.111/pj/isales/saveTearSheetPdf.htm"
-//#define  URL_DM_LIST @"http://192.168.0.111/pj/isales/tearSheetPdfList.htm"
-////#define  URL_DM_SET_QTY @"http://192.168.0.111/pj/isales/setTearSheetAvailableQty.htm"
-//#define  URL_REQUEST_MODEL_QTY @"http://192.168.0.111/pj/isales/getTearSheetAvailableQty.htm"
-//
-//#define  URL_CONTACT_LIST  @"http://192.168.0.111/pj/isales/getAllContact.htm"
-//#define  URL_SHIPTO_LIST  @"http://192.168.0.111/pj/isales/getShipToContact.htm"
-//
-//#define  URL_ADDRESS_EDOTOR  @"http://192.168.0.111/pj/isales/getAddAddress.htm"
-//#define  URL_ADDRESS_SAVE  @"http://192.168.0.111/pj/isales/saveAddress.htm"
-//
-//
-//#define  URL_CREDITCARD_EDOTOR  @"http://192.168.0.111/pj/isales/creditCard.htm"
-//#define  URL_CREDITCARD_SAVE  @"http://192.168.0.111/pj/isales/saveAddress.htm"
-//
-//
-//
-//#define  URL_CUSTOMER_INFO  @"http://192.168.0.111/pj/isales/getCustomerInfoByContact.htm"
-//#define  URL_CUSTOMER_PENDINGORDER  @"http://192.168.0.111/pj/isales/hasPendingOrderByContact.htm"
-//#define  URL_NEW_CUSTOMER  @"http://192.168.0.111/pj/isales/getAddCustomer.htm"
-//#define  URL_EDIT_CUSTOMER  @"http://192.168.0.111/pj/isales/getUpdateCustomerInfoByContact.htm"
-//#define  URL_CUSTOMER_SAVE  @"http://192.168.0.111/pj/isales/saveCustomer.htm"
-//#define  URL_CUSTOMER_UPDATE  @"http://192.168.0.111/pj/isales/updateCustomer.htm"
-//#define  URL_UPDATE_CUSTOMER_BCARD  @"http://192.168.0.111/pj/isales/updateCustomerBusiCard.htm"
-//
-//
-//
-//
-//
-//
-//#define  URL_ERR_LOG  @"http://192.168.0.111/pj/isales/er_log.htm"
-//
-//#define  URL_UPLOAD_IMG  @"http://192.168.0.111/pj/isales/uploadImg.htm"
-//
-//#define  URL_NPD_POLICY  @"http://192.168.0.111/pj/isales/generalPolicy.htm"
-//
-//
-//#define  URL_CHECK_OFFLINE  @"http://192.168.1.3/check.json"
-//
-//#define  URL_DOWNLOAD_OFFLINE  @"http://192.168.1.3/update.json"
+#ifdef test_server
+
+//------------------- chen server-----------------------
+#define  URL_UPDATE_AUTH  @"http://192.168.0.113:8080/site/isales/login.htm"
+#define  URL_LOGOUT  @"http://192.168.0.113:8080/site/isales/loginOut.htm"
+#define  URL_RETRIEVE_PASS  @"http://192.168.0.113:8080/site/isales/forgotPassword.htm"
+
+#define  URL_REQUEST_CATMENU  @"http://192.168.0.113:8080/site/isales/menu.htm"
+#define  URL_LOAD_HOME  @"http://192.168.0.113:8080/site/isales/homePage.htm"
+#define  URL_CATEGORY @"http://192.168.0.113:8080/site/isales/distinctCategory.htm"
+#define  URL_SEARCH  @"http://192.168.0.113:8080/site/isales/search.htm"
+#define  URL_ITEM_SEARCH  @"http://192.168.0.113:8080/site/isales/itemSearch.htm"
+#define  URL_CATEGORY_LOADMORE  @"http://192.168.0.113:8080/site/isales/categoryMore.htm"
+#define  URL_CUSTOMER_ADV_SEARCH @"http://192.168.0.113:8080/site/isales/getContactAdvance.htm"
+
+
+#define  URL_ORDER_LIST  @"http://192.168.0.113:8080/site/isales/orderList.htm"
+#define  URL_ORDER_DETAIL  @"http://192.168.0.113:8080/site/isales/orderDetail.htm"
+#define URL_COMMIT_ORDER @"http://192.168.0.113:8080/site/isales/createOrder.htm"
+#define URL_COPY_ORDER @"http://192.168.0.113:8080/site/isales/copyOrder.htm"
+#define URL_SIGN_ORDER @"http://192.168.0.113:8080/site/isales/updateOrderSign.htm"
+#define URL_SAVE_ORDER @"http://192.168.0.113:8080/site/isales/saveOrder.htm"
+#define URL_UPDATE_ORDERCUSTOMER @"http://192.168.0.113:8080/site/isales/updateOrderCustomerInfo.htm"
+#define  URL_NEW_ORDER  @"http://192.168.0.113:8080/site/isales/createNewOrder.htm"
+#define  URL_OPEN_ORDER  @"http://192.168.0.113:8080/site/isales/openOrder.htm"
+#define  URL_RELEASE_ORDER  @"http://192.168.0.113:8080/site/isales/closeOrder.htm"
+#define  URL_DELETE_ORDER  @"http://192.168.0.113:8080/site/isales/deleteOrder.htm"
+#define  URL_CANCEL_ORDER  @"http://192.168.0.113:8080/site/isales/cancelOrder.htm"
+
+
+#define  URL_CART_SET_PRICE  @"http://192.168.0.113:8080/site/isales/setPrice.htm"
+#define  URL_CART_ITEM_NOTES  @"http://192.168.0.113:8080/site/isales/setItemNotes.htm"
+#define  URL_CART_GENERAL_NOTES  @"http://192.168.0.113:8080/site/isales/updateGeneralNote.htm"
+
+#define  URL_CART_INCRESEMENT  @"http://192.168.0.113:8080/site/isales/increment.htm"
+#define  URL_CART  @"http://192.168.0.113:8080/site/isales/cartDtail.htm"
+#define  URL_CARTDELIVERY  @"http://192.168.0.113:8080/site/isales/cartDelivery.htm"
+#define  URL_ADD_TO_CART  @"http://192.168.0.113:8080/site/isales/addToCart.htm"
+#define  URL_CART_REMOVE  @"http://192.168.0.113:8080/site/isales/deleteToCart.htm"
+#define  URL_CART_CHECK  @"http://192.168.0.113:8080/site/isales/checkCartItem.htm"
+#define  URL_CART2WISH  @"http://192.168.0.113:8080/site/isales/cartRemoveToWishlist.htm"
+#define  URL_WISH2CART  @"http://192.168.0.113:8080/site/isales/wishlistRemoveToCart.htm"
 
 
 
+
+#define  URL_CATEGORYADDALL  @"http://192.168.0.113:8080/site/isales/categoryAddAllTo.htm"
+#define  URL_SEARCHADDALL  @"http://192.168.0.113:8080/site/isales/searchAddAllTo.htm"
+#define  URL_ITEMSEARCHADDALL @"http://192.168.0.113:8080/site/isales/itemSearchAddAllTo.htm"
+
+
+#define  URL_ITEM_DETAIL  @"http://192.168.0.113:8080/site/isales/modelDetail.htm"
+
+#define  URL_ADD_TO_WATCHLIST  @"http://192.168.0.113:8080/site/isales/addToWishList.htm"
+#define  URL_WATCHLIST  @"http://192.168.0.113:8080/site/isales/wishList.htm"
+#define  URL_WATCHLIST_REMOVE  @"http://192.168.0.113:8080/site/isales/deleteToWishList.htm"
+
+
+
+#define  URL_ADD_TO_PORTFOLIO @"http://192.168.0.113:8080/site/isales/addToPortfolio.htm"
+#define  URL_PORTFOLIO_REMOVE  @"http://192.168.0.113:8080/site/isales/deleteToPortfolio.htm"
+#define  URL_PORTFOLIOLIST_REMOVE  @"http://192.168.0.113:8080/site/isales/deleteTearSheetPdf.htm"
+#define  URL_PORTFOLIO  @"http://192.168.0.113:8080/site/isales/portfolios.htm"
+#define  URL_PORTFOLIO_SET_PRICE  @"http://192.168.0.113:8080/site/isales/setTearSheetPrice.htm"
+#define  URL_DM_PARAMS @"http://192.168.0.113:8080/site/isales/selectTearSheetParam.htm"
+#define  URL_REQUEST_DM @"http://192.168.0.113:8080/site/isales/getTearSheetPdf.htm"
+#define  URL_SAVE_DM_DIRECT @"http://192.168.0.113:8080/site/isales/getTearSheetPdf.htm"
+#define  URL_SAVE_DM @"http://192.168.0.113:8080/site/isales/saveTearSheetPdf.htm"
+#define  URL_DM_LIST @"http://192.168.0.113:8080/site/isales/tearSheetPdfList.htm"
+//#define  URL_DM_SET_QTY @"http://192.168.0.113:8080/site/isales/setTearSheetAvailableQty.htm"
+#define  URL_REQUEST_MODEL_QTY @"http://192.168.0.113:8080/site/isales/getTearSheetAvailableQty.htm"
+
+#define  URL_CONTACT_LIST  @"http://192.168.0.113:8080/site/isales/getAllContact.htm"
+#define  URL_SHIPTO_LIST  @"http://192.168.0.113:8080/site/isales/getShipToContact.htm"
+
+#define  URL_ADDRESS_EDOTOR  @"http://192.168.0.113:8080/site/isales/getAddAddress.htm"
+#define  URL_ADDRESS_SAVE  @"http://192.168.0.113:8080/site/isales/saveAddress.htm"
+
+
+#define  URL_CREDITCARD_EDOTOR  @"http://192.168.0.113:8080/site/isales/creditCard.htm"
+#define  URL_CREDITCARD_SAVE  @"http://192.168.0.113:8080/site/isales/saveAddress.htm"
+
+
+
+#define  URL_CUSTOMER_INFO  @"http://192.168.0.113:8080/site/isales/getCustomerInfoByContact.htm"
+#define  URL_CUSTOMER_PENDINGORDER  @"http://192.168.0.113:8080/site/isales/hasPendingOrderByContact.htm"
+#define  URL_NEW_CUSTOMER  @"http://192.168.0.113:8080/site/isales/getAddCustomer.htm"
+#define  URL_EDIT_CUSTOMER  @"http://192.168.0.113:8080/site/isales/getUpdateCustomerInfoByContact.htm"
+#define  URL_CUSTOMER_SAVE  @"http://192.168.0.113:8080/site/isales/saveCustomer.htm"
+#define  URL_CUSTOMER_UPDATE  @"http://192.168.0.113:8080/site/isales/updateCustomer.htm"
+#define  URL_UPDATE_CUSTOMER_BCARD  @"http://192.168.0.113:8080/site/isales/updateCustomerBusiCard.htm"
+
+
+
+
+
+
+#define  URL_ERR_LOG  @"http://192.168.0.113:8080/site/isales/er_log.htm"
+
+#define  URL_UPLOAD_IMG  @"http://192.168.0.113:8080/site/isales/uploadImg.htm"
+
+
+#define  URL_NPD_POLICY  @"http://192.168.0.113:8080/site/isales/generalPolicy.htm"
+
+
+#define  URL_CHECK_OFFLINE  @"http://192.168.0.113:8080/site/offline/initDatas.htm"
+#define  URL_UPLOAD_OFFLINE  @"http://192.168.0.113:8080/site/offline/uploadOfflineData.htm"
+
+
+#define  URL_DOWNLOAD_OFFLINE  @"http://192.168.0.113:8080/site/offline/downloadDatas.htm"
+#define  URL_FINISH_DOWNLOAD_OFFLINE  @"http://192.168.0.113:8080/site/offline/confirmVersion.htm"
+
+
+#define  URL_GET_RESULT  @"http://192.168.0.113:8080/site/offline/getResultBySerial.htm"
+
+#define URL_SET_PRICE_TYPE @"http://192.168.0.113:8080/site/isales/setSeePriceType.htm"
+
+#define URL_GET_CIVEN_PRICE @"http://192.168.0.113:8080/site/isales/getSeeGivenPrice.htm"
+
+#define URL_SET_GIVEN_PRICE @"http://192.168.0.113:8080/site/isales/setSeeGivenPrice.htm"
+
+#define URL_SET_MERGE_ORDER @"http://192.168.0.113:8080/site/isales/mergeOrder.htm"
+
+#define URL_REQUEST_LOGIN @"http://192.168.0.113:8080/site/isales/requestLogin.htm"
+
+#define URL_EMAIL_CART @"http://192.168.0.113:8080/site/isales/sendCartEmail.htm"
+
+#define URL_NOTIFY_ME @"http://192.168.0.113:8080/site/isales/notifyMeEmail.htm"
+
+#else
+
+#define URL_FINISH_DOWNLOAD_OFFLINE @""
+#define URL_CATEGORYADDALL @""
+#define URL_SEARCHADDALL @""
+#define URL_ITEMSEARCHADDALL @""
+#define URL_SET_PRICE_TYPE @""
+#define URL_GET_CIVEN_PRICE @""
+#define URL_SET_GIVEN_PRICE @""
+#define URL_SET_MERGE_ORDER @""
+#define URL_EMAIL_CART @""
+#define URL_NOTIFY_ME @""
+
 //------------------- HMLG TEST server-----------------------
 #define  URL_UPDATE_AUTH  @"http://207.140.24.83/isales/login.htm"
 #define  URL_LOGOUT  @"http://207.140.24.83/isales/loginOut.htm"
@@ -226,6 +271,7 @@
 #define  URL_DOWNLOAD_OFFLINE  @"http://192.168.1.3/update.htm"
 #define  URL_UPLOAD_OFFLINE  @"http://192.168.0.126:8080/site/offline/uploadOfflineData.htm"
 
+#endif
 #endif
 /*
  

+ 14 - 0
RedAnt ERP Mobile/common/CartUtils.h

@@ -0,0 +1,14 @@
+//
+//  CartUtils.h
+//  iSales-NPD
+//
+//  Created by Ray on 12/26/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+typedef void (^add_to_cart_Handler)(void);
+@interface CartUtils : NSObject
++(void) add_to_cart:(UIViewController*) vc selectorholder:(id)holder selector:(SEL)addtocart;
++(void) add_recent_model:(NSDictionary*) model;
+@end

+ 756 - 0
RedAnt ERP Mobile/common/CartUtils.m

@@ -0,0 +1,756 @@
+//
+//  CartUtils.m
+//  iSales-NPD
+//
+//  Created by Ray on 12/26/16.
+//  Copyright © 2016 United Software Applications, Inc. All rights reserved.
+//
+
+#import "CartUtils.h"
+#import "RAUtils.h"
+#import "AppDelegate.h"
+#import "iSalesNetwork.h"
+#import "LoginViewController.h"
+#import "MainViewController.h"
+
+
+@implementation CartUtils
++(void) neworder:(UIViewController*) vc selectorholder:(id)holder selector:(SEL)addtocart
+{
+
+    UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+
+        NSDictionary* return_json = [iSalesNetwork new_Order];
+
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+
+
+            if([[return_json valueForKey:@"result"] intValue]==2)
+            {
+                int result=[[return_json valueForKey:@"result"] intValue];
+                if(result==2)
+                {
+                    //successed.
+
+                    NSString* order_code = [return_json valueForKey:@"orderCode"];
+                    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                    appDelegate.order_code = order_code;
+                    appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
+
+                    [holder performSelector:addtocart];
+
+
+                    //    [self ReloadData];
+
+
+                    //                    if(self.shopCartBlock!=nil)
+                    //                    {
+                    //                        UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
+                    //
+                    //
+                    //                        CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
+                    //                        UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
+                    //                        iv.image = img;
+                    //                        //                        [self.contentView addSubview:iv];
+                    //                        self.shopCartBlock(iv);
+                    //
+                    //                    }
+
+                }
+            }
+            else
+            {
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:vc] ;
+            }
+
+
+
+
+        });
+    });
+}
+
++(void) add_to_cart:(UIViewController*) vc selectorholder:(id)holder selector:(SEL)addtocart
+{
+    UIApplication * app = [UIApplication sharedApplication];
+    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+
+
+
+    if(appDelegate.bLogin==false)
+    {
+
+        LoginViewController * loginvc =[ vc.storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
+
+        loginvc.returnValue = ^(bool blogin){
+
+            if(blogin)
+            {
+                if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/ true)
+                {
+
+                    [main_vc checklogin:false];
+
+
+                    NSString* msg =@"";
+                    //                    if(appDelegate.contact_id.length>0)
+                    //                    {
+                    //                        msg = [msg stringByAppendingString:@"Customer:"];
+                    //                        msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
+                    //
+                    //                    }
+
+                    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Add to cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                    //block代码块取代了delegate
+
+
+
+                    UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+
+
+                        //  vc.disable_refresh = true;
+                        OrderListViewController* ovc =[ vc.storyboard instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+                        ovc.showNavibar = true;
+                        //ovc.customer_id = appDelegate.contact_id;
+                        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+
+                            [holder performSelector:addtocart];
+
+
+                        };
+                        ovc.init_style = OL_OPEN;
+
+                        ovc.onCancel = ^(){
+
+                            //  self.disable_refresh = false;
+
+
+
+                        };
+
+                        [vc.navigationController pushViewController:ovc animated:true];
+
+
+
+
+
+                    }];
+
+                    UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+
+
+                        {
+                            //create new;
+                            //    self.disable_refresh = true;
+                            if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+                            {
+                                ContactListViewController* cvc = [vc.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+                                cvc.showNavibar = true;
+                                cvc.contact_type = @"Sales_Order_Customer";
+                                cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+
+                                    appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+                                    appDelegate.customerInfo = value;
+
+
+                                    if(appDelegate.order_code==nil)
+                                        [self neworder:vc selectorholder:holder selector:addtocart];
+                                    //                                                            neworder();
+
+                                    //    [main_vc checklogin:true];
+                                    //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+
+                                    //
+                                    //                if(self.returnValue)
+                                    //                    self.returnValue(value);
+                                };
+
+                                cvc.onCancel = ^(){
+
+                                    [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"New Order Error" controller:vc];
+
+                                    // self.disable_refresh = false;
+
+                                };
+                                cvc.onReset = ^(){
+                                    // [main_vc checklogin:true];
+                                };
+
+                                [vc.navigationController pushViewController:cvc animated:true];
+                            }
+                            else
+                            {
+                                [self neworder:vc selectorholder:holder selector:addtocart];
+                            }
+
+                        }
+
+
+                        DebugLog(@"No");
+                    }];
+                    [alertControl addAction:actionOne];
+
+                    [alertControl addAction:alertthree];
+
+                    UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+                    }];
+                    [alertControl addAction:alertcancel];
+
+                    //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
+
+
+                    [vc presentViewController:alertControl animated:YES completion:nil];
+
+
+
+
+
+
+
+                }
+
+                else
+                {
+
+                    //customer login;
+                    [main_vc checklogin:false];
+                    //[self addtocart];
+                    [holder performSelector:addtocart];
+                }
+            }
+
+
+        };
+
+        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
+
+
+
+
+
+        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
+
+        navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
+        [vc presentViewController:navi animated:YES completion:^{
+
+            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
+
+            DebugLog(@"LoginViewController present.........");
+
+            //   self.btop = false;
+            //  <#code#>
+        }];
+    }
+    else
+    {
+        if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE&&/*appDelegate.contact_id==nil&&*/appDelegate.order_code==nil)
+        {
+            if(appDelegate.contact_id.length==0)
+            {
+
+
+
+                NSString* msg =@"";
+
+
+                UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Add to cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                //block代码块取代了delegate
+
+
+
+                UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+
+
+                    //  vc.disable_refresh = true;
+                    OrderListViewController* ovc =[ vc.storyboard instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+                    ovc.showNavibar = true;
+                    //ovc.customer_id = appDelegate.contact_id;
+                    ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+
+                        [holder performSelector:addtocart];
+
+
+                    };
+                    ovc.init_style = OL_OPEN;
+
+                    ovc.onCancel = ^(){
+
+                        //  self.disable_refresh = false;
+
+
+
+                    };
+
+                    [vc.navigationController pushViewController:ovc animated:true];
+
+
+
+
+
+                }];
+
+                UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+
+
+                    {
+                        //create new;
+                        //    self.disable_refresh = true;
+                        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+                        {
+                            ContactListViewController* cvc = [vc.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+                            cvc.showNavibar = true;
+                            cvc.contact_type = @"Sales_Order_Customer";
+                            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+
+                                appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+                                appDelegate.customerInfo = value;
+
+
+                                if(appDelegate.order_code==nil)
+                                    [self neworder:vc selectorholder:holder selector:addtocart];
+                                //                                                            neworder();
+
+                                //    [main_vc checklogin:true];
+                                //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+
+                                //
+                                //                if(self.returnValue)
+                                //                    self.returnValue(value);
+                            };
+
+                            cvc.onCancel = ^(){
+
+                                [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"New Order Error" controller:vc];
+
+                                // self.disable_refresh = false;
+
+                            };
+                            cvc.onReset = ^(){
+                                // [main_vc checklogin:true];
+                            };
+
+                            [vc.navigationController pushViewController:cvc animated:true];
+                        }
+                        else
+                        {
+                            [self neworder:vc selectorholder:holder selector:addtocart];
+                        }
+
+                    }
+
+
+                    DebugLog(@"No");
+                }];
+                [alertControl addAction:actionOne];
+
+                [alertControl addAction:alertthree];
+                UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+                }];
+                [alertControl addAction:alertcancel];
+
+                //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
+
+
+                [vc presentViewController:alertControl animated:YES completion:nil];
+
+
+
+
+
+
+
+            }
+
+            else
+
+            {
+
+                UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Checking Pending Order"];
+
+
+
+
+                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+
+                    NSDictionary* return_json = [iSalesNetwork request_PendingOrder:appDelegate.contact_id];
+
+                    dispatch_async(dispatch_get_main_queue(), ^{
+
+                        [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
+
+                        if([[return_json valueForKey:@"result"] intValue]==2)
+                        {
+
+                            bool openPendingOrder= [[return_json valueForKey:@"hasPending"] boolValue];
+                            bool createNewOrder=appDelegate.can_create_order;
+
+                            if(openPendingOrder&&createNewOrder)
+                            {
+
+                                NSString* msg =@"";
+                                if(appDelegate.contact_id.length>0)
+                                {
+                                    msg = [msg stringByAppendingString:@"Customer:"];
+                                    msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
+
+                                }
+
+                                UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Add to cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                                //block代码块取代了delegate
+
+
+
+                                UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+
+
+                                    //  vc.disable_refresh = true;
+                                    OrderListViewController* ovc =[ vc.storyboard instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+                                    ovc.showNavibar = true;
+                                    ovc.customer_id = appDelegate.contact_id;
+                                    ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+
+                                        [holder performSelector:addtocart];
+
+
+                                    };
+                                    ovc.init_style = OL_OPEN;
+
+                                    ovc.onCancel = ^(){
+
+                                        //  self.disable_refresh = false;
+
+
+
+                                    };
+
+                                    [vc.navigationController pushViewController:ovc animated:true];
+
+
+
+
+
+                                }];
+
+                                UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+
+
+                                    {
+                                        //create new;
+                                        //    self.disable_refresh = true;
+                                        if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+                                        {
+                                            ContactListViewController* cvc = [vc.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+                                            cvc.showNavibar = true;
+                                            cvc.contact_type = @"Sales_Order_Customer";
+                                            cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+
+                                                appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+                                                appDelegate.customerInfo = value;
+
+
+                                                if(appDelegate.order_code==nil)
+                                                    [self neworder:vc selectorholder:holder selector:addtocart];
+                                                //                                                            neworder();
+
+                                                //    [main_vc checklogin:true];
+                                                //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+
+                                                //
+                                                //                if(self.returnValue)
+                                                //                    self.returnValue(value);
+                                            };
+
+                                            cvc.onCancel = ^(){
+
+                                                [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"New Order Error" controller:vc];
+
+                                                // self.disable_refresh = false;
+
+                                            };
+                                            cvc.onReset = ^(){
+                                                // [main_vc checklogin:true];
+                                            };
+
+                                            [vc.navigationController pushViewController:cvc animated:true];
+                                        }
+                                        else
+                                        {
+                                            [self neworder:vc selectorholder:holder selector:addtocart];
+                                        }
+
+                                    }
+
+
+                                    DebugLog(@"No");
+                                }];
+                                [alertControl addAction:actionOne];
+
+                                [alertControl addAction:alertthree];
+
+                                UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+                                }];
+                                [alertControl addAction:alertcancel];
+                                //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
+
+
+                                [vc presentViewController:alertControl animated:YES completion:nil];
+
+
+
+
+
+
+                            }
+                            else
+                            {
+                                if(openPendingOrder)
+                                {
+                                    NSString* msg =@"";
+                                    if(appDelegate.contact_id.length>0)
+                                    {
+                                        msg = [msg stringByAppendingString:@"Customer:"];
+                                        msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
+
+                                    }
+
+                                    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Add to cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                                    //block代码块取代了delegate
+
+
+
+                                    UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+
+
+                                        //  vc.disable_refresh = true;
+                                        OrderListViewController* ovc =[ vc.storyboard instantiateViewControllerWithIdentifier:@"OrderListViewController"];
+                                        ovc.showNavibar = true;
+                                        ovc.customer_id = appDelegate.contact_id;
+                                        ovc.selectOrder = ^(NSMutableDictionary* order_detail){
+
+                                            [holder performSelector:addtocart];
+
+
+                                        };
+                                        ovc.init_style = OL_OPEN;
+
+                                        ovc.onCancel = ^(){
+
+                                            //  self.disable_refresh = false;
+
+
+
+                                        };
+
+                                        [vc.navigationController pushViewController:ovc animated:true];
+
+
+
+
+
+                                    }];
+
+
+                                    [alertControl addAction:actionOne];
+                                    UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+                                    }];
+                                    [alertControl addAction:alertcancel];
+
+                                    //   [alertControl addAction:alertthree];
+
+                                    //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
+
+
+                                    [vc presentViewController:alertControl animated:YES completion:nil];
+
+
+
+
+
+
+
+                                }
+                                else if(createNewOrder)
+                                {
+                                    NSString* msg =@"";
+                                    if(appDelegate.contact_id.length>0)
+                                    {
+                                        msg = [msg stringByAppendingString:@"Customer:"];
+                                        msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
+
+                                    }
+
+                                    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Add to cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
+                                    //block代码块取代了delegate
+
+
+
+
+
+                                    UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+
+
+                                        {
+                                            //create new;
+                                            //    self.disable_refresh = true;
+                                            if(appDelegate.customerInfo==nil)// select contact if current contact not exist
+                                            {
+                                                ContactListViewController* cvc = [vc.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
+                                                cvc.showNavibar = true;
+                                                cvc.contact_type = @"Sales_Order_Customer";
+                                                cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
+
+                                                    appDelegate.contact_id=[value valueForKey:@"customer_cid"];
+                                                    appDelegate.customerInfo = value;
+
+
+                                                    if(appDelegate.order_code==nil)
+                                                        [self neworder:vc selectorholder:holder selector:addtocart];
+                                                    //                                                            neworder();
+
+                                                    //    [main_vc checklogin:true];
+                                                    //            [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+
+                                                    //
+                                                    //                if(self.returnValue)
+                                                    //                    self.returnValue(value);
+                                                };
+
+                                                cvc.onCancel = ^(){
+
+                                                    [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"New Order Error" controller:vc];
+
+                                                    // self.disable_refresh = false;
+
+                                                };
+                                                cvc.onReset = ^(){
+                                                    // [main_vc checklogin:true];
+                                                };
+
+                                                [vc.navigationController pushViewController:cvc animated:true];
+                                            }
+                                            else
+                                            {
+                                                [self neworder:vc selectorholder:holder selector:addtocart];
+                                            }
+
+                                        }
+
+
+                                        DebugLog(@"No");
+                                    }];
+                                    //                                        [alertControl addAction:actionOne];
+
+                                    [alertControl addAction:alertthree];
+
+                                    UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+                                    }];
+                                    [alertControl addAction:alertcancel];
+
+                                    //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
+
+
+                                    [vc presentViewController:alertControl animated:YES completion:nil];
+
+
+
+
+
+                                }
+                                else
+                                {
+                                    [RAUtils message_alert:[return_json valueForKey:@"You donot have permission to access order"] title:@"Add To Cart" controller:vc];
+                                }
+
+                            }
+
+
+                        }
+                        else
+                        {
+
+                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Check Pending Order" controller:vc] ;
+                        }
+
+
+
+
+                    });
+                });
+
+
+            }
+            //            // [main_vc checklogin:false];
+            //
+            //            if(appDelegate.can_create_order)
+            //            {
+            //                NSString* msg =@"";
+            //                if(appDelegate.contact_id.length>0)
+            //                {
+            //                    msg = [msg stringByAppendingString:@"\n\nCustomer:"];
+            //                    msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
+            //
+            //                }
+            //                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil),NSLocalizedString(@"Create new order", nil), nil];
+            //
+            //                // alert.
+            //                [alert show];
+            //            }
+            //            else
+            //            {
+            //                UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Add to cart", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil), nil];
+            //
+            //                // alert.
+            //                [alert show];
+            //            }
+        }
+        else
+        {
+
+            //            if(appDelegate.order_code==nil)
+            //                [ self neworder];
+            //            else
+            [holder performSelector:addtocart];
+
+
+
+        }
+    }
+
+}
+
+
++(void) add_recent_model:(NSDictionary*) model
+{
+
+    NSMutableDictionary * newdict = [[NSMutableDictionary alloc]init];
+    [newdict setObject:model forKey:@"item_0"];
+
+
+
+
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    int count=[appDelegate.recent_model[@"count"] intValue];
+    for(int i=0;i<count;i++)
+    {
+        NSMutableDictionary * mitem= appDelegate.recent_model[[NSString stringWithFormat:@"item_%d",i]];
+        if([mitem[@"product_id"] isEqualToString:model[@"product_id"]])
+            continue;
+        [newdict setObject:mitem forKey:[NSString stringWithFormat:@"item_%lu",(unsigned long)newdict.allKeys.count]];
+
+    }
+    newdict[@"count"]=[NSString stringWithFormat:@"%lu",(unsigned long)newdict.allKeys.count];
+
+
+    appDelegate.recent_model = newdict;
+    //
+    //
+    //    if(!bexist)
+    //    {
+    //        [appDelegate.recent_model setObject:item forKey:[NSString stringWithFormat:@"item_%d",count]];
+    //        appDelegate.recent_model[@"count"]=[NSString stringWithFormat:@"%d",count+1];
+    //    }
+}
+@end

+ 3 - 1
RedAnt ERP Mobile/common/Functions/sidemenu/LoginViewController.m

@@ -500,7 +500,8 @@
 #pragma mark - action
 
 - (IBAction)requestLoginBtnClicked:(UIButton *)sender {
-    
+
+#ifdef BUILD_NPD
     WebViewController *webVC = [self.storyboard instantiateViewControllerWithIdentifier:@"WebViewController"];
     webVC.url = URL_REQUEST_LOGIN;
     webVC.title = @"Request Login";
@@ -511,6 +512,7 @@
     nav.modalPresentationStyle = UIModalPresentationFormSheet;
     
     [self presentViewController:nav animated:YES completion:nil];
+#endif
     
 }
 

+ 25 - 0
RedAnt ERP Mobile/common/JKLock/JKDotView.h

@@ -0,0 +1,25 @@
+//
+//  JKDotView.h
+//  Lock
+//
+//  Created by Jack on 2016/10/13.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+typedef NS_ENUM(NSUInteger, JKDotState) {
+    JKDotStateNormal,
+    JKDotStateSelected
+};
+
+@interface JKDotView : UIView
+
+@property (nonatomic,assign) JKDotState state;
+
+@property (nonatomic,strong) UIColor *strokColor;
+@property (nonatomic,strong) UIColor *fillColor;
+
+- (instancetype)initWithFrame:(CGRect)frame strokColor:(UIColor *)strokColor fillColor:(UIColor *)fillColor;
+
+@end

+ 88 - 0
RedAnt ERP Mobile/common/JKLock/JKDotView.m

@@ -0,0 +1,88 @@
+//
+//  JKDotView.m
+//  Lock
+//
+//  Created by Jack on 2016/10/13.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import "JKDotView.h"
+
+@interface JKDotView ()
+
+@property (nonatomic,strong) CAShapeLayer *inscribedCircleLayer;///<内切圆
+
+
+@end
+
+@implementation JKDotView
+
+-(CAShapeLayer *)inscribedCircleLayer{
+    if (!_inscribedCircleLayer) {
+        _inscribedCircleLayer = [CAShapeLayer layer];
+        _inscribedCircleLayer.strokeColor = self.strokColor.CGColor;
+        _inscribedCircleLayer.fillColor = [UIColor clearColor].CGColor;
+        _inscribedCircleLayer.lineWidth = 1.0f;
+    }
+    return _inscribedCircleLayer;
+}
+
+- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
+    
+    self.inscribedCircleLayer.path = [UIBezierPath bezierPathWithOvalInRect:self.bounds].CGPath;
+    
+    [self.layer addSublayer:self.inscribedCircleLayer];
+    
+}
+
+- (instancetype)initWithFrame:(CGRect)frame {
+    if (self = [super initWithFrame:frame]) {
+        self.backgroundColor = [UIColor clearColor];
+        [self.layer setNeedsDisplay];
+    }
+    return self;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame strokColor:(UIColor *)strokColor fillColor:(UIColor *)fillColor {
+    if (self = [super initWithFrame:frame]) {
+        
+        self.strokColor = strokColor;
+        self.fillColor = fillColor;
+        
+        self.backgroundColor = [UIColor clearColor];
+        [self.layer setNeedsDisplay];
+        
+    }
+    return self;
+}
+
+- (void)setState:(JKDotState)state {
+    _state = state;
+    
+    switch (state) {
+        case JKDotStateNormal:{
+            _inscribedCircleLayer.strokeColor = self.strokColor.CGColor;
+            _inscribedCircleLayer.fillColor = [UIColor clearColor].CGColor;
+        }
+            break;
+        case JKDotStateSelected:{
+            _inscribedCircleLayer.strokeColor = self.fillColor.CGColor;
+            _inscribedCircleLayer.fillColor = self.fillColor.CGColor;
+        }
+            break;
+            
+        default:
+            break;
+    }
+}
+
+- (UIColor *)strokColor {
+    return _strokColor ? _strokColor : [UIColor blackColor];
+}
+
+- (UIColor *)fillColor {
+    return _fillColor ? _fillColor : [UIColor blackColor];
+}
+
+
+@end

+ 23 - 0
RedAnt ERP Mobile/common/JKLock/JKLockButton.h

@@ -0,0 +1,23 @@
+//
+//  JKLockButton.h
+//  Lock
+//
+//  Created by Jack on 2016/10/13.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+
+@interface JKLockButton : UIButton
+
+@property (nonatomic,assign) NSInteger number;
+
+@property (nonatomic,strong) UIColor *strokColor;
+@property (nonatomic,strong) UIColor *fillColor;
+@property (nonatomic,strong) UIColor *highlightColor;
+
+- (instancetype)initWithFrame:(CGRect)frame strokColor:(UIColor *)strokColor highlightColor:(UIColor *)highlightColor;
+
+@end

+ 119 - 0
RedAnt ERP Mobile/common/JKLock/JKLockButton.m

@@ -0,0 +1,119 @@
+//
+//  JKLockButton.m
+//  Lock
+//
+//  Created by Jack on 2016/10/13.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import "JKLockButton.h"
+
+@interface JKLockButton ()
+
+@property (nonatomic,strong) CAShapeLayer *inscribedCircleLayer;///<内切圆
+
+@property (nonatomic,strong) CAShapeLayer *borderLayer;///<边框
+
+
+@end
+
+@implementation JKLockButton
+
+- (void)setNumber:(NSInteger)number {
+    _number = number;
+    
+    if (number >= 0 && number < 10) {
+        [self setTitle:[NSString stringWithFormat:@"%d",number] forState:UIControlStateNormal];
+        self.titleLabel.font = [UIFont systemFontOfSize:17.0f];
+    } else {
+        [self setTitle:@"delete" forState:UIControlStateNormal];
+        self.titleLabel.font = [UIFont systemFontOfSize:14.0f];
+    }
+    [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+}
+-(CAShapeLayer *)inscribedCircleLayer{
+    if (!_inscribedCircleLayer) {
+        _inscribedCircleLayer = [CAShapeLayer layer];
+        _inscribedCircleLayer.strokeColor = self.strokColor.CGColor;
+        _inscribedCircleLayer.fillColor = [UIColor clearColor].CGColor;
+        _inscribedCircleLayer.lineWidth = 1.0f;
+    }
+    return _inscribedCircleLayer;
+}
+
+-(CAShapeLayer *)borderLayer{
+    if (!_borderLayer) {
+        _borderLayer = [CAShapeLayer layer];
+        _borderLayer.fillColor = [UIColor clearColor].CGColor;
+        _borderLayer.strokeColor = [UIColor clearColor].CGColor;
+        _borderLayer.lineWidth = 1.0f;
+    }
+    return _borderLayer;
+}
+
+
+- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
+    
+    self.inscribedCircleLayer.path = [UIBezierPath bezierPathWithOvalInRect:self.bounds].CGPath;
+
+    self.borderLayer.path = [UIBezierPath bezierPathWithRect:self.bounds].CGPath;
+    
+    [self.layer addSublayer:self.inscribedCircleLayer];
+    [self.layer addSublayer:self.borderLayer];
+    
+}
+
+- (instancetype)initWithFrame:(CGRect)frame strokColor:(UIColor *)strokColor highlightColor:(UIColor *)highlightColor {
+    if (self = [super initWithFrame:frame]) {
+        self.strokColor = strokColor;
+        self.highlightColor = highlightColor;
+        [self.layer setNeedsDisplay];
+        [self.inscribedCircleLayer addSublayer:self.titleLabel.layer];
+    }
+    return self;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame {
+    if (self = [super initWithFrame:frame]) {
+        [self.layer setNeedsDisplay];
+        [self.inscribedCircleLayer addSublayer:self.titleLabel.layer];
+    }
+    return self;
+}
+
+- (void)setImage:(UIImage *)image forState:(UIControlState)state {
+    
+}
+
+- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
+    self.inscribedCircleLayer.strokeColor = self.highlightColor.CGColor;
+    self.inscribedCircleLayer.fillColor = self.highlightColor.CGColor;
+    
+    NSSet *allTargets = self.allTargets;
+    
+    id target = [allTargets.allObjects firstObject];
+    
+    if (target) {
+        [self sendActionsForControlEvents:UIControlEventTouchUpInside];
+    }
+}
+
+- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
+    self.inscribedCircleLayer.strokeColor = self.strokColor.CGColor;
+    self.inscribedCircleLayer.fillColor = [UIColor clearColor].CGColor;
+}
+
+- (UIColor *)highlightColor {
+    return _highlightColor ? _highlightColor : [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:0.5];
+}
+
+- (UIColor *)strokColor {
+    return _strokColor ? _strokColor : [UIColor lightGrayColor];
+}
+
+- (UIColor *)fillColor {
+    return _fillColor ? _fillColor : self.highlightColor;
+}
+
+
+@end

+ 30 - 0
RedAnt ERP Mobile/common/JKLock/JKLockController.h

@@ -0,0 +1,30 @@
+//
+//  JKLockController.h
+//  Lock
+//
+//  Created by Jack on 2016/10/13.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+typedef void(^authoBlock)(BOOL failure);
+
+@interface JKLockController : UIViewController
+
+@property (nonatomic,copy) authoBlock authoReturn;
+
+#pragma mark - color
+
+@property (nonatomic,strong) UIColor *backgroundColor;
+@property (nonatomic,strong) UIColor *dotStrokColor;
+@property (nonatomic,strong) UIColor *dotFillColor;
+@property (nonatomic,strong) UIColor *lockStrokColor;
+//@property (nonatomic,strong) UIColor *lockFillColor;
+@property (nonatomic,strong) UIColor *lockHighlightColor;
+
+#pragma mark - method
+
+- (void)setPasswordKey:(NSString *)passwordKey;
+
+@end

+ 433 - 0
RedAnt ERP Mobile/common/JKLock/JKLockController.m

@@ -0,0 +1,433 @@
+//
+//  JKLockController.m
+//  Lock
+//
+//  Created by Jack on 2016/10/13.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import "JKLockController.h"
+#import "JKLockButton.h"
+#import "JKDotView.h"
+#import "JKMessageBoxController.h"
+#import "AppDelegate.h"
+
+#define Password_Length 4
+#define Dot_Interval 60
+#define Dot_Width 20
+
+#define View_Tag 10086
+
+@interface JKLockController ()
+
+@property (nonatomic,strong) UILabel *tipLabel;///<提示标签
+@property (nonatomic,copy) NSString *password;///<密码
+@property (nonatomic,strong) UIButton *forgottenButton;
+@property (nonatomic,strong) UIButton *resetButton;
+@property (nonatomic,strong) NSMutableArray *dotArray;///<密码视图
+@property (nonatomic,copy) NSString *input;///<输入
+@property (nonatomic,assign) NSUInteger index;///<输入了多少位
+
+@property (nonatomic,copy,readonly) NSString *passwordKey;///<取密码的钥匙
+
+@end
+
+@implementation JKLockController
+
+- (void)setPasswordKey:(NSString *)passwordKey {
+    _passwordKey = passwordKey;
+}
+
+- (instancetype)init {
+    if (self = [super init]) {
+        self.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:0.8];
+        
+        self.dotStrokColor = [UIColor colorWithRed:0.4737 green:0.3641 blue:0.2456 alpha:0.5];
+        self.dotFillColor = [UIColor colorWithRed:0.4737 green:0.3641 blue:0.2456 alpha:0.5];
+        
+        self.lockStrokColor = [UIColor colorWithRed:0.4737 green:0.3641 blue:0.2456 alpha:0.5];
+        self.lockHighlightColor = [UIColor colorWithRed:0.4737 green:0.3641 blue:0.2456 alpha:0.5];
+    }
+    return self;
+}
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    self.view.backgroundColor = self.backgroundColor;
+        
+    self.index = 0;
+    self.input = @"";
+    [self loadPassword];
+    [self configAppearance];
+    
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
+    return YES;
+}
+
+- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
+    
+    [self configAppearance];
+}
+
+- (void)clearView {
+    for (UIView *view in self.view.subviews) {
+        [view removeFromSuperview];
+        [self.dotArray removeAllObjects];
+    }
+}
+
+- (void)configAppearance {
+    CGFloat width = CGRectGetWidth(self.view.bounds);
+    CGFloat height = CGRectGetHeight(self.view.bounds);
+    
+//    [self clearView];
+    
+    // 20
+    CGFloat y0 = height * 0.2;
+    self.tipLabel.center = CGPointMake(width / 2, y0 + CGRectGetHeight(self.tipLabel.bounds) / 2);
+    [self.view addSubview:self.tipLabel];
+    
+    // 10
+    CGFloat y1 = y0 + CGRectGetHeight(self.tipLabel.bounds) + 20; // 间距20,高度20
+    CGFloat x1 = (width - Dot_Width * Password_Length - Dot_Interval * (Password_Length - 1)) / 2;
+    for (int i = 0; i < Password_Length; i++) {
+        JKDotView *dotView = [self.view viewWithTag:View_Tag + 20 + i];
+        if (dotView) {
+            dotView.frame = CGRectMake(x1 + (Dot_Width + Dot_Interval) * i, y1, Dot_Width, Dot_Width);
+        } else {
+            JKDotView *dot = [[JKDotView alloc] initWithFrame:CGRectMake(x1 + (Dot_Width + Dot_Interval) * i, y1, Dot_Width, Dot_Width) strokColor:self.dotStrokColor fillColor:self.dotFillColor];
+            dot.tag = View_Tag + 20 + i;
+            
+            [self.view addSubview:dot];
+            [self.dotArray addObject:dot];
+        }
+    }
+    
+    // 70
+    // 3 * 4
+    CGFloat y2 = y1 + Dot_Width + 0.1 * height; // 间距 80 / 40
+    CGFloat Button_Width = 0.07 * (width > height ? height : width);
+    CGFloat interval = 0.05 * (width > height ? height : width);
+    CGFloat x2 = (width - Button_Width * 3 - interval * 2) / 2;
+    
+    for (int i = 0; i < 3; i++) { // col
+        
+        for (int j = 0; j < 4; j++) { // row
+            
+            int index = 3 * j + i + View_Tag + 50;
+            UIView *view = [self.view viewWithTag:index];
+            
+            if (i == 0 && j == 3) { // 取消
+                
+                if (!view) {
+                    UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+                    cancelBtn.frame = CGRectMake(x2 + (Button_Width + interval) * i, y2 + (Button_Width + interval) * j, Button_Width, Button_Width);
+                    [cancelBtn setTitle:@"cancel" forState:UIControlStateNormal];
+                    [cancelBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+                    [cancelBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];
+                    [cancelBtn addTarget:self action:@selector(cancelButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+                    [self.view addSubview:cancelBtn];
+                    cancelBtn.tag = index;
+                } else {
+                    view.frame = CGRectMake(x2 + (Button_Width + interval) * i, y2 + (Button_Width + interval) * j, Button_Width, Button_Width);
+                }
+                
+            } else if (i == 2 && j == 3) { // 删除
+                
+                if (view) {
+                    view.frame = CGRectMake(x2 + (Button_Width + interval) * i, y2 + (Button_Width + interval) * j, Button_Width, Button_Width);
+                } else {
+                    UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+                    deleteBtn.frame = CGRectMake(x2 + (Button_Width + interval) * i, y2 + (Button_Width + interval) * j, Button_Width, Button_Width);
+                    [deleteBtn setTitle:@"delete" forState:UIControlStateNormal];
+                    [deleteBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+                    [deleteBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];
+                    [deleteBtn addTarget:self action:@selector(deleteButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+                    [self.view addSubview:deleteBtn];
+                    deleteBtn.tag = index;
+                }
+                
+            } else { // 数字
+                JKLockButton *btn = (JKLockButton *)view;
+                if (btn) {
+                    btn.frame = CGRectMake(x2 + (Button_Width + interval) * i, y2 + (Button_Width + interval) * j, Button_Width, Button_Width);
+                } else {
+                    btn = [[JKLockButton alloc] initWithFrame:CGRectMake(x2 + (Button_Width + interval) * i, y2 + (Button_Width + interval) * j, Button_Width, Button_Width) strokColor:self.lockStrokColor highlightColor:self.lockHighlightColor];
+                    if (i == 1 && j == 3) {
+                        btn.number = 0;
+                    } else {
+                        btn.number = 1 + i + j * 3;
+                    }
+                    [self.view addSubview:btn];
+                    [btn addTarget:self action:@selector(numberButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+                    btn.tag = index;
+                }
+
+                
+            }
+            
+        }
+        
+    }
+    
+    // forget
+    self.forgottenButton.frame = CGRectMake(width - 120, height - 40, 120, 40);
+    [self.view addSubview:self.forgottenButton];
+    
+    // reset
+    self.resetButton.frame = CGRectMake(0, height - 40, 120, 40);
+    [self.view addSubview:self.resetButton];
+    
+}
+
+- (void)loadPassword {
+    
+    NSString *password = [[NSUserDefaults standardUserDefaults] objectForKey:self.passwordKey];
+    self.password = password;
+    
+}
+
+- (void)setPassword:(NSString *)password {
+    _password = password;
+    if (password) {
+        self.tipLabel.text = @"Please Input Your Password";
+    } else {
+        self.tipLabel.text = @"Please Set A Password";
+    }
+}
+
+- (UILabel *)tipLabel {
+    if (!_tipLabel) {
+        _tipLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 20)];
+        _tipLabel.font = [UIFont systemFontOfSize:20.0f];
+        _tipLabel.textAlignment = NSTextAlignmentCenter;
+        
+    }
+    return _tipLabel;
+}
+
+- (UIButton *)forgottenButton {
+    if (!_forgottenButton) {
+        _forgottenButton = [UIButton buttonWithType:UIButtonTypeCustom];
+        [_forgottenButton setTitle:@"forget password" forState:UIControlStateNormal];
+        [_forgottenButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];
+        _forgottenButton.tag = View_Tag + 2;
+        _forgottenButton.titleLabel.font = [UIFont systemFontOfSize:14.0f];
+        [_forgottenButton addTarget:self action:@selector(forgottenButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+    }
+    return _forgottenButton;
+}
+
+- (UIButton *)resetButton {
+    if (!_resetButton) {
+        _resetButton = [UIButton buttonWithType:UIButtonTypeCustom];
+        [_resetButton setTitle:@"reset password" forState:UIControlStateNormal];
+        [_resetButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];
+        _resetButton.tag = View_Tag + 2;
+        _resetButton.titleLabel.font = [UIFont systemFontOfSize:14.0f];
+        [_resetButton addTarget:self action:@selector(resetButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+    }
+    return _resetButton;
+}
+
+- (NSMutableArray *)dotArray {
+    if (!_dotArray) {
+        _dotArray = [NSMutableArray arrayWithCapacity:Password_Length];
+    }
+    return _dotArray;
+}
+
+- (void)numberButtonClick:(JKLockButton *)sender {
+    if (self.index < Password_Length) {
+        NSInteger number = sender.number;
+        JKDotView *dot = [self.dotArray objectAtIndex:self.index];
+        dot.state = JKDotStateSelected;
+        
+        self.input = [self.input stringByAppendingString:[NSString stringWithFormat:@"%d",number]];
+        self.index++;
+    }
+    
+    if (self.index == Password_Length) {
+        
+        [self performSelector:@selector(verifyPassword) withObject:nil afterDelay:0.5];
+    }
+}
+
+- (void)cancelButtonClick:(UIButton *)sender {
+    if (self.navigationController) {
+        [self.navigationController popViewControllerAnimated:YES];
+    } else {
+        [self dismissViewControllerAnimated:YES completion:nil];
+    }
+}
+
+- (void)deleteButtonClick:(UIButton *)sender {
+    if (self.index > 0) {
+        
+        JKDotView *dot = [self.dotArray objectAtIndex:self.index - 1];
+        dot.state = JKDotStateNormal;
+        
+        self.input = [self.input substringToIndex:self.index - 1];
+        self.index--;
+        
+    }
+}
+
+- (void)forgottenButtonClick:(UIButton *)sender {
+
+    JKMessageBoxController *messageBoxController = [JKMessageBoxController messageBoxControllerWithTip:@"Please enter your login password"];
+    
+    __weak typeof(messageBoxController) weakVC = messageBoxController;
+    __weak typeof(self) weakself = self;
+    
+    messageBoxController.changeHandler = ^(UITextField *textField,NSRange range,NSString *string) {
+        
+        return YES;
+    };
+    
+    messageBoxController.textHandler = ^(NSString *text){
+        
+        AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+        
+        if ([text isEqualToString:appDelegate.password]) {
+            
+//            [[NSUserDefaults standardUserDefaults] removeObjectForKey:self.passwordKey];
+//            weakself.password = nil;
+            weakself.index = 0;
+            weakself.input = @"";
+            for (JKDotView *dot in self.dotArray) {
+                dot.state = JKDotStateNormal;
+            }
+            
+//            weakself.tipLabel.text = @"Please Set A New Password";
+            [weakVC dismissViewControllerAnimated:YES completion:^{
+//                weakself.tipLabel.text = @"Please Set A New Password";
+                
+                    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Your Current Password" message:weakself.password preferredStyle:UIAlertControllerStyleAlert];
+
+                
+                    UIAlertAction *action = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+                
+                        if (alertController.navigationController) {
+                            [alertController.navigationController popViewControllerAnimated:YES];
+                        } else {
+                            [alertController dismissViewControllerAnimated:YES completion:nil];
+                        }
+                
+                    }];
+                
+                    [alertController addAction:action];
+                    
+
+                    [weakself presentViewController:alertController animated:YES completion:nil];
+
+
+                
+            }];
+            
+        } else {
+            
+            [weakVC warning:@"It's wrong,please try again"];
+            
+        }
+        
+        
+        
+        
+    };
+    
+    [self presentViewController:messageBoxController animated:YES completion:nil];
+    
+}
+
+- (void)resetButtonClick:(UIButton *)sender {
+    JKMessageBoxController *messageBoxController = [JKMessageBoxController messageBoxControllerWithTip:@"Please enter your login password"];
+    
+    __weak typeof(messageBoxController) weakVC = messageBoxController;
+    __weak typeof(self) weakself = self;
+    
+    messageBoxController.changeHandler = ^(UITextField *textField,NSRange range,NSString *string) {
+        
+        return YES;
+    };
+    
+    messageBoxController.textHandler = ^(NSString *text){
+        
+        AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+        
+        if ([text isEqualToString:appDelegate.password]) {
+            
+            [[NSUserDefaults standardUserDefaults] removeObjectForKey:self.passwordKey];
+            weakself.password = nil;
+            weakself.index = 0;
+            weakself.input = @"";
+            for (JKDotView *dot in self.dotArray) {
+                dot.state = JKDotStateNormal;
+            }
+            
+            weakself.tipLabel.text = @"Please Set A New Password";
+            [weakVC dismissViewControllerAnimated:YES completion:^{
+                weakself.tipLabel.text = @"Please Set A New Password";
+                
+            }];
+            
+        } else {
+            
+            [weakVC warning:@"It's wrong,please try again"];
+            
+        }
+        
+        
+        
+        
+    };
+    
+    [self presentViewController:messageBoxController animated:YES completion:nil];
+}
+
+
+- (void)verifyPassword {
+    
+    self.index = 0;
+    for (JKDotView *dot in self.dotArray) {
+        dot.state = JKDotStateNormal;
+    }
+    
+    if (self.password) { // 验证
+        DebugLog(@"password: %@",self.password);
+        if ([self.password isEqualToString:self.input]) {
+            
+            [[NSUserDefaults standardUserDefaults] setObject:self.password forKey:self.passwordKey];
+            [[NSUserDefaults standardUserDefaults] synchronize];
+            
+            self.tipLabel.text = @"Please Input Your Password";
+            [self cancelButtonClick:nil];// 返回前一个页面
+            sleep(0.25);// 先回到前一个页面才做事情,0.25s为隐式动画持续时间
+            if (self.authoReturn) {
+                self.authoReturn(YES);
+            }
+            
+            
+        } else {
+            
+            self.tipLabel.text = @"The Password Doesn't Match,Please Try Again";
+        }
+        
+    } else { //设置
+        
+        self.password = self.input;
+        self.tipLabel.text = @"Please re-enter password to confirm";
+    }
+    self.input = @"";
+}
+
+
+@end

+ 31 - 0
RedAnt ERP Mobile/common/JKLock/JKMessageBoxController.h

@@ -0,0 +1,31 @@
+//
+//  JKAlertController.h
+//  Lock
+//
+//  Created by Jack on 2016/10/15.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+typedef BOOL(^textChangeHandler)(UITextField *textField,NSRange changeRange,NSString*string);
+
+typedef void(^inputHandler)(NSString *text);
+
+@interface JKMessageBoxController : UIViewController
+
+@property (nonatomic,copy) textChangeHandler changeHandler;
+
+@property (nonatomic,copy) inputHandler textHandler;
+
+@property (nonatomic,copy) NSString *yesButtonTitle;
+
+@property (nonatomic,strong) UITextField *textFiled;///<default secureTextEntry = Yes
+
++ (instancetype)messageBoxControllerWithTip:(NSString *)msg;
+
++ (instancetype)messageBoxControllerWithTip:(NSString *)msg ContentSize:(CGSize)size;
+
+- (void)warning:(NSString *)msg;
+
+@end

+ 171 - 0
RedAnt ERP Mobile/common/JKLock/JKMessageBoxController.m

@@ -0,0 +1,171 @@
+//
+//  JKAlertController.m
+//  Lock
+//
+//  Created by Jack on 2016/10/15.
+//  Copyright © 2016年 mini1. All rights reserved.
+//
+
+#import "JKMessageBoxController.h"
+#import "AppDelegate.h"
+
+#define Button_Title_Normal_Color [UIColor colorWithRed:0.0 green:0.4 blue:0.8 alpha:1]
+#define Button_Title_Highlight_Color [UIColor colorWithRed:0.0 green:0.3 blue:0.8 alpha:1]
+
+
+@interface JKMessageBoxController ()<UITextFieldDelegate>
+
+@property (nonatomic,strong) UILabel *titleLabel;
+@property (nonatomic,strong) UIView *buttonBackground;
+@property (nonatomic,strong) UIButton *cancelButton;
+@property (nonatomic,strong) UIButton *yesButton;
+
+@end
+
+@implementation JKMessageBoxController
+
++ (instancetype)messageBoxControllerWithTip:(NSString *)msg {
+    JKMessageBoxController *alertController = [[JKMessageBoxController alloc] init];
+
+    // 设置弹出视图时视图大小位置
+    alertController.modalPresentationStyle = UIModalPresentationFormSheet; // 只在iPad起作用
+    alertController.preferredContentSize = CGSizeMake(300, 130); // 只有在 UIModalPresentationFormSheet 的时候起作用
+    alertController.titleLabel.text = msg;
+    alertController.title = msg;
+    
+    return alertController;
+}
+
++ (instancetype)messageBoxControllerWithTip:(NSString *)msg ContentSize:(CGSize)size{
+    JKMessageBoxController *alertController = [[JKMessageBoxController alloc] init];
+    
+    // 设置弹出视图时视图大小位置
+    alertController.modalPresentationStyle = UIModalPresentationFormSheet; // 只在iPad起作用
+    if (size.width <= 0 || size.height <= 0) {
+        size = CGSizeMake(300, 130);
+    }
+    alertController.preferredContentSize = size; // 只有在 UIModalPresentationFormSheet 的时候起作用
+    alertController.titleLabel.text = msg;
+    alertController.title = msg;
+    
+    return alertController;
+}
+
+- (void)warning:(NSString *)msg {
+    self.textFiled.text = @"";
+    self.titleLabel.text = msg;
+    self.titleLabel.textColor = [UIColor redColor];
+    
+    [self performSelector:@selector(resetTitleLabel) withObject:nil afterDelay:1];
+}
+
+- (void)resetTitleLabel {
+    self.titleLabel.text = self.title;
+    self.titleLabel.textColor = [UIColor blackColor];
+}
+
+- (UILabel *)titleLabel {
+    if (!_titleLabel) {
+        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, self.preferredContentSize.width - 20, 25)];
+        _titleLabel.font = [UIFont systemFontOfSize:14];
+        _titleLabel.textAlignment = NSTextAlignmentCenter;
+    }
+    return _titleLabel;
+}
+
+- (UITextField *)textFiled {
+    if (!_textFiled) {
+        _textFiled = [[UITextField alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(self.titleLabel.frame) + 10, self.preferredContentSize.width - 20, 25)];
+        _textFiled.font = [UIFont systemFontOfSize:13];
+        _textFiled.borderStyle = UITextBorderStyleRoundedRect;
+        _textFiled.secureTextEntry = YES;
+        _textFiled.delegate = self;
+    }
+    return _textFiled;
+}
+
+- (UIView *)buttonBackground {
+    if (!_buttonBackground) {
+        _buttonBackground = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.textFiled.frame) + 20, self.preferredContentSize.width,  self.preferredContentSize.height - CGRectGetMaxY(self.textFiled.frame) - 10)];
+        
+        [_buttonBackground addSubview:self.cancelButton];
+        [_buttonBackground addSubview:self.yesButton];
+        _buttonBackground.backgroundColor = [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1];
+    }
+    return _buttonBackground;
+}
+
+- (UIButton *)cancelButton {
+    if (!_cancelButton) {
+        _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
+        _cancelButton.frame = CGRectMake(0, 0.5, self.preferredContentSize.width / 2 - 0.25, CGRectGetHeight(self.buttonBackground.frame));
+        [_cancelButton setTitle:@"cancel" forState:UIControlStateNormal];
+        [_cancelButton setTitleColor:Button_Title_Normal_Color forState:UIControlStateNormal];
+        [_cancelButton setTitleColor:Button_Title_Highlight_Color forState:UIControlStateHighlighted];
+        _cancelButton.backgroundColor = [UIColor whiteColor];
+        _cancelButton.titleLabel.font = [UIFont systemFontOfSize:15.0];
+        _cancelButton.titleEdgeInsets = UIEdgeInsetsMake(-15, 0, 0, 0);
+        [_cancelButton addTarget:self action:@selector(cancelButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+    }
+    return _cancelButton;
+}
+
+- (UIButton *)yesButton {
+    if (!_yesButton) {
+        _yesButton = [UIButton buttonWithType:UIButtonTypeCustom];
+        _yesButton.frame = CGRectMake(CGRectGetMaxX(self.cancelButton.frame) + 0.5, 0.5, self.preferredContentSize.width / 2 - 0.25, CGRectGetHeight(self.buttonBackground.frame));
+        NSString *title = self.yesButtonTitle == nil ? @"ok" : self.yesButtonTitle;
+        [_yesButton setTitle:title forState:UIControlStateNormal];
+        [_yesButton setTitleColor:Button_Title_Normal_Color forState:UIControlStateNormal];
+        [_yesButton setTitleColor:Button_Title_Highlight_Color forState:UIControlStateHighlighted];
+        _yesButton.backgroundColor = [UIColor whiteColor];
+        _yesButton.titleLabel.font = [UIFont systemFontOfSize:15.0];
+        _yesButton.titleEdgeInsets = UIEdgeInsetsMake(-15, 0, 0, 0);
+        [_yesButton addTarget:self action:@selector(yesButtonClick:) forControlEvents:UIControlEventTouchUpInside];
+    }
+    return _yesButton;
+}
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+ 
+    self.view.backgroundColor = [UIColor whiteColor];
+    
+    [self.view addSubview:self.titleLabel];
+    [self.view addSubview:self.textFiled];
+    [self.view addSubview:self.buttonBackground];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)cancelButtonClick:(UIButton *)sender {
+    if (self.navigationController) {
+        [self.navigationController popViewControllerAnimated:YES];
+    } else {
+        [self dismissViewControllerAnimated:YES completion:nil];
+    }
+}
+
+- (void)yesButtonClick:(UIButton *)sender {
+    
+    if (self.textHandler) {
+        self.textHandler(self.textFiled.text);
+    }
+    
+}
+
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
+    
+    if (self.changeHandler) {
+        return self.changeHandler(textField,range,string);
+    }
+    
+    return YES;
+}
+
+
+@end

+ 38 - 0
RedAnt ERP Mobile/common/JKTimer/JKTimerManager.h

@@ -0,0 +1,38 @@
+//
+//  JKTimer.h
+//  JKUtilDemo
+//
+//  Created by Jack on 7/1/16.
+//  Copyright © 2016 Emerys. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface JKTimerManager : NSObject
+
++ (instancetype)sharedTimerManager;
+
+/**
+ *  启动一个timer,默认精度为0.1秒
+ *
+ *  @param name          timer的名称,作为唯一标识
+ *  @param timerInterval 执行的时间间隔
+ *  @param queue         timer将被放入的队列,也就是最终action执行的队列。传入nil将自动放到一个子线程队列中
+ *  @param repeats       timer是否循环调用
+ *  @param action        时间间隔到点时执行的block
+ */
+- (void)scheduledDispatchTimerWithName:(NSString *)name timeInterval:(NSTimeInterval)timerInterval queue:(dispatch_queue_t)queue repeats:(BOOL)repeats action:(dispatch_block_t)action;
+
+/**
+ *  撤销某个timer
+ *
+ *  @param name timer的名称,唯一标识
+ */
+- (void)cancelTimerWithName:(NSString *)name;
+
+/**
+ *  撤销所有timer 
+ */
+- (void)cancelAllTimer;
+
+@end

+ 106 - 0
RedAnt ERP Mobile/common/JKTimer/JKTimerManager.m

@@ -0,0 +1,106 @@
+//
+//  JKTimer.m
+//  JKUtilDemo
+//
+//  Created by Jack on 7/1/16.
+//  Copyright © 2016 Emerys. All rights reserved.
+//
+
+#import "JKTimerManager.h"
+
+#define lockName(var) [NSString stringWithFormat:@"%@_canceller",var]
+#define timerLock(var) [[JKTimerManager sharedTimerManager].lockContainer objectForKey:lockName(var)]
+
+@interface JKTimerManager ()
+
+@property (nonatomic,strong) NSMutableDictionary *timerContainer;
+@property (nonatomic,strong) NSMutableDictionary *lockContainer;
+
+@end
+
+@implementation JKTimerManager
+
++ (instancetype)sharedTimerManager {
+    static JKTimerManager *manager = nil;
+    static dispatch_once_t token;
+    dispatch_once(&token, ^{
+        manager = [[JKTimerManager alloc] init];
+    });
+    
+    return manager;
+}
+
+- (NSMutableDictionary *)timerContainer {
+    if (!_timerContainer) {
+        _timerContainer = [NSMutableDictionary dictionary];
+    }
+    return _timerContainer;
+}
+
+- (void)scheduledDispatchTimerWithName:(NSString *)name
+                          timeInterval:(NSTimeInterval)timerInterval
+                                 queue:(dispatch_queue_t)queue
+                               repeats:(BOOL)repeats
+                                action:(dispatch_block_t)action {
+    if (name == nil)
+        return;
+    if (queue == nil)
+        queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
+    
+    dispatch_source_t timer = [self.timerContainer objectForKey:name];
+    if (!timer) {
+        timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
+        dispatch_resume(timer);
+        [self.timerContainer setObject:timer forKey:name];
+    }
+    
+    NSLock *timer_lock = [[NSLock alloc] init];
+    [self.lockContainer setObject:timer_lock forKey:lockName(name)];
+    
+    dispatch_source_set_timer(timer, dispatch_time(DISPATCH_TIME_NOW, timerInterval * NSEC_PER_SEC), timerInterval * NSEC_PER_SEC, 0.1 * NSEC_PER_SEC);
+    __weak typeof(self) weakSelf = self;
+    
+    dispatch_source_set_event_handler(timer, ^{
+        
+        [timerLock(name) lock];
+        
+        if (timer && action) {
+            
+            action();
+            if (!repeats) {
+                [weakSelf cancelTimerWithName:name];
+            }
+            
+        }
+        
+        [timerLock(name) unlock];
+    });
+    
+}
+
+- (void)cancelTimerWithName:(NSString *)name {
+    
+    dispatch_source_t timer = [self.timerContainer objectForKey:name];
+    if (!timer) {
+        return;
+    }
+    
+    NSLock *timer_lock = timerLock(name);
+    [timer_lock lock];
+
+    [self.lockContainer removeObjectForKey:lockName(name)];
+    [self.timerContainer removeObjectForKey:name];
+    dispatch_source_cancel(timer);
+    timer = nil;
+    
+    [timer_lock unlock];
+    
+}
+
+- (void)cancelAllTimer {
+    for (NSString *name in self.timerContainer.allKeys) {
+        [self cancelTimerWithName:name];
+    }
+}
+
+@end

+ 25 - 0
RedAnt ERP Mobile/common/NotificationNameCenter.h

@@ -0,0 +1,25 @@
+//
+//  NotificationNameCenter.h
+//  iSales-NPD
+//
+//  Created by Jack on 16/9/9.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface NotificationNameCenter : NSObject
+
+UIKIT_EXTERN  NSString  *LoginOK_HandleUrgencyFile_Notification;///<登陆成功处理恢复文件
+
+UIKIT_EXTERN  NSString  *Change_Price_Type_Notification;///<切换价格通知
+
+UIKIT_EXTERN  NSString  *No_Rights_Notification;///<无权
+
+UIKIT_EXTERN  NSString  *Lock_Permission_Notification;///<Customer锁Order List
+
+UIKIT_EXTERN  NSString  *unLock_Permission_Notification;///<Customer解锁Order List
+
+UIKIT_EXTERN  NSString  *User_LoginOK_Notification;///<用户登陆成功
+
+@end

+ 25 - 0
RedAnt ERP Mobile/common/NotificationNameCenter.m

@@ -0,0 +1,25 @@
+//
+//  NotificationNameCenter.m
+//  iSales-NPD
+//
+//  Created by Jack on 16/9/9.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "NotificationNameCenter.h"
+
+@implementation NotificationNameCenter
+
+const NSString  *LoginOK_HandleUrgencyFile_Notification = @"LoginOK_HandleUrgencyFile_Notification";
+
+const NSString  *Change_Price_Type_Notification = @"Change_Price_Type_Notification";
+
+const NSString  *No_Rights_Notification = @"No_Rights_Notification";
+
+const NSString  *Lock_Permission_Notification = @"Lock_Permission_Notification";
+
+const NSString  *unLock_Permission_Notification = @"unLock_Permission_Notification";
+
+const NSString  *User_LoginOK_Notification = @"User_LoginOK_Notification";
+
+@end

+ 15 - 0
RedAnt ERP Mobile/common/Price Setting/CategoryPriceCell.h

@@ -0,0 +1,15 @@
+//
+//  CategoryPriceCell.h
+//  iSales-NPD
+//
+//  Created by Jack on 2016/10/11.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface CategoryPriceCell : UITableViewCell
+
+@property (nonatomic,strong) NSDictionary *categoryPrice;
+
+@end

+ 73 - 0
RedAnt ERP Mobile/common/Price Setting/CategoryPriceCell.m

@@ -0,0 +1,73 @@
+//
+//  CategoryPriceCell.m
+//  iSales-NPD
+//
+//  Created by Jack on 2016/10/11.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "CategoryPriceCell.h"
+#import "SetCategoryPriceController.h"
+#import "config.h"
+
+@interface CategoryPriceCell ()
+
+@property (strong, nonatomic) IBOutlet UILabel *categoryLabel;
+
+@property (strong, nonatomic) IBOutlet UILabel *priceLabel;
+
+@end
+
+@implementation CategoryPriceCell
+
+- (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
+}
+
+- (void)setCategoryPrice:(NSDictionary *)categoryPrice {
+    _categoryPrice = categoryPrice;
+    
+    NSString *basePrice = [categoryPrice objectForKey:@"base_price"];
+    NSString *discount = [categoryPrice objectForKey:@"price_discount"];
+    NSString *price = @"";
+    switch (basePrice.integerValue) {
+        case 0:{
+            basePrice = [Singleton sharedInstance].deliveryString;
+        }
+            break;
+        case 1:{
+            basePrice = flat_price;
+        }
+            
+        default:
+            break;
+    }
+    
+    if ([discount hasPrefix:@"-"]) {
+        
+        discount = [discount substringFromIndex:1];
+        price = [NSString stringWithFormat:@"%@ - %@",basePrice,discount];
+        
+    } else if ([discount hasSuffix:@"%"]) {
+        
+        price = [NSString stringWithFormat:@"%@ x %@",basePrice,discount];
+        
+    } else {
+        
+        price = [NSString stringWithFormat:@"%@ + %@",basePrice,discount];
+        
+    }
+    
+    self.categoryLabel.text = [self.categoryPrice objectForKey:@"title"];
+    
+    self.priceLabel.text = price;
+}
+
+@end

+ 17 - 0
RedAnt ERP Mobile/common/Price Setting/CategoryPriceViewController.h

@@ -0,0 +1,17 @@
+//
+//  CategoryPriceViewController.h
+//  iSales-NPD
+//
+//  Created by Jack on 2016/10/11.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "SetCategoryPriceController.h"
+
+
+@interface CategoryPriceViewController : UIViewController
+
+@property (nonatomic,strong) NSMutableDictionary *categoryGivenPrice;
+
+@end

+ 143 - 0
RedAnt ERP Mobile/common/Price Setting/CategoryPriceViewController.m

@@ -0,0 +1,143 @@
+//
+//  CategoryPriceViewController.m
+//  iSales-NPD
+//
+//  Created by Jack on 2016/10/11.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "CategoryPriceViewController.h"
+#import "const.h"
+#import "CategoryPriceCell.h"
+#import "UIColor+JK_HEX.h"
+
+@interface CategoryPriceViewController ()<UITableViewDelegate,UITableViewDataSource>
+
+@property (strong, nonatomic) IBOutlet UITableView *categoryTable;
+
+@end
+
+@implementation CategoryPriceViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    [self configAppearance];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)configAppearance {
+    
+    self.navigationController.navigationBar.translucent = NO;
+    
+    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                                                   style:UIBarButtonItemStylePlain
+                                                                  target:self
+                                                                  action:@selector( returnBackClick:)];
+    
+    self.navigationItem.leftBarButtonItem = backButton;
+}
+
+#pragma mark - action
+
+- (void)returnBackClick:(id)sender {
+    
+    [self.navigationController popViewControllerAnimated:YES];
+}
+
+#pragma mark - data source
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+    return [[self.categoryGivenPrice objectForKey:@"count"] integerValue];
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    NSString *sectionKey = [NSString stringWithFormat:@"category_%d",section];
+    return [[[self.categoryGivenPrice objectForKey:sectionKey] objectForKey:@"count"] integerValue];
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    CategoryPriceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CategoryPriceCell"];
+    
+    // 解析数据
+    NSInteger section = indexPath.section;
+    NSInteger row = indexPath.row;
+    NSDictionary *categorySection = [self.categoryGivenPrice objectForKey:[NSString stringWithFormat:@"category_%d",section]];
+    NSDictionary *categoryRow = [categorySection objectForKey:[NSString stringWithFormat:@"category_%d",row]];
+
+    cell.categoryPrice = categoryRow;
+    
+    return cell;
+}
+
+#pragma mark - delegate
+
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+    return 47.0f;
+}
+
+- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
+    return 40.0f;
+}
+
+- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
+    
+    NSString *sectionKey = [NSString stringWithFormat:@"category_%d",section];
+    
+    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(tableView.bounds), 40)];
+    headerView.backgroundColor = [UIColor colorWithHEX:0xEFEAE5];
+    
+    UILabel *categoryLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 10, 100, 20)];
+    categoryLabel.textColor = [UIColor blackColor];
+    categoryLabel.font = [UIFont systemFontOfSize:17.0f];
+    categoryLabel.textAlignment = NSTextAlignmentLeft;
+    categoryLabel.text = [[self.categoryGivenPrice objectForKey:sectionKey] objectForKey:@"title"];
+    
+    [headerView addSubview:categoryLabel];
+    
+    return headerView;
+}
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    CategoryPriceCell *cell = [tableView cellForRowAtIndexPath:indexPath];
+    
+    SetCategoryPriceController *setPriceVC =[ [UIStoryboard storyboardWithName:@"CUL" bundle:nil] instantiateViewControllerWithIdentifier:@"SetCategoryPriceController"];
+    
+    __weak typeof(self) weakself = self;
+    setPriceVC.returnBlock = ^(NSDictionary *result){
+        
+        
+        if (weakself) {
+            __strong typeof(weakself) strongself = weakself;
+            
+            NSInteger section = indexPath.section;
+            NSInteger row = indexPath.row;
+            NSDictionary *categorySection = [[self.categoryGivenPrice objectForKey:[NSString stringWithFormat:@"category_%d",section]] mutableCopy];
+            [categorySection setValue:result forKey:[NSString stringWithFormat:@"category_%d",row]];
+            
+            [strongself.categoryGivenPrice setObject:categorySection forKey:[NSString stringWithFormat:@"category_%d",section]];
+            
+            dispatch_async(dispatch_get_main_queue(), ^{
+                [strongself.categoryTable reloadData];
+            });
+            
+        }
+        
+        
+    };
+    setPriceVC.categoryID = [[cell.categoryPrice objectForKey:@"cid"] integerValue];
+    setPriceVC.categoryPrice = cell.categoryPrice.mutableCopy;
+    
+    [self.navigationController pushViewController:setPriceVC animated:YES];
+    
+}
+
+
+@end

+ 16 - 0
RedAnt ERP Mobile/common/Price Setting/PriceSettingViewController.h

@@ -0,0 +1,16 @@
+//
+//  PriceSetting.h
+//  iSales-NPD
+//
+//  Created by Jack on 2016/10/11.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface PriceSettingViewController : UIViewController
+
+@property (nonatomic,assign) NSInteger priceType;///< 0提货价、1统一卖价、 2计算价
+@property (nonatomic,assign) BOOL showPrice;
+
+@end

+ 225 - 0
RedAnt ERP Mobile/common/Price Setting/PriceSettingViewController.m

@@ -0,0 +1,225 @@
+//
+//  PriceSetting.m
+//  iSales-NPD
+//
+//  Created by Jack on 2016/10/11.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "PriceSettingViewController.h"
+#import "const.h"
+#import "EnumSelectViewController.h"
+#import "CategoryPriceViewController.h"
+#import "iSalesNetwork.h"
+#import "Singleton.h"
+#import <objc/runtime.h>
+#import "MainViewController.h"
+#import "NotificationNameCenter.h"
+
+
+
+
+@interface PriceSettingViewController ()
+
+@property (strong, nonatomic) IBOutlet UIButton *priceTypeButton;
+
+@property (strong, nonatomic) IBOutlet UIButton *showButton;
+@property (strong, nonatomic) IBOutlet UIButton *setPriceButton;
+
+@end
+
+@implementation PriceSettingViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    self.priceType = [Singleton sharedInstance].npd_shop_price_type;
+    
+    [self configAppearance];
+    
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+#pragma mark - Customer Inint
+
+- (void)configAppearance {
+    
+
+    self.setPriceButton.hidden = ![Singleton sharedInstance].permissions_price_setting;
+
+    
+    UIApplication * app = [UIApplication sharedApplication];
+    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+    
+    self.showPrice = !appDelegate.price_hidden;
+    
+    [self changePriceType:self.priceType];
+    self.showButton.selected = !self.showPrice;
+    
+    UIBarButtonItem *closeButton =   [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                                                      style:UIBarButtonItemStylePlain
+                                                                     target:self
+                                                                     action:@selector(onCloseClick:)];
+    self.navigationItem.rightBarButtonItem = closeButton;
+    
+}
+
+- (void)changePriceType:(NSInteger)type {
+    
+    NSString *title = [Singleton sharedInstance].deliveryString;
+    switch (type) {
+        case 0: {
+            title = [Singleton sharedInstance].deliveryString;
+        }
+            break;
+        case 1: {
+            title = flat_price;
+        }
+            break;
+        case 2: {
+            title = given_price;
+        }
+            break;
+            
+        default:
+            break;
+    }
+    
+    self.priceType = type;
+    [self.priceTypeButton setTitle:title forState:UIControlStateNormal];
+    
+}
+
+#pragma mark - action
+
+- (void)onCloseClick:(id)sender {
+    [self dismissViewControllerAnimated:YES completion:^{
+        
+    }];
+}
+
+- (IBAction)showOrHidePriceButtonClick:(UIButton *)sender {
+    
+    sender.selected = !sender.selected;
+    self.showPrice = !sender.selected;
+    
+    UIApplication * app = [UIApplication sharedApplication];
+    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+    
+    [appDelegate set_priceHidden:sender.selected];
+    
+//    objc_msgSend(appDelegate.main_vc,@selector(initMenuItems));// initMenuItems 不是公开的方法
+    [(MainViewController *)appDelegate.main_vc initMenuItems];
+}
+
+- (IBAction)calculatePriceButtonClick:(UIButton *)sender {
+
+    UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Load Data"];
+    
+    NSDictionary *dic = [iSalesNetwork get_npd_shop_givenPrice];
+
+    [waitalert dismissWithClickedButtonIndex:0 animated:YES];
+    
+    if ([[dic objectForKey:@"result"] integerValue] == 2) {
+    
+        CategoryPriceViewController *categoryPriceVC =[ [UIStoryboard storyboardWithName:@"CUL" bundle:nil] instantiateViewControllerWithIdentifier:@"CategoryPriceViewController"];
+        
+        categoryPriceVC.categoryGivenPrice = dic.mutableCopy;
+        
+        [self.navigationController pushViewController:categoryPriceVC animated:YES];
+    }
+}
+
+- (NSString *)checkPriceType:(NSInteger)priceType {
+    return  self.priceType == priceType ? @"1" : @"0";
+}
+
+- (NSInteger)checkedCadedate:(NSDictionary *)cadedate {
+    
+    int priceType = 0;
+    int count = [[cadedate objectForKey:@"count"] intValue];
+    for (int i = 0; i < count; i++) {
+        NSDictionary *dic = [cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
+        int check = [[dic objectForKey:@"check"] intValue];
+        if (check) {
+            
+            priceType = [[dic objectForKey:@"value_code"] integerValue];
+            
+            break;
+        }
+    }
+    
+    return priceType;
+}
+
+- (IBAction)priceTypeButtonClick:(UIButton *)sender {
+    
+    EnumSelectViewController* enumvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"EnumSelectorViewController"];
+
+    enumvc.max_select = 1;
+    
+    
+//    enumvc.cadedate = @{
+//                        @"count" : @"3",
+//                        @"val_0" : @{@"value" : [Singleton sharedInstance].deliveryString,@"value_code" : @"0",@"check" : [self checkPriceType:0]},
+//                        @"val_1" : @{@"value" : flat_price,@"value_code" : @"1",@"check" : [self checkPriceType:1]},
+//                        @"val_2" : @{@"value" : given_price,@"value_code" : @"2",@"check" : [self checkPriceType:2]}
+//                        }.mutableCopy;
+    
+    enumvc.cadedate = @{
+                        @"count" : @"2",
+                        @"val_0" : @{@"value" : flat_price,@"value_code" : @"1",@"check" : [self checkPriceType:1]},
+                        @"val_1" : @{@"value" : given_price,@"value_code" : @"2",@"check" : [self checkPriceType:2]}
+                        }.mutableCopy;
+    
+    enumvc.title = @"";
+    
+    
+    enumvc.single_select =true;
+    
+    __weak typeof(self) weakSelf = self;
+    
+    enumvc.returnValue = ^(NSMutableDictionary* value){
+        
+        if (weakSelf) {
+            
+            __strong typeof(weakSelf) strongSelf = weakSelf;
+            
+            [strongSelf changePriceType:[strongSelf checkedCadedate:value]];
+
+        }
+        
+    };
+    
+    [self.navigationController pushViewController:enumvc animated:true];
+}
+
+- (IBAction)saveButtonClick:(UIButton *)sender {
+    
+    UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Set PriceType"];
+    
+    NSDictionary *dic = [iSalesNetwork set_npd_shop_price_type:self.priceType];
+    
+    [waitalert dismissWithClickedButtonIndex:0 animated:YES];
+    // 成功
+    if ([[dic objectForKey:@"result"] integerValue] == 2) {
+        
+        [Singleton sharedInstance].npd_shop_price_type = self.priceType;
+    
+        // 刷新 Cart、Order List
+        [[NSNotificationCenter defaultCenter] postNotificationName:Change_Price_Type_Notification object:nil];
+        
+    } else { // 失败
+        
+        DebugLog(@"set price type failure");
+    }
+    
+    [self dismissViewControllerAnimated:YES completion:nil];
+}
+
+@end

+ 23 - 0
RedAnt ERP Mobile/common/Price Setting/SetCategoryPriceController.h

@@ -0,0 +1,23 @@
+//
+//  SetCategoryPriceController.h
+//  iSales-NPD
+//
+//  Created by Jack on 2016/10/11.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+
+typedef void (^setCategoryPriceReturnBlock) (NSDictionary *categoryPrice);
+
+@interface SetCategoryPriceController : UIViewController
+
+@property (nonatomic,assign) NSInteger categoryID;
+
+@property (nonatomic,strong) NSMutableDictionary *categoryPrice;
+
+@property (nonatomic,copy) setCategoryPriceReturnBlock returnBlock;
+
+@end

+ 325 - 0
RedAnt ERP Mobile/common/Price Setting/SetCategoryPriceController.m

@@ -0,0 +1,325 @@
+//
+//  SetCategoryPriceController.m
+//  iSales-NPD
+//
+//  Created by Jack on 2016/10/11.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "SetCategoryPriceController.h"
+#import "const.h"
+#import "EnumSelectViewController.h"
+#import "iSalesNetwork.h"
+
+#define Percent  100
+#define Float    101
+#define NoChange 102
+
+#define NUMBERS @"0123456789.\n"
+#define NEGATIVE_NUMBERS @"0123456789.-\n"
+
+
+@interface SetCategoryPriceController ()<UITextFieldDelegate>
+
+@property (strong, nonatomic) IBOutlet UIButton *basePriceButton;
+@property (strong, nonatomic) IBOutlet UIButton *floatCheckButton;
+@property (strong, nonatomic) IBOutlet UIButton *percentageCheckButton;
+@property (strong, nonatomic) IBOutlet UITextField *floatTextField;
+@property (strong, nonatomic) IBOutlet UITextField *percentageTextField;
+
+@property (nonatomic,assign) NSInteger changePrice;
+@property (nonatomic,assign) NSInteger priceType;
+
+@end
+
+@implementation SetCategoryPriceController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    self.changePrice = NoChange;
+    self.basePriceButton.enabled = NO;
+    [self configAppearance];
+    
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (void)configAppearance {
+    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                                                   style:UIBarButtonItemStylePlain
+                                                                  target:self
+                                                                  action:@selector( returnBackClick:)];
+    
+    self.navigationItem.leftBarButtonItem = backButton;
+    
+    // base price
+//    NSString *basePrice = [self.categoryPrice objectForKey:@"base_price"];
+//    [self changePriceType:basePrice.integerValue];
+    [self changePriceType:1];
+    
+    // discount
+    NSString *discount = [self.categoryPrice objectForKey:@"price_discount"];
+    if ([discount hasSuffix:@"%"]) {
+        self.percentageTextField.text = [discount substringToIndex:discount.length - 1];
+    } else {
+        self.floatTextField.text = discount;
+    }
+
+}
+
+- (void)returnBackClick:(id)sender {
+    
+    [self.navigationController popViewControllerAnimated:YES];
+}
+
+- (void)changePriceType:(NSInteger)type {
+    
+    NSString *title = [Singleton sharedInstance].deliveryString;
+    switch (type) {
+        case 0: {
+            title = [Singleton sharedInstance].deliveryString;
+        }
+            break;
+        case 1: {
+            title = flat_price;
+        }
+            break;
+            
+        default:
+            break;
+    }
+    
+    self.priceType = type;
+    [self.basePriceButton setTitle:title forState:UIControlStateNormal];
+    
+}
+
+
+- (NSString *)checkPriceType:(NSInteger)priceType {
+    return  self.priceType == priceType ? @"1" : @"0";
+}
+
+- (NSInteger)checkedCadedate:(NSDictionary *)cadedate {
+    
+    int priceType = 0;
+    int count = [[cadedate objectForKey:@"count"] intValue];
+    for (int i = 0; i < count; i++) {
+        NSDictionary *dic = [cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
+        int check = [[dic objectForKey:@"check"] intValue];
+        if (check) {
+            
+            priceType = [[dic objectForKey:@"value_code"] integerValue];
+            
+            break;
+        }
+    }
+    
+    return priceType;
+}
+
+
+- (IBAction)basePriceButtonClick:(UIButton *)sender {
+    
+    EnumSelectViewController* enumvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"EnumSelectorViewController"];
+    
+    enumvc.max_select = 1;
+    
+    
+    enumvc.cadedate = @{
+                        @"count" : @"2",
+                        @"val_0" : @{@"value" : [Singleton sharedInstance].deliveryString,@"value_code" : @"0",@"check" : [self checkPriceType:0]},
+                        @"val_1" : @{@"value" : flat_price,@"value_code" : @"1",@"check" : [self checkPriceType:1]}
+                        }.mutableCopy;
+    enumvc.title = @"";
+    
+    
+    enumvc.single_select =true;
+    
+    __weak typeof(self) weakSelf = self;
+    
+    enumvc.returnValue = ^(NSMutableDictionary* value){
+        
+        if (weakSelf) {
+            __strong typeof(weakSelf) strongSelf = weakSelf;
+            [strongSelf changePriceType:[strongSelf checkedCadedate:value]];
+        }
+        
+    };
+    
+    [self.navigationController pushViewController:enumvc animated:true];
+}
+
+- (IBAction)percentageCheckButtonClick:(UIButton *)sender {
+    
+    
+    if (self.changePrice == NoChange || self.changePrice == Percent) {
+        sender.selected = !sender.selected;
+        if (sender.selected) {
+            self.changePrice = Percent;
+        } else {
+            self.changePrice = NoChange;
+        }
+    } else if (self.changePrice == Float) {
+        sender.selected = YES;
+        self.changePrice = Percent;
+        self.floatCheckButton.selected = NO;
+        self.floatTextField.enabled = NO;
+    }
+    
+    self.percentageTextField.enabled = sender.selected;
+    
+}
+
+- (IBAction)floatCheckButtonClick:(UIButton *)sender {
+    
+    if (self.changePrice == NoChange || self.changePrice == Float) {
+        sender.selected = !sender.selected;
+        if (sender.selected) {
+            self.changePrice = Float;
+        } else {
+            self.changePrice = NoChange;
+        }
+        
+    } else if (self.changePrice == Percent) {
+        sender.selected = YES;
+        self.changePrice = Float;
+        self.percentageCheckButton.selected = NO;
+        self.percentageTextField.enabled = NO;
+    }
+    self.floatTextField.enabled = sender.selected;
+}
+- (IBAction)saveButtonClick:(UIButton *)sender {
+    
+    // 向服务器提交数据
+    // http://192.168.0.126:8080/site/isales/setSeeGivenPrice.htm
+    
+    NSString *discount = @"";
+    BOOL rightDiscount = YES;
+    switch (self.changePrice) {
+        case Float:{
+            discount = self.floatTextField.text;
+            if (!discount || !discount.length) {
+                rightDiscount = NO;
+            }
+        }
+            break;
+        case Percent:{
+            discount = [self.percentageTextField.text stringByAppendingString:@"%"];
+            if (!discount || discount.length <= 1) {
+                rightDiscount = NO;
+            }
+        }
+            break;
+    
+        default:
+            break;
+    }
+    
+    
+    if (rightDiscount) {
+        
+        UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Set Price"];
+        
+        NSDictionary *dic = [iSalesNetwork set_npd_shop_givenPrice:@{@"base_price" : [NSString stringWithFormat:@"%d",self.priceType],@"discount" : discount,@"category_id" : @(self.categoryID)}.mutableCopy];
+        
+        [waitalert dismissWithClickedButtonIndex:0 animated:YES];
+        
+        if ([[dic objectForKey:@"result"] integerValue] == 2) {
+            
+            [self.categoryPrice setObject:[NSString stringWithFormat:@"%d",self.priceType] forKey:@"base_price"];
+            [self.categoryPrice setObject:discount forKey:@"price_discount"];
+            
+            // 将数据返回
+            if (self.returnBlock)
+                self.returnBlock(self.categoryPrice);
+        }
+        
+        [self.navigationController popViewControllerAnimated:YES];
+        
+    } else {
+        
+        [RAUtils message_alert:@"Please write a correct value" title:@"Warning" controller:self];
+        
+    }
+    
+}
+
+#pragma mark - text field delegate
+
+- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
+    
+    NSString *newText = [textField.text stringByReplacingCharactersInRange:range withString:string];
+    
+    if (newText.length == 0)
+        return YES;
+
+//    // 第一个字符不能为小数点
+//    if ([newText isEqualToString:@"."])
+//        return NO;
+//    if ([newText componentsSeparatedByString:@"."].count > 2) {
+//        return NO;
+//    } // 不能有多个小数点
+//    
+//    // 只能第一个字符为减号
+//    if (newText.length > 1 && [string isEqualToString:@"-"]) {
+//        return NO;
+//    }
+//    // 不能为 0123
+//    if (newText.length > 1 && [newText hasPrefix:@"0"] && [newText characterAtIndex:1] != '.') {
+//        return NO;
+//    }
+//    // 不能为 -0123
+//    if (newText.length > 2 && [newText hasPrefix:@"-0"] && [newText characterAtIndex:2] != '.') {
+//        return NO;
+//    }
+//
+//    // 校验正数
+//    NSCharacterSet *cs;
+//    cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERS]invertedSet];
+//    NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs]componentsJoinedByString:@""];
+//    BOOL canChange = [string isEqualToString:filtered];
+//    
+//    if ([textField isEqual:self.floatTextField]) {
+//
+//        // 校验负数
+//        NSCharacterSet *negative_cs;
+//        
+//        negative_cs = [[NSCharacterSet characterSetWithCharactersInString:NEGATIVE_NUMBERS]invertedSet];
+//        NSString *negative_filtered = [[string componentsSeparatedByCharactersInSet:negative_cs]componentsJoinedByString:@""];
+//        
+//        BOOL negative_canChange = [string isEqualToString:negative_filtered];
+//        
+//        // 只能第一个字符为减号
+//        if ([string isEqualToString:@"-"]) {
+//            
+//            if (newText.length == 1 && [string isEqualToString:@"-"]) {
+//                negative_canChange = YES && negative_canChange;
+//            } else {
+//                negative_canChange = NO;
+//            }
+//        }
+//
+//        
+//        return canChange || negative_canChange;
+//    } else {
+//        return canChange;
+//    }
+    
+
+    // 正则表达式
+    NSString *match = @"-[1-9]{1,1}[0-9]*(\\.[0-9]*)?|-0\\.[0-9]+|[1-9]{1,1}[0-9]*(\\.[0-9]*)?|0\\.[0-9]{0,}|0{1,1}|-{1,1}|-0{1,1}|-0\\.{1,1}";
+    
+    if ([textField isEqual:self.percentageTextField])
+        match = @"[1-9]{1,1}[0-9]*(\\.[0-9]*)?|0(\\.[0-9]*)?";
+    
+    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",match];
+    
+        return [predicate evaluateWithObject:newText];
+}
+
+@end

+ 48 - 0
RedAnt ERP Mobile/common/Singleton.h

@@ -0,0 +1,48 @@
+//
+//  Singleton.h
+//  iSales-NPD
+//
+//  Created by Jack on 2016/10/12.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <sqlite3.h>
+
+@interface Singleton : NSObject
+
+typedef enum {
+    Shop_Order = 0,
+    Sales_Order = 1
+}Customer_Oder_Type;
+
+@property (nonatomic,assign) sqlite3 *currentDB;///<当前打开的数据库
+
+#pragma mark - Customer
+
+@property (nonatomic,assign) BOOL permissions_price_setting;///<价格设置权限
+@property (nonatomic,assign) BOOL permissions_edit_order;///<编辑订单权限,Place Order
+@property (nonatomic,assign) BOOL permissions_submit_order;///<提交订单权限
+@property (nonatomic,assign) BOOL permissions_merge_order;///<合并订单权限
+@property (nonatomic,assign) NSInteger npd_shop_price_type;///<Shop设置的价格类型,0提货价、1统一卖价、 2计算价
+@property (nonatomic,  copy) NSString *deliveryString;///<登陆成功后接收的提货价名称
+// 使用枚举吗?Customer_Oder_Type
+@property (nonatomic,assign) NSInteger customer_order_type;///< 0 Shop Order/ 1 Sales Order,
+@property (nonatomic,assign) BOOL global_lock;///<全局锁,Yes表示订单不能查看Detail,需要密码验证Price Setting,Hide Price
+@property (nonatomic,assign) BOOL customer_can_see_sales_Order;///<是否有权查看Sales Order,控制Order List
+@property (nonatomic,strong) NSMutableDictionary *shop_order_status_filter;///<Shop Order Status
+@property (nonatomic,  copy) NSString *specialInstruction;///<登陆时传的Special Instruction,在提交订单时显示
+@property (nonatomic,assign) BOOL currentOrderIsMerged;///<当前打开的订单是否为Purchas Order
+@property (nonatomic,  copy) NSString *customer_email;///<Customer邮箱地址,登录时保存
+
+#pragma mark - Employee
+
+
+
+#pragma mark - Method
+
++ (instancetype)sharedInstance;
+
+- (void)resetGlobalLock;
+
+@end

+ 36 - 0
RedAnt ERP Mobile/common/Singleton.m

@@ -0,0 +1,36 @@
+//
+//  Singleton.m
+//  iSales-NPD
+//
+//  Created by Jack on 2016/10/12.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "Singleton.h"
+#import "NotificationNameCenter.h"
+
+@implementation Singleton
+
++ (instancetype)sharedInstance {
+    static Singleton *singleton = nil;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        singleton = [[Singleton alloc] init];
+    });
+    return singleton;
+}
+
+- (void)setGlobal_lock:(BOOL)global_lock {
+    _global_lock = global_lock;
+    if (global_lock) {
+        [[NSNotificationCenter defaultCenter] postNotificationName:Lock_Permission_Notification object:nil];
+    } else {
+        [[NSNotificationCenter defaultCenter] postNotificationName:unLock_Permission_Notification object:nil];
+    }
+}
+
+- (void)resetGlobalLock {
+    _global_lock = YES;
+}
+
+@end

+ 19 - 0
RedAnt ERP Mobile/common/UIColor+HEX/UIColor+JK_HEX.h

@@ -0,0 +1,19 @@
+//
+//  UIColor+JK_HEX.h
+//  chemistry2048
+//
+//  Created by emerys on 16/4/19.
+//  Copyright © 2016年 Emerys. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface UIColor (JK_HEX)
+
++ (instancetype)colorWithHEX:(NSInteger)hex;
+
++ (instancetype)colorWithHEX:(NSInteger)hex alpha:(CGFloat)alpha;
+
++ (instancetype)colorWithHEXString:(NSString *)hexString;
+
+@end

+ 37 - 0
RedAnt ERP Mobile/common/UIColor+HEX/UIColor+JK_HEX.m

@@ -0,0 +1,37 @@
+//
+//  UIColor+JK_HEX.m
+//  chemistry2048
+//
+//  Created by emerys on 16/4/19.
+//  Copyright © 2016年 Emerys. All rights reserved.
+//
+
+#import "UIColor+JK_HEX.h"
+
+@implementation UIColor (JK_HEX)
+
++ (instancetype)colorWithHEX:(NSInteger)hex{
+    return [UIColor colorWithRed:((hex & 0xff0000) >> 16) / 255.0 green:((hex & 0xff00) >> 8) / 255.0 blue:(hex & 0xff) / 255.0 alpha:1];
+}
+
++ (instancetype)colorWithHEX:(NSInteger)hex alpha:(CGFloat)alpha {
+    if (alpha > 1) {
+        alpha = 1 / alpha;
+    }
+    return [UIColor colorWithRed:((hex & 0xff0000) >> 16) / 255.0 green:((hex & 0xff00) >> 8) / 255.0 blue:(hex & 0xff) / 255.0 alpha:alpha];
+}
+
++ (instancetype)colorWithHEXString:(NSString *)hexString{
+    if ([hexString hasPrefix:@"#"]) {
+        hexString = [hexString stringByReplacingOccurrencesOfString:@"#" withString:@"0x"];
+    }
+    
+    if (![hexString hasPrefix:@"0x"]) {
+        return nil;
+    }
+    
+    NSInteger hex = strtoul([hexString UTF8String],0,16);
+    return [self colorWithHEX:hex];
+}
+
+@end

+ 5 - 4
RedAnt ERP Mobile/common/data_provider/iSalesNetwork.m

@@ -2381,6 +2381,7 @@ repeat:
     ////        [appDelegate update_count_mark];
     //    }
     return jsobj;
+
 }
 +(NSDictionary*) download_Offline:(NSString* )vid
 {
@@ -2679,7 +2680,7 @@ repeat:
 +(NSDictionary*)Category_addall: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword  offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip orderCode:(NSString*) orderCode addTo:(NSString*) addTo
 
 {
-    
+
     
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
     
@@ -2757,7 +2758,7 @@ repeat:
     NSError *error=nil;
     NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
     return jsobj;
-    
+
 }
 //+(NSDictionary*)category_addall2portfolio: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword  offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip
 //{
@@ -2915,7 +2916,7 @@ repeat:
 +(NSDictionary*)Search_addall:(long ) offset limit :(long)limit keywords :(NSString*) keywords matchfull:(bool)matchfull orderCode:(NSString*) orderCode  addTo:(NSString*) addTo
 {
     
-    
+
     
     
     NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
@@ -2981,6 +2982,7 @@ repeat:
     NSError *error=nil;
     NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
     return jsobj;
+
 }
 +(NSDictionary*)Search:(long ) offset limit :(long)limit keywords :(NSString*) keywords matchfull:(bool)matchfull
 {
@@ -3027,7 +3029,6 @@ repeat:
 }
 +(NSDictionary*)ItemSearch_addall:(long ) offset limit :(long)limit covertype:(NSString* ) covertype ctgid:(NSString*)ctgid modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller orderCode:(NSString*) orderCode addTo:(NSString*) addTo
 {
-    
     // for debug
     //    return [RAUtils error_json:RESULT_NET_ERROR err_msg:nil];
     //return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];

+ 19 - 0
RedAnt ERP Mobile/common/sort/SortButton.h

@@ -0,0 +1,19 @@
+//
+//  SortButton.h
+//  iSales-NPD
+//
+//  Created by Jack on 16/9/6.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface SortButton : UIControl
+
+@property (nonatomic,strong) UILabel *titleLabel;
+
+@property (nonatomic,strong) UIImageView *imageView;
+
++ (SortButton*)sortButtonWithHeight:(CGFloat)height;
+
+@end

+ 73 - 0
RedAnt ERP Mobile/common/sort/SortButton.m

@@ -0,0 +1,73 @@
+//
+//  SortButton.m
+//  iSales-NPD
+//
+//  Created by Jack on 16/9/6.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "SortButton.h"
+
+@implementation SortButton
+
+- (instancetype)initWithFrame:(CGRect)frame {
+    if (self = [super initWithFrame:frame]) {
+        [self addSubview:self.titleLabel];
+        [self addSubview:self.imageView];
+    }
+    return self;
+}
+
++ (SortButton*)sortButtonWithHeight:(CGFloat)height {
+    SortButton *btn = [[SortButton alloc] initWithFrame:CGRectMake(10, 0, 85, height)];
+    
+    return btn;
+}
+
+- (UILabel *)titleLabel {
+    if (!_titleLabel) {
+        CGSize size = [self string:@"sort by" sizeWithSize:CGSizeMake(60, 22) font:[UIFont systemFontOfSize:17]];
+        CGFloat h = CGRectGetHeight(self.bounds);
+        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, (h - size.height) / 2, size.width, size.height)];
+        _titleLabel.font = [UIFont systemFontOfSize:17];
+        _titleLabel.textColor = [UIColor blackColor];
+        _titleLabel.text = @"Sort By";
+        [_titleLabel sizeToFit];
+        
+    }
+    return _titleLabel;
+}
+
+- (UIImageView *)imageView {
+    if (!_imageView) {
+        CGFloat h = CGRectGetHeight(self.bounds);
+        CGFloat x = CGRectGetMaxX(self.titleLabel.frame) + 5;
+        CGFloat y = (h - 22) / 2;
+        
+        _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, 22, 22)];
+        _imageView.image = [UIImage imageNamed:@"DX_22"];
+        
+        _imageView.userInteractionEnabled = YES;
+        
+        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickImageView:)];
+        [_imageView addGestureRecognizer:tap];
+    }
+    return _imageView;
+}
+
+-(CGSize)string:(NSString *)string sizeWithSize:(CGSize)size font:(UIFont *)font{
+    NSDictionary *attribute = @{NSFontAttributeName: font};
+    
+    CGSize resSize = [string boundingRectWithSize:size
+                                        options:(NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading)
+                                     attributes:attribute
+                                        context:nil].size;
+    
+    return resSize;
+}
+
+- (void)clickImageView:(id)recognizer {
+    [self sendActionsForControlEvents:UIControlEventTouchUpInside];
+}
+
+@end

+ 23 - 0
RedAnt ERP Mobile/common/sort/SortItemCell.h

@@ -0,0 +1,23 @@
+//
+//  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;
+
+@property (nonatomic,assign) NSInteger sortIndex;
+
+@end

+ 122 - 0
RedAnt ERP Mobile/common/sort/SortItemCell.m

@@ -0,0 +1,122 @@
+//
+//  SortItemCell.m
+//  iSales-NPD
+//
+//  Created by Jack on 16/9/5.
+//  Copyright © 2016年 United Software Applications, Inc. All rights reserved.
+//
+
+#import "SortItemCell.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];
+        self.sortIndex = YES;
+    }
+    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.userInteractionEnabled = NO;
+    }
+    return _selectedView;
+}
+
+- (void)setSortTitle:(NSString *)sortTitle {
+    _sortTitle = sortTitle;
+    
+    self.sortTitleLabel.text = sortTitle;
+   
+}
+
+- (void)setSelectedSort:(BOOL)selectedSort {
+    _selectedSort = selectedSort;
+
+    self.selectedView.selected = selectedSort;
+}
+
+- (void)setSortIndex:(NSInteger)sortIndex {
+    _sortIndex = sortIndex;
+    
+    NSString *selectedImageName = @"";
+    switch (sortIndex) {
+        case 0:{
+            selectedImageName = @"TX_18";
+        }
+            break;
+        case 1:{
+            selectedImageName = @"TS_18";
+        }
+            break;
+        case 2:{
+            selectedImageName = @"IX_18";
+        }
+            break;
+        case 3:{
+            selectedImageName = @"IS_18";
+        }
+            break;
+        case 4:{
+            selectedImageName = @"DX_18";
+        }
+            break;
+            
+        default:
+            break;
+    }
+    [self.selectedView setImage:[UIImage imageNamed:selectedImageName] forState:UIControlStateSelected];
+}
+
+
+@end

+ 21 - 0
RedAnt ERP Mobile/common/sort/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

+ 157 - 0
RedAnt ERP Mobile/common/sort/SortItemViewController.m

@@ -0,0 +1,157 @@
+//
+//  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.
+}
+
+#pragma mark - view
+
+- (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 = @"Last";
+        }
+            break;
+        case 1:{
+            cell.sortTitle = @"First";
+        }
+            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;
+    }
+    cell.sortIndex = indexPath.row;
+    
+//    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