<div class="row insights_widget" id="SectionAuditTable">

	<div class="col-lg-10 col-md-9 col-sm-8">
		<div class="card">
			<div class="card-header">
				<h5 class="card-title">Audit Trail</h5>
				<h6 class="card-subtitle mb-2 text-muted"></h6>
			</div>
			<div class="card-body">

				<div id="TableAuditTrail"></div>

			</div>
		</div>
	</div>

	<div class="col-lg-2 col-md-3 col-sm-4">

		<div id="AuditFilter" class="table-side-filter">

		<h6 class="mt-3">{{ strings.title_filter_form }}</h6>
		<div class="" id="">
			<form id="AuditFilterForm" autocomplete="off">
				<div class="form-group">
					<label for="_fContext">Context</label>
					<select id="_fContext" name="fContext" class="form-control">
						{% for context_key,context_name in vars.contexts_for_select %}
							<option value="{{ context_key }}">{{ context_name }}</option>
						{% endfor %}
					</select>
				</div>

				<div class="form-group">
					<label for="_fIp">IP Address</label>
					<select id="_fIp" name="fIp" class="form-control">
						<option value="">-- select --</option>
						{% for unique_ip in vars.unique_ips %}
							<option value="{{ unique_ip }}">{{ unique_ip }}</option>
						{% endfor %}
					</select>
				</div>
				<div class="form-group">
					<label class="form-check-label" for="_fExludeYou" title="Exclude Your IP From Results">
						Exclude Your Current IP?</label>
					<input type="checkbox" id="_fExludeYou" name="fExludeYou" value="Y"
						   class="form-control" />
				</div>

				<div class="form-group">
					<label for="_fUsername">Username (ignores 'Logged-In' filter)</label>
					<select id="_fUsername" name="fUsername" class="form-control">
						<option value="">-- select --</option>
						{% for uniq_user in vars.unique_users %}
							<option value="{{ uniq_user }}">{{ uniq_user }}</option>
						{% endfor %}
					</select>
					<small id="fUsernameHelp" class="form-text text-muted">
						Providing a username will cause the 'logged-in' filter to be ignored.
					</small>
				</div>

				<div class="form-group">
					<label for="_fLoggedIn">Logged-In?</label>
					<select id="_fLoggedIn" name="fLoggedIn" class="form-control">
						<option value="-1" selected>-- select --</option>
						<option value="1">Yes</option>
						<option value="0">No</option>
					</select>
				</div>

				<div class="form-group input-daterange">
					<label class="form-label" for="_fFromDate" title="Show results since...">
						From:</label>
					<input type="text" class="form-control date-picker" id="_fDateFrom"
						   name="fDateFrom" value="" placeholder="YYYY-MM-DD">
					<div class="input-group-addon">To:</div>
					<input type="text" class="form-control date-picker" id="_fDateTo"
						   name="fDateTo" value="" placeholder="YYYY-MM-DD">
				</div>
				
				<div class="form-group text-right">
					<input id="SubmitForm" href="#" class="btn btn-info" type="submit"
						   value="Apply Filters" />
					<a id="ClearForm" href="#" class="btn btn-link">Clear Filters</a>
				</div>

			</form>
		</div>
		</div>
	</div>

</div>

<script>
	var $oTableAuditTrail = jQuery( '#TableAuditTrail' ).icwpWpsfAjaxTable(
		{
			'ajax_render':{{ ajax.render_table_audittrail|raw }}
		}
	);
	jQuery( document ).icwpWpsfTableWithFilter(
		{
			'table': $oTableAuditTrail,
			'selector_filter_form': 'form#AuditFilterForm'
		}
	);
	jQuery( '#SectionAuditTable' ).icwpWpsfTableActions(
		{
			'table': $oTableAuditTrail,
			'custom_actions_ajax': {
				'item_addparamwhite': {{ ajax.item_addparamwhite|raw }}
			}
		}
	);

	var $oDataPickers = jQuery( '.date-picker' );
	$oDataPickers.datepicker(
		{
			autoclose: true,
			clearBtn: true,
			format: "yyyy-mm-dd",
			language: "az",
			maxViewMode: 2
		}
	);


</script>