<?php
$sql=DB_query("select * from bill_material where id='".$_REQUEST['Id']."'",$db);
$myrow=DB_fetch_array($sql);
?>
<h2 align="center">View Bill Of Material</h2>
<form action="" method="post">
<table width="25%" border="0" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC" align="center">
  <tr>
    <th>Branch</th>
    <td>
    <select name="site" id="site" style="width:100%">
        <?php 
		$site_sql = "SELECT prefix,loccode, locationname from locations where loccode='".$myrow['brach_code']."'";
		$site_result = DB_query($site_sql,$db);
		while($site_row = DB_fetch_array($site_result))
		{
			
		?>
         <option value="<?php echo $site_row['loccode']; ?>" ><?php echo $site_row['locationname']; ?></option>
            <?php } ?>
    </select>
    </td>
  </tr>
</table>

<br/>
<table width="100%" border="0" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC">
  <tr>
    <th>BOM No.</th>
    <td><label>
      <input type="text" name="bomno" id="bomno" style="width:100%" value="<?php echo $myrow['Bom_no']; ?>" readonly>
    </label></td>
    <th>Type Of BOM</th>
    <td>  <select name="bomtype" id="" style="width:100%">
      <?php 
		$site_sql2 = "SELECT id,bom_type from bom_type where id='".$myrow['Bom_type']."'";
		$site_result1 = DB_query($site_sql2,$db);
		while($site_row2 = DB_fetch_array($site_result1))
		{
		?>
         <option value="<?php echo $site_row2['id']; ?>" ><?php echo $site_row2['bom_type']; ?></option>
            <?php } ?>
    </select></td>
    <th>Description</th>
    <td><input type="text" name="Description" id="Description" style="width:100%" value="<?php echo $myrow['description']; ?>" readonly></td>
  </tr>
  <tr>
    <th>Location Of BOM</th>
    <td> <select name="bomlocation" id="" style="width:100%">
        <?php 
		$site_sql3 = "SELECT id,bom_location from bom_location where id='".$myrow['Bom_location']."'";
		$site_result2 = DB_query($site_sql3,$db);
		while($site_row2 = DB_fetch_array($site_result2))
		{
		?>
         <option value="<?php echo $site_row2['id']; ?>" ><?php echo $site_row2['bom_location']; ?></option>
            <?php } ?>
    </select></td>
    <th>Revision No.</th>
    <td><input type="text" name="revisionno" id="v" style="width:100%" value="<?php echo $myrow['revision_no']; ?>" readonly></td>
    <th>Revision Date</th>
    <td><input type="text" name="revisiondate" id="revisiondate" style="width:100%"  value="<?php echo $myrow['revision_date']; ?>" readonly></td>
  </tr>
  <tr>
    <th>Prepared Date</th>
    <td><input type="text" name="prepared_date" id="prepared_date" style="width:100%"  value="<?php echo $myrow['prepared_date']; ?>"></td>
    <th>Prepared By</th>
    <td><input type="text" name="prepared_by" id="prepared_by" style="width:100%" value="<?php echo $myrow['prepared_by']; ?>" readonly></td>
    <th>Approved By</th>
    <td><input type="text" name="approved_by" id="approved_by" style="width:100%"  value="<?php echo $myrow['approved_by']; ?>" readonly></td>
  </tr>
</table>
<br/>
<table width="100%" border="0" cellspacing="2" cellpadding="1"  style="background-color:#FFF; border:solid 1px #CCC" align="center">
  <tr>
    <th colspan="6"><div align="center">Finished Product Details</div></th>
    </tr>
  <tr>
  	 <th>Item Details</th>
  	 <td>&nbsp;</td>
    <th>Part Code</th>
    <td><input type="text" name="part_code" id="part_code" style="width:80%" value="<?php echo $myrow['part_code']; ?>" readonly></td>
    <th>Product Name</th>
    <td><input type="text" name="product_name" id="product_name" style="width:100%" value="<?php echo $myrow['product_name']; ?>" readonly></td>
    <th>UOM</th>
    <td><input type="text" name="uom" id="uom" style="width:100%" value="<?php echo $myrow['uom']; ?>" readonly></td>
  
  </tr>
