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

<?= $this->section('content') ?>
<?php
$productid = 0;
$productnumber = '';
$productowner = '';
if(isset($products)) { $data = $products[0]; }
if(isset($new_value)) { $data = $new_value; }
if(isset($data)) {
	if(isset($data['productid'])) { $productid = $data['productid']; }
	$productowner = $data['productowner'];
	$productnumber = $data['productnumber'];
	$productname = $data['productname'];
}
?>

<div class="form-body">
	<h3 class="card-title">Product Moving</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='productid' value='<?=$productid;?>'/>
		<div class="form-group row">
			<label class="col-3 col-form-label">Product# (SN.)</label>
			<div class="col-9"><input class="form-control" type="text" value="<?=$productnumber;?>" disabled></div>
		</div>

		<div class="form-group row">
			<label class="col-3 col-form-label">Catalog</label>
			<div class="col-9"><input class="form-control" type="text" value="<?=$productname;?>" disabled></div>
		</div>
		
		<div class="form-group row">
			<label class="col-3 col-form-label">Product Owner</label>
			<div class="col-9">
				<select class='form-control' name='productowner'> 
					<option value=''></option>
					<?php 
						foreach($productowners as $qowner => $qname) {
							if($qowner == $productowner) { echo "<option value='$qowner' selected>$qname</option>"; }
							else { echo "<option value='$qowner'>$qname</option>";  }
						}
					?>
				</select>
			</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() ?>