4 include('includes/session.inc');
7 If (isset($_POST['PrintPDF'])
8 AND isset($_POST['FromCriteria'])
9 AND strlen($_POST['FromCriteria'])>=1
10 AND isset($_POST['ToCriteria'])
11 AND strlen($_POST['ToCriteria'])>=1){
13 include('includes/PDFStarter.php');
16 $pdf->addinfo('Title',_('Bill Of Material Listing'));
17 $pdf->addinfo('Subject',_('Bill Of Material Listing'));
22 /*Now figure out the bills to report for the part range under review */
23 $SQL = "SELECT bom.parent,
25 stockmaster.description as compdescription,
26 stockmaster.decimalplaces,
30 bom.effectiveto AS eff_to,
31 bom.effectiveafter AS eff_frm
35 WHERE stockmaster.stockid=bom.component
36 AND bom.parent >= '" . $_POST['FromCriteria'] . "'
37 AND bom.parent <= '" . $_POST['ToCriteria'] . "'
38 AND bom.effectiveto >= NOW() AND bom.effectiveafter <= NOW()
43 $BOMResult = DB_query($SQL,$db,'','',false,false); //dont do error trapping inside DB_query
45 if (DB_error_no($db) !=0) {
46 $title = _('Bill of Materials Listing') . ' - ' . _('Problem Report');
47 include('includes/header.inc');
48 prnMsg(_('The Bill of Material listing could not be retrieved by the SQL because'),'error');
49 echo "<BR><A HREF='" .$rootpath ."/index.php?" . SID
. "'>" . _('Back to the menu') . '</A>';
53 include('includes/footer.inc');
56 if (DB_num_rows($BOMResult)==0){
57 $title = _('Bill of Materials Listing') . ' - ' . _('Problem Report');
58 include('includes/header.inc');
59 prnMsg( _('The Bill of Material listing has no bills to report on'),'warn');
60 include('includes/footer.inc');
64 include ('includes/PDFBOMListingPageHeader.inc');
68 While ($BOMList = DB_fetch_array($BOMResult,$db)){
70 if ($ParentPart!=$BOMList['parent']){
73 if ($ParentPart!=''){ /*Then it's NOT the first time round */
74 /* need to rule off from the previous parent listed */
76 $pdf->line($Page_Width-$Right_Margin, $YPos,$Left_Margin, $YPos);
79 $SQL = "SELECT description FROM stockmaster WHERE stockmaster.stockid = '" . $BOMList['parent'] . "'";
80 $ParentResult = DB_query($SQL,$db);
81 $ParentRow = DB_fetch_row($ParentResult);
82 $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,400-$Left_Margin,$FontSize,$BOMList['parent'] . ' - ' . $ParentRow[0],'left');
83 $ParentPart = $BOMList['parent'];
88 $LeftOvers = $pdf->addTextWrap($Left_Margin+
5,$YPos,80,$FontSize,$BOMList['component'],'left');
89 $LeftOvers = $pdf->addTextWrap(110,$YPos,200,$FontSize,$BOMList['compdescription'],'left');
91 $DisplayQuantity = number_format($BOMList['quantity'],$BOMList['decimalplaces']);
92 $LeftOvers = $pdf->addTextWrap(320,$YPos,50,$FontSize,ConvertSQLDate($BOMList['eff_frm']),'left');
93 $LeftOvers = $pdf->addTextWrap(370,$YPos,50,$FontSize,ConvertSQLDate($BOMList['eff_to']),'left');
94 $LeftOvers = $pdf->addTextWrap(420,$YPos,20,$FontSize,$BOMList['loccode'],'left');
95 $LeftOvers = $pdf->addTextWrap(440,$YPos,30,$FontSize,$BOMList['workcentreadded'],'left');
96 $LeftOvers = $pdf->addTextWrap(480,$YPos,60,$FontSize,$DisplayQuantity,'right');
98 if ($YPos < $Bottom_Margin +
$line_height){
99 include('includes/PDFBOMListingPageHeader.inc');
102 } /*end BOM Listing while loop */
104 $YPos -=$line_height;
105 $pdf->line($Page_Width-$Right_Margin, $YPos,$Left_Margin, $YPos);
107 $buf = $pdf->output();
110 header('Content-type: application/pdf');
111 header("Content-Length: $len");
112 header('Content-Disposition: inline; filename=BOMListing.pdf');
113 header('Expires: 0');
114 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
115 header('Pragma: public');
120 } else { /*The option to print PDF was not hit */
122 $title=_('Bill Of Material Listing');
123 include('includes/header.inc');
125 if (strlen($_POST['FromCriteria'])<1 ||
strlen($_POST['ToCriteria'])<1) {
127 /*if $FromCriteria is not set then show a form to allow input */
129 echo '<FORM ACTION=' . $_SERVER['PHP_SELF'] . " METHOD='POST'><CENTER><TABLE>";
131 echo '<TR><TD>' . _('From Inventory Part Code') . ':' . "</FONT></TD><TD><INPUT TYPE=text name=FromCriteria SIZE=20 MAXLENGTH=20 VALUE='1'></TD></TR>";
133 echo '<TR><TD>' . _('To Inventory Part Code') . ':' . "</TD><TD><INPUT TYPE=text name=ToCriteria SIZE=20 MAXLENGTH=20 VALUE='zzzzzzz'></TD></TR>";
136 echo "</TABLE><INPUT TYPE=Submit Name='PrintPDF' Value='" . _('Print PDF') . "'></CENTER>";
138 include('includes/footer.inc');;
140 } /*end of else not PrintPDF */