Переглянути джерело

hmlg scan order 1.11,修复1.10 测试发现的bug
增加guest 快捷登陆
增加保存购物车
修改价格显示
增加针对审核的隐藏服务器选择界面逻辑

Ray Zhang 3 роки тому
батько
коміт
c2a9836be8
24 змінених файлів з 1279 додано та 310 видалено
  1. 4 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. 12 1
      RedAnt ERP Mobile/HMLG Scan Order/Base.lproj/Main.storyboard
  4. 1 0
      RedAnt ERP Mobile/HMLG Scan Order/MainViewController.h
  5. 266 1
      RedAnt ERP Mobile/HMLG Scan Order/MainViewController.m
  6. 371 269
      RedAnt ERP Mobile/HMLG Scan Order/SO.storyboard
  7. 3 0
      RedAnt ERP Mobile/HMLG Scan Order/ScanListCell.h
  8. 47 4
      RedAnt ERP Mobile/HMLG Scan Order/ScanListCell.m
  9. 2 0
      RedAnt ERP Mobile/HMLG Scan Order/ScanModelListCell.h
  10. 43 3
      RedAnt ERP Mobile/HMLG Scan Order/ScanModelListCell.m
  11. 5 1
      RedAnt ERP Mobile/HMLG Scan Order/SetupServerViewController.m
  12. 53 0
      RedAnt ERP Mobile/common/AppDelegateBase.m
  13. 3 3
      RedAnt ERP Mobile/common/ERP_Mobile_Order.storyboard
  14. 2 2
      RedAnt ERP Mobile/common/Functions/OLO/ScanOrderListViewController.m
  15. 197 1
      RedAnt ERP Mobile/common/Functions/cart/CartViewController.m
  16. 1 1
      RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.h
  17. 3 2
      RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m
  18. 128 14
      RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m
  19. 1 0
      RedAnt ERP Mobile/common/Functions/sidemenu/LoginViewController.h
  20. 10 0
      RedAnt ERP Mobile/common/Functions/sidemenu/LoginViewController.m
  21. 1 1
      RedAnt ERP Mobile/common/data_provider/RADataProvider.h
  22. 119 1
      RedAnt ERP Mobile/common/data_provider/RADataProvider.m
  23. 1 1
      RedAnt ERP Mobile/common/data_provider/RANetwork.m
  24. 5 0
      common/RAUtils.m

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

@@ -2713,7 +2713,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 51285;
+				CURRENT_PROJECT_VERSION = 51332;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -2730,7 +2730,7 @@
 					"$(PROJECT_DIR)/ScanApiSDK-10.2.227-2/lib",
 					"$(PROJECT_DIR)/GoogleAnalytics/GoogleAnalytics/Libraries",
 				);
-				MARKETING_VERSION = 1.10;
+				MARKETING_VERSION = 1.11;
 				OTHER_LDFLAGS = (
 					"$(inherited)",
 					"-ObjC",
@@ -2757,7 +2757,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 51285;
+				CURRENT_PROJECT_VERSION = 51332;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -2774,7 +2774,7 @@
 					"$(PROJECT_DIR)/ScanApiSDK-10.2.227-2/lib",
 					"$(PROJECT_DIR)/GoogleAnalytics/GoogleAnalytics/Libraries",
 				);
-				MARKETING_VERSION = 1.10;
+				MARKETING_VERSION = 1.11;
 				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>7</integer>
+			<integer>2</integer>
 		</dict>
 	</dict>
 </dict>

+ 12 - 1
RedAnt ERP Mobile/HMLG Scan Order/Base.lproj/Main.storyboard

@@ -561,6 +561,14 @@
                                     <color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 </state>
                             </button>
+                            <button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mLS-MS-2Jr">
+                                <rect key="frame" x="293.5" y="219.5" width="126.5" height="31"/>
+                                <state key="normal" title="Button"/>
+                                <buttonConfiguration key="configuration" style="plain" title="Sign in as guest"/>
+                                <connections>
+                                    <action selector="onGuestClick:" destination="Q1j-qK-Nq8" eventType="touchUpInside" id="9Kn-SA-Z2p"/>
+                                </connections>
+                            </button>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="20z-6W-PvH">
                                 <rect key="frame" x="296" y="224" width="124" height="22"/>
                                 <constraints>
@@ -667,6 +675,7 @@
                             <constraint firstItem="B5F-AY-BkK" firstAttribute="leading" secondItem="2AI-yS-Vfe" secondAttribute="leading" id="C5V-5F-xxp"/>
                             <constraint firstItem="20z-6W-PvH" firstAttribute="trailing" secondItem="e4L-J6-NNX" secondAttribute="trailing" id="F8M-cK-QME"/>
                             <constraint firstItem="CZM-O3-JlR" firstAttribute="top" secondItem="3dj-qP-iVc" secondAttribute="bottom" constant="8" id="FSS-Qf-IC9"/>
+                            <constraint firstItem="20z-6W-PvH" firstAttribute="centerY" secondItem="mLS-MS-2Jr" secondAttribute="centerY" id="J9x-ru-Rrv"/>
                             <constraint firstItem="E3s-Bo-qWx" firstAttribute="trailing" secondItem="CZM-O3-JlR" secondAttribute="trailing" constant="20" id="QNS-eu-p2q"/>
                             <constraint firstItem="E3s-Bo-qWx" firstAttribute="bottom" secondItem="CZM-O3-JlR" secondAttribute="bottom" constant="20" id="RFM-nE-ZoK"/>
                             <constraint firstItem="2AI-yS-Vfe" firstAttribute="top" secondItem="E3s-Bo-qWx" secondAttribute="top" constant="67" id="X4o-Ve-shM"/>
@@ -679,6 +688,7 @@
                             <constraint firstItem="20z-6W-PvH" firstAttribute="bottom" secondItem="B5F-AY-BkK" secondAttribute="bottom" id="oiO-3K-qoF"/>
                             <constraint firstItem="pO9-Lj-YQb" firstAttribute="trailing" secondItem="e4L-J6-NNX" secondAttribute="trailing" id="p1K-RF-wFX"/>
                             <constraint firstItem="E3s-Bo-qWx" firstAttribute="trailing" secondItem="e4L-J6-NNX" secondAttribute="trailing" constant="60" id="pN5-Nz-h0t"/>
