| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 |
- //
- // ViewController.m
- // AntsContract
- //
- // Created by Ray on 12/16/16.
- // Copyright © 2016 United Software Applications, Inc. All rights reserved.
- //
- #import "RootViewController.h"
- #import "DocumentPageViewController.h"
- #import "LoginViewController.h"
- #import "AppDelegate.h"
- #import "RAUtils.h"
- #import "RAPDFViewController.h"
- #import "DocumentListViewController.h"
- #import "PendingDocumentsViewController.h"
- #import "RANetwork.h"
- #import "PDFUtils.h"
- #import "AddExtDocumentViewController.h"
- #import "config.h"
- #import "DocumentTemplateViewController.h"
- #import "WebViewController.h"
- @interface RootViewController ()
- @property (nonatomic,assign) BOOL hasShowLoginView;
- @end
- @implementation RootViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title= @"eSign";
- self.welcomeLabel.text=@"Not sign in";
- self.buttonHIC.enabled = false;
- self.buttonSRL.enabled = false;
- self.coverView.hidden = false;
-
- [self reloadBG];
-
- NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
- NSString* build =[infoDict objectForKey:@"CFBundleVersion"];
- NSString* version =[infoDict objectForKey:@"CFBundleShortVersionString"];
- NSString* versionNum = [NSString stringWithFormat:@"VeS1.%@.%@",version,build];
- self.labelVer.text = versionNum;
-
- self.debugBtn.hidden = !DEBUG_PDFSIG;
-
-
- // Do any additional setup after loading the view, typically from a nib.
- }
- - (NSInteger)loadDocCount {
- NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
- NSArray *docArr = [defaults arrayForKey:@"pending_doc"];
- if (docArr) {
- return docArr.count;
- }
- return 0;
- }
- -(void) viewDidAppear:(BOOL)animated
- {
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if(appDelegate.accessMode == AppAccessModeOnline)
- {
- self.labelMode.text = @"Mode: Online";
- [self.switchMode setOn:true];
- self.navigationItem.rightBarButtonItem = self.ibSignin;
- }
- else
- {
- self.labelMode.text = @"Mode: Offline";
- [self.switchMode setOn:false];
- self.navigationItem.rightBarButtonItem = nil;
- }
- if(!appDelegate.bLogin)
- [self presentLogin:self.ibSignin];
-
- NSInteger docCount = [self loadDocCount];
- if (docCount > 0) {
- self.labelDocNumber.hidden = NO;
- self.labelDocNumber.text = [NSString stringWithFormat:@"%ld",docCount];
- } else {
- self.labelDocNumber.hidden = YES;
- self.labelDocNumber.text = [NSString stringWithFormat:@""];
- }
- }
- -(void) presentLogin:(id)sender
- {
- // 确保只Presnet LoginView一次.
- if (self.hasShowLoginView) return;
- self.hasShowLoginView = YES;
-
- UIBarButtonItem* bbitem = sender;
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- {
- LoginViewController * loginvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
- loginvc.returnValue = ^(bool blogin){
-
- // [self checklogin :true];
-
- self.hasShowLoginView = NO;
-
- if(blogin)
- {
- self.welcomeLabel.text=[NSString stringWithFormat:@"Welcome %@",RASingleton.sharedInstance.user];
-
- [bbitem setTitle:@"Sign out"];
- self.buttonHIC.enabled = true;
- self.buttonSRL.enabled = true;
- self.coverView.hidden = true;
-
- // 处理三方app 传入文件
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if(appDelegate.shareFile)
- {
-
-
-
- AddExtDocumentViewController * addVC;
-
-
-
- addVC = [ [UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"AddExtDocumentViewController"];
- addVC.is_present = true;
- addVC.doc_number = nil;
- addVC.arr_documents = [NSMutableArray arrayWithObjects:appDelegate.shareFile, nil];
- appDelegate.shareFile=nil;
-
- // notesVC.docNotes = notes;
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:addVC] ;
-
-
-
-
-
-
- navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-
- DebugLog(@"filter present.........");
-
- // self.btop = false;
- // <#code#>
- }];
-
-
- }
-
- }
- else
- {
- appDelegate.shareFile=nil;
- self.welcomeLabel.text=@"Not sign in";
- self.buttonHIC.enabled = false;
- self.buttonSRL.enabled = false;
- self.coverView.hidden = false;
- }
-
- };
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-
-
-
- if (@available(iOS 13, *)) {
- navi.modalInPresentation = true;
- }
-
-
- navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- DebugLog(@"login present.........");
-
- }];
- }
- }
- //-(void) leak_debug
- //{
- //
- //
- // CGPDFDocumentRef document = [PDFUtils OpenPDF:@"GEIC - Home Improvement Contract 2017.pdf"];
- // // self.total_page = CGPDFDocumentGetNumberOfPages (self.document);
- //
- // NSMutableDictionary * controlTemplate = [self templateInit:[PDFUtils loadControl:@"GEIC - Home Improvement Contract 2017.json"]];
- //
- //
- // NSString* pdffile = [PDFUtils SavePDF:controlTemplate source:document window_rect:CGRectMake(0, 0, 768, 960)];
- //
- // CGPDFDocumentRelease(document);
- //
- // // CFRelease(document);
- //
- // NSString* zipfile=[ACNetwork prepareUploadFile:pdffile json:controlTemplate];
- //
- // [self previewPDF:pdffile];
- //
- //
- //
- //
- //
- //
- //}
- //-(NSMutableDictionary*) templateInit:(NSMutableDictionary*) template
- //{
- //
- //
- // NSString* temp = NSTemporaryDirectory();
- // NSString* filename =[NSString stringWithFormat:@"%@.png", [[NSUUID UUID] UUIDString]];
- // NSString* qrpath=[temp stringByAppendingPathComponent:filename];
- // UIImage* qrimg=[RAUtils generateBarCode:@"leak test" width:300 height:44];//[QRCodeGenerator qrImageForString:order_code imageSize:240];
- // bool bwrite=[UIImagePNGRepresentation(qrimg)writeToFile: qrpath atomically:YES];
- //
- //
- //
- // for(int i=0;i<[template[@"count"] intValue];i++)
- // {
- // NSMutableDictionary* page =template[[NSString stringWithFormat:@"page_%d",i]];
- // for(int j=0;j<[page[@"count"] intValue];j++)
- // {
- // NSMutableDictionary* control =page[[NSString stringWithFormat:@"control_%d",j]];
- // NSString* type = control[@"type"];
- // NSString* field =control[@"field"];
- // if([type isEqualToString:@"Label"])
- // {
- // if([field isEqualToString:@"doc_number"])
- // {
- // control[@"value"]= @"leak test";
- // }
- // }
- // else if([type isEqualToString:@"Image"])
- // {
- // NSString* name =control[@"name"];
- // if([name isEqualToString:@"BarCode"])
- // {
- // if(bwrite)
- // control[@"value"]= qrpath;
- // }
- // }
- // else if([type isEqualToString:@"DatePicker"])
- // {
- // NSString* name =control[@"aname"];
- // if([name isEqualToString:@"Today's Date"])
- // {
- // NSDateFormatter * formatter = [[NSDateFormatter alloc]init];
- // [formatter setDateFormat:@"MM/dd/yyyy"];
- // NSString* date = [formatter stringFromDate:[NSDate date]] ;
- //
- // control[@"value"]= date;
- // }
- // }
- // }
- // }
- // return template;
- //}
- - (IBAction)onNewCustomerClick:(id)sender {
- // [self leak_debug];
- // return;
-
- __weak typeof(self) weakSelf = self;
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if(appDelegate.accessMode == AppAccessModeOffline)
- {
- __block NSString* offline_docnumber =[RANetwork offline_docnumber];
-
- if(offline_docnumber==nil)
- {
- // [RAUtils message_alert:@"Offline document number prefix not found, Please check your user name and make sure you had signed in at least once." title:@"Create Customer" controller:self] ;
- [RAUtils message_box:@"Create Customer" message:@"Offline document number prefix not found, Please check your user name and make sure you had signed in at least once." completion:nil];
- return;
- }
- DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
-
- // dvc.templateName = @"debug.json";
- dvc.templatePath = [[NSBundle mainBundle] pathForResource:CONTRACT_TEMPLATE ofType:nil];
- dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"GECI - Home Improvement Contract - Tan.pdf" ofType:nil];
- dvc.docment_id = offline_docnumber;
- dvc.OnSave=^(NSString* file, NSString* subject)
- {
-
- [weakSelf previewPDF:file title:offline_docnumber subject:subject];
- };
-
- [self.navigationController pushViewController:dvc animated:true];
-
-
- }
- else
- {
-
-
-
- PopWaitAlert* pop =[RAUtils waiting_pop:@"Create customer" completion:nil];
-
-
- NSMutableDictionary* param = [NSMutableDictionary new];
- [RANetwork request_new_document:param completionHandler:^(NSMutableDictionary *result) {
- NSMutableDictionary* json= result;
-
-
-
-
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-
-
- // [waitalert dismissViewControllerAnimated:YES completion:^{
-
- [pop hide];
- if([json[@"result"] intValue]==RESULT_TRUE)
-
- {
- DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
-
- // dvc.templateName = @"debug.json";
- dvc.templatePath = [[NSBundle mainBundle] pathForResource:CONTRACT_TEMPLATE ofType:nil];
- dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"GECI - Home Improvement Contract - Tan.pdf" ofType:nil];
- dvc.docment_id = json[@"doc_number"];
- dvc.OnSave=^(NSString* file, NSString* subject)
- {
-
- [weakSelf previewPDF:file title:json[@"doc_number"] subject:subject];
- };
-
- [self.navigationController pushViewController:dvc animated:true];
- }
- else
- {
- // [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Create Customer" controller:self] ;
-
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Create Customer" message:@"Can not create new customer on server, do you want to create an offline document?" preferredStyle:UIAlertControllerStyleAlert];
-
-
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
- __block NSString* offline_docnumber =[RANetwork offline_docnumber];
- if(offline_docnumber==nil)
- {
- // [RAUtils message_alert:@"Offline document number prefix not found, Please check your user name and make sure you had signed in at least once." title:@"Create Customer" controller:self] ;
- [RAUtils message_box:@"Create Customer" message:@"Offline document number prefix not found, Please check your user name and make sure you had signed in at least once." completion:nil];
- return;
- }
- [appDelegate SwitchToOffline:RASingleton.sharedInstance.user];
- DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
-
- // dvc.templateName = @"debug.json";
- dvc.templatePath = [[NSBundle mainBundle] pathForResource:CONTRACT_TEMPLATE ofType:nil];
- dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"GECI - Home Improvement Contract - Tan.pdf" ofType:nil];
- dvc.docment_id = offline_docnumber;
- dvc.OnSave=^(NSString* file, NSString* subject)
- {
-
- [weakSelf previewPDF:file title:offline_docnumber subject:subject];
- };
-
- [self.navigationController pushViewController:dvc animated:true];
-
-
- }];
-
- UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- DebugLog(@"Cancel");
- }];
- [alertControl addAction:actionOne];
-
- [alertControl addAction:alertthree];
-
- //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
-
-
- [self presentViewController:alertControl animated:YES completion:nil];
-
-
- }
- // }];
-
-
-
-
-
- }];
-
- // __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Create customer" completion:^{
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- //
- // NSMutableDictionary* json=[[RANetwork new_document] mutableCopy];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- //
- //
- //// [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- //
- //// [waitalert dismissViewControllerAnimated:YES completion:^{
- //
- // [pop hide];
- // if([json[@"result"] intValue]==RESULT_TRUE)
- //
- // {
- // DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
- //
- // // dvc.templateName = @"debug.json";
- // dvc.templatePath = [[NSBundle mainBundle] pathForResource:CONTRACT_TEMPLATE ofType:nil];
- // dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"GECI - Home Improvement Contract - Tan.pdf" ofType:nil];
- // dvc.docment_id = json[@"doc_number"];
- // dvc.OnSave=^(NSString* file, NSString* subject)
- // {
- //
- // [weakSelf previewPDF:file title:json[@"doc_number"] subject:subject];
- // };
- //
- // [self.navigationController pushViewController:dvc animated:true];
- // }
- // else
- // {
- // // [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Create Customer" controller:self] ;
- //
- // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Create Customer" message:@"Can not create new customer on server, do you want to create an offline document?" preferredStyle:UIAlertControllerStyleAlert];
- //
- //
- // UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
- // __block NSString* offline_docnumber =[RANetwork offline_docnumber];
- // if(offline_docnumber==nil)
- // {
- //// [RAUtils message_alert:@"Offline document number prefix not found, Please check your user name and make sure you had signed in at least once." title:@"Create Customer" controller:self] ;
- // [RAUtils message_box:@"Create Customer" message:@"Offline document number prefix not found, Please check your user name and make sure you had signed in at least once." completion:nil];
- // return;
- // }
- // [appDelegate SwitchToOffline:RASingleton.sharedInstance.user];
- // DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
- //
- // // dvc.templateName = @"debug.json";
- // dvc.templatePath = [[NSBundle mainBundle] pathForResource:CONTRACT_TEMPLATE ofType:nil];
- // dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"GECI - Home Improvement Contract - Tan.pdf" ofType:nil];
- //
- // dvc.docment_id = offline_docnumber;
- // dvc.OnSave=^(NSString* file, NSString* subject)
- // {
- //
- // [weakSelf previewPDF:file title:offline_docnumber subject:subject];
- // };
- //
- // [self.navigationController pushViewController:dvc animated:true];
- //
- //
- // }];
- //
- // UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- // DebugLog(@"Cancel");
- // }];
- // [alertControl addAction:actionOne];
- //
- // [alertControl addAction:alertthree];
- //
- // //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
- //
- //
- // [self presentViewController:alertControl animated:YES completion:nil];
- //
- //
- // }
- //// }];
- //
- //
- //
- //
- // });
- // });
-
- // }];
-
- }
-
-
-
-
- }
- - (IBAction)onCustomerPerDocClick:(id)sender {
-
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if(appDelegate.accessMode == AppAccessModeOffline)
- {
- // [RAUtils message_alert:@"You can only access this function onder online mode." title:@"Offline mode." controller:self];
-
- [RAUtils message_box:@"Offline mode." message:@"You can only access this function onder online mode." completion:nil];
- return;
- }
-
- DocumentListViewController* docVC =[self.storyboard instantiateViewControllerWithIdentifier:@"DocumentListViewController" ];
-
- [self.navigationController pushViewController:docVC animated:true];
- }
- - (IBAction)onPendingDocClick:(id)sender {
- PendingDocumentsViewController* docVC =[self.storyboard instantiateViewControllerWithIdentifier:@"PendingDocumentsViewController" ];
-
- [self.navigationController pushViewController:docVC animated:true];
- }
- - (IBAction)onModeSwitch:(id)sender {
- UISwitch* sw = sender;
-
- NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
- NSString * user = [AESCrypt decrypt:[defaults stringForKey:@"user"] password:@"usai"];
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if(sw.isOn)
- {
- self.navigationItem.rightBarButtonItem = self.ibSignin;
- self.labelMode.text = @"Mode: Online";
- [appDelegate Logout];
- [self.ibSignin setTitle:@"Sign in"];
- [self presentLogin:self.ibSignin];
-
- //
- // [self.switchMode setOn:true];
- }
- else
- {
-
-
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Enter user name for offline mode." message:nil preferredStyle:UIAlertControllerStyleAlert];
-
-
- [alertControl addTextFieldWithConfigurationHandler:^(UITextField *textField) {
- textField.text = user;
- textField.keyboardType=UIKeyboardTypeDefault;
- textField.delegate = nil;
-
-
- }];
-
- UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-
-
- UITextField *name = alertControl.textFields.firstObject;
- if(name.text.length==0)
- {
- self.navigationItem.rightBarButtonItem = self.ibSignin;
- [sw setOn: true];
- // [RAUtils message_alert:@"User name is required." title:@"Can not switch to offline mode." controller:self];
- [RAUtils message_box:@"Can not switch to offline mode." message:@"User name is required." completion:nil];
- }
- else
- {
- self.navigationItem.rightBarButtonItem = nil;
- self.labelMode.text = @"Mode: Offline";
- [appDelegate SwitchToOffline:name.text];
- self.welcomeLabel.text=[NSString stringWithFormat:@"Welcome %@",RASingleton.sharedInstance.user];
- self.coverView.hidden = true;
- }
-
-
- }];
- // [alertControl addAction:actionOne];
-
- [alertControl addAction:alertthree];
-
-
- UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- [sw setOn: true];
- }];
- [alertControl addAction:alertcancel];
- //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
-
-
-
-
- [self presentViewController:alertControl animated:YES completion:nil];
-
- // [self.switchMode setOn:false];
- }
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- -(void) reloadBG
- {
- UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];
-
- switch (orientation) {
- case UIInterfaceOrientationPortrait:
- case UIInterfaceOrientationPortraitUpsideDown:
- {
- self.coverBG.image = [UIImage imageNamed:@"home_bg_p"];
- self.imageBG.image = [UIImage imageNamed:@"home_bg_p"];
- break;
- }
-
-
- case UIInterfaceOrientationLandscapeLeft:
- case UIInterfaceOrientationLandscapeRight:
- {
- self.coverBG.image = [UIImage imageNamed:@"home_bg_l"];
- self.imageBG.image = [UIImage imageNamed:@"home_bg_l"];
- break;
- }
-
- default:
- self.coverBG.image = [UIImage imageNamed:@"home_bg_p"];
- self.imageBG.image = [UIImage imageNamed:@"home_bg_p"];
- break;
- }
- }
- //-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
- //{
- //
- // [self reloadBG];
- //
- //
- //// [self initControl];
- //// // [self.pdfPageView setNeedsLayout];
- //// [self.pdfPageView setNeedsDisplay];
- //// // UIDeviceOrientation dev_ori = [[UIDevice currentDevice]orientation];
- ////
- //// // UIApplication * app = [UIApplication sharedApplication];
- //// // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- //// // [appDelegate didRotated];
- ////
- //
- //
- //// // if (UIInterfaceOrientationIsLandscape(orientation)|| UIInterfaceOrientationIsPortrait(orientation))
- //// // {
- //// // self.orientation = orientation;
- //// // [self.collectionview.collectionViewLayout invalidateLayout];
- //// // DebugLog(@"routed");
- //// // }
- //
- //
- //
- //
- //}
- - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
- [self reloadBG];
- [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
- }
- - (void)dealWithUILogout {
- self.welcomeLabel.text=@"Not sign in";
- // [sender setTitle:@"Sign in" forState:UIControlStateNormal];
- [self.ibSignin setTitle:@"Sign in"];
-
- self.buttonHIC.enabled = false;
- self.buttonSRL.enabled = false;
- self.coverView.hidden = false;
- }
- - (IBAction)onPrivacyClick:(id)sender {
-
- NSString* url = URL_PRIVACY;
-
- NSString* title = @"Privacy Policy";
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
- [self.navigationController pushViewController:ViewController animated:YES];
- }
- - (IBAction)OnSigninClick:(id)sender {
-
-
- UIBarButtonItem* bbitem = sender;
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if(appDelegate.bLogin)
- {
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Are you sure to sign out?" message:nil preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-
-
- // __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Sign out" completion:^{
-
- PopWaitAlert* pop =[RAUtils waiting_pop:@"Sign out" completion:nil];
-
- [RANetwork request_logout:^(NSMutableDictionary *result) {
- NSDictionary* logout_json = result;
- [pop hide];
- if([[logout_json valueForKey:@"result"] intValue]==2)
- {
- self.welcomeLabel.text=@"Not sign in";
- // [sender setTitle:@"Sign in" forState:UIControlStateNormal];
- [bbitem setTitle:@"Sign in"];
-
- self.buttonHIC.enabled = false;
- self.buttonSRL.enabled = false;
- self.coverView.hidden = false;
- }
- else
- {
- // [RAUtils message_alert:[logout_json valueForKey:@"err_msg"] title:@"Sign out" controller:self] ;
-
- [RAUtils message_box:@"Sign out" message:[logout_json valueForKey:@"err_msg"] completion:nil];
- }
- }];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* logout_json = nil;
- //
- //
- //
- // logout_json = [RANetwork logout];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- //
- //// [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- //// [waitalert dismissViewControllerAnimated:YES completion:^{
- //
- // [pop hide];
- // if([[logout_json valueForKey:@"result"] intValue]==2)
- // {
- // self.welcomeLabel.text=@"Not sign in";
- // // [sender setTitle:@"Sign in" forState:UIControlStateNormal];
- // [bbitem setTitle:@"Sign in"];
- //
- // self.buttonHIC.enabled = false;
- // self.buttonSRL.enabled = false;
- // self.coverView.hidden = false;
- // }
- // else
- // {
- //// [RAUtils message_alert:[logout_json valueForKey:@"err_msg"] title:@"Sign out" controller:self] ;
- //
- // [RAUtils message_box:@"Sign out" message:[logout_json valueForKey:@"err_msg"] completion:nil];
- // }
- //// }];
- //
- //
- //
- //
- //
- // });
- // });
- // }];
-
-
-
-
-
- }];
- // [alertControl addAction:actionOne];
-
- [alertControl addAction:alertthree];
-
-
- UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- }];
- [alertControl addAction:alertcancel];
- //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
-
-
-
-
- [self presentViewController:alertControl animated:YES completion:nil];
-
- }
- else
- [self presentLogin:sender];
-
-
-
- }
- -(void) previewPDF:(NSString*)file title:(NSString*)title subject:(NSString*)subject
- {
- // return;
-
- // NSString* name=@"";//[self.content_data[indexPath.row] valueForKey:@"tear_name"];
- NSString* url= file;//[self.content_data[indexPath.row] valueForKey:@"pdf_path"];
-
-
-
- bool isLocalFile= true;//[self.content_data[indexPath.row] valueForKey:@"isLocalFile"];
-
- RAPDFViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
- ViewController.url = url;
- ViewController.canSave = false;
- ViewController.isLocalfile=isLocalFile;
- ViewController.defaultStyle = true;
- ViewController.save_name=title;
- ViewController.title = title;
- // NSString* subject;
- // if (company.length==0) {
-
- // NSString* cur_time =[RAUtils current_date];
- // subject =name;//[NSString stringWithFormat:@"NPD Product List %@",cur_time];
-
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // NSString* customer_email= [appDelegate.customerInfo valueForKey:@"customer_email"];
-
-
- NSMutableArray* send_to = [[NSMutableArray alloc]init];
- // if(customer_email.length>0)
- // {
- // send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
- // // customer_email compo
- // // [send_to addObject:customer_email];
- // }
- ViewController.mail_to = send_to;
-
- // }
- // else
- // {
- // subject = [NSString stringWithFormat:@"Tear sheet for %@",company ];
- // }
- // ViewController.attachment_name = [NSString stringWithFormat:@"NPD_Product_List %@.pdf",cur_time];
- ViewController.mail_subject = subject;
-
- ViewController.hidenavi = false;
- [self.navigationController pushViewController:ViewController animated:YES];
- }
- //- (IBAction)OnHICClick:(id)sender {
- //
- //
- // __weak typeof(self) weakSelf = self;
- //
- //
- // DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
- //
- // dvc.templateName = @"GEIC - Home Improvement Contract 2016.json";
- // dvc.pdfName = @"GEIC - Home Improvement Contract 2017.pdf";
- //
- // dvc.OnSave=^(NSString* file)
- // {
- // // [weakSelf previewPDF:file];
- // };
- //
- // [self.navigationController pushViewController:dvc animated:true];
- //}
- //- (IBAction)OnSRLClick:(id)sender {
- //
- // DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
- //
- // dvc.templateName = @"SUBCONTRACTORS REFERRAL LIST.json";
- // dvc.pdfName = @"SUBCONTRACTORS REFERRAL LIST.pdf";
- // dvc.OnSave=^(NSString* file)
- // {
- //
- // //[self previewPDF:file];
- // };
- //
- // [self.navigationController pushViewController:dvc animated:true];
- //}
- - (IBAction)debugBtnClick:(UIButton *)sender {
-
- DocumentTemplateViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentTemplateViewController" ];
-
- dvc.templatePath = [[NSBundle mainBundle] pathForResource:CONTRACT_TEMPLATE ofType:nil];
- dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"GECI - Home Improvement Contract - Tan.pdf" ofType:nil];
-
- dvc.docment_id = @"debug_template";
- dvc.OnSave=^(NSString* file, NSString* subject)
- {
-
-
- };
-
- [self.navigationController pushViewController:dvc animated:true];
-
- }
- @end
|