<?php
	include("building_func.php");
	$hddnBuildingId = -1;
	$clientName = null;
	if (sizeof($_SESSION['caller']['args']) > 2)
	{
		$hddnClientId = $_SESSION['caller']['args'][1];
		$clientName = $sableDB->getValue("select concat(client_name, ' ', client_surname) from client where client_id = ".$hddnClientId);
	}
	if ($_SESSION['user']['access_level'] < SABLE_ACCESS_MANAGER)
	{
		SableGeneralFunctions::divertFromPage();
	}

?>
<script src="<?php SableGeneralFunctions::printModuleJS('building'); ?>"></script>

<!--// Building -->
<form id="frmBuilding" name="frmBuilding" autocomplete="on">
	<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-plus" aria-hidden="true"></i>&nbsp;Add 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;" value="<?php echo($clientName); ?>" 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');" onkeypress="handleEnter(this, event)" placeholder="Client" size="6" class="noArrow"  onClick="setClientName()">
						<?php echo(SableDBFunctions::getOptions("client", "client_id", "concat(client_name, ' ', client_surname)", $hddnClientId)); ?>
						</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", -1)); ?>
						</select>
					</div>
				</div>
				<div class="col-md-8">
					<div class="fieldHint" id="hint_selAreaId">Area</div>
				</div>
			</div>
			<p></p>
			<!-- selAreaId //-->
			
            

      <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);" >
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtBuildingName">Building Name</div>
        </div>
      </div>
      <p></p>
      
      <!-- edtBuildingName //--> 
      
      <!--// Add Addresses -->
      <div class="row forms-grids">
        <div class="col-xs-12 col-sm-10 col-md-8 col-lg-6 forms-grid">
          <label class="fieldHint hintUnder" id="hint_txtClientAddress">Address</label>
        </div>
      </div>
      <p></p>
      <!--// edtBuildingName -->
      <div class="row forms-grid">
        <div class="col-md-4 forms-grid">
          <input name="edtAddressStreet" type="text" id="edtAddressStreet" onfocus="showHint('edtAddressStreet'); validate_edtAddressStreet();" onblur="hideHint('edtAddressStreet');" placeholder="Address Street" onkeypress="handleEnter(this, event);" >
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtAddressStreet">Address Street</div>
        </div>
      </div>
      <p></p>
      
      <!-- edtBuildingName //--> 
      
      <!--// edtBuildingName -->
      <div class="row forms-grid">
        <div class="col-md-4 forms-grid">
          <input name="edtAddressSuburb" type="text" id="edtAddressSuburb" onfocus="showHint('edtAddressSuburb'); validate_edtAddressSuburb();" onblur="hideHint('edtAddressSuburb');" placeholder="Address Suburb" onkeypress="handleEnter(this, event);" >
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtAddressSuburb">Address Suburb</div>
        </div>
      </div>
      <p></p>
      
      <!-- edtBuildingName //--> 
      
      <!--// edtBuildingName -->
      
      <div class="row forms-grid">
        <div class="col-md-4 forms-grid">
          <input name="edtAddressCity" type="text" id="edtAddressCity" onfocus="showHint('edtAddressCity'); validate_edtAddressCity();" onblur="hideHint('edtAddressCity');" placeholder="Address City" onkeypress="handleEnter(this, event);" >
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtAddressCity">Address City</div>
        </div>
      </div>
      <p></p>
      
      <!-- edtBuildingName //--> 
      
      <!--// edtBuildingName -->
      <div class="row forms-grid">
        <div class="col-md-4 forms-grid">
          <input name="edtAddressCounty" type="text" id="edtAddressCounty" onfocus="showHint('edtAddressCounty'); validate_edtAddressCounty();" onblur="hideHint('edtAddressCounty');" placeholder="Address County" onkeypress="handleEnter(this, event);" >
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtAddressCounty">Address County</div>
        </div>
      </div>
      <p></p>
      
      <!-- edtBuildingName //--> 
      
      <!--// edtBuildingName -->
      <div class="row forms-grid">
        <div class="col-md-4 forms-grid">
          <input name="edtAddressPostalCode" type="text" id="edtAddressPostalCode" onfocus="showHint('edtAddressPostalCode'); validate_edtAddressPostalCode();" onblur="hideHint('edtAddressPostalCode');" placeholder="Address Postal Code" onkeypress="handleEnter(this, event);" >
        </div>
        <div class="col-md-8">
          <div class="fieldHint" id="hint_edtAddressPostalCode">Address Postal Code</div>
        </div>
      </div>
      <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);" ></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="insertBuilding();" value="Add Building" class="submit"/>
				</div>
			</div>
		<!-- buttons //-->
		</div>
	</div>
</form>
<!-- Building //-->