+                            <constraint firstItem="20z-6W-PvH" firstAttribute="trailing" secondItem="mLS-MS-2Jr" secondAttribute="trailing" id="qsc-Bv-2Xs"/>
                             <constraint firstItem="oCu-XS-jr9" firstAttribute="trailing" secondItem="e4L-J6-NNX" secondAttribute="trailing" id="x8C-kd-WnK"/>
                             <constraint firstItem="3dj-qP-iVc" firstAttribute="top" secondItem="e4L-J6-NNX" secondAttribute="bottom" id="xIq-bZ-ffe"/>
                             <constraint firstItem="oCu-XS-jr9" firstAttribute="top" secondItem="e4L-J6-NNX" secondAttribute="bottom" constant="9" id="xiC-xJ-kR0"/>
@@ -698,6 +708,7 @@
                     <connections>
                         <outlet property="Loginlist" destination="3dj-qP-iVc" id="XaJ-eX-qBn"/>
                         <outlet property="bb_close" destination="Rl4-6e-kHm" id="0Mj-Do-OjV"/>
+                        <outlet property="btnGuest" destination="mLS-MS-2Jr" id="fhO-7d-LL1"/>
                         <outlet property="btnLogin" destination="CZM-O3-JlR" id="unz-tZ-32M"/>
                         <outlet property="checkOfflineMode" destination="20z-6W-PvH" id="dce-H9-djn"/>
                         <outlet property="checkSavePassword" destination="B5F-AY-BkK" id="zzE-TR-Jcm"/>
@@ -2018,7 +2029,7 @@ Email: redantsupport@united-us.net</string>
         <image name="btn_retrieve" width="102" height="30"/>
         <image name="btn_signin" width="100" height="30"/>
         <image name="camera" width="48" height="48"/>
-        <image name="cart_empty" width="96" height="96"/>
+        <image name="cart_empty" width="72" height="72"/>
         <image name="check_1_24" width="24" height="24"/>
         <image name="checkbox" width="16" height="16"/>
         <image name="close" width="32" height="32"/>

+ 1 - 0
RedAnt ERP Mobile/HMLG Scan Order/MainViewController.h

@@ -147,6 +147,7 @@
 -(void) switchToOrder;
 -(void) switchToCart;
 -(void)switchToHome;
+-(void) scanLogin;
 @property (strong, nonatomic) IBOutlet UILabel *label_ccount;
 
 -(void)initMenuItems;

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

@@ -1323,6 +1323,168 @@
 //        });
 //    });
     
