/
pdf_qms.php
126 lines (72 loc) · 5.93 KB
/
pdf_qms.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
include_once "inc_files/inc_checkcookie.php";
include_once "inc_files/inc_action_functions_pdf.php";
include_once "secure/prefs.php";
// Use FDPI to get the template
define('FPDF_FONTPATH','fpdf/font/');
require('fpdf/fpdi.php');
$pdf= new fpdi();
$pagecount = $pdf->setSourceFile("pdf/template.pdf");
$tplidx = $pdf->ImportPage(1);
$pdf->addPage();
$pdf->SetMargins(10,15,10);
$pdf->useTemplate($tplidx, 0, 0, 210, 297);
$format_font = PDFFonts($settings_pdffont);
if ($_GET[s1] > 0) {
$s1 = intval($_GET[s1]);
$s2 = intval($_GET[s2]);
$sql_firstpage = "SELECT qms_text FROM intranet_qms WHERE qms_toc1 = $s1 AND qms_toc2 = $s2";
$result_firstpage = mysql_query($sql_firstpage, $conn) or die(mysql_error());
$array_firstpage = mysql_fetch_array($result_firstpage);
$qms_firstpage = strip_tags ( $array_firstpage['qms_text'] );
}
if ($_GET[s1] > 0) { $s1 = intval($_GET[s1]); $section = "Section " . $_GET[s1] . " only - " . $qms_firstpage; $s1 = " WHERE qms_toc1 = $s1 "; } else { unset($s1); }
if ($_GET[s2] > 0) { $s2 = intval($_GET[s2]); $section = "Section " . $_GET[s1] . "." . $_GET[s2] . " only - " . $qms_firstpage; $s2 = " AND qms_toc2 = $s2 "; } else { unset($s2); }
$pdf->SetXY(10,175);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFillColor(220,220,220);
$pdf->SetFont('Helvetica','',18);
$pdf->MultiCell(0,10,$settings_companyname,0,L);
$pdf->SetFont('Helvetica','B',32);
$pdf->MultiCell(0,20,'Quality Management System',0,L);
$pdf->SetFont($format_font,'',14);
$printed_date = "Current at " . date("g.ia, jS F Y",time());
$pdf->MultiCell(0,25,'',0,L);
$pdf->MultiCell(0,8,$printed_date,0,L);
$pdf->SetLineWidth(0.1);
$pdf->SetFont($format_font,'',11);
$width = $pdf->GetStringWidth($printed_date) + 20;
if ($s1 != NULL OR $s2 != NULL) { $pdf->MultiCell(0,8,$section,T,L); }
$sql = "SELECT * FROM intranet_qms $s1 $s2 ORDER BY qms_toc1, qms_toc2, qms_toc3, qms_toc4";
$result = mysql_query($sql, $conn) or die(mysql_error());
while ($array = mysql_fetch_array($result)) {
$qms_id = $array['qms_id'];
$qms_toc1 = $array['qms_toc1'];
$qms_toc2 = $array['qms_toc2'];
$qms_toc3 = $array['qms_toc3'];
$qms_toc4 = $array['qms_toc4'];
$qms_type = $array['qms_type'];
$qms_text = strip_tags ( $array['qms_text'] );
$qms_timestamp = $array['qms_timestamp'];
$qms_date = date("d M Y",$qms_timestamp);
$qms_pagebreak = $array['qms_pagebreak'];
$number = $qms_toc4;
if ($_GET[proj_id] != NULL && $qms_text == "[project name]" ) { $qms_text = ProjectData($_GET[proj_id], $type); }
if ($_GET[proj_id] != NULL && substr($qms_text,0,1) == "#" ) { $qms_text = ChecklistDate($_GET[proj_id], $qms_text); }
$qms_text = ClauseCrossReference($qms_text);
$line_length = $pdf->GetStringWidth($qms_text);
$line_height = $pdf->GetY() + ceil($line_length/150) * 4;
if ($line_height > 270) { $pdf->addPage(); $line_height = 0;} elseif ($qms_pagebreak == 1) { $pdf->addPage(); $line_height = 0;}
if ($qms_toc4 > 0 && $qms_type == "code") { UpDate ($qms_date); $pdf->SetTextColor(0); $pdf->SetFont('Helvetica','',7); $pdf->Cell(15,4,$number,0,0,R); $pdf->SetFont('Courier','',10); $pdf->SetTextColor(0); $pdf->Cell(150,2,'',0,2,'',1); $pdf->MultiCell(150,4.5,$qms_text,0,'',true); $pdf->SetX(25); $pdf->Cell(150,2,'',0,2,'',1); $pdf->Cell(0,3,'',0,1); }
elseif ($qms_toc4 > 0 && $qms_type == "comp") { UpDate ($qms_date); $pdf->SetTextColor(0); $pdf->SetFont('Helvetica','',7); $pdf->Cell(15,4,$number,0,0,R); $pdf->SetTextColor(0); $pdf->SetLineWidth(0.5); $pdf->SetDrawColor(100);$pdf->Cell(1,3,'',0,0); $pdf->SetFont('Helvetica','',11); $pdf->Cell(149,15,$qms_text,1,1); $pdf->Cell(0,3,'',0,1); }
elseif ($qms_toc4 > 0 && $qms_type == "image") { $max_width = 150; $image = "images/" . $qms_text ; $image_size = GetImagesize($image); $image_height = $image_size[1]; $image_width = $image_size[0]; $height = ($image_height / $image_width) * $max_width; if ($pdf->GetY() + $height > 270) { $pdf->addPage(); } UpDate ($qms_date); $pdf->SetTextColor(0); $pdf->SetFont('Helvetica','',7); $pdf->Cell(15,4,$number,0,0,R); $x = $pdf->GetX(); $y = $pdf->GetY(); $pdf->Image($image,$x,$y,$max_width,$height); $y = ( $pdf->GetY() + $height + 2 ); $pdf->SetY($y); unset($x); unset($y); }
elseif ($qms_toc4 > 0 && $qms_type == "check") { UpDate ($qms_date); $pdf->SetTextColor(0); $pdf->SetFont('Helvetica','',7); $pdf->Cell(15,4,$number,0,0,R); $pdf->SetTextColor(0); $pdf->SetLineWidth(0.5); $pdf->SetDrawColor(100); $pdf->Cell(1,3,'',0,0); $pdf->Cell(10,6,'',1,0); $pdf->Cell(2,3,'',0,0); $pdf->SetFont($format_font,'',10); $pdf->MultiCell(135,4,$qms_text,0,L); $pdf->Cell(0,4,'',0,1); }
elseif ($qms_toc4 > 0 && $qms_type == NULL) { UpDate ($qms_date); $pdf->SetTextColor(0); $pdf->SetFont('Helvetica','',7); $pdf->SetTextColor(0); $pdf->Cell(15,5,$number,0,0,R); Paragraph($qms_text); $pdf->Cell(0,2,'',0,1); }
elseif ($qms_toc3 > 0) { if ($pdf->GetY() > 210) { $pdf->addPage(); } UpDate ($qms_date); $pdf->Cell(0,3,'',0,1); $pdf->SetFont('Helvetica','',11); $number = $qms_toc1 . "." . $qms_toc2 . "." . $qms_toc3; $pdf->Cell(15,6,$number,0,0,R); $pdf->Cell(150,6,$qms_text,0,2); $pdf->Cell(0,2,'',0,1); }
elseif ($qms_toc2 > 0) { $pdf->Cell(0,8,'',0,1); if ($pdf->GetY() > 210) { $pdf->addPage(); } UpDate ($qms_date); $pdf->SetFont('Helvetica','',12); $number = $qms_toc1 . "." . $qms_toc2; $pdf->Cell(15,8,$number,0,0,R); $pdf->Cell(150,8,$qms_text,0,2); $pdf->Cell(0,3,'',0,1); }
elseif ($qms_toc1 > 0) { NewPage(); UpDate ($qms_date); $pdf->SetFont('Helvetica','B',16); $pdf->Cell(15,10,$qms_toc1,0,0,R); $pdf->Cell(150,10,$qms_text,0,2); $pdf->Cell(0,5,'',0,1); }
}
// and send to output
$file_name = $pref_practice . "_QMS_".Date("Y",time())."-".Date("m",time())."-".Date("d",time()). "_" . $qms_toc1 . "-" . $qms_toc2 . ".pdf";
$pdf->Output($file_name,I);
?>