<?= $this->extend('layouts/form.php') ?>

<?= $this->section('content') ?>
<?php
$offid = 0;
$offname = '';
$offaddress = '';
$offphone = '';
if(isset($offices)) { $data = $offices[0]; }
if(isset($new_value)) { $data = $new_value; }
if(isset($data)) {
	if(isset($data['offid'])) { $offid = $data['offid']; }
	$offname = $data['offname'];
	$offaddress = $data['offaddress'];
	$offphone = $data['offphone'];
	
}
?>
<div class="form-body">
	<h3 class="card-title">Office Editor</h3>
	<hr>
	<?php 
	if(isset($validation)) {
	?>
		<div class='alert alert-danger alert-dismissible'>
			<?= $validation->listErrors(); ?>
			<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"> <span aria-hidden="true"></span> </button>
		</div>
	<?php
	}
	?>

	<form method='post'>
		
		<input type='hidden' name='offid' value='<?=$offid;?>'/>
		
		<div class="form-group row">
			<label class="col-2 col-form-label">Office Name</label>
			<div class="col-10"><input class="form-control" type="text" name='offname' value="<?=$offname;?>"></div>
		</div>
		
		<div class="form-group row">
			<label class="col-2 col-form-label">Office Address</label>
			<div class="col-10"><input class="form-control" type="text" name='offaddress' value="<?=$offaddress;?>"></div>
		</div>
		
		<div class="form-group row">
			<label class="col-2 col-form-label">Office Phone</label>
			<div class="col-10"><input class="form-control" type="text" name='offphone' value="<?=$offphone;?>"></div>
		</div>
		
		<button type="button" class="btn btn-dark float-start" onclick="window.close()">Cancel</button>
		
		<button type="submit" class="btn btn-success text-white float-end"> <i class="fa fa-check"></i> Submit</button>
	
	</form>

</div>
<?= $this->endSection() ?>