+}
+-(void) scanTempsave
+{
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+        
+//        RASingleton.sharedInstance.scan_temp_code
+    
+    NSString *orderdir =[OLDataProvider getScanPath];
+    appDelegate.order_code = RASingleton.sharedInstance.scan_temp_code;
+    [OLDataProvider moveScanTemp2Order];
+    
+//        NSString *orderdir = [OLDataProvider getScanPath];
+    NSString* userdir = [OLDataProvider getUserPath];
+    NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
+    
+    
+    
+//        [RAUtils dicttofile:orderPath dict:self.content_data_download];
+    
+    
+
+    
+    NSString* order_code = RASingleton.sharedInstance.scan_temp_code;
+//
+//        int section_count = [self.content_data_download[@"section_count"] intValue];
+//
+//        for(int i=0;i<section_count;i++)
+//        {
+//            NSMutableDictionary* section = [self.content_data_download[[NSString stringWithFormat:@"section_%d",i]] mutableCopy];
+//            NSString* title = section[@"title"];
+//
+//                if([title isEqualToString:@"Customer"])
+//                {
+//                    // 订单信息会写customer info
+//
+//                    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(item[@"value"]!=nil )
+//                                appDelegate.customerInfo[name]=item[@"value"];
+//
+//
+//                    }
+//
+//
+//
+//        }
+    
+    
+//
+//        NSString *contactpath = [orderdir stringByAppendingPathComponent:@"contact.json"];
+//
+//
+//
+//        [RAUtils dicttofile:contactpath dict:appDelegate.customerInfo];
+    
+    orderdir = [OLDataProvider getScanOrderPath];
+    NSString *cartpath = [orderdir stringByAppendingPathComponent:@"cart.json"];
+    
+    RASingleton.sharedInstance.scan_cart[@"price_type"] = @(RASingleton.sharedInstance.price_type);
+    
+    [RAUtils dicttofile:cartpath dict:RASingleton.sharedInstance.scan_cart];
+    
+    
+    
+    
+    NSMutableDictionary* orderlist = nil;
+    
+    
+        NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"orderlist.json"];
+    
+    
+            if (![[NSFileManager defaultManager] fileExistsAtPath:orderlistPath]) {
+ 
+                
+                orderlist = [NSMutableDictionary new];
+                
+//                    [orderlist addObject:appDelegate.order_code];
+//                    [RAUtils dicttofile:orderlistPath dict:orderlist];
+                
+          }
+            else
+            {
+                orderlist=[[RAUtils dictfromfile:orderlistPath] mutableCopy];
+                
+//                    [orderlist insertObject:appDelegate.order_code atIndex:0];
+ 
+//                    [RAUtils dicttofile:orderlistPath dict:orderlist];
+            }
+    float p =0;
+    float s =0;
+    int order_qty=0;
+    for(int j=0;j<[RASingleton.sharedInstance.scan_cart[@"section_0"][@"count"] intValue];j++)
+    {
+        NSDictionary* cartitem =RASingleton.sharedInstance.scan_cart[@"section_0"][[NSString stringWithFormat:@"item_%d",j]];
+        p+=[cartitem[@"unit_price"] doubleValue]*[cartitem[@"count"]intValue] * (1-[cartitem[@"discount"]doubleValue]/100.0);
+        int mcount = [cartitem[@"count"] intValue];
+        order_qty+=mcount;
+        double msurcharge =0;
+        if(RASingleton.sharedInstance.price_type==1)
+        {
+            if([cartitem[@"special_price"] boolValue])
+            {
+                msurcharge=([cartitem[@"price3"] doubleValue]-[cartitem[@"price2"] doubleValue])*mcount*(1-[cartitem[@"discount"]doubleValue]/100.0);
+            }
+            else
+            {
+                msurcharge=([cartitem[@"price3"] doubleValue]-[cartitem[@"price1"] doubleValue])*mcount*(1-[cartitem[@"discount"]doubleValue]/100.0);
+            }
+        }
+
+        s+=msurcharge;
+    }
+    
+    NSMutableDictionary* orderitem = [NSMutableDictionary new];
+    orderitem[@"create_by"] = appDelegate.user;
+    
+    orderitem[@"price"] = [RAConvertor currencyNumber:p+s];//[NSString stringWithFormat:@"%.2f",p+s];
+    orderitem[@"model_count"] =[ NSString stringWithFormat:@"%d",order_qty];
+    
+//        orderitem[@"price"] = upparams[@"totalPrice"];
+//    NSString*
+    orderitem[@"customer_name"] = appDelegate.customerInfo[@"customer_contact"];
+    orderitem[@"purchase_time"] = [RAUtils current_date_time];
+        orderitem[@"order_status"] = @"Saved Order";
+    orderitem[@"order_code"] = order_code;
+    NSMutableDictionary* section =RASingleton.sharedInstance.scan_cart[@"section_0"];
+
+//        orderitem[@"model_count"] =[ NSString stringWithFormat:@"%d",order_qty];//RASingleton.sharedInstance.scan_cart[@"section_0"][@"count"] ];
+    
+    
+    int count = [orderlist[@"count"] intValue];
+    
+    NSMutableDictionary* newlist  = [NSMutableDictionary new];
+    
+    newlist[@"item_0"]=orderitem;
+    int newcount = 1;
+    for(int i=0;i<count;i++)
+    {
+        NSMutableDictionary* item = orderlist[[NSString stringWithFormat:@"item_%d",i]];
+        if([item[@"order_code"] isEqualToString: appDelegate.order_code ])
+            continue;
+        else
+        {
+            newlist[[NSString stringWithFormat:@"item_%d",newcount]] = item;
+            newcount++;
+        }
+    }
+    newlist[@"count"] = @(newcount);
+    [RAUtils dicttofile:orderlistPath dict:newlist];
+#ifdef RA_NOTIFICATION
+    [ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+    
+#else
+        
+        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+        [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+#endif
 }
 - (IBAction)onUserButtonClick:(id)sender {
     
@@ -1366,9 +1528,98 @@
                         UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Sign Out" message:@"" preferredStyle:UIAlertControllerStyleAlert];
         
                         UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Sign Out" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+                            
+                            
                             //open exist
                             AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                             
+                           // int cc=[RASingleton.sharedInstance.scan_cart[@"section_0"][@"count"] intValue];
+                            if(appDelegate.order_code == nil && [RASingleton.sharedInstance.scan_cart[@"section_0"][@"count"] intValue]>0)
+                            {
+                                UIAlertController *alertController1 = [UIAlertController alertControllerWithTitle:@"Save Cart?" message:@"" preferredStyle:UIAlertControllerStyleAlert];
+                                UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+                                    [self scanTempsave];
+                                    appDelegate.cart_count = 0;//[[jsobj  :@"cart_count"] intValue];
+                                    appDelegate.wish_count =0;//[[jsobj valueForKey:@"wish_count"] intValue];
+                                    appDelegate.port_count =0;//[[jsobj valueForKey:@"portfolio_count"] intValue];
+                                    
+                                    [appDelegate update_count_mark];
+                                    
+                                    
+                                    appDelegate.can_show_price =false;
+                                    appDelegate.can_see_price =false;
+                                    appDelegate.can_create_portfolio =false;
+                                    appDelegate.can_create_order =false;
+                                    
+                                    
+                                    appDelegate.can_cancel_order =false;
+                                    appDelegate.can_set_cart_price =false;
+                                    appDelegate.can_delete_order =false;
+                                    appDelegate.can_submit_order =false;
+                                    appDelegate.can_set_tearsheet_price =false;
+                                    appDelegate.can_update_contact_info = false;
+                                    
+                                    appDelegate.save_order_logout = false;
+                                    appDelegate.submit_order_logout = false;
+                                    appDelegate.alert_sold_in_quantities = false;
+                                    
+                                    appDelegate.ipad_perm =nil ;
+                                    appDelegate.user_type = USER_ROLE_UNKNOWN;
+                                    appDelegate.OrderFilter= nil;
+                                    [appDelegate SetSo:nil];
+                                    [appDelegate set_main_button_panel];
+                        #ifdef RA_NOTIFICATION
+                                    [ActiveViewController Notify:@"SearchViewController" Message:RA_NOTIFICATION_CLEAR_DATA];
+                        #endif
+                                    [appDelegate Logout];
+                                }];
+                                UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+                                    //create new;
+               
+                                    appDelegate.cart_count = 0;//[[jsobj  :@"cart_count"] intValue];
+                                    appDelegate.wish_count =0;//[[jsobj valueForKey:@"wish_count"] intValue];
+                                    appDelegate.port_count =0;//[[jsobj valueForKey:@"portfolio_count"] intValue];
+                                    
+                                    [appDelegate update_count_mark];
+                                    
+                                    
+                                    appDelegate.can_show_price =false;
+                                    appDelegate.can_see_price =false;
+                                    appDelegate.can_create_portfolio =false;
+                                    appDelegate.can_create_order =false;
+                                    
+                                    
+                                    appDelegate.can_cancel_order =false;
+                                    appDelegate.can_set_cart_price =false;
+                                    appDelegate.can_delete_order =false;
+                                    appDelegate.can_submit_order =false;
+                                    appDelegate.can_set_tearsheet_price =false;
+                                    appDelegate.can_update_contact_info = false;
+                                    
+                                    appDelegate.save_order_logout = false;
+                                    appDelegate.submit_order_logout = false;
+                                    appDelegate.alert_sold_in_quantities = false;
+                                    
+                                    appDelegate.ipad_perm =nil ;
+                                    appDelegate.user_type = USER_ROLE_UNKNOWN;
+                                    appDelegate.OrderFilter= nil;
+                                    [appDelegate SetSo:nil];
+                                    [appDelegate set_main_button_panel];
+                        #ifdef RA_NOTIFICATION
+                                    [ActiveViewController Notify:@"SearchViewController" Message:RA_NOTIFICATION_CLEAR_DATA];
+                        #endif
+                                    [appDelegate Logout];
+               
+                                }];
+                                [alertController1 addAction:action_1];
+                                [alertController1 addAction:action_2];
+
+               
+               
+                                [self presentViewController:alertController1 animated:YES completion:nil];
+                                
+                                return;
+                            }
                             
                             
                             appDelegate.cart_count = 0;//[[jsobj  :@"cart_count"] intValue];
