<div class="header">
	<a href="javascript:void(0)" class="btn btn-default" id="showFilterBtn" style="margin-left:15px">
		<i class="fa fa-edit button"></i>
		<?= __("Show Filter") ?>
	</a>
	<button id="expandBtn" type="button" class="btn btn-default" onclick="expandAllHistory()"><?= __('Expand all') ?></button>
	<div style ="clear:both"></div>
	<?php
		echo $this->Form->create("Log", array('id' => 'FilterForm'));
		echo $this->Form->input('keyword');
		echo $this->Form->input('administrator');
		echo $this->Form->input('type', array('type' => 'select', 'options' => $types));
		echo $this->Form->input('model', array('type' => 'select', 'options' => $models));
		echo $this->Form->close('filter');
	?>
</div>

<div class="index">
	<?php if(!empty($logs)) { ?>

		<div class="table-options clearfix">
			<?= $this->element('index/paginator', array('showAll' => false)) ?>
		</div>

		<?php if(empty($header)) { ?>
			<div class="clear"></div>
		<?php } ?>
			<?php foreach($logs as $log) { ?>
				<?= $this->Format->showLog($log) ?>
			<?php } ?>
		<?= $this->element('index/paginator', array('showAll' => false)) ?>
	<?php } else { ?>
		<div style="text-align:center"><?= __('No records found') ?></div>
	<?php } ?>
</div>

<script type="text/javascript">

	$("#showFilterBtn").click(function() {
		$('#FilterForm').slideToggle(
			'fast',
			function() {
				$('#showFilterBtn').html($('#FilterForm').is(':visible') ? '<i class="fa fa-edit button"></i> <?= __("Hide Filter") ?>' : '<i class="fa fa-edit button"></i> <?= __("Show Filter") ?>');
				$('#FilterForm').find('input[type=text]:first').focus();
		});
	});

	function toggleHistory(param) {
		$("div.view-list").hide();
		$("div.view-"+param).show();
	}

	function showDetails(id) {
		if($(".log-history-item#history-item-"+id).is(":visible")) {
			$(".log-history-item#history-item-"+id).hide();
		} else {
			$(".log-history-item#history-item-"+id).fadeToggle('fast');
		}
	}

	function expandAllHistory() {

		var btnText = $("#expandBtn").text();

		if(btnText == '<?= __("Expand all");?>') {
			$(".log-history-item").show('fast');
			$("#expandBtn").text('<?= __("Collapse all");?>');
		} else {
			$(".log-history-item").hide('fast');
			$("#expandBtn").text('<?= __("Expand all");?>');
		}
	}
</script>
