RootViewController.m 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  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:@"GEIC - Home Improvement Contract 2017 Desktop.json" ofType:nil];
  225. dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"GEIC - Home Improvement Contract 2017 Desktop_1.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:@"GEIC - Home Improvement Contract 2017 Desktop.json" ofType:nil];
  245. dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"GEIC - Home Improvement Contract 2017 Desktop_1.pdf" ofType:nil]; dvc.docment_id = json[@"doc_number"];
  246. dvc.OnSave=^(NSString* file, NSString* subject)
  247. {
  248. [weakSelf previewPDF:file title:json[@"doc_number"] subject:subject];
  249. };
  250. [self.navigationController pushViewController:dvc animated:true];
  251. }
  252. else
  253. {
  254. // [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Create Customer" controller:self] ;
  255. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Create Customer" message:@"Can not create new customer on server, do you want to create an offline document?" preferredStyle:UIAlertControllerStyleAlert];
  256. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  257. __block NSString* offline_docnumber =[ACNetwork offline_docnumber];
  258. if(offline_docnumber==nil)
  259. {
  260. [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] ;
  261. return;
  262. }
  263. [appDelegate SwitchToOffline:appDelegate.user];
  264. DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
  265. // dvc.templateName = @"debug.json";
  266. dvc.templatePath = [[NSBundle mainBundle] pathForResource:@"GEIC - Home Improvement Contract 2017 Desktop.json" ofType:nil];
  267. dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"GEIC - Home Improvement Contract 2017 Desktop_1.pdf" ofType:nil];
  268. dvc.docment_id = offline_docnumber;
  269. dvc.OnSave=^(NSString* file, NSString* subject)
  270. {
  271. [weakSelf previewPDF:file title:offline_docnumber subject:subject];
  272. };
  273. [self.navigationController pushViewController:dvc animated:true];
  274. }];
  275. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  276. DebugLog(@"Cancel");
  277. }];
  278. [alertControl addAction:actionOne];
  279. [alertControl addAction:alertthree];
  280. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  281. [self presentViewController:alertControl animated:YES completion:nil];
  282. }
  283. });
  284. });
  285. }
  286. }
  287. - (IBAction)onCustomerPerDocClick:(id)sender {
  288. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  289. if(appDelegate.accessMode == AppAccessModeOffline)
  290. {
  291. [RAUtils message_alert:@"You can only access this function onder online mode." title:@"Offline mode." controller:self];
  292. return;
  293. }
  294. DocumentListViewController* docVC =[self.storyboard instantiateViewControllerWithIdentifier:@"DocumentListViewController" ];
  295. [self.navigationController pushViewController:docVC animated:true];
  296. }
  297. - (IBAction)onPendingDocClick:(id)sender {
  298. PendingDocumentsViewController* docVC =[self.storyboard instantiateViewControllerWithIdentifier:@"PendingDocumentsViewController" ];
  299. [self.navigationController pushViewController:docVC animated:true];
  300. }
  301. - (IBAction)onModeSwitch:(id)sender {
  302. UISwitch* sw = sender;
  303. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  304. NSString * user = [AESCrypt decrypt:[defaults stringForKey:@"user"] password:@"usai"];
  305. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  306. if(sw.isOn)
  307. {
  308. self.navigationItem.rightBarButtonItem = self.ibSignin;
  309. self.labelMode.text = @"Mode: Online";
  310. [appDelegate Logout];
  311. [self.ibSignin setTitle:@"Sign in"];
  312. [self presentLogin:self.ibSignin];
  313. //
  314. // [self.switchMode setOn:true];
  315. }
  316. else
  317. {
  318. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Enter user name for offline mode." message:nil preferredStyle:UIAlertControllerStyleAlert];
  319. [alertControl addTextFieldWithConfigurationHandler:^(UITextField *textField) {
  320. textField.text = user;
  321. textField.keyboardType=UIKeyboardTypeDefault;
  322. textField.delegate = nil;
  323. }];
  324. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  325. UITextField *name = alertControl.textFields.firstObject;
  326. if(name.text.length==0)
  327. {
  328. self.navigationItem.rightBarButtonItem = self.ibSignin;
  329. [sw setOn: true];
  330. [RAUtils message_alert:@"User name is required." title:@"Can not switch to offline mode." controller:self];
  331. }
  332. else
  333. {
  334. self.navigationItem.rightBarButtonItem = nil;
  335. self.labelMode.text = @"Mode: Offline";
  336. [appDelegate SwitchToOffline:name.text];
  337. self.welcomeLabel.text=[NSString stringWithFormat:@"Welcome %@",appDelegate.user];
  338. self.coverView.hidden = true;
  339. }
  340. }];
  341. // [alertControl addAction:actionOne];
  342. [alertControl addAction:alertthree];
  343. UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  344. [sw setOn: true];
  345. }];
  346. [alertControl addAction:alertcancel];
  347. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  348. [self presentViewController:alertControl animated:YES completion:nil];
  349. // [self.switchMode setOn:false];
  350. }
  351. }
  352. - (void)didReceiveMemoryWarning {
  353. [super didReceiveMemoryWarning];
  354. // Dispose of any resources that can be recreated.
  355. }
  356. -(void) reloadBG
  357. {
  358. UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];
  359. switch (orientation) {
  360. case UIInterfaceOrientationPortrait:
  361. case UIInterfaceOrientationPortraitUpsideDown:
  362. {
  363. self.coverBG.image = [UIImage imageNamed:@"home_bg_p"];
  364. self.imageBG.image = [UIImage imageNamed:@"home_bg_p"];
  365. break;
  366. }
  367. case UIInterfaceOrientationLandscapeLeft:
  368. case UIInterfaceOrientationLandscapeRight:
  369. {
  370. self.coverBG.image = [UIImage imageNamed:@"home_bg_l"];
  371. self.imageBG.image = [UIImage imageNamed:@"home_bg_l"];
  372. break;
  373. }
  374. default:
  375. self.coverBG.image = [UIImage imageNamed:@"home_bg_p"];
  376. self.imageBG.image = [UIImage imageNamed:@"home_bg_p"];
  377. break;
  378. }
  379. }
  380. -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
  381. {
  382. [self reloadBG];
  383. // [self initControl];
  384. // // [self.pdfPageView setNeedsLayout];
  385. // [self.pdfPageView setNeedsDisplay];
  386. // // UIDeviceOrientation dev_ori = [[UIDevice currentDevice]orientation];
  387. //
  388. // // UIApplication * app = [UIApplication sharedApplication];
  389. // // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  390. // // [appDelegate didRotated];
  391. //
  392. // // if (UIInterfaceOrientationIsLandscape(orientation)|| UIInterfaceOrientationIsPortrait(orientation))
  393. // // {
  394. // // self.orientation = orientation;
  395. // // [self.collectionview.collectionViewLayout invalidateLayout];
  396. // // DebugLog(@"routed");
  397. // // }
  398. }
  399. - (void)dealWithUILogout {
  400. self.welcomeLabel.text=@"Not sign in";
  401. // [sender setTitle:@"Sign in" forState:UIControlStateNormal];
  402. [self.ibSignin setTitle:@"Sign in"];
  403. self.buttonHIC.enabled = false;
  404. self.buttonSRL.enabled = false;
  405. self.coverView.hidden = false;
  406. }
  407. - (IBAction)OnSigninClick:(id)sender {
  408. UIBarButtonItem* bbitem = sender;
  409. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  410. if(appDelegate.bLogin)
  411. {
  412. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Are you sure to sign out?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  413. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  414. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Sign out"];
  415. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  416. NSDictionary* logout_json = nil;
  417. logout_json = [ACNetwork logout];
  418. dispatch_async(dispatch_get_main_queue(), ^{
  419. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  420. if([[logout_json valueForKey:@"result"] intValue]==2)
  421. {
  422. self.welcomeLabel.text=@"Not sign in";
  423. // [sender setTitle:@"Sign in" forState:UIControlStateNormal];
  424. [bbitem setTitle:@"Sign in"];
  425. self.buttonHIC.enabled = false;
  426. self.buttonSRL.enabled = false;
  427. self.coverView.hidden = false;
  428. }
  429. else
  430. {
  431. [RAUtils message_alert:[logout_json valueForKey:@"err_msg"] title:@"Sign out" controller:self] ;
  432. }
  433. });
  434. });
  435. }];
  436. // [alertControl addAction:actionOne];
  437. [alertControl addAction:alertthree];
  438. UIAlertAction *alertcancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  439. }];
  440. [alertControl addAction:alertcancel];
  441. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  442. [self presentViewController:alertControl animated:YES completion:nil];
  443. }
  444. else
  445. [self presentLogin:sender];
  446. }
  447. -(void) previewPDF:(NSString*)file title:(NSString*)title subject:(NSString*)subject
  448. {
  449. // return;
  450. NSString* name=@"";//[self.content_data[indexPath.row] valueForKey:@"tear_name"];
  451. NSString* url= file;//[self.content_data[indexPath.row] valueForKey:@"pdf_path"];
  452. bool isLocalFile= true;//[self.content_data[indexPath.row] valueForKey:@"isLocalFile"];
  453. RAPDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
  454. ViewController.url = url;
  455. ViewController.canSave = false;
  456. ViewController.isLocalfile=isLocalFile;
  457. ViewController.defaultStyle = true;
  458. ViewController.save_name=title;
  459. ViewController.title = title;
  460. // NSString* subject;
  461. // if (company.length==0) {
  462. // NSString* cur_time =[RAUtils current_date];
  463. // subject =name;//[NSString stringWithFormat:@"NPD Product List %@",cur_time];
  464. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  465. // NSString* customer_email= [appDelegate.customerInfo valueForKey:@"customer_email"];
  466. NSMutableArray* send_to = [[NSMutableArray alloc]init];
  467. // if(customer_email.length>0)
  468. // {
  469. // send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
  470. // // customer_email compo
  471. // // [send_to addObject:customer_email];
  472. // }
  473. ViewController.mail_to = send_to;
  474. // }
  475. // else
  476. // {
  477. // subject = [NSString stringWithFormat:@"Tear sheet for %@",company ];
  478. // }
  479. // ViewController.attachment_name = [NSString stringWithFormat:@"NPD_Product_List %@.pdf",cur_time];
  480. ViewController.mail_subject = subject;
  481. ViewController.hidenavi = false;
  482. [self.navigationController pushViewController:ViewController animated:YES];
  483. }
  484. //- (IBAction)OnHICClick:(id)sender {
  485. //
  486. //
  487. // __weak typeof(self) weakSelf = self;
  488. //
  489. //
  490. // DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
  491. //
  492. // dvc.templateName = @"GEIC - Home Improvement Contract 2016.json";
  493. // dvc.pdfName = @"GEIC - Home Improvement Contract 2017.pdf";
  494. //
  495. // dvc.OnSave=^(NSString* file)
  496. // {
  497. // // [weakSelf previewPDF:file];
  498. // };
  499. //
  500. // [self.navigationController pushViewController:dvc animated:true];
  501. //}
  502. //- (IBAction)OnSRLClick:(id)sender {
  503. //
  504. // DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
  505. //
  506. // dvc.templateName = @"SUBCONTRACTORS REFERRAL LIST.json";
  507. // dvc.pdfName = @"SUBCONTRACTORS REFERRAL LIST.pdf";
  508. // dvc.OnSave=^(NSString* file)
  509. // {
  510. //
  511. // //[self previewPDF:file];
  512. // };
  513. //
  514. // [self.navigationController pushViewController:dvc animated:true];
  515. //}
  516. - (IBAction)debugBtnClick:(UIButton *)sender {
  517. DocumentTemplateViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentTemplateViewController" ];
  518. dvc.templatePath = [[NSBundle mainBundle] pathForResource:@"GEIC - Home Improvement Contract 2017 Desktop.json" ofType:nil];
  519. dvc.pdfPath = [[NSBundle mainBundle] pathForResource:@"GEIC - Home Improvement Contract 2017 Desktop_1.pdf" ofType:nil];
  520. dvc.docment_id = @"debug_template";
  521. dvc.OnSave=^(NSString* file, NSString* subject)
  522. {
  523. };
  524. [self.navigationController pushViewController:dvc animated:true];
  525. }
  526. @end