<?php
	include("building_func.php");
	$hddnBuildingId = $_SESSION['caller']['args'][1];
	if ($_SESSION['user']['access_level'] < SABLE_ACCESS_MANAGER)
	{
		SableGeneralFunctions::divertFromPage();
	}
	$row = $sableDB->getRow("select * from building where building_id = ".$hddnBuildingId);
?>
<script src="<?php SableGeneralFunctions::printModuleJS('building'); ?>"></script>

<!--// Building -->
<form id="frmBuilding" name="frmBuilding" autocomplete="on">
	<input type="hidden" value="<?php echo(SableSystem::sableEncode($hddnBuildingId)); ?>" id="hddnBuildingId" name="hddnBuildingId" />
	<div class="forms">
		<div class="container forms-grids">
			<div class="row forms-grid">
				<div class="col-md-12">
					<h3 class="title"><i class="fa fa-edit" aria-hidden="true"></i>&nbsp;Modify Building</h3>
					<p></p>
				</div>
			</div>
			<!--// edtClientName -->
			<div class="row forms-grids">
				<div class="col-md-4 forms-grid">
					<input type="text" id="edtClientName" name="edtClientName" placeholder="SEARCH..." onKeyUp="doClientRefinement(this)" style="border-bottom: none;" autocomplete="off"/>
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_edtClientName">Search by name</div>
				</div>   
			</div>
			<!-- edtClientName //-->	
			<!--// selClientId -->
			<div class="row forms-grid">
				<div class="col-md-4 forms-grid">
					<div class="dropdown">
						<select name="selClientId" type="select" id="selClientId" onfocus="showHint('selClientId');" onblur="hideHint('selClientId'); validate_selClientId()" onkeypress="handleEnter(this, event)" placeholder="Client" size="6" class="noArrow"  onClick="setClientName()">
						<?php echo(SableDBFunctions::getOptions("client", "client_id", "concat(client_name, ' ', client_surname)", $row['client_id'])); ?>
						</select>
					</div>
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_selClientId">Client</div>
				</div>
			</div>
			<p></p>
			<!-- selClientId //-->
			<p></p>
			<!--// edtAreaName -->
			<div class="row forms-grids">
				<div class="col-md-4 forms-grid">
					<input type="text" id="edtAreaName" name="edtAreaName" placeholder="SEARCH..." onKeyUp="doAreaRefinement(this)" style="border-bottom: none;" autocomplete="off"/>
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_edtAreaName">Search by area</div>
				</div>   
			</div>
			<!-- edtAreaName //-->		
			<!--// selAreaId -->
			<div class="row forms-grid">
				<div class="col-md-4 forms-grid">
					<div class="dropdown">
						<select name="selAreaId" type="select" id="selAreaId" onfocus="showHint('selAreaId');" onblur="hideHint('selAreaId'); validate_selAreaId()" onkeypress="handleEnter(this, event)" placeholder="Area" size="6" class="noArrow"  onClick="setAreaName()">
						<?php echo(SableDBFunctions::getOptions("area", "area_id", "area_name", $row['area_id'])); ?>
						</select>
					</div>
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_selAreaId">Area</div>
				</div>
			</div>
			<p></p>
			<!-- selAreaId //-->
			<p></p>
			<!--// edtBuildingName -->
			<div class="row forms-grid">
				<div class="col-md-4 forms-grid">
					<input name="edtBuildingName" type="text" id="edtBuildingName" onfocus="showHint('edtBuildingName'); validate_edtBuildingName();" onblur="hideHint('edtBuildingName');" placeholder="Building Name" onkeypress="handleEnter(this, event);" value="<?php echo($row['building_name']); ?>" >
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_edtBuildingName">Building Name</div>
				</div>
			</div>
			<p></p>
			<!-- edtBuildingName //-->
			

			<p></p>
			<!--// txtBuildingNeeds -->
			<div class="row forms-grid">
				<div class="col-md-4 forms-grid">
					<textarea name="txtBuildingNeeds" type="date" id="txtBuildingNeeds" onfocus="showHint('txtBuildingNeeds'); validate_txtBuildingNeeds();" onblur="hideHint('txtBuildingNeeds');" placeholder="Requirements/Special Needs" onkeypress="handleEnter(this, event);" ><?php echo($row['building_notes']); ?></textarea>	
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_txtBuildingNeeds">Requirements/Special Needs</div>
				</div>
			</div>
			<p></p>
			<!-- txtBuildingNeeds //-->			
			<p></p>
		<!--// buttons -->
			<div class="row forms-grid">
				<div class="col-md-2">
					<input type="button" id="btnCancel" value="Cancel"
					class="submit" onclick="window.location = '<?php SableSystem::printCallPageLink('/building/'); ?>'"/>
				</div>
				<div class="col-md-2 forms-grid">
					<input id="btnOk" type="button" onclick="modifyBuilding();" value="Update Building" class="submit"/>
				</div>
			</div>
		<!-- buttons //-->
		</div>
	</div>
</form>
<!-- Building //-->
<script>
	setClientName();
	setAreaName();
</script>
