<div class="card card-info card-outline">
	<div class="card-header">
		<h5 class="m-0">Changelogs:
			<form method="post" class="float-right">
				{{ csrf() }}
				<input type="hidden" name="action" value="new" />
				<button type="submit" class="btn btn-sm btn-success">New</button>
			</form>
		</h5>
	</div>

	<div class="card-body">
		<table class="tb_datatable table table-striped table-bordered table-responsive d-md-table">
			<thead>
			<tr>
				<th width="5%">ID</th>
				<th>Date</th>
				<th>Description</th>
				<th>Type</th>
				<th>Where</th>
				<th></th>
			</tr>
			</thead>
			<tbody>
			{% if changelogs|length > 0 %}
				{% set i = 0 %}
				{% for log in changelogs %}
					<tr>
						<td>{{ log.id }}</td>
						<td data-sort="{{ log.date }}">{{ log.date|date("j.m.Y") }}</td>
						<td>{{ truncate(log.body|raw,20) }}</td>
						<td><img src="{{ constant('BASE_URL') }}images/changelog/{{ log.type }}.png" alt="icon" title="{{ log.type|capitalize }}"/> {{ log.type|capitalize }}</td>
						<td><img src="{{ constant('BASE_URL') }}images/changelog/{{ log.where }}.png" alt="icon" title="{{ log.where|capitalize }}"/> {{ log.where|capitalize }}</td>
						<td>
							<div class="btn-group">
								<form method="post">
									{{ csrf() }}
									<input type="hidden" name="action" value="edit" />
									<input type="hidden" name="id" value="{{ log.id }}" />
									<button type="submit" class="btn btn-success btn-sm" title="Edit"><i class="fas fa-pencil-alt"></i></button>
								</form>

								<form method="post">
									{{ csrf() }}
									<input type="hidden" name="action" value="delete" />
									<input type="hidden" name="id" value="{{ log.id }}" />
									<button type="submit" class="btn btn-danger btn-sm" title="Delete" onclick="return confirm('Are you sure?');"><i class="fas fa-pencil-alt"></i></button>
								</form>

								<form method="post">
									{{ csrf() }}
									<input type="hidden" name="action" value="hide" />
									<input type="hidden" name="id" value="{{ log.id }}" />
									<button type="submit" class="btn btn-{{ (log.hide != 1) ? 'info' : 'default' }} btn-sm" title="{% if log.hide != 1 %}Hide{% else %}Show{% endif %}"><i class="fas fa-eye{{ (log.hide != 1) ? '' : '-slash' }}"></i></button>
								</form>
							</div>
						</td>
					</tr>
					{% set i = i + 1 %}
				{% endfor %}
			{% else %}
				<tr>
					<td colspan="6">There are no changelogs for the moment.</td>
				</tr>
			{% endif %}
			</tbody>
		</table>
	</div>
</div>
<link rel="stylesheet" type="text/css" href="{{ constant('BASE_URL') }}tools/css/jquery.datetimepicker.css"/ >
<script src="{{ constant('BASE_URL') }}tools/js/jquery.datetimepicker.js"></script>
<script>
	$(document).ready(function () {
		$('#createdate').datetimepicker({format: "M d Y, H:i:s",});

		$('.tb_datatable').DataTable({
			"order": [[0, "desc"]],
			"columnDefs": [{targets: [2, 5], orderable: false}]
		});
	});
</script>
