{block content}
	{var $exportFormat = $projectSetting['exportFormat']}

	<div class="span3">
		{include '@menu.latte'}
	</div>

	<div class="span9">
		<div class="box-content">
			<div class="filter">
				{form filterForm, class => 'form-inline'}
					{label year /}&nbsp;{input year, class => 'input-small'}&nbsp;&nbsp;
					{label month /}&nbsp;{input month, class => 'input-small'}&nbsp;&nbsp;
					{label week /}&nbsp;{input week, class => 'input-small'}&nbsp;&nbsp;
					{input submit}
				{/form}
			</div>

			<div n:foreach="$flashes as $flash" class="alert alert-{$flash->type}">{$flash->message}</div>

			<div class="alert alert-info alert-no-margin" n:if="$orderSumMonth <= 0">
				V daném období, dle nastaveného roku a měsíce, nevznikly žádné objednávky.
			</div>

			<div class="alert alert-info alert-no-margin" n:if="$orderSumWeek <= 0">
				V daném období, dle nastaveného roku a týdne, nevznikly žádné objednávky.
			</div>

			<table class="table table-striped" n:if="$orderSumMonth > 0">
				<thead>
					<tr>
						<th style="width: 10%;">Měsíc</th>
						<th style="width: 20%;">Datum</th>
						<th>Export</th>
					</tr>
				</thead>

				<tbody>
					<tr>
						<td>{$month}</td>
						<td>{$dateMonth->format('d')}.-{$dateMonth->modifyClone('last day of this month')->format('d.m.Y')}</td>
						<td>
							{var $name = "{$year}-m{$month}_export"}
							<a n:href="generateOrderReport!, from => $dateMonth->format('Y-m-d'), to => $dateMonth->modifyClone('last day of this month')->format('Y-m-d'), name => $name">{$name}.{$exportFormat}</a>
						</td>
					</tr>
				</tbody>
			</table>

			<table class="table table-striped" n:if="$orderSumWeek > 0">
				<thead>
					<tr>
						<th style="width: 10%;">Týden</th>
						<th style="width: 20%;">Datum</th>
						<th>Export</th>
					</tr>
				</thead>

				<tbody>
					<tr>
						<td>{$week}</td>
						<td>{$dateWeek->format('d')}.-{$dateWeek->modifyClone('+6 days')->format('d.m.Y')}</td>
						<td>
							{var $name = "{$year}-t{$week}_export"}
							<a n:href="generateOrderReport!, from => $dateWeek->format('Y-m-d'), to => $dateWeek->modifyClone('+6 days')->format('Y-m-d'), name => $name">{$name}.{$exportFormat}</a>
						</td>
					</tr>
				</tbody>
			</table>

			<table class="table table-striped" n:if="$orderSumWeek > 0">
				<thead>
					<tr>
						<th style="width: 10%;">Týden</th>
						<th style="width: 20%;">Datum</th>
						<th>Export</th>
						<th>Expedice</th>
						<th>Řidič</th>
					</tr>
				</thead>

				<tbody>
				{for $i = 0; $i < 7; $i++}
					<tr>
						{var $lineDate = $dateWeek->modifyClone("+{$i} days")}
						<td></td>
						<td style="vertical-align: middle;">{$lineDate->format('d.m.Y')}</td>
						<td>
							{var $name = "{$lineDate->format('Y-m-d')}_export"}
							<a n:href="generateOrderReport!, from => $lineDate->format('Y-m-d'), to => $lineDate->format('Y-m-d'), name => $name">{$name}.{$exportFormat}</a>
						</td>
						<td>
							{var $name = "{$lineDate->format('Y-m-d')}_export"}
							<div class="btn-group">
								<button class="btn dropdown-toggle" data-toggle="dropdown">Expedice&nbsp;<i class="caret"></i></button>

								<ul class="dropdown-menu">
									<li n:foreach="$userExpedition as $ueId => $ueName">
										{var $nameDown = ($name . '_' . \Nette\Utils\Strings::webalize($ueName))}
										<a tabindex="-1" n:href="generateOrderReport!, from => $lineDate->format('Y-m-d'), to => $lineDate->format('Y-m-d'), name => $nameDown, expedid => $ueId">{$ueName}</a>
									</li>
								</ul>
							</div>
						</td>
						<td>
							{var $name = "{$lineDate->format('Y-m-d')}_export"}
							<div class="btn-group">
								<button class="btn dropdown-toggle" data-toggle="dropdown">Řidič&nbsp;<i class="caret"></i></button>

								<ul class="dropdown-menu">
									<li n:foreach="$userDriver as $ueId => $ueName">
										{var $nameDown = ($name . '_' . \Nette\Utils\Strings::webalize($ueName))}
										<a tabindex="-1" n:href="generateOrderReport!, from => $lineDate->format('Y-m-d'), to => $lineDate->format('Y-m-d'), name => $nameDown, expedid => null, driverid => $ueId">{$ueName}</a>
									</li>
								</ul>
							</div>
						</td>
					</tr>
				{/for}
				</tbody>
			</table>
		</div>
	</div>
