forked from opendcim/openDCIM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate_mpdf_reports.inc.php
103 lines (92 loc) · 2.91 KB
/
template_mpdf_reports.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
include "vendor/mpdf/mpdf/mpdf.php";
$header=(!isset($header))?$config->ParameterArray["OrgName"]:$header;
$subheader=(!isset($subheader))?"":$subheader;
$reportHTML=(!isset($reportHTML))?__("No Data to Display"):$reportHTML;
// $mpdf=new \Mpdf\Mpdf('','',0,'',20,15,48,25,10,10);
$mpdf=new Mpdf();
$mpdf->useOnlyCoreFonts = true; // false is default
//$mpdf->SetProtection(array('print'));
$mpdf->SetTitle($header . " " . $subheader);
$mpdf->SetAuthor($config->ParameterArray["OrgName"]);
$mpdf->SetDisplayMode('fullpage');
$mpdf->useActiveForms = true;
/* Note: typically you would do zebra-striping in the report using an
nth-child(even) type of css selector on tr (if you know for sure
your report doesn't use rowspans) or on tbody (if your report uses
rowspans) - but mpdf doesn't support css classes for the tbody
tag, so if we want to do reliable zebra-striping, you have to
put code into the report generation to do it and use the
tr.altcolor selector.
see report_panel_schedule.php
*/
$html = <<<EOT
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body {
font-family: sans-serif;
font-size: 10pt;
}
p { margin: 0pt; }
td { vertical-align: top; }
.items td {
border: 0.1mm solid #000000;
}
table {
border-collapse: collapse;
border-spacing: 0px;
margin-bottom: 25px;
page-break-inside:avoid;
}
table thead td {
background-color: #EEEEEE;
text-align: center;
}
.items td.bottom {
background-color: #FFFFFF;
}
.items td.totals {
text-align: right;
}
td.altcolor, tr.altcolor {
background-color: #E0EBFF;
}
</style>
EOT;
$html .= $reportHead;
$html .= <<<EOT
<title>openDCIM Inventory Reporting</title>
</head>
<body>
<!--mpdf
<htmlpageheader name="myheader">
<table width="100%"><tr>
EOT;
$html .= '<td width="50%"><img src="images/'.$config->ParameterArray['PDFLogoFile'].'">';
$html .= '<td width="50%" style="text-align: right;"><h4>'.$header.'<br>';
$html .= __("Date").': '.strftime("%x").'</h4></td>';
$html .= <<<EOT
</tr></table>
</htmlpageheader>
<htmlpagefooter name="myfooter">
<div style="border-top: 1px solid #000000; font-size: 9pt; text-align: center; padding-top: 3mm; ">
Page {PAGENO} of {nb}
</div>
</htmlpagefooter>
<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="on" />
mpdf-->
EOT;
$html .= '<h2>'.$subheader.'</h2>';
$html .= $reportHTML;
$html .= '</body></html>';
// since mpdf is slow, give it more than 30 seconds to generate report
set_time_limit(150);
$mpdf->WriteHTML($html);
$mpdf->Output();
//print $html;
?>