@@ -2862,6 +3113,10 @@
 //        [self newoloorder];
 //    }
 //}
+-(void) scanLogin
+{
+    [self onUserButtonClick:nil];
+}
 -(void) initAppDelegate
 {
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
@@ -2891,7 +3146,16 @@
 //            self.address = [addressDic objectForKey:@"serverAddress"];
 //        }
         appDelegate.address = [addressDic objectForKey:@"serverAddress"];
-        [OLDataProvider guestLogin];
+//        [OLDataProvider guestLogin];
+        
+        NSMutableDictionary* guestjson=[OLDataProvider loadScanTemplate:@"guest.json"];
+        if(!guestjson)
+        {
+            [RADataProvider updateTemplate:self];
+            
+        }
+        else
+            [self onUserButtonClick:nil];
     }
     else
     {
@@ -2909,6 +3173,7 @@
         [self.navigationController pushViewController:servervc animated:true];
     }
 }
+
 //-(void) newoloorder
 //{
 //    NSString* order_code = [[NSUUID new] UUIDString];

Різницю між файлами не показано, бо вона завелика
+ 371 - 269
RedAnt ERP Mobile/HMLG Scan Order/SO.storyboard


+ 3 - 0
RedAnt ERP Mobile/HMLG Scan Order/ScanListCell.h

@@ -21,6 +21,9 @@ NS_ASSUME_NONNULL_BEGIN
 @property (weak, nonatomic) IBOutlet UILabel *labelPriceNCA;
 @property (weak, nonatomic) IBOutlet UILabel *labelPrice25p;
 @property (weak, nonatomic) IBOutlet UILabel *labelAvailable;
+@property (weak, nonatomic) IBOutlet UILabel *labelPriceNet;
+
+@property (weak, nonatomic) IBOutlet UILabel *labelPriceSpecial;
 
 @property (strong, nonatomic) NSMutableDictionary *modelJson;
 @end

+ 47 - 4
RedAnt ERP Mobile/HMLG Scan Order/ScanListCell.m

@@ -205,13 +205,56 @@
         _labelPriceCTNR.text= price0;
     else
         _labelPriceCTNR.text=[RAConvertor currencyNumber:[price0 floatValue]];
-    if([price3 isEqualToString:@"N/A"])
-        _labelPriceNCA.text= price3;
-    else
-        _labelPriceNCA.text=[RAConvertor currencyNumber:[price3 floatValue]];
+    
+//
+//    if([price3 isEqualToString:@"N/A"])
+//        _labelPriceNCA.text= price3;
+//    else
+//        _labelPriceNCA.text=[RAConvertor currencyNumber:[price3 floatValue]];
 //    _labelPrice25p.text=price2;
     
     
+    if([_modelJson [@"special_price"] boolValue])
+    {
+        if([_modelJson[@"price2"] isEqualToString:@"N/A"])
+            _labelPriceSpecial.text=_modelJson[@"price2"];
+        else
+            _labelPriceSpecial.text=[RAConvertor currencyNumber:[_modelJson[@"price2"] floatValue]];
+    }
+    else
+    {
+        _labelPriceSpecial.text=@"N/A";
+    }
+    
+    
+    if([_modelJson [@"net_price"] boolValue])
+    {
+        if([_modelJson[@"price1"] isEqualToString:@"N/A"])
+        {
+            _labelPriceNet.text=_modelJson[@"price1"];
+            _labelPriceNCA.text=@"N/A";
+        }
+        else
+        {
+            _labelPriceNet.text=[RAConvertor currencyNumber:[_modelJson[@"price1"] floatValue]];
+            _labelPriceNCA.text=@"N/A";
+        }
+    }
+    else
+    {
+        if([_modelJson[@"price1"] isEqualToString:@"N/A"])
+        {
+            _labelPriceNet.text=_modelJson[@"price1"];
+            _labelPriceNCA.text=@"N/A";
+        }
+        else
+        {
+            _labelPriceNCA.text=[RAConvertor currencyNumber:[_modelJson[@"price1"] floatValue]];
+            _labelPriceNet.text=@"N/A";
+        }
+    }
+    
+    
     NSString * available=_modelJson[@"available"];
     if(available.length==0)
         available = @"N/A";

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

@@ -23,6 +23,8 @@ NS_ASSUME_NONNULL_BEGIN
 @property (weak, nonatomic) IBOutlet UILabel *labelAvailable;
 @property (weak, nonatomic) IBOutlet UITextField *editQTY;
 @property (strong, nonatomic) NSMutableDictionary *modelJson;
+@property (weak, nonatomic) IBOutlet UILabel *labelPriceNet;
+@property (weak, nonatomic) IBOutlet UILabel *labelPriceSpecial;
 @property (weak, nonatomic) IBOutlet UIStepper *steper;
 
 //@property int pre_val;

+ 43 - 3
RedAnt ERP Mobile/HMLG Scan Order/ScanModelListCell.m

@@ -103,10 +103,50 @@
     else
         _labelPriceCTNR.text=[RAConvertor currencyNumber:[_modelJson[@"price0"] floatValue]];
     
