RootViewController.m 26 KB

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