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

<xf:pageaction>
	<xf:button href="{{ link('cron/add') }}" icon="add">{{ phrase('add_cron_entry') }}</xf:button>
</xf:pageaction>

<xf:if is="$entries is not empty">
	<xf:form action="{{ link('cron/toggle') }}" class="block" ajax="true">
		<div class="block-outer">
			<xf:macro id="filter_macros::quick_filter" arg-key="cron" arg-class="block-outer-opposite" />
		</div>
		<div class="block-container">
			<div class="block-body">
				<xf:datalist>
					<xf:foreach loop="$entries" value="$cron">
						<xf:datarow>
							<xf:main hash="{$cron.entry_id}" href="{{ link('cron/edit', $cron) }}"
								label="{$cron.title}"
								hint="{{ $cron.addon_id != 'XF' ? $cron.AddOn.title : '' }}">

								<xf:explain>
									<xf:if is="{$cron.active}">
										<xf:if is="{{ !$cron.addon_id OR $cron.AddOn.active }}">
											{{ phrase('next_run') . ': ' . date_time($cron.next_run)  }}
										<xf:else />
											{{ phrase('cron_entry_associated_with_inactive_add_on_cannot_run') }}
										</xf:if>
									</xf:if>
								</xf:explain>
							</xf:main>
							<xf:toggle name="active[{$cron.entry_id}]" selected="$cron.active"
								class="dataList-cell--separated" submit="true"
								tooltip="{{ phrase('enable_disable_x', {'title': $cron.title}) }}" />
							<xf:if is="{{ !$cron.addon_id OR $cron.AddOn.active }}">
								<xf:action href="{{ link('cron/run', $cron) }}" overlay="true"
									data-xf-init="tooltip" title="{{ phrase('run_now') }}"
									class="dataList-cell--iconic">
									<xf:fa icon="fa-sync" /></xf:action>
							<xf:else />
								<xf:action></xf:action>
							</xf:if>
							<xf:delete href="{{ link('cron/delete', $cron) }}" />
						</xf:datarow>
					</xf:foreach>
				</xf:datalist>
			</div>
			<div class="block-footer">
				<span class="block-footer-counter">{{ display_totals($entries) }}</span>
			</div>
		</div>
	</xf:form>
<xf:else />
	<div class="blockMessage">{{ phrase('no_items_have_been_created_yet') }}</div>
</xf:if>