-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBOMListing.php
144 lines (115 loc) · 5.88 KB
/
BOMListing.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
<?php
include('includes/session.php');
If (isset($_POST['PrintPDF'])
AND isset($_POST['FromCriteria'])
AND mb_strlen($_POST['FromCriteria'])>=1
AND isset($_POST['ToCriteria'])
AND mb_strlen($_POST['ToCriteria'])>=1){
include('includes/PDFStarter.php');
$pdf->addInfo('Title',_('Bill Of Material Listing'));
$pdf->addInfo('Subject',_('Bill Of Material Listing'));
$FontSize=12;
$PageNumber=0;
$line_height=12;
/*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 > '" . date('Y-m-d') . "' AND bom.effectiveafter <= '" . date('Y-m-d') . "'
ORDER BY bom.parent,
bom.component";
$BOMResult = DB_query($SQL,'','',false,false); //dont do error trapping inside DB_query
if (DB_error_no() !=0) {
$Title = _('Bill of Materials Listing') . ' - ' . _('Problem Report');
include('includes/header.php');
echo prnMsg(_('The Bill of Material listing could not be retrieved by nERP because'),'error');
echo '<br /><p align="right"><a href="' . $RootPath . '/menu_data.php?Application=manuf" class="btn btn-default">' . _('<i class="fa fa-hand-o-left fa-fw"></i> Menu') . '</a></p>';
if ($debug==1){
echo '<br />' . $SQL;
}
include('includes/footer.php');
exit;
}
if (DB_num_rows($BOMResult)==0){
$Title = _('Bill of Materials Listing') . ' - ' . _('Problem Report');
include('includes/header.php');
echo prnMsg( _('The Bill of Material listing has no data to report on'),'warn');
include('includes/footer.php');
exit;
}
include ('includes/PDFBOMListingPageHeader.inc');
$ParentPart = '';
while ($BOMList = DB_fetch_array($BOMResult)){
if ($ParentPart!=$BOMList['parent']){
$FontSize=10;
if ($ParentPart!=''){ /*Then it's NOT the first time round */
/* need to rule off from the previous parent listed */
$YPos -=$line_height;
$pdf->line($Page_Width-$Right_Margin, $YPos,$Left_Margin, $YPos);
$YPos -=$line_height;
}
$SQL = "SELECT description FROM stockmaster WHERE stockmaster.stockid = '" . $BOMList['parent'] . "'";
$ParentResult = DB_query($SQL);
$ParentRow = DB_fetch_row($ParentResult);
$LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,400-$Left_Margin,$FontSize,$BOMList['parent'] . ' - ' . $ParentRow[0],'left');
$ParentPart = $BOMList['parent'];
}
$YPos -=$line_height;
$FontSize=8;
$LeftOvers = $pdf->addTextWrap($Left_Margin+5,$YPos,80,$FontSize,$BOMList['component'],'left');
$LeftOvers = $pdf->addTextWrap(110,$YPos,200,$FontSize,$BOMList['compdescription'],'left');
$DisplayQuantity = locale_number_format($BOMList['quantity'],$BOMList['decimalplaces']);
$LeftOvers = $pdf->addTextWrap(320,$YPos,50,$FontSize,ConvertSQLDate($BOMList['eff_frm']),'left');
$LeftOvers = $pdf->addTextWrap(375,$YPos,50,$FontSize,ConvertSQLDate($BOMList['eff_to']),'left');
$LeftOvers = $pdf->addTextWrap(430,$YPos,30,$FontSize,$BOMList['loccode'],'left');
$LeftOvers = $pdf->addTextWrap(465,$YPos,30,$FontSize,$BOMList['workcentreadded'],'left');
$LeftOvers = $pdf->addTextWrap(480,$YPos,60,$FontSize,$DisplayQuantity,'right');
$LeftOvers = $pdf->addTextWrap(540,$YPos,20,$FontSize,$BOMList['units'],'left');
if ($YPos < $Bottom_Margin + $line_height){
include('includes/PDFBOMListingPageHeader.inc');
}
} /*end BOM Listing while loop */
$YPos -=$line_height;
$pdf->line($Page_Width-$Right_Margin, $YPos,$Left_Margin, $YPos);
$pdf->OutputD($_SESSION['DatabaseName'] . '_BOMListing_' . date('Y-m-d').'.pdf');
$pdf->__destruct();
} else { /*The option to print PDF was not hit */
$Title=_('Bill Of Material Listing');
include('includes/header.php');
echo '<div class="block-header"><a href="" class="header-title-link"><h1>' . ' ' . $Title . '</h1></a></div>';
if (!isset($_POST['FromCriteria']) || !isset($_POST['ToCriteria'])) {
/*if $FromCriteria is not set then show a form to allow input */
echo '<div class="row gutter30">
<div class="col-xs-12">';
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">
<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />
';
echo '<div class="row">
<div class="col-xs-4">
<div class="form-group has-error"> <label class="col-md-8 control-label">' . _('From Stock ID') . '' . '</label>
<input tabindex="1" class="form-control" type="text" autofocus="autofocus" required="required" data-type="no-illegal-chars" title="' . _('Enter the lowest alpha code of parent bom items to list the bill of material for') . '" name="FromCriteria" size="20" maxlength="20" value="1" /></div>
</div>';
echo '<div class="col-xs-4">
<div class="form-group has-error"> <label class="col-md-8 control-label">' . _('To Stock ID') . '' . '</label>
<input tabindex="2" class="form-control" type="text" required="required" data-type="no-illegal-chars" title="' . _('Enter the end alpha numeric code of any parent bom items to list the bill of material for') . '" name="ToCriteria" size="20" maxlength="20" value="zzzzzzz" /></div>
</div>';
echo '<div class="col-xs-4">
<div class="form-group"> <br /><input tabindex="3" type="submit" class="btn btn-warning" name="PrintPDF" value="' . _('Print PDF') . '" /></div>
</div> </div>
</form> </div> </div>';
}
include('includes/footer.php');
} /*end of else not PrintPDF */
?>