Przeglądaj źródła

Scan order 1.07

Ray Zhang 3 lat temu
rodzic
commit
1cf2d80b17
40 zmienionych plików z 2420 dodań i 686 usunięć
  1. 16 4
      RedAnt ERP Mobile/HMLG Scan Order.xcodeproj/project.pbxproj
  2. 1 1
      RedAnt ERP Mobile/HMLG Scan Order.xcodeproj/xcuserdata/ruizhang.xcuserdatad/xcschemes/xcschememanagement.plist
  3. 23 0
      RedAnt ERP Mobile/HMLG Scan Order/Images.xcassets/camera_s.imageset/Contents.json
  4. BIN
      RedAnt ERP Mobile/HMLG Scan Order/Images.xcassets/camera_s.imageset/appicon-1.png
  5. BIN
      RedAnt ERP Mobile/HMLG Scan Order/Images.xcassets/camera_s.imageset/appicon-2.png
  6. BIN
      RedAnt ERP Mobile/HMLG Scan Order/Images.xcassets/camera_s.imageset/appicon.png
  7. BIN
      RedAnt ERP Mobile/HMLG Scan Order/Images.xcassets/wishlist.imageset/appicon-1.png
  8. BIN
      RedAnt ERP Mobile/HMLG Scan Order/Images.xcassets/wishlist.imageset/appicon-2.png
  9. BIN
      RedAnt ERP Mobile/HMLG Scan Order/Images.xcassets/wishlist.imageset/appicon.png
  10. 106 0
      RedAnt ERP Mobile/HMLG Scan Order/MainViewController.m
  11. 269 106
      RedAnt ERP Mobile/HMLG Scan Order/SO.storyboard
  12. 29 0
      RedAnt ERP Mobile/HMLG Scan Order/ScanDiscountViewController.h
  13. 80 0
      RedAnt ERP Mobile/HMLG Scan Order/ScanDiscountViewController.m
  14. 2 1
      RedAnt ERP Mobile/HMLG Scan Order/ScanListCell.m
  15. 80 76
      RedAnt ERP Mobile/HMLG Scan Order/ScanOrderModelListViewController.m
  16. 1 1
      RedAnt ERP Mobile/HMLG Scan Order/ScanSearchViewController.m
  17. 2 2
      RedAnt ERP Mobile/HMLG Scan Order/ServerSettingViewController.m
  18. 2 1
      RedAnt ERP Mobile/HMLG Scan Order/SetupServerViewController.m
  19. 22 0
      RedAnt ERP Mobile/HMLG Scan Order/StockTableViewCell.h
  20. 24 0
      RedAnt ERP Mobile/HMLG Scan Order/StockTableViewCell.m
  21. 24 0
      RedAnt ERP Mobile/HMLG Scan Order/StockViewController.h
  22. 342 0
      RedAnt ERP Mobile/HMLG Scan Order/StockViewController.m
  23. 2 2
      RedAnt ERP Mobile/HMLG Scan Order/config.h
  24. 5 0
      RedAnt ERP Mobile/common/AppDelegateBase.h
  25. 72 80
      RedAnt ERP Mobile/common/Functions/OLO/ScanOrderListViewController.m
  26. 3 1
      RedAnt ERP Mobile/common/Functions/camscan/ScannerViewController.m
  27. 278 119
      RedAnt ERP Mobile/common/Functions/cart/CartViewController.m
  28. 1 0
      RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.h
  29. 2 2
      RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m
  30. 810 270
      RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m
  31. 1 1
      RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m
  32. 1 1
      RedAnt ERP Mobile/common/const.h
  33. 2 2
      RedAnt ERP Mobile/common/customUI/ImageUploadViewController.m
  34. 4 0
      RedAnt ERP Mobile/common/data_provider/RADataProvider.h
  35. 168 2
      RedAnt ERP Mobile/common/data_provider/RADataProvider.m
  36. 2 2
      RedAnt ERP Mobile/common/data_provider/RANetwork.m
  37. 1 1
      RedAnt ERP Mobile/iSales-CONTRAST.xcodeproj/xcuserdata/ruizhang.xcuserdatad/xcschemes/xcschememanagement.plist
  38. 13 4
      common/customUI/CommonEditoriPad/iPadCommonEditorCellModel.xib
  39. 1 0
      common/customUI/commoneditor/CommonEditorCellModel.h
  40. 31 7
      common/customUI/commoneditor/CommonEditorViewController.m

+ 16 - 4
RedAnt ERP Mobile/HMLG Scan Order.xcodeproj/project.pbxproj

@@ -85,6 +85,8 @@
 		3C9F81D427F6E04300B4C511 /* SetupServerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C9F81D327F6E04300B4C511 /* SetupServerViewController.m */; };
 		3C9F81D727F831A500B4C511 /* ScanServerListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C9F81D627F831A500B4C511 /* ScanServerListViewController.m */; };
 		3CABBF122836224500FA3352 /* guest.json in Resources */ = {isa = PBXBuildFile; fileRef = 3CABBF112836224400FA3352 /* guest.json */; };
+		3CABE0202861A51F00CF0DC1 /* StockViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CABE01F2861A51E00CF0DC1 /* StockViewController.m */; };
+		3CABE0232861A5E000CF0DC1 /* StockTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CABE0222861A5E000CF0DC1 /* StockTableViewCell.m */; };
 		3CC1122B279163F4004ACA57 /* offline_order_new_contact.json in Resources */ = {isa = PBXBuildFile; fileRef = 3CC1122A279163F4004ACA57 /* offline_order_new_contact.json */; };
 		3CD54A79282CF21D0073A15D /* ScanHomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CD54A78282CF21D0073A15D /* ScanHomeViewController.m */; };
 		3CD54A7C282CF4930073A15D /* ScanHomeCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CD54A7B282CF4930073A15D /* ScanHomeCell.m */; };
@@ -470,6 +472,10 @@
 		3C9F81D527F831A500B4C511 /* ScanServerListViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScanServerListViewController.h; sourceTree = "<group>"; };
 		3C9F81D627F831A500B4C511 /* ScanServerListViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScanServerListViewController.m; sourceTree = "<group>"; };
 		3CABBF112836224400FA3352 /* guest.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = guest.json; path = common/Functions/OLO/guest.json; sourceTree = SOURCE_ROOT; };
+		3CABE01E2861A51E00CF0DC1 /* StockViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StockViewController.h; sourceTree = "<group>"; };
+		3CABE01F2861A51E00CF0DC1 /* StockViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StockViewController.m; sourceTree = "<group>"; };
+		3CABE0212861A5E000CF0DC1 /* StockTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StockTableViewCell.h; sourceTree = "<group>"; };
+		3CABE0222861A5E000CF0DC1 /* StockTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StockTableViewCell.m; sourceTree = "<group>"; };
 		3CC1122A279163F4004ACA57 /* offline_order_new_contact.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = offline_order_new_contact.json; path = common/Functions/contact/offline_order_new_contact.json; sourceTree = SOURCE_ROOT; };
 		3CD54A77282CF21D0073A15D /* ScanHomeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScanHomeViewController.h; sourceTree = "<group>"; };
 		3CD54A78282CF21D0073A15D /* ScanHomeViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ScanHomeViewController.m; sourceTree = "<group>"; };
@@ -1093,6 +1099,10 @@
 				3CD54A7B282CF4930073A15D /* ScanHomeCell.m */,
 				3C2D0481285B242800423D97 /* ScanDiscountViewController.h */,
 				3C2D0482285B242800423D97 /* ScanDiscountViewController.m */,
+				3CABE01E2861A51E00CF0DC1 /* StockViewController.h */,
+				3CABE01F2861A51E00CF0DC1 /* StockViewController.m */,
+				3CABE0212861A5E000CF0DC1 /* StockTableViewCell.h */,
+				3CABE0222861A5E000CF0DC1 /* StockTableViewCell.m */,
 			);
 			name = OLO;
 			sourceTree = "<group>";
@@ -2379,6 +2389,7 @@
 				715F30BD1DAB37EB00490EED /* OfflineUnlockViewController.m in Sources */,
 				7162A5161C58704600AB630E /* BundleModelCell.m in Sources */,
 				42DC12F11F0CD98E00A4C011 /* OrderDetailPickInfoCell.m in Sources */,
+				3CABE0232861A5E000CF0DC1 /* StockTableViewCell.m in Sources */,
 				3C51494A273D095900F78617 /* CommonEditorCellEdit.m in Sources */,
 				7141DD621C5747CE00F7DF59 /* NSData+CommonCrypto.m in Sources */,
 				712AFED71DBA050200254965 /* BasicDrawable.m in Sources */,
@@ -2465,6 +2476,7 @@
 				3C9F81D427F6E04300B4C511 /* SetupServerViewController.m in Sources */,
 				71D01B1A1E0A2055006620CE /* ImageUtils.m in Sources */,
 				3CF33C8F27BF4A3D001CBEEC /* RAQRCodeScannerViewController.m in Sources */,
+				3CABE0202861A51F00CF0DC1 /* StockViewController.m in Sources */,
 				7141DD521C57459B00F7DF59 /* qrinput.c in Sources */,
 				7162A5601C58724700AB630E /* CustomerEditViewController.m in Sources */,
 				7162A5DC1C5876E300AB630E /* LoginViewController.m in Sources */,
@@ -2701,7 +2713,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 51139;
+				CURRENT_PROJECT_VERSION = 51205;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -2718,7 +2730,7 @@
 					"$(PROJECT_DIR)/ScanApiSDK-10.2.227-2/lib",
 					"$(PROJECT_DIR)/GoogleAnalytics/GoogleAnalytics/Libraries",
 				);
-				MARKETING_VERSION = 1.06;
+				MARKETING_VERSION = 1.07;
 				OTHER_LDFLAGS = (
 					"$(inherited)",
 					"-ObjC",
@@ -2745,7 +2757,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 51139;
+				CURRENT_PROJECT_VERSION = 51205;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -2762,7 +2774,7 @@
 					"$(PROJECT_DIR)/ScanApiSDK-10.2.227-2/lib",
 					"$(PROJECT_DIR)/GoogleAnalytics/GoogleAnalytics/Libraries",
 				);
-				MARKETING_VERSION = 1.06;
+				MARKETING_VERSION = 1.07;
 				OTHER_LDFLAGS = (
 					"$(inherited)",
 					"-ObjC",

+ 1 - 1
RedAnt ERP Mobile/HMLG Scan Order.xcodeproj/xcuserdata/ruizhang.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -7,7 +7,7 @@
 		<key>HMLG Scan Order.xcscheme_^#shared#^_</key>
 		<dict>
 			<key>orderHint</key>
-			<integer>1</integer>
+			<integer>7</integer>
 		</dict>
 	</dict>
 </dict>

+ 23 - 0
RedAnt ERP Mobile/HMLG Scan Order/Images.xcassets/camera_s.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "filename" : "appicon.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "appicon-1.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "appicon-2.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
RedAnt ERP Mobile/HMLG Scan Order/Images.xcassets/camera_s.imageset/appicon-1.png


BIN
RedAnt ERP Mobile/HMLG Scan Order/Images.xcassets/camera_s.imageset/appicon-2.png


BIN
RedAnt ERP Mobile/HMLG Scan Order/Images.xcassets/camera_s.imageset/appicon.png


BIN
RedAnt ERP Mobile/HMLG Scan Order/Images.xcassets/wishlist.imageset/appicon-1.png


BIN
RedAnt ERP Mobile/HMLG Scan Order/Images.xcassets/wishlist.imageset/appicon-2.png


BIN
RedAnt ERP Mobile/HMLG Scan Order/Images.xcassets/wishlist.imageset/appicon.png


+ 106 - 0
RedAnt ERP Mobile/HMLG Scan Order/MainViewController.m

@@ -607,6 +607,107 @@
     self.btnsearch.selected = false;
     self.btnsetting.selected = false;
 }
+- (void)of_test
+{
+    NSString* str =@"[\"5688\",\"5808-68\",\"DINING TBL, ACACIA VNER\",\"1\",\"123.45\",\"123.45\",\"123.45\",\"123.45\",\"123.45\",\"1\",\"10.96\",\"viet\",\"vcsf\",\"42 X 68 x 30.5H\",\"234.56\"]";
+    NSDictionary* item = [RAConvertor string2dict:str];
+    NSMutableDictionary* of = [NSMutableDictionary new];
+    for(int i=0;i<4000;i++)
+    {
+        of[[NSString stringWithFormat:@"model_%d",i]]=item;
+    }
+    
+    NSString* strof=[RAConvertor dict2string:of];
+    
+    
+           NSString* str2 = [AESCrypt encrypt:strof password:@"usai2010"];
+            NSString * str3 = [AESCrypt decrypt:str2 password:@"usai2010"];
+    
+    NSString * str123 = [AESCrypt decrypt:@"706dZ9zTqNPauH3j2S7MQg==" password:@"usai"];
+//    NSString * str333 = [AESCrypt decrypt:@"RQtrNBCGKxNq6Bk5QGkPiw==" password:@"usai2010\0\0\0\0\0\0\0\0"];
+//    NSString * str33 = [AESCrypt decrypt:@"0s0+JiC2ZzoDiBGQaCnT1g==" password:@"usai2010"];
+    
+    
+    [self sortedDictionary:of];
+    
+    NSDictionary* test1 = of[@"model_1234"];
+    NSDictionary* test2 = of[@"model_9876"];
+    NSDictionary* test3 = of[@"model_4567"];
+    NSDictionary* test4 = of[@"model_7654"];
+    
+    [self of_search:of keyword:@"12"];
+    
+    
+}
+/**
+ 对字典(Key-Value)排序 区分大小写
+
+ @param dict 要排序的字典
+ */
+- (void)sortedDictionary:(NSDictionary *)dict{
+    
+    //将所有的key放进数组
+    NSArray *allKeyArray = [dict allKeys];
+    
+    //序列化器对数组进行排序的block 返回值为排序后的数组
+    NSArray *afterSortKeyArray = [allKeyArray sortedArrayUsingComparator:^NSComparisonResult(id  _Nonnull obj1, id
+    _Nonnull obj2) {
+        /**
+          In the compare: methods, the range argument specifies the
+          subrange, rather than the whole, of the receiver to use in the
+          comparison. The range is not applied to the search string.  For
+          example, [@"AB" compare:@"ABC" options:0 range:NSMakeRange(0,1)]
+          compares "A" to "ABC", not "A" to "A", and will return
+          NSOrderedAscending. It is an error to specify a range that is
+          outside of the receiver's bounds, and an exception may be raised.
+         
+        - (NSComparisonResult)compare:(NSString *)string;
+         
+         compare方法的比较原理为,依次比较当前字符串的第一个字母:
+         如果不同,按照输出排序结果
+         如果相同,依次比较当前字符串的下一个字母(这里是第二个)
+         以此类推
+         
+         排序结果
+         NSComparisonResult resuest = [obj1 compare:obj2];为从小到大,即升序;
+         NSComparisonResult resuest = [obj2 compare:obj1];为从大到小,即降序;
+         
+         注意:compare方法是区分大小写的,即按照ASCII排序
+         */
+        //排序操作
+        NSComparisonResult resuest = [obj1 compare:obj2];
+        return resuest;
+    }];
+    NSLog(@"afterSortKeyArray:%@",afterSortKeyArray);
+    
+    //通过排列的key值获取value
+    NSMutableArray *valueArray = [NSMutableArray array];
+    for (NSString *sortsing in afterSortKeyArray) {
+        NSString *valueString = [dict objectForKey:sortsing];
+        [valueArray addObject:valueString];
+    }
+    NSLog(@"valueArray:%@",valueArray);
+}
+-(void)of_search:(NSMutableDictionary*) dict keyword:(NSString*)keyword
+{
+    NSMutableArray* arr = [NSMutableArray new];
+    
+    NSArray* keys=[dict allKeys];
+    
+    for(int i=0;i<keys.count;i++)
+    {
+        NSString* key = keys[i];
+        if([key containsString:keyword])
+        {
+            [arr addObject:dict[key]];
+        }
+        
+        
+    }
+    
+    int a=0;
+    
+}
 - (void)viewDidLoad
 {
     
@@ -615,6 +716,11 @@
 //    NSLog(@"decrypt:%@",[AESCrypt fastdecrypt:@"vafHUwfRPIUbPNVnKhLc5aAVK7sOFRztlfJVRHW7QVa/qGgm11E5UwfYWZEBTQpH"]);
  
     
+//    [self of_test];
+    
+    
+    [RADataProvider load_scan_models];
+    
     [self.btncart setBackgroundImage:[UIImage imageNamed:@"btn_bg"] forState:UIControlStateSelected];
     [self.btnorder setBackgroundImage:[UIImage imageNamed:@"btn_bg"] forState:UIControlStateSelected];
     [self.btnlist setBackgroundImage:[UIImage imageNamed:@"btn_bg"] forState:UIControlStateSelected];

Plik diff jest za duży
+ 269 - 106
RedAnt ERP Mobile/HMLG Scan Order/SO.storyboard


+ 29 - 0
RedAnt ERP Mobile/HMLG Scan Order/ScanDiscountViewController.h

@@ -0,0 +1,29 @@
+//
+//  ScanDiscountViewController.h
+//  HMLG Scan Order
+//
+//  Created by Rui Zhang on 6/16/22.
+//  Copyright © 2022 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface ScanDiscountViewController : UIViewController
+@property  double price;
+
+@property  double discount;
+
+@property (strong,nonatomic) NSString* cart_id;
+
+@property (weak, nonatomic) IBOutlet UIButton *btn3;
+@property (weak, nonatomic) IBOutlet UIButton *btnnone;
+@property (weak, nonatomic) IBOutlet UIButton *btn5;
+@property (weak, nonatomic) IBOutlet UIButton *btn8;
+@property (weak, nonatomic) IBOutlet UIButton *btn10;
+
+@property (nonatomic , copy) void (^onSetValue)(double price,double discount);
+@end
+
+NS_ASSUME_NONNULL_END

+ 80 - 0
RedAnt ERP Mobile/HMLG Scan Order/ScanDiscountViewController.m

@@ -0,0 +1,80 @@
+//
+//  ScanDiscountViewController.m
+//  HMLG Scan Order
+//
+//  Created by Rui Zhang on 6/16/22.
+//  Copyright © 2022 United Software Applications, Inc. All rights reserved.
+//
+
+#import "ScanDiscountViewController.h"
+
+@interface ScanDiscountViewController ()
+
+@end
+
+@implementation ScanDiscountViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    
+    
+    // Do any additional setup after loading the view.
+}
+
+-(void) updatebtn:(UIButton*)btn
+{
+    self.btn3.backgroundColor = UIColor.clearColor;
+    self.btn5.backgroundColor = UIColor.clearColor;
+    self.btn8.backgroundColor = UIColor.clearColor;
+    self.btn10.backgroundColor = UIColor.clearColor;
+    self.btnnone.backgroundColor = UIColor.clearColor;
+    btn.backgroundColor =UIColor.redColor;
+    
+}
+- (IBAction)onCancel:(id)sender {
+    [self dismissViewControllerAnimated:NO
+                             completion:^{
+                                 
+                                 
+                             }];
+}
+- (IBAction)onUpdate:(id)sender {
+    [self dismissViewControllerAnimated:NO
+                             completion:^{
+                                 if(self.onSetValue)
+                                     self.onSetValue( self.price,self.discount);
+                                 
+                             }];
+}
+- (IBAction)on3:(id)sender {
+    self.discount = 3;
+    [self updatebtn:sender];
+}
+- (IBAction)onnone:(id)sender {
+    self.discount = 0;
+    [self updatebtn:sender];
+}
+- (IBAction)on5:(id)sender {
+    self.discount = 5;
+    [self updatebtn:sender];
+}
+- (IBAction)on8:(id)sender {
+    self.discount = 8;
+    [self updatebtn:sender];
+}
+- (IBAction)on10:(id)sender {
+    self.discount = 10;
+    [self updatebtn:sender];
+}
+
+/*
+#pragma mark - Navigation
+
+// In a storyboard-based application, you will often want to do a little preparation before navigation
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+    // Get the new view controller using [segue destinationViewController].
+    // Pass the selected object to the new view controller.
+}
+*/
+
+@end

