<?php
$sql=DB_query("select * from bill_material where id='".$_REQUEST['Id']."'",$db);
$myrow=DB_fetch_array($sql);
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1>View Bill Of Material</h1>
<form action="" method="post">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
  <tr class="row1">
    <td class="tabledata1">Branch</td>
    <td><?php echo $s->GetFieldValue('locations',"loccode='".$myrow['brach_code']."'",'locationname'); ?></td>
  </tr>
  <tr class="row1">
    <td class="tabledata1">BOM No.</td>
    <td><?php echo $myrow['Bom_no']; ?></td>
    <td class="tabledata1">Type Of BOM</td>
    <td><?php echo $s->GetFieldValue('bom_type',"id='".$myrow['Bom_type']."'",'bom_type'); ?></td>
    <td class="tabledata1">Description</td>
    <td><?php echo $myrow['description']; ?></td>
  </tr>
  <tr class="row1">
    <td class="tabledata1">Location Of BOM</td>
    <td><?php echo $s->GetFieldValue('bom_location',"id='".$myrow['Bom_location']."'",'bom_location'); ?></td>
    <td class="tabledata1">Revision No.</td>
    <td><?php echo $myrow['revision_no']; ?></td>
    <td class="tabledata1">Revision Date</td>
    <td><?php echo $myrow['revision_date']; ?></td>
  </tr>
  <tr class="row1">
    <td class="tabledata1">Prepared Date</td>
    <td><?php echo $myrow['prepared_date']; ?></td>
    <td class="tabledata1">Prepared By</td>
    <td><?php echo $myrow['prepared_by']; ?></td>
    <td class="tabledata1">Approved By</td>
    <td><?php echo $myrow['approved_by']; ?></td>
  </tr>
  <tr class="row1">
    <td class="tabledata1" colspan="8">Finished Product Details</td>
    </tr>
  <tr class="row1">
  	 <td class="tabledata1">Item Details</td>
    <td class="tabledata1">Part Code</td>
    <td><?php echo $myrow['part_code']; ?></td>
    <td class="tabledata1">Product Name</td>
    <td><?php echo $myrow['product_name']; ?></td>
    <td class="tabledata1">UOM</td>
    <td><?php echo $myrow['uom']; ?></td>
  
  </tr>
  <tr class="row1">
    <td class="tabledata1" colspan="8"><strong>BOM - Raw Material And Assembly Item Details</strong></td></tr>
  <tr>
  	<td class="tabledata">S.R. No</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>
    <td class="tabledata">Cost Landed Price</td>
    <td class="tabledata">Amount</td>
  </tr>
     <?php
     $i=1;
   $raw_mat=DB_query("select * from bill_raw_material where bill_material_id='".$myrow['id']."' and status='0'",$db);
   while($raw=DB_fetch_array($raw_mat))
   {   
   ?>	
  <tr>
  <td><?php echo $i; ?></td> 	
  <td><?php echo $s->GetFieldValue('production_process_master',"id='".$raw['production_process']."'",'manuf_process_name'); ?></td>
  <td><?php echo $raw['part_code']?></td>
    <td><?php echo $raw['bom_description']?></td>
    <td><?php echo $raw['bom_uom']?></td>
    <td><?php echo $raw['bom_qty']?></td>
    <td><?php echo $raw['bom_costlanded_price']?></td>
    <td><?php echo $raw['bom_amount']?></td>
  </tr>
  <?php } ?>
  
</table>

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

<table width="100%" border="0" cellpadding="0" cellspacing="3">
  <tr>
    <td valign="top">    	
   <table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
  <tr>
    <td class="tabledata" colspan="4">Process Operational Cost</td>
  </tr>
  
  <tr>
    <td class="tabledata" scope="col">S. No.</td>
    <td class="tabledata" scope="col">Process</td>
    <td class="tabledata" scope="col">%</td>
    <td class="tabledata" scope="col">Amount</td>
  </tr>
  <?php
  $k=1;
  $raw_mat1=DB_query("select * from bom_process_operational  where bill_id='".$myrow['id']."' and status='0'",$db);
   while($raw1=DB_fetch_array($raw_mat1))
   {   
  ?>
   <tr>
    <td><?php echo $k; ?></td>
    <td><?php echo $s->GetFieldValue('production_process_master',"id='".$raw1['process_name']."'",'manuf_process_name'); ?></td>
    <td><?php echo $raw1['process_per']; ?></td>
    <td><?php echo $raw1['process_amt']; ?></td>
  </tr>
  <?php $k++; } ?>
</table>
	
	<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
    	<tr><td class="tabledata">Total Operational Cost</td><td colspan="3"><?php echo $myrow['total_operation_cost']; ?></td></tr>
    </table>
	</td>
   
    <td valign="top">
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
  <tr>
    <td class="tabledata" colspan="4">Other Overhead Cost</td>
  </tr>
  <tr>
    <td class="tabledata">S. No.</td>
    <td class="tabledata">Process</td>
    <td class="tabledata">%</td>
    <td class="tabledata">Amount</td>
  </tr>
  <?php 
   $j=1;
  $raw_mat2=DB_query("select * from bill_other_overhead  where bill_id='".$myrow['id']."' and status='0'",$db);
   while($raw2=DB_fetch_array($raw_mat2))
   {   
  ?>
    <tr>
    <td><?php echo $j; ?> </td>
    <td><?php echo $s->GetFieldValue('production_process_master',"id='".$raw2['overhead_process']."'",'manuf_process_name'); ?></td>
    <td><?php echo $raw2['overhead_per']; ?></td>
    <td><?php echo $raw2['overhead_cost']; ?></td>
  </tr>
  <?php } ?>
    </table>
  
   <table width="100%" border="0" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC">
    	<tr>
    	  <td class="tabledata">Total Overhead Cost</td>
    	  <td><?php echo $myrow['total_overheadcost']; ?></td></tr>
    </table>
    </td>
  </tr>
</table>

<table width="100%" border="0" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC">
<tr>
<td class="tabledata" style="width:195px;">Total Production Rate Of Bill Of Material</td>
<td><?php echo $myrow['total_production_rate']; ?></td>
</tr>
</table>
</form>
</div>
</div>