-    if([price3 isEqualToString:@"N/A"])
-        _labelPriceNCA.text= price3;
+//    if([price3 isEqualToString:@"N/A"])
+//        _labelPriceNCA.text= price3;
+//    else
+//        _labelPriceNCA.text=[RAConvertor currencyNumber:[price3 floatValue]];
+    
+    if([_modelJson [@"special_price"] boolValue])
+    {
+        if([_modelJson[@"price2"] isEqualToString:@"N/A"])
+            _labelPriceSpecial.text=_modelJson[@"price2"];
+        else
+            _labelPriceSpecial.text=[RAConvertor currencyNumber:[_modelJson[@"price2"] floatValue]];
+    }
     else
-        _labelPriceNCA.text=[RAConvertor currencyNumber:[price3 floatValue]];
+    {
+        _labelPriceSpecial.text=@"N/A";
+    }
+    
+    
+    if([_modelJson [@"net_price"] boolValue])
+    {
+        if([_modelJson[@"price1"] isEqualToString:@"N/A"])
+        {
+            _labelPriceNet.text=_modelJson[@"price1"];
+            _labelPriceNCA.text=@"N/A";
+        }
+        else
+        {
+            _labelPriceNet.text=[RAConvertor currencyNumber:[_modelJson[@"price1"] floatValue]];
+            _labelPriceNCA.text=@"N/A";
+        }
+    }
+    else
+    {
+        if([_modelJson[@"price1"] isEqualToString:@"N/A"])
+        {
+            _labelPriceNet.text=_modelJson[@"price1"];
+            _labelPriceNCA.text=@"N/A";
+        }
+        else
+        {
+            _labelPriceNCA.text=[RAConvertor currencyNumber:[_modelJson[@"price1"] floatValue]];
+            _labelPriceNet.text=@"N/A";
+        }
+    }
     
 //
 //    if([cell_price isEqualToString:@"N/A"])

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

@@ -10,6 +10,7 @@
 #import "RADataProvider.h"
 #import "ScanServerListViewController.h"
 #import "ZipArchive.h"
+#import "MainViewController.h"
 @interface SetupServerViewController ()
 
 @end
@@ -183,7 +184,10 @@
                             templateDic[@"updatetime"]= datetime;
                             [self setUserDefaultsValue:templateDic forKey:@"ScanTemplate"];
                             
-                            [OLDataProvider guestLogin];
+                            
+                            MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+                            [main_vc  scanLogin];
+//                            [OLDataProvider guestLogin];
                             [RADataProvider load_scan_models];
 //                            [self loadTemplate];
                             

+ 53 - 0
RedAnt ERP Mobile/common/AppDelegateBase.m

@@ -2842,6 +2842,59 @@ void UncaughtExceptionHandler(NSException *exception) {
 }
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
+    
+#ifdef SCANNER_ORDER
+    //审核时连接测试数据库
+    
+    NSDate *cdate= [NSDate date];
+       NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
+       [dateFormatter setDateFormat:@"yyyy-MM-dd"];
+
+NSDate * ddate =[dateFormatter dateFromString:@"2022-07-03"];
+    
+//    bool review=[cdate earlierDate:ddate];
+    NSTimeInterval secondsInterval= [cdate timeIntervalSinceDate:ddate];
+    int sec =secondsInterval;
+    NSDictionary *addressDic = [[NSUserDefaults standardUserDefaults] valueForKey:@"ScanAddress"];
+    if(true&&sec<=0 && !addressDic)
+    {
+
+        
+        NSUInteger selectedIndex = 1;
+     
+                // 保存信息
+                
+                NSString *name = @"HMLG";
+        NSString *show_name = @"FREMONT, CA";
+                NSString *internalAddr =@"https://erp.homelegance.com/" ;
+      int price_index = 0;
+    //            NSString *externalAddr = weakself.externalTextField.text;
+                NSMutableDictionary *addressDic = [NSMutableDictionary dictionary];
+                if (internalAddr.length) {
+                    [addressDic setObject:internalAddr forKey:@"serverAddress"];
+                }
+    //            if (externalAddr.length) {
+    //                [addressDic setObject:externalAddr forKey:@"externalAddress"];
+    //            }
+                if (name.length) {
+                    [addressDic setObject:name forKey:@"name"];
+                }
+        if (show_name.length) {
+            [addressDic setObject:show_name forKey:@"show_name"];
+        }
+        [addressDic setObject:@(price_index) forKey:@"price_index"];
+                [addressDic setObject:@(selectedIndex) forKey:@"selectedIndex"];
+        NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
+        [userDefaults setValue:addressDic forKey:@"ScanAddress"];
+        [userDefaults synchronize];
+        
+      
+
+    }
+    
+#endif
+    
+    
     self.compressFile = [[RAUPloadManagerConfigure alloc] init].compressImage;
 #ifdef OFFLINE_ORDER
     

+ 3 - 3
RedAnt ERP Mobile/common/ERP_Mobile_Order.storyboard

@@ -932,7 +932,7 @@
                                     <outlet property="delegate" destination="LNa-Wq-bWf" id="6CH-jc-j9I"/>
                                 </connections>
                             </tableView>
-                            <tableView hidden="YES" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="tla-Jv-Qec" userLabel="table submit">
+                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="tla-Jv-Qec" userLabel="table submit">
                                 <rect key="frame" x="0.0" y="51" width="1024" height="717"/>
                                 <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <prototypes>
@@ -1038,7 +1038,7 @@
                                     <outlet property="delegate" destination="LNa-Wq-bWf" id="YsK-ri-grY"/>
                                 </connections>
                             </tableView>
-                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="okE-6e-1XS">
+                            <tableView hidden="YES" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="okE-6e-1XS">
                                 <rect key="frame" x="0.0" y="51" width="1024" height="717"/>
                                 <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <prototypes>
@@ -1150,7 +1150,7 @@
                                 <color key="textColor" red="0.33333333329999998" green="0.33333333329999998" blue="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <nil key="highlightedColor"/>
                             </label>
-                            <segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="ni4-Ku-8zb">
+                            <segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="1" translatesAutoresizingMaskIntoConstraints="NO" id="ni4-Ku-8zb">
                                 <rect key="frame" x="0.0" y="20" width="1024" height="32"/>
                                 <segments>
                                     <segment title="Unsubmitted"/>

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