+ 2 - 1
RedAnt ERP Mobile/HMLG Scan Order/ScanListCell.m

@@ -131,7 +131,7 @@
             
         [OLDataProvider saveScanCart:RASingleton.sharedInstance.scan_cart];
 
-    [RAUtils message_alert:@"Successful" title:[NSString stringWithFormat: @"%@ added to cart",jitem[@"model"]] controller:[RAUtils getViewController:self]];
+    [RAUtils message_alert:@"Successfully" title:[NSString stringWithFormat: @"%@ added to cart",jitem[@"model"]] controller:[RAUtils getViewController:self]];
     
     
 }
@@ -233,6 +233,7 @@
     
     
     NSString * mpack=_modelJson[@"stockUom"];
+    _modelJson[@"count"]=_modelJson[@"stockUom"];
     _modelJson[@"cuft"] = @([mpack intValue]* [unit_cuft doubleValue]);
     _modelJson[@"subtotal_price"] = @([mpack intValue]* [unit_price doubleValue]);
 

+ 80 - 76
RedAnt ERP Mobile/HMLG Scan Order/ScanOrderModelListViewController.m

@@ -54,56 +54,57 @@
         iscollection = true;
     for(int i=0;i<arr.count;i++)
     {
-        NSArray* item = arr[i];
+//        NSArray* item = arr[i];
         
-        NSMutableDictionary* jitem = [NSMutableDictionary new];
+        NSMutableDictionary* jitem = [arr[i] mutableCopy];
         
         
+//
+//        NSString* pid = item[0];
+//        NSString * model =item[1];
+//        if(model.length==0)
+//            model = @"";
+//        NSString * description=item[2];
+//        if(description.length==0)
+//            description = @"";
+//
+//        NSString * dimension=item[3];
+//        if(dimension.length==0)
+//            dimension = @"N/A";
         
-        NSString* pid = item[0];
-        NSString * model =item[1];
-        if(model.length==0)
-            model = @"";
-        NSString * description=item[2];
-        if(description.length==0)
-            description = @"";
-        
-        NSString * dimension=item[3];
-        if(dimension.length==0)
-            dimension = @"N/A";
-        
-        NSString * mpack=item[4];
+        NSString * mpack=jitem[@"stockUom"];
         if(mpack.length==0)
             mpack = @"1";
         
-        NSString * unit_cuft=item[5];
+        NSString * unit_cuft=jitem[@"unit_cuft"];
         if(unit_cuft.length==0)
             unit_cuft = @"N/A";
         else
         {
             
-            unit_cuft = [NSString stringWithFormat:@"%.2f", [item[5] doubleValue]];
+            unit_cuft = [NSString stringWithFormat:@"%.2f", [jitem[@"unit_cuft"] doubleValue]];
         }
         
-        NSString * port=item[6];
-        if(port.length==0)
-            port = @"N/A";
-        
-        NSString * origin=item[7];
-        if(origin.length==0)
-            origin = @"N/A";
-        
-        NSString * available=item[8];
-        if(available.length==0)
-            available = @"N/A";
-        
-        NSString* price0;
-        NSString* price1;
-        NSString* price2;
+//        NSString * port=item[6];
+//        if(port.length==0)
+//            port = @"N/A";
+//
+//        NSString * origin=item[7];
+//        if(origin.length==0)
+//            origin = @"N/A";
+//
+//        NSString * available=item[8];
+//        if(available.length==0)
+//            available = @"N/A";
+//
+//        NSString* price0;
+//        NSString* price1;
+//        NSString* price2;
+//        NSString* price3;
         NSDictionary *addressDic = [[NSUserDefaults standardUserDefaults] valueForKey:@"ScanAddress"];
         if (addressDic) {
             
-            int price_index =[addressDic[ @"price_index"] intValue];
+            int price_index =0;//[addressDic[ @"price_index"] intValue];
     //        NSString* ia=addressDic[@"internalAddress"];
     //        NSString* ea=addressDic[@"externalAddress"];
     //        NSString* sa=addressDic[@"serverAddress"];
@@ -118,67 +119,70 @@
             
             int idx = 9+price_index;
 
-            
-            price0=item[idx];
-            if(price0.length==0)
-                price0 = @"N/A";
-            else
-                price0 = [NSString stringWithFormat:@"%.2f",[item[idx] doubleValue]];
-            
-            price1=item[idx+1];
-            if(price1.length==0)
-                price1 = @"N/A";
-            else
-                price1 = [NSString stringWithFormat:@"%.2f",[item[idx+1] doubleValue]];
-            
-            if(![price1 isEqualToString:@"N/A"])
-            {
-                price2 =  [NSString stringWithFormat:@"%.2f",[item[idx+1] doubleValue] *1.25];
-            }
-            else
-            {
-                price2 = @"N/A";
-            }
+//
+//            price0=item[idx];
+//            if(price0.length==0)
+//                price0 = @"N/A";
+//            else
+//                price0 = [NSString stringWithFormat:@"%.2f",[item[idx] doubleValue]];
+//
+//            price1=item[idx+1];
+//            if(price1.length==0)
+//                price1 = @"N/A";
+//            else
+//                price1 = [NSString stringWithFormat:@"%.2f",[item[idx+1] doubleValue]];
+//
+//            if(![price1 isEqualToString:@"N/A"])
+//            {
+//                price2 =  [NSString stringWithFormat:@"%.2f",[item[idx+1] doubleValue] *1.25];
+//            }
+//            else
+//            {
+//                price2 = @"N/A";
+//            }
         }
+//
+//
+//
+//
+//        jitem[@"product_id"]= pid;
+//        jitem[@"model"] =model;
+//        jitem[@"description"] = description;
+//
         
-        
-        
-        
-        jitem[@"product_id"]= pid;
-        jitem[@"model"] =model;
-        jitem[@"description"] = description;
-        
-        
-        
+            if(RASingleton.sharedInstance.price_type==3)
+            {
+                jitem[@"unit_price"] =jitem[@"price3"];
+            }
         if(RASingleton.sharedInstance.price_type==2)
         {
-            jitem[@"unit_price"] =price2;
+            jitem[@"unit_price"] =jitem[@"price2"];
         }
         else if(RASingleton.sharedInstance.price_type==1)
         {
-            jitem[@"unit_price"] =price1;
+            jitem[@"unit_price"] =jitem[@"price1"];
         }
         else
         {
-            jitem[@"unit_price"] =price0;
+            jitem[@"unit_price"] =jitem[@"price0"];
         }
         
-        jitem[@"price0"] =price0;
-        jitem[@"price1"] =price1;
-        jitem[@"price2"] =price2;
-        jitem[@"stockUom"] = mpack;
+//        jitem[@"price0"] =price0;
+//        jitem[@"price1"] =price1;
+//        jitem[@"price2"] =price2;
+//        jitem[@"stockUom"] = mpack;
         if(iscollection)
             jitem[@"count"]=@"0";
         else
             jitem[@"count"] = mpack;
         jitem[@"subtotal_price"] = @([mpack intValue]* [jitem[@"unit_price"] doubleValue]);
 
-        jitem[@"dimension"] = dimension;
-        jitem[@"unit_cuft"] = unit_cuft;
+//        jitem[@"dimension"] = dimension;
+//        jitem[@"unit_cuft"] = unit_cuft;
         jitem[@"cuft"] = @([mpack intValue]* [unit_cuft doubleValue]);
-        jitem[@"origin"] = origin;
-        jitem[@"port"] = port;
-        jitem[@"available"] = available;
+//        jitem[@"origin"] = origin;
+//        jitem[@"port"] = port;
+//        jitem[@"available"] = available;
 //        jitem[@"iscollection"]= @(iscollection);
         
         //        jitem[@"unit_price"] =@( [item[3] doubleValue]);
@@ -286,7 +290,7 @@
         
         NSString* models=[RAConvertor arr2string:arrname separator:@"," trim:false];
         
-        [RAUtils message_alert:@"Successful" title:[NSString stringWithFormat: @"%@ added to cart",models] controller:self action_handler:^(UIAlertAction * _Nonnull action) {
+        [RAUtils message_alert:@"Successfully" title:[NSString stringWithFormat: @"%@ added to cart",models] controller:self action_handler:^(UIAlertAction * _Nonnull action) {
             [self dismissViewControllerAnimated:true completion:^{
                     if(self.returnValue)
                         self.returnValue(self.modellist);

+ 1 - 1
RedAnt ERP Mobile/HMLG Scan Order/ScanSearchViewController.m

@@ -12,7 +12,7 @@
 #import "RADataProvider.h"
 
 
-#define PAGE_ITEM 20
+#define PAGE_ITEM 20000
 
 @interface ScanSearchViewController ()
 

+ 2 - 2
RedAnt ERP Mobile/HMLG Scan Order/ServerSettingViewController.m

@@ -291,7 +291,7 @@
                             
                             NSFileManager *fileManager = [NSFileManager defaultManager];
                             [fileManager removeItemAtPath:path error:nil];
-                            [RAUtils message_alert:@"Update templete file successful." title:@"Message" controller:self];
+                            [RAUtils message_alert:@"Update template file successful." title:@"Message" controller:self];
                             
 
                             NSMutableDictionary *templateDic = [NSMutableDictionary dictionary];
@@ -299,7 +299,7 @@
                             templateDic[@"updatetime"]= datetime;
                             [self setUserDefaultsValue:templateDic forKey:@"ScanTemplate"];
                             [self loadTemplate];
-                            
+                            [RADataProvider load_scan_models];
                             
                         }
                         //[zip UnzipCloseFile];

+ 2 - 1
RedAnt ERP Mobile/HMLG Scan Order/SetupServerViewController.m

@@ -172,7 +172,7 @@
                             
                             NSFileManager *fileManager = [NSFileManager defaultManager];
                             [fileManager removeItemAtPath:path error:nil];
-                            [RAUtils message_alert:@"Update templete file successful." title:@"Message" controller:self];
+                            [RAUtils message_alert:@"Update template file successful." title:@"Message" controller:self];
                             
 
                             NSMutableDictionary *templateDic = [NSMutableDictionary dictionary];
@@ -181,6 +181,7 @@
                             [self setUserDefaultsValue:templateDic forKey:@"ScanTemplate"];
                             
                             [OLDataProvider guestLogin];
+                            [RADataProvider load_scan_models];
 //                            [self loadTemplate];
                             
                             

+ 22 - 0
RedAnt ERP Mobile/HMLG Scan Order/StockTableViewCell.h

@@ -0,0 +1,22 @@
+//
+//  StockTableViewCell.h
+//  HMLG Scan Order
+//
+//  Created by Rui Zhang on 6/21/22.
+//  Copyright © 2022 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface StockTableViewCell : UITableViewCell
+@property (weak, nonatomic) IBOutlet UILabel *labelModel;
+@property (weak, nonatomic) IBOutlet UIButton *btnMove;
+@property (weak, nonatomic) IBOutlet UILabel *labelQTY;
+@property (weak, nonatomic) IBOutlet UILabel *labelETD;
+
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 24 - 0
RedAnt ERP Mobile/HMLG Scan Order/StockTableViewCell.m

@@ -0,0 +1,24 @@
+//
+//  StockTableViewCell.m
+//  HMLG Scan Order
+//
+//  Created by Rui Zhang on 6/21/22.
+//  Copyright © 2022 United Software Applications, Inc. All rights reserved.
+//
+
+#import "StockTableViewCell.h"
+
+@implementation StockTableViewCell
+
+- (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
+}
+
+@end

+ 24 - 0
RedAnt ERP Mobile/HMLG Scan Order/StockViewController.h

@@ -0,0 +1,24 @@
+//
+//  StockViewController.h
+//  HMLG Scan Order
+//
+//  Created by Rui Zhang on 6/21/22.
+//  Copyright © 2022 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface StockViewController : UIViewController
+@property (weak, nonatomic) IBOutlet UITableView *table;
+@property (strong, nonatomic) NSMutableArray* data;
+
+@property (strong, nonatomic) NSMutableArray* idata;
+@property (strong, nonatomic) NSMutableArray* bdata;
+@property NSUInteger taptime;
+@property (strong, nonatomic) NSIndexPath* lasttap;
+@property (nonatomic , copy) void (^returnValue)(NSMutableDictionary* models);
+@end
+
+NS_ASSUME_NONNULL_END

+ 342 - 0
RedAnt ERP Mobile/HMLG Scan Order/StockViewController.m

@@ -0,0 +1,342 @@
+//
+//  StockViewController.m
+//  HMLG Scan Order
+//
+//  Created by Rui Zhang on 6/21/22.
+//  Copyright © 2022 United Software Applications, Inc. All rights reserved.
+//
+
+#import "StockViewController.h"
+#import "StockTableViewCell.h"
+#import "DefaultTableHeaderView.h"
+#import "DefaultAppearance.h"
+#import "const.h"
+@interface StockViewController ()
+
+@end
+
+@implementation StockViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+}
+- (IBAction)onSubmit:(id)sender {
+    NSMutableDictionary* models = [NSMutableDictionary new];
+    models[@"count"] = @(self.idata.count+self.bdata.count);
+    models[@"title"] =@"Model Information";
+    int count=0;
+    for(int i=0;i<self.idata.count;i++)
+    {
+        models[[NSString stringWithFormat:@"item_%d",count]]=self.idata[i];
+        count++;
+    }
+    for(int j=0;j<self.bdata.count;j++)
+    {
+        models[[NSString stringWithFormat:@"item_%d",count]]=self.bdata[j];
+        count++;
+    }
+    if(self.returnValue)
+        self.returnValue(models);
+    
+    [self dismissViewControllerAnimated:true completion:nil];
+    
+}
+- (IBAction)onCancel:(id)sender {
+    [self dismissViewControllerAnimated:true completion:nil];
+}
+
+- (IBAction)onMovebackorder:(id)sender {
+    
+    UITableViewCell* cell = (UITableViewCell*)((UIButton*)sender).superview.superview;
+    NSIndexPath *   indexPath = [self.table indexPathForCell:cell];
+    UITableView* tableView = self.table;
+    
+    NSMutableArray * from;
+    NSMutableArray * to ;
+//    int section;
+//    if(indexPath.section==0)
+//    {
+        from  = self.idata;
+        to = self.bdata;
+    
+    
+ 
+    
+//    [tableView beginUpdates];
+    NSMutableDictionary* content=from[indexPath.row];
+    content[@"is_back_order"] =@"true";
+    [from removeObjectAtIndex:indexPath.row];
+//    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
+
+    for(int i=0;i<to.count;i++)
+    {
+        if([to[i][@"model"] isEqualToString:content[@"model"]])
+        {
+            to[i][@"count"]=@([to[i][@"count"] intValue]+[content[@"count"] intValue]);
+            to[i][@"cuft"]=@([to[i][@"count"] intValue] * [to[i][@"unit_cuft"] doubleValue]);
+//                                NSString * mpack=newitem[@"stockUom"];
+            
+            to[i][@"subtotal_price"] = @([to[i][@"count"] intValue]* [to[i][@"unit_price"] doubleValue]*(1-[to[i][@"discount"] doubleValue]/100.0));
+            content=nil;
+            break;
+        }
+    }
+    if(content!=nil)
+    {
+        [to insertObject:content atIndex:0];
+//        NSIndexPath * toIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
+//        [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:toIndexPath] withRowAnimation:UITableViewRowAnimationFade];
+    }
+    
+    
+
+//    [tableView endUpdates];
+    
+//            [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:headerIndexPath] withRowAnimation:UITableViewRowAnimationFade];
+//            [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:headerIndexPath1] withRowAnimation:UITableViewRowAnimationFade];
+    [tableView reloadData];
+    
+}
+
+- (void)setData:(NSMutableArray *)data
+{
+    _data = data;
+    
+    self.idata = [NSMutableArray new];
+    self.bdata = [NSMutableArray new];
+    
+    for(int i=0;i<data.count;i++)
+    {
+       if( [ data[i][@"is_back_order"] boolValue])
+       {
+           [_bdata addObject:data[i]];
+       }
+       else{
+           [_idata addObject:data[i]];
+       }
+    }
+}
+
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+    
+    return;
+    //如果两次点击的时间间隔小于1秒,则断定为双击事件
+    
+//    if(tableView.editing==false)
+//        return;
+    
+//    if(self.forNewResult)
+//    {
+//         if(indexPath.section==1&&[tableView numberOfRowsInSection:0]>=3)
+//             return;
+//    }
+//    else
+//    {
+//        if(indexPath.section==0&&[tableView numberOfRowsInSection:indexPath.section]<=1)
+//            return;
+//    }
+//    int between = 1;
+    NSUInteger curr = [[NSDate date] timeIntervalSince1970];
+    
+    if(indexPath.row==self.lasttap.row&&indexPath.section==self.lasttap.section)
+    {
+        if (curr-self.taptime<1) {
+              DebugLog(@"double click!");
+            self.lasttap =nil;
+            
+            NSMutableArray * from;
+            NSMutableArray * to ;
+            int section;
+            if(indexPath.section==0)
+            {
+                from  = self.idata;
+                to = self.bdata;
+                section = 1;
+            }
+            else
+            {
+            
+                from  = self.bdata;
+                to = self.idata;
+                section = 0;
+            }
+            NSIndexPath * toIndexPath = [NSIndexPath indexPathForRow:0 inSection:section];
+//            NSIndexPath * headerIndexPath = [NSIndexPath indexPathForRow:0 inSection:indexPath.section];
+//            NSIndexPath * headerIndexPath1 = toIndexPath;
+            
+            id content=from[indexPath.row];
+            [tableView beginUpdates];
+            [from removeObjectAtIndex:indexPath.row];
+            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
+
+            [to insertObject:content atIndex:0];
+            [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:toIndexPath] withRowAnimation:UITableViewRowAnimationFade];
+            [tableView endUpdates];
+            
+//            [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:headerIndexPath] withRowAnimation:UITableViewRowAnimationFade];
+//            [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:headerIndexPath1] withRowAnimation:UITableViewRowAnimationFade];
+            [tableView reloadData];
+            
+
+        }
+        self.taptime = curr;
+        
+        
+    }
+    else
+    {
+        self.taptime = curr;
+        self.lasttap = indexPath;
+    }
+}
+
+//
+//- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
+//{
+////    return [super tableview:tableView viewForHeaderInSection:section];
+//    NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
+//    if(value==nil)
+//        value=@"";
+//    unsigned long color = strtoul([value UTF8String],0,16);
+//
+//
+//    NSString* btntitle=nil ;
+//    NSString*labeltitle = nil;
+//
+//
+//    labeltitle= [self tableView:tableView titleForHeaderInSection:section];
+//
+//
+//    DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
+//  //  myView.backgroundColor = [UIColor whiteColor];//UIColorFromRGB(0x996633);;
+//    myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
+//    myView.layer.shadowColor = [UIColor blackColor].CGColor;
+//    myView.layer.shadowOffset = CGSizeMake(0, 0);
+//    myView.layer.shadowOpacity = 0.5;
+//    myView.layer.shadowRadius = 2.0;
+//
+//    int linespace=0;
+//    if(section==0)
+//        linespace=11;
+//
+//
+//
+//
+//    UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5.5+linespace, 200, 20)];
+//    titlelabel.textColor=UIColorFromRGB(color);//[UIColor whiteColor];
+//    titlelabel.backgroundColor = [UIColor clearColor];
+//    titlelabel.text=NSLocalizedString(labeltitle, nil);
+//    titlelabel.font = [UIFont boldSystemFontOfSize:20];
+//    [titlelabel sizeToFit];
+//    [myView addSubview:titlelabel];
+//    //
+//    //    UILabel *contactlabel = [[UILabel alloc] initWithFrame:CGRectMake(300, 0, 90, 22)];
+//    //    contactlabel.textColor=[UIColor whiteColor];
+//    //    contactlabel.backgroundColor = [UIColor clearColor];
+//    //    contactlabel.text=NSLocalizedString(@"Contact", nil);
+//    //    [contactlabel sizeToFit];
+//    //    [myView addSubview:contactlabel];
+//    //
+//    //
+//    //    UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(400, 0, 90, 22)];
+//    //    modellabel.textColor=[UIColor whiteColor];
+//    //    modellabel.backgroundColor = [UIColor clearColor];
+//    //    modellabel.text=NSLocalizedString(@"Model", nil);
+//    //    [modellabel sizeToFit];
+//    //    [myView addSubview:modellabel];
+//    //
+//    //    UILabel *pricelabel = [[UILabel alloc] initWithFrame:CGRectMake(500, 0, 90, 22)];
+//    //    pricelabel.textColor=[UIColor whiteColor];
+//    //    pricelabel.backgroundColor = [UIColor clearColor];
+//    //    pricelabel.text=NSLocalizedString(@"Price", nil);
+//    //    [pricelabel sizeToFit];
+//    //    [myView addSubview:pricelabel];
+//    //
+//    //
+//    //
+//    //    UILabel *timelabel = [[UILabel alloc] initWithFrame:CGRectMake(630, 0, 90, 22)];
+//    //    timelabel.textColor=[UIColor whiteColor];
+//    //    timelabel.backgroundColor = [UIColor clearColor];
+//    //    timelabel.text=NSLocalizedString(@"Create time", nil);
+//    //    [timelabel sizeToFit];
+//    //    [myView addSubview:timelabel];
+//    //
+//    //
+//    //
+//    //    UILabel *statuslabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 60, 22)];
+//    //    statuslabel.textColor=[UIColor whiteColor];
+//    //    statuslabel.backgroundColor = [UIColor clearColor];
+//    //    statuslabel.text=NSLocalizedString(@"Status", nil);
+//    //    [statuslabel sizeToFit];
+//    //    [myView addSubview:statuslabel];
+//    //
+//    myView.backgroundColor = UIColor.lightGrayColor;
+////    UIColor * c=myView.backgroundColor;
+//    return myView;
+//}
+
+- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
+    
+    if(section==0)
+        return @"In Stock";
+    else
+        return @"Backorder";
+    
+}
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+    return 2;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    if(section==0)
+        return _idata.count;
+    else
+        return _bdata.count;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    StockTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"StockTableViewCell"];
+    if (!cell) {
+        cell = [[StockTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"StockTableViewCell"];
+    }
+
+    NSArray* arr;
+    if(indexPath.section==0)
+    {
+        arr = self.idata;
+        cell.btnMove.hidden = false;
+    }
+    else
+    {
+        arr = self.bdata;
+        cell.btnMove.hidden = true;
+    }
+    cell.labelModel.text = arr[indexPath.row][@"model"];
+    cell.labelETD.text = arr[indexPath.row][@"etd"];
+    cell.labelQTY.text = [arr[indexPath.row][@"count"] stringValue];
+    
+    return cell;
+}
+
+
+//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
+//{
+//    if(section==0)
+//        return 44;
+//    return 44;
+//}
+/*
+#pragma mark - Navigation
+
+// In a storyboard-based application, you will often want to do a little preparation before navigation
+- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+    // Get the new view controller using [segue destinationViewController].
+    // Pass the selected object to the new view controller.
+}
+*/
+
+@end

+ 2 - 2
RedAnt ERP Mobile/HMLG Scan Order/config.h

@@ -10,14 +10,14 @@
 #define RedAnt_ERP_Mobile_config_h
 #define BUILD_HMLG_SCAN_ORDER
 #define BACKORDER_PROCESS // 允许backorder process
-
+#define JSON_TIMEOUT 30 //接口超时
 
 #define GLES_SILENCE_DEPRECATION //关闭glkview警告
 
 #define RA_NOTIFICATION
 
 # ifdef DEBUG
-#define test_server
+//#define test_server
 # endif
 
 #define exception_switch 1

+ 5 - 0
RedAnt ERP Mobile/common/AppDelegateBase.h

@@ -201,5 +201,10 @@ typedef enum {
 @property (strong, nonatomic)  RAUploadManager *uploadManager;
 @property (nonatomic,assign) BOOL compressFile;
 
+#ifdef SCANNER_ORDER
+@property (strong, nonatomic) NSDictionary* scan_model;
+@property (strong, nonatomic) NSArray* scan_model_key;
 
+
+#endif
 @end

+ 72 - 80
RedAnt ERP Mobile/common/Functions/OLO/ScanOrderListViewController.m

@@ -438,7 +438,7 @@
 {
     NSString* order_code = RASingleton.sharedInstance.scan_temp_code;
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    appDelegate.order_code = order_code;
+//    appDelegate.order_code = order_code;
     
     if(appDelegate.user.length==0)
     {
@@ -480,18 +480,18 @@
         //        NSData* data=[NSData dataWithContentsOfFile:[[NSBundle mainBundle]  pathForResource:URL_SO_ORDER ofType:@"json" ]];
         
         //        NSMutableDictionary* dict=[[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error] mutableCopy];
-        
-        NSMutableDictionary* dict=[OLDataProvider loadScanTemplate:@"scan_order.json"];
-        
-        
-        
-        
-        NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
-        
-        
-        
-        [RAUtils dicttofile:orderPath dict:dict];
-        
+//        
+//        NSMutableDictionary* dict=[OLDataProvider loadScanTemplate:@"scan_order.json"];
+//        
+//        
+//        
+//        
+//        NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
+//        
+//        
+//        
+//        [RAUtils dicttofile:orderPath dict:dict];
+//        
         
         
         
@@ -1913,23 +1913,7 @@
             [appDelegate update_count_mark];
             //            [appDelegate updateScanButton:true];
             [appDelegate SetMode:@""];
-            
-//            CreateOrderViewController * orderinfoVC = [[CreateOrderViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
-//
-//
-//
-//            orderinfoVC.disable_dropdown_refresh=true;
-//            orderinfoVC.url_type = URL_FILE;
-//            orderinfoVC.request_url=[orderdir stringByAppendingPathComponent:@"order.json"];
-//
-//            orderinfoVC.params = params;
-//            orderinfoVC.title=@"";
-            //            orderinfoVC.delegate=self;
-            //
-            //    if(checked.count==count)
-            //    {
-            //    orderinfoVC.have_tail = true
-            //    }
+  
             
             
 #ifdef RA_NOTIFICATION
@@ -1949,91 +1933,99 @@
             
         }
         
-//        UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Open Saved Order" message:nil preferredStyle:UIAlertControllerStyleAlert];
-//        UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Open" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+        
+    }
+    else if(tableView==self.table_submit)
+    {
+        
+        
+        
+        
+        //        RASingleton.sharedInstance.enable_OfflineOrder = true;
+        if (tableView.isEditing) { // 编辑模式下不响应
+            return;
+        }
+        //
+//        if(indexPath.row==self.content_data.count)
+//            return;
+        
+        {
 //            AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//
-//
-//            NSMutableDictionary* orderitem =self.content_data[indexPath.row];
-//            NSString* ordercode =orderitem[@"order_code"];
+            
+            
+            NSMutableDictionary* orderitem =self.submit_content_data[indexPath.row];
+            NSString* ordercode =orderitem[@"order_code"];
+            
+                        NSString *orderdir = [OLDataProvider getScanOrderPath];
+            orderdir = [orderdir stringByAppendingPathComponent:ordercode];
+            NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
+            CreateOrderViewController * orderinfoVC = [[CreateOrderViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
+
+
+
+            orderinfoVC.disable_dropdown_refresh=true;
+            orderinfoVC.url_type = URL_FILE;
+            orderinfoVC.request_url=[orderdir stringByAppendingPathComponent:@"order.json"];
+
+            orderinfoVC.params = params;
+            orderinfoVC.title=@"";
+                        orderinfoVC.delegate=nil;
+            [self.navigationController pushViewController:orderinfoVC animated:true];
+//                if(checked.count==count)
+//                {
+//                orderinfoVC.have_tail = true
+//                }
+            
+            
+            
 //            appDelegate.order_code = ordercode;
 //
 //            [appDelegate setUser:orderitem[@"create_by"]];
-//            //            appDelegate.user =;
-//            //        appDelegate.custo orderitem[@"customer_name"]
-//            appDelegate.user_type = USER_ROLE_EMPLOYEE;
+//
 //            appDelegate.can_set_cart_price = true;
 //            appDelegate.can_see_price = true;
 //
 //
 //            NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
 //
-////            NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
-////            NSString *documents = [paths objectAtIndex:0];
 //
 //
 //
 //            NSString *orderdir = [OLDataProvider getScanPath];
-//            //        NSMutableDictionary* order= [[RAUtils dictfromfile:[orderdir stringByAppendingPathComponent:@"order.json"]] mutableCopy];
 //            NSMutableDictionary* cart= [[RAUtils dictfromfile:[orderdir stringByAppendingPathComponent:@"cart.json"]] mutableCopy];
 //            NSMutableDictionary* contact= [[RAUtils dictfromfile:[orderdir stringByAppendingPathComponent:@"contact.json"]] mutableCopy];
-//            //        NSMutableDictionary* app= [[RAUtils dictfromfile:[orderdir stringByAppendingPathComponent:@"app.json"]] mutableCopy];
 //
 //            [appDelegate setCustomerInfo: contact];
+//            appDelegate.contact_id = contact[@"customer_cid"];
 //            RASingleton.sharedInstance.scan_cart = cart;
 //            RASingleton.sharedInstance.price_type = [cart[@"price_type"] intValue];
 //
 //
 //            [appDelegate update_count_mark];
-//            //            [appDelegate updateScanButton:true];
 //            [appDelegate SetMode:@""];
 //
-//            CreateOrderViewController * orderinfoVC = [[CreateOrderViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
 //
 //
+//#ifdef RA_NOTIFICATION
+//            [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//#else
 //
-//            orderinfoVC.disable_dropdown_refresh=true;
-//            orderinfoVC.url_type = URL_FILE;
-//            orderinfoVC.request_url=[orderdir stringByAppendingPathComponent:@"order.json"];
-//
-//            orderinfoVC.params = params;
-//            orderinfoVC.title=@"";
-//            //            orderinfoVC.delegate=self;
-//            //
-//            //    if(checked.count==count)
-//            //    {
-//            //    orderinfoVC.have_tail = true
-//            //    }
-//
-//            [self.navigationController pushViewController:orderinfoVC animated:true];
-//
-//            return;
-//
-//
-//        }];
-//
-//
-//
-//        UIAlertAction *alertCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
-//
-//        }];
-//
-//        [alertControl addAction:actionOne];
-//
-//        //        [alertControl addAction:alertthree];
-//        [alertControl addAction:alertCancel];
 //
-//        [self presentViewController:alertControl animated:YES completion:nil];
+//            [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+//#endif
 //
+////            [self.navigationController pushViewController:orderinfoVC animated:true];
 //
+//            [((MainViewController*)appDelegate.main_vc) switchToCart];
 //
-        
-        
-        //    NSString* orderid= [ valueForKey:@"order_id"];
-        
+            return;
+            
+            
+        }
         
         
     }
+    
 }
 
 

Plik diff jest za duży
+ 3 - 1
RedAnt ERP Mobile/common/Functions/camscan/ScannerViewController.m


+ 278 - 119
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -1568,26 +1568,110 @@
         
 //        NSMutableDictionary* dict=[[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error] mutableCopy];
         
-        NSMutableDictionary* dict=[OLDataProvider loadScanTemplate:@"scan_order.json"];
-
-
-        
-        
-        NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
-        
-        
-        
-        [RAUtils dicttofile:orderPath dict:dict];
         
         
+//        __block NSMutableDictionary* block_dict = dict;
+        if(appDelegate.user_type== USER_ROLE_EMPLOYEE)
+        {
+           
+            
+            
+            UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Select Customer type" message:@"" preferredStyle:UIAlertControllerStyleAlert];
+            //block代码块取代了delegate
+            
+            
+            
+            UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Existing Customer" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
+                
+                NSMutableDictionary* dict = nil;
+                dict=[OLDataProvider loadScanTemplate:@"e_order.json"];
+                
+                NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
+                
+                
+                
+                [RAUtils dicttofile:orderPath dict:dict];
+                
+                
+
+                
+                
+                NSString *contactpath = [orderdir stringByAppendingPathComponent:@"contact.json"];
+                
+                
+                
+                [RAUtils dicttofile:contactpath dict:appDelegate.customerInfo];
+                
+                [self scanPlaceOrder];
+                
+            }];
+            
+            UIAlertAction *alert2 = [UIAlertAction actionWithTitle:@"New customer" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                NSMutableDictionary* dict = nil;
+                dict=[OLDataProvider loadScanTemplate:@"n_order.json"];
+                
+                NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
+                
+                
+                
+                [RAUtils dicttofile:orderPath dict:dict];
+                
+                
+
+                
+                
+                NSString *contactpath = [orderdir stringByAppendingPathComponent:@"contact.json"];
+                
+                
+                
+                [RAUtils dicttofile:contactpath dict:appDelegate.customerInfo];
+                [self scanPlaceOrder];
+            }];
+            UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+                DebugLog(@"No");
+            }];
+            [alertControl addAction:actionOne];
+            [alertControl addAction:alert2];
+            [alertControl addAction:alertthree];
+            
+            //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
+            
+            
+            [self presentViewController:alertControl animated:YES completion:nil];
+            
+            DebugLog(@"%@",self.edit_select_arr);
+
+            
+        }
+        else
+        {
+            NSMutableDictionary* dict = nil;
+            dict=[OLDataProvider loadScanTemplate:@"c_order.json"];
+            
+            NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
+            
+            
+            
+            [RAUtils dicttofile:orderPath dict:dict];
+            
+            
+
+            
+            
+            NSString *contactpath = [orderdir stringByAppendingPathComponent:@"contact.json"];
+            
+            
+            
+            [RAUtils dicttofile:contactpath dict:appDelegate.customerInfo];
+            [self scanPlaceOrder];
+        }
+            
+
+//        NSMutableDictionary* dict=[OLDataProvider loadScanTemplate:@"scan_order.json"];
+
 
         
-        
-        NSString *contactpath = [orderdir stringByAppendingPathComponent:@"contact.json"];
-        
-        
-        
-        [RAUtils dicttofile:contactpath dict:appDelegate.customerInfo];
+
         
         
     }
