<link rel="stylesheet" href="css/new_mxerp.css">
<?php
$PageSecurity = 4;
$title = _('Finished Material Recieved');
$_SESSION['modid']=$_REQUEST['modid'];
$_SESSION['frmid']=$_REQUEST['frmid'];
$frmpermission= $px->GetFileAccess($_SESSION['modid'],$_SESSION['frmid'],$_SESSION['ACGRoleId']);
$_SESSION['frmAdd']=$frmpermission[0];
$_SESSION['frmEdit']=$frmpermission[1];
$_SESSION['frmDelete']=$frmpermission[2];
$_SESSION['frmView']=$frmpermission[3];
?>

<div class="body_contain">
<div class="tab_div">

<h1>NRGP Challan</h1>
<?php //if($_SESSION['frmAdd']=='1') {?>
<div align="left" style="padding-left:10px;"><a href="index.php?route=ADD_NRGP&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&NewReturn=yes">Add NRGP Challan</a></div>
<?php //}?>
<br />
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
  <tr>
    <td class="tabledata">Branch</td>
	<td class="tabledata">Godown</td>
    <td class="tabledata">NRGP No. </td>
	<td class="tabledata">Challan Date</td>
	<td class="tabledata">Form No.</td>
	<td class="tabledata">Issue To</td>
	<!--<td class="tabledata">View</td>-->
	<td class="tabledata">Delete</td>
	
  </tr>
  <?php
  $sql=DB_query("Select * from nrgp_challan",$db);
  $i=0;
  if(DB_num_rows($sql)>0)
  {
  while($myrow=DB_fetch_array($sql))
  {
  ?>
<tr bgcolor="#c1c1c1">
       <td><?php 
    $sitename=$s->getField('locations','loccode',$myrow['site'],'locationname');
    echo $sitename;?></td>
	 <td><?php 
	$storename=$s->getField('storetype','StoreCode',$myrow['store'],'StoreName');
	echo $storename;?></td>
    <td><?php echo $myrow['NRGP_no'];?></td>
   	<td><?php echo ConvertSQLDate($myrow['challan_date']);?></td>
    <td><?php echo $myrow['form_no'];?></td>
    <td><?php echo $myrow['issued_for'];?></td>
	<!--<td><a href="index.php?route=finished_material_recieved_view&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&action=view&id=<?php echo $myrow['id']; ?>">View</a></td> -->
	<td>	<a href="index.php?route=ADD_NRGP_index&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&action=delete&id=<?php echo $myrow['id']; ?>">Delete</a>
		</td>
	
  </tr>
  <?php $i++;} }
  else
  {?>
  <tr>
  <td colspan="12"><h3 align="center"><strong>No Record Found</strong></h3></td>
  </tr>
  <?php 	
  }
  
  if($_REQUEST['id']!='' && $_REQUEST['action']=='delete') 
{ 
$del="delete from nrgp_challan where id='".$_REQUEST['id']."'";
$query=DB_query($del,$db);
$del1="delete from nrgp_challan_details where nrgp_challan_id='".$_REQUEST['id']."'";
$query1=DB_query($del1,$db);
header("location:index.php?route=ADD_NRGP_index&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."");
	
}	?>

</table>