@@ -1359,7 +1359,7 @@
         
         contactlabel.textColor=UIColorFromRGB(color);
         contactlabel.backgroundColor = [UIColor clearColor];
-        contactlabel.text=NSLocalizedString(@"Contact", nil);
+        contactlabel.text=NSLocalizedString(@"Company / Contact ID", nil);
         [contactlabel sizeToFit];
         [myView addSubview:contactlabel];
         
@@ -1683,7 +1683,7 @@
             }
             cell.labelprice.frame = price_frame;
             cell.label_so.text=so;
-            cell.labelprice.text=[RAConvertor currencyNumber:(price.floatValue)];//price;
+            cell.labelprice.text=price;//price;
             cell.label_date.text=purchase_time;
             cell.label_contact.text=customer_name;
             cell.label_model.hidden = false;

+ 197 - 1
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -1664,6 +1664,7 @@
                 [self scanPlaceOrder];
             }];
             UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+                appDelegate.order_code=nil;
                 DebugLog(@"No");
             }];
             [alertControl addAction:actionOne];
@@ -1718,6 +1719,193 @@
 
    
     
+}
+-(void) newoloorder1
+{
+//    NSString* order_code = RASingleton.sharedInstance.scan_temp_code;
+                                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//                                appDelegate.order_code = order_code;
+    
+    if(appDelegate.user.length==0)
+    {
+        [RAUtils message_alert:@"Please login first." title:@"Warring" controller:self];
+        return;
+    }
+    
+//    NSData* json =[NSData dataWithContentsOfFile:[[NSBundle mainBundle]  pathForResource:URL_SO_CART ofType:@"json" ]];
+//    NSMutableDictionary* cartTemplate=[OLDataProvider loadScanTemplate:@"scan_cart.json"];
+//    RASingleton.sharedInstance.scan_cart=cartTemplate;//[[RAConvertor data2dict:json] mutableCopy];
+    
+    
+    
+//    appDelegate.user_type = USER_ROLE_EMPLOYEE;
+    appDelegate.can_set_cart_price = true;
+    appDelegate.can_see_price = true;
+    
+//    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+//    NSString *documents = [paths objectAtIndex:0];
+    
+    {
+        
+        
+        NSString *orderdir =[OLDataProvider getScanPath];
+        [OLDataProvider moveScanTemp2Order];
+        
+//        NSError *error = nil;
+//        bool bsuccess=[[NSFileManager defaultManager] createDirectoryAtPath:orderdir withIntermediateDirectories:YES attributes:nil error:&error];
+        
+        
+//        NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
+        //   NSString * string = [checked componentsJoinedByString:@","];
+        //  [params setValue:string forKey:@"cart2Checkbox"];
+        
+//        NSData* data=[NSData dataWithContentsOfFile:[[NSBundle mainBundle]  pathForResource:URL_SO_ORDER ofType:@"json" ]];
+        
+//        NSMutableDictionary* dict=[[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error] mutableCopy];
+        
+        
+        
+//        __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) {
+                appDelegate.order_code=nil;
+                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"];
+
+
+        
+
+        
+        
+    }
+//    MainViewController * mainvc=(MainViewController * )appDelegate.main_vc;
+//    mainvc.btnScan.enabled = true;
+    
+//    [appDelegate updateScanButton:true];
+
+   
+    
+}
+-(void)newScanOrder1
+{
+    
+//
+//    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+//
+//
+//    if(appDelegate.order_code.length>0)
+//    {
+////        当前订单先关闭
+////        [OLDataProvider deleteScanOrder:appDelegate.order_code];
+//        appDelegate.order_code = nil;
+//        appDelegate.customerInfo = nil;
+//        RASingleton.sharedInstance.scan_cart = nil;
+//        appDelegate.contact_id = nil;
+////        [appDelegate updateScanButton:false];
+//
+//        [appDelegate update_count_mark];
+//        [appDelegate closeOrder];
+//
+//    }
+//
+//
+    {
+        [self newoloorder1];
+        
+    }
 }
 -(void)newScanOrder
 {
@@ -1991,10 +2179,18 @@
     }
     else
     {
-        if(appDelegate.order_code.length==0)
+        
+        NSString *orderdir =[OLDataProvider getScanPath];
+        NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
+        
+        if(appDelegate.order_code.length==0 )
         {
             [self newScanOrder];
         }
+        else if( ![[NSFileManager defaultManager] fileExistsAtPath:orderPath])
+        {
+            [self newScanOrder1];
+        }
         else
         {
             

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

@@ -166,7 +166,7 @@ typedef void(^resultHandler)(NSMutableDictionary *result);
 +(NSString*) getUserPath;
 +(NSString*) getScanPath;
 +(void) moveScanTemp2Order;
-+(void) guestLogin;
++(void) realguestLogin;
 +(NSString*) getScanOrderPath;
 +(NSString*) getScanOrderPathByCode:(NSString*) order_code;
 @end

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

@@ -2237,10 +2237,11 @@
     return templatefile;
 }
 
-+(void) guestLogin
++(void) realguestLogin
 {
     NSMutableDictionary* guestjson=[self loadScanTemplate:@"guest.json"];
     [RANetwork parse_logininfo:guestjson user:@"GUEST" password:@"GUEST"];
+    [ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
     
 }
 +(NSMutableDictionary*) loadScanTemplate:(NSString*)file
@@ -2426,7 +2427,7 @@
         NSMutableDictionary* item = orderlist[[NSString stringWithFormat:@"item_%d",i]];
         if([item[@"order_code"] isEqualToString: order_code ])
         {
-            item[@"price"] = [NSString stringWithFormat:@"%.2f",p+s];
+            item[@"price"] = [RAConvertor currencyNumber:p+s];//[NSString stringWithFormat:@"%.2f",p+s];
             item[@"model_count"] =[ NSString stringWithFormat:@"%d",order_qty];//RASingleton.sharedInstance.scan_cart[@"section_0"][@"count"] ];
             orderlist[[NSString stringWithFormat:@"item_%d",i]] = item;
         }

+ 128 - 14
RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m

@@ -1485,8 +1485,11 @@
     NSMutableDictionary* orderitem = [NSMutableDictionary new];
     orderitem[@"create_by"] = appDelegate.user;
     orderitem[@"price"] = upparams[@"totalPrice"];
-//    NSString* 
-    orderitem[@"customer_name"] = upparams[@"customer_contact"];
+//    NSString*
+    NSString* company = upparams[@"customer_cid"];
+    if(company.length==0)
+        company = upparams[@"customer_name"];
+    orderitem[@"customer_name"] = company;
     orderitem[@"purchase_time"] = [RAUtils current_date_time];
     if(self.fail_submit)
         orderitem[@"order_status"] = @"Unsubmitted Order";
@@ -1533,6 +1536,77 @@
 #endif
 }
 #endif
+-(void) newScanOrder
+{
+    
+    
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    
+//    if(appDelegate.user.length<=0)
+//    {
+//        [RAUtils message_alert:@"Please login first." title:@"Warring" controller:self];
+//        return;
+//    }
+    
+    if(appDelegate.order_code.length>0)
+    {
+        //        当前订单先关闭
+        //        [OLDataProvider deleteScanOrder:appDelegate.order_code];
+        appDelegate.order_code = nil;
+        RASingleton.sharedInstance.scan_temp_code = nil;
+        if(appDelegate.customer_type!=USER_ROLE_CUSTOMER ) //customer 角色不清空customer info
+        {   appDelegate.customerInfo = nil;
+            appDelegate.contact_id = nil;
+        }
+        RASingleton.sharedInstance.scan_cart = nil;
+        RASingleton.sharedInstance.price_type = 1;
+        //        [appDelegate updateScanButton:false];
+        
+        [appDelegate update_count_mark];
+        [appDelegate closeOrder];
+        
+    }
+    
+    
+    //    RASingleton.sharedInstance.enable_OfflineOrder = true;
+    
+    
+    //    __block MainViewController *brself= self;
+    NSString* order_code = RASingleton.sharedInstance.scan_temp_code;
+    appDelegate.can_set_cart_price = true;
+    appDelegate.can_see_price = true;
+    RASingleton.sharedInstance.scan_cart = nil;
+    RASingleton.sharedInstance.price_type = 1;
+    
+    {
+        
+        
+        NSString *orderdir = [OLDataProvider getScanPath];
+        [OLDataProvider moveScanTemp2Order];
+        
+        
+        
+        
+        NSString *contactpath = [orderdir stringByAppendingPathComponent:@"contact.json"];
+        
+        
+        
+        [RAUtils dicttofile:contactpath dict:appDelegate.customerInfo];
+        
+        
+    }
+    
+    
+#ifdef RA_NOTIFICATION
+                        [ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+#else
+                        MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
+                        [main_vc reloadCart:true immediately:false];
+#endif
+    MainViewController * mainvc = (MainViewController*)appDelegate.main_vc;
+    
+   [mainvc switchToCart];
+}
 - (IBAction)onSaveClick:(id)sender {
 //    id foo = nil;
 //    [[NSMutableArray array] addObject:foo];
@@ -1560,7 +1634,10 @@
         [self scanSave:upparams];
         
         [RAUtils message_alert:@"Save Successfully" title:@"Message" controller:self action_handler:^(UIAlertAction * _Nonnull action) {
+            
+            [self newScanOrder];
             [self.navigationController popViewControllerAnimated:true];
+            
         } completion:nil];
         return;
     }
@@ -3603,22 +3680,34 @@
                 
                 
             }
-            else
+            else if([result[@"result"] intValue]==-4||[result[@"result"] intValue]==4-3)
             {
                 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.realuser = nil;
+                self.realpassword = nil;
+                [RAUtils message_alert:@"Order submission failed. Please check your internet and try later." 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;
                 
             }
+            else
+            {
+                self.fail_submit = true;
+                self.realuser = nil;
+                self.realpassword = nil;
+                [RAUtils message_alert:@"Can not submit order, please contact administrator." title:@"Submit Order" controller:self];
+            }
+
+                
+            
         }];
 
 
