{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
{$xajax}
<SCRIPT TYPE="text/javascript">
<!--
	function SelectAllNodes()
	{
		if (document.setwarnings.nodes.checked)
			for (var i = 0; i < document.getElementById('nodeslist').length; i++)
				document.getElementById('nodeslist').options[i].selected = true;
		else
			for (var i = 0; i < document.getElementById('nodeslist').length; i++)
				document.getElementById('nodeslist').options[i].selected = false;
	}

	function SelectAllNodes2()
	{
		document.setwarnings.nodes.checked = !document.setwarnings.nodes.checked;
		SelectAllNodes();
	}

	function switchbox(id)
	{
		if ((id.name == 'setwarnings[warnon]') && id.checked)
			document.setwarnings.elements['setwarnings[warnoff]'].checked = false;
		if ((id.name == 'setwarnings[warnoff]') && id.checked)
			document.setwarnings.elements['setwarnings[warnon]'].checked = false;
	}

	function switchbox1()
	{
		document.setwarnings.elements['setwarnings[warnon]'].checked = !document.setwarnings.elements['setwarnings[warnon]'].checked;
		switchbox(document.setwarnings.elements['setwarnings[warnon]']);
	}

	function switchbox2()
	{
		document.setwarnings.elements['setwarnings[warnoff]'].checked = !document.setwarnings.elements['setwarnings[warnoff]'].checked;
		switchbox(document.setwarnings.elements['setwarnings[warnoff]']);
	}

	function change_message_template(tmplid) {
		if (tmplid) {
			xjx.$('msgtmplid').disabled = true;
			xajax_getMessageTemplate(tmplid);
		}
	}

	function messageTemplateReceived(message) {
		var editor = tinyMCE.get(0);
		if (editor) {
			editor.setContent(message);
			xjx.$('message').value = message;
		} else {
			xjx.$('message').value = message;
		}
		xjx.$('msgtmplid').disabled = false;
	}
//-->
</SCRIPT>
<H1>{$layout.pagetitle}</H1>
<FORM NAME="setwarnings" METHOD="POST" ACTION="?m=nodewarn" id="setwarnings">
<INPUT type="submit" class="hiddenbtn">
<TABLE width="100%" cellpadding="3">
	<TR>
		<TD WIDTH="1%" VALIGN="TOP">
			<TABLE class="lmsbox">
                            <THEAD>
				<TR>
					<TD WIDTH="1%">
						<IMG SRC="img/node.gif" alt="">&nbsp;<B>{trans("Nodes:")}</B>
					</TD>
					<TD WIDTH="99%" COLSPAN="2">
						<IMG SRC="img/mail.gif" alt="">&nbsp;<B>{trans("Notice content:")}</B>
					</TD>
				</TR>
                            </THEAD>
                            <TBODY>
				<TR>
					<TD>
						<SELECT size="30" name="setwarnings[mnodeid][]" id="nodeslist" multiple {tip text="Select nodes"}>
							{section name=nodelist loop=$nodelist}
							<OPTION value="{$nodelist[nodelist].id}" {if $nodelist[nodelist].warning}CLASS="red"{/if}>{$nodelist[nodelist].name|truncate:40:"&hellip;":true} / {$nodelist[nodelist].ip} ({$nodelist[nodelist].id|string_format:"%04d"})</OPTION>
							{/section}
						</SELECT>
					</TD>
					<TD COLSPAN="2">
						<table>
							<tr>
								<td colspan="2" class="nobr">
									<label>
										{trans("Message template:")}
										<select name="setwarnings[tmplid]" id="msgtmplid" {tip trigger="msgtmplid" text="Select message template"} onChange="javascript:change_message_template(this.options[this.selectedIndex].value);">
											<option value="0">{trans("— none —")}</option>
											{foreach $messagetemplates as $msgtmpl}
											<option value="{$msgtmpl.id}">{$msgtmpl.name}</option>
											{/foreach}
										</select>
									</label>
								</td>
							</tr>
							<tr>
								<td colspan="2">
									<TEXTAREA NAME="setwarnings[message]" class="lms-ui-wysiwyg-editor" ROWS="20" COLS="75" {tip text="Enter notice content"}>{$warnmessage}</TEXTAREA>
								</td>
							</tr>
							<tr>
								<td colspan="2">
									<input type="radio" name="setwarnings[tmploper]" id="msgtmplradionone" value="1" onClick="javascript:document.getElementById('msgtmplname').style.display='none';" checked><label for="msgtmplradionone">{trans("no operation on message template")}</label><br>
									<input type="radio" name="setwarnings[tmploper]" id="msgtmplradioupdate" value="2" onClick="javascript:document.getElementById('msgtmplname').style.display='none';"><label for="msgtmplradioupdate">{trans("message template update")}</label><br>
									<input type="radio" name="setwarnings[tmploper]" id="msgtmplradionew" value="3" onClick="javascript:document.getElementById('msgtmplname').style.display='';"><label for="msgtmplradionew">{trans("message template creation")}</label>
									<input type="text" size="40" name="setwarnings[tmplname]" id="msgtmplname" style="display: none;" {tip trigger="tmplname" text="Enter name of the new message template"}>
								</td>
							</tr>
						</table>
					</TD>
				</TR>
				<TR>
					<TD WIDTH="1%" nowrap>
						<INPUT TYPE="checkbox" NAME="nodes" OnClick="javascript:SelectAllNodes()"><A HREF="javascript:SelectAllNodes2()">{trans("Select All<!nodes>")}</A>
					</TD>
					<TD ALIGN="left">
						 <INPUT TYPE="checkbox" NAME="setwarnings[warnon]" ID="warnon" OnClick="switchbox(this);"{if $warnon}CHECKED{/if}><A HREF="javascript:switchbox1()">{trans("Enable")}</A>
						 / <INPUT TYPE="checkbox" NAME="setwarnings[warnoff]" ID="warnoff" OnClick="switchbox(this);" {if $warnoff}CHECKED{/if}><A HREF="javascript:switchbox2()">{trans("Disable")}</A>
					</TD>
					<TD ALIGN="RIGHT">
						<A HREF="javascript:document.setwarnings.submit()">{trans("Submit")} <IMG SRC="img/save.gif" ALT=""></A>
					</TD>
				</TR>
                            </TBODY>
			</TABLE>
		</TD>
	</TR>
</TABLE>
</FORM>

<SCRIPT type="text/javascript">
<!--//
	$(function() {
		$('form[name="setwarnings"] [name="setwarnings[message]"]').focus();
	});
//-->
</SCRIPT>

{/block}
