<?php
 if($_REQUEST['action']=='delete' and $_REQUEST['Id']!='')
{
 $del="delete from bill_material where id='".$_REQUEST['Id']."'";
 $query=DB_query($del,$db);
 $del1="delete from bill_raw_material where bill_material_id='".$_REQUEST['Id']."'"	;
 $query1=DB_query($del1,$db);
  $del2="delete from bom_process_operational where bill_id='".$_REQUEST['Id']."'"	;
  $query2=DB_query($del2,$db);
   $del3="delete from bill_other_overhead where bill_id='".$_REQUEST['Id']."'"	;
  $query3=DB_query($del3,$db);
}
?>

<h2 align="center">BOM List</h2>
<a href="index.php?route=bill_of_material&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>">Add BOM</a>
<br><br>
<table width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>
<th>Branch</th>
<th>BOM No.</th>
<th>Prepared Date</th>
<th>Total RawMaterial Qty</th>
<th>Total CostLanded </th>
<th>Total OT Cost</th>
<th>Total Overhead Cost</th>
<th>Total Production Rate </th>
<th>View</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<?php
$sql=DB_query("Select * from bill_material",$db);	
$i=0;
$num=DB_num_rows($sql);
if($num>0)
{
while($myrow=DB_fetch_array($sql))
{
?>
<tr bgcolor="#FFFFFF">
<td><?php   echo  $branch=$s->getField('locations','loccode',$myrow['brach_code'],'locationname');?></td>
<td><?php echo $myrow['Bom_no'];?></td>
<td><?php echo $myrow['prepared_date'];?></td>
<td><?php echo $myrow['total_qty'];?></td>
<td><?php echo $myrow['total_costland_price'];?></td>
<td><?php echo $myrow['total_operation_cost'];?></td>
<td><?php echo $myrow['total_overheadcost'];?></td>
<td><?php echo $myrow['total_production_rate'];?></td>
<td><div align="center"><a href="index.php?route=view_bill_of_material&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&action=edit&Id=<?php echo $myrow['id'];?>">View</a></div></td>
<td><div align="center"><a href="index.php?route=edit_bill_of_material&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&action=edit&Id=<?php echo $myrow['id'];?>">Edit</a></div></td>
<td><div align="center"><a href="index.php?route=bill_of_materiallist&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&action=delete&Id=<?php echo $myrow['id'];?>" onclick="return confirm('Are you sure you want to delete?')">Delete</a></div></td>
</tr>
<?php $i++;}}
else { ?>
	<tr bgcolor="#FFFFFF">
<td colspan="9">No Records Find</td>
</tr>
<?php }   ?>
	
</table>
