1<?php 2 3 4include('includes/session.php'); 5 6If (isset($_POST['PrintPDF']) 7 AND isset($_POST['FromCriteria']) 8 AND mb_strlen($_POST['FromCriteria'])>=1 9 AND isset($_POST['ToCriteria']) 10 AND mb_strlen($_POST['ToCriteria'])>=1){ 11 12 include('includes/PDFStarter.php'); 13 $pdf->addInfo('Title',_('Bill Of Material Listing')); 14 $pdf->addInfo('Subject',_('Bill Of Material Listing')); 15 $FontSize=12; 16 $PageNumber=0; 17 $line_height=12; 18 19 /*Now figure out the bills to report for the part range under review */ 20 $SQL = "SELECT bom.parent, 21 bom.component, 22 stockmaster.description as compdescription, 23 stockmaster.decimalplaces, 24 stockmaster.units, 25 bom.quantity, 26 bom.loccode, 27 bom.workcentreadded, 28 bom.effectiveto AS eff_to, 29 bom.effectiveafter AS eff_frm 30 FROM stockmaster INNER JOIN bom 31 ON stockmaster.stockid=bom.component 32 INNER JOIN locationusers ON locationusers.loccode=bom.loccode AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canview=1 33 WHERE bom.parent >= '" . $_POST['FromCriteria'] . "' 34 AND bom.parent <= '" . $_POST['ToCriteria'] . "' 35 AND bom.effectiveto > '" . date('Y-m-d') . "' AND bom.effectiveafter <= '" . date('Y-m-d') . "' 36 ORDER BY bom.parent, 37 bom.component"; 38 39 $BOMResult = DB_query($SQL,'','',false,false); //dont do error trapping inside DB_query 40 41 if (DB_error_no() !=0) { 42 $Title = _('Bill of Materials Listing') . ' - ' . _('Problem Report'); 43 include('includes/header.php'); 44 prnMsg(_('The Bill of Material listing could not be retrieved by the SQL because'),'error'); 45 echo '<br /><a href="' .$RootPath .'/index.php">' . _('Back to the menu') . '</a>'; 46 if ($debug==1){ 47 echo '<br />' . $SQL; 48 } 49 include('includes/footer.php'); 50 exit; 51 } 52 if (DB_num_rows($BOMResult)==0){ 53 $Title = _('Bill of Materials Listing') . ' - ' . _('Problem Report'); 54 include('includes/header.php'); 55 prnMsg( _('The Bill of Material listing has no bills to report on'),'warn'); 56 include('includes/footer.php'); 57 exit; 58 } 59 60 include ('includes/PDFBOMListingPageHeader.inc'); 61 62 $ParentPart = ''; 63 64 while ($BOMList = DB_fetch_array($BOMResult)){ 65 66 if ($ParentPart!=$BOMList['parent']){ 67 68 $FontSize=10; 69 if ($ParentPart!=''){ /*Then it's NOT the first time round */ 70 /* need to rule off from the previous parent listed */ 71 $YPos -=$line_height; 72 $pdf->line($Page_Width-$Right_Margin, $YPos,$Left_Margin, $YPos); 73 $YPos -=$line_height; 74 } 75 $SQL = "SELECT description FROM stockmaster WHERE stockmaster.stockid = '" . $BOMList['parent'] . "'"; 76 $ParentResult = DB_query($SQL); 77 $ParentRow = DB_fetch_row($ParentResult); 78 $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,400-$Left_Margin,$FontSize,$BOMList['parent'] . ' - ' . $ParentRow[0],'left'); 79 $ParentPart = $BOMList['parent']; 80 } 81 82 $YPos -=$line_height; 83 $FontSize=8; 84 $LeftOvers = $pdf->addTextWrap($Left_Margin+5,$YPos,80,$FontSize,$BOMList['component'],'left'); 85 $LeftOvers = $pdf->addTextWrap(110,$YPos,200,$FontSize,$BOMList['compdescription'],'left'); 86 87 $DisplayQuantity = locale_number_format($BOMList['quantity'],$BOMList['decimalplaces']); 88 $LeftOvers = $pdf->addTextWrap(320,$YPos,50,$FontSize,ConvertSQLDate($BOMList['eff_frm']),'left'); 89 $LeftOvers = $pdf->addTextWrap(375,$YPos,50,$FontSize,ConvertSQLDate($BOMList['eff_to']),'left'); 90 $LeftOvers = $pdf->addTextWrap(430,$YPos,30,$FontSize,$BOMList['loccode'],'left'); 91 $LeftOvers = $pdf->addTextWrap(465,$YPos,30,$FontSize,$BOMList['workcentreadded'],'left'); 92 $LeftOvers = $pdf->addTextWrap(480,$YPos,60,$FontSize,$DisplayQuantity,'right'); 93 $LeftOvers = $pdf->addTextWrap(540,$YPos,20,$FontSize,$BOMList['units'],'left'); 94 95 if ($YPos < $Bottom_Margin + $line_height){ 96 include('includes/PDFBOMListingPageHeader.inc'); 97 } 98 99 } /*end BOM Listing while loop */ 100 101 $YPos -=$line_height; 102 $pdf->line($Page_Width-$Right_Margin, $YPos,$Left_Margin, $YPos); 103 104 $pdf->OutputD($_SESSION['DatabaseName'] . '_BOMListing_' . date('Y-m-d').'.pdf'); 105 $pdf->__destruct(); 106 107} else { /*The option to print PDF was not hit */ 108 109 $Title=_('Bill Of Material Listing'); 110 include('includes/header.php'); 111 echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/reports.png" title="' . _('Search') . 112 '" alt="" />' . ' ' . $Title . '</p><br />'; 113 if (!isset($_POST['FromCriteria']) || !isset($_POST['ToCriteria'])) { 114 115 /*if $FromCriteria is not set then show a form to allow input */ 116 117 echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post"> 118 <div> 119 <input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" /> 120 <table class="selection">'; 121 122 echo '<tr><td>' . _('From Inventory Part Code') . ':' . '</td> 123 <td><input tabindex="1" 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" /></td> 124 </tr>'; 125 126 echo '<tr><td>' . _('To Inventory Part Code') . ':' . '</td> 127 <td><input tabindex="2" 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" /></td> 128 </tr>'; 129 130 131 echo '</table> 132 <br /><div class="centre"><input tabindex="3" type="submit" name="PrintPDF" value="' . _('Print PDF') . '" /></div> 133 </div> 134 </form>'; 135 } 136 include('includes/footer.php'); 137 138} /*end of else not PrintPDF */ 139 140?> 141