RootViewController.m 27 KB

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