<style>
	#client-pro-changes-filters label {
		font-weight: bold;
	}

	#client-pro-changes-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="client-pro-changes-filters" method="GET" action="{{ route('practice-management.client-pro-changes') }}" 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>Association Type:</label>
			<select name="responsibility_type" class="form-control input-sm" v-model="filters.responsibility_type">
				<option value="">All</option>
				@foreach($associationTypes as $at)
				<option value="{{ $at }}">{{ $at }}</option>
				@endforeach
			</select>
		</div>
	</div>

	<div>
		<div class="form-group">
			<div class="old-pro-filter-container">
				<label>Old Pro:</label>
			</div>
		</div>
	</div>

	<div>
		<div class="form-group">
			<div class="new-pro-filter-container">
				<label>New Pro:</label>
			</div>
		</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('practice-management.client-pro-changes')}}')" 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',
	'responsibility_type',
	'old_pro',
	'new_pro'
];
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: '#client-pro-changes-filters',
				delimiters: ['@{{', '}}'],
				data: {
					filters: <?= json_encode($loadedFilters) ?>
				},
				methods: {
					doSubmit: function() {
						fastLoad('{{ route("practice-management.client-pro-changes") }}?' + $('#client-pro-changes-filters').serialize());
						return false;
					},
					init: function() {

					}
				},
				mounted: function() {
					this.init();

					let oldProSelect = $('<select name="old_pro" class="form-control min-width-unset input-sm" provider-search data-pro-uid="{{request()->input("old_pro")}}" provider-type="hcp"><option value="">--select--</option></select>').appendTo('.old-pro-filter-container');
					let newProSelect = $('<select name="new_pro" class="form-control min-width-unset input-sm" provider-search data-pro-uid="{{request()->input("new_pro")}}" provider-type="hcp"><option value="">--select--</option></select>').appendTo('.new-pro-filter-container');
					initProSuggest();
				},
			});


		}
		addMCInitializer('client-pro-changes-filters', init, '#client-pro-changes-filters');
	})();
</script>