<style>
	#admin-management-stats-filters label {
		font-weight: bold;
	}

	#admin-management-stats-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: 10px;
	}
	.sm-section {
		width: 125px !important;
		margin-bottom: 10px;
	}
</style>
<form id="admin-management-stats-filters" method="GET" action="{{ route('management-stats') }}" class="filter-container" v-cloak>
	<div class="sm-section">
		<div class="">
			<label>Start Month:</label>
			<input type="date" name="start_date" class="form-control input-sm" v-model="filters.start_date">
		</div>
	</div>

	<div class="sm-section">
		<div class="">
			<label>End Month:</label>
			<input type="date" name="end_date" class="form-control input-sm" v-model="filters.end_date">
		</div>
	</div>


	<div>
		<div class="">
			<label>&nbsp;</label>
			<div class=" d-flex">
				<button type="button" 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('management-stats')}}')" class="btn btn-link btn-sm text-danger">Clear</a>
			</div>
		</div>
	</div>
</form>

<?php
$loadedFilters = @$filters;
$allFilterKeys = [
	'start_date',
	'end_date',
];
for ($i=0; $i < count($allFilterKeys); $i++) {
	if (!isset($loadedFilters[$allFilterKeys[$i]]) || !$loadedFilters[$allFilterKeys[$i]]) {
		$loadedFilters[$allFilterKeys[$i]] = '';
	}
}
?>
<script>
	(function() {
		function init() {
			new Vue({
				el: '#admin-management-stats-filters',
				delimiters: ['@{{', '}}'],
				data: {
					filters: <?= json_encode($loadedFilters) ?>
				},
				methods: {
					init: function() {

					},
					doSubmit: function() {
						fastLoad("{{ route('management-stats') }}?" + $('#admin-management-stats-filters').serialize());
						return false;
					}
				},
				mounted: function() {
					console.log(this.filters);
					this.init();
				},
			});


		}
		addMCInitializer('admin-management-stats-filters', init, '#admin-management-stats-filters');
	})();
</script>
