{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!-- $Id$ -->
<H1>{$layout.pagetitle}</H1>
<TABLE class="lmsbox">
    <THEAD>
	<TR>
		<TD WIDTH="1%" nowrap>
			<img src="img/host.gif" alt=""><B>{trans("Name:")}</B>
		</TD>
		<TD WIDTH="1%" NOWRAP>
			{trans("ID:")}
		</TD>
		<TD WIDTH="1%" NOWRAP>
			{trans("Last Reload:")}
		</TD>
		<TD WIDTH="96%">
			{trans("Description:")}
		</TD>
		<TD WIDTH="1%" nowrap>
			<A href="?m=hostadd">{trans("Add host")} <img src="img/save.gif" alt=""></A>
		</TD>
	</TR>
    </THEAD>
    <TBODY>
	{cycle values="light,lucid" print=false}
	{foreach from=$hostlist item=host}
	<TR class="highlight {cycle}" data-name="{$host.name}">
		<TD onClick="return self.location.href='?m=hostedit&amp;id={$host.id}';" nowrap>
			<IMG src="img/host.gif" alt="">
			<B>{$host.name}</B>
		</TD>
		<TD onClick="return self.location.href='?m=hostedit&amp;id={$host.id}';">
			({$host.id|string_format:"%04d"})
		</TD>
		<TD onClick="return self.location.href='?m=hostedit&amp;id={$host.id}';" nowrap>
			{if $host.lastreload}{$host.lastreload|date_format:"Y-m-d H:i:s"}{else}-{/if}
		</TD>
		<TD onClick="return self.location.href='?m=hostedit&amp;id={$host.id}';">
			{$host.description}
		</TD>
		<TD align="right" NOWRAP>
			<A HREF="?m=hostedit&amp;id={$host.id}"><IMG src="img/edit.gif" alt="{trans("Edit")}" title="{trans("Edit")}"></A>
			<A class="delete-host" HREF="?m=hostdel&id={$host.id}"><IMG src="img/delete.gif" alt="{trans("Delete")}" title="{trans("Delete")}"></A>
		</TD>
	</TR>
	{foreachelse}
	<tr>
		<td colspan="5" class="empty-table">
			{trans("There are no hosts configured.")}
		</td>
	</tr>
	{/foreach}
        </TBODY>
        <TFOOT>
	<TR>
		<TD colspan="5" align="right">
			<A href="?m=hostadd">{trans("Add host")} <IMG src="img/save.gif" alt=""></A>
		</TD>
	</TR>
        </TFOOT>
</TABLE>
	<script>
		$('.delete-host').click(function() {
			var name = $(this).closest('tr').attr('data-name');
			confirmDialog($t("Are you sure, you want to remove host '$a' and all assigned configuration?", name), this).done(function() {
				location.href = $(this).attr('href');
			});
			return false;
		});
	</script>
{/block}
