<?php 
if($_REQUEST['save'])
{
	$data['site']=$_REQUEST['site'];
	$data['store']=$_REQUEST['storecode'];
	$data['floor_name']=$_REQUEST['industry_type'];
	$data['CompanyId']=$_SESSION['ACGCompanyId'];
	
	if($_REQUEST['action']=='Edit')
	{
	$data['modified_date']=date('Y-m-d');
	$data['modified_by']=$_SESSION['UserID'];
	$cond="id='".$_REQUEST['id']."'";
	$s->RecordEdit('log_floor',$data,$cond);	
	}
	else
	{
	$data['created_date']=date('Y-m-d');
	$data['created_by']=$_SESSION['UserID'];
	$s->RecordInsert('log_floor',$data);
	}
	$s->pageLocation("index.php?route=LOG/masters/floor_note_index".$rurl);
}


if($_REQUEST['action']=='delete')
{
	$condition="id='".$_REQUEST['id']."'";
	$s->DeleteRecord('log_floor',  $condition);
	$s->pageLocation("index.php?route=LOG/masters/floor_note_index".$rurl);
}


if($_REQUEST['action']=='Edit')
{
	$condition="id='".$_REQUEST['id']."'";
	$rec=$s->DisplayRecord('log_floor',  $condition);
	$Getrec=DB_fetch_array($rec);
	extract($Getrec);
}
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1>Floor Details</h1>
<form method="post">
<table width="30%" border="0" cellspacing="0" cellpadding="3" align="center">
<tr class="row1">
	<td class="tabledata1">Site</td>
	<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	  <td><?php
	if($_SESSION['AssignedBranch']!='')
	  {	  	
      $ss="Select loccode, locationname from locations  where CompanyId='".$_SESSION['ACGCompanyId']."'
    and loccode in('".$_SESSION['AssignedBranch']."')";
	  	 $site_sql=DB_query($ss,$db);
	  }
	  else
	  {
		$ss="Select loccode,locationname from locations where CompanyId='".$_SESSION['ACGCompanyId']."'";
		$site_sql=DB_query($ss,$db);
	  }?>
     <select name="site" onchange="getreqitemdata(this.value)" id="site" style="width:70px"    >
      <option value="0">---Select---</option>
      <?php
	while($site_row=DB_fetch_array($site_sql))
	{
	?>
      <option value="<?php echo $site_row['loccode'];?>"<?php echo ($site==$site_row['loccode']?'selected':'')?>><?php echo $site_row['loccode'];?></option>
      <?php } ?>
    </select></td>
	  <td><div id="txtsite">
	    <?php
	
	$site_sql="Select locationname from locations where loccode ='".$site."'";
	$site_res=DB_query($site_sql,$db);
	$site_row=DB_fetch_array($site_res);
	if(isset($site))
	{
	?>
	    <input name="sitename" type="text" id="sitename"  value="<?php echo $site_row['locationname'];?>" size="20" readonly="true">
	<?php } else {?>
	<input name="sitename" type="text" id="sitename"  value="<?php echo $sitename;?>" size="20" readonly="true">
	<?php } ?>
	<input type="hidden" name="hidden_site" id="hidden_site" value="<?php echo $_REQUEST['hidden_site'];?>"/></div></td>
	</tr>
	<tr></tr>
	</table>
	</td>
</tr>
<tr class="row1">
	<td class="tabledata1">Warehouse</td>
	<td id="storedata">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
		<td>	
		<?php
		$sql_store = "select id, StoreCode, StoreName from storetype where CompanyId='".$_SESSION['ACGCompanyId']."' and Store_Site in ('".$_SESSION['AssignedBranch']."') order by StoreCode ASC";
		$resultStkLocs = DB_query($sql_store,$db);
		?>
		<select id="storecode" name="storecode"  style="width:100%">
		<option value="0">Select</option> 
		<?php 
		while ($myrow=DB_fetch_array($resultStkLocs))
		{
				$p='';
				if($store==$myrow['id'])
				$p="selected";
		?>
			<option Value="<?php echo $myrow['id']; ?>" <?php echo $p; ?>><?php echo $myrow['StoreName']; ?></option>
		<?php }
		?>
		</select>		</td>
        <!--<td><div id="txtid"><input type="text" name="storename" id="storename" size="20" readonly="true" value="<?php echo $storename; ?>"></div></td>-->
      </tr>
    </table></td>
</tr>
<tr class="row1">
	<td class="tabledata1">Floor Name </td>
	<td><input type="text" name="industry_type" value="<?php echo $floor_name; ?>" id="industry_type" style="width:150px;"></td>
</tr>
<tr class="row1">
	<td colspan="2" style="text-align:center;"><input type="submit" name="save" value="Save" class="search"></td>
</tr>
</table>
</form>


<table width="100%" border="1" cellspacing="0" cellpadding="3" align="center">
<tr class="row1">
	<td class="tabledata">Sr. No.</td>
	<td class="tabledata">Site</td>
	<td class="tabledata">Store</td>
	<td class="tabledata">Floor Id</td>
	<td class="tabledata">Floor Name </td>
	<td class="tabledata">Edit</td>
	
</tr>
<?php $i=1;
 
 $SQL=DB_query("SELECT * FROM log_floor where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);


while($GetRec=DB_fetch_array($SQL)) 
{
$complaint=$s->GetTotalRecordsTalbes('log_addmrnbox',"layout='".$GetRec['id']."'");
		if($complaint<=0)
		{
		$status=0;
		}
		else
		{
		$status=1;
		}



?>
<tr class="row1">
	<td><?php echo $i; ?></td>
	<td><?php echo $s->GetFieldValue('locations','loccode="'.$GetRec['site'].'"','locationname'); ?></td>
	<td><?php echo $s->GetFieldValue('storetype','id="'.$GetRec['store'].'"','StoreName'); ?></td>
	<td><?php echo $GetRec['id']; ?></td>
	<td><?php echo $GetRec['floor_name']; ?></td>
	<td><a href="index.php?route=LOG/masters/floor_note_index&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&id=<?php echo $GetRec['id'];?>&action=Edit"><img src="images/icon-edit.png"  width="10" height="10"/></a>
<?php if($status==0) { ?>	
	<a href="index.php?route=LOG/masters/floor_note_index&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&id=<?php echo $GetRec['id'];?>&action=delete" onclick="return confirm('This Industry Type will be deleted. Are you sure?')"><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++;} ?>
</table>

</div>
</div>
<script>
function abc()
{
window.alert("Floor Used You Can Not Delete");
}
</script>