| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- //
- // OLOSettingViewController.m
- // iSales-UWAVER
- //
- // Created by Rui Zhang on 1/7/22.
- // Copyright © 2022 United Software Applications, Inc. All rights reserved.
- //
- #import "OLOSettingViewController.h"
- #import "AppDelegate.h"
- #import "RASingleton.h"
- #import "ContactListViewController.h"
- #import "MainViewController.h"
- #import "CustomerEditViewController.h"
- #import "UploadCell.h"
- #import "UIView+Toast.h"
- //#import "ServerSettingViewController.h"
- #define OOC_OFFLINE_CONTACT 0
- #define OOC_ONLINE_CONTACT 1
- #define OOC_CREATE_ORDER 10
- @interface OLOSettingViewController ()
- @end
- @implementation OLOSettingViewController
- - (IBAction)onSetUnlockCode:(id)sender {
- }
- - (IBAction)onUpdateLocalData:(id)sender {
- }
- - (IBAction)onSetServer:(id)sender {
- // ServerSettingViewController *loginSettingVC = [[UIStoryboard storyboardWithName:@"OLM" bundle:nil] instantiateViewControllerWithIdentifier:@"ServerSettingViewController"];
- // __weak typeof(self) weakself = self;
- // loginSettingVC.returnValue = ^(NSString *name,NSString *address) {
- // if (weakself) {
- // __strong typeof(weakself) strongself = weakself;
- // AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
- // appDelegate.address = address;
- // weakself.textfieldName.text = name;
- // weakself.textfieldServer.text = address;
- //// [strongself.loginTable reloadData];
- // }
- // };
- // UINavigationController *settingRootNav = [[UINavigationController alloc] initWithRootViewController:loginSettingVC];
- // [self presentViewController:settingRootNav animated:YES completion:nil];
- //
-
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
-
-
- #ifdef SCANNER_ORDER
- {
- self.switch_enable.on=true;
- }
- #else
- {
- self.switch_enable.on=false;
- }
- #endif
- // Do any additional setup after loading the view.
- }
- //- (IBAction)onEnableOLOChanged:(id)sender {
- //
- // RASingleton.sharedInstance.enable_OfflineOrder = [self.switch_enable isOn];
- //}
- - (IBAction)onCreateOO:(id)sender
- {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if(appDelegate.user.length<=0)
- {
- [RAUtils message_alert:@"Please select a sales first" title:@"Create Offline Order" controller:self];
- return;
- }
-
- [self dismissViewControllerAnimated:NO completion:^{
- if(self.returnValue)
- self.returnValue(OOC_CREATE_ORDER);
-
- }];
-
- return;
-
-
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // __block bool abort = false;
-
- 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.url_type = URL_LOCAL;
- cuseditVC.request_url=LOCAL_URL_CUSTOMER_INFO_EDIT;
-
- cuseditVC.params = params;
-
- // cuseditVC.delegate=self;
- //
- // if(checked.count==count)
- // {
- // orderinfoVC.have_tail = true
- // }
-
- [self dismissViewControllerAnimated:NO completion:^{
- [(UINavigationController*)[self parentViewController] pushViewController:cuseditVC animated:false];;
- }];
-
- // [[self navigationController] setNavigationBarHidden:NO animated:NO];
- // [self.navigationController pushViewController:cuseditVC animated:false];
-
-
- }];
- UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"With Online Contact" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- if(appDelegate.order_code && appDelegate.order_code.length>0)
- {
- // appDelegate.order_code= nil;
- // [appDelegate SetSo:nil];
-
-
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.showNavibar = true;
- cvc.contact_type = @"Sales_Order_Customer";
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- appDelegate.customerInfo = value;
-
- // self.norefresh = true;
- [self neworder];
-
-
-
- // [main_vc checklogin:true];
- // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
- cvc.onCancel = ^(){
- // self.norefresh = true;
- if(appDelegate.customerInfo==nil)
- {
- [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
- }
- else
- {
- [self neworder];
- }
- // [main_vc checklogin:true];
- };
- cvc.onReset = ^(){
- // [main_vc checklogin:true];
- };
-
- [self.navigationController pushViewController:cvc animated:true];
-
-
- }
- else
- {
- //create new;
-
- if(appDelegate.customerInfo==nil)// select contact if current contact not exist
- {
- MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.showNavibar = true;
- cvc.contact_type = @"Sales_Order_Customer";
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- appDelegate.customerInfo = value;
-
-
- if(appDelegate.order_code==nil)
- [self neworder];
-
- // [main_vc checklogin:true];
- // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
- cvc.onCancel = ^(){
-
- [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
-
-
-
- };
- cvc.onReset = ^(){
- [main_vc checklogin:true];
- };
-
- [self.navigationController pushViewController:cvc animated:true];
- }
- else
- {
- [self neworder];
- }
- }
-
- }];
- 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 neworder];
- }
-
-
- //block代码块取代了delegate
-
-
-
-
-
-
- //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
-
-
-
- }
- -(void) neworder
- {
-
- __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Create Order" completion:^{
- [RANetwork request_create_order:^(NSMutableDictionary *result) {
- NSMutableDictionary* return_json =result;
-
- [waitalert dismissViewControllerAnimated:YES completion:^{
- if([[return_json valueForKey:@"result"] intValue]==2)
- {
- int result=[[return_json valueForKey:@"result"] intValue];
- if(result==2)
- {
- //successed.
-
- NSString* order_code = [return_json valueForKey:@"orderCode"];
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- appDelegate.order_code = order_code;
- appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-
-
- #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 ReloadData];
-
-
- // [self performSelector:@selector(loadpage) withObject:nil afterDelay:1];
- // [self loadpage];
-
-
- // if(self.shopCartBlock!=nil)
- // {
- // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
- //
- //
- // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
- // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
- // iv.image = img;
- // // [self.contentView addSubview:iv];
- // self.shopCartBlock(iv);
- //
- // }
-
- }
- }
- else
- {
- [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:self] ;
- }
- }];
- // [waitalert dismissViewControllerAnimated:YES completion:nil];
-
-
-
-
-
-
-
-
- }];
- }];
-
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* return_json = [RANetwork new_Order];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissViewControllerAnimated:YES completion:nil];
- //
- //
- // if([[return_json valueForKey:@"result"] intValue]==2)
- // {
- // int result=[[return_json valueForKey:@"result"] intValue];
- // if(result==2)
- // {
- // //successed.
- //
- // NSString* order_code = [return_json valueForKey:@"orderCode"];
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // appDelegate.order_code = order_code;
- // appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
- //
- //
- //#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 ReloadData];
- //
- //
- // // [self performSelector:@selector(loadpage) withObject:nil afterDelay:1];
- // // [self loadpage];
- //
- //
- // // if(self.shopCartBlock!=nil)
- // // {
- // // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
- // //
- // //
- // // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
- // // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
- // // iv.image = img;
- // // // [self.contentView addSubview:iv];
- // // self.shopCartBlock(iv);
- // //
- // // }
- //
- // }
- // }
- // else
- // {
- // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- }
- - (IBAction)onSelectSales:(id)sender {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- appDelegate.user = @"OLOTEST";
- appDelegate.bLogin = true;
- }
- /*
- #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
|