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

<?= $this->section('content') ?>
<?php
$catalogid = '';
$siteid = '';
$locationstartdate = '';
$locationenddate = '';
$installationdate = '';
$warrantystartdate = '';
$warrantyenddate = '';
$productowner = '';
$productserviceid = '';
$statuspart = '';
if(isset($products_log)) { $data = $products_log[0]; }
if(isset($new_value)) { $data = $new_value; }
if(isset($data)) {
	if(isset($data['productlogid'])) { $productlogid = $data['productlogid']; }
	$catalogid = $data['catalogid'];
	$siteid = $data['siteid'];
	$locationstartdate = $data['locationstartdate'];
	$locationenddate = $data['locationenddate'];
	$installationdate = $data['installationdate'];
	$warrantystartdate = $data['warrantystartdate'];
	$warrantyenddate = $data['warrantystartdate'];
	$productowner = $data['productowner'];
	$productserviceid = $data['productserviceid'];
	$statuspart = $data['statuspart'];
}
?>
<div class="form-body">
	<h3 class="card-title">Product 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='productlogid' value='<?=$productlogid;?>'/>
		
		<div class="form-group row">
			<label class="col-3 col-form-label">Catalog</label>
			<div class="col-9">
				<select class="form-control select2" name='catalogid' >
					<option value=''>-</option>
					<?php
					foreach ($productcatalog as $data) {
						$qcatalogid = $data['catalogid'];
						$qcatalognumber = $data['catalognumber'];
						$qproductname = $data['productname'];
						if ($qcatalogid== $catalogid) { echo "<option value='$qcatalogid' selected>$qcatalognumber - $qproductname</option>"; }
						else { echo "<option value='$qcatalogid'>$qcatalognumber - $qproductname</option>"; }
					}
					?>
				</select>
			</div>
		</div>
		<div class="form-group row">
			<label class="col-3 col-form-label">Sitename</label>
			<div class="col-9">
				<select class="form-control select2" name='siteid' >
					<option value=''>-</option>
					<?php
					foreach ($sites as $data) {
						$qsiteid = $data['siteid'];
						$qsitename = $data['sitename'];
						if ($qsiteid== $siteid) { echo "<option value='$qsiteid' selected>$qsitename</option>"; }
						else { echo "<option value='$qsiteid'>$qsitename</option>"; }
					}
					?>
				</select>
			</div>
		</div>
		<div class="form-group row">
			<label class="col-3 col-form-label">Location Start Date</label>
			<div class="col-9"><input class="form-control" type="date" name='locationstartdate' value="<?=$locationstartdate;?>"></div>
		</div>
		<div class="form-group row">
			<label class="col-3 col-form-label">Installation Date</label>
			<div class="col-9"><input class="form-control" type="date" name='installationdate' value="<?=$installationdate;?>"></div>
		</div>
		<div class="form-group row">
			<label class="col-3 col-form-label">Location End Date</label>
			<div class="col-9"><input class="form-control" type="date" name='locationenddate' value="<?=$locationenddate;?>"></div>
		</div>
		<div class="form-group row">
			<label class="col-3 col-form-label">Warranty Start Date</label>
			<div class="col-9"><input class="form-control" type="date" name='warrantystartdate' value="<?=$warrantystartdate;?>"></div>
		</div>
		<div class="form-group row">
			<label class="col-3 col-form-label">Warranty End Date</label>
			<div class="col-9"><input class="form-control" type="date" name='warrantyenddate' value="<?=$warrantyenddate;?>"></div>
		</div>
		<div class="form-group row">
			<label class="col-3 col-form-label">Product Owner ( S / C )</label>
			<div class="col-9"><input class="form-control" type="text" name='productowner' value="<?=$productowner;?>"></div>
		</div>
		<div class="form-group row">
			<label class="col-3 col-form-label">Status Service</label>
			<div class="col-9"><input class="form-control" type="text" name='productserviceid' value="<?=$productserviceid;?>"></div>
		</div>
		<div class="form-group row">
			<label class="col-3 col-form-label">Status Part</label>
			<div class="col-9"><input class="form-control" type="text" name='statuspart' value="<?=$statuspart;?>"></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() ?>