<xf:title>{{ phrase('expired_user_upgrades') }}{{ $userUpgrade ? ': ' . $userUpgrade.title : '' }}</xf:title>

<xf:form action="{{ link('user-upgrades/expired', $userUpgrade) }}" class="block">
	<div class="block-container">
		<div class="block-body">
			<xf:formrow label="{{ phrase('filter_by_user') }}" rowtype="input">
				<xf:textbox name="username" class="input--inline" ac="single" />
				<xf:button type="submit">{{ phrase('filter') }}</xf:button>
			</xf:formrow>
		</div>
	</div>
</xf:form>

<xf:if is="$expiredUpgrades is not empty">
	<div class="block">
		<div class="block-container">
			<div class="block-body">
				<xf:datalist data-xf-init="responsive-data-list">
					<xf:datarow rowtype="header">
						<xf:cell><a href="{{ link('user-upgrades/expired', $userUpgrade, {'order': 'username', 'direction': ($linkParams.order == 'username' && $linkParams.direction == 'desc') ? 'asc' : 'desc'} + $linkParams) }}">{{ phrase('user') }}</a></xf:cell>
						<xf:cell>{{ phrase('upgrade_title') }}</xf:cell>
						<xf:cell>{{ phrase('payment_profile') }}</xf:cell>
						<xf:cell><a href="{{ link('user-upgrades/expired', $userUpgrade, {'order': 'start_date', 'direction': ($linkParams.order == 'start_date' && $linkParams.direction == 'desc') ? 'asc' : 'desc'} + $linkParams) }}">{{ phrase('start_date') }}</a></xf:cell>
						<xf:cell><a href="{{ link('user-upgrades/expired', $userUpgrade, {'order': 'end_date', 'direction': ($linkParams.order == 'end_date' && $linkParams.direction == 'desc') ? 'asc' : 'desc'} + $linkParams) }}">{{ phrase('end_date') }}</a></xf:cell>
					</xf:datarow>
					<xf:foreach loop="$expiredUpgrades" value="$expiredUpgrade">
						<xf:datarow rowclass="dataList-row--noHover">
							<xf:cell>
								<xf:username user="{$expiredUpgrade.User}" defaultname="{{ phrase('unknown_user') }}" href="{{ link('users/edit', $expiredUpgrade.User) }}" />
							</xf:cell>
							<xf:cell>
								<a href="{{ link('user-upgrades/edit', $expiredUpgrade.Upgrade) }}">{$expiredUpgrade.Upgrade.title}</a>
							</xf:cell>
							<xf:cell>
								<xf:set var="$paymentProfile" value="{$expiredUpgrade.PurchaseRequest.PaymentProfile}" />
								<xf:if is="$paymentProfile">
									<a href="{{ link('payment-profiles/edit', $paymentProfile) }}">{$paymentProfile.title}</a>
								<xf:else />
									{{ phrase('n_a') }}
								</xf:if>
							</xf:cell>
							<xf:cell><xf:date time="{$expiredUpgrade.start_date}" /></xf:cell>
							<xf:cell>{{ $expiredUpgrade.end_date ? date($expiredUpgrade.end_date) : phrase('permanent') }}</xf:cell>
						</xf:datarow>
					</xf:foreach>
				</xf:datalist>
			</div>
			<div class="block-footer">
				<span class="block-footer-counter">{{ display_totals($expiredUpgrades, $totalExpired) }}</span>
			</div>
		</div>

		<xf:pagenav page="{$page}" perpage="{$perPage}" total="{$totalExpired}"
			link="user-upgrades/expired" data="{$userUpgrade}" params="{$linkParams}"
			wrapperclass="block-outer block-outer--after" />
	</div>
<xf:else />
	<div class="blockMessage">{{ phrase('no_results_found') }}</div>
</xf:if>