printPDF_szisz.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. require_once '/var/www/html/custom/settlements/dompdf/autoload.inc.php';
  3. use Dompdf\Dompdf;
  4. use FontLib\Table\Type\head;
  5. class SettlementsPDFPrint
  6. {
  7. public $htmlTemplate = '';
  8. public function __construct($htmlContent = '')
  9. {
  10. $this->htmlTemplate = $htmlContent;
  11. }
  12. public function generateSettlementsPDF($userinvoice = null)
  13. {
  14. $dompdf = new Dompdf();
  15. $options = $dompdf->getOptions();
  16. $dompdf->set_option('defaultFont', 'DejaVu Sans');
  17. $dompdf->setOptions($options);
  18. $html = '
  19. <html>
  20. <head>
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  22. <style type="text/css">
  23. * { font-family: "DejaVu Sans" !important; }
  24. </style>
  25. </head>
  26. <body>';
  27. $html .= $this->htmlTemplate;
  28. $html .= '<script type="text/php"><?=$PAGE_NUM?></script></body></html>';
  29. $dompdf->loadHtml($html, 'UTF-8');
  30. $dompdf->setPaper('A4', 'portrai');
  31. $dompdf->render();
  32. $fname = time() . '_' . uniqid();
  33. $filename = $fname . '.pdf';
  34. $directory_path = '/var/www/html/documents/settlements/pdf/';
  35. //$custompath = date('Y') . '/' . date('m') . '/' .
  36. if (!is_dir($directory_path)) {
  37. mkdir($directory_path, 0775, true);
  38. chmod($directory_path, 0775);
  39. }
  40. if (is_null($userinvoice)) {
  41. $full_path = $directory_path . $filename;
  42. } else {
  43. $full_path = $directory_path . $userinvoice . '/' . $filename;
  44. }
  45. $pdf_gen = $dompdf->output();
  46. file_put_contents($full_path, $pdf_gen);
  47. //$dompdf->stream($fname,array("Attachment"=>0));
  48. return $full_path;
  49. }
  50. public function generateCommissionSettlementsPDF()
  51. {
  52. $dompdf = new Dompdf();
  53. $options = $dompdf->getOptions();
  54. $dompdf->set_option('defaultFont', 'DejaVu Sans');
  55. $dompdf->setOptions($options);
  56. $html = '
  57. <html>
  58. <head>
  59. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  60. <style type="text/css">
  61. * { font-family: "DejaVu Sans" !important; }
  62. </style>
  63. </head>
  64. <body>';
  65. $html .= $this->htmlTemplate;
  66. $html .= '<script type="text/php"><?=$PAGE_NUM?></script></body></html>';
  67. $dompdf->loadHtml($html, 'UTF-8');
  68. $dompdf->setPaper('A4', 'portrai');
  69. $dompdf->render();
  70. $fname = time() . '_' . uniqid();
  71. $filename = $fname . '.pdf';
  72. $directory_path = '/var/www/html/documents/settlements/pdf/commissionsettlements/';
  73. if (!is_dir($directory_path)) {
  74. mkdir($directory_path, 0775, true);
  75. chmod($directory_path, 0775);
  76. }
  77. //$custompath = date('Y') . '/' . date('m') . '/' .
  78. $full_path = $directory_path . $filename;
  79. $pdf_gen = $dompdf->output();
  80. file_put_contents($full_path, $pdf_gen);
  81. //$dompdf->stream($fname,array("Attachment"=>0));
  82. return $full_path;
  83. }
  84. public function generateDailyClosuingCheckoutClosurePDF()
  85. {
  86. $dompdf = new Dompdf();
  87. $options = $dompdf->getOptions();
  88. $dompdf->set_option('defaultFont', 'DejaVu Sans');
  89. $dompdf->setOptions($options);
  90. $html = '
  91. <html>
  92. <head>
  93. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  94. <style type="text/css">
  95. * { font-family: "DejaVu Sans" !important; }
  96. </style>
  97. </head>
  98. <body>';
  99. $html .= $this->htmlTemplate;
  100. $html .= '<script type="text/php"><?=$PAGE_NUM?></script></body></html>';
  101. $dompdf->loadHtml($html, 'UTF-8');
  102. $dompdf->setPaper('A4', 'portrai');
  103. $dompdf->render();
  104. $fname = time() . '_' . uniqid();
  105. $filename = $fname . '.pdf';
  106. $directory_path = '/var/www/html/documents/settlements/pdf/dailyclosingcheckoutclosure/';
  107. //$custompath = date('Y') . '/' . date('m') . '/' .
  108. $full_path = $directory_path . $filename;
  109. $pdf_gen = $dompdf->output();
  110. file_put_contents($full_path, $pdf_gen);
  111. //$dompdf->stream($fname,array("Attachment"=>0));
  112. return $full_path;
  113. }
  114. }