</table>
<br/>
<table width="100%" border="0" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC" align="center">
  <tr>
    <th colspan="9"><div align="center">BOM - Raw Material And Assembly Item Details</div></th></tr>
  <tr>
  	<th>S.R. No</th>
  	<th>Production Process</th>
    <th>Part Code</th>
    <th>Description</th>
    <th>UOM</th>
    <th>Qty</th>
    <th>Cost Landed Price</th>
    <th>Amount</th>
  </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><select name="product_process" id="prodcut_process" style="width:100%">
      <?php $productrow=DB_query("select * from production_process_master where id='".$raw['production_process']."'",$db);
		while($product_row1=DB_fetch_array($productrow))
		{
			?>
			<option value="<?php echo $product_row1['id']; ?>"><?php echo $product_row1['manuf_process_name'];?></option>
		}
    	
    	<?php $i++; } ?>
    	
    </select></td>
    <td><input type="text" name="itemcode" id="itemcode" style="width:100%"readonly  value="<?php echo $raw['part_code']?>" readonly></td>
    <td><input type="text" name="desc" id="desc" style="width:100%" readonly  value="<?php echo $raw['bom_description']?>" readonly></td>
    <td><input type="text" name="uom" id="uom" style="width:100%" readonly  value="<?php echo $raw['bom_uom']?>" readonly></td>
    <td><input type="text" name="qty" id="qty" style="width:100%"  value="<?php echo $raw['bom_qty']?>" readonly></td>
    <td><input type="text" name="costlandprice" id="costlandprice" style="width:100%"  value="<?php echo $raw['bom_costlanded_price']?>" readonly></td>
    <td><input type="text" name="amount" id="amount" style="width:100%"  value="<?php echo $raw['bom_amount']?>" readonly></td>
  </tr>
  <?php } ?>
  
</table>

<table width="70%" border="0" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC" align="center">
  <tr>
    <th nowrap>Total Raw Material And Assembly Item Qty</th>
    <td><input type="text" name="total_qty" id="total_qty" style="width:100%"  value="<?php echo $myrow['total_qty']; ?>" readonly></td>
    <th nowrap>Total Cost Landed Price</th>
    <td><input type="text" name="landedprice" id="landedprice" style="width:100%"  value="<?php echo $myrow['total_costland_price']; ?>" readonly></td>
  </tr>
</table>
<br/>
<br/>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>    	
    <table width="100%" border="0" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC">
  <tr>
    <th colspan="4">Process Operational Cost</th>
  </tr>
  
  <tr>
    <th scope="col">S. No.</th>
    <th scope="col">Process</th>
    <th scope="col">%</th>
    <th scope="col">Amount</th>
  </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><select name="processid="process" style="width:100%">
    	<?php       	
    	$productrow=DB_query("select * from production_process_master where id='".$raw1['process_name']."'",$db);
		while($product_row1=DB_fetch_array($productrow))
		{
			?>
			<option value="<?php echo $product_row1['id']; ?>"><?php echo $product_row1['manuf_process_name'];?></option>
		}
    	
    	<?php } ?>
    	
    </select>
    	
    	 </td>
    <td><input type="text" name="procesper"   id="procesper" value="<?php echo $raw1['process_per']; ?>" readonly/></td>
    <td><input type="text" name="procesamt[]" id="procesamt" value="<?php echo $raw1['process_amt']; ?>" readonly/>;</td>
  </tr>
  <?php $k++; } ?>
</table>
	<br/>
	
	<table width="70%" border="0" cellspacing="0" cellpadding="0" style="background-color:#FFF; border:solid 1px #CCC">
    	<tr><th>Total Operational Cost</th><td><input type="text" name="procsstotal" readonly id="procsstotal" style="width:100%" value="<?php echo $myrow['total_operation_cost']; ?>"></td></tr>
    </table>
	</td>
    <td>&nbsp;</td>
    <td>
     <table width="100%" border="0" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC">
  <tr>
    <th colspan="4">Other Overhead Cost</th>
  </tr>
  <tr>
    <th>S. No.</th>
    <th>Process</th>
    <th>%</th>
    <th>Amount</th>
  </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><select name="process_overhead[]="process" style="width:100%">
    	
    	<?php       	
    	$productrow=DB_query("select * from production_process_master where id='".$raw2['overhead_process']."'",$db);
		while($product_row1=DB_fetch_array($productrow))
		{
			?>
			<option value="<?php echo $product_row1['id']; ?>"><?php echo $product_row1['manuf_process_name'];?></option>
		}
    	
    	<?php $j++; } ?>
    	
    </select>
    	
    	 </td>
    <td><input type="text" name="procesoverper"  id="procesoverper"  value="<?php echo $raw2['overhead_per']; ?>" readonly/></td>
    <td><input type="text" name="procesoveram" id="procesoveram"    value="<?php echo $raw2['overhead_cost']; ?>" readonly/>;</td>
  </tr>
  <?php } ?>
    </table>
    <br/>
    <table width="70%" border="0" cellspacing="0" cellpadding="0" style="background-color:#FFF; border:solid 1px #CCC" align="right">
    	<tr>
    	  <th>Total Overhead Cost</th>
    	  <td><input type="text" name="overheadcost" id="overheadcost" style="width:100%" value="<?php echo $myrow['total_overheadcost']; ?>" readonly></td></tr>
    </table>
    </td>
  </tr>
</table>
<br>
<table width="45%" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC" align="center">
<tr>
<th>Total Production Rate Of Bill Of Material</th>
<td><input type="text" name="totalamount" id="totalamount" style="width:100%"  value="<?php echo $myrow['total_production_rate']; ?>" readonly></td>
</tr>
</table>
