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

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

<xf:if is="$ads is not empty">
	<xf:form action="{{ link('advertising/toggle') }}" class="block" ajax="true">
		<div class="block-outer">
			<xf:macro template="filter_macros" name="quick_filter" arg-key="advertising" arg-class="block-outer-opposite" />
		</div>
		<div class="block-container">
			<div class="block-body">
				<xf:datalist>
					<xf:foreach loop="$positions" key="$positionId" value="$position">
						<xf:if is="{$ads.{$positionId}} is not empty">
							<tbody class="dataList-rowGroup">
								<xf:datarow
									colspan="3"
									label="{$position.title}"
									explain="{$position.description|raw}"
									rowtype="subsection"
									rowclass="dataList-row--noHover" />
								<xf:foreach loop="{$ads.{$positionId}}" value="$ad">
									<xf:datarow
										label="{$ad.title}"
										href="{{ link('advertising/edit', $ad) }}"
										delete="{{ link('advertising/delete', $ad) }}">

										<xf:toggle name="active[{$ad.ad_id}]" selected="$ad.active"
											class="dataList-cell--separated" submit="true"
											tooltip="{{ phrase('enable_disable_x', {'title': $ad.title}) }}" />
									</xf:datarow>
								</xf:foreach>
							</tbody>
						</xf:if>
					</xf:foreach>
				</xf:datalist>
				<div class="block-footer">
					<span class="block-footer-counter">{{ display_totals($totalAds) }}</span>
				</div>
			</div>
		</div>
	</xf:form>
<xf:else />
	<div class="blockMessage">{{ phrase('no_items_have_been_created_yet') }}</div>
</xf:if>

<xf:macro template="option_macros" name="option_form_block" arg-options="{$options}" />