<?php 
$PageSecurity = 11;
$title = _('Floor Master');
include('includes/SQL_CommonFunctions.inc');
?>
<style type="text/css">
  .cap{
    text-transform:uppercase
    };
</style>
<?php 
if($_REQUEST['action']=='delete' && $_GET['id']!='')
{
	$del_sql=DB_query("Delete from floor_master where id='".$_GET['id']."'",$db);
	echo "<script>location.href='index.php?route=floor_master&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}
if($_REQUEST['Submit'] != '')
{
	$sql="INSERT INTO floor_master(id,floorName) VALUES('','".$_POST['name']."')";
	$result=DB_query($sql,$db);
	prnMsg( _('Record Inserted Successfully!'),'success');
	echo "<script>location.href='index.php?route=floor_master&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}
if($_GET['id']!='' && $_GET['action']=='edit' && !isset($_REQUEST['Update']))
{
	$get_sql=DB_query("Select * from floor_master where id='".$_GET['id']."'",$db);
	$get_row=DB_fetch_array($get_sql);
	
	$_REQUEST['name']=$get_row['floorName'];
}
if($_REQUEST['Update'] != '' && $_REQUEST['row_id']!='')
{
$update_sql="Update floor_master SET floorName='".$_POST['name']."' where id='".$_REQUEST['row_id']."' ";
$update_res=DB_query($update_sql,$db);
prnMsg( _('Record Updated Successfully!'),'success');
echo "<script>location.href='index.php?route=floor_master&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}
?>
<h2 align="center"><strong>Floor Master</strong></h2>
<form action="" method="post">
<table width="40%" border="0" cellspacing="1" cellpadding="2" align="center">
  <tr>
    <th><strong>FLOOR</strong></th>
    <td><input name="name" type="text" id="name" value="<?php echo $_REQUEST['name'];?>" size="30" class="cap"></td>
  </tr>
</table>
<p align="center">
<?php if($_GET['action']=='edit'){?>
<input type="submit" value="Update" name="Update">
<input type="hidden" name="row_id" value="<?php echo $_GET['id'];?>" id="row_id">
<?php } else {?>
<input type="submit" value="Submit" name="Submit">
<?php }?>
</p>
</form>
<br>	
<br>
<?php 
$floor_sql=DB_query("Select * from floor_master",$db);
?>
<table width="20%" border="0" cellspacing="1" cellpadding="2" align="center">
<tr>
<th><strong>Floor</strong></th>
<th colspan="2"><strong>Action</strong></th>
</tr>
<?php
if(DB_num_rows($floor_sql)>0){
while($floor_row=DB_fetch_array($floor_sql))
{ 
?>
<tr>
<td><?php echo $floor_row['floorName'];?></td>
<td><a href="index.php?route=floor_master&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&id=<?php echo $floor_row['id'];?>&action=edit">Edit</a></td>
<td><a href="index.php?route=floor_master&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&id=<?php echo $floor_row['id'];?>&action=delete" onClick="return confirm('Are you sure you want to delete this record?')">Delete</a></td>
</tr>
<?php } }
else
{?>
<tr>
<td colspan="2"><h3 align="center"><strong><font color="#FF0000">NO RECORD FOUND!</font></strong></h3></td>
</tr>
<?php 
}?>
</table>
<?php 
include('includes/footer.inc');
?>