forked from timschofield/webERP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrintWOItemSlip.php
207 lines (167 loc) · 8.8 KB
/
PrintWOItemSlip.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
<?php
include ('includes/session.php');
if (isset($_GET['WO'])) {
$WO = filter_number_format($_GET['WO']);
} elseif (isset($_POST['WO'])) {
$WO = filter_number_format($_POST['WO']);
} else {
$WO = '';
}
if (isset($_GET['StockId'])) {
$StockId = $_GET['StockId'];
} elseif (isset($_POST['StockId'])) {
$StockId = $_POST['StockId'];
}
if (isset($_GET['Location'])) {
$Location = $_GET['Location'];
} elseif (isset($_POST['Location'])) {
$Location = $_POST['Location'];
}
if (isset($WO) and isset($StockId) and $WO != '') {
$SQL = "SELECT woitems.qtyreqd,
woitems.qtyrecd,
stockmaster.description,
stockmaster.decimalplaces,
stockmaster.units
FROM woitems, stockmaster
WHERE stockmaster.stockid = woitems.stockid
AND woitems.wo = '" . $WO . "'
AND woitems.stockid = '" . $StockId . "' ";
$ErrMsg = _('The SQL to find the details of the item to produce failed');
$ResultItems = DB_query($SQL, $ErrMsg);
if (DB_num_rows($ResultItems) != 0) {
include ('includes/PDFStarter.php');
$pdf->addInfo('Title', _('WO Production Slip'));
$pdf->addInfo('Subject', _('WO Production Slip'));
while ($MyItem = DB_fetch_array($ResultItems)) {
// print the info of the parent product
$FontSize = 10;
$PageNumber = 1;
$LineHeight = 12;
$Xpos = $Left_Margin + 1;
$Fill = false;
$QtyPending = $MyItem['qtyreqd'] - $MyItem['qtyrecd'];
PrintHeader($pdf, $YPos, $PageNumber, $Page_Height, $Top_Margin, $Left_Margin, $Page_Width, $Right_Margin, $WO, $StockId, $MyItem['description'], $QtyPending, $MyItem['units'], $MyItem['decimalplaces'], $ReportDate);
$PartCounter = 0;
$SQLBOM = "SELECT bom.parent,
bom.component,
bom.quantity AS bomqty,
stockmaster.decimalplaces,
stockmaster.units,
stockmaster.description,
stockmaster.shrinkfactor,
locstock.quantity AS qoh
FROM bom, stockmaster, locstock
WHERE bom.component = stockmaster.stockid
AND bom.component = locstock.stockid
AND locstock.loccode = '" . $Location . "'
AND bom.parent = '" . $StockId . "'
AND bom.effectiveafter <= '" . date('Y-m-d') . "'
AND bom.effectiveto > '" . date('Y-m-d') . "'";
$ErrMsg = _('The bill of material could not be retrieved because');
$BOMResult = DB_query($SQLBOM, $ErrMsg);
while ($MyComponent = DB_fetch_array($BOMResult)) {
$ComponentNeeded = $MyComponent['bomqty'] * $QtyPending;
$PrevisionShrinkage = $ComponentNeeded * ($MyComponent['shrinkfactor'] / 100);
$Xpos = $Left_Margin + 1;
$pdf->addTextWrap($Xpos, $YPos, 150, $FontSize, $MyComponent['component'], 'left');
$pdf->addTextWrap(150, $YPos, 50, $FontSize, locale_number_format($MyComponent['bomqty'], 'Variable'), 'right');
$pdf->addTextWrap(200, $YPos, 30, $FontSize, $MyComponent['units'], 'left');
$pdf->addTextWrap(230, $YPos, 50, $FontSize, locale_number_format($ComponentNeeded, $MyComponent['decimalplaces']), 'right');
$pdf->addTextWrap(280, $YPos, 30, $FontSize, $MyComponent['units'], 'left');
$pdf->addTextWrap(310, $YPos, 50, $FontSize, locale_number_format($PrevisionShrinkage, $MyComponent['decimalplaces']), 'right');
$pdf->addTextWrap(360, $YPos, 30, $FontSize, $MyComponent['units'], 'left');
$YPos-= $LineHeight;
if ($YPos < $Bottom_Margin + $LineHeight) {
PrintHeader($pdf, $YPos, $PageNumber, $Page_Height, $Top_Margin, $Left_Margin, $Page_Width, $Right_Margin, $WO, $Stockid, $MyItem['description'], $QtyPending, $MyItem['units'], $MyItem['decimalplaces'], $ReportDate);
}
}
}
// Production Notes
$pdf->addTextWrap($Xpos, $YPos - 50, 200, $FontSize, _('Incidences / Production Notes') . ':', 'left');
$YPos-= (8 * $LineHeight);
PrintFooterSlip($pdf, _('Components Ready By'), _('Item Produced By'), _('Quality Control By'), $YPos, $FontSize, false);
if ($YPos < $Bottom_Margin + $LineHeight) {
PrintHeader($pdf, $YPos, $PageNumber, $Page_Height, $Top_Margin, $Left_Margin, $Page_Width, $Right_Margin, $WO, $Stockid, $MyItem['description'], $QtyPending, $MyItem['units'], $MyItem['decimalplaces'], $ReportDate);
}
$pdf->OutputD('WO-' . $WO . '-' . $StockId . '-' . Date('Y-m-d') . '.pdf');
$pdf->__destruct();
} else {
$Title = _('WO Item production Slip');
include ('includes/header.php');
prnMsg(_('There were no items with ready to produce'), 'info');
prnMsg($SQL);
echo '<br /><a href="' . $RootPath . '/index.php">' . _('Back to the menu') . '</a>';
include ('includes/footer.php');
exit;
}
}
function PrintHeader(&$pdf, &$YPos, &$PageNumber, $Page_Height, $Top_Margin, $Left_Margin, $Page_Width, $Right_Margin, $WO, $StockId, $Description, $Qty, $UOM, $DecimalPlaces, $ReportDate) {
if ($PageNumber > 1) {
$pdf->newPage();
}
$LineHeight = 12;
$FontSize = 10;
$YPos = $Page_Height - $Top_Margin;
$pdf->addTextWrap($Left_Margin, $YPos, 300, $FontSize, $_SESSION['CompanyRecord']['coyname']);
$pdf->addTextWrap(190, $YPos, 100, $FontSize, $ReportDate);
$pdf->addTextWrap($Page_Width - $Right_Margin - 150, $YPos, 160, $FontSize, _('Printed') . ': ' . Date($_SESSION['DefaultDateFormat']) . ' ' . _('Page') . ' ' . $PageNumber, 'left');
$YPos-= $LineHeight;
$pdf->addTextWrap($Left_Margin, $YPos, 150, $FontSize, _('Work Order Item Production Slip'));
$YPos-= (2 * $LineHeight);
$pdf->addTextWrap($Left_Margin, $YPos, 150, $FontSize, _('WO') . ': ' . $WO);
$YPos-= $LineHeight;
$pdf->addTextWrap($Left_Margin, $YPos, 500, $FontSize, _('Item Code') . ': ' . $StockId . ' --> ' . $Description);
$YPos-= $LineHeight;
$pdf->addTextWrap($Left_Margin, $YPos, 150, $FontSize, _('Quantity') . ': ' . locale_number_format($Qty, $DecimalPlaces) . ' ' . $UOM);
$YPos-= (2 * $LineHeight);
if (file_exists($_SESSION['part_pics_dir'] . '/' . $StockId . '.jpg')) {
$pdf->Image($_SESSION['part_pics_dir'] . '/' . $StockId . '.jpg', 135, $Page_Height - $Top_Margin - $YPos + 10, 200, 200);
$YPos-= (16 * $LineHeight);
} /*end checked file exist*/
/*set up the headings */
$Xpos = $Left_Margin + 1;
$pdf->addTextWrap($Xpos, $YPos, 150, $FontSize, _('Component Code'), 'left');
$pdf->addTextWrap(150, $YPos, 50, $FontSize, _('Qty BOM'), 'right');
$pdf->addTextWrap(200, $YPos, 30, $FontSize, '', 'left');
$pdf->addTextWrap(230, $YPos, 50, $FontSize, _('Qty Needed'), 'right');
$pdf->addTextWrap(280, $YPos, 30, $FontSize, '', 'left');
$pdf->addTextWrap(310, $YPos, 50, $FontSize, _('Shrinkage'), 'right');
$pdf->addTextWrap(360, $YPos, 30, $FontSize, '', 'left');
$FontSize = 10;
$YPos-= $LineHeight;
$PageNumber++;
}
function PrintFooterSlip($pdf, $Column1, $Column2, $Column3, $YPos, $FontSize, $Fill) {
//add column 1
$pdf->addTextWrap(40, $YPos - 50, 100, $FontSize, $Column1 . ':', 'left');
$pdf->addTextWrap(40, $YPos - 70, 100, $FontSize, _('Name'), 'left');
$pdf->addTextWrap(80, $YPos - 70, 200, $FontSize, ':__________________', 'left', 0, $Fill);
$pdf->addTextWrap(40, $YPos - 90, 100, $FontSize, _('Date'), 'left');
$pdf->addTextWrap(80, $YPos - 90, 200, $FontSize, ':__________________', 'left', 0, $Fill);
$pdf->addTextWrap(40, $YPos - 110, 100, $FontSize, _('Hour'), 'left');
$pdf->addTextWrap(80, $YPos - 110, 200, $FontSize, ':__________________', 'left', 0, $Fill);
$pdf->addTextWrap(40, $YPos - 150, 100, $FontSize, _('Signature'), 'left');
$pdf->addTextWrap(80, $YPos - 150, 200, $FontSize, ':__________________', 'left', 0, $Fill);
//add column 2
$pdf->addTextWrap(220, $YPos - 50, 100, $FontSize, $Column2 . ':', 'left');
$pdf->addTextWrap(220, $YPos - 70, 100, $FontSize, _('Name'), 'left');
$pdf->addTextWrap(260, $YPos - 70, 200, $FontSize, ':__________________', 'left', 0, $Fill);
$pdf->addTextWrap(220, $YPos - 90, 100, $FontSize, _('Date'), 'left');
$pdf->addTextWrap(260, $YPos - 90, 200, $FontSize, ':__________________', 'left', 0, $Fill);
$pdf->addTextWrap(220, $YPos - 110, 100, $FontSize, _('Hour'), 'left');
$pdf->addTextWrap(260, $YPos - 110, 200, $FontSize, ':__________________', 'left', 0, $Fill);
$pdf->addTextWrap(220, $YPos - 150, 100, $FontSize, _('Signature'), 'left');
$pdf->addTextWrap(260, $YPos - 150, 200, $FontSize, ':__________________', 'left', 0, $Fill);
//add column 3
$pdf->addTextWrap(400, $YPos - 50, 100, $FontSize, $Column3 . ':', 'left');
$pdf->addTextWrap(400, $YPos - 70, 100, $FontSize, _('Name'), 'left');
$pdf->addTextWrap(440, $YPos - 70, 200, $FontSize, ':__________________', 'left', 0, $Fill);
$pdf->addTextWrap(400, $YPos - 90, 100, $FontSize, _('Date'), 'left');
$pdf->addTextWrap(440, $YPos - 90, 200, $FontSize, ':__________________', 'left', 0, $Fill);
$pdf->addTextWrap(400, $YPos - 110, 100, $FontSize, _('Hour'), 'left');
$pdf->addTextWrap(440, $YPos - 110, 200, $FontSize, ':__________________', 'left', 0, $Fill);
$pdf->addTextWrap(400, $YPos - 150, 100, $FontSize, _('Signature'), 'left');
$pdf->addTextWrap(440, $YPos - 150, 200, $FontSize, ':__________________', 'left', 0, $Fill);
}
?>