<?php 
if($_REQUEST['save'])
{
	$data['nature_of_complaints']=$_REQUEST['nature_of_complaints'];
	$data['CompanyId']=$_SESSION['ACGCompanyId'];
	$data['created_date']=date('Y-m-d');
	$s->RecordInsert('dbl_nature_of_complaint', $data);
	$s->pageLocation("index.php?route=DealerDistrbutions/Setup/nature_of_complaints".$rurl);
}


if($_REQUEST['action']=='Edit')
{
	$condition="id='".$_REQUEST['id']."'";
	$SQL12=$s->GetRecordById('dbl_nature_of_complaint',  $condition);
	$FetchRec=DB_fetch_array($SQL12);
}

if($_REQUEST['update'])
{
	$dataArray['nature_of_complaints']=$_REQUEST['nature_of_complaints'];
	$cond="id='".$_REQUEST['id']."'";
	$s->RecordEdit('dbl_nature_of_complaint', $dataArray, $cond);
	$s->pageLocation("index.php?route=DealerDistrbutions/Setup/nature_of_complaints".$rurl);
}

if($_REQUEST['action']=='Del')
{
	$condition="id='".$_REQUEST['id']."'";
	$s->DeleteRecord('dbl_nature_of_complaint',$condition);
	$s->pageLocation("index.php?route=DealerDistrbutions/Setup/nature_of_complaints".$rurl);
}

?>
<script type="text/javascript" language="javascript">
function validate()
{
	if(document.getElementById("nature_of_complaints").value=='')
	{
		alert("Please Fill The Nature Of Complaint Name");
		document.getElementById("nature_of_complaints").focus();
		return false;
	}
}	
</script>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1>Nature Of Complaint Master</h1>
<form name="form1" action="" method="post" >
<table width="50%" align="center" border="0" cellpadding="3" cellspacing="0">
<tr class="row1">
	<td class="tabledata1"><strong>Nature Of Complaint </strong></td>
	<td><input type="text" name="nature_of_complaints" id="nature_of_complaints" value="<?php echo $FetchRec['nature_of_complaints']; ?>" style="width:150px;"></td>
</tr>
<tr class="row1">
	<td class="tabledata1" colspan="2" style="text-align:center;"><input type="submit" name="<?php if($_REQUEST['action']=='Edit'){echo 'update';}else{echo 'save';} ?>" onClick="return validate();" value="<?php if($_REQUEST['action']=='Edit'){echo 'Update';}else{echo 'Save';} ?>" class="search"></td>
</tr>
</table>
</form>
<br/>
<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr class="row1">
	<td width="12%" class="tabledata"><strong>Sr. No.</strong></td>
	<td width="75%" class="tabledata"><strong>Nature Of Complaint Name</strong></td>
	<td width="13%" class="tabledata"><strong>Actions</strong></td>
	
</tr>
<?php $i=0; $SQL=DB_query("select * from dbl_nature_of_complaint where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
		if(DB_num_rows($SQL)>0){
	 while($GetRec=DB_fetch_array($SQL))
	 {
	   $complaint=$s->GetTotalRecordsTalbes('dbl_coplaint',"nature_of_complaint='".$GetRec['id']."'");
		
		if($complaint<=0)
		{
		$status=0;
		}
		else
		{
		$status=1;
		}
	 
	 
	 
	 ?>
<tr class="row1">
	<td><?php echo $i+1;?></td>
	<td><?php echo $GetRec['nature_of_complaints'];?></td>
	<td><a href="index.php?route=DealerDistrbutions/Setup/nature_of_complaints&modid=<?php echo $_REQUEST['modid']; ?>&frmid=<?php echo $_REQUEST['frmid']; ?>&action=Edit&id=<?php echo $GetRec['id']; ?>" title="Edit"><img src="images/icon_edit.gif"  width="10" height="10"/></a>
	<?php if($status==0) { ?>
	<a href="index.php?route=DealerDistrbutions/Setup/nature_of_complaints&modid=<?php echo $_REQUEST['modid']; ?>&frmid=<?php echo $_REQUEST['frmid']; ?>&action=Del&id=<?php echo $GetRec['id']; ?>" onclick="return confirm('This Nature Of Complaint will be deleted. Are you sure?')" title="Delete"><img src="images/delete.Gif" width="10" height="10"
	 /></a>
<?php } else { ?>
<img src="images/delete.Gif" width="10" height="10" onclick="abc()" />

<?php } ?>	
	
	
	</td>
</tr>
<?php $i++;} }else{?>
<tr class="row1">
	<td colspan="4" style="color:#FF0000;">No Record Found</td>
</tr>
<?php } ?>
</table>
</div>
</div>
<script>
function abc()
{
window.alert("Nature Of Complaint Used You Can Not Delete");
}
</script>