|
@@ -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 {
|
|
- (IBAction)onUserButtonClick:(id)sender {
|
|
|
|
|
|
|
@@ -1366,9 +1528,98 @@
|
|
|
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Sign Out" message:@"" preferredStyle:UIAlertControllerStyleAlert];
|
|
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Sign Out" message:@"" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
|
|
|
UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Sign Out" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
|
|
UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Sign Out" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//open exist
|
|
//open exist
|
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
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];
|
|
appDelegate.cart_count = 0;//[[jsobj :@"cart_count"] intValue];
|
|
@@ -2862,6 +3113,10 @@
|
|
|
// [self newoloorder];
|
|
// [self newoloorder];
|
|
|
// }
|
|
// }
|
|
|
//}
|
|
//}
|
|
|
|
|
+-(void) scanLogin
|
|
|
|
|
+{
|
|
|
|
|
+ [self onUserButtonClick:nil];
|
|
|
|
|
+}
|
|
|
-(void) initAppDelegate
|
|
-(void) initAppDelegate
|
|
|
{
|
|
{
|
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
@@ -2891,7 +3146,16 @@
|
|
|
// self.address = [addressDic objectForKey:@"serverAddress"];
|
|
// self.address = [addressDic objectForKey:@"serverAddress"];
|
|
|
// }
|
|
// }
|
|
|
appDelegate.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
|
|
else
|
|
|
{
|
|
{
|
|
@@ -2909,6 +3173,7 @@
|
|
|
[self.navigationController pushViewController:servervc animated:true];
|
|
[self.navigationController pushViewController:servervc animated:true];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
//-(void) newoloorder
|
|
//-(void) newoloorder
|
|
|
//{
|
|
//{
|
|
|
// NSString* order_code = [[NSUUID new] UUIDString];
|
|
// NSString* order_code = [[NSUUID new] UUIDString];
|