@@ -3738,6 +3827,31 @@
                 return;
                 
             }
+            else if([result[@"result"] intValue]==-4||[result[@"result"] intValue]==4-3)
+            {
+                self.fail_submit = true;
+                self.realuser = nil;
+                self.realpassword = nil;
+                [RAUtils message_alert:@"Order submission failed. Please check your internet and try later." 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;
+                
+            }
+            else
+            {
+                self.fail_submit = true;
+                self.realuser = nil;
+                self.realpassword = nil;
+                [RAUtils message_alert:@"Can not submit order, please contact administrator." title:@"Submit Order" controller:self];
+            }
             
             
             

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

@@ -34,6 +34,7 @@
 @property (strong, nonatomic) IBOutlet UITextField *editpass;
 @property (nonatomic , copy) void (^returnValue)(bool blogin);
 
+@property (weak, nonatomic) IBOutlet UIButton *btnGuest;
 @property (strong, nonatomic) IBOutlet UITableView *Loginlist;
 @property (strong, nonatomic)  NSArray *logindata;
 @property bool showList;

+ 10 - 0
RedAnt ERP Mobile/common/Functions/sidemenu/LoginViewController.m

@@ -112,6 +112,9 @@
     //  self.Loginlist.layer.cornerRadius=15;
     self.Loginlist.layer.masksToBounds=true;
     // Do any additional setup after loading the view.
+#ifdef SCANNER_ORDER
+    self.btnGuest.hidden=false;
+#endif
 }
 - (void)LoginList:(UIButton *)sender {
     [self.edituser endEditing:true];
@@ -228,6 +231,13 @@
     
     [self.navigationController pushViewController:vc animated:true];
 }
