<?php
if($_REQUEST['Save'] && $_REQUEST['act']==''){
	if($_REQUEST['qc_parameter_master']['parameter']!=''){
		$sql=$s->insertRecord('qc_parameter_master', $_REQUEST['qc_parameter_master']);
		$result=DB_query($sql,$db);
	}
	echo "<script>location.href='index.php?route=".$_REQUEST['route']."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}
if($_REQUEST['act']!='' && $_REQUEST['act']=='edit'){
	$sql=DB_fetch_array(DB_query("Select * from qc_parameter_master where id=".$_REQUEST['id'],$db));
	extract($sql);
}
if($_REQUEST['act']!='' && $_REQUEST['act']=='edit' && $_REQUEST['Save']){
	if($_REQUEST['qc_parameter_master']['parameter']!=''){
		$cond="id=".$_REQUEST['id'];
		$sql=$s->EditRecord("qc_parameter_master", $_REQUEST['qc_parameter_master'], $cond);
		$resutl=DB_query($sql,$db);
	}
	echo "<script>location.href='index.php?route=".$_REQUEST['route']."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="tab_div">
<center> <h2>Parameter Master</h2></center>
<div id="container">
<form action="" method="post">
<table width="100%" align="center" border="0" cellpadding="3" cellspacing="0">
  <tr class="row1">
    <td width="13%"><strong>Process</strong></td>
    <td width="20%"><select name="qc_parameter_master[process_id]" style="width:100%">
		<?php $sql1=DB_query("Select * from production_process_master where CompanyId=".$_SESSION['ACGCompanyId'],$db);
				while($row1=DB_fetch_array($sql1)){
					extract($row1);
				?>
					<option value="<?php echo $id;?>" <?php echo ($process_id==$id?'selected':'')?>><?php echo $manuf_process_name;?></option>
				<?php 
				}	
		?>	
		</select>	</td>
    <td width="13%"><strong>Category</strong></td>
    <td width="20%"><select name="qc_parameter_master[qc_category_id]" style="width:100%">
		<?php $sql2=DB_query("Select * from qc_category_master where CompanyId=".$_SESSION['ACGCompanyId'],$db);
				while($row2=DB_fetch_array($sql2)){
					extract($row2);
				?>
					<option value="<?php echo $id;?>" <?php echo ($qc_category_id==$id?'selected':'')?>><?php echo $cat_name;?></option>
				<?php 
				}	
		?>	
		</select></td>
	<td width="15%"><strong>Parameter Description</strong></td>
    <td><input name="qc_parameter_master[parameter]" id="" type="text" style="width:100%;" value="<?php if($parameter!='') echo $parameter;?>" /></td>
  </tr>
  <tr class="row1">
    <td colspan="6" style="text-align:center;">
<?php if($_REQUEST['act']==''){?>
	<input type="hidden" name="qc_parameter_master[created_by]" value="<?php echo $_SESSION['UserID'];?>" />
	<input type="hidden" name="qc_parameter_master[created_date]" value="<?php echo date('Y-m-d');?>" />
<?php }else{
?>
	<input type="hidden" name="qc_parameter_master[modified_by]" value="<?php echo $_SESSION['UserID'];?>" />
	<input type="hidden" name="qc_parameter_master[modified_date]" value="<?php echo date('Y-m-d');?>" />
<?php 
} ?>
<input name="qc_parameter_master[CompanyId]" value="<?php echo $_SESSION['ACGCompanyId'];?>" type="hidden" style="width:100%;" />
<input type="submit" name="Save" value="Save" class="search" />&nbsp;<input type="submit" name="Cancel" value="Cancel" class="search" /></td>
    </tr>
  <tr class="row1">
    <td colspan="6"><table width="60%" align="center" cellpadding="3" cellspacing="0" border="1" style="border:#999999 1px solid;">
<tr bgcolor="#cccccc" height="25">
<td><strong>Process</strong></td>
<td><strong>Category</strong></td>
<td><strong>Parameter</strong></td>
<td colspan="2" style="text-align:center"><strong>Action</strong></td>
</tr>
<?php $sql=DB_query("Select * from qc_parameter_master where CompanyId=".$_SESSION['ACGCompanyId'],$db);
		while($row=DB_fetch_array($sql)){
			extract($row);
?>
	<tr bgcolor="#FFFFFF">
		<td><?php echo $s->getField('production_process_master','id',$process_id,'manuf_process_name');?></td>
		<td><?php echo $s->getField('qc_category_master','id',$qc_category_id,'cat_name')?></td>
		<td><?php echo $parameter;?></td>
		<td style="text-align:center"><a href="<?php echo "index.php?route=".$_REQUEST['route']."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."&act=edit&id=".$id;?>"><img src="images/icon-edit.png" /></a></td>
		<td style="text-align:center"><a href=""><img src="images/Icon_Delete3.gif" /></a></td>
	</tr>
<?php } ?>
</table></td>
    </tr>
</table>
<p align="center">
</p>
</form>

</div>
</div>