@@ -1631,115 +1715,115 @@
     
 
 //    __block MainViewController *brself= self;
-    if(appDelegate.contact_id.length<=0)
-    {
-        
-        UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"New Offline Order" message:nil preferredStyle:UIAlertControllerStyleAlert];
-        UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"With Offline Contact" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-
-//            if(appDelegate.order_code && appDelegate.order_code.length>0)
+//    if(appDelegate.contact_id.length<=0)
+//    {
+//
+//        UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"New Offline Order" message:nil preferredStyle:UIAlertControllerStyleAlert];
+//        UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"With Offline Contact" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+//
+////            if(appDelegate.order_code && appDelegate.order_code.length>0)
+////            {
+////                [RAUtils message_alert:@"Please close current order and try again." title:@"" controller:self];
+////            }
+////            NSLog(@"new click");
+//
+//            NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
+//
+////            NSString *path = [[NSBundle mainBundle] pathForResource:@"editContact.json" ofType:nil];
+//
+//            CustomerEditViewController * cuseditVC = [[CustomerEditViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
+//            cuseditVC.bnewcustomer=true;
+//            cuseditVC.bolocustomer = true;
+//            cuseditVC.url_type = URL_FILE;
+//            cuseditVC.request_url=[OLDataProvider scanTemplatePath:@"scan_contact.json"];
+//
+//            cuseditVC.params = params;
+//
+//            cuseditVC.returnValue=^(NSMutableDictionary* value)
 //            {
