<?php 
$_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];

if($_REQUEST['id']!='' && $_REQUEST['action']=='Delete') 
{ 

$del="delete from prd_model_sub_group where id='".$_REQUEST['id']."'";
$query=DB_query($del,$db);

 $s->pageLocation("index.php?route=Production/model_sub_group_index".$rurl);//PAGE REDIRCTION
}

?>
<style>
#slidingDiv {
    display: none;
	height:100px;
	background-color: #D9D6DA;
	padding:20px;
}
</style>
<script type="text/javascript">
function showSlidingDiv(){
$("#slidingDiv").animate({"height": "toggle"}, { duration: 700 });
}
</script>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h3 align="center"><strong>Model Group</strong></h3>
<div align="left"><a href="#" onClick="showSlidingDiv(); return false;"><input type="button" class="search" value="Show Search" style="width:140px;cursor:pointer;"/></a>
<?php //if($_SESSION['frmAdd']=='1') {?>
<!--<a href="index.php?route=Production/model_sub_group&modid=<?php //echo $_REQUEST['modid'];?>&frmid=<?php //echo $_REQUEST['frmid'];?>&NewIssue=yes" class="search" style="text-decoration:none;"><input type="button" class="search" value="Add New Sub Model Group" style="width:140px;cursor:pointer;"/></a>-->
<?php //} ?>
<form action="" method="post">
<div id="slidingDiv" class="centre" >
<table width="100%" border="1" cellspacing="1" cellpadding="2" align="center">
  <tr class="row1">
	<td class="tabledata1" ><strong>Sub Group Code</strong></td>
    <td class="tabledata1">
	<?php	
		$ss="Select * from prd_model_sub_group where CompanyId='".$_SESSION['ACGCompanyId']."'";
		$site_sql=DB_query($ss,$db);
	 ?>
	 <select name="modelcode"> 
    <option  value="000">Select Model Code</option>
	<?php 
	
		while ($myrow=DB_fetch_array($site_sql)){
 				echo '<option Value="' . $myrow['id'] . '">' . $myrow['sub_code'].'</option>';
 		}
      

	?> </select></td>
	<td class="tabledata1" ><strong>Sub Group Name</strong></td>
     <td class="tabledata1">
	
    <?php	
		$ss="Select * from prd_model_sub_group where CompanyId='".$_SESSION['ACGCompanyId']."'";
		$site_sql=DB_query($ss,$db);
	 ?>
	 <select name="modelname"> 
    <option  value="000">Select Model Code</option>
	<?php 
	
		while ($myrow=DB_fetch_array($site_sql)){
 				echo '<option Value="' . $myrow['id'] . '">' . $myrow['sub_name'].'</option>';
 		}
      

	?> </select>
	
	</td>
	
	<td class="tabledata1" ><strong>Model Group</strong></td>
     <td class="tabledata1">
	
    <?php	
		$ss="Select * from prd_model_group where CompanyId='".$_SESSION['ACGCompanyId']."'";
		$site_sql=DB_query($ss,$db);
	 ?>
	 <select name="modelgroup"> 
    <option  value="000">Select Model Code</option>
	<?php 
	
		while ($myrow=DB_fetch_array($site_sql)){
 				echo '<option Value="' . $myrow['id'] . '">' . $myrow['model_group_name'].'('. $myrow['model_group_code'].')'.'</option>';
 		}
      

	?> </select>
	
	</td>
	
	
	</tr>
   
	<tr class="row1">
	<td class="tabledata1" colspan="4" align="center" style="text-align:center;" ><input name="Search" type="submit" value="Search" class="search" /></td>
	</tr>
  </table>

</div>
<br/>
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;" align="center">
  <tr>
    <td class="tabledata"><strong>Sr. No.</strong></td>
    <td class="tabledata"><strong>Sub Group Code </strong></td>
    <td class="tabledata"><strong>Sub Group Name</strong></td>
	<td class="tabledata"><strong>Quantity</strong></td>
   	<td class="tabledata"><strong>VIEW</strong></td>
	<td class="tabledata"><strong>EDIT</strong></td>
	<td class="tabledata"><strong>DELETE</strong></td>
  </tr>
  <?php
     if(isset($_POST['Search']))
	 {
	 
       
		$modelcode=$_REQUEST['modelcode'];
		$modelname=$_REQUEST['modelname'];
		$modelgroup=$_REQUEST['modelgroup'];
		if($modelcode!='000')
		{
		$filter[]="id='".$modelcode."'";
		}
		if($modelname!='000')
		{
		$filter[]="id ='".$modelname."'";
		}
		if($modelgroup!='000')
		{
		$filter[]="parentid ='".$modelgroup."'";
		}
		
      
      if(isset($filter))
		{
		
		 if(count($filter)>0)		 
			{
			$filter1=implode(" and ",$filter);
		    $SQL ="SELECT * FROM prd_model_sub_group where $filter1 order by id DESC";			   
			}
		else
			{			
			 $SQL ="SELECT * FROM prd_model_sub_group  order by id DESC";
	        }
			
		}
		else 
		{
		$SQL ="SELECT * FROM prd_model_sub_group   order by id DESC";
		}
	}	
	
else 
{   

 $SQL = "SELECT * FROM prd_model_sub_group   order by id DESC";
  
}  


  
  $sql=DB_query($SQL,$db);
 
  $i=1;
  if(DB_num_rows($sql)>0)
  {
  while($myrow=DB_fetch_array($sql))
  {
   //$check=$s->getField('prd_model_sub_group','parentid',$myrow['id'],'id');
  ?>
  <tr bgcolor="#FFFFFF">
    <td><?php echo $i;?></td>
    <td><?php echo $myrow['sub_code'];?></td>
     <td><?php echo $myrow['sub_name'];?></td>
	 <td><?php echo $myrow['qty'];?></td>
    <td><?php if($_SESSION['frmView']=='1' ){?>
	<a href="index.php?route=Production/model_sub_group&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&action=view&id=<?php echo $myrow['id']; ?>" ><img src="images/search.gif" height="15" width="15"></a><?php }else{echo "No Permission";}?></td>
	<td>
	<?php if($_SESSION['frmEdit']=='1' ){?>
	<a href="index.php?route=Production/model_sub_group&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&action=Edit&id=<?php echo $myrow['id']; ?>" ><img src="images/icon-edit.png" height="15" width="15"></a><?php }else{echo "No Permission";}?>
	</td>
	<td>
	<?php if($_SESSION['frmDelete']=='1' ){?>
	<a href="index.php?route=Production/model_sub_group_index&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?')"><img src="images/Icon_Delete.png" height="15" width="15"></a><?php }else{echo "No Permission";}?>
	</td>
  </tr>
  <?php $i++;} }
  else
  {?>
  <tr>
  <td colspan="12"><h3 align="center"><strong>No Record Found</strong></h3></td>
  </tr>
  <?php 	
  }
  ?>
</table>
</form>
</div></div>

