{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/settings.gif" alt=""> <B>{trans("Name:")}</B>
		</TD>
		<TD align="right" WIDTH="1%" NOWRAP>
			{trans("Host:")}
		</TD>
		<TD align="right" WIDTH="1%" NOWRAP>
			{trans("Priority:")}
		</TD>
		<TD align="right" WIDTH="1%" NOWRAP>
			{trans("Module:")}<BR>
			{trans("Crontab:")}
		</TD>
		<TD WIDTH="95%">
			{trans("Description:")}
		</TD>
		<TD WIDTH="1%" nowrap>
			<A href="?m=daemoninstanceadd&amp;hostid={$hostid}">{trans("Add instance")} <IMG src="img/save.gif" alt=""></A>
		</TD>
	</TR>
	<TR>
		<TD colspan="6">
			<FORM method="GET" action="?m=daemoninstancelist" name="filter">
				<INPUT type="submit" class="hiddenbtn">
				<INPUT type="HIDDEN" name="m" value="daemoninstancelist">
				<B>{trans("Filter:")} </B> {trans("Host:")}
				<SELECT size="1" name="id" OnChange="document.filter.submit();">
					<OPTION value="0"{if ! $hostid} SELECTED{/if}>{trans("— all hosts —")}</OPTION>
					{section name=hosts loop=$hosts}
					<OPTION value="{$hosts[hosts].id}"{if $hosts[hosts].id == $hostid} SELECTED{/if}>{$hosts[hosts].name}</OPTION>
					{/section}
				</SELECT>
			</FORM>
		</TD>
	</TR>
    </THEAD>
    <TBODY>
	{cycle values="light,lucid" print=false}
	{foreach from=$instancelist item=instance}
	<TR class="highlight {cycle}{if $instance.disabled} blend{/if}" data-name="{$instance.name}">
		<TD onClick="return self.location.href='?m=daemoninstanceview&amp;id={$instance.id}';" nowrap>
			<IMG src="img/settings.gif" alt="">
			<B>{$instance.name}</B>
		</TD>
		<TD align="right" onClick="return self.location.href='?m=daemoninstanceview&amp;id={$instance.id}';">
			{$instance.hostname}
		</TD>
		<TD align="right" onClick="return self.location.href='?m=daemoninstanceview&amp;id={$instance.id}';">
			{$instance.priority}
		</TD>
		<TD align="right" onClick="return self.location.href='?m=daemoninstanceview&amp;id={$instance.id}';" nowrap>
			{$instance.module}<BR>{$instance.crontab}
		</TD>
		<TD onClick="return self.location.href='?m=daemoninstanceview&amp;id={$instance.id}';">
			{$instance.description}
		</TD>
		<TD align="right" NOWRAP>
			<A HREF="?m=daemoninstanceview&amp;id={$instance.id}"><IMG SRC="img/view.gif" alt="{trans("Browse Configuration")}" title="{trans("Browse Configuration")}"></A>
			<A HREF="?m=daemoninstanceedit&amp;id={$instance.id}&amp;statuschange=1"><IMG SRC="img/wait.gif" alt="{if $instance.disabled}{trans("Enable")}{else}{trans("Disable")}{/if}" title="{if $instance.disabled}{trans("Enable")}{else}{trans("Disable")}{/if}"></A>
			<A HREF="?m=daemoninstanceadd&amp;id={$instance.id}"><IMG SRC="img/clone.gif" alt="{trans("Clone")}" title="{trans("Clone")}"></A>
			<A class="delete-daemoninstance" HREF="?m=daemoninstancedel&id={$instance.id}"><IMG SRC="img/delete.gif" alt="{trans("Delete")}" title="{trans("Delete")}"></A>
			<A HREF="?m=daemoninstanceedit&amp;id={$instance.id}"><IMG SRC="img/edit.gif" alt="{trans("Edit")}" title="{trans("Edit")}"></A>
		</TD>
	</TR>
	{foreachelse}
	<tr>
		<td colspan="6" class="empty-table">
			{trans("There are no instances configured.")}
		</td>
	</tr>
	{/foreach}
    </TBODY>
    <TFOOT>
	<TR>
		<TD colspan="6" align="right">
			<A href="?m=daemoninstanceadd&amp;hostid={$hostid}">{trans("Add instance")} <IMG src="img/save.gif" alt=""></A>
		</TD>
	</TR>
    </TFOOT>
</TABLE>
	<script>
		$('.delete-daemoninstance').click(function() {
			var name = $(this).closest('tr').attr('data-name');
			confirmDialog($t("Are you sure, you want to remove instance '$a' and all assigned configuration?", name), this).done(function() {
				location.href = $(this).attr('href');
			});
			return false;
		});
	</script>
{/block}
