forked from webERP-team/webERP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPDFProdSpec.php
288 lines (268 loc) · 8.87 KB
/
PDFProdSpec.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<?php
include('includes/session.php');
include('includes/SQL_CommonFunctions.inc');
if (isset($_GET['KeyValue'])) {
$SelectedProdSpec=$_GET['KeyValue'];
} elseif (isset($_POST['KeyValue'])) {
$SelectedProdSpec=$_POST['KeyValue'];
} else {
$SelectedProdSpec='';
}
//Get Out if we have no product specification
If (!isset($SelectedProdSpec) OR $SelectedProdSpec==''){
$Title = _('Select Product Specification To Print');
include('includes/header.php');
echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/printer.png" title="' . _('Print') . '" alt="" />' . ' ' . $Title . '</p>';
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">
<div>
<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />
<table class="selection">
<tr>
<td>' . _('Enter Specification Name') .':</td>
<td><input type="text" name="KeyValue" size="25" maxlength="25" /></td>
</tr>
</table>
</div>
<div>
<input type="submit" name="PickSpec" value="' . _('Submit') . '" />
</div>
</form>
<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">
<div>
<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />
<table class="selection">
<tr>
<td>' . _('Or Select Existing Specification') .':</td>';
$SQLSpecSelect="SELECT DISTINCT(keyval),
description
FROM prodspecs LEFT OUTER JOIN stockmaster
ON stockmaster.stockid=prodspecs.keyval";
$ResultSelection=DB_query($SQLSpecSelect);
echo '<td><select name="KeyValue">';
while ($MyRowSelection=DB_fetch_array($ResultSelection)){
echo '<option value="' . $MyRowSelection['keyval'] . '">' . $MyRowSelection['keyval'].' - ' .htmlspecialchars($MyRowSelection['description'], ENT_QUOTES,'UTF-8', false) . '</option>';
}
echo '</select></td>';
echo '</tr>
</table>
</div>
<div>
<input type="submit" name="PickSpec" value="' . _('Submit') . '" />
</div>
</form>';
include('includes/footer.php');
exit();
}
/*retrieve the order details from the database to print */
$ErrMsg = _('There was a problem retrieving the Product Specification') . ' ' . $SelectedProdSpec . ' ' . _('from the database');
$sql = "SELECT keyval,
description,
longdescription,
prodspecs.testid,
name,
method,
qatests.units,
type,
numericvalue,
prodspecs.targetvalue,
prodspecs.rangemin,
prodspecs.rangemax,
groupby
FROM prodspecs INNER JOIN qatests
ON qatests.testid=prodspecs.testid
LEFT OUTER JOIN stockmaster on stockmaster.stockid=prodspecs.keyval
WHERE prodspecs.keyval='" .$SelectedProdSpec."'
AND prodspecs.showonspec='1'
ORDER by groupby, prodspecs.testid";
$result=DB_query($sql,$ErrMsg);
//If there are no rows, there's a problem.
if (DB_num_rows($result)==0){
$Title = _('Print Product Specification Error');
include('includes/header.php');
echo '<div class="centre">
<br />
<br />
<br />';
prnMsg( _('Unable to Locate Specification') . ' : ' . $_SelectedProdSpec . ' ', 'error');
echo '<br />
<br />
<br />
<table class="table_index">
<tr>
<td class="menu_group_item">
<ul><li><a href="'. $RootPath . '/PDFProdSpec.php">' . _('Product Specifications') . '</a></li></ul>
</td>
</tr>
</table>
</div>
<br />
<br />
<br />';
include('includes/footer.php');
exit;
}
$PaperSize = 'Letter';
include('includes/PDFStarter.php');
$pdf->addInfo('Title', _('Product Specification') );
$pdf->addInfo('Subject', _('Product Specification') . ' ' . $SelectedProdSpec);
$FontSize=12;
$PageNumber = 1;
$HeaderPrinted=0;
$line_height=$FontSize*1.25;
$RectHeight=12;
$SectionHeading=0;
$CurSection='NULL';
$SectionTitle='';
$SectionTrailer='';
$SectionsArray=array(array('PhysicalProperty',3, _('Technical Data Sheet Properties'), _('* Data herein is typical and not to be construed as specifications.'), array(260,110,135),array(_('Physical Property'),_('Value'),_('Test Method')),array('left','center','center')),
array('',3, _('Header'), _('* Trailer'), array(260,110,135), array(_('Physical Property'),_('Value'),_('Test Method')),array('left','center','center')),
array('Processing',2, _('Injection Molding Processing Guidelines'), _('* Desicant type dryer required.'), array(240,265),array(_('Setting'),_('Value')),array('left','center')),
array('RegulatoryCompliance',2, _('Regulatory Compliance'), '', array(240,265),array(_('Regulatory Compliance'),_('Value')),array('left','center')));
while ($myrow=DB_fetch_array($result)){
if ($myrow['description']=='') {
$myrow['description']=$myrow['keyval'];
}
$Spec=$myrow['description'];
$SpecDesc=$myrow['longdescription'];
foreach($SectionsArray as $row) {
if ($myrow['groupby']==$row[0]) {
$SectionColSizes=$row[4];
$SectionColLabs=$row[5];
$SectionAlign=$row[6];
}
}
$TrailerPrinted=1;
if ($HeaderPrinted==0) {
include('includes/PDFProdSpecHeader.inc');
$HeaderPrinted=1;
}
if ($CurSection!=$myrow['groupby']) {
$SectionHeading=0;
if ($CurSection!='NULL' AND $PrintTrailer==1) {
$pdf->line($XPos+1, $YPos+$RectHeight,$XPos+506, $YPos+$RectHeight);
}
$PrevTrailer=$SectionTrailer;
$CurSection=$myrow['groupby'];
foreach($SectionsArray as $row) {
if ($myrow['groupby']==$row[0]) {
$SectionTitle=$row[2];
$SectionTrailer=$row[3];
}
}
}
if ($SectionHeading==0) {
$XPos=65;
if ($PrevTrailer>'' AND $PrintTrailer==1) {
$PrevFontSize=$FontSize;
$FontSize=8;
$line_height=$FontSize*1.25;
$LeftOvers = $pdf->addTextWrap($XPos+5,$YPos,500,$FontSize,$PrevTrailer,'left');
$FontSize=$PrevFontSize;
$line_height=$FontSize*1.25;
$YPos -= $line_height;
$YPos -= $line_height;
}
if ($YPos < ($Bottom_Margin + 90)){ // Begins new page
$PrintTrailer=0;
$PageNumber++;
include ('includes/PDFProdSpecHeader.inc');
}
$LeftOvers = $pdf->addTextWrap($XPos,$YPos,500,$FontSize,$SectionTitle,'center');
$YPos -= $line_height;
$pdf->setFont('','B');
$pdf->SetFillColor(200,200,200);
$x=0;
foreach($SectionColLabs as $CurColLab) {
$ColLabel=$CurColLab;
$ColWidth=$SectionColSizes[$x];
$x++;
$LeftOvers = $pdf->addTextWrap($XPos+1,$YPos,$ColWidth,$FontSize,$ColLabel,'center',1,'fill');
$XPos+=$ColWidth;
}
$SectionHeading=1;
$YPos -= $line_height;
$pdf->setFont('','');
} //$SectionHeading==0
$XPos=65;
$Value='';
if ($myrow['targetvalue'] > '') {
$Value=$myrow['targetvalue'];
} elseif ($myrow['rangemin'] > '' OR $myrow['rangemax'] > '') {
if ($myrow['rangemin'] > '' AND $myrow['rangemax'] == '') {
$Value='> ' . $myrow['rangemin'];
} elseif ($myrow['rangemin']== '' AND $myrow['rangemax'] > '') {
$Value='< ' . $myrow['rangemax'];
} else {
$Value=$myrow['rangemin'] . ' - ' . $myrow['rangemax'];
}
}
if (strtoupper($Value) <> 'NB' AND strtoupper($Value) <> 'NO BREAK') {
$Value.= ' ' . $myrow['units'];
}
$x=0;
foreach($SectionColLabs as $CurColLab) {
$ColLabel=$CurColLab;
$ColWidth=$SectionColSizes[$x];
$ColAlign=$SectionAlign[$x];
switch ($x) {
case 0;
$DispValue=$myrow['name'];
break;
case 1;
$DispValue=$Value;
break;
case 2;
$DispValue=$myrow['method'];
break;
}
$LeftOvers = $pdf->addTextWrap($XPos+1,$YPos,$ColWidth,$FontSize,$DispValue,$ColAlign,1);
$XPos+=$ColWidth;
$x++;
}
$YPos -= $line_height;
$XPos=65;
$PrintTrailer=1;
if ($YPos < ($Bottom_Margin + 80)){ // Begins new page
$pdf->line($XPos+1, $YPos+$RectHeight,$XPos+506, $YPos+$RectHeight);
$PrintTrailer=0;
$PageNumber++;
include ('includes/PDFProdSpecHeader.inc');
}
//echo 'PrintTrailer'.$PrintTrailer.' '.$PrevTrailer.'<br>' ;
} //while loop
$pdf->line($XPos+1, $YPos+$RectHeight,$XPos+506, $YPos+$RectHeight);
if ($SectionTrailer>'') {
$PrevFontSize=$FontSize;
$FontSize=8;
$line_height=$FontSize*1.25;
$LeftOvers = $pdf->addTextWrap($XPos+5,$YPos,500,$FontSize,$SectionTrailer,'left');
$FontSize=$PrevFontSize;
$line_height=$FontSize*1.25;
$YPos -= $line_height;
$YPos -= $line_height;
}
if ($YPos < ($Bottom_Margin + 85)){ // Begins new page
$PageNumber++;
include ('includes/PDFProdSpecHeader.inc');
}
$Disclaimer= _('The information provided on this datasheet should only be used as a guideline. Actual lot to lot values will vary.');
$FontSize=8;
$line_height=$FontSize*1.25;
$YPos -= $line_height;
$LeftOvers = $pdf->addTextWrap($XPos+5,$YPos,500,$FontSize,$Disclaimer);
$YPos -= $line_height;
$YPos -= $line_height;
$sql = "SELECT confvalue
FROM config
WHERE confname='QualityProdSpecText'";
$result=DB_query($sql,$ErrMsg);
$myrow=DB_fetch_array($result);
$Disclaimer=$myrow[0];
$LeftOvers = $pdf->addTextWrap($XPos+5,$YPos,500,$FontSize,$Disclaimer);
while (mb_strlen($LeftOvers) > 1) {
$YPos -= $line_height;
$LeftOvers = $pdf->addTextWrap($XPos+5,$YPos,500,$FontSize, $LeftOvers, 'left');
}
$pdf->OutputI($_SESSION['DatabaseName'] . '_ProductSpecification_' . date('Y-m-d') . '.pdf');
$pdf->__destruct();
?>