<xf:title>{{ phrase('discouraged_ip_addresses') }}</xf:title>

<xf:pageaction>
	<div class="buttonGroup">
		<xf:button href="{{ link('banning/discouraged-ips/import') }}" icon="import" overlay="true" />
		<xf:if is="$discouragedIps is not empty">
			<xf:button href="{{ link('banning/discouraged-ips/export', null, {'t': csrf_token()}) }}" icon="export" />
		</xf:if>
	</div>
</xf:pageaction>

<xf:if is="$discouragedIps is not empty">
	<xf:form action="{{ link('banning/discouraged-ips/delete') }}" ajax="true" class="block">
		<div class="block-container">
			<div class="block-body">
				<xf:datalist data-xf-init="responsive-data-list">
					<colgroup>
						<col style="width: 1%">
						<col style="width: 15%">
						<col style="width: 15%">
						<col style="width: 15%">
						<col style="width: 15%">
						<col>
					</colgroup>
					<xf:datarow rowtype="header">
						<xf:cell><xf:checkbox standalone="true"><xf:option check-all="< .block-container" data-xf-init="tooltip" title="{{ phrase('select_all') }}" /></xf:checkbox></xf:cell>
						<xf:cell href="{{ link('banning/discouraged-ips', '', {'order': 'start_range', 'direction': ($direction == 'desc' || !$direction)  ? 'asc' : ''}) }}">
							{{ phrase('ip') }}
						</xf:cell>
						<xf:cell href="{{ link('banning/discouraged-ips', '', {'order': '', 'direction': ($direction == 'desc' || !$direction)  ? 'asc' : ''}) }}">
							{{ phrase('date') }}
						</xf:cell>
						<xf:cell href="{{ link('banning/discouraged-ips', '', {'order': 'last_triggered_date', 'direction': ($direction == 'desc' || !$direction)  ? 'asc' : ''}) }}">
							{{ phrase('last_triggered') }}
						</xf:cell>
						<xf:cell>{{ phrase('by') }}</xf:cell>
						<xf:cell>{{ phrase('reason') }}</xf:cell>
					</xf:datarow>
					<xf:foreach loop="$discouragedIps" value="$discouragedIp">
						<xf:datarow>
							<xf:toggle name="delete[]" value="{$discouragedIp.ip}" />
							<xf:cell class="u-ltr">{$discouragedIp.ip}</xf:cell>
							<xf:cell>{{ $discouragedIp.create_date ? date($discouragedIp.create_date) : phrase('n_a') }}</xf:cell>
							<xf:cell>
								{{ $discouragedIp.last_triggered_date ? date_dynamic($discouragedIp.last_triggered_date) : phrase('never') }}
							</xf:cell>
							<xf:cell>{{ $discouragedIp.User ? $discouragedIp.User.username : phrase('n_a') }}</xf:cell>
							<xf:cell>{{ $discouragedIp.reason ? $discouragedIp.reason : phrase('n_a') }}</xf:cell>
						</xf:datarow>
					</xf:foreach>
				</xf:datalist>
			</div>
			<div class="block-footer block-footer--split">
				<span class="block-footer-counter">{{ display_totals($discouragedIps) }}</span>
				<span class="block-footer-select"><xf:checkbox standalone="true"><xf:option check-all="< .block-container" label="{{ phrase('select_all') }}" /></xf:checkbox></span>
				<span class="block-footer-controls"><xf:button type="submit" icon="delete" /></span>
			</div>
		</div>

		<xf:pagenav page="{$page}" perpage="{$perPage}" total="{$total}" link="banning/discouraged-ips"
			params="{{ {
					'order': ($order != 'create_date' ? $order : ''),
					'direction': ($direction != 'desc' ? $direction : '')
				} }}"
			wrapperclass="block-outer block-outer--after" />
	</xf:form>
<xf:else />
	<div class="blockMessage">{{ phrase('no_ips_have_been_discouraged') }}</div>
</xf:if>

<xf:form action="{{ link('banning/discouraged-ips/add') }}" ajax="true" class="block">
	<div class="block-container">
		<h3 class="block-header">{{ phrase('add_discouraged_ip') }}</h3>
		<div class="block-body">
			<xf:textboxrow name="ip" value="{$ip}"
				label="{{ phrase('ip_to_discourage') }}"
				explain="{{ phrase('you_may_enter_partial_ip_v4_v6') }}"
				dir="ltr" />
			<xf:textboxrow name="reason" value="{$newIp}"
				label="{{ phrase('reason') }}"
				hint="{{ phrase('optional') }}" />
		</div>
		<xf:submitrow icon="save" />
	</div>
</xf:form>