<!--// $Id$ //-->
<table class="lmsbox">
	<colgroup>
		<col style="width: 99%;">
		<col style="width: 1%;">
	</colgroup>
	<thead>
		<tr>
			<td class="hand" onclick="showOrHide('promotionschemas');">
				{icon name="money"}
				{if empty($promotion.schemas)}{$count = 0}{else}{$count = count($promotion.schemas)}{/if}
				<strong>{t a=$count}Promotion's Schemas ($a):{/t}</strong>
			</td>
			<td class="text-right nobr">
				{button type="link-button" icon="add" label="New Schema" href="?m=promotionschemaadd&id={$promotion.id}"}
			</td>
		</tr>
	</thead>
	<tbody>
		<tr id="promotionschemas" style="display: none;">
			<td colspan="2">
				<table class="lmsbox-inner lms-ui-background-cycle">
					<colgroup>
						<col style="width: 1%;">
						<col style="width: 97%;">
						<col style="width: 1%;">
						<col style="width: 1%;">
					</colgroup>
					<thead>
						<tr class="fbottom">
							<td>
								<strong>{trans("Name")}</strong>
							</td>
							<td>
								{trans("Description")}
							</td>
							<td>
								{trans("Assignments")}
							</td>
							<td>&nbsp;</td>
						</tr>
					</thead>
					<tbody>
						{foreach $promotion.schemas as $schema}
							<TR class="highlight{if $schema.disabled} blend{/if}{if $schema.deleted} lms-ui-resource-deleted{/if}" data-name="{$schema.name|escape}">
								<td data-target-url="?m=promotionschemainfo&id={$schema.id}" class="nobr">
									<strong>{$schema.name|escape}</strong>
									{if $schema.datefrom || $schema.dateto}
										{if $schema.datefrom}
											({trans("from")} {$schema.datefrom|date_format:"Y-m-d"}{if !$schema.dateto}){/if}
										{/if}
										{if $schema.dateto}
											{if !$schema.datefrom}({/if}{trans("to")} {$schema.dateto|date_format:"Y-m-d"})
										{/if}
									{/if}
								</td>
								<td data-target-url="?m=promotionschemainfo&id={$schema.id}">
									{$schema.description|escape}
								</td>
								<td>
									{$schema.assignments|default:"-"}
								</td>
								<td class="nobr">
									{if !$schema.deleted}
										{if $schema.disabled}
											{button type="link" icon="disconnected" tip="Enable" href="?m=promotionschemaset&id={$schema.id}&access={$schema.disabled}"}
										{else}
											{button type="link" icon="connected" tip="Disable" href="?m=promotionschemaset&id={$schema.id}&access={$schema.disabled}"}
										{/if}
									{/if}
									{if !$schema.deleted || !$schema.assignments}
										{button type="link" class="delete-promotion" href="?m=promotionschemadel&id={$schema.id}"
											icon="delete" tip="Delete"}
									{/if}
									{button type="link" href="?m=promotionschemaclone&id={$schema.id}" icon="clone" tip="Clone"}
									{if !$schema.deleted}
										{button type='link' icon="edit" href="?m=promotionschemaedit&id={$schema.id}" tip="Edit schema"}
									{/if}
									{button type="link" icon="view" href="?m=promotionschemainfo&id={$schema.id}" tip="Info"}
								</td>
							</TR>
						{foreachelse}
							<tr>
								<td colspan="4" class="empty-table">
									{trans("This promotion hasn't got any schemas.")}
								</td>
							</tr>
						{/foreach}
					</tbody>
				</table>
			</td>
		</tr>
	</tbody>
</table>

<script>

	if (getCookie('promotionschemas') == '1') {
		$('#promotionschemas').show();
	}

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

</script>
