<!-- $Id$ -->
<style>

	#attachment-list {
		margin-right: 1em;
		width: auto;
	}

	#attachment-list thead,
	#attachment-list tbody {
		border-width: 1px;
		border-style: dotted;
	}

	#attachment-list tbody {
		border-top-style: none;
	}

</style>

<table class="lmsbox">
	<colgroup>
		<col style="width: 1%;">
		<col style="width: 1%;">
		<col style="width: 98%;">
	</colgroup>
	<thead>
		<tr>
			<td>
				{icon name="money"}
			</td>
			<td colspan="2">
				<strong>{$promotion.name|escape} ({$promotion.id|string_format:"%04d"})</strong>
				{if $promotion.deleted} <span class="lms-ui-alert">({trans("deleted promotion")})</span>{/if}
			</td>
		</tr>
	</thead>
	<tbody>
		{if $promotion.datefrom || $promotion.dateto}
			<tr>
				<td>
					{icon name="period"}
				</td>
				<td class="nobr" colspan="2">
					{if $promotion.datefrom}
						{trans("from")} {$promotion.datefrom|date_format:"Y-m-d"}
					{/if}
					{if $promotion.dateto}
						{trans("to")} {$promotion.dateto|date_format:"Y-m-d"}
					{/if}
				</td>
			</tr>
		{/if}
		<tr>
			<td>
				{if $promotion.disabled}
					{button type="link" icon="disconnected" tip="Enable" href="?m=promotionset&id={$promotion.id}&access={$promotion.disabled}"}
				{else}
					{button type="link" icon="connected" tip="Disable" href="?m=promotionset&id={$promotion.id}&access={$promotion.disabled}"}
				{/if}
			</td>
			<td class="nobr" colspan="2">
				{if $promotion.disabled}{trans("disabled")}{else}{trans("enabled")}{/if}
			</td>
		</tr>
		{if $promotion.description}
			<tr>
				<td>
					{icon name="optional-info"}
				</td>
				<td colspan="2">
					<table width="100%" cellpadding="5">
						<tr><td class="fall superlight">
							{$promotion.description|escape|replace:"\n":"<BR>"}
						</td></tr>
					</table>
				</td>
			</tr>
		{/if}
		{if !empty($promotion.attachments)}
			<tr>
				<td class="valign-top">
					{icon name="attachment"}
				</td>
				<td colspan="2">
					<table class="lmsbox" id="attachment-list">
						<thead>
							<tr>
								<td class="bold nobr">
									{trans("File name")}
								</td>
								<td class="bold nobr">
									{trans("Text label")}
								</td>
								<td class="bold nobr">
									{trans("Default checked")}
								</td>
							</tr>
						</thead>
						<tbody>
							{foreach $promotion.attachments as $attachmentid => $attachment}
								<tr>
									<td>
										{documentview
											id="{$promotion.id}-{$attachment.id}"
											type=$attachment.contenttype
											name=$attachment.filename
											url="?m=promotionattachmentview&promotionid={$promotion.id}&attachmentid={$attachment.id}"
											external=true
										}
									</td>
									<td>
										{$attachment.label|escape}
									</td>
									<td>
										{if !empty($attachment.checked)}
											{icon name="checked"}
										{/if}
									</td>
								</tr>
							{/foreach}
						</tbody>
					</table>
				</td>
			</tr>
		{/if}
		<tr>
			<td colspan="3" class="lms-ui-box-buttons">
				{if !$promotion.deleted}
					{button icon="edit" label="Edit" href="?m=promotionedit&id={$promotion.id}"}
				{/if}
				{if !$promotion.deleted || !$promotion.assignments}
					{button icon="delete" label="Delete" id="delete-promotion" data_href="?m=promotiondel&id={$promotion.id}"}
				{/if}
			</td>
		</tr>
	</tbody>
</table>

<script>

	$(function() {
		$('#delete-promotion').click(function () {
			confirmDialog($t("Are you sure, you want to delete this promotion?"), this).done(function () {
				location.href = $(this).attr('data-href');
			});
			return false;
		});
	});

</script>
