<button id="btn-{{ $model ?? null }}-filters" type="button" class="btn bg-gradient-secondary btn-filter" data-toggle="modal" data-target="#modal-{{ $model ?? null }}-filters">
	<i class="fa fa-fw fa-filter"></i>
	<div id="{{ $model ?? null }}-filters-badge" class="badge bg-orange text-light" style="top: -10px; position: absolute; display:none;"><i class="fa fa-exclamation-triangle"></i></div>
</button>


@push('js')
	<script>
		var $filter = $('#{{ $model ?? null }}-table-header .btn-filter');

		$('#modal-{{ $model ?? null }}-filters').on('shown.bs.modal', function () {
			initSelect2('.select2', '#modal-{{ $model ?? null }}-filters');
		});

		$('#modal-{{ $model ?? null }}-filters .apply').click(function() {
			$('#modal-{{ $model ?? null }}-filters').modal('hide');
			var table = window.LaravelDataTables["{{ $model ?? null }}-table"];
			table.draw();
			setAlertWhenFiltered('{{ $model ?? null }}');
		})

		$('#modal-{{ $model ?? null }}-filters .reset').click(function() {
			// $('#{{ $model ?? null }}-filters').trigger("reset");
			$('#{{ $model ?? null }}-filters').closest('form').find("input[type=text], select").val("");
			$('#{{ $model ?? null }}-filters .select2').val(null).trigger("change");
		})

		setAlertWhenFiltered('{{ $model ?? null }}');

		/*
		$filter.on( 'click', function () {
			var table = window.LaravelDataTables["{{ $model ?? null }}-table"];
			// table.search($search.val()).draw();
			openModal('{{ __('Filters') }}', '{{ $route }}/getFiltersHtml', {
				onApply: function() {
					filters = $('#filters').serialize();
					console.log(filters);
					table.draw();
				}
			}); 	    	
		} );
		*/
	</script>
@endpush