<style>
	#mcp-memos-filters label {
		font-weight: bold;
	}

	#mcp-memos-filters .mw-100px {
		min-width: 100px;
	}

	.filter-container {
		display: flex;
		align-items: flex-start;
		flex-wrap: wrap;
	}

	.filter-container>div {
		width: 165px;
	}

	.filter-container>div:not(:last-child) {
		margin-right: 15px;
	}
</style>
<form id="mcp-memos-filters" method="GET" action="{{ route('mcp.memos') }}" class="filter-container" v-cloak>
	<!-- DATE	 -->
	<div>
		<div class="form-group">
			<label>Date:</label>
			<select name="date_category" class="form-control input-sm" v-model="filters.date_category">
				<option value="">All</option>
				<option value="EXACTLY">Exactly</option>
				<option value="LESS_THAN">Less Than</option>
				<option value="GREATER_THAN">Greater Than</option>
				<option value="BETWEEN">Between</option>
				<option value="NOT_BETWEEN">Not Between</option>
			</select>
			<div v-show="filters.date_category" class="mt-2">
				<div>
					<input name="date_value_1" v-model="filters.date_value_1" type="date" class="form-control input-sm" />
				</div>
				<div v-show="filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN'" class="mt-2">
					<input name="date_value_2" v-model="filters.date_value_2" type="date" class="form-control input-sm" />
				</div>
			</div>
		</div>
	</div>
	<!-- STATUS -->
	<div>
		<div class="form-group">
			<label>Category:</label>
			<select name="category" class="form-control input-sm" v-model="filters.category">
				<option value="">All</option>
				<option value="Incoming Call">Incoming Call</option>
				<option value="Outgoing Call">Outgoing Call</option>
				<option value="Call Unspecified">Call Unspecified</option>
				<option value="Other">Other</option>
			</select>
		</div>
	</div>

	<div>
		<div class="form-group">
			<label>&nbsp;</label>
			<div class="d-flex">
				<button type="submit" v-on:click.prevent="doSubmit()" class="btn btn-primary btn-sm mr-2"><i class="fas fa-filter"></i> Filter</button>
				<a href="#" v-on:click.prevent="fastLoad('{{route('mcp.memos')}}')" class="btn btn-link btn-sm text-danger">Clear Filters</a>
			</div>
		</div>
	</div>
</form>
<?php
$loadedFilters = @$filters;
$allFilterKeys = [
	'date_category',
	'date_value_1',
	'date_value_2',
	'category'
];
for ($i = 0; $i < count($allFilterKeys); $i++) {
	if (!isset($loadedFilters[$allFilterKeys[$i]]) || !$loadedFilters[$allFilterKeys[$i]]) {
		$loadedFilters[$allFilterKeys[$i]] = '';
	}
}
?>
<script>
	(function() {
		function init() {
			window.apapp = new Vue({
				el: '#mcp-memos-filters',
				delimiters: ['@{{', '}}'],
				data: {
					filters: <?= json_encode($loadedFilters) ?>
				},
				methods: {
					doSubmit: function() {
						fastLoad('{{ route("mcp.memos") }}?' + $('#mcp-memos-filters').serialize());
						return false;
					},
					init: function() {

					}
				},
				mounted: function() {
					this.init();
				},
			});
		}
		addMCInitializer('mcp-memos-filters', init, '#mcp-memos-filters');
	})();
</script>