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

<?= $this->section('content') ?>
<?php
$userdepartment = '';
$userposition = '';
$office = '';
$reportto = '';
$startdate = '';
$enddate = '';
if(isset($users_log)) { $data = $users_log[0]; }
if(isset($new_value)) { $data = $new_value; }
if(isset($data)) {
	if(isset($data['userlogid'])) { 
		$userlogid = $data['userlogid']; 
	}

	// var_dump($data);die();

	$userdepartment = $data['userdepartment'];
	$userposition = $data['userposition'];
	$office = $data['office'];
	$reportto= $data['reportto'];

	$startdate = $data['startdate'];
	if($startdate != '') { $startdate = substr( $startdate,0,10 ); }
	
	$enddate = $data['enddate'];
	if($enddate != '') { $enddate = substr( $enddate,0,10 ); }
	
	}
?>
<div class="form-body">
	<h3 class="card-title">User Log 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='userlogid' value='<?=$userlogid;?>'/>

		<div class="form-group row">
			<label class="col-2 col-form-label">Name</label>
			<div class="col-10"><input class="form-control" disabled type="text" name='fullname' value="<?=$fullname;?>"></div>
		</div>

		<div class="form-group row">
			<label class="col-2 col-form-label">Department</label>
			<div class="col-10"><input class="form-control" disabled type="text" name='userdepartment' value="<?=$userdepartment;?>"></div>
		</div>
		
		<div class="form-group row">
			<label class="col-2 col-form-label">Position</label>
			<div class="col-10"><input class="form-control" disabled type="text" name='userposition' value="<?=$userposition;?>"></div>
		</div>
		
		<div class="form-group row">
			<label class="col-2 col-form-label">Office</label>
			<div class="col-10"><input class="form-control" disabled value="<?=$office;?>" type="text" name='office'></div>
		</div>

		<div class="form-group row">
			<label class="col-2 col-form-label">Report to</label>
			<div class="col-10"><input class="form-control" disabled type="text" name='reportto' value="<?=$reportto;?>"></div>
		</div>

		<div class="form-group row">
			<label class="col-2 col-form-label">Start Work 
				<br> 
				<small class="text-muted fs-6">Mulai Menjabat</small>
			</label>
			<div class="col-10"><input class="form-control" type="date" required name='startdate' value='<?=$startdate;?>'></div>
		</div>

		<div class="form-group row">
			<label class="col-2 col-form-label">End Work
				<br> 
				<small class="text-muted fs-6">Akhir Jabatan</small>
			</label>
			<div class="col-10"><input class="form-control" type="date" name='enddate' value="<?=$enddate;?>"></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() ?>