1<?php 2 3/* Session started in session.php for password checking and authorisation level check 4config.php is in turn included in session.php*/ 5include ('includes/session.php'); 6$Title = _('Raw Materials Not Used Anywhere'); 7include ('includes/header.php'); 8 9$SQL = "SELECT stockmaster.stockid, 10 stockmaster.description, 11 stockmaster.decimalplaces, 12 (stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost) AS stdcost, 13 (SELECT SUM(quantity) 14 FROM locstock 15 WHERE locstock.stockid = stockmaster.stockid) AS qoh 16 FROM stockmaster, 17 stockcategory 18 WHERE stockmaster.categoryid = stockcategory.categoryid 19 AND stockcategory.stocktype = 'M' 20 AND stockmaster.discontinued = 0 21 AND NOT EXISTS( 22 SELECT * 23 FROM bom 24 WHERE bom.component = stockmaster.stockid ) 25 ORDER BY stockmaster.stockid"; 26$result = DB_query($SQL); 27if (DB_num_rows($result) != 0){ 28 $TotalValue = 0; 29 echo '<p class="page_title_text"><strong>' . _('Raw Materials Not Used in any BOM') . '</strong></p>'; 30 echo '<div>'; 31 echo '<table class="selection">'; 32 $TableHeader = '<tr> 33 <th>' . _('#') . '</th> 34 <th>' . _('Code') . '</th> 35 <th>' . _('Description') . '</th> 36 <th>' . _('QOH') . '</th> 37 <th>' . _('Std Cost') . '</th> 38 <th>' . _('Value') . '</th> 39 </tr>'; 40 echo $TableHeader; 41 $i = 1; 42 43 while ($myrow = DB_fetch_array($result)) { 44 $CodeLink = '<a href="' . $RootPath . '/SelectProduct.php?StockID=' . $myrow['stockid'] . '">' . $myrow['stockid'] . '</a>'; 45 $LineValue = $myrow['qoh'] * $myrow['stdcost']; 46 $TotalValue = $TotalValue + $LineValue; 47 48 printf('<tr class="striped_row"> 49 <td class="number">%s</td> 50 <td>%s</td> 51 <td>%s</td> 52 <td class="number">%s</td> 53 <td class="number">%s</td> 54 <td class="number">%s</td> 55 </tr>', 56 $i, 57 $CodeLink, 58 $myrow['description'], 59 locale_number_format($myrow['qoh'],$myrow['decimalplaces']), 60 locale_number_format($myrow['stdcost'],$_SESSION['CompanyRecord']['decimalplaces']), 61 locale_number_format($LineValue,$_SESSION['CompanyRecord']['decimalplaces']) 62 ); 63 $i++; 64 } 65 66 printf('<tr> 67 <td colspan="4">%s</td> 68 <td>%s</td> 69 <td class="number">%s</td> 70 </tr>', 71 '', 72 _('Total').':', 73 locale_number_format($TotalValue,$_SESSION['CompanyRecord']['decimalplaces'])); 74 75 echo '</table> 76 </div> 77 </form>'; 78} 79 80include ('includes/footer.php'); 81?>