forked from timschofield/webERP
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBOMListing.php
More file actions
181 lines (151 loc) · 6.48 KB
/
BOMListing.php
File metadata and controls
181 lines (151 loc) · 6.48 KB
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
<?php
require(__DIR__ . '/includes/session.php');
use Dompdf\Dompdf;
include(__DIR__ . '/includes/SetDomPDFOptions.php');
if (isset($_POST['PrintPDF']) or isset($_POST['View'])) {
/*Now figure out the bills to report for the part range under review */
$SQL = "SELECT bom.parent,
bom.component,
stockmaster.description as compdescription,
stockmaster.decimalplaces,
stockmaster.units,
bom.quantity,
bom.loccode,
bom.workcentreadded,
bom.effectiveto AS eff_to,
bom.effectiveafter AS eff_frm
FROM stockmaster INNER JOIN bom
ON stockmaster.stockid=bom.component
INNER JOIN locationusers ON locationusers.loccode=bom.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1
WHERE bom.parent >= '" . $_POST['FromCriteria'] . "'
AND bom.parent <= '" . $_POST['ToCriteria'] . "'
AND bom.effectiveto > CURRENT_DATE AND bom.effectiveafter <= CURRENT_DATE
ORDER BY bom.parent,
bom.component";
$ErrMsg = ('The Bill of Material listing could not be retrieved');
$BOMResult = DB_query($SQL, $ErrMsg);
if (DB_num_rows($BOMResult)==0){
$Title = __('Bill of Materials Listing') . ' - ' . __('Problem Report');
include(__DIR__ . '/includes/header.php');
prnMsg( __('The Bill of Material listing has no bills to report on'),'warn');
include(__DIR__ . '/includes/footer.php');
exit();
}
$HTML = '';
if (isset($_POST['PrintPDF'])) {
$HTML .= '<html>
<head>';
$HTML .= '<link href="css/reports.css" rel="stylesheet" type="text/css" />';
}
$HTML .= '<meta name="author" content="WebERP">
<meta name="Creator" content="webERP https://www.weberp.org">
</head>
<body>
<div class="centre" id="ReportHeader">
' . $_SESSION['CompanyRecord']['coyname'] . '<br />
' . __('Bill Of Material Listing for Parts Between') . ' ' . $_POST['FromCriteria'] . ' ' . __('and') . ' ' . $_POST['ToCriteria'] . '<br />
' . __('Printed') . ': ' . date($_SESSION['DefaultDateFormat']) . '<br />
</div>
<table>
<thead>
<tr>
<th>' . __('Component Part') . '</th>
<th>' . __('Description') . '</th>
<th>' . __('Effective After') . '</th>
<th>' . __('Effective To') . '</th>
<th>' . __('Location') . '</th>
<th>' . __('Work') . '<br />' . __('Centre') . '</th>
<th>' . __('Quantity') . '</th>
</tr>
</thead>
<tbody>';
$ParentPart = '';
while ($BOMList = DB_fetch_array($BOMResult)){
if ($ParentPart!= $BOMList['parent']){
$SQL = "SELECT description FROM stockmaster WHERE stockmaster.stockid = '" . $BOMList['parent'] . "'";
$ParentResult = DB_query($SQL);
$ParentRow = DB_fetch_row($ParentResult);
$HTML .= '<tr class="total_row">
<td>' . $BOMList['parent'] . '</td>
<td>' . $ParentRow[0] . '</td>
<td colspan="5"></td>
</tr>';
$ParentPart = $BOMList['parent'];
}
$HTML .= '<tr class="striped_row">
<td>' . $BOMList['component'] . '</td>
<td>' . $BOMList['compdescription'] . '</td>
<td class="date">' . ConvertSQLDate($BOMList['eff_frm']) . '</td>
<td class="date">' . ConvertSQLDate($BOMList['eff_to']) . '</td>
<td>' . $BOMList['loccode'] . '</td>
<td>' . $BOMList['workcentreadded'] . '</td>
<td class="number">' . locale_number_format($BOMList['quantity'],$BOMList['decimalplaces']) . ' ' . $BOMList['units'] . '</td>
</tr>';
} /*end BOM Listing while loop */
if (isset($_POST['PrintPDF'])) {
$HTML .= '</tbody>
<div class="footer fixed-section">
<div class="right">
<span class="page-number">Page </span>
</div>
</div>
</table>';
} else {
$HTML .= '</tbody>
</table>
<div class="centre">
<form><input type="submit" name="close" value="' . __('Close') . '" onclick="window.close()" /></form>
</div>';
}
$HTML .= '</body>
</html>';
if (isset($_POST['PrintPDF'])) {
$DomPDF = new Dompdf($DomPDFOptions); // Pass the options object defined in SetDomPDFOptions.php containing common options
$DomPDF->loadHtml($HTML);
// (Optional) Setup the paper size and orientation
$DomPDF->setPaper($_SESSION['PageSize'], 'landscape');
// Render the HTML as PDF
$DomPDF->render();
// Output the generated PDF to Browser
$DomPDF->stream($_SESSION['DatabaseName'] . '_BOMListing_' . date('Y-m-d') . '.pdf', array(
"Attachment" => false
));
} else {
$Title = __('Bill Of Material Listing');
include(__DIR__ . '/includes/header.php');
echo '<p class="page_title_text"><img src="' . $RootPath . '/css/' . $Theme . '/images/maintenance.png" title="' . $Title . '" alt="" />' . ' ' . $Title . '</p>';
echo $HTML;
include(__DIR__ . '/includes/footer.php');
}
} else { /*The option to print PDF was not hit */
$Title=__('Bill Of Material Listing');
$ViewTopic = 'Manufacturing';
$BookMark = '';
include(__DIR__ . '/includes/header.php');
echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/reports.png" title="' . __('Search') .
'" alt="" />' . ' ' . $Title . '</p>';
if (!isset($_POST['FromCriteria']) || !isset($_POST['ToCriteria'])) {
/*if $FromCriteria is not set then show a form to allow input */
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post" target="_blank">
<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />
<fieldset>
<legend>', __('Report Criteria'), '</legend>';
echo '<field>
<label for="FromCriteria">' . __('From Inventory Part Code') . ':' . '</label>
<input tabindex="1" type="text" autofocus="autofocus" required="required" data-type="no-illegal-chars" title="" name="FromCriteria" size="20" maxlength="20" value="1" />
<fieldhelp>' . __('Enter the lowest alpha code of parent bom items to list the bill of material for') . '</fieldhelp>
</field>';
echo '<field>
<label for="ToCriteria">' . __('To Inventory Part Code') . ':' . '</label>
<input tabindex="2" type="text" required="required" data-type="no-illegal-chars" title="" name="ToCriteria" size="20" maxlength="20" value="zzzzzzz" />
<fieldhelp>' . __('Enter the end alpha numeric code of any parent bom items to list the bill of material for') . '</fieldhelp>
</field>';
echo '</fieldset>
<div class="centre">
<input type="submit" name="PrintPDF" title="Produce PDF Report" value="' . __('Print PDF') . '" />
<input type="submit" name="View" title="View Report" value="' . __('View') . '" />
</div>
</form>';
}
include(__DIR__ . '/includes/footer.php');
} /*end of else not PrintPDF */