{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
<h1>{$layout.pagetitle}</h1>
<table class="lmsbox lms-ui-background-cycle">
	<colgroup>
		<col style="width: 1%;">
		<col style="width: 1%;">
		<col style="width: 97%;">
		<col style="width: 1%;">
	</colgroup>
	<thead>
		<tr>
			<td class="nobr">
				{icon name="location"}
				<strong>{trans("Name")}</strong>
			</td>
			<td class="text-right nobr">{trans("ID")}</td>
			<td class="text-left nobr">{trans("Description")}</td>
			<td class="text-right nobr">
				{button icon="save" label="Add state" href="?m=stateadd"}
			</td>
		</tr>
		{if $listdata.total != 0}
			<tr>
				<td class="lms-ui-pagination" colspan="4">
					{include file="scroller.html" loop=$statelist}
				</>
			</tr>
		{/if}
	</thead>
	<tbody>
		{foreach $statelist as $state}
			<tr class="highlight" data-name="{$state.name|escape}">
				<td class="nobr" data-target-url="?m=stateedit&id={$state.id}">
					{icon name="location"}
					<strong>{$state.name|escape}</strong>
				</td>
				<td class="text-right nobr" data-target-url="?m=stateedit&id={$state.id}">
					(#{$state.id})
				</td>
				<td class="text-left" data-target-url="?m=stateedit&id={$state.id}">
					{$state.description|escape|replace:"\n":"<BR>"}
				</td>
				<td class="text-right nobr">
					{button type="link" class="delete-state" data_href="?m=statedel&id={$state.id}"
						icon="delete" tip="Delete"}
					{button type="link" href="?m=stateedit&id={$state.id}" icon="edit" tip="Edit"}
				</td>
			</tr>
		{foreachelse}
			<tr>
				<td colspan="4" class="empty-table">
					{trans("No such states in database.")}
				</td>
			</tr>
		{/foreach}
	</tbody>
	<tfoot>
		{if $listdata.total != 0}
			<tr>
				<td class="lms-ui-pagination" colspan="4">
					{include file="scroller.html" loop=$statelist}
				</td>
			</tr>
		{/if}
		<tr>
			<td colspan="4" class="text-right">
				{button icon="save" label="Add state" href="?m=stateadd"}
			</td>
		</tr>
	</tfoot>
</table>
<script>

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

</script>
{/block}
