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

<xf:form action="{{ link('tools/file-check') }}" class="block">
	<div class="block-container">
		<div class="block-body">
			<xf:inforow rowtype="close">{{ phrase('file_health_check_description', {'button': phrase('proceed')}) }}</xf:inforow>
		</div>
		<xf:submitrow submit="{{ phrase('proceed...') }}" rowtype="simple" />
	</div>
</xf:form>

<xf:if is="$fileChecks is not empty">
	<div class="block">
		<div class="block-container">
			<h3 class="block-header">{{ phrase('file_health_check_results') }}</h3>
			<div class="block-body">
				<xf:macro id="file_check_list" arg-fileChecks="{$fileChecks}" />
			</div>
			<div class="block-footer">
				<span class="block-footer-counter">{{ display_totals($fileChecks, $total) }}</span>
			</div>
		</div>
		<xf:pagenav page="{$page}" perpage="{$perPage}" total="{$total}"
			link="tools/file-check"
			wrapperclass="block-outer block-outer--after" />
	</div>
</xf:if>

<xf:macro id="file_check_list" arg-fileChecks="!">
	<xf:datalist data-xf-init="responsive-data-list">
		<xf:datarow rowtype="header">
			<xf:cell>{{ phrase('check_date') }}</xf:cell>
			<xf:cell>{{ phrase('check_state') }}</xf:cell>
			<xf:cell>{{ phrase('missing') }}</xf:cell>
			<xf:cell>{{ phrase('unexpected_contents') }}</xf:cell>
			<xf:cell>{{ phrase('total_checked') }}</xf:cell>
			<xf:cell> </xf:cell>
		</xf:datarow>

		<xf:foreach loop="$fileChecks" value="$fileCheck" i="$i">
			<xf:datarow rowclass="{{ $i == 1 ? 'dataList-row--highlighted' : '' }}">
				<xf:cell>
					<xf:date time="$fileCheck.check_date" />
				</xf:cell>
				<xf:cell>
					<xf:if is="$fileCheck.check_state == 'success'">
						{{ phrase('success') }}
					<xf:elseif is="$fileCheck.check_state == 'failure'" />
						{{ phrase('failed') }}
					<xf:elseif is="$fileCheck.check_state == 'pending'" />
						{{ phrase('pending') }}
					</xf:if>
				</xf:cell>

				<xf:if is="$fileCheck.check_state == 'pending'">
					<xf:cell>{{ phrase('n_a') }}</xf:cell>
					<xf:cell>{{ phrase('n_a') }}</xf:cell>
					<xf:cell>{{ phrase('n_a') }}</xf:cell>
					<xf:action></xf:action>
				<xf:else />
					<xf:cell>{$fileCheck.total_missing|number}</xf:cell>
					<xf:cell>{$fileCheck.total_inconsistent|number}</xf:cell>
					<xf:cell>{$fileCheck.total_checked|number}</xf:cell>
					<xf:action href="{{ link('tools/file-check/results', $fileCheck) }}">{{ phrase('results') }}</xf:action>
				</xf:if>
			</xf:datarow>
		</xf:foreach>
	</xf:datalist>
</xf:macro>