-//                [RAUtils message_alert:@"Please close current order and try again." title:@"" controller:self];
-//            }
-//            NSLog(@"new click");
-            
-            NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
-            
-//            NSString *path = [[NSBundle mainBundle] pathForResource:@"editContact.json" ofType:nil];
-            
-            CustomerEditViewController * cuseditVC = [[CustomerEditViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
-            cuseditVC.bnewcustomer=true;
-            cuseditVC.bolocustomer = true;
-            cuseditVC.url_type = URL_FILE;
-            cuseditVC.request_url=[OLDataProvider scanTemplatePath:@"scan_contact.json"];
-            
-            cuseditVC.params = params;
-            
-            cuseditVC.returnValue=^(NSMutableDictionary* value)
-            {
-                if(value==nil)
-                {
-                    [RAUtils message_alert:@"Cannot create order without customer infomation." title:@"" controller:self];
-                }
-                else
-                {
-                    NSString* contact_id=[[NSUUID new] UUIDString];
-                    
-                    
-                    //---------------- construct customer_contact----------------------
-                    NSString* customer_first_name = [value valueForKey:@"customer_first_name"];
-                    if(customer_first_name==nil)
-                        customer_first_name=@"";
-                    
-                    NSString* customer_last_name= [value valueForKey:@"customer_last_name"];
-                    if(customer_last_name==nil)
-                        customer_last_name=@"";
-                    NSString* customer_contact = [NSString stringWithFormat:@"%@ %@",customer_first_name,customer_last_name];
-                    customer_contact=[customer_contact stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
-                    [value setValue:customer_contact forKey:@"customer_contact"];
-    
-                        
-                        
-                        value [@"customer_cid"] = contact_id;
-                        appDelegate.contact_id=contact_id;
-                        appDelegate.customerInfo = value;
-                    
-                    
-
-                    
-                    
-                    
-//                        [brself refreshContactDisplay];
-                    [self newoloorder];
-                    
-                    [self scanPlaceOrder];
-                    
-//                        [brself switchToCart:nil];
-                    
-                }
-            };
-            
-            
-        //    cuseditVC.delegate=self;
-            //
-            //    if(checked.count==count)
-            //    {
-            //    orderinfoVC.have_tail = true
-            //    }
-            
-            [[self navigationController] setNavigationBarHidden:NO animated:NO];
-            [self.navigationController pushViewController:cuseditVC animated:false];
-            
-//            [self dismissViewControllerAnimated:NO completion:^{
-////                [(UINavigationController*)[self parentViewController] pushViewController:cuseditVC animated:false];;
-////                            [[self navigationController] setNavigationBarHidden:NO animated:NO];
+//                if(value==nil)
+//                {
+//                    [RAUtils message_alert:@"Cannot create order without customer infomation." title:@"" controller:self];
+//                }
+//                else
+//                {
+//                    NSString* contact_id=[[NSUUID new] UUIDString];
+//
+//
+//                    //---------------- construct customer_contact----------------------
+//                    NSString* customer_first_name = [value valueForKey:@"customer_first_name"];
+//                    if(customer_first_name==nil)
+//                        customer_first_name=@"";
+//
+//                    NSString* customer_last_name= [value valueForKey:@"customer_last_name"];
+//                    if(customer_last_name==nil)
+//                        customer_last_name=@"";
+//                    NSString* customer_contact = [NSString stringWithFormat:@"%@ %@",customer_first_name,customer_last_name];
+//                    customer_contact=[customer_contact stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+//                    [value setValue:customer_contact forKey:@"customer_contact"];
+//
+//
+//
+//                        value [@"customer_cid"] = contact_id;
+//                        appDelegate.contact_id=contact_id;
+//                        appDelegate.customerInfo = value;
+//
+//
+//
+//
+//
+//
+////                        [brself refreshContactDisplay];
+//                    [self newoloorder];
+//
+//                    [self scanPlaceOrder];
+//
+////                        [brself switchToCart:nil];
+//
+//                }
+//            };
+//
+//
+//        //    cuseditVC.delegate=self;
+//            //
+//            //    if(checked.count==count)
+//            //    {
+//            //    orderinfoVC.have_tail = true
+//            //    }
 //
-////                            [self pushViewController:cuseditVC animated:false];
-//            }];
-            
 //            [[self navigationController] setNavigationBarHidden:NO animated:NO];
 //            [self.navigationController pushViewController:cuseditVC animated:false];
-            
-            
-        }];
-
-        
-
-        UIAlertAction *alertCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
-            
-        }];
-        
-        [alertControl addAction:actionOne];
-        
-//        [alertControl addAction:alertthree];
-        [alertControl addAction:alertCancel];
-        
-        [self presentViewController:alertControl animated:YES completion:nil];
-    }
-    else
+//
+////            [self dismissViewControllerAnimated:NO completion:^{
+//////                [(UINavigationController*)[self parentViewController] pushViewController:cuseditVC animated:false];;
+//////                            [[self navigationController] setNavigationBarHidden:NO animated:NO];
+////
+//////                            [self pushViewController:cuseditVC animated:false];
+////            }];
+//
+////            [[self navigationController] setNavigationBarHidden:NO animated:NO];
+////            [self.navigationController pushViewController:cuseditVC animated:false];
+//
+//
+//        }];
+//
+//
+//
+//        UIAlertAction *alertCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+//
+//        }];
+//
+//        [alertControl addAction:actionOne];
+//
+////        [alertControl addAction:alertthree];
+//        [alertControl addAction:alertCancel];
+//
+//        [self presentViewController:alertControl animated:YES completion:nil];
+//    }
+//    else
     {
         [self newoloorder];
-        [self scanPlaceOrder];
+        
     }
 }
 
@@ -2877,6 +2961,81 @@
     
     
 }
