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

<?= $this->section('content') ?>

<style>
.small { font-size : 11px; }
.guidebooklink:hover { background-color:#888; }
.right {}
</style>
<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">Guidebook Management Page</h4>
			</div>
		</div>
		<div class="row">
			<div class="col-12">
				<div class="card">
					<div class="card-body">

						
                        <div class="row mb-3">
						<?php if($_SESSION['level'] == 0) { ?>
							<div class="col-12">
							
								<a class='btn btn-info btn-sm text-white' href='guidebook/create/' 
									onclick="window.open(this.href, 'Create Gudeibook','width=1000,height=600,toolbar=1,resizable=0'); return false;">
									<i class="fas fa-plus-circle"></i> Add Guide
								</a>
								
							</div>
							<?php } ?>
						</div>
						

						<div class="row mb-3">
							<div class="table-responsive">
								<table id="openTable" class="table display border">
									<thead>
										<th style="width:15%;">post#</th> <th style="width:65%;">subject</th> <th style="width:20%;">date</th>
									</thead>
									<tbody>
									<?php foreach($guidebooks as $row) { ?>
										<tr class='guidebooklink' onclick="window.open('guidebook/view/<?=$row['guideid'];?>', 'form','width=1000,height=700'); return false;">
											<td><?=$row['guideid'];?></td>
											<td><?=$row['guidetitle'];?></td>
											<td><?=substr($row['createdate'],0,16);?></td>
										</tr>
									<?php } ?>
									</tbody>
								</table>
							</div>
						</div>

					</div>
				</div>
			</div>
		</div>
    </div>
</div>
<?= $this->endSection() ?>
<?= $this->section('script') ?>
<script>
$(function () {
	$('#openTable').DataTable({
		"order" : [],
		"pageLength" : [25],
		"lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ] 
	});
});
</script>
<?= $this->endSection() ?>