<link rel="stylesheet" href="css/new_mxerp.css">


<?php include('includes/Class_Branch.php');
include('includes/AccountGroupMaster_Class.php');
$modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];
$action=$_REQUEST['action'];
$daction=$_REQUEST['daction'];
$rurl="&modid=".$modid."&frmid=".$frmid;
$targetpage="index.php?route=service/mode_complaint".$rurl;
$msgErr=array();?>

<div class="body_contain">
<div class="tab_div">

  <h1>Mode of Complaint</h1>

<?php 
if($_REQUEST['Save']){
	$Insert = DB_query("INSERT INTO mode_complaint SET 
						location = '".$_REQUEST['location']."',
						modeofcomplaint = '".$_REQUEST['modeofcomplaint']."'",$db);
		$s->pageLocation("index.php?route=service/mode_complaint".$rurl);		
}
if($_REQUEST['action']=='Edit'){
$con ="id='".$_REQUEST['id']."'";
$Get_id = $s->GetRecordById('mode_complaint',$con);
$var = DB_fetch_array($Get_id);

	if($_REQUEST['Update']){
	$UPDATE = DB_query("UPDATE mode_complaint SET 
						location = '".$_REQUEST['location']."',
						modeofcomplaint = '".$_REQUEST['modeofcomplaint']."'
						where id = '".$_REQUEST['id']."'",$db);
						$s->pageLocation("index.php?route=service/mode_complaint".$rurl);
	
	}
	
}
if($_REQUEST['action']=='Delete'){
	$delete = DB_query("DELETE FROM mode_complaint
						WHERE id = '".$_REQUEST['id']."'",$db);
}
?>
<form method="post" name="mode_complaint">
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
    <tr>
      <td class="tabledata">Branch Name<label><font color="#FF0000"> *</font></label></td>
      <td><?php $location_qry = "Select * from locations";
		$get_loc=DB_query($location_qry,$db);?>
        <select name="location" style="width:150px">
          <?php while($fetch = DB_fetch_array($get_loc)){
		  		$p='';
				if($fetch['loccode']==$var['location'])
				$p="selected";
			?>
          <option value="<?php echo $fetch['loccode']?>"<?php echo $p;?>><?php echo $fetch['locationname']?></option>
          <?php } ?>
        </select>
      </td>

      <td class="tabledata">Mode of Complaint<label><font color="#FF0000"> *</font></label></td>
      <td><input name="modeofcomplaint" type="text"  value="<?php echo $var['modeofcomplaint']?>" style="width:150px" /></td>
    </tr>
  </table>
  <input name="<?php if($_REQUEST['action']=='Edit') { echo 'Update';}else { echo 'Save'; }?>" type="submit" onclick="return validate_teshMaster()" value="<?php if($_REQUEST['action']=='Edit') { echo 'Update';}else { echo 'Save'; }?>" />
</form>
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
  <tr>
    <td class="tabledata">S. No.</td>
    <td class="tabledata">Branch Name</td>
    <td class="tabledata">Mode of Complaint </td>
    <td class="tabledata">Edit</strong>
    <td class="tabledata">Delete</td>
  </tr>
  <?php $j=0; 
    $ResultData=DB_query("select *  from mode_complaint where 1=1 ",$db);
    while($RowData = DB_fetch_array($ResultData))
   {  if($j++%2==0)
     $bgcolor="#CCCCCC";
	 else{
	 $bgcolor="#FFFFFF";
	 }
	 ?>
<tr bgcolor="#c1c1c1">
    <td><?php echo $j."." ?></td>
    <td><?php echo $s->getField('locations','loccode',$RowData['location'],'locationname');;?> </td>
    <td><?php echo $RowData['modeofcomplaint'];?></td>
  
    <td><a href="<?php  echo $targetpage;?>&action=Edit&id=<?php echo $RowData['id']?>">Edit</a></td>
    <td><a href="<?php echo $targetpage;?>&action=Delete&id=<?php echo $RowData['id']?>" >Delete</a></td>
  </tr>
  <?php } ?>
</table>
</div></div>
<script type="text/javascript">
function validate_teshMaster() {
	if(document.mode_complaint.location.value=='')
	{
		alert("Please Select Branch First");
		return false;
	}
	else if(document.mode_complaint.modeofcomplaint.value=='')
	{
		alert("Please Enter Mode of Complaint");
		return false;
	}
}
</script>
