<!-- $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 class="bold" colspan="2">
				{$schema.name|escape} ({$schema.id|string_format:"%04d"})
				{if $schema.deleted} <span class="lms-ui-alert">({trans("deleted promotion schema")})</span>{/if}
			</td>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>
				{icon name="calendar"}
			</td>
			<td class="nobr" colspan="2">
				{if $schema.data}{$schema.data}{else}{trans("unlimited")}{/if}
			</td>
		</tr>
		{if $schema.datefrom || $schema.dateto}
			<tr>
				<td>
					{icon name="period"}
				</td>
				<td class="nobr" colspan="2">
					{if $schema.datefrom}
						{trans("from")} {$schema.datefrom|date_format:"Y-m-d"}
					{/if}
					{if $schema.dateto}
						{trans("to")} {$schema.dateto|date_format:"Y-m-d"}
					{/if}
				</td>
			</tr>
		{/if}
		<tr>
			<td>
				<A href="?m=promotionschemaset&id={$schema.id}&access={$schema.disabled}">
					{if $schema.disabled}
						{icon name="disconnected"}
					{else}
						{icon name="connected"}
					{/if}
				</A>
			</td>
			<td class="nobr" colspan="2">
				{if $schema.disabled}{trans("disabled")}{else}{trans("enabled")}{/if}
			</td>
		</tr>
		<tr>
			<td>
				{icon name="money"}
			</td>
			<td class="nobr" colspan="2">
				<A href="?m=promotioninfo&id={$schema.pid}">{$schema.promotion|escape}</A>
			</td>
		</tr>
		{if $schema.description}
		<tr>
			<td>
				{icon name="info"}
			</td>
			<td colspan="2">
				<table width="100%" cellpadding="5">
					<tr><td class="fall superlight">
						{$schema.description|escape|replace:"\n":"<BR>"}
					</td></tr>
				</table>
			</td>
		</tr>
		{/if}
		{if !empty($schema.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 $schema.attachments as $attachmentid => $attachment}
								<tr>
									<td>
										{documentview
											id="{$schema.id}-{$attachment.id}"
											type=$attachment.contenttype
											name=$attachment.filename
											url="?m=promotionattachmentview&schemaid={$schema.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 class="lms-ui-box-buttons" colspan="3">
				{if !$schema.deleted}
					{button icon="edit" label="Edit" href="?m=promotionschemaedit&id={$schema.id}"}
				{/if}
				{if !$schema.deleted || !$schema.assignments}
					{button icon="delete" label="Delete" id="delete-promotionschema" data_href="?m=promotionschemadel&id={$schema.id}"}
				{/if}
			</td>
		</tr>
	</tbody>
</table>

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

