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

<?= $this->section('content') ?>
<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">User Position Management Page</h4>
			</div>					
			<div class="col-md-7 align-self-center text-end">
				<a class='btn btn-info text-white btn-sm' href='userposition/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">
						<div class="table-responsive">
							<table id="myTable" class="table display table-striped border">
								<thead>
									<th>Shorttext</th> <th>Texts</th> <th></th>
								</thead>
								<tbody>
									<?php
									foreach($userposition as $data) {
										$shorttext = $data['shorttext'];
										$texts = $data['texts'];
										$userposid = $data['userposid'];
										if( $data['createdate'] != '' ) {
											$createdate = date('d-m-Y', strtotime($data['createdate']));
										} else { $createdate = ''; }
									?>
									<tr> 
										<td><?=$shorttext;?></td> <td><?=$texts;?></td>
										<td>
											<a class='btn btn-warning btn-sm' href='userposition/edit/<?=$userposid;?>' 
												onclick="window.open(this.href, 'Editor','width=900,height=600,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>
	</div>
</div>
<?= $this->endSection() ?>


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

$('.toggleUser').on('click',function(){
	event.preventDefault();
	if(confirm('Are you sure?') == true ) {
		window.open(this.href, 'Data toggler','width=800,height=500,toolbar=1,resizable=0');
	}
});

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