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

<?= $this->section('content') ?>
<?php
$productaliastext = '';
?>
<div class="page-wrapper">
	<div class="container-fluid">
		
		<div class="row page-titles">
			<div class="col-md-5 align-self-center">
				<h4 class="text-themecolor">Products Alias</h4>
			</div>
			<div class="col-md-7 align-self-center text-end">
				<a class='btn btn-info text-white btn-sm' href='productalias/create/' 
					onclick="window.open(this.href, 'Create','width=900,height=600,toolbar=1,resizable=0'); return false;">
					<i class="fas fa-plus-circle"></i> Create
				</a>
			</div>
		</div>
		
		<div class="row">
			<div class="col-12">
				<div class="card">
					<div class="card-body">
						<form method='post' >
							<div class='row mb-2'>
								<div class="col-2">
									<label class="form-label">Product Alias </label>
								</div>
								<div class='col-10'>
									<input type='text' class='form-control form-control-sm' name='productaliastext' value='<?=$productaliastext;?>'/>
								</div>
							</div>
							<button type="submit" class="btn btn-success text-white"> <i class="fa fa-search"></i> Search</button>
						</form>
					</div>
				</div>
			</div>
		</div>
		
		<?php if(isset($productalias)) { ?>
		<div class="row">
			<div class="col-12">
				<div class="card">
					<div class="card-body">
						<div class="table-responsive">
							<table id="myTable" class="table display table-striped border">
								<thead>
									<th>ID</th> <th>Text</th> <th>Create Date</th> <th></th>
								</thead>
								<tbody>
									<?php
									foreach($productalias as $data) {
										$productaliasid= $data['productaliasid'];
										$productaliastext= $data['productaliastext'];
										if( $data['createdate'] != '' ) {
											$createdate = date('d-m-Y', strtotime($data['createdate']));
										} else { $createdate = ''; }
									?>
									<tr> 
										<td><?=$productaliasid;?></td> <td><?=$productaliastext;?></td> <td><?=$createdate;?></td> 
										<td>
											<a class='btn btn-warning btn-sm' href='productalias/edit/<?=$productaliasid;?>' 
												onclick="window.open(this.href, 'Editor','width=950,height=400,toolbar=1,resizable=0'); return false;">
												<i class="fas fa-pencil-alt"></i> Edit
											</a>
										</td>
									</tr>
									<?php } ?>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
		<?php } ?>
		
		<div id="modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="tooltipmodel" aria-hidden="true">
			<div class="modal-dialog modal-dialog-centered modal-xl">
				<div class="modal-content">
				</div>
			</div>
		</div>
	</div>
</div>
<?= $this->endSection() ?>

<?= $this->section('script') ?>
<script>
$(function () {
	$('#myTable').DataTable({
		"order" : [],
		"iDisplayLength" : -1
	});
});
</script>
<?= $this->endSection() ?>