{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
<H1><span class="bold">{$layout.pagetitle}</span></H1>
<FORM name="reload" method="POST" action="?m=reload&amp;setreloads">
<INPUT type="submit" class="hiddenbtn">
<TABLE class="lmsbox">
    <THEAD>
	<TR>
		<TD>
			<div class="bold" style="float:left">
				{trans("Select hosts for configuration reload:")}
			</div>
			<div id="reloadtxt" class="bold" style="display:none; float:right">
				{trans("Reload configuration in:")}
				<span id="reloadtimer"></span>
			</div>
		</TD>
	</TR>
    </THEAD>
    <TBODY>
	<TR>
		<TD width="100%">
			<TABLE class="lmsbox-inner lms-ui-background-cycle">
				<COLGROUP>
					<COL style="width: 1%;">
					<COL style="width: 96%;">
					<COL style="width: 1%;">
					<COL style="width: 1%;">
					<COL style="width: 1%;">
				</COLGROUP>
				<THEAD>
				<TR>
					<TD class="bold nobr">
						<IMG src="img/host.gif" ALT=""> {trans("Name:")}
					</TD>
					<TD class="nobr">{trans("Description:")}</TD>
					<TD class="text-center nobr">{trans("Last Reload:")}</TD>
					<TD class="text-center nobr">{trans("Status:")}</TD>
					<TD></TD>
				</TR>
				</THEAD>
				<TBODY class="lms-ui-multi-check">
				{foreach $hosts as $host}
				<TR class="highlight">
					<TD class="bold nobr">
						<IMG src="img/host.gif" ALT=""> {$host.name}
					</TD>
					<TD>{$host.description}</TD>
					<TD class="text-center nobr">
						{if $host.lastreload}{$host.lastreload|date_format:"Y-m-d H:i"}{else}-{/if}
					</TD>
					<TD class="text-center nobr">
						{if $host.reload==1}{trans("waiting")}
						{elseif $host.reload==0}{trans("OK")}
						{else}{trans("unknown")}{/if}
					</TD>
					<TD>
						<INPUT TYPE="checkbox" NAME="hosts[]" class="lms-ui-multi-check" id="{$host.id}" VALUE="{$host.id}"{if $host.reload} checked{/if}>
					</TD>
				</TR>
				{foreachelse}
				<tr>
					<td colspan="5" class="empty-table">
						{trans("No such hosts in database.")}
					</td>
				</tr>
				{/foreach}
				<TR class="lms-ui-button-panel">
					<TD colspan="2" class="nobr">
						<label>
							<INPUT TYPE="checkbox" NAME="allbox" class="lms-ui-multi-check-all" VALUE="1">
							{trans("Check All")}
						</label>
					</TD>
					<TD colspan="3" class="buttons">
						<A href="javascript:document.reload.submit();">{trans("Submit")} <IMG src="img/save.gif" ALT=""></A>
					</TD>
				</TR>
				</TBODY>
			</TABLE>
		</TD>
	</TR>
    </TBODY>
</TABLE>
</FORM>
{if $serverTime}
<SCRIPT type="text/javascript">
<!--

	var serverTime = new Date("{$serverTime}");
	var timerOn = false;
{foreach $hosts as $host}
	{if $host.reload==1}timerOn=true;{/if}
{/foreach}
	var timer;
	var userDate = new Date();

	function ShowSeconds()
	{
		var serverTimeMinute = new Date(serverTime.getFullYear(),serverTime.getMonth(),serverTime.getDate(),serverTime.getHours(),serverTime.getMinutes(),Math.floor((serverTime.getSeconds()+59)/60)*60);
		var serverTimeDiff = serverTimeMinute-serverTime;
		serverTimeDiff=Math.round((serverTimeDiff+(userDate-(new Date())))/1000);
		if (serverTimeDiff>=0)
		{
			document.getElementById("reloadtxt").style.display='inline';
			document.getElementById("reloadtimer").innerHTML=" "+serverTimeDiff+" s";
			timer=setTimeout("ShowSeconds()",1000);
		}
		else
			window.location.reload();
	}

	if (timerOn && typeof(serverTime) != 'undefined')
		ShowSeconds();

//-->
</SCRIPT>
{/if}
{/block}