+- (IBAction)onGuestClick:(id)sender {
+    [OLDataProvider realguestLogin];
+    [self dismissViewControllerAnimated:true completion:^{
+        if(self.returnValue)
+            self.returnValue(false);
+    }];
+}
 - (IBAction)onLoginClick:(UIButton *)sender {
     NSString* user = self.edituser.text;
     NSString* password = self.editpass.text;

+ 1 - 1
RedAnt ERP Mobile/common/data_provider/RADataProvider.h

@@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
 +(void)request_change_password:(NSString*) pwd completionHandler:(resultHandler)result;
 +(void)load_scan_models;
 +(NSArray*)request_scan_model_by_names:(NSString*)names;
-
++(void) updateTemplate:(UIViewController*) vc;
 //+(void)encrypt_scan_models;
 @end
 

+ 119 - 1
RedAnt ERP Mobile/common/data_provider/RADataProvider.m

@@ -7,7 +7,7 @@
 //
 
 #import "RADataProvider.h"
-
+#import "ZipArchive.h"
 @implementation RADataProvider
 
 +(void)encrypt_scan_models
@@ -51,7 +51,125 @@
     return models;
     
 }
++(void) updateTemplate:(UIViewController*) vc
+{
+    
+//    if(self.internalTextField.text.length>0)
+    {
+        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+        NSString *documents = [paths objectAtIndex:0];
+        
+        [RAUtils deletefiles:[documents stringByAppendingPathComponent:@"download"]];
+        
+//        NSString* file_name=[appDelegate.downloadurl lastPathComponent];
+        
+        dispatch_async(dispatch_get_global_queue(0, 0), ^{
+            
+            NSData*  download_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:appDelegate.downloadurl]];
+            dispatch_async(dispatch_get_main_queue(), ^{
+                
+                
+                
+                if(download_data!=nil)
+                {
+                    NSString* file_name=[appDelegate.downloadurl lastPathComponent];
+                    NSString* path = [documents stringByAppendingPathComponent:file_name];
+                    [RAUtils saveData:download_data toPath:path];
+                    
+                    ZipArchive* zip = [[ZipArchive alloc] init];
+                    NSString* unZipTo=[documents stringByAppendingPathComponent:@"download"];
+//                    NSFileManager* fileManager=[NSFileManager defaultManager];
+//                    [fileManager removeItemAtPath:unZipTo error:nil];
+//                    NSString *unZipTo = [temp stringByAppendingPathComponent:unziplocation];
+                    //
+                    //    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+                    //    NSString *documentPath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
+                    //NSString* zipFile = [documentPath stringByAppendingString:@"/images.zip"] ;
+                    // NSString* unZipTo = img_cache;//[documentPath stringByAppendingString:@"/images"] ;
+                    
+                    DebugLog(@"path: %@",unZipTo);
+                    if( [zip UnzipOpenFile:path Password:nil] ){
+                        BOOL result = [zip UnzipFileTo:unZipTo overWrite:YES];
+                        if( NO==result )
+                        {
+                            //            int aaa=0;
+                            //解压失败
+                          
+                            [zip UnzipCloseFile];
+                            //文件损坏,删除文件重试
+                            
+                            
+                            NSFileManager* fileManager=[NSFileManager defaultManager];
+                            //debug
+                //            BOOL blDele= [fileManager removeItemAtPath:zipFile error:nil];
+                            [fileManager removeItemAtPath:path error:nil];
+                            [fileManager removeItemAtPath:unZipTo error:nil];
+                            
+                            [RAUtils message_alert:@"Can not unzip template file, please try download again." title:@"Warrning" controller:vc];
+                            
+                            
+                            
+                            
+                        }
+                        else
+                        {
+                            [zip UnzipCloseFile];
+                            
+                            
+                            NSFileManager *fileManager = [NSFileManager defaultManager];
+                            [fileManager removeItemAtPath:path error:nil];
+                            [RAUtils message_alert:@"Update template file successful." title:@"Message" controller:vc];
+                            
+//                            [RADataProvider encrypt_scan_models];
+                            NSMutableDictionary *templateDic = [NSMutableDictionary dictionary];
+                            NSString* datetime= [RAUtils current_date_time];
+                            templateDic[@"updatetime"]= datetime;
+                            
+                            
+                            NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
+                            [userDefaults setValue:templateDic forKey:@"ScanTemplate"];
+                            [userDefaults synchronize];
+                            
+                            
+                            [RADataProvider load_scan_models];
+//                            [self loadTemplate];
+                            
+                            
+                        }
+                        //[zip UnzipCloseFile];
+                    }
+                    else
+                    {
+                        //打开文件失败,通常是文件路径有问题或密码错误。
+                        [RAUtils message_alert:@"Can not unzip template file, please contact the Administrator." title:@"Warrning" controller:vc];
+                        
+                //        NSFileManager *fileManager = [NSFileManager defaultManager];
+                //        [fileManager removeItemAtPath:zipFile error:nil];
+                    }
+                    
+                    
+//                    [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
+//
+//                    UIImage * img =[UIImage imageWithData:downloadimg_data];
+//                    cell.imageView.image=img;
+                }
+                else
+                    [RAUtils message_alert:@"Can not update template file, you can update manually in the setting." title:@"Warrning" controller:vc];
+//                    cell.imageView.image=[UIImage imageNamed:@"notfound_s"];
+                
+            });
+            
+        });
+        
+        
+//        NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:appDelegate.downloadurl]];
+//        [RADataProvider downloadFileOffset:0 Param:nil from:appDelegate.downloadurl method:@"post" toPath:[documents stringByAppendingPathComponent:file_name] progressHandler:nil completionHandler:^(NSMutableDictionary *result) {
+//            int i=0;    ;
+//        }];
+    }
 
+}
 +(void)load_scan_models
 {
     

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

@@ -5354,7 +5354,7 @@ NSString *const ScreenCodeOfflineSync = @"Offline Sync Screen";
 #endif
     if(scan_guest)
     {
-        [OLDataProvider guestLogin];
+        [OLDataProvider realguestLogin];
 //        int ret = [self parse_logininfo:chresult user:user password:password] ;
         
         

+ 5 - 0
common/RAUtils.m

@@ -61,6 +61,11 @@
 
 +(void) dicttofile:(NSString*) path dict:(NSDictionary*)dict
 {
+    
+    NSDictionary* saveddict = dict;
+    if(saveddict==nil)
+        return;
+    
     NSString *filestr =[RAConvertor dict2string:dict];
 
     NSError *error=nil;

Деякі файли не було показано, через те що забагато файлів було змінено