<?php 
if(isset($_POST['Submit']) && $_REQUEST['action']!='Edit')
{
    $data['sub_name']=$_REQUEST['model_group_name'];
	$data['sub_code']=$_REQUEST['model_group_code'];
	$data['qty']=$_REQUEST['qty'];
	$data['parentid']=$_REQUEST['modelgroup'];
	$data['Created_by']=$_SESSION['UserID'];
	$data['CompanyId']=$_SESSION['ACGCompanyId'];
	$data['Created_date']=date('Y-m-d');
	$s->RecordInsert('prd_model_sub_group', $data);

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

if(isset($_POST['Submit']) && $_REQUEST['action']=='Edit')
{
    $data['sub_name']=$_REQUEST['model_group_name'];
	$data['qty']=$_REQUEST['qty'];
	$data['Modified_by']=$_SESSION['UserID'];
	$data['Modified_date']=date('Y-m-d');
	$cond="id='".$_REQUEST['id']."'";
	$s->RecordEdit('prd_model_sub_group', $data,$cond);

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




if($_REQUEST['id']!='')
{
$sql=DB_query("select * from prd_model_sub_group where id='".$_REQUEST['id']."'",$db);
$row=DB_fetch_array($sql);
extract($row);
}
if($_REQUEST['action']=='')
$readonly="";
else
$readonly="readonly";



?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h3 align="center"><strong>Model Group</strong></h3>

<form action="" method="post">
<table width="100%" border="0" cellspacing="1" cellpadding="2" align="center">
<tr class="row1">
<td class="tabledata1"><strong>Model Group</strong></td>	
	  <td class="tabledata1">
	  <?php	
	
		$ss1="Select * from prd_model_group where CompanyId='".$_SESSION['ACGCompanyId']."'";
		$site_sql1=DB_query($ss1,$db);
	 ?>
	 <select name="modelgroup"> 
    <option  value="000">Select Model Code</option>
	<?php 
	
		while ($myrow1=DB_fetch_array($site_sql1))
		{
		$s1='';
		if($myrow1['id']==$parentid)
		$s1='selected';
 				echo '<option Value="' . $myrow1['id'] . '" '.$s1.'>' . $s->getField('item_master','id',$myrow1['mst_itemid'],'item_name').'('. $myrow1['model_group_code'].')'.'</option>';
 		}
      

	?> </select>
	
	  
	  </td>
  <td class="tabledata1"><strong>Sub Group  Name</strong></td>	
	  <td class="tabledata1"><input type="text"  name="model_group_name" style="width:135px" value="<?php echo $sub_name; ?>" /></td>
	  </tr>
	  <tr class="row1">
<td class="tabledata1"><strong>Sub Group Code  </strong></td>
<td class="tabledata1"><input name="model_group_code" id="model_group_code" style="width:135px" type="text" value="<?php echo $sub_code; ?>" <?php echo $readonly; ?>>
</td>
<td class="tabledata1"><strong>Quantity  </strong></td>
<td class="tabledata1"><input name="qty" id="qty" style="width:135px" type="text" value="<?php echo $qty; ?>" >
</td>

</tr>

<tr class="row1">
<td class="tabledata1" colspan="4" style="text-align:center">
<?php if($_REQUEST['action']!='view') { ?>   
<input type="submit" value="Save" name="Submit" class="search">
&nbsp;&nbsp;
<a href="index.php?route=Production/model_sub_group_index&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>"><input type="button" value=">>" name="Back" class="search"></a>
<?php } else { ?>
<a href="index.php?route=Production/model_sub_group_index&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>"><input type="button" value=">>" name="Back" class="search"></a>
<?php } ?>
</td></tr>
</table>
</form>
</div></div>