RootViewController.m 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. //
  2. // ViewController.m
  3. // AntsContract
  4. //
  5. // Created by Ray on 12/16/16.
  6. // Copyright © 2016 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "RootViewController.h"
  9. #import "DocumentPageViewController.h"
  10. #import "LoginViewController.h"
  11. #import "AppDelegate.h"
  12. #import "RAUtils.h"
  13. #import "RAPDFViewController.h"
  14. #import "DocumentListViewController.h"
  15. #import "PendingDocumentsViewController.h"
  16. #import "ACNetwork.h"
  17. #import "PDFUtils.h"
  18. #import "AddExtDocumentViewController.h"
  19. #import "config.h"
  20. #import "DocumentTemplateViewController.h"
  21. #import "WebViewController.h"
  22. @interface RootViewController ()
  23. @property (nonatomic,assign) BOOL hasShowLoginView;
  24. @end
  25. @implementation RootViewController
  26. - (void)viewDidLoad {
  27. [super viewDidLoad];
  28. self.title= @"eSign";
  29. self.welcomeLabel.text=@"Not sign in";
  30. self.buttonHIC.enabled = false;
  31. self.buttonSRL.enabled = false;
  32. self.coverView.hidden = false;
  33. [self reloadBG];
  34. NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
  35. NSString* build =[infoDict objectForKey:@"CFBundleVersion"];
  36. NSString* version =[infoDict objectForKey:@"CFBundleShortVersionString"];
  37. NSString* versionNum = [NSString stringWithFormat:@"VeS1.%@.%@",version,build];
  38. self.labelVer.text = versionNum;
  39. self.debugBtn.hidden = !DEBUG_PDFSIG;
  40. // Do any additional setup after loading the view, typically from a nib.
  41. }
  42. - (NSInteger)loadDocCount {
  43. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  44. NSArray *docArr = [defaults arrayForKey:@"pending_doc"];
  45. if (docArr) {
  46. return docArr.count;
  47. }
  48. return 0;
  49. }
  50. -(void) viewDidAppear:(BOOL)animated
  51. {
  52. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  53. if(appDelegate.accessMode == AppAccessModeOnline)
  54. {
  55. self.labelMode.text = @"Mode: Online";
  56. [self.switchMode setOn:true];
  57. self.navigationItem.rightBarButtonItem = self.ibSignin;
  58. }
  59. else
  60. {
  61. self.labelMode.text = @"Mode: Offline";
  62. [self.switchMode setOn:false];
  63. self.navigationItem.rightBarButtonItem = nil;
  64. }
  65. if(!appDelegate.bLogin)
  66. [self presentLogin:self.ibSignin];
  67. NSInteger docCount = [self loadDocCount];
  68. if (docCount > 0) {
  69. self.labelDocNumber.hidden = NO;
  70. self.labelDocNumber.text = [NSString stringWithFormat:@"%ld",docCount];
  71. } else {
  72. self.labelDocNumber.hidden = YES;
  73. self.labelDocNumber.text = [NSString stringWithFormat:@""];
  74. }
  75. }
  76. -(void) presentLogin:(id)sender
  77. {
  78. // 确保只Presnet LoginView一次.
  79. if (self.hasShowLoginView) return;
  80. self.hasShowLoginView = YES;
  81. UIBarButtonItem* bbitem = sender;
  82. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  83. {
  84. LoginViewController * loginvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
  85. loginvc.returnValue = ^(bool blogin){
  86. // [self checklogin :true];
  87. self.hasShowLoginView = NO;
  88. if(blogin)
  89. {
  90. self.welcomeLabel.text=[NSString stringWithFormat:@"Welcome %@",appDelegate.user];
  91. [bbitem setTitle:@"Sign out"];
  92. self.buttonHIC.enabled = true;
  93. self.buttonSRL.enabled = true;
  94. self.coverView.hidden = true;
  95. // 处理三方app 传入文件
  96. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  97. if(appDelegate.shareFile)
  98. {
  99. AddExtDocumentViewController * addVC;
  100. addVC = [ [UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"AddExtDocumentViewController"];
  101. addVC.is_present = true;
  102. addVC.doc_number = nil;
  103. addVC.arr_documents = [NSMutableArray arrayWithObjects:appDelegate.shareFile, nil];
  104. appDelegate.shareFile=nil;
  105. // notesVC.docNotes = notes;
  106. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:addVC] ;
  107. navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  108. [self presentViewController:navi animated:YES completion:^{
  109. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  110. DebugLog(@"filter present.........");
  111. // self.btop = false;
  112. // <#code#>
  113. }];
  114. }
  115. }
  116. else
  117. {
  118. appDelegate.shareFile=nil;
  119. self.welcomeLabel.text=@"Not sign in";
  120. self.buttonHIC.enabled = false;
  121. self.buttonSRL.enabled = false;
  122. self.coverView.hidden = false;
  123. }
  124. };
  125. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  126. navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  127. [self presentViewController:navi animated:YES completion:^{
  128. DebugLog(@"login present.........");
  129. }];
  130. }
  131. }
  132. //-(void) leak_debug
  133. //{
  134. //
  135. //
  136. // CGPDFDocumentRef document = [PDFUtils OpenPDF:@"GEIC - Home Improvement Contract 2017.pdf"];
  137. // // self.total_page = CGPDFDocumentGetNumberOfPages (self.document);
  138. //
  139. // NSMutableDictionary * controlTemplate = [self templateInit:[PDFUtils loadControl:@"GEIC - Home Improvement Contract 2017.json"]];
  140. //
  141. //
  142. // NSString* pdffile = [PDFUtils SavePDF:controlTemplate source:document window_rect:CGRectMake(0, 0, 768, 960)];
  143. //
  144. // CGPDFDocumentRelease(document);
  145. //
  146. // // CFRelease(document);
  147. //
  148. // NSString* zipfile=[ACNetwork prepareUploadFile:pdffile json:controlTemplate];
  149. //
  150. // [self previewPDF:pdffile];
  151. //
  152. //
  153. //
  154. //
  155. //
  156. //
  157. //}
  158. //-(NSMutableDictionary*) templateInit:(NSMutableDictionary*) template
  159. //{
  160. //
  161. //
  162. // NSString* temp = NSTemporaryDirectory();
  163. // NSString* filename =[NSString stringWithFormat:@"%@.png", [[NSUUID UUID] UUIDString]];
  164. // NSString* qrpath=[temp stringByAppendingPathComponent:filename];
  165. // UIImage* qrimg=[RAUtils generateBarCode:@"leak test" width:300 height:44];//[QRCodeGenerator qrImageForString:order_code imageSize:240];
  166. // bool bwrite=[UIImagePNGRepresentation(qrimg)writeToFile: qrpath atomically:YES];
  167. //
  168. //
  169. //
  170. // for(int i=0;i<[template[@"count"] intValue];i++)
  171. // {
  172. // NSMutableDictionary* page =template[[NSString stringWithFormat:@"page_%d",i]];
  173. // for(int j=0;j<[page[@"count"] intValue];j++)
  174. // {
  175. // NSMutableDictionary* control =page[[NSString stringWithFormat:@"control_%d",j]];
  176. // NSString* type = control[@"type"];
  177. // NSString* field =control[@"field"];
  178. // if([type isEqualToString:@"Label"])
  179. // {
  180. // if([field isEqualToString:@"doc_number"])
  181. // {
  182. // control[@"value"]= @"leak test";
  183. // }
  184. // }
  185. // else if([type isEqualToString:@"Image"])
  186. // {
  187. // NSString* name =control[@"name"];
  188. // if([name isEqualToString:@"BarCode"])
  189. // {
  190. // if(bwrite)
  191. // control[@"value"]= qrpath;
  192. // }
  193. // }
  194. // else if([type isEqualToString:@"DatePicker"])
  195. // {
  196. // NSString* name =control[@"aname"];
  197. // if([name isEqualToString:@"Today's Date"])
  198. // {
  199. // NSDateFormatter * formatter = [[NSDateFormatter alloc]init];
  200. // [formatter setDateFormat:@"MM/dd/yyyy"];
  201. // NSString* date = [formatter stringFromDate:[NSDate date]] ;
  202. //
  203. // control[@"value"]= date;
  204. // }
  205. // }
  206. // }
  207. // }
  208. // return template;
  209. //}
  210. - (IBAction)onNewCustomerClick:(id)sender {
  211. // [self leak_debug];
  212. // return;
  213. __weak typeof(self) weakSelf = self;
  214. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  215. if(appDelegate.accessMode == AppAccessModeOffline)
  216. {
  217. __block NSString* offline_docnumber =[ACNetwork offline_docnumber];
  218. if(offline_docnumber==nil)
  219. {
  220. [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] ;
  221. return;
  222. }
  223. DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
  224. // dvc.templateName = @"debug.json";
  225. dvc.templatePath = [[NSBundle mainBundle] pathForResource:@"2020 GECI - Home Improvement Contract.json" ofType:nil];
  226. dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"2020 GECI - Home Improvement Contract.pdf" ofType:nil];
  227. dvc.docment_id = offline_docnumber;
  228. dvc.OnSave=^(NSString* file, NSString* subject)
  229. {
  230. [weakSelf previewPDF:file title:offline_docnumber subject:subject];
  231. };
  232. [self.navigationController pushViewController:dvc animated:true];
  233. }
  234. else
  235. {
  236. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Create customer"];
  237. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  238. NSMutableDictionary* json=[[ACNetwork new_document] mutableCopy];
  239. dispatch_async(dispatch_get_main_queue(), ^{
  240. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  241. if([json[@"result"] intValue]==RESULT_TRUE)
  242. {
  243. DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
  244. // dvc.templateName = @"debug.json";
  245. dvc.templatePath = [[NSBundle mainBundle] pathForResource:@"2020 GECI - Home Improvement Contract.json" ofType:nil];
  246. dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"2020 GECI - Home Improvement Contract.pdf" ofType:nil];
  247. dvc.docment_id = json[@"doc_number"];
  248. dvc.OnSave=^(NSString* file, NSString* subject)
  249. {
  250. [weakSelf previewPDF:file title:json[@"doc_number"] subject:subject];
  251. };
  252. [self.navigationController pushViewController:dvc animated:true];
  253. }
  254. else
  255. {
  256. // [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Create Customer" controller:self] ;
  257. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Create Customer" message:@"Can not create new customer on server, do you want to create an offline document?" preferredStyle:UIAlertControllerStyleAlert];
  258. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  259. __block NSString* offline_docnumber =[ACNetwork offline_docnumber];
  260. if(offline_docnumber==nil)
  261. {
  262. [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] ;
  263. return;
  264. }
  265. [appDelegate SwitchToOffline:appDelegate.user];
  266. DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
  267. // dvc.templateName = @"debug.json";
  268. dvc.templatePath = [[NSBundle mainBundle] pathForResource:@"2020 GECI - Home Improvement Contract.json" ofType:nil];
  269. dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"2020 GECI - Home Improvement Contract.pdf" ofType:nil];
  270. dvc.docment_id = offline_docnumber;
  271. dvc.OnSave=^(NSString* file, NSString* subject)
  272. {
  273. [weakSelf previewPDF:file title:offline_docnumber subject:subject];
  274. };
  275. [self.navigationController pushViewController:dvc animated:true];
  276. }];
  277. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  278. DebugLog(@"Cancel");
  279. }];
  280. [alertControl addAction:actionOne];
  281. [alertControl addAction:alertthree];
  282. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  283. [self presentViewController:alertControl animated:YES completion:nil];
  284. }
  285. });
  286. });
  287. }
  288. }
  289. - (IBAction)onCustomerPerDocClick:(id)sender {
  290. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  291. if(appDelegate.accessMode == AppAccessModeOffline)
  292. {
  293. [RAUtils message_alert:@"You can only access this function onder online mode." title:@"Offline mode." controller:self];
  294. return;
  295. }
  296. DocumentListViewController* docVC =[self.storyboard instantiateViewControllerWithIdentifier:@"DocumentListViewController" ];
  297. [self.navigationController pushViewController:docVC animated:true];
  298. }
  299. - (IBAction)onPendingDocClick:(id)sender {
  300. PendingDocumentsViewController* docVC =[self.storyboard instantiateViewControllerWithIdentifier:@"PendingDocumentsViewController" ];
  301. [self.navigationController pushViewController:docVC animated:true];
  302. }
  303. - (IBAction)onModeSwitch:(id)sender {
  304. UISwitch* sw = sender;
  305. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  306. NSString * user = [AESCrypt decrypt:[defaults stringForKey:@"user"] password:@"usai"];
  307. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  308. if(sw.isOn)
  309. {
  310. self.navigationItem.rightBarButtonItem = self.ibSignin;
  311. self.labelMode.text = @"Mode: Online";
  312. [appDelegate Logout];
  313. [self.ibSignin setTitle:@"Sign in"];
  314. [self presentLogin:self.ibSignin];
  315. //
  316. // [self.switchMode setOn:true];
  317. }
  318. else
  319. {
  320. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Enter user name for offline mode." message:nil preferredStyle:UIAlertControllerStyleAlert];
  321. [alertControl addTextFieldWithConfigurationHandler:^(UITextField *textField) {
  322. textField.text = user;
  323. textField.keyboardType=UIKeyboardTypeDefault;
  324. textField.delegate = nil;
  325. }];
  326. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  327. UITextField *name = alertControl.textFields.firstObject;
  328. if(name.text.length==0)
  329. {
  330. self.navigationItem.rightBarButtonItem = self.ibSignin;
  331. [sw setOn: true];
  332. [RAUtils message_alert:@"User name is required." title:@"Can not switch to offline mode." controller:self];
  333. }
  334. else
  335. {
  336. self.navigationItem.rightBarButtonItem = nil;
  337. self.labelMode.text = @"Mode: Offline";
  338. [appDelegate SwitchToOffline:name.text];
  339. self.welcomeLabel.text=[NSString stringWithFormat:@"Welcome %@",appDelegate.user];
  340. self.coverView.hidden = true;
  341. }
  342. }];
  343. // [alertControl addAction:actionOne];
  344. [alertControl addAction:alertthree];
  345. UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  346. [sw setOn: true];
  347. }];
  348. [alertControl addAction:alertcancel];
  349. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  350. [self presentViewController:alertControl animated:YES completion:nil];
  351. // [self.switchMode setOn:false];
  352. }
  353. }
  354. - (void)didReceiveMemoryWarning {
  355. [super didReceiveMemoryWarning];
  356. // Dispose of any resources that can be recreated.
  357. }
  358. -(void) reloadBG
  359. {
  360. UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];
  361. switch (orientation) {
  362. case UIInterfaceOrientationPortrait:
  363. case UIInterfaceOrientationPortraitUpsideDown:
  364. {
  365. self.coverBG.image = [UIImage imageNamed:@"home_bg_p"];
  366. self.imageBG.image = [UIImage imageNamed:@"home_bg_p"];
  367. break;
  368. }
  369. case UIInterfaceOrientationLandscapeLeft:
  370. case UIInterfaceOrientationLandscapeRight:
  371. {
  372. self.coverBG.image = [UIImage imageNamed:@"home_bg_l"];
  373. self.imageBG.image = [UIImage imageNamed:@"home_bg_l"];
  374. break;
  375. }
  376. default:
  377. self.coverBG.image = [UIImage imageNamed:@"home_bg_p"];
  378. self.imageBG.image = [UIImage imageNamed:@"home_bg_p"];
  379. break;
  380. }
  381. }
  382. -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
  383. {
  384. [self reloadBG];
  385. // [self initControl];
  386. // // [self.pdfPageView setNeedsLayout];
  387. // [self.pdfPageView setNeedsDisplay];
  388. // // UIDeviceOrientation dev_ori = [[UIDevice currentDevice]orientation];
  389. //
  390. // // UIApplication * app = [UIApplication sharedApplication];
  391. // // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  392. // // [appDelegate didRotated];
  393. //
  394. // // if (UIInterfaceOrientationIsLandscape(orientation)|| UIInterfaceOrientationIsPortrait(orientation))
  395. // // {
  396. // // self.orientation = orientation;
  397. // // [self.collectionview.collectionViewLayout invalidateLayout];
  398. // // DebugLog(@"routed");
  399. // // }
  400. }
  401. - (void)dealWithUILogout {
  402. self.welcomeLabel.text=@"Not sign in";
  403. // [sender setTitle:@"Sign in" forState:UIControlStateNormal];
  404. [self.ibSignin setTitle:@"Sign in"];
  405. self.buttonHIC.enabled = false;
  406. self.buttonSRL.enabled = false;
  407. self.coverView.hidden = false;
  408. }
  409. - (IBAction)onPrivacyClick:(id)sender {
  410. NSString* url = URL_PRIVACY;
  411. NSString* title = @"Privacy Policy";
  412. WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
  413. ViewController.url = url;
  414. ViewController.title = title;
  415. [self.navigationController pushViewController:ViewController animated:YES];
  416. }
  417. - (IBAction)OnSigninClick:(id)sender {
  418. UIBarButtonItem* bbitem = sender;
  419. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  420. if(appDelegate.bLogin)
  421. {
  422. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Are you sure to sign out?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  423. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  424. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Sign out"];
  425. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  426. NSDictionary* logout_json = nil;
  427. logout_json = [ACNetwork logout];
  428. dispatch_async(dispatch_get_main_queue(), ^{
  429. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  430. if([[logout_json valueForKey:@"result"] intValue]==2)
  431. {
  432. self.welcomeLabel.text=@"Not sign in";
  433. // [sender setTitle:@"Sign in" forState:UIControlStateNormal];
  434. [bbitem setTitle:@"Sign in"];
  435. self.buttonHIC.enabled = false;
  436. self.buttonSRL.enabled = false;
  437. self.coverView.hidden = false;
  438. }
  439. else
  440. {
  441. [RAUtils message_alert:[logout_json valueForKey:@"err_msg"] title:@"Sign out" controller:self] ;
  442. }
  443. });
  444. });
  445. }];
  446. // [alertControl addAction:actionOne];
  447. [alertControl addAction:alertthree];
  448. UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  449. }];
  450. [alertControl addAction:alertcancel];
  451. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  452. [self presentViewController:alertControl animated:YES completion:nil];
  453. }
  454. else
  455. [self presentLogin:sender];
  456. }
  457. -(void) previewPDF:(NSString*)file title:(NSString*)title subject:(NSString*)subject
  458. {
  459. // return;
  460. NSString* name=@"";//[self.content_data[indexPath.row] valueForKey:@"tear_name"];
  461. NSString* url= file;//[self.content_data[indexPath.row] valueForKey:@"pdf_path"];
  462. bool isLocalFile= true;//[self.content_data[indexPath.row] valueForKey:@"isLocalFile"];
  463. RAPDFViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
  464. ViewController.url = url;
  465. ViewController.canSave = false;
  466. ViewController.isLocalfile=isLocalFile;
  467. ViewController.defaultStyle = true;
  468. ViewController.save_name=title;
  469. ViewController.title = title;
  470. // NSString* subject;
  471. // if (company.length==0) {
  472. // NSString* cur_time =[RAUtils current_date];
  473. // subject =name;//[NSString stringWithFormat:@"NPD Product List %@",cur_time];
  474. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  475. // NSString* customer_email= [appDelegate.customerInfo valueForKey:@"customer_email"];
  476. NSMutableArray* send_to = [[NSMutableArray alloc]init];
  477. // if(customer_email.length>0)
  478. // {
  479. // send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
  480. // // customer_email compo
  481. // // [send_to addObject:customer_email];
  482. // }
  483. ViewController.mail_to = send_to;
  484. // }
  485. // else
  486. // {
  487. // subject = [NSString stringWithFormat:@"Tear sheet for %@",company ];
  488. // }
  489. // ViewController.attachment_name = [NSString stringWithFormat:@"NPD_Product_List %@.pdf",cur_time];
  490. ViewController.mail_subject = subject;
  491. ViewController.hidenavi = false;
  492. [self.navigationController pushViewController:ViewController animated:YES];
  493. }
  494. //- (IBAction)OnHICClick:(id)sender {
  495. //
  496. //
  497. // __weak typeof(self) weakSelf = self;
  498. //
  499. //
  500. // DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
  501. //
  502. // dvc.templateName = @"GEIC - Home Improvement Contract 2016.json";
  503. // dvc.pdfName = @"GEIC - Home Improvement Contract 2017.pdf";
  504. //
  505. // dvc.OnSave=^(NSString* file)
  506. // {
  507. // // [weakSelf previewPDF:file];
  508. // };
  509. //
  510. // [self.navigationController pushViewController:dvc animated:true];
  511. //}
  512. //- (IBAction)OnSRLClick:(id)sender {
  513. //
  514. // DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
  515. //
  516. // dvc.templateName = @"SUBCONTRACTORS REFERRAL LIST.json";
  517. // dvc.pdfName = @"SUBCONTRACTORS REFERRAL LIST.pdf";
  518. // dvc.OnSave=^(NSString* file)
  519. // {
  520. //
  521. // //[self previewPDF:file];
  522. // };
  523. //
  524. // [self.navigationController pushViewController:dvc animated:true];
  525. //}
  526. - (IBAction)debugBtnClick:(UIButton *)sender {
  527. DocumentTemplateViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentTemplateViewController" ];
  528. dvc.templatePath = [[NSBundle mainBundle] pathForResource:@"2020 GECI - Home Improvement Contract.json" ofType:nil];
  529. dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"2020 GECI - Home Improvement Contract.pdf" ofType:nil];
  530. dvc.docment_id = @"debug_template";
  531. dvc.OnSave=^(NSString* file, NSString* subject)
  532. {
  533. };
  534. [self.navigationController pushViewController:dvc animated:true];
  535. }
  536. @end