+#ifdef SCANNER_ORDER
+- (IBAction)onScanChangeCustomerType:(id)sender {
+    
+    return;
+    NSString *orderdir =[OLDataProvider getScanPath];
+    
+    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Select Customer type" message:@"" preferredStyle:UIAlertControllerStyleAlert];
+    //block代码块取代了delegate
+    
+    
+    
+    UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Existing Customer" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
+        
+        NSMutableDictionary* dict = nil;
+        dict=[OLDataProvider loadScanTemplate:@"e_order.json"];
+        
+        NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
+        
+        
+        
+        [RAUtils dicttofile:orderPath dict:dict];
+        
+        
+
+        
+//
+//        NSString *contactpath = [orderdir stringByAppendingPathComponent:@"contact.json"];
+//
+//
+//
+//        [RAUtils dicttofile:contactpath dict:appDelegate.customerInfo];
+//
+//        [self scanPlaceOrder];
+//
+    }];
+    
+    UIAlertAction *alert2 = [UIAlertAction actionWithTitle:@"New customer" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+        NSMutableDictionary* dict = nil;
+        dict=[OLDataProvider loadScanTemplate:@"n_order.json"];
+        
+        NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
+        
+        
+        
+        [RAUtils dicttofile:orderPath dict:dict];
+        
+        
+
+//        
+//        
+//        NSString *contactpath = [orderdir stringByAppendingPathComponent:@"contact.json"];
+//        
+//        
+//        
+//        [RAUtils dicttofile:contactpath dict:appDelegate.customerInfo];
+//        [self scanPlaceOrder];
+    }];
+    UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+        DebugLog(@"No");
+    }];
+    [alertControl addAction:actionOne];
+    [alertControl addAction:alert2];
+    [alertControl addAction:alertthree];
+    
+    //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
+    
+    
+    [self presentViewController:alertControl animated:YES completion:nil];
+    
+    DebugLog(@"%@",self.edit_select_arr);
+
+    
+}
+#endif
+
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 {
     if (self.back_order_flag) {

+ 1 - 0
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.h

@@ -167,4 +167,5 @@ typedef void(^resultHandler)(NSMutableDictionary *result);
 +(NSString*) getScanPath;
 +(void) moveScanTemp2Order;
 +(void) guestLogin;
++(NSString*) getScanOrderPath;
 @end

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

@@ -5777,9 +5777,9 @@
     
     //JEPG格式
     
-    //NSData *imagedata=UIImageJEPGRepresentation(m_imgFore,1.0);
+//    NSData *imagedata=UIImageJEPGRepresentation(m_imgFore,1.0);
     
-    NSString* filename =[NSString stringWithFormat:@"%@.png",[[NSUUID UUID] UUIDString]];
+    NSString* filename =[NSString stringWithFormat:@"%@.jpg",[[NSUUID UUID] UUIDString]];
     NSString *savedImagePath=[offline_createimg stringByAppendingPathComponent:filename];
     
     NSString *cacheImagePath=[img_cache stringByAppendingPathComponent:filename];

+ 810 - 270
RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m

@@ -16,6 +16,7 @@
 #import "CreditCardEditorViewController.h"
 #import "JKTimerManager.h"
 #import "ZipArchive.h"
+#import "StockViewController.h"
 
 #define SUBMIT_CONFIRM 123
 #define KEEP_TAIL 456
@@ -29,6 +30,343 @@
 
 @implementation CreateOrderViewController
 
+
+- (void)onScanSwitchUserTypeClick:(id)sender
+{
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    NSString *orderdir =[OLDataProvider getScanPath];
+    
+    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Select Customer type" message:@"" preferredStyle:UIAlertControllerStyleAlert];
+    //block代码块取代了delegate
+    
+    
+    
+    UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Existing Customer" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
+        
+        NSMutableDictionary* dict = nil;
+        dict=[OLDataProvider loadScanTemplate:@"e_order.json"];
+        
+        NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
+        
+        
+        
+        [RAUtils dicttofile:orderPath dict:dict];
+        
+        NSString *orderdir = [OLDataProvider getScanPath];
+        
+        
+//        NSMutableDictionary* dict= [[RAUtils dictfromfile:[orderdir stringByAppendingPathComponent:@"order.json"]] mutableCopy];
+        
+        int section_count = [dict[@"section_count"] intValue];
+        
+        for(int i=0;i<section_count;i++)
+        {
+            NSMutableDictionary* section = [dict[[NSString stringWithFormat:@"section_%d",i]] mutableCopy];
+            NSString* title = section[@"title"];
+            if([title isEqualToString:@"Model Information"])
+            {
+                
+                NSMutableDictionary* cart_section = RASingleton.sharedInstance.scan_cart[@"section_0"];
+                int cart_count = [cart_section[@"count"] intValue];
+                for(int j=0;j<cart_count;j++)
+                {
+                    NSMutableDictionary* cart_item = [cart_section[[NSString stringWithFormat:@"item_%d",j]] mutableCopy];
+                    cart_item[@"description"]= [NSString stringWithFormat:@"%@\n%@\n%@",cart_item[@"model"],cart_item[@"description"],cart_item[@"dimension"] ];
+                    cart_item[@"control"]=@"model";
+                    section[[NSString stringWithFormat:@"item_%d",j]] = cart_item;
+                    
+                }
+                section[@"count"] = @(cart_count);
+                dict[[NSString stringWithFormat:@"section_%d",i]] = section;
+            }
+            else
+                if([title isEqualToString:@"Customer"])
+                {
+                    
+                    int scount = [section[@"count"] intValue];
+                    for(int j=0;j<scount;j++)
+                    {
+                        NSMutableDictionary * item = [section[[NSString stringWithFormat:@"item_%d",j]] mutableCopy];
+                        NSString * name = item[@"name"];
+                        
+                        if([name isEqualToString:@"business_card"])
+                        {
+                            NSArray*arr =[RAConvertor string2arr:appDelegate.customerInfo[name] separator:@","];
+                            for(int l=0;l<arr.count;l++)
+                            {
+                                item[[NSString stringWithFormat:@"img_url_%d",l] ]=arr[l];
+                            }
+                        }
+                        else
+                        {
+                            if(item[@"value"]==nil ||[item[@"value"] stringValue].length==0) //order 内没有值才从customer 复制
+                                item[@"value"]=appDelegate.customerInfo[name];
+                        }
+                        section[[NSString stringWithFormat:@"item_%d",j]] = item;
+                    }
+                    
+    //                    NSDictionary* item_0=@{@"control":@"text",@"name":@"customer_cid",@"aname":@"Contact",@"value":appDelegate.contact_id};
+                    dict[[NSString stringWithFormat:@"section_%d",i]] = section;
+                    
+                    
+                }
+                else
+                    if([title isEqualToString:@"Remarks Content"])
+                    {
+                        
+                        int scount = [section[@"count"] intValue];
+                        for(int j=0;j<scount;j++)
+                        {
+                            NSMutableDictionary * item = [section[[NSString stringWithFormat:@"item_%d",j]] mutableCopy];
+                            NSString * name = item[@"name"];
+                            
+                            
+                            if([name isEqualToString:@"comments"])
+                            {
+                                item[@"value"] = RASingleton.sharedInstance.scan_cart[@"general_note"];
+                                section[[NSString stringWithFormat:@"item_%d",j]] = item;
+                            }
+                            
+                            
+                        }
+                        
+    //                    NSDictionary* item_0=@{@"control":@"text",@"name":@"customer_cid",@"aname":@"Contact",@"value":appDelegate.contact_id};
+                        dict[[NSString stringWithFormat:@"section_%d",i]] = section;
+                        
+                        
+                    }
+            else if([title isEqualToString:@"Order Total"])
+            {
+//
+//                int scount = [section[@"count"] intValue];
+//                for(int j=0;j<scount;j++)
+//                {
+//                    NSMutableDictionary * item = [section[[NSString stringWithFormat:@"item_%d",j]] mutableCopy];
+//                    NSString * name = item[@"name"];
+//
+//
+//                    if([name isEqualToString:@"totalPrice"])
+//                    {
+//                        item[@"value"] = [NSString stringWithFormat:@"%.2f",self.total];
+//                        section[[NSString stringWithFormat:@"item_%d",j]] = item;
+//                    }
+//
+//
+//                }
+//
+//    //                    NSDictionary* item_0=@{@"control":@"text",@"name":@"customer_cid",@"aname":@"Contact",@"value":appDelegate.contact_id};
+//                dict[[NSString stringWithFormat:@"section_%d",i]] = section;
+//
+//
+                
+            }
+               
+            
+            
+            
+        }
+        
+    //        NSString *path = NSTemporaryDirectory();
+    //
+    //        NSString* file=[NSString stringWithFormat:@"SO_%@.json",appDelegate.order_code];
+    //        NSString *filePath = [path stringByAppendingPathComponent:file];
+    //
+    //
+    //
+        [RAUtils dicttofile:[orderdir stringByAppendingPathComponent:@"order.json"] dict:dict];
+        
+        
+        
+        
+        
+        NSData* json =nil;
+        if(self.url_type== URL_LOCAL)
+            json=[NSData dataWithContentsOfFile:[[NSBundle mainBundle]  pathForResource:self.request_url ofType:@"json" ]];
+        else
+            json=[NSData dataWithContentsOfFile:self.request_url];
+        NSError *error=nil;
+        self.content_data_download = [[NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:nil] mutableCopy];
+        self.content_data_control=[self translate_json:self.content_data_download changed:self.changed_data];
+        
+        self.navigationItem.title =  [self.content_data_download valueForKey:@"title"] ;
+        [self.editorTable reloadData];
+//        self refresh:<#(NSString *)#> discardDirty:<#(bool)#>
+        
+//
+//        NSString *contactpath = [orderdir stringByAppendingPathComponent:@"contact.json"];
+//
+//
+//
+//        [RAUtils dicttofile:contactpath dict:appDelegate.customerInfo];
+//
+//        [self scanPlaceOrder];
+//
+    }];
+    
+    UIAlertAction *alert2 = [UIAlertAction actionWithTitle:@"New customer" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+        NSMutableDictionary* dict = nil;
+        dict=[OLDataProvider loadScanTemplate:@"n_order.json"];
+        NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
+        
+        
+        
+        [RAUtils dicttofile:orderPath dict:dict];
+        
+        NSString *orderdir = [OLDataProvider getScanPath];
+        
+        
+//        NSMutableDictionary* dict= [[RAUtils dictfromfile:[orderdir stringByAppendingPathComponent:@"order.json"]] mutableCopy];
+        
+        int section_count = [dict[@"section_count"] intValue];
+        
+        for(int i=0;i<section_count;i++)
+        {
+            NSMutableDictionary* section = [dict[[NSString stringWithFormat:@"section_%d",i]] mutableCopy];
+            NSString* title = section[@"title"];
+            if([title isEqualToString:@"Model Information"])
+            {
+                
+                NSMutableDictionary* cart_section = RASingleton.sharedInstance.scan_cart[@"section_0"];
+                int cart_count = [cart_section[@"count"] intValue];
+                for(int j=0;j<cart_count;j++)
+                {
+                    NSMutableDictionary* cart_item = [cart_section[[NSString stringWithFormat:@"item_%d",j]] mutableCopy];
+                    cart_item[@"description"]= [NSString stringWithFormat:@"%@\n%@\n%@",cart_item[@"model"],cart_item[@"description"],cart_item[@"dimension"] ];
+                    cart_item[@"control"]=@"model";
+                    section[[NSString stringWithFormat:@"item_%d",j]] = cart_item;
+                    
+                }
+                section[@"count"] = @(cart_count);
+                dict[[NSString stringWithFormat:@"section_%d",i]] = section;
+            }
+            else
+                if([title isEqualToString:@"Customer"])
+                {
+                    
+                    int scount = [section[@"count"] intValue];
+                    for(int j=0;j<scount;j++)
+                    {
+                        NSMutableDictionary * item = [section[[NSString stringWithFormat:@"item_%d",j]] mutableCopy];
+                        NSString * name = item[@"name"];
+                        
+                        if([name isEqualToString:@"business_card"])
+                        {
+                            NSArray*arr =[RAConvertor string2arr:appDelegate.customerInfo[name] separator:@","];
+                            for(int l=0;l<arr.count;l++)
+                            {
+                                item[[NSString stringWithFormat:@"img_url_%d",l] ]=arr[l];
+                            }
+                        }
+                        else
+                        {
+                            if(item[@"value"]==nil ||[item[@"value"] stringValue].length==0) //order 内没有值才从customer 复制
+                                item[@"value"]=appDelegate.customerInfo[name];
+                        }
+                        section[[NSString stringWithFormat:@"item_%d",j]] = item;
+                    }
+                    
+    //                    NSDictionary* item_0=@{@"control":@"text",@"name":@"customer_cid",@"aname":@"Contact",@"value":appDelegate.contact_id};
+                    dict[[NSString stringWithFormat:@"section_%d",i]] = section;
+                    
+                    
+                }
+                else
+                    if([title isEqualToString:@"Remarks Content"])
+                    {
+                        
+                        int scount = [section[@"count"] intValue];
+                        for(int j=0;j<scount;j++)
+                        {
+                            NSMutableDictionary * item = [section[[NSString stringWithFormat:@"item_%d",j]] mutableCopy];
+                            NSString * name = item[@"name"];
+                            
+                            
+                            if([name isEqualToString:@"comments"])
+                            {
+                                item[@"value"] = RASingleton.sharedInstance.scan_cart[@"general_note"];
+                                section[[NSString stringWithFormat:@"item_%d",j]] = item;
+                            }
+                            
+                            
+                        }
+                        
+    //                    NSDictionary* item_0=@{@"control":@"text",@"name":@"customer_cid",@"aname":@"Contact",@"value":appDelegate.contact_id};
+                        dict[[NSString stringWithFormat:@"section_%d",i]] = section;
+                        
+                        
+                    }
+            else if([title isEqualToString:@"Order Total"])
+            {
+//
+//                int scount = [section[@"count"] intValue];
+//                for(int j=0;j<scount;j++)
+//                {
+//                    NSMutableDictionary * item = [section[[NSString stringWithFormat:@"item_%d",j]] mutableCopy];
+//                    NSString * name = item[@"name"];
+//
+//
+//                    if([name isEqualToString:@"totalPrice"])
+//                    {
+//                        item[@"value"] = [NSString stringWithFormat:@"%.2f",self.total];
+//                        section[[NSString stringWithFormat:@"item_%d",j]] = item;
+//                    }
+//
+//
+//                }
+//
+//    //                    NSDictionary* item_0=@{@"control":@"text",@"name":@"customer_cid",@"aname":@"Contact",@"value":appDelegate.contact_id};
+//                dict[[NSString stringWithFormat:@"section_%d",i]] = section;
+//
+//
+                
+            }
+               
+            
+            
+            
+        }
+        
+    //        NSString *path = NSTemporaryDirectory();
+    //
+    //        NSString* file=[NSString stringWithFormat:@"SO_%@.json",appDelegate.order_code];
+    //        NSString *filePath = [path stringByAppendingPathComponent:file];
+    //
+    //
+    //
+        [RAUtils dicttofile:[orderdir stringByAppendingPathComponent:@"order.json"] dict:dict];
+        
+        
+        
+        
+        
+        NSData* json =nil;
+        if(self.url_type== URL_LOCAL)
+            json=[NSData dataWithContentsOfFile:[[NSBundle mainBundle]  pathForResource:self.request_url ofType:@"json" ]];
+        else
+            json=[NSData dataWithContentsOfFile:self.request_url];
+        NSError *error=nil;
+        self.content_data_download = [[NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:nil] mutableCopy];
+        self.content_data_control=[self translate_json:self.content_data_download changed:self.changed_data];
+        
+        self.navigationItem.title =  [self.content_data_download valueForKey:@"title"] ;
+        [self.editorTable reloadData];
+    }];
+    UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+        DebugLog(@"No");
+    }];
+    [alertControl addAction:actionOne];
+    [alertControl addAction:alert2];
+    [alertControl addAction:alertthree];
+    
+    //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
+    
+    
+    [self presentViewController:alertControl animated:YES completion:nil];
+    
+ 
+
+    
+}
 - (void)alertMessage:(NSString *)msg {
     
     
@@ -325,6 +663,17 @@
     
 #ifdef SCANNER_ORDER
     [items addObject:self.btnSubmitOrder];
+    [items addObject:fixedItem];
+    UIBarButtonItem *switchbtn = nil;
+    
+    switchbtn = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"select"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                               style:UIBarButtonItemStylePlain
+                                              target:self
+                                              action:@selector(onScanSwitchUserTypeClick:)];
+    
+//    [items addObject:switchbtn];
+        if([self.content_data_download[@"readonly"] boolValue])
+           [items removeAllObjects];
 #else
     if (!self.isResume) {
         // 正常情况
@@ -406,7 +755,8 @@
     //    closeButton.title = @"Close";
     
     self.navigationItem.leftBarButtonItem = closeButton;
-    
+
+//    self.navigationItem.rightBarButtonItem = switchbtn;
     //    self.navigationItem.backBarButtonItem = backButton;
     
     
@@ -2949,172 +3299,182 @@
     return upparams;
     
 }
