<?php
$modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];
$url="&modid=".$modid."&frmid=".$frmid;
//

$targetpage="index.php?route=Production/Plant/plant_process_entry".$url;

if($_REQUEST['action'] == 'delete')
{
   $del_query = "DELETE FROM plant_process WHERE id='".$_REQUEST['id']."'";
	$del_query_res = DB_query($del_query,$db) or die(DB_error());
 
  $sql_total=DB_query("select * from plant_process_details1 where parentid='".$_REQUEST['id']."'",$db);
  $numrow=DB_num_rows($sql_total);
  if($numrow>0)
  {
   while($row1=DB_fetch_array($sql_total))
   {
    $parentid1[]=$row1['id'];
   }
  }
  if(!empty($parentid1))
  {
   $patid=implode("','",$parentid1);
   $del=DB_query("DELETE FROM plant_process_details1 WHERE parentid='".$_REQUEST['id']."'",$db);
   $del1=DB_query("DELETE FROM plant_process_details2 WHERE parentid in('".$patid."')",$db);
  }
 
	
	
	if(DB_affected_rows($del_query_res)>0)
	{
	echo "<script>alert('Successfully Deleted');</script>";
	}
}
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<style type="text/css">
.padd{text-align:left; padding-left:3px;}
</style>
<div class="body_contain">
<div class="tab_div">
<h3>General Invoice Entry </h3>
<p align="left"><a href="<?php echo $targetpage; ?>&amp;action=Addnew">
<input type="button" name="Add New" value="Add New" class="search" /></a></p>

<table width="100%" border="1" cellspacing="0" cellpadding="3" style="border:#999999 1px solid;">
  <tr>
    <th align="left" valign="top" width="5%" class="padd"><strong>Sr. No.</strong></th>
    <th align="left" valign="top" class="padd" width="10%"><strong>Branch</strong></th>
	<th align="left" valign="top" class="padd" width="10%"><strong>Doc No</strong></th>
	<th align="left" valign="top" class="padd" width="9%"><strong>Date</strong></th>
    <th align="left" valign="top" class="padd" width="15%"><strong>Shift</strong></th>
    <th align="left" valign="top" class="padd" width="12%"><strong>Shift Incharge </strong></th>
    <th align="left" valign="top" class="padd" width="12%"><strong>Prepared By </strong></th>
	<th align="left" valign="top" class="padd"><strong>Created By</strong></th>   
    <th align="left" valign="top" class="padd"><strong>Edit</strong></th>
	<th align="left" valign="top" class="padd"><strong>Delete</strong></th>
  </tr>
  <?php 
   $GetRecord = "Select * from plant_process order by id DESC";
   $ResultData = DB_query($GetRecord,$db);
   $i=1;   
   if(DB_num_rows($ResultData)==0)
   echo "<td  colspan='11'><center>--No Record--</center></td>";
  
   while($myrow = DB_fetch_array($ResultData))
   {    	
       
			
	?>
	
  <tr>
    <td align="left" valign="top"><?php echo $i; ?></td>
    <td align="left" valign="top"><?php echo $s->getField('locations','loccode',$myrow['site'],'locationname'); ?></td>
	<td align="left" valign="top"><?php echo $myrow['doc_no']; ?></td>
	<td align="left" valign="top"><?php echo ConvertSQLDate($myrow['date']);?></td>
    <td align="left" valign="top"><?php echo $s->getField('production_shift','id',$myrow['shift'],'shift_name'); ?></td>
    <td align="left" valign="top"><?php echo $myrow['shift_incharge']; ?></td>
    <td align="left" valign="top"><?php echo $myrow['prepared_by']; ?></td>
    <td align="left" valign="top"><?php echo $s->getField('www_users','id',$myrow['Created_by'],'realname');?></td>
	<td align="left" valign="top">	
	<a href="#" ><img src="images/icon-edit.png"width="15" height="15"></a></td>
		
	<td align="left" valign="top"><a href="index.php?route=Production/Plant/plant_process_entry_index&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid']?>&id=<?php echo $myrow['id'];?>&action=delete">
	  <input type="image" src="images/Icon_Delete.png"></a></td>
  </tr>
  
  	
	<?php  $i++;  $count++; }


 ?>
</table>
</div>
</div>