<?php error_reporting(0);  
   session_name('CAKEPHP'); session_start();
	$PageSecurity = 3;
	include ('includes/session.inc');
	include ('includes/function_lib.php');
	include('includes/fun-php.php');
	include('includes/fun-HRClass.php');

 	global $db; 
?>


<link rel="stylesheet" href="css/new_mxerp.css">




      <?php  
//$mpdf=new mPDF();
//$mpdf->Bookmark('Start of the document');
$Compamies=DB_query("select * from companies",$db);
$CompamiesRow=DB_fetch_array($Compamies);

?>
<link rel="stylesheet" href="css/new_mxerp.css">
 <p align="center"><input type="button" onclick="javascript:toggle_visibility('foo');" value="Print" id="foo" /></p>
<div style="width:100%; color:#006699; font-size:16px; font-weight:900; padding:10px; text-align:center;"><?php echo $CompamiesRow['CompanyName']?> <br />
 BOM  Details</div>  
  

<h3>Bill Of Material</h3>
<?php 

$sql=DB_query("select * from bill_material where id='".$_REQUEST['Id']."'",$db);
$row=DB_fetch_array($sql);
extract($row);
  $unitid=$s->GetFieldValue('item_master',"id='".$part_id."'",'unit');  
 $unitname= $s->GetFieldValue('unitsofmeasure',"unitid='".$unitid."'",'unitname');	
$locationbom=$s->GetFieldValue('bom_location',"id='".$Bom_location."'",'bom_location');	
$bomtype=$s->GetFieldValue('bom_type',"id='".$Bom_type."'",'bom_type');
?>



<table width="100%" border="1" cellspacing="0" cellpadding="0">
   <tr>
    <td style="width:250px;" class="tabledata">Branch</td>
    <td colspan="5"><?php echo $s->getField('locations','loccode',$brach_code,'locationname');?></td>
  </tr>
  <tr class="row1">
    <td class="tabledata">BOM No.</td>
    <td id="hotfoil" style="padding-right:5px;"><?php echo $Bom_no;  ?></td>
    <td class="tabledata">Type Of BOM</td>
    <td style="padding-right:5px;"><?php echo $bomtype;  ?></td>
    <td class="tabledata">Description</td>
    <td><?php echo $description;  ?></td>
  </tr>
  <tr class="row1">
    <td class="tabledata">Location Of BOM</td>
    <td><?php echo $locationbom;  ?></td>
    <td class="tabledata">Revision No.</td>
    <td><?php echo $revision_no;  ?></td>
    <td class="tabledata">Revision Date</td>
    <td><?php echo ConvertSQLDate($revision_date);  ?></td>
  </tr>
  <tr class="row1">
    <td class="tabledata">Prepared Date</td>
    <td><?php echo ConvertSQLDate($prepared_date);  ?></td>
    <td class="tabledata">Prepared By</td>
    <td><?php echo $prepared_by;  ?></td>
    <td class="tabledata1">Approved By</td>
    <td><?php echo $approved_by;  ?></td>
  </tr>
  <tr class="row1">
    <td colspan="6" ><h3 ><strong>Finished Product Details</strong></h3></td>
    </tr>
  <tr class="row1">
    <td colspan="6" class="tabledata">
		<table width="100%%" border="0" cellspacing="0" cellpadding="0">
  	  <tr>
	   <th >Product Code</th>
	    <td><?php echo $part_code; ?></td>
	    <th >Product Name</th>
    <td><?php echo $product_name; ?></td>
    <th>Category</th>
    <td><?php  echo $subcatname=$s->GetFieldValue('stockcategory',"id='".$subcatid."'",'categorydescription') ?></td>
    <th>UOM</th>
    <td><?php echo $unitname ?></td>
	  </tr>
</table>
</td>
    </tr>
</table>

<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
<tr>
<td class="tabledata" colspan="9"><h3 style="color:#000000; font-size:16px;"><strong>BOM - Raw Material And Assembly Item Details</strong></h3></td></tr>
  <tr>
  	<td class="tabledata">Sr</td>
    <td class="tabledata">Production Process</td>
    <td class="tabledata">Part Code</td>
    <td class="tabledata">Description</td>
    <td class="tabledata">UOM</td>
    <td class="tabledata">Qty</td>
   
  </tr>
  <?php 
  $i=1;
  $bill=DB_query("select * from bill_raw_material where bill_material_id='".$id."'",$db);
  while($billrow=DB_fetch_array($bill))
  {
   $itemcode=$s->GetFieldValue('item_master',"id='".$billrow['mst_itemid']."'",'StockID');
   $itemname=$s->GetFieldValue('item_master',"id='".$billrow['mst_itemid']."'",'item_name');
   $unit= $s->GetFieldValue('unitsofmeasure',"unitid='".$billrow['mst_itemid']."'",'unitname');	
   $process= $s->GetFieldValue('production_process_master',"id='".$billrow['production_process']."'",'manuf_process_name')

  ?>
  <tr>
  	<td><?php echo $i; ?></td>
	<td><?php echo $process; ?></td>
	<td><?php echo  $itemcode; ?></td>
    <td><?php echo  $itemname; ?></td>
    <td><?php echo  $unit; ?></td>
    <td><?php echo  $billrow['bom_qty']; ?></td>
   
  </tr>
 <?php $i++; } ?>
</table>
<br />


<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
  <tr>
    <td class="tabledata"><strong>Total Raw Material And Assembly Item Qty</strong></td>
    <td><?php echo $total_qty; ?></td>
    
  </tr>
</table>

<br />




<script type="text/javascript" language="javascript">
  function toggle_visibility(id) {
       var e = document.getElementById(id);
	      e.style.display = 'none';
		       //alert(e.style.display);
			   window.print();
    }
  
</script>