-- (void)empolyee_commit_order:(NSMutableDictionary *)upparams {
+
+-(NSString*) scan_stock
+{
+    NSMutableArray* ret=[NSMutableArray new];
+    NSDictionary* section=self.content_data_download[@"section_0"];
+    int count = [section[@"count"] intValue];
+    for(int i=0;i<count;i++)
+    {
+        NSDictionary* item = section[[NSString stringWithFormat:@"item_%d",i]];
+        NSDictionary* newitem =@{@"count":item[@"count"],@"model":item[@"model"]}; //@"product_id":item[@"product_id"],
+        [ret addObject:newitem];
+        
+    }
     
+    return [RAConvertor dict2string:ret];
     
     
-#ifdef SCANNER_ORDER
+}
+-(NSMutableArray*) scan_split_models:(NSMutableArray*) smodels
+{
     
-//    if(RASingleton.sharedInstance.enable_OfflineOrder)
+    NSMutableDictionary* cart_section = RASingleton.sharedInstance.scan_cart[@"section_0"];
+    int cart_count = [cart_section[@"count"] intValue];
+    for(int i=0;i<smodels.count;i++)
     {
+                        for(int j=0;j<cart_count;j++)
+                        {
+                            NSMutableDictionary* cart_item = [cart_section[[NSString stringWithFormat:@"item_%d",j]] mutableCopy];
+                            if([cart_item[@"model"] isEqualToString:smodels[i][@"model"] ])
+                            {
+                                NSMutableDictionary* newitem = [[NSMutableDictionary dictionaryWithDictionary:cart_item] mutableCopy];
+                                [newitem addEntriesFromDictionary:smodels[i]];
+                                newitem[@"cuft"]=@([newitem[@"count"] intValue] * [newitem[@"unit_cuft"] doubleValue]);
+//                                NSString * mpack=newitem[@"stockUom"];
+                                newitem[@"control"]=@"model";
+                                newitem[@"description"]= [NSString stringWithFormat:@"%@\n%@\n%@",cart_item[@"model"],cart_item[@"description"],cart_item[@"dimension"] ];
+                                newitem[@"subtotal_price"] = @([newitem[@"count"] intValue]* [newitem[@"unit_price"] doubleValue]*(1-[newitem[@"discount"] doubleValue]/100.0));
+                                smodels[i]=newitem;
+                                break;
+                            }
         
+                        }
         
-        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    }
+    return smodels;
+
+    //                for(int j=0;j<cart_count;j++)
+    //                {
+    //                    NSMutableDictionary* cart_item = [cart_section[[NSString stringWithFormat:@"item_%d",j]] mutableCopy];
+    //                    cart_item[@"description"]= [NSString stringWithFormat:@"%@\n%@\n%@",cart_item[@"model"],cart_item[@"description"],cart_item[@"dimension"] ];
+    //                    cart_item[@"control"]=@"model";
+    //                    section[[NSString stringWithFormat:@"item_%d",j]] = cart_item;
+    //
+    //                }
+    //                section[@"count"] = @(cart_count);
+    //                dict[[NSString stringWithFormat:@"section_%d",i]] = section;
+}
+
+-(void) scan_commit:(NSMutableDictionary *)upparams newmodel:(NSMutableDictionary *)newmodel{
+    
+    
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    
+    
+    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+    NSString *documents = [paths objectAtIndex:0];
+    
         
-//        if([appDelegate.user isEqualToString:@"GUEST"])
-//        {
-//
-//            UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Submit Order" message:@"Please enter your user name and password." preferredStyle:UIAlertControllerStyleAlert];
-//            [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
-//                textField.placeholder = @"User";
-////                textField.secureTextEntry = YES;
-//            }];
-//            [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
-//                textField.placeholder = @"Password";
-//                textField.secureTextEntry = YES;
-//            }];
-//
-//            UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
-//                UITextField *user = alertController.textFields[0];
-//                UITextField *password = alertController.textFields[1];
-////                if (![user.text isEqualToString:@""]) {
-////
-////                    //change password
-////
-////                }
-////                else{
-////                    [self presentViewController:alertController animated:YES completion:nil];
-////                }
-//            }];
-//
-//
-//            [alertController addAction:okAction];
-//            UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-//                NSLog(@"Canelled");
-//            }];
-//            [alertController addAction:cancelAction];
-//            [self presentViewController:alertController animated:YES completion:nil];
-//
-//
-//
-//        }
-//
-        
-        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
-        NSString *documents = [paths objectAtIndex:0];
-        
-            
-            
-        NSString *orderdir = [OLDataProvider getScanPath];
-        
-        
-//
-//        NSArray *cachepaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
-//        NSString *cachefolder = [paths objectAtIndex:0];
-//
-//        NSString *upfolder = [cachefolder stringByAppendingPathComponent:@"upload_data"];
-//        NSString* str=[RAConvertor dict2string:upparams];
-        
-        
-        
-
-        
-//        NSString *ordercontrol = [orderdir stringByAppendingPathComponent:@"order_control.json"];
-        NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
         
+    NSString *orderdir = [OLDataProvider getScanPath];
+    
+    
+    
+//        NSString *ordercontrol = [orderdir stringByAppendingPathComponent:@"order_control.json"];
+    NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
+    
+    NSMutableDictionary* saveorder = [[NSMutableDictionary dictionaryWithDictionary:self.content_data_download] mutableCopy];
+    if(newmodel)
+        saveorder[@"section_0"]=newmodel;
+    
         
 //        [RAUtils dicttofile:ordercontrol dict:self.content_data_control];
-        [RAUtils dicttofile:orderPath dict:self.content_data_download];
-        
-        for(int os=0;os<[self.content_data_download[@"section_count"] intValue];os++)
+    [RAUtils dicttofile:orderPath dict:saveorder];
+    
+    for(int os=0;os<[self.content_data_download[@"section_count"] intValue];os++)
+    {
+        NSDictionary* section = self.content_data_download[[NSString stringWithFormat:@"section_%d",os]];
+        for(int oi=0;oi<[section[@"count"] intValue];oi++)
         {
-            NSDictionary* section = self.content_data_download[[NSString stringWithFormat:@"section_%d",os]];
-            for(int oi=0;oi<[section[@"count"] intValue];oi++)
+            NSDictionary* item = section [[NSString stringWithFormat:@"item_%d",oi]];
+            if([item[@"control"] isEqualToString:@"img"])
             {
-                NSDictionary* item = section [[NSString stringWithFormat:@"item_%d",oi]];
-                if([item[@"control"] isEqualToString:@"img"])
+                // 复制图片到打包目录
+                NSString* img_url_0=item[@"img_url_0"];
+                NSString* img_url_1=item[@"img_url_1"];
+                NSString* img_url_2=item[@"img_url_2"];
+                
+                NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+                NSString *cachefolder = [paths objectAtIndex:0];
+//                    NSString *offline_createimg = [cachefolder stringByAppendingPathComponent:@"offline_createimg"];
+                NSString *img_cache = [cachefolder stringByAppendingPathComponent:@"img_cache"];
+                NSFileManager* fileManager=[NSFileManager defaultManager];
+                if(img_url_0.length>0&&[fileManager fileExistsAtPath:[img_cache stringByAppendingPathComponent:img_url_0]])
                 {
-                    // 复制图片到打包目录
-                    NSString* img_url_0=item[@"img_url_0"];
-                    NSString* img_url_1=item[@"img_url_1"];
-                    NSString* img_url_2=item[@"img_url_2"];
+                    NSError* err;
                     
-                    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
-                    NSString *cachefolder = [paths objectAtIndex:0];
-//                    NSString *offline_createimg = [cachefolder stringByAppendingPathComponent:@"offline_createimg"];
-                    NSString *img_cache = [cachefolder stringByAppendingPathComponent:@"img_cache"];
-                    NSFileManager* fileManager=[NSFileManager defaultManager];
-                    if(img_url_0.length>0&&[fileManager fileExistsAtPath:[img_cache stringByAppendingPathComponent:img_url_0]])
-                    {
-                        NSError* err;
-                        
-                        [fileManager copyItemAtURL:[NSURL fileURLWithPath:[img_cache stringByAppendingPathComponent:img_url_0]] toURL:[NSURL fileURLWithPath:[orderdir stringByAppendingPathComponent:img_url_0]] error:&err];
-                        int i=0;
-                    }
-                    if(img_url_1.length>0&&[fileManager fileExistsAtPath:[img_cache stringByAppendingPathComponent:img_url_1]])
-                    {
-                        NSError* err;
-                        [fileManager copyItemAtURL:[NSURL fileURLWithPath:[img_cache stringByAppendingPathComponent:img_url_1]] toURL:[NSURL fileURLWithPath:[orderdir stringByAppendingPathComponent:img_url_1]] error:&err];
-                    }
-                    if(img_url_2.length>0&&[fileManager fileExistsAtPath:[img_cache stringByAppendingPathComponent:img_url_2]])
-                    {
-                        NSError* err;
-                        [fileManager copyItemAtURL:[NSURL fileURLWithPath:[img_cache stringByAppendingPathComponent:img_url_2]] toURL:[NSURL fileURLWithPath:[orderdir stringByAppendingPathComponent:img_url_2]] error:&err];
-                    }
+                    [fileManager copyItemAtURL:[NSURL fileURLWithPath:[img_cache stringByAppendingPathComponent:img_url_0]] toURL:[NSURL fileURLWithPath:[orderdir stringByAppendingPathComponent:img_url_0]] error:&err];
+                    int i=0;
                 }
-                else                 if([item[@"control"] isEqualToString:@"signature"])
+                if(img_url_1.length>0&&[fileManager fileExistsAtPath:[img_cache stringByAppendingPathComponent:img_url_1]])
                 {
-                    // 复制图片到打包目录
-                    NSString* img_url_0=item[@"value"];
-                 
-                    
-                    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
-                    NSString *cachefolder = [paths objectAtIndex:0];
+                    NSError* err;
+                    [fileManager copyItemAtURL:[NSURL fileURLWithPath:[img_cache stringByAppendingPathComponent:img_url_1]] toURL:[NSURL fileURLWithPath:[orderdir stringByAppendingPathComponent:img_url_1]] error:&err];
+                }
+                if(img_url_2.length>0&&[fileManager fileExistsAtPath:[img_cache stringByAppendingPathComponent:img_url_2]])
+                {
+                    NSError* err;
+                    [fileManager copyItemAtURL:[NSURL fileURLWithPath:[img_cache stringByAppendingPathComponent:img_url_2]] toURL:[NSURL fileURLWithPath:[orderdir stringByAppendingPathComponent:img_url_2]] error:&err];
+                }
+            }
+            else                 if([item[@"control"] isEqualToString:@"signature"])
+            {
+                // 复制图片到打包目录
+                NSString* img_url_0=item[@"value"];
+             
+                
+                NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+                NSString *cachefolder = [paths objectAtIndex:0];
 //                    NSString *offline_createimg = [cachefolder stringByAppendingPathComponent:@"offline_createimg"];
-                    NSString *img_cache = [cachefolder stringByAppendingPathComponent:@"img_cache"];
-                    NSFileManager* fileManager=[NSFileManager defaultManager];
-                    if(img_url_0.length>0&&[fileManager fileExistsAtPath:[img_cache stringByAppendingPathComponent:img_url_0]])
-                    {
-                        NSError* err;
-                        [fileManager copyItemAtURL:[NSURL fileURLWithPath:[img_cache stringByAppendingPathComponent:img_url_0]] toURL:[NSURL fileURLWithPath:[orderdir stringByAppendingPathComponent:img_url_0]] error:&err];
-                    }
-   
+                NSString *img_cache = [cachefolder stringByAppendingPathComponent:@"img_cache"];
+                NSFileManager* fileManager=[NSFileManager defaultManager];
+                if(img_url_0.length>0&&[fileManager fileExistsAtPath:[img_cache stringByAppendingPathComponent:img_url_0]])
+                {
+                    NSError* err;
+                    [fileManager copyItemAtURL:[NSURL fileURLWithPath:[img_cache stringByAppendingPathComponent:img_url_0]] toURL:[NSURL fileURLWithPath:[orderdir stringByAppendingPathComponent:img_url_0]] error:&err];
                 }
+
             }
         }
+    }
 
-        NSString * parampath= [orderdir stringByAppendingPathComponent:@"param.json"];
-        
-        NSDictionary* param=[self convertScanOrder:self.content_data_download];
-        
-        [RAUtils dicttofile:parampath dict:param];
-        
-        NSString *contactpath = [orderdir stringByAppendingPathComponent:@"contact.json"];
-        
-        
-        if(appDelegate.customerInfo==nil)
-            appDelegate.customerInfo = [NSMutableDictionary new];
-        [RAUtils dicttofile:contactpath dict:appDelegate.customerInfo];
-        
-        
-        NSString *cartpath = [orderdir stringByAppendingPathComponent:@"cart.json"];
-        
-        RASingleton.sharedInstance.scan_cart[@"price_type"] = @(RASingleton.sharedInstance.price_type);
-        
-        [RAUtils dicttofile:cartpath dict:RASingleton.sharedInstance.scan_cart];
-        
-        NSString * zippath= [orderdir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.zip",appDelegate.order_code]];
-        
-        
+    NSString * parampath= [orderdir stringByAppendingPathComponent:@"param.json"];
+    
+    NSDictionary* param=[self convertScanOrder:self.content_data_download];
+    
+    [RAUtils dicttofile:parampath dict:param];
+    
+    NSString *contactpath = [orderdir stringByAppendingPathComponent:@"contact.json"];
+    
+    
+    if(appDelegate.customerInfo==nil)
+        appDelegate.customerInfo = [NSMutableDictionary new];
+    [RAUtils dicttofile:contactpath dict:appDelegate.customerInfo];
+    
+    
+    NSString *cartpath = [orderdir stringByAppendingPathComponent:@"cart.json"];
+    
+    RASingleton.sharedInstance.scan_cart[@"price_type"] = @(RASingleton.sharedInstance.price_type);
+    NSMutableDictionary* savecart = [[NSMutableDictionary dictionaryWithDictionary:RASingleton.sharedInstance.scan_cart] mutableCopy];
+    
+    if(newmodel)
+        savecart[@"section_0"]=newmodel;
+    [RAUtils dicttofile:cartpath dict:savecart];
+    
+    NSString * zippath= [orderdir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.zip",appDelegate.order_code]];
+    
+    
 //        NSError *error=nil;
 //
 //        [str writeToFile:jsonpath atomically:true encoding:NSUTF8StringEncoding error:&error];
-        
-        NSArray* arr_files=[RAUtils allFilesAtPath:orderdir];
-        
-        ZipArchive* zip = [[ZipArchive alloc] init];
-        
-        
+    
+    NSArray* arr_files=[RAUtils allFilesAtPath:orderdir];
+    
+    ZipArchive* zip = [[ZipArchive alloc] init];
+    
+    
 //        if ([[NSFileManager defaultManager] fileExistsAtPath:zippath]) {
 //
 //
@@ -3122,162 +3482,342 @@
 //
 //
 //      }
+    
+    BOOL r = [zip CreateZipFile2:zippath Password:@"usai2010"];
+    
+    for(int i=0;i<arr_files.count;i++)
+    {
+        NSString* file=arr_files[i];
         
-        BOOL r = [zip CreateZipFile2:zippath Password:@"usai2010"];
-        
-        for(int i=0;i<arr_files.count;i++)
+        r = [zip addFileToZip:file newname:[file lastPathComponent]];
+    }
+    
+    NSString * filepath=[[RADataProvider getSiteName] stringByAppendingPathComponent:appDelegate.user];
+    filepath=[filepath stringByAppendingPathComponent:appDelegate.order_code];
+    filepath=[filepath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.zip",appDelegate.order_code]];
+        if( ![zip CloseZipFile2] )
         {
-            NSString* file=arr_files[i];
-            
-            r = [zip addFileToZip:file newname:[file lastPathComponent]];
+            zippath = @"";
+            filepath =@"";
         }
-        
-        NSString * filepath=[[RADataProvider getSiteName] stringByAppendingPathComponent:appDelegate.user];
-        filepath=[filepath stringByAppendingPathComponent:appDelegate.order_code];
-        filepath=[filepath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.zip",appDelegate.order_code]];
-            if( ![zip CloseZipFile2] )
-            {
-                zippath = @"";
-                filepath =@"";
-            }
 
-        
-        NSString *md5 = [RAUtils md5WithFile:zippath];
+    
+    NSString *md5 = [RAUtils md5WithFile:zippath];
+    
+    
+    
+    {
+        //括号内为单个文件上传
+        NSString *fileName = [zippath lastPathComponent];
+        NSData * file_data= [NSData dataWithContentsOfFile:zippath];
         
         
+        NSString* realuser;
+        NSString* realpassword;
         
+        if(self.realuser.length>0)
         {
-            //括号内为单个文件上传
-            NSString *fileName = [zippath lastPathComponent];
-            NSData * file_data= [NSData dataWithContentsOfFile:zippath];
-            
-            
-            NSString* realuser;
-            NSString* realpassword;
-            
-            if(self.realuser.length>0)
+            realuser = self.realuser;
+            realpassword = self.realpassword;
+        }
+        else
+        {
+            realuser = appDelegate.user;
+            realpassword = appDelegate.password;
+        }
+        NSDictionary* params = @{
+//                @"site_name":[RADataProvider getSiteName],
+            @"user":realuser,
+            @"_method":@"uploadOfflineOrder",
+            @"password" : realpassword,
+            @"md5":md5
+                                 };
+        [RANetwork request_fastupload:[params mutableCopy] filename:fileName data:file_data url:appDelegate.uploadurl completionHandler:^(NSMutableDictionary *result) {
+                    int iresult = [result[@"result"] intValue];
+            if(iresult == RESULT_TRUE)
             {
-                realuser = self.realuser;
-                realpassword = self.realpassword;
+                NSString* soid = result[@"so_id"];
+                if(soid.length==0)
+                    soid=@"N/A";
+//                            upparams[@"soid"]=soid;
+                
+//                NSMutableDictionary* saveorder = [[NSMutableDictionary dictionaryWithDictionary:self.content_data_download] mutableCopy];
+                if(newmodel)
+                {    self.content_data_download[@"section_0"]=newmodel;
+                    self.content_data_download[@"readonly"]=@1;
+                }
+                [self scanSave:upparams];
+                NSString* company = upparams[@"customer_name"];
+                [OLDataProvider save2submitScanOrder:soid company:company];
+                [appDelegate closeOrder];
+                RASingleton.sharedInstance.scan_cart = nil;
+                
+                #ifdef RA_NOTIFICATION
+                                    [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+                #else
+                                    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+                                    [main_vc reloadCart:true immediately:false];
+                #endif
+                
+        //
+
+                
+                [self prepareReturn:nil];
+                
+                
+                
+                [self.navigationController popViewControllerAnimated:true];
+                [((MainViewController*)appDelegate.main_vc) switchToOrder];
+        //        NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
+        //        ret[@"result"]=@2;
+        //        ret[@"file"]=zippath;
+        //        result(ret);
+                return;
+            }
+            else if(iresult==1)
+            {
+                self.fail_submit = true;
+                self.realuser = nil;
+                self.realpassword = nil;
+                [RAUtils message_alert:@"Can not submit the order, wrong password" title:@"Submit Order" controller:self];
+                if ([[NSFileManager defaultManager] fileExistsAtPath:zippath]) {
+     
+                    
+                    [[NSFileManager defaultManager] removeItemAtPath:zippath error:nil];
+                    
+    //                    [orderlist addObject:appDelegate.order_code];
+    //                    [RAUtils dicttofile:orderlistPath dict:orderlist];
+                    
+              }
+                
+                
             }
             else
             {
-                realuser = appDelegate.user;
-                realpassword = appDelegate.password;
+                self.fail_submit = true;
+                [RAUtils message_alert:@"Can not submit the order, please check your network" title:@"Submit Order" controller:self];
+                
+                if ([[NSFileManager defaultManager] fileExistsAtPath:zippath]) {
+     
+                    
+                    [[NSFileManager defaultManager] removeItemAtPath:zippath error:nil];
+                    
+    //                    [orderlist addObject:appDelegate.order_code];
+    //                    [RAUtils dicttofile:orderlistPath dict:orderlist];
+                    
+              }
+                
             }
-            NSDictionary* params = @{
-//                @"site_name":[RADataProvider getSiteName],
-                @"user":realuser,
-                @"_method":@"uploadOfflineOrder",
-                @"password" : realpassword,
-                @"md5":md5
-                                     };
-                    [RANetwork request_fastupload:[params mutableCopy] filename:fileName data:file_data url:appDelegate.uploadurl completionHandler:^(NSMutableDictionary *result) {
-                                int iresult = [result[@"result"] intValue];
-                        if(iresult == RESULT_TRUE)
-                        {
-                            NSString* soid = result[@"so_id"];
-                            if(soid.length==0)
-                                soid=@"N/A";
-//                            upparams[@"soid"]=soid;
-                            [self scanSave:upparams];
-                            NSString* company = upparams[@"customer_name"];
-                            [OLDataProvider save2submitScanOrder:soid company:company];
-                            [appDelegate closeOrder];
-                            RASingleton.sharedInstance.scan_cart = nil;
-                            
-                            #ifdef RA_NOTIFICATION
-                                                [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-                            #else
-                                                MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-                                                [main_vc reloadCart:true immediately:false];
-                            #endif
-                            
-                    //
+        }];
+
 
-                            
-                            [self prepareReturn:nil];
-                            
-                            
-                            
-                            [self.navigationController popViewControllerAnimated:true];
-                            [((MainViewController*)appDelegate.main_vc) switchToOrder];
-                    //        NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
-                    //        ret[@"result"]=@2;
-                    //        ret[@"file"]=zippath;
-                    //        result(ret);
-                            return;
-                        }
-                        else if(iresult==1)
-                        {
-                            self.fail_submit = true;
-                            self.realuser = nil;
-                            self.realpassword = nil;
-                            [RAUtils message_alert:@"Can not submit the order, wrong password" title:@"Submit Order" controller:self];
-                            if ([[NSFileManager defaultManager] fileExistsAtPath:zippath]) {
-                 
-                                
-                                [[NSFileManager defaultManager] removeItemAtPath:zippath error:nil];
-                                
-                //                    [orderlist addObject:appDelegate.order_code];
-                //                    [RAUtils dicttofile:orderlistPath dict:orderlist];
-                                
-                          }
-                            
-                            
-                        }
-                        else
-                        {
-                            self.fail_submit = true;
-                            [RAUtils message_alert:@"Can not submit the order, please check your network" title:@"Submit Order" controller:self];
-                            
-                            if ([[NSFileManager defaultManager] fileExistsAtPath:zippath]) {
-                 
-                                
-                                [[NSFileManager defaultManager] removeItemAtPath:zippath error:nil];
-                                
-                //                    [orderlist addObject:appDelegate.order_code];
-                //                    [RAUtils dicttofile:orderlistPath dict:orderlist];
-                                
-                          }
-                            
-                        }
-                    }];
-        }
         
-//        [self addTasks:filepath md5:md5];
+       
         
+                        }
+    
 
-      
+    return;
+}
+
+- (void)empolyee_commit_order:(NSMutableDictionary *)upparams {
+    
+    
+    
+#ifdef SCANNER_ORDER
+    
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    
+    NSString* realuser;
+    NSString* realpassword;
+    
+    if(self.realuser.length>0)
+    {
+        realuser = self.realuser;
+        realpassword = self.realpassword;
+    }
+    else
+    {
+        realuser = appDelegate.user;
+        realpassword = appDelegate.password;
+    }
+    if(appDelegate.user_type==USER_ROLE_CUSTOMER || [upparams[@"customer_cid"] stringValue].length>0 ||[appDelegate.user.uppercaseString isEqualToString:@"GUEST"])
+    {
+        NSMutableDictionary* param = [NSMutableDictionary new];
+        
+
+        
+        NSString* model = [self scan_stock];
+        param[@"models"]=model;
+        param[@"customer_cid"]=upparams[@"customer_cid"];
+        param[@"user"]=realuser;
+        param[@"password"]=realpassword;
         
+        
+        [RADataProvider request_scan_stock:param completionHandler:^(NSMutableDictionary *result) {
+            
+            if([result[@"result"] intValue]==2)
+            {
+                
+                NSMutableArray* models = [result[@"models"] mutableCopy];
+                if(models.count==0)
+                {
+                    //不可拆分,直接提交
+                    [self scan_commit:upparams newmodel:nil];
+                }
+                else
+                {
+                    StockViewController * vc =[[UIStoryboard storyboardWithName:@"SO" bundle:nil] instantiateViewControllerWithIdentifier:@"StockViewController"];
 //
-//        [OLDataProvider save2submitScanOrder];
+//                            NSMutableArray* testmodels =[[RAConvertor string2dict:@"[{\"model\":\"1420-1*\",\"count\":1,\"is_back_order\":true,\"etd\":\"2022-06-23\"},{\"model\":\"1420-1*\",\"count\":1,\"is_back_order\":false,\"etd\":\"2022-06-23\"}]"] mutableCopy];
+                    NSMutableArray* testmodels =[[RAConvertor string2dict:@"[{\"model\":\"1420-1*\",\"count\":1,\"is_back_order\":false,\"etd\":\"2022-06-23\"}]"] mutableCopy];
+                    
+//                    models = testmodels;
+                    
+                    models = [self scan_split_models:models];
+                    vc.data =models;
+                    vc.returnValue = ^(NSMutableDictionary * _Nonnull models) {
+//                                model
+//                        int i=0;
+//                        RASingleton.sharedInstance.scan_cart[@"section_0"]=models;
+//                        self.content_data_download[@"section_0"]=models;
+                        [self scan_commit:upparams newmodel:models];
+                        return;
+                    };
+                    
+                    UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:vc] ;
+                    
+                    
+                    
+                    
+                    
+                    //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
+                    
+//                            navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
+                    [self presentViewController:navi animated:YES completion:^{
+                        
+                        //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
+                        
+                        DebugLog(@"EditModelPriceViewController present.........");
+                        
+                        //   self.btop = false;
+                        //  <#code#>
+                    }];
+                }
+                
+
+              
+                
+            }
+            else if([result[@"result"] intValue]==1)
+            {
+                self.fail_submit = true;
+                self.realuser = nil;
+                self.realpassword = nil;
+                [RAUtils message_alert:@"Can not submit the order, wrong password" title:@"Submit Order" controller:self];
+//                if ([[NSFileManager defaultManager] fileExistsAtPath:zippath]) {
 //
-//        [appDelegate closeOrder];
-//        RASingleton.sharedInstance.scan_cart = nil;
 //
-//        #ifdef RA_NOTIFICATION
-//                            [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-//        #else
-//                            MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
-//                            [main_vc reloadCart:true immediately:false];
-//        #endif
+//                    [[NSFileManager defaultManager] removeItemAtPath:zippath error:nil];
 //
-////
+//    //                    [orderlist addObject:appDelegate.order_code];
+//    //                    [RAUtils dicttofile:orderlistPath dict:orderlist];
 //
+//              }
+                return;
+                
+            }
+            
+            
+            
+            
+            
+          
+           
+            
+            
+
+        }];
+    }
+    else
+    {
+        //无contact 直接提交
+        [self scan_commit:upparams newmodel:nil];
+//        [RANetwork request_fastupload:[params mutableCopy] filename:fileName data:file_data url:appDelegate.uploadurl completionHandler:^(NSMutableDictionary *result) {
+//                    int iresult = [result[@"result"] intValue];
+//            if(iresult == RESULT_TRUE)
+//            {
+//                NSString* soid = result[@"so_id"];
+//                if(soid.length==0)
+//                    soid=@"N/A";
+////                            upparams[@"soid"]=soid;
+//                [self scanSave:upparams];
+//                NSString* company = upparams[@"customer_name"];
+//                [OLDataProvider save2submitScanOrder:soid company:company];
+//                [appDelegate closeOrder];
+//                RASingleton.sharedInstance.scan_cart = nil;
 //
-//        [self prepareReturn:nil];
+//                #ifdef RA_NOTIFICATION
+//                                    [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+//                #else
+//                                    MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+//                                    [main_vc reloadCart:true immediately:false];
+//                #endif
 //
+//        //
 //
 //
-//        [self.navigationController popViewControllerAnimated:true];
-//        [((MainViewController*)appDelegate.main_vc) switchToOrder];
-////        NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
-////        ret[@"result"]=@2;
-////        ret[@"file"]=zippath;
-////        result(ret);
-        return;
+//                [self prepareReturn:nil];
+//
+//
+//
+//                [self.navigationController popViewControllerAnimated:true];
+//                [((MainViewController*)appDelegate.main_vc) switchToOrder];
+//        //        NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
+//        //        ret[@"result"]=@2;
+//        //        ret[@"file"]=zippath;
+//        //        result(ret);
+//                return;
+//            }
+//            else if(iresult==1)
+//            {
+//                self.fail_submit = true;
+//                self.realuser = nil;
+//                self.realpassword = nil;
+//                [RAUtils message_alert:@"Can not submit the order, wrong password" title:@"Submit Order" controller:self];
+//                if ([[NSFileManager defaultManager] fileExistsAtPath:zippath]) {
+//
+//
+//                    [[NSFileManager defaultManager] removeItemAtPath:zippath error:nil];
+//
+//    //                    [orderlist addObject:appDelegate.order_code];
+//    //                    [RAUtils dicttofile:orderlistPath dict:orderlist];
+//
+//              }
+//
+//
+//            }
+//            else
+//            {
+//                self.fail_submit = true;
+//                [RAUtils message_alert:@"Can not submit the order, please check your network" title:@"Submit Order" controller:self];
+//
+//                if ([[NSFileManager defaultManager] fileExistsAtPath:zippath]) {
+//
+//
+//                    [[NSFileManager defaultManager] removeItemAtPath:zippath error:nil];
+//
+//    //                    [orderlist addObject:appDelegate.order_code];
+//    //                    [RAUtils dicttofile:orderlistPath dict:orderlist];
+//
+//              }
+//
+//            }
+//        }];
+
+        
     }
+    return;
     
 #endif
     

+ 1 - 1
RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m

@@ -710,7 +710,7 @@
     if(appDelegate.offline_mode)
     {
         
-        NSData *data = [OLDataProvider offline_saveBusinesscard:UIImagePNGRepresentation(img)];;
+        NSData *data = [OLDataProvider offline_saveBusinesscard:UIImageJPEGRepresentation(img,1.0f)];;
         
         // 再将NSData转为字符串
         NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

+ 1 - 1
RedAnt ERP Mobile/common/const.h

@@ -129,7 +129,7 @@
 #define  ACTION_SAVE_DATA 0
 #define ACTION_FILL_SECTION 1
 
-#define JSON_TIMEOUT 60
+//#define JSON_TIMEOUT 60
 
 #ifndef dispatch_queue_async_safe
 #define dispatch_queue_async_safe(queue, block)\

+ 2 - 2
RedAnt ERP Mobile/common/customUI/ImageUploadViewController.m

@@ -226,7 +226,7 @@
 //    if(RASingleton.sharedInstance.enable_OfflineOrder)
     {
         
-        NSData *data = [OLDataProvider offline_saveBusinesscard:UIImagePNGRepresentation(self.imgview.image)];;
+        NSData *data = [OLDataProvider offline_saveBusinesscard:UIImageJPEGRepresentation(self.imgview.image,1.0f)];;
         
         // 再将NSData转为字符串
         NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
@@ -261,7 +261,7 @@
     if(appDelegate.offline_mode)
     {
         
-        NSData *data = [OLDataProvider offline_saveBusinesscard:UIImagePNGRepresentation(self.imgview.image)];;
+        NSData *data = [OLDataProvider offline_saveBusinesscard:UIImageJPEGRepresentation(self.imgview.image,1.0f)];;
         
         // 再将NSData转为字符串
         NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

+ 4 - 0
RedAnt ERP Mobile/common/data_provider/RADataProvider.h

@@ -9,6 +9,7 @@
 #import <Foundation/Foundation.h>
 #import "NetworkUtils.h"
 #import "RANetwork.h"
+#import "AESCrypt.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
@@ -21,10 +22,13 @@ NS_ASSUME_NONNULL_BEGIN
 +(void)request_scansearch:(long ) offset limit :(long)limit keywords :(NSString*) keywords completionHandler:(resultHandler)result;
 +(void)request_scan_server:(resultHandler)result;
 +(void)request_scan_news:(resultHandler)result;
++(void)request_scan_stock:(NSMutableDictionary*)param completionHandler:(resultHandler)result;
 +(void)request_sign_up:user email:(NSString*)email password:(NSString*) pwd completionHandler:(resultHandler)result;
 +(void)request_validate_scan_server:(NSString*)url name:(NSString*)name password:(NSString*)password completionHandler:(resultHandler)result;
 +(NSString*)getSiteName;
 +(void)request_change_password:(NSString*) pwd completionHandler:(resultHandler)result;
++(void)load_scan_models;
++(NSArray*)request_scan_model_by_names:(NSString*)names;
 @end
 
 NS_ASSUME_NONNULL_END

+ 168 - 2
RedAnt ERP Mobile/common/data_provider/RADataProvider.m

@@ -10,6 +10,134 @@
 
 @implementation RADataProvider
 
++(NSArray*)request_scan_model_by_names:(NSString*)names
+{
+    AppDelegate *appDelegate = nil;
+    
+    appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+    
+    NSMutableArray* models=[NSMutableArray new];
+    
+    NSArray* arrname=[RAConvertor string2dict:names];
+    for(int i=0;i<arrname.count;i++)
+    {
+        NSString* key = arrname[i];
+        NSDictionary* m=appDelegate.scan_model[key];
+        if(m!=nil)
+        [models addObject:m];
+        
+        
+    }
+    return models;
+    
+}
+
++(void)load_scan_models
+{
+    
+    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+    NSString *documents = [paths objectAtIndex:0];
+    NSString* unZipTo=[documents stringByAppendingPathComponent:@"download"];
+    NSString* templatefile = [unZipTo stringByAppendingPathComponent:@"offline_models.json"];
+
+    NSString* str = [NSString stringWithContentsOfFile:templatefile encoding:NSUTF8StringEncoding error:nil];
+//    NSString * str3 = [AESCrypt decrypt:str password:@"usai2010"];
+    NSMutableDictionary* of = [[RAConvertor string2dict:str] mutableCopy];
+//    NSData *filedata = [NSData dataWithContentsOfFile:path];
+//    if(filedata == nil)
+//        return nil;
+//    NSError *error = nil;
+//    NSDictionary *string2dic = [NSJSONSerialization JSONObjectWithData: filedata
+//                                                               options: NSJSONReadingMutableContainers
+//                                                                 error: &error];
+    // DebugLog(@"%@",string2dic);
+    
+//    NSString* str =@"";
+//    NSMutableDictionary* item = [@{
+//        @"product_id": @"114",
+//        @"model": @"1420K-1EK*",
+//        @"description": @"Eastern King Platform Bed with Footboard Storage",
+//        @"dimension": @"82 x 91.5 x 59.5H",
+//        @"stockUom": @"1",
+//        @"unit_cuft": @"34.602",
+//        @"port": @"VIET",
+//        @"origin": @"VCGS",
+//        @"available": @"Apr",
+//        @"Fremont_DDP": @"289",
+//        @"Fremont_WHSE": @"429"
+//    } mutableCopy];
+//    NSMutableDictionary* of = [NSMutableDictionary new];
+//    for(int i=0;i<4000;i++)
+//    {
+//        item[@"product_id"]=[NSString stringWithFormat:@"pid_%d",i];
+//        of[[NSString stringWithFormat:@"model_%d",i]]=item;
+//    }
+//
+//    NSString* strof=[RAConvertor dict2string:of];
+//
+//
+//           NSString* str2 = [AESCrypt encrypt:strof password:@"usai2010"];
+//            NSString * str3 = [AESCrypt decrypt:str2 password:@"usai2010"];
+    
+    
+    NSArray* keysort=[self sortedDictionary:of];
+    
+    AppDelegate *appDelegate = nil;
+    
+    appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+    
+    appDelegate.scan_model = of;
+    appDelegate.scan_model_key=keysort;
+    
+    
+}
++ (NSArray*)sortedDictionary:(NSDictionary *)dict{
+    
+    //将所有的key放进数组
+    NSArray *allKeyArray = [dict allKeys];
+    
+    //序列化器对数组进行排序的block 返回值为排序后的数组
+    NSArray *afterSortKeyArray = [allKeyArray sortedArrayUsingComparator:^NSComparisonResult(id  _Nonnull obj1, id
+    _Nonnull obj2) {
+        /**
+          In the compare: methods, the range argument specifies the
+          subrange, rather than the whole, of the receiver to use in the
+          comparison. The range is not applied to the search string.  For
+          example, [@"AB" compare:@"ABC" options:0 range:NSMakeRange(0,1)]
+          compares "A" to "ABC", not "A" to "A", and will return
+          NSOrderedAscending. It is an error to specify a range that is
+          outside of the receiver's bounds, and an exception may be raised.
+         
+        - (NSComparisonResult)compare:(NSString *)string;
+         
+         compare方法的比较原理为,依次比较当前字符串的第一个字母:
+         如果不同,按照输出排序结果
+         如果相同,依次比较当前字符串的下一个字母(这里是第二个)
+         以此类推
+         
+         排序结果
+         NSComparisonResult resuest = [obj1 compare:obj2];为从小到大,即升序;
+         NSComparisonResult resuest = [obj2 compare:obj1];为从大到小,即降序;
+         
+         注意:compare方法是区分大小写的,即按照ASCII排序
+         */
+        //排序操作
+        NSComparisonResult resuest = [obj1 compare:obj2];
+        return resuest;
+    }];
+    
+    return afterSortKeyArray;
+//    NSLog(@"afterSortKeyArray:%@",afterSortKeyArray);
+    
+//    //通过排列的key值获取value
+//    NSMutableArray *valueArray = [NSMutableArray array];
+//    for (NSString *sortsing in afterSortKeyArray) {
+//        NSString *valueString = [dict objectForKey:sortsing];
+//        [valueArray addObject:valueString];
+//    }
+//    NSLog(@"valueArray:%@",valueArray);
+}
+
 +(void) request_scan_news:(resultHandler)result
 {
     
@@ -18,6 +146,14 @@
     [self request_interface:URL_SCAN_NEWS parameters:param err_record_url:nil completionHandler:result retry:0];
 }
 
++(void)request_scan_stock:(NSMutableDictionary*)param completionHandler:(resultHandler)result
+{
+
+//    
+    param[@"_method"]=@"orderItemCheckStock";
+    [self request_interface:URL_SCAN_NEWS parameters:param err_record_url:nil completionHandler:result retry:0];
+}
+
 +(void) request_scan_server :(resultHandler)result
 {
     
@@ -117,12 +253,42 @@
     NSString* url = [appDelegate.address stringByAppendingPathComponent:URL_SIGN_UP];
     [self request_interface:url parameters:param err_record_url:nil completionHandler:result retry:0];
 }
-
-+(void)request_scansearch:(long ) offset limit :(long)limit keywords :(NSString*) keywords completionHandler:(resultHandler)result
++(NSMutableDictionary*)scan_search:(NSString*)keyword
 {
+//    NSMutableArray* arr = [NSMutableArray new];
+    
+    int count = 0;
+    NSMutableDictionary * ret = [NSMutableDictionary new];
+    ret[@"result"]=@2;
+    AppDelegate *appDelegate = nil;
     
+    appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
+    
+//    NSArray* keys=[dict allKeys];
     
+    for(int i=0;i<appDelegate.scan_model_key.count;i++)
+    {
+        NSString* key = appDelegate.scan_model_key[i];
+        if([key.lowercaseString containsString:keyword.lowercaseString]||keyword.length==0)
+        {
+            ret[[NSString stringWithFormat:@"item_%d",count]]=appDelegate.scan_model[key];
+//            [arr addObject:dict[key]];
+            count ++;
+        }
+        
+        
+    }
+    ret[@"count"]=@(count);
+    return ret;
+//    int a=0;
+    
+}
++(void)request_scansearch:(long ) offset limit :(long)limit keywords :(NSString*) keywords completionHandler:(resultHandler)result
+{
+
+    result([self scan_search:keywords]);
     
+    return;
     
     NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
     AppDelegate *appDelegate = nil;

+ 2 - 2
RedAnt ERP Mobile/common/data_provider/RANetwork.m

@@ -98,9 +98,9 @@ NSString *const ScreenCodeOfflineSync = @"Offline Sync Screen";
     
     
     
-    if(appDelegate.user!=nil)
+    if(appDelegate.user!=nil && params[@"user"]==nil)
         [params setValue:appDelegate.user forKey:@"user"];
-    if(appDelegate.password!=nil)
+    if(appDelegate.password!=nil&& params[@"password"]==nil)
         [params setValue:appDelegate.password forKey:@"password"];
     
     

+ 1 - 1
RedAnt ERP Mobile/iSales-CONTRAST.xcodeproj/xcuserdata/ruizhang.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -7,7 +7,7 @@
 		<key>iSales-CONTRAST.xcscheme_^#shared#^_</key>
 		<dict>
 			<key>orderHint</key>
-			<integer>4</integer>
+			<integer>2</integer>
 		</dict>
 		<key>iSales-USAI.xcscheme_^#shared#^_</key>
 		<dict>

+ 13 - 4
common/customUI/CommonEditoriPad/iPadCommonEditorCellModel.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="ipad9_7" orientation="portrait" layout="fullscreen" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15509"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -46,7 +46,7 @@
                         <nil key="highlightedColor"/>
                     </label>
                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Masert pack:9999" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DiR-zl-kj1">
-                        <rect key="frame" x="461" y="15" width="142" height="21"/>
+                        <rect key="frame" x="462" y="15" width="140.5" height="21"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="21" id="wOR-Sp-CYC"/>
                         </constraints>
@@ -90,13 +90,19 @@
                         <fontDescription key="fontDescription" type="system" pointSize="17"/>
                         <nil key="highlightedColor"/>
                     </label>
-                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cdV-EN-AC5">
+                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cdV-EN-AC5">
                         <rect key="frame" x="128" y="102" width="46" height="29"/>
                         <state key="normal" title="Button"/>
                         <connections>
                             <action selector="onClickBundle:" destination="Vb5-DF-E1M" eventType="touchUpInside" id="VBL-I9-GQ8"/>
                         </connections>
                     </button>
+                    <label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Backorder" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GqP-L3-Ygz">
+                        <rect key="frame" x="342.5" y="105.5" width="83" height="22"/>
+                        <fontDescription key="fontDescription" type="system" pointSize="18"/>
+                        <color key="textColor" red="1" green="0.14913141730000001" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                        <nil key="highlightedColor"/>
+                    </label>
                 </subviews>
                 <constraints>
                     <constraint firstItem="N4y-kV-Abh" firstAttribute="baseline" secondItem="cdV-EN-AC5" secondAttribute="firstBaseline" id="0O8-Hl-JaX"/>
@@ -118,10 +124,12 @@
                     <constraint firstItem="N4y-kV-Abh" firstAttribute="top" secondItem="Qde-5C-KXh" secondAttribute="bottom" constant="10" id="PcC-6b-dya"/>
                     <constraint firstItem="hlq-ia-5c5" firstAttribute="leading" secondItem="eSO-cn-6Wf" secondAttribute="leading" constant="20" id="QPG-zA-u3c"/>
                     <constraint firstAttribute="trailing" secondItem="Qde-5C-KXh" secondAttribute="trailing" constant="22" id="Tvt-Ho-K1B"/>
+                    <constraint firstItem="GqP-L3-Ygz" firstAttribute="centerX" secondItem="eSO-cn-6Wf" secondAttribute="centerX" id="UAK-pn-JQi"/>
                     <constraint firstItem="cdV-EN-AC5" firstAttribute="top" secondItem="4Eu-9D-ElM" secondAttribute="bottom" constant="6" id="YT2-Gs-JqW"/>
                     <constraint firstItem="4Eu-9D-ElM" firstAttribute="top" secondItem="eSO-cn-6Wf" secondAttribute="topMargin" constant="4" id="aX4-Mb-oyU"/>
                     <constraint firstItem="cdV-EN-AC5" firstAttribute="centerY" secondItem="N4y-kV-Abh" secondAttribute="centerY" id="ajc-Ly-TM1"/>
                     <constraint firstItem="4Eu-9D-ElM" firstAttribute="centerY" secondItem="MWP-U1-4gi" secondAttribute="centerY" id="blT-Ga-63C"/>
+                    <constraint firstItem="N4y-kV-Abh" firstAttribute="centerY" secondItem="GqP-L3-Ygz" secondAttribute="centerY" id="eyK-zm-hHY"/>
                     <constraint firstItem="4Eu-9D-ElM" firstAttribute="firstBaseline" secondItem="DiR-zl-kj1" secondAttribute="firstBaseline" id="gP3-dY-QUS"/>
                     <constraint firstAttribute="trailing" secondItem="N4y-kV-Abh" secondAttribute="trailing" constant="22" id="ixr-Lm-1eI"/>
                     <constraint firstItem="DiR-zl-kj1" firstAttribute="baseline" secondItem="31Q-hs-9l0" secondAttribute="baseline" id="mbF-hK-hgR"/>
@@ -131,6 +139,7 @@
             <connections>
                 <outlet property="buttonBundle" destination="cdV-EN-AC5" id="BCS-gt-WIe"/>
                 <outlet property="imgModel" destination="hlq-ia-5c5" id="68c-Yh-RnQ"/>
+                <outlet property="labelBackOrder" destination="GqP-L3-Ygz" id="poD-yA-LSX"/>
                 <outlet property="labelCount" destination="Qde-5C-KXh" id="qPZ-MD-HK8"/>
                 <outlet property="labelDescription" destination="4Eu-9D-ElM" id="ykc-kw-x3k"/>
                 <outlet property="labelDiscount" destination="3a4-O9-TRc" id="4hM-a3-mAn"/>

+ 1 - 0
common/customUI/commoneditor/CommonEditorCellModel.h

@@ -26,5 +26,6 @@
 
 @property (strong, nonatomic) IBOutlet UIButton *masterBtn;
 @property (nonatomic,strong) NSDictionary *master_items;
+@property (weak, nonatomic) IBOutlet UILabel *labelBackOrder;
 
 @end

+ 31 - 7
common/customUI/commoneditor/CommonEditorViewController.m

@@ -3495,7 +3495,7 @@ if(!self.alert.isBeingDismissed)
                 }
                 else
                 {
-                    cell.touchImageView0.image=nil;
+                    cell.touchImageView0.image=[UIImage imageNamed:@"camera_s"];
                     cell.imgs[0]=@"";
                 }
             }
@@ -3556,7 +3556,7 @@ if(!self.alert.isBeingDismissed)
                 }
                 else
                 {
-                    cell.touchImageView1.image=nil;
+                    cell.touchImageView1.image=[UIImage imageNamed:@"camera_s"];
                     cell.imgs[1]=@"";
                 }
             }
@@ -3613,7 +3613,7 @@ if(!self.alert.isBeingDismissed)
                     }}
                 else
                 {
-                    cell.touchImageView2.image=nil;
+                    cell.touchImageView2.image=[UIImage imageNamed:@"camera_s"];
                     cell.imgs[2]=@"";
                 }
             }
@@ -3942,7 +3942,7 @@ if(!self.alert.isBeingDismissed)
     {
         CellIdentifier = @"CommonEditorCellMAction";
         CommonEditorCellMAction * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-        
+        int disabble = [[item_json objectForKey:@"disable"] intValue];
         int count = [[item_json valueForKey:@"count"]intValue];
         
         for(int i=0;i<count;i++)
@@ -3954,21 +3954,32 @@ if(!self.alert.isBeingDismissed)
                     [cell.btn_action0 setTitle:title forState:UIControlStateNormal];
                     [cell.btn_action0 addTarget:self action:@selector(MActionClicked:) forControlEvents:UIControlEventTouchUpInside];
                     cell.btn_action0.hidden = NO;
+                    if (disabble==1 || readonly)
+                        cell.btn_action0.enabled =false;
                     break;
                 case 1:
                     [cell.btn_action1 setTitle:title forState:UIControlStateNormal];
                     [cell.btn_action1 addTarget:self action:@selector(MActionClicked:) forControlEvents:UIControlEventTouchUpInside];
                     cell.btn_action1.hidden = NO;
+                    if (disabble==1 || readonly)
+                        cell.btn_action1.enabled =false;
+
                     break;
                 case 2:
                     [cell.btn_action2 setTitle:title forState:UIControlStateNormal];
                     [cell.btn_action2 addTarget:self action:@selector(MActionClicked:) forControlEvents:UIControlEventTouchUpInside];
                     cell.btn_action2.hidden = NO;
+
+                    if (disabble==1 || readonly)
+                        cell.btn_action2.enabled =false;
                     break;
                 case 3:
                     [cell.btn_action3 setTitle:title forState:UIControlStateNormal];
                     [cell.btn_action3 addTarget:self action:@selector(MActionClicked:) forControlEvents:UIControlEventTouchUpInside];
                     cell.btn_action3.hidden = NO;
+                    if (disabble==1 || readonly)
+                        cell.btn_action3.enabled =false;
+
                     break;
                 default:
                     break;
@@ -4286,9 +4297,22 @@ if(!self.alert.isBeingDismissed)
             int stockUom =[[item_json valueForKey:@"stockUom"] intValue];
             double discount =[[item_json valueForKey:@"discount"] doubleValue];
             NSString* discountstr=[NSString stringWithFormat:@"%@%% off", [RAUtils FloatFormat:discount]];
-            
+
             
             NSString* oldprice =[NSString stringWithFormat:@"%.2f",unitprice];
+            
+#ifdef SCANNER_ORDER
+            if([item_json[@"is_back_order"] boolValue])
+            {
+                cell.labelBackOrder.hidden=false;
+                cell.contentView.backgroundColor = UIColor.yellowColor;
+            }
+            else
+            {
+                cell.labelBackOrder.hidden=true;
+                cell.contentView.backgroundColor = UIColor.whiteColor;
+            }
+#endif
             NSString* newunitprice=@"";
             if(dprice>0)
             newunitprice = [NSString stringWithFormat:@"%.2f+%.2f",unitprice* (1.0-discount/100),dprice];
@@ -5039,7 +5063,7 @@ if(!self.alert.isBeingDismissed)
                     
                    
                     
-                    NSData *data = [OLDataProvider offline_saveBusinesscard:UIImagePNGRepresentation(img)];
+                    NSData *data = [OLDataProvider offline_saveBusinesscard:UIImageJPEGRepresentation(img,1.0f)];
                     
                     // 再将NSData转为字符串
                     NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
@@ -5098,7 +5122,7 @@ if(!self.alert.isBeingDismissed)
                     
                    
                     
-                    NSData *data = [OLDataProvider offline_saveBusinesscard:UIImagePNGRepresentation(img)];
+                    NSData *data = [OLDataProvider offline_saveBusinesscard:UIImageJPEGRepresentation(img,1.0f)];
                     
                     // 再将NSData转为字符串
                     NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików