<?php 
if($_REQUEST['Save'] && $_REQUEST['act']==''){
	foreach($_REQUEST['qc_category_master'] as $key=>$val){
		if(!empty($val['cat_code'])){
			$sql=$s->insertRecord('qc_category_master', $val);
			$resutl=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_category_master where id=".$_REQUEST['id'],$db));
	extract($sql);
}
if($_REQUEST['act']!='' && $_REQUEST['act']=='edit' && $_REQUEST['Save']){
	foreach($_REQUEST['qc_category_master'] as $key=>$val){
		if($val['cat_code']!=''){
			$cond="id=".$_REQUEST['id'];
			$sql=$s->EditRecord("qc_category_master", $val, $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>Category Master</h2>
</center>
<div id="container">
<form action="" method="post">
<table align="center" border="0" cellpadding="3" cellspacing="0" width="100%">
<tr class="row1">
<td><table width="50%" align="center" border="1" cellpadding="3" cellspacing="1" style="border:#999999 1px solid;">
<tr height="25" bgcolor="#CCCCCC">
    <td width="20%"><strong>Category Code</strong></td>
    <td width="20%"><strong>Category Description</strong></td>
  </tr>
<?php for($i=0; $i<10; $i++){?>
  <tr>
    <td><input name="qc_category_master[<?php echo $i;?>][cat_code]" id="qc_category_master[<?php echo $i;?>][cat_code]" type="text" style="width:100%;" value="<?php if($cat_code!='' && $i==0)echo $cat_code;?>" />
<?php if($_REQUEST['act']==''){?>
	<input type="hidden" name="qc_category_master[<?php echo $i;?>][created_by]" value="<?php echo $_SESSION['UserID'];?>" />
	<input type="hidden" name="qc_category_master[<?php echo $i;?>][created_date]" value="<?php echo date('Y-m-d');?>" />
<?php }else{
?>
	<input type="hidden" name="qc_category_master[<?php echo $i;?>][modified_by]" value="<?php echo $_SESSION['UserID'];?>" />
	<input type="hidden" name="qc_category_master[<?php echo $i;?>][modified_date]" value="<?php echo date('Y-m-d');?>" />
<?php 
} ?>
	<input type="hidden" name="qc_category_master[<?php echo $i;?>][CompanyId]" value="<?php echo $_SESSION['ACGCompanyId'];?>" />
	</td>
    <td><input name="qc_category_master[<?php echo $i;?>][cat_name]" id="qc_category_master[<?php echo $i;?>][cat_name]" type="text" style="width:100%;" value="<?php if($cat_name!='' && $i==0)echo $cat_name;?>" /></td>
  </tr>
  <?php } ?>
</table></td>
</tr>

<tr class="row1">
<td><p align="center"><input type="submit" name="Save" value="Save" class="search" />&nbsp;<input type="submit" name="Cancel" value="Cancel" class="search" /></p></td>
</tr>
<tr class="row1">
<td><table width="50%" align="center" border="1" cellpadding="3" cellspacing="1" style="border:#999999 1px solid;">
<tr height="25">
<td bgcolor="#CCCCCC"><strong>Code</strong></td>
<td bgcolor="#CCCCCC"><strong>Name</strong></td>
<td colspan="2" bgcolor="#CCCCCC" style="text-align:center"><strong>Action</strong></td>
</tr>
<?php $sql=DB_query("Select * from qc_category_master where CompanyId=".$_SESSION['ACGCompanyId'],$db);
		while($row=DB_fetch_array($sql)){
			extract($row);
?>
	<tr bgcolor="#FFFFFF">
		<td><?php echo $cat_code;?></td>
		<td><?php echo $cat_name;?></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>

</form>


</div>
</div>