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

<?php include(SABLE_INCLUDES_PATH.'googleMaps.php'); ?>

<!--// Client -->
<form id="frmClient" name="frmClient" autocomplete="on">
	<input type="hidden" value="<?php echo(SableSystem::sableEncode($hddnClientId)); ?>" id="hddnClientId" name="hddnClientId" />
	<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-eye" aria-hidden="true"></i>&nbsp;View Client</h3>
					<p></p>
				</div>
			</div>
			<!--// edtClientName -->
			<div class="row forms-grid">
				<div class="col-md-4 forms-grid">
					<input name="edtClientName" type="text" id="edtClientName"readonly value="<?php echo($row['client_name']); ?>" >
					<label for="edtClientName" class="fieldHint hintUnder" id="hint_edtClientName">Name</label>
				</div>
				<div class="col-md-8">
				</div>
			</div>
			<p></p>
			<!-- edtClientName //-->
			<p></p>
			<!--// edtClientSurname -->
			<div class="row forms-grid" style="display:none;">
				<div class="col-md-4 forms-grid">
					<input name="edtClientSurname" type="text" id="edtClientSurname"readonly value="<?php echo($row['client_surname']); ?>" >
					<label for="edtClientSurname" class="fieldHint hintUnder" id="hint_edtClientSurname">Surname</label>
				</div>
				<div class="col-md-8">
				</div>
			</div>
			<p></p>
			<!-- edtClientSurname //-->
			<p></p>
			<!--// txtAddressId -->
			<div class="row forms-grid">
				<div class="col-md-4 forms-grid">
					<textarea name="txtAddressId" type="textarea" id="txtAddressId" readonly ><?php echo($address['address']); ?></textarea>
					<label for="txtAddressId" class="fieldHint hintUnder" id="hint_txtAddressId">Address</label>
				</div>
				<div class="col-md-4 forms-grid">
					<textarea name="txtAddressNote" type="textarea" id="txtAddressNote" readonly ><?php echo($row['client_address_note']); ?></textarea>
					<label for="txtAddressNote" class="fieldHint hintUnder" id="hint_txtAddressNote">Address Note</label>
				</div>
				<div class="col-md-4 forms-grid"></div>
			</div>
			<p></p>
			<!-- txtAddressId //-->
			<!--// edtClientCell -->
			<div class="row">
				<div class="col-md-4 forms-grid" style="padding:0;">
					<div class="col-md-12">
						<input name="edtClientCell" type="text" id="edtClientCell" value="<?php echo($row['client_cell']); ?>">
						<label for="edtClientCell" class="fieldHint hintUnder" id="hint_edtClientCell">Cell No.</label>
					</div>
					<div class="col-md-12">
						<input name="edtClientPhone" type="text" id="edtClientPhone" value="<?php echo($row['client_phone']); ?>">	
						<label for="edtClientPhone" class="fieldHint hintUnder" id="hint_edtClientPhone">Phone No.</label>
					</div>				
					<div class="col-md-12">
						<input name="edtClientEmail" type="email" id="edtClientEmail" value="<?php echo($row['client_email']); ?>">
						<label for="edtClientEmail" class="fieldHint hintUnder" id="hint_edtClientEmail">Email</label>
					</div>
				</div>
				<div class="col-md-4 forms-grid">
					<textarea name="txtClientBookingNote" type="date" id="txtClientBookingNote" style="height:13.5em;"><?= $row['client_booking_note']; ?></textarea>
					<label for="txtClientBookingNote" class="fieldHint hintUnder" id="hint_txtClientBookingNote">Booking Notes</label>
				</div>				
			</div>
			<!-- edtClientCell //-->
			
			<?php if (!empty($row['client_notes'])){ ?>
			<p><h3><i class="fa fa-comment"></i>&nbsp;Client Notes</h3></p>
			<div class="row forms-grid">
				<div class="col-md-8 forms-grid">
					<textarea name="txtClientNotes" type="textarea" id="txtClientNotes" size="7" readonly><?php echo($row['client_notes']); ?></textarea>
				</div>
			</div>			
			<?php } ?>			
			<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('/client/'); ?>'"/>
				</div>
				<div class="col-md-2 forms-grid">
					<input id="btnOk" type="button" onclick="editClient('<?php echo(SableSystem::sableEncode($hddnClientId)); ?>')" value="Modify Client" class="submit"/>
				</div>
			</div>
		<!-- buttons //-->
		<?php include(SABLE_INCLUDES_PATH.'googleMapsDisplay.php'); ?>
		</div>
	</div>
</form>
<!--// Google Maps -->
<script src="<?php echo(SABLE_URL_ROOT.'scripts/googleMapB.js'); ?>"></script>
<!-- Google Maps //-->
<!-- Client //-->
<script>showAddress('<?php echo($address['address_lng']); ?>', '<?php echo($address['address_lat']); ?>', '<?php echo($address['address']); ?>');</script>
